diff --git a/app/Controllers/Setting/HospitalProfile.php b/app/Controllers/Setting/HospitalProfile.php index 31218d6..1bc0011 100644 --- a/app/Controllers/Setting/HospitalProfile.php +++ b/app/Controllers/Setting/HospitalProfile.php @@ -15,6 +15,7 @@ class HospitalProfile extends BaseController $logo = $this->readSettingValue('H_logo'); $pharmacyLogo = $this->readSettingValue('H_Med_logo'); + helper('common'); return view('Setting/Admin/hospital_profile', [ 'hospital_name' => $this->readSettingValue('H_Name'), @@ -22,6 +23,9 @@ class HospitalProfile extends BaseController 'hospital_address_2' => $this->readSettingValue('H_address_2'), 'hospital_phone' => $this->readSettingValue('H_phone_No'), 'hospital_email' => $this->readSettingValue('H_Email'), + 'footer_version' => $this->readSettingValue('HMS_UPDATE_ID') !== '' + ? $this->readSettingValue('HMS_UPDATE_ID') + : hms_default_version_id(), 'hospital_logo' => $logo, 'hospital_logo_url' => $logo !== '' ? base_url('assets/images/' . rawurlencode($logo)) : '', 'pharmacy_name' => $this->readSettingValue('H_Med_Name'), @@ -52,6 +56,7 @@ class HospitalProfile extends BaseController $address2 = trim((string) $this->request->getPost('hospital_address_2')); $phone = trim((string) $this->request->getPost('hospital_phone')); $email = trim((string) $this->request->getPost('hospital_email')); + $footerVersion = trim((string) $this->request->getPost('footer_version')); $pharmacyName = trim((string) $this->request->getPost('pharmacy_name')); $pharmacyAddress = trim((string) $this->request->getPost('pharmacy_address')); @@ -83,6 +88,9 @@ class HospitalProfile extends BaseController if ($this->upsertSettingValue('H_Email', $email)) { $savedCount++; } + if ($this->upsertSettingValue('HMS_UPDATE_ID', $footerVersion)) { + $savedCount++; + } if ($this->upsertSettingValue('H_Med_Name', $pharmacyName)) { $savedCount++; } @@ -196,6 +204,7 @@ class HospitalProfile extends BaseController 'H_address_2', 'H_phone_No', 'H_Email', + 'HMS_UPDATE_ID', 'H_logo', 'H_Med_Name', 'H_Med_address_1', diff --git a/app/Helpers/common_helper.php b/app/Helpers/common_helper.php index f811ce6..6335994 100644 --- a/app/Helpers/common_helper.php +++ b/app/Helpers/common_helper.php @@ -157,3 +157,58 @@ function cal_exp(string $exp) return $result; } + +if (! function_exists('hospital_setting_value')) { + function hospital_setting_value(string $name, string $default = ''): string + { + static $settings = null; + + if ($settings === null) { + $settings = []; + + try { + $db = db_connect(); + if ($db && method_exists($db, 'tableExists') && $db->tableExists('hospital_setting')) { + $rows = $db->table('hospital_setting') + ->select('s_name, s_value') + ->get() + ->getResultArray(); + + foreach ($rows as $row) { + $key = trim((string) ($row['s_name'] ?? '')); + if ($key === '') { + continue; + } + + $settings[$key] = trim((string) ($row['s_value'] ?? '')); + } + } + } catch (\Throwable $e) { + $settings = []; + } + } + + return array_key_exists($name, $settings) ? (string) $settings[$name] : $default; + } +} + +if (! function_exists('hms_footer_version')) { + function hms_default_version_id(): string + { + return date('y') . '.' . str_pad((string) ((int) date('z') + 1), 3, '0', STR_PAD_LEFT); + } +} + +if (! function_exists('hms_footer_version')) { + function hms_footer_version(string $default = ''): string + { + foreach (['HMS_UPDATE_ID', 'HMS_VERSION_NO', 'APP_VERSION_NO'] as $key) { + $value = hospital_setting_value($key, ''); + if ($value !== '') { + return $value; + } + } + + return $default !== '' ? $default : hms_default_version_id(); + } +} diff --git a/app/Views/Setting/Admin/hospital_profile.php b/app/Views/Setting/Admin/hospital_profile.php index d52368b..a78e5f9 100644 --- a/app/Views/Setting/Admin/hospital_profile.php +++ b/app/Views/Setting/Admin/hospital_profile.php @@ -27,6 +27,11 @@ +