So what i have - is a function to get the dates between ranges and returns them as an array.
I then wanted to put those dates into a bit of javascript on my template page.
Just can't seem to find a way to get the code to put the values on the page. Any help would be great thanks!
What i have so far...
public function getItemBookedOutDates() {
$Params = $this->getURLParams();
$itemDatesBookedOutOn = new item_booking();
$itemDatesBookedOutOn = item_Booking::get()->filter(array(
'Item' => $Params['ID']
));
$DateList = new ArrayList();
foreach($itemDatesBookedOutOn as $item) {
$days = $this->createDateRangeArray($item->itemBookingFrom, $item->itemBookingTo);
$item->DateUnavailable = $days;
$DateList->push($item);
}
return $this->DateList;
}
function createDateRangeArray($strDateFrom,$strDateTo)
{
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange=array();
$iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2), substr($strDateFrom,8,2), substr($strDateFrom,0,4));
$iDateTo=mktime(1,0,0,substr($strDateTo,5,2), substr($strDateTo,8,2), substr($strDateTo,0,4));
if ($iDateTo >= $iDateFrom)
{
array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry
while ($iDateFrom < $iDateTo)
{
$iDateFrom += 86400; // add 24 hours
array_push($aryRange,date('Y-m-d',$iDateFrom));
}
}
return $aryRange;
}