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 duration()
 {
     $time = [0, 0];
     $st = ConvertTimeToHrMin($this->start_time);
     $et = ConvertTimeToHrMin($this->end_time);
     if ($st[0] > $et[0]) {
         $diff = $et[0] - $st[0];
         $time[0] = 24 + $diff;
     }
     if ($st[0] <= $et[0]) {
         $time[0] = $et[0] - $st[0];
     }
     if ($st[1] > $et[1]) {
         $diff = $et[1] - $st[1];
         $time[1] = 60 + $diff;
         --$time[0];
     }
     if ($st[1] <= $et[1]) {
         $time[1] = $et[1] - $st[1];
     }
     $padtime[0] = str_pad($time[0], 2, 0, STR_PAD_LEFT);
     //These are to ensure the time will be 4 digits (00:00) - GIOVI
     $padtime[1] = str_pad($time[1], 2, 0, STR_PAD_LEFT);
     $dur = implode('', $padtime);
     return $dur;
 }
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;
}