Add configurable footer version setting

This commit is contained in:
DevSoftTech Server 2026-03-27 13:38:56 +05:30
parent b1ba3105c0
commit d293c261e6
5 changed files with 81 additions and 1 deletions

View File

@ -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',

View File

@ -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();
}
}

View File

@ -27,6 +27,11 @@
<label class="form-label">Hospital Email</label>
<input type="text" class="form-control" id="hospital_email" value="<?= esc($hospital_email ?? '') ?>" placeholder="hospital@example.com">
</div>
<div class="col-md-6">
<label class="form-label">Version / Update ID</label>
<input type="text" class="form-control" id="footer_version" value="<?= esc($footer_version ?? '') ?>" placeholder="e.g. 2026.03.27.01">
<div class="form-text">Shown in the footer so live deployments can be verified without code changes.</div>
</div>
<div class="col-md-7">
<label class="form-label">Hospital Logo</label>
@ -142,6 +147,7 @@
fd.append('hospital_address_2', ($('#hospital_address_2').val() || '').trim());
fd.append('hospital_phone', ($('#hospital_phone').val() || '').trim());
fd.append('hospital_email', ($('#hospital_email').val() || '').trim());
fd.append('footer_version', ($('#footer_version').val() || '').trim());
fd.append('pharmacy_name', ($('#pharmacy_name').val() || '').trim());
fd.append('pharmacy_address', ($('#pharmacy_address').val() || '').trim());
fd.append('pharmacy_phone', ($('#pharmacy_phone').val() || '').trim());
@ -255,6 +261,7 @@
$('#hospital_address_2').val('');
$('#hospital_phone').val('');
$('#hospital_email').val('');
$('#footer_version').val('');
$('#pharmacy_name').val('');
$('#pharmacy_address').val('');
$('#pharmacy_phone').val('');

View File

@ -1,3 +1,4 @@
<?php helper('common'); ?>
<!DOCTYPE html>
<html lang="en">
@ -29,6 +30,8 @@
<body>
<?php $footerVersion = hms_footer_version(); ?>
<main>
<div class="container">
@ -129,6 +132,10 @@
</div>
</main>
<footer class="py-3 text-center text-muted small">
&copy; 2017 - 2026 <strong>E-Atria</strong>. All Rights Reserved | Version: <?= esc($footerVersion) ?>
</footer>
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>

View File

@ -1,3 +1,4 @@
<?php helper('common'); ?>
<!DOCTYPE html>
<html lang="en">
@ -34,6 +35,7 @@
<body>
<?php $user = auth()->user(); ?>
<?php $footerVersion = hms_footer_version(); ?>
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
@ -56,7 +58,7 @@
<footer id="footer" class="footer">
<div class="copyright">
&copy; 2017 - <?= date('Y') ?> <strong><span>E-Atria</span></strong>. All Rights Reserved
&copy; 2017 - 2026 <strong><span>E-Atria</span></strong>. All Rights Reserved | Version: <?= esc($footerVersion) ?>
</div>
</footer>
<div id="wait"