Page 2 of 2

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 3:54 pm
by MrRundog
Only dates where bookingID(in the table) is equal to the bookingID (in my session) can be modified - However I would still need to see what dates are unavailable for the id_item(in my case that is a room)

Shall I proceed with your code and take it from there?

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 4:08 pm
by chris
If I understand you correctly, the user can modify their bookings removing or adding more from all the available dates - but are NOT able to touch dates that are booked as other bookinID's. is this correct?

If so, you would need to change this in the function:
Code: Select all
if($booked_days[$this_date]["id_booking"]>0){
            //   date with idbooking - NO link
            //   you could also define diferent style here to "highlight" the dates
            $date_alt      =   $lang["day_".$week_day.""].' '. $date_format.' booked - id: '.$booked_days[$this_date]["id_booking"];
         }
         elseif($show_link==1)
         {
            $date_alt       =    $lang["modify_availability_for"].' '.$lang["days"][$week_day].' '. $date_format;
            $day_link_start   =   '<a href="#" onclick="ajax_mod_state(\''.$id.'\',\''.$this_date.'\',\''.$day_counter.'\',event); return false"  title="'.$date_alt.'" class="cal_day">';
            $day_link_end   =   '</a>';
         }

into something like this:
Code: Select all
if($show_link==1){
   //only do this if we are in "modify" mode
   //   make all dates modifiable
   $date_alt       =    $lang["modify_availability_for"].' '.$lang["days"][$week_day].' '. $date_format;
   $day_link_start   =   '<a href="#" onclick="ajax_mod_state(\''.$id.'\',\''.$this_date.'\',\''.$day_counter.'\',event); return false"  title="'.$date_alt.'" class="cal_day">';
   $day_link_end   =   '</a>';
            
   if($booked_days[$this_date]["id_booking"]==$_SESSION["bookingID"]){
      //   mark the dates booked under the current session bookingID
      $date_alt      =   'BOOKING ID: '.$_SESSION["bookingID"].' '.$date_alt;
   }elseif($booked_days[$this_date]["id_booking"]>0){
      // ie the date is booked by other
      //   remove links from dates
      $date_alt      =   $lang["day_".$week_day.""].' '. $date_format.' booked - You can not modify it.';
      $day_link_start   ="";
      $day_link_end   ="";
   }
}


I hope this is getting nearer the mark ;)

Chris

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 4:10 pm
by MrRundog
Yes that's correct - Sorry for the confusion there - Now you say I should change the code above - Does that require any changes previously mentioned or is the code above all that needs changing?

Andy

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 4:18 pm
by chris
just that bit which is in the function.

Chris

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 5:50 pm
by MrRundog
Success - It all works as expected - tha's to say "(I cannot alter a booking which is not the booking that i am working with now...held in my session.)"

one piece of code that causes errors in display
Code: Select all
if(array_key_exists($this_date,$booked_days)){
            //echo "<br>".$booked_days[$this_date];
            if($booked_days[$this_date]["state"]=="am")      $day_image='cal_am_'.$day_counter.'.png';
            elseif($booked_days[$this_date]["state"]=="pm")   $day_image='cal_pm_'.$day_counter.'.png';
            elseif($booked_days[$this_date]["state"]=="prv")   $day_image='cal_prv_'.$day_counter.'.png';
            else                     $day_image='cal_on_'.$day_counter.'.png';
         }




This causes the days to repeat - this however is not a problem in my case as I actually don't need the above - i'm not using am pm etc - as a room is booked per 24hr period.

So - Thanks once again for a great job.
Andy

Re: Passing a new value to the table

PostPosted: Sun Apr 13, 2008 5:53 pm
by chris
OK, good to hear that you got it working.
I will double check that block of code to see what I did wrong :oops:

Chris