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>";
}
Example #2
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>.');
}