function get_people_for_shift($master_shift, $master_shift_length) { /* $master_shift is a MasterScheduleEntry object * an associative array of (venue, my_group, day, time, * start, end, slots, persons, notes) */ $people = get_persons($master_shift->get_id()); $slots = get_total_slots($master_shift->get_id()); if (!$people[0]) { array_shift($people); } $p = "<br>"; for ($i = 0; $i < count($people); ++$i) { if (is_array($people[$i])) { $p = $p . " " . $people[$i]['first_name'] . " " . $people[$i]['last_name'] . "<br>"; } else { $p = $p . " " . $people[$i] . "<br>"; } } if ($slots - count($people) > 0) { $p = $p . " <b>Vacancies (" . ($slots - count($people)) . ")</b><br>"; } else { if (count($people) == 0) { $p = $p . " <br>"; } } return substr($p, 0, strlen($p) - 4); }
function get_people_for_shift($master_shift) { /* $master_shift is a MasterScheduleEntry object * an associative array of people */ $people = get_persons($master_shift->get_group(), $master_shift->get_day(), $master_shift->get_week_no()); $slots = get_total_slots($master_shift->get_group(), $master_shift->get_day(), $master_shift->get_week_no()); if (!$people[0]) { array_shift($people); } $p = "<br>"; for ($i = 0; $i < count($people); ++$i) { if (is_array($people[$i])) { $fr = filter_roles($master_shift->get_group(), "(" . $people[$i]['role'] . ")"); if ($fr != "()") { $p = $p . " " . $people[$i]['first_name'] . " " . $people[$i]['last_name'] . " " . $fr . "<br>"; } else { $p = $p . " " . $people[$i]['first_name'] . " " . $people[$i]['last_name'] . "<br>"; } } else { $p = $p . " " . $people[$i] . "<br>"; } } if ($slots - count($people) > 0) { $p = $p . " <b>Vacancies (" . ($slots - count($people)) . ")</b><br>"; } else { if (count($people) == 0) { $p = $p . " <br>"; } } return substr($p, 0, strlen($p) - 4); // remove the last )<br> }
function get_total_vacancies($Schedule_type, $day, $time) { $slots = get_total_slots($Schedule_type, $day, $time); $persons = count(get_persons($Schedule_type, $day, $time)); return $slots - $persons; }
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; }
function get_total_vacancies($group, $day, $week_no) { $slots = get_total_slots($group, $day, $week_no); $persons = count(get_persons($group, $day, $week_no)); return $slots - $persons; }
function do_slot_num($group, $day, $week_no) { $slots = get_total_slots($group, $day, $week_no); if ($slots == 1) { return "1 slot for this crew:"; } return $slots . " slots for this crew:"; }