From 5c5ad8bae779aadcf81d5459cdd19fd33601e108 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 6 Jan 2024 12:35:58 +0700 Subject: [PATCH 1/2] update ecard dan enrolment 2 --- .../Services/MemberEnrollmentService.php | 13 ++++++++----- app/Models/Member.php | 18 ++++++++++++++---- resources/views/pdf/ecard-lms.blade.php | 3 +-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Modules/Internal/Services/MemberEnrollmentService.php b/Modules/Internal/Services/MemberEnrollmentService.php index bcaa3aef..3a87b81a 100644 --- a/Modules/Internal/Services/MemberEnrollmentService.php +++ b/Modules/Internal/Services/MemberEnrollmentService.php @@ -340,8 +340,10 @@ class MemberEnrollmentService if ($date_from_row instanceof DateTime) { return $date_from_row->format('Y-m-d'); - } else { + } else if ($date_from_row != null) { return date('Y-m-d', strtotime($date_from_row)); + } else { + return null; } } @@ -728,7 +730,7 @@ class MemberEnrollmentService ], [ 'name' => $row['name'] ?? null, - 'birth_date' => $this->dateParser($row['date_of_birth']), + 'birth_date' => $this->dateParser($row['date_of_birth']) ?? null, 'gender' => Helper::genderNormalization($row['sex']), 'language' => $row['language'] ?? null, 'race' => $row['race'] ?? null, @@ -785,7 +787,7 @@ class MemberEnrollmentService if ($member->save()) { $person = Person::create([ 'name' => $row['name'], - 'birth_date' => $this->dateParser($row['date_of_birth']), + 'birth_date' => $this->dateParser($row['date_of_birth']) ?? null, 'gender' => Helper::genderNormalization($row['sex']) ?? '-', 'language' => $row['language'] ?? null, 'race' => $row['race'] ?? null, @@ -906,6 +908,7 @@ class MemberEnrollmentService $member->gender = Helper::genderPerson($row['sex']); $member->relation_with_principal = $row['relationship_with_principal']; $member->marital_status = $row['marital_status']; + $member->birth_date = $this->dateParser($row['date_of_birth']); $member->save(); try { @@ -937,7 +940,7 @@ class MemberEnrollmentService // $memberPlan->plan_id = $plan->id; // $memberPlan->save(); // } - + // Hapus Member plan terkait $member->memberPlans()->delete(); //Update plan @@ -999,7 +1002,7 @@ class MemberEnrollmentService 'sNamaPeserta' => $row['name'], 'dStartDate' => $row['member_effective_date'], 'dExpireDate' => $row['member_expiry_date'], - 'dTanggalLahir' => $row['date_of_birth'], + 'dTanggalLahir' => $row['date_of_birth'] ? $this->dateParser($row['date_of_birth']) : null, // 'nNoKTP' => $row['nric'] ?? , ] ); diff --git a/app/Models/Member.php b/app/Models/Member.php index 218bb7f4..6724d2bb 100644 --- a/app/Models/Member.php +++ b/app/Models/Member.php @@ -268,10 +268,20 @@ class Member extends Model protected function birthDateeCard(): Attribute { // $date = $this->person->birth_date ?? ($this->birth_date ?? null); - $date = $this->birth_date ?? ($this->birth_date ?? this->person->birth_date); - return Attribute::make( - get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null - ); + if ($this->birth_date){ + $date = $this->birth_date; + return Attribute::make( + get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null + ); + } else if ($this->person->birth_date){ + return Attribute::make( + get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null + ); + } else { + return Attribute::make( + get: fn () => '-' + ); + } } protected function startDate(): Attribute diff --git a/resources/views/pdf/ecard-lms.blade.php b/resources/views/pdf/ecard-lms.blade.php index 37ff372a..00893477 100644 --- a/resources/views/pdf/ecard-lms.blade.php +++ b/resources/views/pdf/ecard-lms.blade.php @@ -77,10 +77,9 @@ -



+

@if($member->currentCorporate->files && count($member->currentCorporate->files) > 0)
- {{ asset($member->currentCorporate->files[0]->path)}}
@endif From 7db0af3bef21041f2c4301e016b260d7b7310941 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 6 Jan 2024 14:13:13 +0700 Subject: [PATCH 2/2] update fix member detail --- app/Models/Member.php | 69 +++++++++++++++++-- .../src/pages/Corporates/Member/List.tsx | 4 +- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/Models/Member.php b/app/Models/Member.php index 6724d2bb..9f0f6e25 100644 --- a/app/Models/Member.php +++ b/app/Models/Member.php @@ -71,6 +71,9 @@ class Member extends Model 'full_name', 'age', 'gender_code', + 'relations', + 'status_marital' + // 'relation_with_principal' ]; protected $hidden = [ @@ -245,7 +248,7 @@ class Member extends Model protected function genderCode(): Attribute { return Attribute::make( - get: fn () => $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender + get: fn () => $this->gender ? ($this->gender == 'Female' ? 'F' : 'M') : $this->gender ); } @@ -256,6 +259,39 @@ class Member extends Model ); } + + protected function relations(): Attribute + { + $relation = '-'; + if ($this->relation_with_principal == 'H'){ + $relation = 'Husbund'; + } else if ($this->relation_with_principal == 'W'){ + $relation = 'Wife'; + } else if ($this->relation_with_principal == 'S'){ + $relation = 'Son'; + } else if ($this->relation_with_principal == 'D'){ + $relation = 'Daughter'; + } + return Attribute::make( + get: fn () => $relation + ); + } + + protected function statusMarital(): Attribute + { + $maritalStatus = '-'; + if ($this->marital_status == 'M'){ + $maritalStatus = 'Married'; + } else if ($this->relation_with_principal == 'D'){ + $maritalStatus = 'Divorced'; + } else if ($this->relation_with_principal == 'S'){ + $maritalStatus = 'Sungle'; + } + return Attribute::make( + get: fn () => $maritalStatus + ); + } + // protected function birthDate(): Attribute // { // // $date = $this->person->birth_date ?? ($this->birth_date ?? null); @@ -302,12 +338,31 @@ class Member extends Model ); } - protected function gender(): Attribute - { - return Attribute::make( - get: fn () => ucfirst($this->person->gender) ?? null - ); - } + // protected function relationWithPrincipal(): Attribute + // { + // $relation = null; + + // if ($this->relation_with_principal === 'S') { + // $relation = 'Son'; + // } elseif ($this->relation_with_principal === 'H') { + // $relation = 'Husband'; + // } elseif ($this->relation_with_principal === 'D') { + // $relation = 'Daughter'; + // } elseif ($this->relation_with_principal === 'Wife') { + // $relation = 'Wife'; + // } + + // return Attribute::make( + // get: fn () => $relation + // ); + // } + + // protected function gender(): Attribute + // { + // return Attribute::make( + // get: fn () => ucfirst($this->person->gender) ?? null + // ); + // } protected function corporateLogo(): Attribute { diff --git a/frontend/dashboard/src/pages/Corporates/Member/List.tsx b/frontend/dashboard/src/pages/Corporates/Member/List.tsx index 5c30fb60..86c13dbe 100644 --- a/frontend/dashboard/src/pages/Corporates/Member/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/Member/List.tsx @@ -603,7 +603,7 @@ export default function CorporatePlanList({handleSubmitSuccess}) { NRIC: {row.nric ? row.nric : '-'} Marital Status: - {row.marital_status ? row.marital_status : '-'} + {row.status_marital ? row.status_marital : '-'} NIK: @@ -622,7 +622,7 @@ export default function CorporatePlanList({handleSubmitSuccess}) { Email: {row.email ? row.email : '-'} Relationship: - {row.relation_with_principal ? row.relation_with_principal : '-'} + {row.relations ? row.relations : '-'} Phone Number: