function report_shifts_staffed_vacant($from, $to) { $from_date = setFromDate($from); $to_date = setToDate($to); $reports = []; $all_shifts = get_all_shifts(); $count = 0; foreach ($all_shifts as $s) { $shift_date = date_create_from_mm_dd_yyyy($s->get_mm_dd_yy()); if ($shift_date >= $from_date && $shift_date <= $to_date && $s->get_vacancies() != 0) { if (!isset($reports[$s->get_id()][0])) { $reports[$s->get_id()][0] = NULL; } error_log("Getting the number of remaining vacancies--------------------------------------------"); $reports[$s->get_id()][0] += $s->get_remaining_vacancies($s->get_id()); $count++; } } error_log("------- " . $count . " vacancy(ies) recorded-----------"); return $reports; }
function report_shifthours($from, $to) { error_log("reporting shift hours by day"); $from_date = setFromDate($from); $to_date = setToDate($to); $reports = []; $all_shifts = get_all_shifts(); $count = 0; foreach ($all_shifts as $s) { $hours = 0; $minutes = 0; $hrmin = [0, 0]; $shift_date = date_create_from_mm_dd_yyyy($s->get_mm_dd_yy()); if ($shift_date >= $from_date && $shift_date <= $to_date && $s->get_persons() != null) { if (!isset($reports[$s->get_id()][0]) || !isset($reports[$s->get_id()][1]) || !isset($reports[$s->get_id()][2])) { $reports[$s->get_id()][0] = NULL; $reports[$s->get_id()][1] = NULL; } error_log("Getting total hours and number of volunteers---------------------------"); error_log("The number of hours is " . $s->duration()); error_log("The number of volunteers is " . $s->get_num_of_persons()); $hrmin = ConvertTimeToHrMin($s->duration()); $hours = $hrmin[0] * $s->get_num_of_persons(); $minutes = $hrmin[1] * $s->get_num_of_persons(); $shiftTime = ArrangeMinutesInHours($hours, $minutes); $reports[$s->get_id()][0] = $shiftTime; $reports[$s->get_id()][1] = $s->get_num_of_persons(); $count++; error_log("End of loop--------------------------------------"); } } return $reports; }
function get_all_peoples_histories_in_shifts() { // This function is now returning the correct data - GIOVI $today = date('m-d-y'); $histories = []; $all_shifts = get_all_shifts(); foreach ($all_shifts as $a_shift) { $persons = explode('*', $a_shift->get_persons()); //The star is what's used to separate people's ids in the persons column in the shift table - GIOVI if (!$persons[0]) { array_shift($persons); } if (count($persons) > 0) { foreach ($persons as $a_person) { if (strpos($a_person, '+') > 0) { //The plus is used to state the end of a person's id, first name, and last name and should be placed before each star - GIOVI $person_id = substr($a_person, 0, strpos($a_person, '+')); if (array_key_exists($person_id, $histories)) { $histories[$person_id] .= "," . $a_shift->get_id(); } else { $histories[$person_id] = $a_shift->get_id(); } } } } } ksort($histories); return $histories; }
function get_all_venue_shifts($from, $to, $venue) { if ($venue == "") { $all_shifts = get_all_shifts(); } else { connect(); $query = "SELECT * FROM dbShifts WHERE venue = '" . $venue . "'"; $result = mysql_query($query); if ($result == null || mysql_num_rows($result) == 0) { mysql_close(); return false; } $result = mysql_query($query); $all_shifts = array(); while ($result_row = mysql_fetch_assoc($result)) { $shift = make_a_shift($result_row); $all_shifts[] = $shift; } } return $all_shifts; }
function shiftLabel($from, $to, $section) { //This is used to print out display the project table the new way - GIOVI $from_date = setFromDate($from); $to_date = setToDate($to); $labels = []; $shiftdata = get_all_shifts(); $count = 0; foreach ($shiftdata as $shift) { $shifts_date = date_create_from_mm_dd_yyyy($shift->get_mm_dd_yy()); if ($section === 'hours') { if ($shifts_date >= $from_date && $shifts_date <= $to_date && $shift->get_persons() != null) { $starthrmin = ConvertTimeToHrMin($shift->get_start_time()); $endhrmin = ConvertTimeToHrMin($shift->get_end_time()); array_push($labels, $shift->get_date() . "<br>" . ArrangeMinutesInHours($starthrmin[0], $starthrmin[1]) . " - " . ArrangeMinutesInHours($endhrmin[0], $endhrmin[1]) . "<br>" . $shift->get_venue()); $count++; } } if ($section === 'vacancies') { if ($shifts_date >= $from_date && $shifts_date <= $to_date && $shift->get_vacancies() != 0) { $starthrmin = ConvertTimeToHrMin($shift->get_start_time()); $endhrmin = ConvertTimeToHrMin($shift->get_end_time()); array_push($labels, $shift->get_date() . "<br>" . ArrangeMinutesInHours($starthrmin[0], $starthrmin[1]) . " - " . ArrangeMinutesInHours($endhrmin[0], $endhrmin[1]) . "<br>" . $shift->get_venue()); $count++; } } } error_log("------- " . $count . " shift label(s) recorded-----------"); return $labels; }