function testdbMasterScheduleModule()
 {
     //creates MasterScheduleEntries to insert to database
     $entry1 = new MasterScheduleEntry("house", "Wed", "odd", "1-5", 2, "", "I do not know what Lin means");
     $entry2 = new MasterScheduleEntry("house", "Tue", "even", "1-5", 3, "", "Yay kitchen shift!");
     $entry3 = new MasterScheduleEntry("house", "Wed", "even", "1-5", 2, "", "");
     $entry4 = new MasterScheduleEntry("house", "Fri", "odd", "1-5", 4, "", "Best job ever.");
     //tests the insert function
     $this->assertTrue(insert_dbMasterSchedule($entry1));
     $this->assertTrue(insert_dbMasterSchedule($entry2));
     $this->assertTrue(insert_dbMasterSchedule($entry3));
     $this->assertTrue(insert_dbMasterSchedule($entry4));
     //tests the retrieve function
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_day(), $entry2->get_day());
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_hours(), $entry2->get_hours());
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_venue(), $entry2->get_venue());
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_week_no(), $entry2->get_week_no());
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_slots(), $entry2->get_slots());
     $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_id(), $entry2->get_id());
     //tests the update function
     $entry3->set_notes("This is a new note");
     $this->assertTrue(update_dbMasterSchedule($entry3));
     $this->assertEqual(retrieve_dbMasterSchedule($entry3->get_id())->get_notes(), "This is a new note");
     //tests the delete function
     $this->assertTrue(delete_dbMasterSchedule($entry1->get_id()));
     $this->assertTrue(delete_dbMasterSchedule($entry2->get_id()));
     $this->assertTrue(delete_dbMasterSchedule($entry3->get_id()));
     $this->assertTrue(delete_dbMasterSchedule($entry4->get_id()));
     echo "testdbMasterSchedule complete";
 }
function test_update_dbMasterSchedule()
{
    $new_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", 14, 17, 2, "joe2071234567,sue2079876543", "This is a super fun shift.", "Afternoon Shift");
    // not sure what the id looks like
    echo 'will test update_dbMasterSchedule </br>';
    $new_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", 14, 17, 2, "joe2071234567,sue2079876543", "This is a super fun shift.", "Afternoon Shift");
    // not sure what the id looks like
    echo 'will test update_dbMasterSchedule </br>';
    error_log('testing update');
    $result = insert_dbMasterSchedule($new_MasterScheduleEntry);
    echo 'result is ' . $result;
    if ($result) {
        echo "insert_dbMasterSchedule succeeded </br>";
    } else {
        echo "insert_dbMasterSchedule failed</br>";
    }
    // removed one person
    $updated_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", "14", "17", 2, "sue2079876543", "This is a super fun shift.", "Afternoon Shift");
    // not sure what the id looks lik
    $mse = update_dbMasterSchedule($updated_MasterScheduleEntry);
    if ($mse == false) {
        echo 'update failed</br>';
    } else {
        echo 'update succeeded';
    }
    $res = delete_dbMasterSchedule($new_MasterScheduleEntry->get_MS_ID());
    if ($res == null) {
        echo 'delete failed</br>';
    }
}
Ejemplo n.º 3
0
function update_dbMasterSchedule($entry)
{
    connect();
    if (!$entry instanceof MasterScheduleEntry) {
        echo "Invalid argument for update_dbMasterSchedule function call";
        return false;
    }
    if (delete_dbMasterSchedule($entry->get_id())) {
        return insert_dbMasterSchedule($entry);
    } else {
        echo mysql_error() . " - Unable to update dbMasterSchedule: " . $entry->get_id() . "\n";
        return false;
    }
    mysql_close();
    return true;
}
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 insert_nonoverlapping($shift)
{
    $other_shifts = get_master_shifts($shift->get_schedule_type(), $shift->get_day());
    foreach ($other_shifts as $other_shift) {
        if (masterslots_overlap($shift->get_start_time(), $shift->get_end_time(), $other_shift->get_start_time(), $other_shift->get_end_time())) {
            return false;
        }
    }
    insert_dbMasterSchedule($shift);
    return true;
}
function insert_nonoverlapping($shift)
{
    $other_shifts = get_master_shifts($shift->get_group(), $shift->get_day(), $shift->get_week_no());
    foreach ($other_shifts as $other_shift) {
        if (masterslots_overlap($shift, $oher_shift)) {
            return false;
        }
    }
    insert_dbMasterSchedule($shift);
    return true;
}
Ejemplo n.º 7
0
function process_add_shift($post, $group, $day, $time, $venue)
{
    //if (!array_key_exists('_submit_insert_shift', $post))
    //    return false;
    $entry = new MasterScheduleEntry($venue, $day, $group, $time, 0, "", "");
    insert_dbMasterSchedule($entry);
    if ($error) {
        echo $error;
        return false;
    } else {
        //$groupdisplay = $venue . " Group ".$group." Time ".$time;
        echo "Added a master schedule shift <br><br>";
        add_log_entry('<a href=\\"personEdit.php?id=' . $_SESSION['_id'] . '\\">' . $_SESSION['f_name'] . ' ' . $_SESSION['l_name'] . '</a> added a new master schedule shift: <a href=\\"editMasterSchedule.php?group=' . $group . "&day=" . $day . "&shift=" . $time . "&venue=" . $venue . '\\">' . $group . ":" . $day . ":" . $time . ":" . $venue . '</a>.');
        return true;
    }
}