Forums

Calender for Hotel Reservations

duvru 17 Jun, 2009
Greetings All (newbie here) :o

I've been looking into using Chronoform (which looks great at first sight), but have an issue.

I want to use the default calender function (http://www.electricprism.com/aeron/calendar/) for a hotel reservation form. I've added two calenders, one for arrival_date and another for departure_date. What i want to achieve is:

1. The arrival_date cannot be prior to today
2. The departure_date cannot be on or prior to the arrival_date - that is at least arrival_date plus 1 day

Can this be acheived? Any assistance would be much appreciated.
GreyHead 17 Jun, 2009
Hi duvru,

teh instructions for using custom calendar settings are here - if you combine these with the dual-calendar settings from the link you posted this should be straightforward.

Bob
duvru 17 Jun, 2009
Thx Greyhead

I was using the documents you mentioned but could only get it to work with one of the calenders. Got a little confused with the dual calender settings.

How do i merge this:

myCal = new Calendar({
  day1: { monthyear1: 'Y-m', day1: 'd' },
  day2: { monthyear2: 'Y-m', day2: 'd' },
  day3: { monthyear3: 'Y-m', day3: 'd' }
}, { pad: 2 }); 


into:

<?php
$doc = & JFactory::getDocument();
$script = "
window .addEvent('domready', function() {
  myCal_date_0 = new Calendar({
    date_0: 'd/m/Y'
  }, {
    classes: ['dashboard'],
    blocked: ['0 * * 0,6'],
    direction: 7
  });
});
";
$doc->addScriptDeclaration($script);
?>
duvru 18 Jun, 2009
Only took a couple of days, but it's been solved 😀

Was not thinking like a coder 🙄

Cheers again
GreyHead 19 Jun, 2009
Hi dubru,

Well done - can you post the answer?

Bob

PS It was no my to-do list but didn't make it to the top in time.
duvru 19 Jun, 2009
No laughing, i'm not a coder. If anyone know's a simpler way then please add ...

1. Remove autogenerated fields as mentioned in GreyHeads post.
2. Add code to form html:

<?php
$doc = & JFactory::getDocument();
$script = "
window .addEvent('domready', function() {
  arrival_date = new Calendar({
    arrival_date: 'F j, Y',
	departure_date: 'F j, Y'
  }, {
    classes: ['dashboard'],
	direction: 0.5,
	pad: +1
  });
});
";
$doc->addScriptDeclaration($script);
?>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 150px;">Arrival Date:</label>
    <input name="arrival_date" type="text" class="cf_datetime required" id="arrival_date" title="Please select an arrival date" value='<?php
echo date("F")." ".date("j").", ".date("Y");
?>'
 size="20" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 150px;">Departure Date:</label>
    <input class="cf_datetime required" title="Please select a departure date" size="20" id="departure_date" name="departure_date" value='<?php
$tommorrow = date("j")+1;
echo date("F")." ".$tommorrow.", ".date("Y");
?>'
type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>


Note: The php code in the form <div> tags auto fills the fields arrival_date and departure_date with todays and tomorrows date; this then allows the calender script to process the rules set. This is the part which may be done better, but hey "it works" 😀
GreyHead 19 Jun, 2009
Hi duvru,

Thank you - looks good to me.

Bob
This topic is locked and no more replies can be posted.