Page 1 of 1

Logic

Posted: Mon Nov 07, 2005 4:55 pm
by adam
Hi Marco

I have been playing around with a few things in the availabilty template :oops: and messed something up... Do you think you could explain to me the logic the script uses to see if there is availablty within the hotel?

Cheers

Posted: Mon Nov 07, 2005 7:50 pm
by marco
Hi Adam,

the core function that checks availability is liberasettimane in the file liberasettimane.php. "Libera settimane" means "to free weeks", as originally php-residence was only for weekly periods, so each time you see "settimane" you can consider that as referring to "days". Liberasettimane works recursively (it calls itself) until it frees an apartment, but I think you are more interested in how it is used in the availability template.

If you open the file modello_disponibilita.php, in the includes/templates directory, after some checking of the passed variables the fuction tab_a_var is called, its role is to transer the reservatins data from the database table to some variables, these variables are passed later to liberasettimane. The requested apartments (you can have multiple requests) are stored in $app_richiesti. If there are some assignment rules 1 ($num_app_agenzia != 0) before the first attempt of liberasettimane some fake reservations are inserted in the periods corresponding to those rules.
Then if there were no rules 1 or it was not possible to free the requested apartments, liberasettimane is called (again or for the first time). If the requested apartments have been freed $fatto_libera will be set to "SI".

That's more or less how it works, hope it was sufficiently clear.

Marco

Posted: Fri Nov 11, 2005 9:22 am
by adam
Hi Marco

That should be enough info... Thanks!
Are you planning to release a new version soon? If so what can we expect to change?

Thanks again

Posted: Mon Nov 14, 2005 7:26 pm
by marco
The new version is available today, it's not a major release, I will discuss the changelog in a new thread.

Marco