feat: add timezone setting to admin panel
This commit is contained in:
parent
486d54348f
commit
a361ed7269
@ -14,6 +14,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$companyPhone = trim($_POST['company_phone'] ?? '');
|
||||
$companyAddress = trim($_POST['company_address'] ?? '');
|
||||
$platformCharge = trim($_POST['platform_charge_percentage'] ?? '0');
|
||||
$timezone = trim($_POST['timezone'] ?? 'UTC');
|
||||
|
||||
$updates = [
|
||||
'company_name' => $companyName,
|
||||
@ -21,6 +22,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
'company_phone' => $companyPhone,
|
||||
'company_address' => $companyAddress,
|
||||
'platform_charge_percentage' => $platformCharge,
|
||||
'timezone' => $timezone,
|
||||
'terms_en' => trim($_POST['terms_en'] ?? ''),
|
||||
'terms_ar' => trim($_POST['terms_ar'] ?? ''),
|
||||
'privacy_en' => trim($_POST['privacy_en'] ?? ''),
|
||||
@ -80,6 +82,7 @@ $currentEmail = $settings['company_email'] ?? '';
|
||||
$currentPhone = $settings['company_phone'] ?? '';
|
||||
$currentAddress = $settings['company_address'] ?? '';
|
||||
$currentPlatformCharge = $settings['platform_charge_percentage'] ?? '0';
|
||||
$currentTimezone = $settings['timezone'] ?? 'UTC';
|
||||
$currentLogo = $settings['logo_path'] ?? '';
|
||||
$currentFavicon = $settings['favicon_path'] ?? '';
|
||||
$currentTermsEn = $settings['terms_en'] ?? '';
|
||||
@ -163,6 +166,18 @@ render_header('Company Profile', 'admin', true);
|
||||
<div class="form-text">Percentage applied as a platform fee.</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold"><?= e(t('timezone')) ?></label>
|
||||
<select name="timezone" class="form-select">
|
||||
<?php foreach (DateTimeZone::listIdentifiers() as $tz): ?>
|
||||
<option value="<?= e($tz) ?>" <?= $tz === $currentTimezone ? 'selected' : '' ?>>
|
||||
<?= e($tz) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="form-text">System Timezone</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<hr class="my-2">
|
||||
</div>
|
||||
|
||||
@ -14,9 +14,10 @@ try {
|
||||
('company_address', '123 Transport St, City, Country'),
|
||||
('platform_charge_percentage', '0'),
|
||||
('logo_path', ''),
|
||||
('favicon_path', '');
|
||||
('favicon_path', ''),
|
||||
('timezone', 'UTC');
|
||||
");
|
||||
echo "Settings table created/updated.\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +254,8 @@ $translations = [
|
||||
'reset_password_title' => 'Reset Password',
|
||||
'reset_password_subtitle' => 'Enter your email to receive a reset link',
|
||||
'send_reset_link' => 'Send Reset Link',
|
||||
'back_to_login' => 'Back to Login'
|
||||
'back_to_login' => 'Back to Login',
|
||||
'timezone' => 'Timezone',
|
||||
),
|
||||
"ar" => array (
|
||||
'app_name' => 'CargoLink',
|
||||
@ -497,7 +498,8 @@ $translations = [
|
||||
'reset_password_title' => 'إعادة تعيين كلمة المرور',
|
||||
'reset_password_subtitle' => 'أدخل بريدك الإلكتروني لتلقي رابط إعادة التعيين',
|
||||
'send_reset_link' => 'إرسال رابط إعادة التعيين',
|
||||
'back_to_login' => 'العودة لتسجيل الدخول'
|
||||
'back_to_login' => 'العودة لتسجيل الدخول',
|
||||
'timezone' => 'المنطقة الزمنية',
|
||||
)
|
||||
];
|
||||
|
||||
@ -711,4 +713,12 @@ function has_permission(string $permissionSlug, ?int $userId = null): bool
|
||||
function format_currency(float $amount): string
|
||||
{
|
||||
return number_format($amount, 3) . ' OMR';
|
||||
}
|
||||
}
|
||||
|
||||
// Set timezone from settings
|
||||
try {
|
||||
$tz = get_setting('timezone', 'UTC');
|
||||
if ($tz && in_array($tz, DateTimeZone::listIdentifiers())) {
|
||||
date_default_timezone_set($tz);
|
||||
}
|
||||
} catch (Throwable $e) {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user