|
|
@@ -372,96 +372,101 @@ class Member extends Component
|
|
|
public function render()
|
|
|
{
|
|
|
|
|
|
- // $this->emit('destroy-data-table');
|
|
|
-
|
|
|
$datas = [];
|
|
|
- if (!$this->advanced)
|
|
|
- {
|
|
|
- /*if ($this->search != '')
|
|
|
- $datas = \App\Models\Member::select('members.*') // , \DB::raw('SUM(records.id) As total'))
|
|
|
- ->where('first_name', 'LIKE', '%' . $this->search . '%')
|
|
|
- ->orWhere('last_name', 'LIKE', '%' . $this->search . '%')
|
|
|
- ->orWhere('email', 'LIKE', '%' . $this->search . '%');
|
|
|
- $this->records = \App\Models\Member::where('first_name', 'LIKE', '%' . $this->search . '%')->orWhere('last_name', 'LIKE', '%' . $this->search . '%')->orWhere('email', 'LIKE', '%' . $this->search . '%')->get();
|
|
|
- else*/
|
|
|
- $this->records = \App\Models\Member::get();
|
|
|
- //$datas = \App\Models\Member::select('members.*');
|
|
|
- }
|
|
|
- else
|
|
|
+ // $this->emit('destroy-data-table');
|
|
|
+ if (false)
|
|
|
{
|
|
|
- //$this->records = \App\Models\Member::where('id', '>', 0);
|
|
|
- $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
|
|
|
- if (sizeof($this->filterCard) > 0)
|
|
|
- {
|
|
|
- $card_ids = \App\Models\MemberCard::whereIn('card_id', $this->filterCard)->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $card_ids);
|
|
|
- $datas = $datas->whereIn('id', $card_ids);
|
|
|
- }
|
|
|
- if (sizeof($this->filterCategory) > 0)
|
|
|
- {
|
|
|
- $cats_ids = \App\Models\MemberCategory::whereIn('category_id', $this->filterCategory)->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $cats_ids);
|
|
|
- $datas = $datas->whereIn('id', $cats_ids);
|
|
|
- }
|
|
|
- $certs = [];
|
|
|
|
|
|
- if ($this->filterCertNormal > 0)
|
|
|
- {
|
|
|
- $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $normal);
|
|
|
- $datas = $datas->whereIn('id', $normal);;
|
|
|
- }
|
|
|
- if ($this->filterCertAgonistic > 0)
|
|
|
- {
|
|
|
- $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $agonistic);
|
|
|
- $datas = $datas->whereIn('id', $agonistic);
|
|
|
- }
|
|
|
- if ($this->filterCertScaduto > 0)
|
|
|
+ if (!$this->advanced)
|
|
|
{
|
|
|
- $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $scaduto);
|
|
|
- $datas = $datas->whereIn('id', $scaduto);
|
|
|
+ /*if ($this->search != '')
|
|
|
+ $datas = \App\Models\Member::select('members.*') // , \DB::raw('SUM(records.id) As total'))
|
|
|
+ ->where('first_name', 'LIKE', '%' . $this->search . '%')
|
|
|
+ ->orWhere('last_name', 'LIKE', '%' . $this->search . '%')
|
|
|
+ ->orWhere('email', 'LIKE', '%' . $this->search . '%');
|
|
|
+ $this->records = \App\Models\Member::where('first_name', 'LIKE', '%' . $this->search . '%')->orWhere('last_name', 'LIKE', '%' . $this->search . '%')->orWhere('email', 'LIKE', '%' . $this->search . '%')->get();
|
|
|
+ else*/
|
|
|
+ $this->records = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone')->get();
|
|
|
+ //$datas = \App\Models\Member::select('members.*');
|
|
|
}
|
|
|
- if ($this->filterCertInScadenza > 0)
|
|
|
+ else
|
|
|
{
|
|
|
- $scaduto = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
|
|
|
- //$this->records->whereIn('id', $scaduto);
|
|
|
- $datas = $datas->whereIn('id', $scaduto);
|
|
|
+ //$this->records = \App\Models\Member::where('id', '>', 0);
|
|
|
+ $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
|
|
|
+ if (sizeof($this->filterCard) > 0)
|
|
|
+ {
|
|
|
+ $card_ids = \App\Models\MemberCard::whereIn('card_id', $this->filterCard)->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $card_ids);
|
|
|
+ $datas = $datas->whereIn('id', $card_ids);
|
|
|
+ }
|
|
|
+ if (sizeof($this->filterCategory) > 0)
|
|
|
+ {
|
|
|
+ $cats_ids = \App\Models\MemberCategory::whereIn('category_id', $this->filterCategory)->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $cats_ids);
|
|
|
+ $datas = $datas->whereIn('id', $cats_ids);
|
|
|
+ }
|
|
|
+ $certs = [];
|
|
|
+
|
|
|
+ if ($this->filterCertNormal > 0)
|
|
|
+ {
|
|
|
+ $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $normal);
|
|
|
+ $datas = $datas->whereIn('id', $normal);;
|
|
|
+ }
|
|
|
+ if ($this->filterCertAgonistic > 0)
|
|
|
+ {
|
|
|
+ $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $agonistic);
|
|
|
+ $datas = $datas->whereIn('id', $agonistic);
|
|
|
+ }
|
|
|
+ if ($this->filterCertScaduto > 0)
|
|
|
+ {
|
|
|
+ $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $scaduto);
|
|
|
+ $datas = $datas->whereIn('id', $scaduto);
|
|
|
+ }
|
|
|
+ if ($this->filterCertInScadenza > 0)
|
|
|
+ {
|
|
|
+ $scaduto = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
|
|
|
+ //$this->records->whereIn('id', $scaduto);
|
|
|
+ $datas = $datas->whereIn('id', $scaduto);
|
|
|
+ }
|
|
|
+ if (sizeof($certs) > 0)
|
|
|
+ {
|
|
|
+ $datas = $datas->whereIn('id', $certs);
|
|
|
+ //$this->records->whereIn('id', $certs);
|
|
|
+ }
|
|
|
+ $this->records = $datas->get();
|
|
|
+
|
|
|
}
|
|
|
- if (sizeof($certs) > 0)
|
|
|
+
|
|
|
+ foreach($this->records as $r)
|
|
|
{
|
|
|
- $datas = $datas->whereIn('id', $certs);
|
|
|
- //$this->records->whereIn('id', $certs);
|
|
|
+ $r->age = $r->getAge();
|
|
|
+ $active = $r->isActive();
|
|
|
+ $r->status = $active["status"];
|
|
|
+ $r->date = $active["date"];
|
|
|
+ $r->certificate = $r->hasCertificate()["date"];
|
|
|
+ $r->state = $r->getStatus()["status"];
|
|
|
}
|
|
|
- $this->records = $datas->get();
|
|
|
-
|
|
|
- }
|
|
|
+ /*
|
|
|
+ if ($this->sortAsc)
|
|
|
+ $this->records = $this->records->sortBy($this->sortField);
|
|
|
+ else
|
|
|
+ $this->records = $this->records->sortByDesc($this->sortField);
|
|
|
+ */
|
|
|
|
|
|
- /*
|
|
|
- foreach($this->records as $r)
|
|
|
- {
|
|
|
- $r->age = $r->getAge();
|
|
|
- $r->status = $r->isActive()["status"];
|
|
|
- $r->certificate = $r->hasCertificate()["status"];
|
|
|
- $r->state = $r->getStatus()["status"];
|
|
|
- }
|
|
|
+ //$datas = $datas->get(); // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
|
|
|
|
|
|
- if ($this->sortAsc)
|
|
|
- $this->records = $this->records->sortBy($this->sortField);
|
|
|
- else
|
|
|
- $this->records = $this->records->sortByDesc($this->sortField);
|
|
|
- */
|
|
|
+ //$this->records = $this->records->get();
|
|
|
+ $this->loadMemberCards();
|
|
|
+ $this->loadMemberCourses();
|
|
|
+ $this->loadMemberCategories();
|
|
|
+ $this->loadMemberCertificates();
|
|
|
|
|
|
- //$datas = $datas->get(); // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
|
|
|
-
|
|
|
- //$this->records = $this->records->get();
|
|
|
- $this->loadMemberCards();
|
|
|
- $this->loadMemberCourses();
|
|
|
- $this->loadMemberCategories();
|
|
|
- $this->loadMemberCertificates();
|
|
|
+ $this->emit('load-data-table');
|
|
|
+ }
|
|
|
|
|
|
- $this->emit('load-data-table');
|
|
|
|
|
|
return view('livewire.member', ['datas' => $datas]);
|
|
|
}
|
|
|
@@ -1574,4 +1579,6 @@ class codicefiscale {
|
|
|
|
|
|
return $codice;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|