diff --git a/api/settings.php b/api/settings.php index 9cd53bf..e3c5c9a 100644 --- a/api/settings.php +++ b/api/settings.php @@ -12,7 +12,7 @@ if (!in_array($user['role'], ['owner', 'manager'])) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pdo = db(); $keys = [ - 'company_name_ar', 'company_name_en', 'vat_percentage', + 'timezone', 'company_name_ar', 'company_name_en', 'vat_percentage', 'company_vat_number', 'company_phone', 'company_email', 'company_address', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_secure', 'mail_from', 'mail_from_name' ]; @@ -54,4 +54,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $referer = $_SERVER['HTTP_REFERER'] ?? '../index.php'; header('Location: ' . $referer); exit; -} +} \ No newline at end of file diff --git a/includes/app.php b/includes/app.php index bb69dbf..27fe2c7 100644 --- a/includes/app.php +++ b/includes/app.php @@ -7,7 +7,7 @@ if (session_status() !== PHP_SESSION_ACTIVE) { require_once __DIR__ . '/../db/config.php'; -date_default_timezone_set('UTC'); + function get_settings(): array { @@ -33,6 +33,15 @@ function get_setting(string $key, $default = '') return $settings[$key] ?? $default; } +$app_tz = get_setting('timezone', 'UTC'); +if (empty($app_tz)) { + $app_tz = 'UTC'; +} +date_default_timezone_set($app_tz); +try { + db()->exec("SET time_zone = '" . date('P') . "'"); +} catch (Throwable $e) {} + function app_name(): string diff --git a/includes/footer_settings.php b/includes/footer_settings.php index 4b25295..059ed01 100644 --- a/includes/footer_settings.php +++ b/includes/footer_settings.php @@ -10,6 +10,17 @@