diff --git a/app/Controllers/Abha.php b/app/Controllers/Abha.php index 144df6f..6222e59 100644 --- a/app/Controllers/Abha.php +++ b/app/Controllers/Abha.php @@ -474,6 +474,7 @@ class Abha extends BaseController 'abha_qr_url' => $abhaQrUrl, 'patient_mobile' => $mobileNo, 'mobile_verified' => $mobileVerified, + 'stored_abha_card' => trim((string) ($patient['abha_card_base64'] ?? '')), ]); } @@ -803,6 +804,7 @@ class Abha extends BaseController $abhaMeta = [ 'abha_address' => (string) ($this->request->getPost('abha_address') ?? ''), 'profile_photo' => (string) ($this->request->getPost('photo') ?? ''), + 'card_base64' => (string) ($this->request->getPost('card_base64') ?? ''), 'verified_status' => (string) ($this->request->getPost('verified_status') ?? ''), 'verification_type' => (string) ($this->request->getPost('verification_type') ?? ''), 'kyc_verified' => $this->request->getPost('kyc_verified'), @@ -1025,7 +1027,7 @@ class Abha extends BaseController } $selectFields = array_values(array_intersect( - ['id', 'p_code', 'p_fname', 'p_lname', 'gender', 'dob', 'age', 'mphone1', 'udai', 'add1', 'district', 'state', 'zip'], + ['id', 'p_code', 'p_fname', 'p_lname', 'gender', 'dob', 'age', 'mphone1', 'udai', 'add1', 'district', 'state', 'zip', 'profile_file_id', 'profile_picture', 'abha_profile_photo_base64'], $fields )); $select = implode(',', $selectFields); @@ -1109,6 +1111,7 @@ class Abha extends BaseController 'dob' => $rowDob, 'age' => $rowAgeYears, 'mobile' => (string) ($row['mphone1'] ?? ''), + 'photo_url' => $this->resolvePatientPhotoUrl($row), 'address' => trim(implode(', ', array_filter([ (string) ($row['add1'] ?? ''), (string) ($row['district'] ?? ''), @@ -1391,6 +1394,11 @@ class Abha extends BaseController if ($profilePhoto !== '' && in_array('abha_profile_photo_base64', $fields, true)) { $target['abha_profile_photo_base64'] = $profilePhoto; } + + $cardBase64 = trim((string) ($abhaMeta['card_base64'] ?? '')); + if ($cardBase64 !== '' && in_array('abha_card_base64', $fields, true)) { + $target['abha_card_base64'] = $cardBase64; + } } private function toDbBool($value): int diff --git a/app/Database/Migrations/2026-08-13-000001_AddAbhaCardToPatientMaster.php b/app/Database/Migrations/2026-08-13-000001_AddAbhaCardToPatientMaster.php new file mode 100644 index 0000000..869caab --- /dev/null +++ b/app/Database/Migrations/2026-08-13-000001_AddAbhaCardToPatientMaster.php @@ -0,0 +1,43 @@ +tableExists('patient_master')) { + return; + } + + $fields = $this->getColumns('patient_master'); + if (! in_array('abha_card_base64', $fields, true)) { + $this->forge->addColumn('patient_master', [ + 'abha_card_base64' => [ + 'type' => 'LONGTEXT', + 'null' => true, + ], + ]); + } + } + + public function down(): void + { + if ($this->tableExists('patient_master') && in_array('abha_card_base64', $this->getColumns('patient_master'), true)) { + $this->forge->dropColumn('patient_master', 'abha_card_base64'); + } + } + + private function getColumns(string $table): array + { + $result = $this->db->query('SHOW COLUMNS FROM `' . $table . '`')->getResultArray(); + return array_map(static fn (array $row): string => (string) ($row['Field'] ?? ''), $result); + } + + private function tableExists(string $table): bool + { + return ! empty($this->db->query("SHOW TABLES LIKE '" . $table . "'")->getRowArray()); + } +} diff --git a/app/Views/abha/card.php b/app/Views/abha/card.php index ce7b7fc..6e60560 100644 --- a/app/Views/abha/card.php +++ b/app/Views/abha/card.php @@ -168,6 +168,8 @@ background: #fff; } .qr-value { margin-top: 5px; font-size: 10px; color: #3b5474; word-break: break-word; } + .official-card-wrap { margin-top: 14px; text-align: center; } + .official-card { display: block; width: 100%; max-height: 480px; object-fit: contain; border: 1px solid #d8e6fb; border-radius: 8px; background: #fff; } .abha-number-wrap { margin-top: 12px; border: 1px solid #d3e3f9; @@ -241,6 +243,10 @@ $abhaQrUrl = esc($abha_qr_url ?? ''); $barcodeImage = esc($hms_barcode_image ?? ''); $patientMobile = esc($patient_mobile ?? ''); $mobileVerified = (bool) ($mobile_verified ?? false); +$storedAbhaCard = trim((string) ($stored_abha_card ?? '')); +$storedAbhaCardSrc = $storedAbhaCard !== '' + ? (str_starts_with($storedAbhaCard, 'data:') ? $storedAbhaCard : 'data:image/png;base64,' . $storedAbhaCard) + : ''; ?>