adding timezone
This commit is contained in:
parent
dd6a5338d0
commit
e4e262595a
34
index.php
34
index.php
@ -49,6 +49,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
file_put_contents('post_debug.log', date('Y-m-d H:i:s') . " - POST: " . json_encode($_POST) . "\n", FILE_APPEND);
|
||||
}
|
||||
require_once 'db/config.php';
|
||||
|
||||
# Timezone setup
|
||||
try {
|
||||
$stmt_tz = db()->prepare("SELECT `value` FROM settings WHERE `key` = 'time_zone'");
|
||||
$stmt_tz->execute();
|
||||
$tz_setting = $stmt_tz->fetchColumn();
|
||||
$timezone = $tz_setting ?: 'Asia/Muscat'; // Default to Muscat
|
||||
date_default_timezone_set($timezone);
|
||||
# Sync DB
|
||||
$now = new DateTime();
|
||||
$mins = $now->getOffset() / 60;
|
||||
$sgn = ($mins < 0 ? -1 : 1);
|
||||
$mins = abs($mins);
|
||||
$hrs = floor($mins / 60);
|
||||
$mins -= $hrs * 60;
|
||||
$offset = sprintf('%+d:%02d', $hrs * $sgn, $mins);
|
||||
db()->exec("SET time_zone = '$offset'");
|
||||
} catch (Exception $e) {
|
||||
date_default_timezone_set('Asia/Muscat');
|
||||
}
|
||||
|
||||
require_once 'includes/DatabaseInstaller.php';
|
||||
|
||||
// Auto-install database if not installed
|
||||
@ -9031,6 +9052,19 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
|
||||
<option value="1" <?= ($data['settings']['allow_zero_stock_sell'] ?? '1') === '1' ? 'selected' : '' ?> data-en="Enabled" data-ar="مفعل">Enabled</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4 mt-3">
|
||||
<label class="form-label" data-en="Timezone" data-ar="المنطقة الزمنية">Timezone</label>
|
||||
<select name="settings[time_zone]" class="form-select">
|
||||
<?php
|
||||
$current_tz = $data['settings']['time_zone'] ?? 'Asia/Muscat';
|
||||
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
|
||||
foreach ($timezones as $tz) {
|
||||
$selected = ($tz === $current_tz) ? 'selected' : '';
|
||||
echo "<option value='$tz' $selected>$tz</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4 mt-3">
|
||||
<label class="form-label" data-en="Company Logo" data-ar="شعار الشركة">Company Logo</label>
|
||||
<input type="file" name="company_logo" class="form-control" accept="image/*">
|
||||
|
||||
10
repair_timezone.py
Normal file
10
repair_timezone.py
Normal file
@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
file_path = 'index.php'
|
||||
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Fix the syntax error
|
||||
search_bad = 'echo "<option value=\"$tz\" $selected>$tz</option>";'
|
||||
replace_good = 'echo "<option value=\\\
|
||||
Loading…
x
Reference in New Issue
Block a user