function show_master_month($group) { $group_names = array("foodbank" => "Food Bank", "foodpantry" => "Food Pantry", "soupkitchen" => "Soup Kitchen"); $days = array("Sun" => "Sunday", "Mon" => "Monday", "Tue" => "Tuesday", "Wed" => "Wednesday", "Thu" => "Thursday", "Fri" => "Friday", "Sat" => "Saturday"); $fpdays = array("Sun" => "Sunday", "Mon" => "Monday", "Tue" => "Tuesday", "Wed930" => "Wed 9:30", "Wed1100" => "Wed 11:45", "Thu" => "Thursday", "Fri" => "Friday", "Sat" => "Saturday"); $weeks = array(1 => "1st", 2 => "2nd", 3 => "3rd", 4 => "4th", 5 => "5th"); if ($group == "foodpantry") { $thisdays = $fpdays; } else { $thisdays = $days; } echo '<br><table id="calendar" align="center" >' . '<tr class="weekname"><td colspan="' . (sizeof($thisdays) + 2) . '" ' . 'bgcolor="#99B1D1" align="center" >' . $group_names[$group] . ' Master Schedule</td></tr>'; echo '<tr><td bgcolor="#99B1D1"></td>'; foreach ($thisdays as $day => $dayname) { echo '<td class="dow" align="center"> ' . $dayname . ' </td>'; } echo '<td bgcolor="#99B1D1"></td></tr>'; $shiftdefaultsizes = array("foodbank" => 8, "foodpantry" => 6, "soupkitchen" => 9); foreach ($weeks as $week_no => $week) { echo '<tr><td bgcolor="#99B1D1">' . $week . '</td>'; foreach ($thisdays as $day => $dayname) { $master_shift = retrieve_dbMasterSchedule($group . $day . $week_no); /* retrieves a MasterScheduleEntry for this group, day, and week of the month */ if ($master_shift) { echo do_shift($master_shift); } else { if ($group == "foodpantry" && ($day == "Sun" || $day == "Tue" || $day == "Thu")) { $master_shift = new MasterScheduleEntry($group, $day, $week_no, 0, "", ""); insert_dbMasterSchedule($master_shift); echo do_shift($master_shift); } else { if ($group == "foodbank" && ($day == "Sat" || $day == "Sun") || $group == "soupkitchen" && $day == "Sat") { $master_shift = new MasterScheduleEntry($group, $day, $week_no, 1, "", ""); insert_dbMasterSchedule($master_shift); echo do_shift($master_shift); } else { if ($group == "soupkitchen" && $day == "Sun") { $master_shift = new MasterScheduleEntry($group, $day, $week_no, 0, "", ""); insert_dbMasterSchedule($master_shift); echo do_shift($master_shift); } else { $master_shift = new MasterScheduleEntry($group, $day, $week_no, $shiftdefaultsizes[$group], "", ""); insert_dbMasterSchedule($master_shift); echo do_shift($master_shift); } } } } } echo '<td bgcolor="#99B1D1">' . $week . '</td></tr>'; } echo '<tr class="weekname"><td colspan="' . (sizeof($thisdays) + 2) . '" ' . 'bgcolor="#99B1D1" align="center" >' . $group_names[$group] . ' Master Schedule</td></tr>'; echo "</table>"; }
function show_master_schedule($venue) { $wkndgroups = array("1st", "2nd", "3rd", "4th", "5th"); $groups = array("odd", "even"); $shifts = array("9-12", "12-3", "3-6", "6-9", "night"); $venues = array("portland" => "Portland House", "bangor" => "Bangor House"); $days = array("Mon" => "Monday", "Tue" => "Tuesday", "Wed" => "Wednesday", "Thu" => "Thursday", "Fri" => "Friday"); echo '<p><table id="calendar" align="center" ><tr class="weekname"><td colspan="' . (sizeof($days) + 2) . '" ' . 'bgcolor="ffdddd" align="center" >' . $venues[$venue] . " Master Schedule -- weekday shifts"; echo '</td></tr><tr><td bgcolor="#ffdddd"> </td>'; foreach ($days as $day => $dayname) { echo '<td class="dow" align="center"> ' . $dayname . ' </td>'; } echo '<td bgcolor="#ffdddd"></td></tr>'; $columns = sizeof($days); foreach ($groups as $group) { $showgroup = $group; foreach ($shifts as $hour) { echo "<tr><td class=\"masterhour\"> " . $showgroup . " " . $hour . "</td>"; foreach ($days as $day => $dayname) { $master_shift = retrieve_dbMasterSchedule($group . ":" . $day . ":" . $hour . ":" . $venue); if ($master_shift) { echo do_shift($master_shift, 1); } else { $master_shift = new MasterScheduleEntry($venue, $day, $group, $hour, 0, "", ""); echo do_shift($master_shift, 0); } } echo "<td class=\"masterhour\">" . $showgroup . " " . $hour . "</td></tr>"; $showgroup = " "; } } echo "</table>"; $satshiftsportland = array("10-1", "1-4", "night"); $sunshiftsportland = array("9-12", "2-5", "5-9"); $satshiftsbangor = array("9-5", "night"); $sunshiftsbangor = array("9-5", "5-9"); if ($_SESSION['venue'] == "portland") { $satshifts = $satshiftsportland; $sunshifts = $sunshiftsportland; } else { $satshifts = $satshiftsbangor; $sunshifts = $sunshiftsbangor; } echo "</p><p> <table align='center'><tr><td>"; echo '<table id="calendar" align="left" ><tr class="weekname"><td colspan="2" ' . 'bgcolor="ffdddd" align="center" >weekend shifts'; echo '</td></tr><tr><td bgcolor="#ffdddd"> </td>'; echo '<td class="dow" align="center"> Saturday </td>'; echo '<td bgcolor="#ffffff"></td></tr>'; foreach ($wkndgroups as $group) { $showgroup = $group; foreach ($satshifts as $hour) { echo "<tr><td class=\"masterhour\"> " . $showgroup . " " . $hour . "</td>"; $day = "Sat"; $dayname = "Saturday"; $master_shift = retrieve_dbMasterSchedule($group . ":" . $day . ":" . $hour . ":" . $venue); if ($master_shift) { echo do_shift($master_shift, 1); } else { $master_shift = new MasterScheduleEntry($venue, $day, $group, $hour, 0, "", ""); echo do_shift($master_shift, 0); } echo "<td bgcolor='#ffffff'></td></tr>"; $showgroup = " "; } } echo "</table>"; echo "</td><td> </td><td>"; echo '<table id="calendar" align="center"><tr class="weekname"><td colspan="2" ' . 'bgcolor="ffdddd" align="center" >'; echo '</td></tr><tr><td bgcolor="#ffdddd"> </td>'; echo '<td class="dow" align="center"> Sunday </td>'; echo '<td bgcolor="ffffff" ></td></tr>'; foreach ($wkndgroups as $group) { $showgroup = $group; foreach ($sunshifts as $hour) { echo "<tr><td class=\"masterhour\"> " . $showgroup . " " . $hour . "</td>"; $day = "Sun"; $dayname = "Sunday"; $master_shift = retrieve_dbMasterSchedule($group . ":" . $day . ":" . $hour . ":" . $venue); if ($master_shift) { echo do_shift($master_shift, 1); } else { $master_shift = new MasterScheduleEntry($venue, $day, $group, $hour, 0, "", ""); echo do_shift($master_shift, 0); } echo "<td bgcolor='#ffffff'></td></tr>"; $showgroup = " "; } } echo "</table>"; echo "</td></tr></table>"; }
function show_master_week($group, $days) { echo '<br><table id="calendar" align="center" ><tr class="weekname"><td colspan="' . (sizeof($days) + 2) . '" ' . 'bgcolor="#99B1D1" align="center" >' . $group; if (sizeof($days) > 2) { echo ' weekday Master Schedule'; } else { echo ' weekend Master Schedule'; } echo '</td></tr><tr><td bgcolor="#99B1D1"> </td>'; foreach ($days as $day => $dayname) { echo '<td class="dow" align="center"> ' . $dayname . ' </td>'; } echo '<td bgcolor="#99B1D1"></td></tr>'; $free_hour = []; $columns = sizeof($days); for ($i = 0; $i < 12 * $columns; $i++) { $free_hour[] = true; } for ($hour = 9; $hour < 21; $hour++) { echo "<tr><td class=\"masterhour\">" . show_hours($hour) . "</td>"; $i = 0; foreach ($days as $day => $dayname) { $master_shift = retrieve_dbMasterSchedule("weekly" . $day . $group . "-" . $hour); /* retrieves a MasterScheduleEntry whose start time is $hour */ if ($master_shift) { $shift_length = $master_shift->get_end_time() - $master_shift->get_start_time(); echo do_shift($master_shift, $shift_length); for ($j = $hour; $j < $hour + $shift_length; $j++) { $free_hour[$columns * ($j - 9) + $i] = false; } } else { if ($free_hour[$columns * ($hour - 9) + $i]) { // $t = $hour . "-" . ($hour+1); $master_shift = new MasterScheduleEntry("weekly", $day, $group, $hour, $hour + 1, 1, "", "", ""); echo do_shift($master_shift, 0); } } $i++; } echo "<td class=\"masterhour\">" . show_hours($hour) . "</td></tr>"; } echo "<tr><td class=\"masterhour\">" . "overnight" . "</td>"; foreach ($days as $day => $dayname) { $master_shift = retrieve_dbMasterSchedule("weekly" . $day . $group . "-overnight"); if ($master_shift) { echo do_shift($master_shift, 1); } else { $master_shift = new MasterScheduleEntry("weekly", $day, $group, "overnight", 0, 1, "", "", ""); echo do_shift($master_shift, 0); } } echo "<td class=\"masterhour\">" . "overnight" . "</td></tr>"; echo "</table>"; }