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 IndividualHoursLabel($from, $to) { $fromweek = setFromDate($from); $toweek = setToDate($to); $fw = getNormWeek($fromweek); $tw = getNormWeek($toweek); $yearswithweeks = DateRange($fw, $tw); $labels = []; $count = 0; //Two foreach loops are need because the first runs through the array of years, but can't also run through the the array of week numbers, so a second one is needed to take care of it - GIOVI foreach ($yearswithweeks as $years => $weeks) { foreach ($weeks as $w) { array_push($labels, "<nobr>Week of " . getSunWeek($years, $w) . "</nobr><br>Shift Hours" . "<br>Project Hours" . "<br>Total"); //Why 2013 on 12/29? - GIOVI $count++; } } error_log("------- " . $count . " week(s) recorded-----------"); return $labels; }