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