function delete_dbMasterSchedule($id) { // first, unschedule people from the shift $msentry = retrieve_dbMasterSchedule($id); if ($msentry != null) { $ids = get_person_ids($msentry->get_venue(), $msentry->get_week_no(), $msentry->get_day(), $msentry->get_hours()); foreach ($ids as $person_id) { if ($person_id) { unschedule_person($msentry, $person_id); } } } connect(); $query = "DELETE FROM dbMasterSchedule WHERE id = '" . $id . "'"; $result = mysql_query($query); if (!$result) { echo mysql_error() . " - Unable to delete from dbMasterSchedule: " . $id . "\n"; return false; } mysql_close(); return true; }
function generate_and_populate_shift($day_id, $venue, $week_of_month, $week_of_year, $day, $time, $note) { // gets the people from the master schedule $people1 = get_person_ids($venue, $week_of_month, $day, $time); if (!$people1[0]) { array_shift($people1); } // echo($week_of_month.":".$day.":".$time.":".$venue); $vacancies1 = get_total_slots($week_of_month . ":" . $day . ":" . $time . ":" . $venue) - count($people1); $people2 = get_person_ids($venue, $week_of_year, $day, $time); if (!$people2[0]) { array_shift($people2); } $vacancies2 = get_total_slots($week_of_year . ":" . $day . ":" . $time . ":" . $venue) - count($people2); $people = array_unique(array_merge($people1, $people2)); if (!$people[0]) { array_shift($people); } $vacancies = $vacancies1 + $vacancies2; // changes the people array to the format used by Shift (id, fname lname) for ($i = 0; $i < count($people); ++$i) { $person = retrieve_person($people[$i]); if ($person) { $people[$i] = $person->get_id() . "+" . $person->get_first_name() . "+" . $person->get_last_name(); } } // calculates vacancies // makes a new shift filled with people found above $newShift = new Shift($day_id . ":" . $time, $venue, $vacancies, $people, array(), "", $note); return $newShift; }