Hi all,
I am using the date picket for reservations in a restaurant. With the code below from the Wiki I have managed to block certain dates in the Calendar. What I also want to do is to block out all the mondays and tuesdays because we are closed then. I have looked at the .js examples and tried some things but was not succesfull so far. Can anyone provide me with the code to be used.
Many Thanks,
KooTjoo
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select ('DATE(book_bookingstartdate)')
->from('fab_booking');
$myDb->setQuery($myQuery);
$bookedDates = $myDb->loadColumn();
$begin = new DateTime();
$end = new DateTime('2016-12-31');
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$myAllowedDates = array();
foreach( $period as $dt ) {
$thisDate = $dt->format("Y-m-d");
if (!in_array($thisDate, $bookedDates)) {
$myAllowedDates[] = $thisDate;
}
}
return $myAllowedDates;
I am using the date picket for reservations in a restaurant. With the code below from the Wiki I have managed to block certain dates in the Calendar. What I also want to do is to block out all the mondays and tuesdays because we are closed then. I have looked at the .js examples and tried some things but was not succesfull so far. Can anyone provide me with the code to be used.
Many Thanks,
KooTjoo
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select ('DATE(book_bookingstartdate)')
->from('fab_booking');
$myDb->setQuery($myQuery);
$bookedDates = $myDb->loadColumn();
$begin = new DateTime();
$end = new DateTime('2016-12-31');
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$myAllowedDates = array();
foreach( $period as $dt ) {
$thisDate = $dt->format("Y-m-d");
if (!in_array($thisDate, $bookedDates)) {
$myAllowedDates[] = $thisDate;
}
}
return $myAllowedDates;