The part is red, is the additional code.
First I have create to custom fields. Date From and Date To. This is neither the id of name of the custom field, its the description. So just adding the fields and then looking at the source code, I see there names (its a db id)
No that I have the control's names, I added the parts in red.
First, I've linked to the css and js files of the Zapatec Calendar.
Second, I said that if my field title contains the word "date", I know it is the correct control. I give it a name and id (id is important because the calendar control need to refer back to it)
I also added a button after it, the button that launch the calendar widget.
The buttons name is "button_"+nameOfControl
And lastly I've added my Zapatec calendar configuration setting and some functions to control that the departure date should be >= to the arrival date.
The variable "doCalendar" is there to prevent the js to run if my date fields is not there (because I use templates and the date fields are only applicable when you log a ticket for the reservation department)
Code:
<link rel="stylesheet" href="includes/zapatec/zpcal/themes/system.css" />
<link rel="stylesheet" href="includes/zapatec/zpcal/themes/layouts/tiny.css" />
<script type="text/javascript" src="includes/zapatec/utils/zapatec.js"></script>
<script type="text/javascript" src="includes/zapatec/zpcal/src/calendar.js"></script>
<script type="text/javascript" src="includes/zapatec/zpcal/lang/calendar-en.js"></script>
<script type="text/javascript">var doCalender = false;</script>
<{foreach key=key value=cfgroup from=$cfrender}>
<fieldset class="swiftfieldset">
<legend><{$cfgroup[value]}></legend>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<{foreach key=fieldkey value=field from=$cfgroup[fields]}>
<{if $field[type] == "text"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%"><input id="<{$field[name]}>" name="<{$field[name]}>" type="text" size="25" class="swifttext" value="<{$field[value]}>">
<{if strpos($field[title], "Date")!== false}>
<script type="text/javascript">doCalender = true;</script>
<input style="font-size:10px" type="reset" value="..." id='button_<{$field[name]}>'>
<{/if}>
</td>
</tr>
<{elseif $field[type] == "password"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%"><input name="<{$field[name]}>" type="password" size="20" class="swifttext" value="<{$field[value]}>"></td>
</tr>
<{elseif $field[type] == "textarea"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%"><textarea name="<{$field[name]}>" cols="50" rows="5" class="swifttextarea"><{$field[value]}></textarea></td>
</tr>
<{elseif $field[type] == "select"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%"><select name="<{$field[name]}>" class="swiftselect">
<{foreach key=optionkey value=option from=$field[value]}>
<option value="<{$option[value]}>"<{if $option[selected] == 1}> selected<{/if}>><{$option[title]}></option>
<{/foreach}>
</select></td>
</tr>
<{elseif $field[type] == "selectmultiple"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%"><select name="<{$field[name]}>[]" size="5" style="width:160px;" class="swiftselect" multiple>
<{foreach key=optionkey value=option from=$field[value]}>
<option value="<{$option[value]}>"<{if $option[selected] == 1}> selected<{/if}>><{$option[title]}></option>
<{/foreach}>
</select></td>
</tr>
<{elseif $field[type] == "radio"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%">
<{foreach key=optionkey value=option from=$field[value]}>
<label for="<{$field[name]}>[<{$optionkey}>]"><input type="radio" id="<{$field[name]}>[<{$optionkey}>]" name="<{$field[name]}>" value="<{$option[value]}>"<{if $option[checked] == 1}> checked<{/if}> /> <span class="smalltext"><{$option[value]}></span><BR />
<{/foreach}>
</td>
</tr>
<{elseif $field[type] == "hidden"}>
<input type="hidden" name="<{$field[name]}>" value="<{$field[value]}>" />
<{elseif $field[type] == "plaintext"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="smalltext"><b><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span></b><br/><{$field[description]}> </span><{/if}></td>
<td width="70%"><span class="smalltext"><{$field[value]}></span></td>
</tr>
<{elseif $field[type] == "checkbox"}>
<tr>
<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}><br/><{$field[description]}> </span></td>
<td width="70%">
<{foreach key=optionkey value=option from=$field[value]}>
<label for="<{$field[name]}>[<{$optionkey}>]"><input type="checkbox" id="<{$field[name]}>[<{$optionkey}>]" name="<{$field[name]}>[<{$optionkey}>]" value="<{$option[value]}>"<{if $option[checked] == 1}> checked<{/if}> /> <span class="smalltext"><{$option[value]}></span><BR />
<{/foreach}>
</td>
</tr>
<{/if}>
<{/foreach}>
</table>
</fieldset>
<{/foreach}>
<script type="text/javascript">
<!-- to hide script contents from old browsers
var startDate; var endDate;
function resetDates() {startDate = endDate = null;}
function filterDates1(cal) {
startDate = new Date(cal.date)
startDate.setHours(0,0,0,0)
if (endDate == null) {
Zapatec.Calendar.setup({
inputField : "5f4b712635",
button : "button_5f4b712635", ifFormat : "%Y-%m-%d",
date : cal.date,
showsTime : false,
dateStatusFunc : disallowDateBefore,
onUpdate : filterDates2,
noHelp : true
});
}
}
function filterDates2(cal) {
var date = cal.date;
endDate = new Date(cal.date)
endDate.setHours(0,0,0,0)
}
function disallowDateBefore(dateCheckOut) {
dateCheckOut.setHours(0,0,0,0)
if ((startDate != null) && startDate > dateCheckOut)
return true;
var now = new Date()
now.setHours(0,0,0,0)
if (dateCheckOut < now)
return true;
return false;
}
function disallowDateAfter(dateCheckIn) {
dateCheckIn.setHours(0,0,0,0)
if ((endDate != null) && dateCheckIn > endDate)
return true;
var now = new Date()
now.setHours(0,0,0,0)
if (dateCheckIn < now)
return true;
return false;
}
// end hiding contents from old browsers -->
</script>
<script type="text/javascript">
if (doCalender) {
var cal = new Zapatec.Calendar.setup({
inputField : "69873f6168",
button : "button_69873f6168",
ifFormat : "%Y-%m-%d",
showsTime : false,
dateStatusFunc : disallowDateAfter,
onUpdate : filterDates1,
noHelp : true
});
Zapatec.Calendar.setup({
inputField : "5f4b712635",
button : "button_5f4b712635",
ifFormat : "%Y-%m-%d",
showsTime : false,
dateStatusFunc : disallowDateBefore,
onUpdate : filterDates2,
noHelp : true
});
}
</script> Craig, with 2000+ post

... you may as well be staff !
Regards
Guss