booking state

Help with installation and general calendar setttings

booking state

Postby zomba » Sat May 15, 2010 10:30 pm

Chris,
thank you very much for your calendar.

I really would like to use it, but i can't figure out one problem.
Could you give me a hint where to look to fix it?

Its about the booking state in the admin page Bookings.
When I press a date in order to change the state, the date will go from
"Booked" to "Booked am", but no further. No matter how often I click
on the date, the date will be "Booked am".

I refreshed all the files on my server (changed nothing) put it in another map,
made another db, put every file 777...and it still gives this error..

I really hope you ( or anyone else) can help me,

with regards, Zomba
zomba
 
Posts: 10
Joined: Sat May 15, 2010 10:08 pm

Re: booking state

Postby chris » Sun May 16, 2010 9:52 am

Hi,
I'm sure that I have answered this recently on the forum but I can't seem to find the thread :(

This appears to be a problem with "some" php instalations. However I haven't yet been able to identify the reason behind this error.

Anyway, there is a simple solution that should work.

In the ajax file that updates the states:
"ac-includes" > "ajax" > "update_calendar.ajax.php"
could you try chaning this code (line 85 approx):

Code: Select all
foreach($list_states as $id=>$val){
        if($id==$current_state_id) break;
        //      advance the pointer to next
         next($list_states);
         //     stop if id is the same as current

}


to this:

Code: Select all
foreach($list_states as $id=>$val){
   next($list_states);
   if($id==$current_state_id) break;
}


Change that and it should work ok.

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: booking state

Postby zomba » Sun May 16, 2010 11:37 am

It's working, thank you very much! :D
zomba
 
Posts: 10
Joined: Sat May 15, 2010 10:08 pm

Re: booking state

Postby zomba » Tue Oct 19, 2010 1:23 pm

And if it happens again, change it back :)
zomba
 
Posts: 10
Joined: Sat May 15, 2010 10:08 pm

Re: booking state

Postby Rawthey » Thu Jun 23, 2011 4:27 pm

chris wrote:Hi,
I'm sure that I have answered this recently on the forum but I can't seem to find the thread :(

This appears to be a problem with "some" php instalations. However I haven't yet been able to identify the reason behind this error.

Anyway, there is a simple solution that should work.

In the ajax file that updates the states:
"ac-includes" > "ajax" > "update_calendar.ajax.php"
could you try chaning this code (line 85 approx):

Code: Select all
foreach($list_states as $id=>$val){
        if($id==$current_state_id) break;
        //      advance the pointer to next
         next($list_states);
         //     stop if id is the same as current

}


to this:

Code: Select all
foreach($list_states as $id=>$val){
   next($list_states);
   if($id==$current_state_id) break;
}


Change that and it should work ok.

Chris

I run the same calendar on 2 different servers with php versions 5.0.4 and 5.3.6. The original script works fine with 5.3.6 but breaks with 5.0.4. Applying the above fix cures the problem with 5.0.4 but causes every alternate state to be skipped with 5.3.6.

I think the next($list_states) line is superfluous, if I remove it the script works fine with both versions of php.
Code: Select all
      //   loop though states array until we find this one
      foreach($list_states as $id=>$val){
         if($id==$current_state_id) break;
      }

I've done a few tests with a simplified script on each server and it appears that next() has no effect on the iteration of the foreach loop but it does influence the value of key($list_states) which is seen after breaking out of the loop, this effect is different between the 2 php versions. If next() is not invoked then key($list_states) on breaking out of the loop is that of the next item to be selected, irrespective of which php version I'm using.
Rawthey
 
Posts: 4
Joined: Mon Jun 06, 2011 7:25 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron