Needing to schedule performance and rehearsal space in a shared area, I set up a modified copy of phpScheduleIt for Your Theatre a while back. When the theatre is scheduling, they are somewhat sensitive to holidays. It’s a volunteer community theatre, and many people take vacations and trips around the holidays, and of course, audience may also avoid coming out on certain holidays.
To help with this end, I added a holiday table and support to phpScheduleIt. The day, week, and month calendars will display the holiday name as appropriate. The basic reservation form also shows the holiday name.
First, I added a new table to the database, ‘datenames’ has five fields:
datename_id int(11) auto_increment //unique id, for editor datename_year int(11) //holiday year, 0=all datename_month int(11) //holiday month datename_day int(11) //holiday day datename_name varchar(50) //holiday name
I then created a simple routine (in lrhschedhelper.php) to return the holiday name for any given date.
// Look up the given date and determine
// if there is a name assigned
function lrh_GetDayName($aDate,$aDB) {
if ($aDB==null) return ""; //need to pass access to database
// get the individual date parts
list($d,$m,$y) = explode(' ',date('d m Y', $aDate));
$Q="SELECT * FROM datenames "
."WHERE (datename_day='$d') "
." AND (datename_month='$m') "
." AND ( (datename_year='$y') OR (datename_year='0') ) "
;
$p = $aDB->prepare($Q);
$r = $aDB->execute($p);
// get all the holidays for the date
while ($rs = $r->fetchRow()) {
$l[] = $rs['datename_name'];
}
$r->free();
if (count($l)==0) return "";
else return implode($l[0]['datename_name'];
}
Now I have a function I can pass the date of interest to, and receive either blank or the holiday name. I used phpMyAdmin to populate ‘datenames’, but I have plans to add an editor to the console at some point.
Here’s a sampling of the data I added to the table:
Year Month Day Name 0 12 25 Christmas //Same day every year 0 1 1 New Year //Same day every year 2010 11 25 Thanksgiving //Different day every year 2011 11 24 Thanksgiving
You can figure it out from there. Search an online site for a holiday calendar and fill it in for a few years in advance.
Now that all the holiday information is on hand and online, it’s time to display it in the calendars.
The first place is in lib\Schedule.class.php function get_display_date().
function get_display_date() {
$r=Time::formatReservationDate($this->_date['current']
,$this->startDay,null,'schedule_daily');
$dn=lrh_GetDayName($this->_date['current'],$this->db->db);
if ($dn<>"") $r.=",<br>".$dn;
return $r;
}
Another change is in templates\mycalendar.template.php function print_day_reservations. You need to find the day_count loop:
for ($day_count = 0; $day_count < $days; $day_count++)
We’re looking for the href:
<a href="schedule.php?date='
At the end of which is:
'</a></td>';
We’re inserting the modification between the </a> and </td>:
'</a>'; $dn=lrh_GetDayName($datestamps[$day_count],$aDB); if ($dn<>"") echo "<br><b>$dn</b>"; echo '</td>';
Easy, right? In the same file, a similar change is made to print_month_reservations. Find:
echo "<td class= ...etc $currentDate=mktime(0,0,0,$date_vars['1'],$currentDay,$date_vars['2']);
The echo line is moved after the $currentDate line, and a table is inserted into the output:
$currentDate=mktime(0,0,0,$date_vars['1'],$currentDay,$date_vars['2']);
$holiday=lrh_GetDayName($currentDate,$aDB);
echo "<td class=\"$class\">";
echo "<table width='100%' cellpadding=0 cellspacing=0>";
echo "<tr><td align='left'><b>$holiday</b></td><td align='right'>";
echo "<a class=\"MyCalDateNumber\" "
."href=\"schedule.php?date={$actualCurrentMonth}"
."-{$actualCurrentDay}-{$actualCurrentYear}&"
."scheduleid=$scheduleid\">";
echo "$actualCurrentDay</a></td></tr></table>\n";
That takes care of the calendar displays. The last change is to show the holiday in the reservation window. We change print_time_info in templates\reserve.template.php. Find where $display_start_date and $display_end_date are set:
$display_start_date = Time::getAdjustedDate($res->get_start_date() , $res->get_start()); $display_end_date = Time::getAdjustedDate($res->get_end_date() , $res->get_end());
Add in:
$sdn=lrh_GetDayName($display_start_date,$res->db->db); $edn=lrh_GetDayName($display_end_date,$res->db->db); $sdn=(($sdn.$edn)<>'')?"<br><b>$sdn</b>":""; $edn=(($sdn.$edn)<>'')?"<br><b>$edn</b>":"";
Now, insert $sdn and $edn into the output, there are two each of these:
Time::formatDate($display_start_date, '', false) .$sdn Time::formatDate($display_end_date, '', false) .$edn
You also need to be sure to include the new code file, add this at the top of files rescalendar.php and templates\auth.template.php:
require_once('lrhschedulehelper.php');
That should do it!

