function report_individual_hours($shifthis, $projecthis, $from, $to) { $from_date = setFromDate($from); $to_date = setToDate($to); $groupedreports = []; $count = 0; $fw = getNormWeek($from_date); $tw = getNormWeek($to_date); $yearswithweeks = DateRange($fw, $tw); foreach ($yearswithweeks as $years => $weeks) { foreach ($weeks as $w) { $currentweek = getSunWeek($years, $w); $weeklyreport = ['Sun' => [[0, 0], [0, 0], [0, 0]], 'Mon' => [[0, 0], [0, 0], [0, 0]], 'Tue' => [[0, 0], [0, 0], [0, 0]], 'Wed' => [[0, 0], [0, 0], [0, 0]], 'Thu' => [[0, 0], [0, 0], [0, 0]], 'Fri' => [[0, 0], [0, 0], [0, 0]], 'Sat' => [[0, 0], [0, 0], [0, 0]]]; //This consists of [Days] => [shift, project, total] => [hrs, mins] - GIOVI $hours_s = 0; $minutes_s = 0; $hrmin_s = [0, 0]; $hours_p = 0; $minutes_p = 0; $hrmin_p = [0, 0]; if (array_key_exists($this->get_id(), $shifthis)) { $sfthid = explode(',', $shifthis[$this->ID]); foreach ($sfthid as $shift_id) { $s = select_dbShifts($shift_id); if (CheckIfDateIsInWeek($s->get_date(), $currentweek)) { $shift_date = date_create_from_mm_dd_yyyy($s->get_mm_dd_yy()); if ($shift_date >= $from_date && $shift_date <= $to_date) { $hrmin_s = ConvertTimeToHrMin($s->duration()); $hours_s = $hrmin_s[0]; $minutes_s = $hrmin_s[1]; $weeklyreport[$s->get_day()][0][0] += $hours_s; //Shift hours $weeklyreport[$s->get_day()][0][1] += $minutes_s; //Shift minutes } } } } if (array_key_exists($this->get_id(), $projecthis)) { $projhid = explode(',', $projecthis[$this->ID]); foreach ($projhid as $proj_id) { $p = select_dbProjects($proj_id); if (CheckIfDateIsInWeek($p->get_date(), $currentweek)) { $proj_date = date_create_from_mm_dd_yyyy($p->get_mm_dd_yy()); if ($proj_date >= $from_date && $proj_date <= $to_date) { $hrmin_p = ConvertTimeToHrMin($p->duration()); $hours_p = $hrmin_p[0]; $minutes_p = $hrmin_p[1]; $weeklyreport[$p->get_dayOfWeek()][1][0] += $hours_p; //Project hours $weeklyreport[$p->get_dayOfWeek()][1][1] += $minutes_p; //Project minutes } } } } foreach ($weeklyreport as $day => $hrs) { $weeklyreport[$day][2][0] = $weeklyreport[$day][0][0] + $weeklyreport[$day][1][0]; $weeklyreport[$day][2][1] = $weeklyreport[$day][0][1] + $weeklyreport[$day][1][1]; } $groupedreports[] = $weeklyreport; $count++; } } error_log("------- " . $count . " grouped report(s) recorded-----------"); error_log("/////EXITING the report_hours function--------------------"); return $groupedreports; }
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 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; }