<?php 
include 'header.php';
?>
    <div id="content">
        <?php 
$projectid = $_GET['project'];
$venue = $_GET['venue'];
include_once 'editProject.inc';
if ($projectid == "") {
    echo "<p>No Project ID Supplied.  Click on \"Calendar\" above to edit projects.</p>";
} else {
    $project = select_dbProjects($projectid);
    if (!$project instanceof Project) {
        echo "<p>Invalid Project ID Supplied.  Click on \"Calendar\" above to edit projects.</p>";
    } else {
        if (!process_fill_vacancy($_POST, $project, $venue) && !process_add_volunteer($_POST, $project, $venue) && !process_move_project($_POST, $project) && !process_change_times($_POST, $project)) {
            if (process_unfill_project($_POST, $project, $venue)) {
                $project = select_dbProjects($projectid);
            } else {
                if (process_add_slot($_POST, $project, $venue)) {
                    $project = select_dbProjects($projectid);
                } else {
                    if (process_clear_project($_POST, $project, $venue)) {
                        $project = select_dbProjects($projectid);
                    } else {
                        if (process_ignore_slot($_POST, $project, $venue)) {
                            $project = select_dbProjects($projectid);
                        }
                    }
                }
            }
    <?php 
include 'header.php';
?>
    <div id="content">
        <?php 
$shiftid = $_GET['shift'];
$venue = $_GET['venue'];
include_once 'editShift.inc';
if ($shiftid == "") {
    echo "<p>No Shift ID Supplied.  Click on \"Calendar\" above to edit shifts.</p>";
} else {
    $shift = select_dbShifts($shiftid);
    if (!$shift instanceof Shift) {
        echo "<p>Invalid Shift ID Supplied.  Click on \"Calendar\" above to edit shifts.</p>";
    } else {
        if (!process_fill_vacancy($_POST, $shift, $venue) && !process_add_volunteer($_POST, $shift, $venue) && !process_move_shift($_POST, $shift) && !process_change_times($_POST, $shift)) {
            if (process_unfill_shift($_POST, $shift, $venue)) {
                $shift = select_dbShifts($shiftid);
            } else {
                if (process_add_slot($_POST, $shift, $venue)) {
                    $shift = select_dbShifts($shiftid);
                } else {
                    if (process_clear_shift($_POST, $shift, $venue)) {
                        $shift = select_dbShifts($shiftid);
                    } else {
                        if (process_ignore_slot($_POST, $shift, $venue)) {
                            $shift = select_dbShifts($shiftid);
                        }
                    }
                }
            }
// Mon
$shiftname = $_GET['shift'];
// 9-12
$id = $group . ":" . $day . ":" . $shiftname . ":" . $venue;
$msentry = retrieve_dbMasterSchedule($id);
if (!$msentry) {
    $result = process_add_shift($_POST, $group, $day, $shiftname, $venue);
    if ($result) {
        $returnpoint = "viewSchedule.php?venue=" . $venue;
        echo "<table align=\"center\"><tr><td align=\"center\" width=\"442\">\n\t\t\t\t\t\t\t\t<br><a href=\"" . $returnpoint . "\">\n\t\t\t\t\t\t\t\tBack to Master Schedule</a></td></tr></table>";
    } else {
        echo "Failed to add a master schedule shift";
    }
} else {
    // if a shift is there, see what we can do to update it
    if (!process_fill_vacancy($_POST, $msentry) && !process_add_volunteer($_POST, $msentry) && !process_remove_shift($_POST, $msentry, $group, $day, $shiftname, $venue)) {
        if (process_unfill_shift($_POST, $msentry, $venue)) {
            // try to remove a person
        } else {
            if (process_add_slot($_POST, $msentry, $venue)) {
                // try to add a new slot
            } else {
                if (process_ignore_slot($_POST, $msentry, $venue)) {
                    //try to remove a slot
                }
            }
        }
        // we've tried to clear the shift, add a slot, or remove a slot;
        // so now display the shift again.
        $msentry = retrieve_dbMasterSchedule($id);
        $persons = get_persons($msentry->get_id());
			<div id="content">
				<?php 
include_once 'database/dbCrews.php';
include_once 'database/dbPersons.php';
include_once 'database/dbLog.php';
include_once 'editCrew.inc';
$crewid = $_GET['id'];
$group = substr($crewid, 9);
if ($crewid == "") {
    echo "<p>No Crew ID Supplied.  Click on \"Calendar\" above to edit crews.</p>";
} else {
    $crew = select_dbCrews($crewid);
    if (!$crew instanceof Crew) {
        echo "<p>Invalid Crew ID Supplied.  Click on \"Calendar\" above to edit crews.</p>";
    } else {
        if (!process_fill_vacancy($_POST, $crew, $group) && !process_add_volunteer($_POST, $crew, $group)) {
            if (process_unfill_crew($_POST, $crew, $group)) {
                $crew = select_dbCrews($crewid);
            } else {
                if (process_add_slot($_POST, $crew, $group)) {
                    $crew = select_dbCrews($crewid);
                } else {
                    if (process_clear_crew($_POST, $crew, $group)) {
                        $crew = select_dbCrews($crewid);
                    } else {
                        if (process_ignore_slot($_POST, $crew, $group)) {
                            $crew = select_dbCrews($crewid);
                        }
                    }
                }
            }
include_once 'domain/MasterScheduleEntry.php';
include_once 'database/dbLog.php';
if ($group == "" || $day == "" || $week_no == "") {
    echo "<p>Invalid schedule parameters.  Please click on the \"Master Schedule\" link above to edit a master schedule crew.</p>";
} else {
    if (retrieve_dbMasterSchedule($group . $day . $week_no) == false) {
        $result = process_set_times($_POST, $group, $day, $week_no);
        if ($result) {
            $returnpoint = "viewSchedule.php?group=" . $group;
            echo "<table align=\"center\"><tr><td align=\"center\" width=\"442\">\n\t\t\t\t\t\t\t\t<br><a href=\"" . $returnpoint . "\">\n\t\t\t\t\t\t\t\tBack to Master Schedule</a></td></tr></table>";
        } else {
            echo "<table align=\"center\" width=\"450\"><tr><td align=\"center\" colspan=\"2\"><b>\n\t\t\t\t\t\t\t\tAdding a New Master Schedule crew for " . $do_group_name($group) . ", " . do_week_name($week_no) . " " . do_day_name($day) . " " . "</b></td></tr>" . "<tr><td>\n\t\t\t\t\t\t\t\t\t<form method=\"POST\" style=\"margin-bottom:0;\">\n\t\t\t\t\t\t\t\t\t<select name=\"new_slots\">\n\t\t\t\t\t\t\t\t\t<option value=\"0\">Please select the number of slots for this crew</option>" . slots_select() . "</select><br>\n\t\t\t\t\t\t\t\t\t<br><br>\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"_submit_change_times\" value=\"1\">\n\t\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"Add New Crew\" name=\"submit\">\n\t\t\t\t\t\t\t\t\t</form><br></td></tr></table>";
        }
    } else {
        // if one is there, see what we can do to update it
        if (!process_fill_vacancy($_POST, $group, $day, $week_no) && !process_add_volunteer($_POST, $group, $day, $week_no) && !process_remove_crew($_POST, $group, $day, $week_no)) {
            // try to remove the crew
            if (process_unfill_crew($_POST, $group, $day, $week_no)) {
                // try to remove a person
            } else {
                if (process_add_slot($_POST, $group, $day, $week_no)) {
                    // try to add a new slot
                } else {
                    if (process_ignore_slot($_POST, $group, $day, $week_no)) {
                        //try to remove a slot
                    }
                }
            }
            // we've tried to clear the crew, add a slot, or remove a slot;
            // so now display the crew again.
            $persons = get_persons($group, $day, $week_no);