예제 #1
0
/**
 * updates a SCL in the database by deleting it and re-inserting it.
 */
function update_dbSCL($scl)
{
    if (!$scl instanceof SCL) {
        die("Invalid argument for dbSCL->update_dbSCL(\$) function call");
    }
    delete_dbSCL($scl);
    // try to delete
    if (insert_dbSCL($scl)) {
        return true;
    } else {
        return false;
    }
}
예제 #2
0
 function testdbSCLModule()
 {
     $p = array();
     $p[] = array("max123", "max", "palmer", "123", "456", "1/1/08", "LM", "true");
     $p[] = array("oliver345", "oliver", "radwan", "123", "456", "1/1/08", "LM", "false");
     $s = new SCL("01-01-08-9-12", $p, "open", 1, "11223344");
     //	print_r($s);
     $this->assertTrue(insert_dbSCL($s));
     $s2 = select_dbSCL("01-01-08-9-12");
     $this->assertTrue($s2 !== null);
     $p2 = $s2->get_persons();
     $p2[] = array("max123", "max", "palmer", "123", "456", "1/1/08", "LM", "true");
     $s2->set_persons($p2);
     $this->assertTrue(update_dbSCL($s2));
     //	print_r(select_dbSCL("01-01-08-9-12"));
     $this->assertTrue(delete_dbSCL($s));
     echo "testdbSCL complete";
 }
function generate_scl($id)
{
    //	echo "<br>we are here";
    $shift = select_dbShifts($id);
    $vacancies = $shift->num_vacancies();
    $day = $shift->get_day();
    $time = $shift->get_time_of_day();
    $time = substr($time, 0, strlen($time) - 3);
    $venue = $shift->get_venue();
    $shift_persons = $shift->get_persons();
    if (!$shift_persons[0]) {
        array_shift($shift_persons);
    }
    connect();
    $query = "SELECT * FROM dbPersons WHERE (status = 'active' AND type LIKE '%sub%' AND availability LIKE '%" . $day . ":" . $time . "%') ORDER BY last_name,first_name";
    $persons_result = mysql_query($query);
    mysql_close();
    for ($i = 0; $i < mysql_num_rows($persons_result); ++$i) {
        $row = mysql_fetch_row($persons_result);
        $id_and_name = $row[0] . "+" . $row[1] . "+" . $row[2];
        $match = false;
        //			for($j=0;$j<count($shift_persons);++$j) {
        //				if($id_and_name==$shift_persons[$j] || in_array($id_and_name, )) {
        //					$match=true;
        //				}
        //			}
        if (!in_array($id_and_name, $shift_persons) && !in_array($id_and_name, $shift->get_removed_persons())) {
            $persons[] = [$row[0], $row[1], $row[2], $row[9], $row[10], "", "", "?"];
        }
    }
    $new_scl = new SCL($id, $persons, "open", $vacancies, get_sub_call_list_timestamp($id));
    if (select_dbSCL($id)) {
        delete_dbSCL($new_scl);
    }
    insert_dbSCL($new_scl);
    $shift->open_sub_call_list();
    update_dbShifts($shift);
    add_log_entry('<a href=\\"personEdit.php?id=' . $_SESSION['_id'] . '\\">' . $_SESSION['f_name'] . ' ' . $_SESSION['l_name'] . '</a> generated a <a href=\\"subCallList.php?shift=' . $shift->get_id() . '\\">sub call list</a> for the shift: <a href=\\"editShift.php?shift=' . $shift->get_id() . '&venue=' . $venue . '\\">' . get_shift_name_from_id($shift->get_id()) . '</a>.');
    //$_POST['_shiftid']=$id;
    //echo "<p>SCL ".$id." added successfully.</p>";
}
예제 #4
0
function generate_scl($id)
{
    //	echo "<br>we are here";
    $shift = select_dbShifts($id);
    $vacancies = $shift->num_vacancies();
    $day = $shift->get_day();
    $time = $shift->get_time_of_day();
    $venue = $shift->get_venue();
    $shift_persons = $shift->get_persons();
    if (!$shift_persons[0]) {
        array_shift($shift_persons);
    }
    connect();
    $query = "SELECT * FROM dbPersons WHERE (status = 'active' AND type LIKE '%sub%' AND availability LIKE '%" . $day . ":" . $time . ":" . $venue . "%') ORDER BY last_name,first_name";
    $persons_result = mysql_query($query);
    mysql_close();
    for ($i = 0; $i < mysql_num_rows($persons_result); ++$i) {
        $row = mysql_fetch_row($persons_result);
        $id_and_name = $row[0] . "+" . $row[3] . "+" . $row[4];
        if (!in_array($id_and_name, $shift_persons) && !in_array($id_and_name, $shift->get_removed_persons())) {
            $persons[] = array($row[0], $row[3], $row[4], $row[9] . " " . $row[10], $row[11] . " " . $row[12], "", "", "?");
        }
    }
    $new_scl = new SCL($id, $persons, "open", $vacancies, get_sub_call_list_timestamp($id));
    if (!select_dbSCL($id)) {
        insert_dbSCL($new_scl);
        $shift->open_sub_call_list();
        update_dbShifts($shift);
    } else {
        $new_scl = select_dbSCL($id);
    }
    add_log_entry('<a href=\\"personEdit.php?id=' . $_SESSION['_id'] . '\\">' . $_SESSION['f_name'] . ' ' . $_SESSION['l_name'] . '</a> generated a <a href=\\"subCallList.php?shift=' . $shift->get_id() . '\\">sub call list</a> for the shift: <a href=\\"editShift.php?shift=' . $shift->get_id() . '&venue=' . $venue . '\\">' . get_shift_name_from_id($shift->get_id()) . '</a>.');
}