Chronoforms Booking/Reservation form

amorz 18 Jan, 2013
Hi all,

I have a question about the calendar. It has a database link with the form. I would like to disable date ranges in the calendar that are stored in the databse. Is this possible within the chronoforms system?

King Regards,

Amorz
GreyHead 18 Jan, 2013
Hi Amorz,

Yes, this is possible, we looked at this once before. There is a setting that allows you to include or exclude certain dates.

Here is the extract from the MooTools DatePicker docs

availableDates: (*object*, defaults to null) When only a few dates should be selectable. An object like {2011: {1: [19, 29, 31], 3: [5, 19, 24]}} with all the dates (year -> months -> days).
invertAvailable: (*boolean*, defaults to false) Invert the availableDates option.


You'd need to look up the dates in the database, then process the results into a JavaScript array like this.

Bob
amorz 18 Jan, 2013
Hi Greyhead,

Ok i have the dates in the database in the colums 'aankomst' and 'vertrek'. Nou i can't get the dates to iterate in PHP. i got basic knowlege of PHP. I've managed it to create a date range array. at this point i get lost.. :?

This is the loop output

Array ( [0] => 2013-01-21 [1] => 2013-01-22 [2] => 2013-01-23 [3] => 2013-01-24 ) 
Array ( [0] => 2013-01-26 [1] => 2013-01-27 [2] => 2013-01-28 [3] => 2013-01-29 ) 
Array ( [0] => 2013-01-17 [1] => 2013-01-18 [2] => 2013-01-19 [3] => 2013-01-20 [4] => 2013-01-21 [5] => 2013-01-22 [6] => 2013-01-23 [7] => 2013-01-24 [8] => 2013-01-25 ) 


Kind Regards,

Amorz
GreyHead 19 Jan, 2013
Hi Amorz,

There's a version of the code you need in this FAQ - it looks a bit complicated because it is producing the rather odd looking JavaScript array.

Please take a look and see if you can adapt it. If not post the names of the variables you have extracted here (Debugger output is good) and I'll see if I can make it work).

Bob

PS Sorry not to have linked to the FAQ earlier, I'd forgotten that the example had been posted.
amorz 23 Jan, 2013
Hi Greyhead,

Sorry for the late response..

I have found the solution for my problem. I have managed it with the jquery datepicker.
Thank you very much for your help.

Kind Regards,

Amorz


var $notAvailable= new Array("01-02-2013","25-01-2013","26-01-2013","27-01-2013","28-01-2013","29-01-2013","30-01-2013","31-01-2013");
var $halfAvailable = new Array("01-02-2013","25-01-2013");

function checkAvailability(mydate){
var $return=true;
var $returnclass ="available";
$checkdate = jQuery.datepicker.formatDate("dd-mm-yy", mydate);
for(var i = 0; i < $notAvailable.length; i++)
    {    
       if($notAvailable[i] == $checkdate)
          {
		if( jQuery.inArray($notAvailable[i], $halfAvailable ) !== -1 ) {

			$return = true;
			$returnclass= "halfavailable";
 
		}else{
			$return = false;
			$returnclass= "unavailable";
		}     
	}
}
return [$return,$returnclass];
}
jQuery("#datepicker").datepicker({    
    minDate:0,
    numberOfMonths: 1,
    showButtonPanel: true,
    dateFormat: "dd-mm-yy",
    beforeShowDay: checkAvailability
});
This topic is locked and no more replies can be posted.