|
|
@@ -32,7 +32,7 @@ class PresenceReport extends Component
|
|
|
|
|
|
public $ids = [];
|
|
|
|
|
|
- public $course_id;
|
|
|
+ public $course_name;
|
|
|
public $from;
|
|
|
public $to;
|
|
|
public $court_id;
|
|
|
@@ -83,14 +83,16 @@ class PresenceReport extends Component
|
|
|
|
|
|
// Elenco corsi per tipologia in base al calendario
|
|
|
$courses = \App\Models\Course::where('name', $calendar->name)->where('date_from', '<=', $calendar->from)->where('date_to', '>=', $calendar->to);
|
|
|
- if (!is_null($this->course_id)) {
|
|
|
- $courses = $courses->where('id', $this->course_id);
|
|
|
+ if (!is_null($this->course_name)) {
|
|
|
+ $courses = $courses->where('name', $this->course_name);
|
|
|
}
|
|
|
$courses = $courses->pluck('id')->toArray();
|
|
|
|
|
|
+ $mids = [];
|
|
|
+
|
|
|
// Elenco utenti iscritti al corso "padre"
|
|
|
- // $members = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('course_id', $courses)->get();
|
|
|
- $members = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('member_id', $presences)->whereIn('course_id', $courses)->get();
|
|
|
+ $members = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('course_id', $courses)->get();
|
|
|
+ //$members = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('member_id', $presences)->whereIn('course_id', $courses)->get();
|
|
|
foreach ($members as $member) {
|
|
|
|
|
|
$court = '';
|
|
|
@@ -122,12 +124,37 @@ class PresenceReport extends Component
|
|
|
}
|
|
|
|
|
|
$this->records[$calendar->name][$h][] = array("last_name" => $member->member->last_name, "first_name" => $member->member->first_name, "court" => $court, "instructor" => $instructor, "status" => $status, 'motivation' => $motivation);
|
|
|
+
|
|
|
+ $mids[] = $member->member->id;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- array_push($this->courses, $calendar->course_id);
|
|
|
+ $presences_recuperi = \App\Models\Presence::where('calendar_id', $calendar->id)->whereNotIn('member_id', $mids)->get();
|
|
|
+ foreach($presences_recuperi as $p)
|
|
|
+ {
|
|
|
+ $court = $p->court ? $p->court->name : "";
|
|
|
+ $instructor = $p->instructor ? $p->instructor->name : "";
|
|
|
+ $motivation = $p->motivation ? $p->motivation->name : "";
|
|
|
+ $status = "<span class='fw-bold' style='color:gray'>Recupero</span>";
|
|
|
+ $this->records[$calendar->name][$h][] = array("last_name" => $p->member->last_name, "first_name" => $p->member->first_name, "court" => $court, "instructor" => $instructor, "status" => $status, 'motivation' => $motivation);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->where('id', $calendar->id)->pluck('id')->toArray();
|
|
|
+ $presences_recuperi = \App\Models\Presence::whereIn('calendar_id', $calendar_recuperi)->where('member_id', $this->dataId)->get();
|
|
|
+ foreach($presences_recuperi as $p)
|
|
|
+ {
|
|
|
+ $this->member_presences[] = array('calendar_id' => $p->calendar->id, 'from' => $p->calendar->from, 'to' => $p->calendar->to, 'status' => '<span style="color:#7136f6">Recupero</span>');//\App\Models\Presence::where('member_id', $this->dataId)->get();
|
|
|
+ $this->recuperi += 1;
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ //array_push($this->courses, $calendar->course_id);
|
|
|
}
|
|
|
|
|
|
- $this->courses = array_unique($this->courses);
|
|
|
+ $this->courses = \App\Models\Calendar::orderBy('name')->groupBy('name')->pluck('name')->toArray();
|
|
|
+
|
|
|
+ /*$this->courses = array_unique($this->courses);
|
|
|
$this->courses = array_map(function ($course_id) {
|
|
|
try {
|
|
|
return \App\Models\Course::findOrFail($course_id);
|
|
|
@@ -135,7 +162,7 @@ class PresenceReport extends Component
|
|
|
return null;
|
|
|
}
|
|
|
}, $this->courses);
|
|
|
- $this->courses = array_filter($this->courses);
|
|
|
+ $this->courses = array_filter($this->courses);*/
|
|
|
|
|
|
return view('livewire.presence_report');
|
|
|
}
|