Exemplo n.º 1
0
 function testShiftModule()
 {
     $noonshift = new Shift("08-03-28:1-5", "house", 3, array(), array(), "", "");
     $this->assertEqual($noonshift->get_hours(), "1-5");
     $this->assertTrue($noonshift->get_id() == "08-03-28:1-5:house");
     $this->assertEqual($noonshift->get_yy_mm_dd(), "08-03-28");
     // Test new function for resetting shift's start/end time
     $this->assertTrue($noonshift->get_start_time() == 13);
     $this->assertEqual($noonshift->get_end_time(), 17);
     // Be sure that invalid times are caught.
     $this->assertFalse($noonshift->set_start_end_time(13, 12));
     $this->assertTrue($noonshift->get_id() == "08-03-28:1-5:house");
     $this->assertTrue($noonshift->get_hours() == "1-5");
     $this->assertTrue($noonshift->num_vacancies() == 3);
     $this->assertTrue($noonshift->get_day() == "Fri");
     $this->assertFalse($noonshift->has_sub_call_list());
     $persons = array();
     $persons[] = "alex1234567890+alex+jones";
     $noonshift->assign_persons($persons);
     $noonshift->ignore_vacancy();
     $persons[] = "malcom1234567890+malcom+jones";
     $noonshift->assign_persons($persons);
     $noonshift->ignore_vacancy();
     $persons[] = "nat1234567890+nat+jones";
     $noonshift->assign_persons($persons);
     $noonshift->ignore_vacancy();
     $this->assertTrue($noonshift->num_vacancies() == 0);
     $noonshift->add_vacancy();
     $this->assertTrue($noonshift->num_slots() == 4);
     $noonshift->ignore_vacancy();
     $this->assertTrue($noonshift->num_slots() == 3);
     $noonshift->set_notes("Hello 1-5 shift!");
     $this->assertTrue($noonshift->get_notes() == "Hello 1-5 shift!");
     echo "testShift complete";
 }
Exemplo n.º 2
0
function insert_dbShifts(Shift $s)
{
    connect();
    $query = 'SELECT * FROM SHIFT WHERE SHIFTID ="' . $s->get_id() . '"';
    error_log('in insert_dbShifts, query is ' . $query);
    $result = mysql_query($query);
    if (mysql_num_rows($result) != 0) {
        delete_dbShifts($s);
        connect();
    }
    $query = "INSERT INTO SHIFT VALUES ('" . $s->get_id() . "','" . $s->get_date() . "','" . $s->get_start_time() . "','" . $s->get_end_time() . "','" . $s->get_venue() . "','" . $s->num_vacancies() . "','" . implode("*", $s->get_persons()) . "','" . implode("*", $s->get_removed_persons()) . "','" . $s->get_notes() . "');";
    error_log('in insert_dbShifts, query is ' . $query);
    $result = mysql_query($query);
    if (!$result) {
        echo "unable to insert into SHIFT " . $s->get_id() . mysql_error();
        mysql_close();
        return false;
    }
    mysql_close();
    return true;
}