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 3163f842..fa8f2729 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 = [ @@ -238,7 +241,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 ); } @@ -286,13 +289,67 @@ class Member extends Model ); } - protected function status(): Attribute + + 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 () => $this->active ? ($this->active == 1 ? 'Active' : 'Inactive') : null + 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); + // $date = $this->birth_date ?? ($this->person->birth_date ?? null); + // return Attribute::make( + // get: fn () => !empty($date) ? Carbon::parse($date)->format('Y-m-d') : null + // ); + // } + + protected function birthDateeCard(): Attribute + { + // $date = $this->person->birth_date ?? ($this->birth_date ?? 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 birthDateCard(): Attribute { $date = $this->birth_date; @@ -329,6 +386,32 @@ class Member extends Model ); } + // 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 { $avatar = null; 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: diff --git a/resources/views/pdf/ecard-lms.blade.php b/resources/views/pdf/ecard-lms.blade.php index d9bc30a2..eb69d6fe 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