Просмотр исходного кода

absence_report - messo limite al giorno precedente

ferrari 1 месяц назад
Родитель
Сommit
e1d810d4e4
1 измененных файлов с 9 добавлено и 9 удалено
  1. 9 9
      app/Http/Livewire/AbsenceReport.php

+ 9 - 9
app/Http/Livewire/AbsenceReport.php

@@ -23,8 +23,10 @@ class AbsenceReport extends Component
 
         $this->record_assenze = [];
 
-        $today = now();
-        $this->year = ($today->month >= $this->fiscalStartMonth) ? $today->year : $today->year - 1;
+        $end_day = now()->yesterday();
+        $limit = $end_day->endOfDay();
+
+        $this->year = ($end_day->month >= $this->fiscalStartMonth) ? $end_day->year : $end_day->year - 1;
 
         $dayMap = [
             'lun' => 1,
@@ -37,14 +39,12 @@ class AbsenceReport extends Component
         ];
 
         try {
-            $courses = \App\Models\Course::whereDate('date_from', '<=', now())
-                ->whereDate('date_to', '>=', now())
+            $courses = \App\Models\Course::whereDate('date_from', '<=', $limit)
+                ->whereDate('date_to', '>=', $limit)
                 ->where('active', true)
                 ->where('enabled', true)
                 ->get();
 
-            $limit = now()->endOfDay();
-
             foreach ($courses as $course) {
                 $course_members = \App\Models\MemberCourse::with(['member' => function ($q) {
                     $q->where(function ($q) {
@@ -290,11 +290,11 @@ class AbsenceReport extends Component
 
     protected function generateFiscalDateRanges($months, $days, $dayMap, $fromTime, $toTime)
     {
-        $limit = now()->endOfDay();
+        $limit = now()->yesterday()->endOfDay();
 
-        $today = $limit;
+        $end_day = $limit;
 
-        $startYear = ($today->month >= $this->fiscalStartMonth) ? $today->year : $today->year - 1;
+        $startYear = ($end_day->month >= $this->fiscalStartMonth) ? $end_day->year : $end_day->year - 1;
 
         $allowedDow = collect($days)
             ->map(fn($d) => $dayMap[$d] ?? null)