some new updates
This commit is contained in:
parent
5f8d3b1aed
commit
9f43a69a1d
@ -69,6 +69,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
set_setting('loyalty_currency_per_point', $_POST['loyalty_currency_per_point'] ?? '0.05');
|
||||
$success = __('success_update');
|
||||
}
|
||||
|
||||
if ($is_super && isset($_POST['save_smtp_settings'])) {
|
||||
set_setting('smtp_host', $_POST['smtp_host'] ?? '');
|
||||
set_setting('smtp_port', $_POST['smtp_port'] ?? '587');
|
||||
set_setting('smtp_user', $_POST['smtp_user'] ?? '');
|
||||
set_setting('smtp_pass', $_POST['smtp_pass'] ?? '');
|
||||
set_setting('smtp_secure', $_POST['smtp_secure'] ?? 'tls');
|
||||
$success = __('success_update');
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure SMTP settings exist for display fallback
|
||||
if ($is_super) {
|
||||
if (get_setting('smtp_host') === null) {
|
||||
$env_host = getenv('SMTP_HOST');
|
||||
set_setting('smtp_host', $env_host !== false ? $env_host : '');
|
||||
$env_port = getenv('SMTP_PORT');
|
||||
set_setting('smtp_port', $env_port !== false ? $env_port : '587');
|
||||
$env_user = getenv('SMTP_USER');
|
||||
set_setting('smtp_user', $env_user !== false ? $env_user : '');
|
||||
$env_pass = getenv('SMTP_PASS');
|
||||
set_setting('smtp_pass', $env_pass !== false ? $env_pass : '');
|
||||
$env_secure = getenv('SMTP_SECURE');
|
||||
set_setting('smtp_secure', $env_secure !== false ? $env_secure : 'tls');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -90,92 +115,173 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card p-4 mb-4 shadow-sm border-0" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-building me-2"></i> <?= is_arabic() ? 'معلومات الشركة' : 'Company Information' ?></h5>
|
||||
<form action="company_profile.php" method="POST" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('name_en') ?></label><input type="text" name="name_en" class="form-control rounded-3" value="<?= htmlspecialchars($company['name_en'] ?? '') ?>" required></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('name_ar') ?></label><input type="text" name="name_ar" class="form-control rounded-3" value="<?= htmlspecialchars($company['name_ar'] ?? '') ?>" required></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('email') ?></label><input type="email" name="email" class="form-control rounded-3" value="<?= htmlspecialchars($company['email'] ?? '') ?>"></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('phone') ?></label><input type="text" name="phone" class="form-control rounded-3" value="<?= htmlspecialchars($company['phone'] ?? '') ?>"></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('ctr_no') ?></label><input type="text" name="ctr_no" class="form-control rounded-3" value="<?= htmlspecialchars($company['ctr_no'] ?? '') ?>"></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('vat_no') ?></label><input type="text" name="vat_no" class="form-control rounded-3" value="<?= htmlspecialchars($company['vat_no'] ?? '') ?>"></div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-6"><label class="form-label"><?= __('logo') ?></label><input type="file" name="logo" class="form-control rounded-3" accept="image/*"><?php if ($company['logo']): ?><img src="<?= $company['logo'] ?>" alt="Logo" class="mt-2 rounded border" style="max-height: 50px;"><?php endif; ?></div>
|
||||
<div class="col-md-6"><label class="form-label"><?= __('favicon') ?></label><input type="file" name="favicon" class="form-control rounded-3" accept="image/*"><?php if ($company['favicon']): ?><img src="<?= $company['favicon'] ?>" alt="Favicon" class="mt-2 rounded border" style="max-height: 32px;"><?php endif; ?></div>
|
||||
<ul class="nav nav-pills mb-4" id="settingsTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active px-4 rounded-pill me-2 fw-semibold" id="main-tab" data-bs-toggle="pill" data-bs-target="#main-settings" type="button" role="tab"><i class="bi bi-building me-2"></i> <?= is_arabic() ? 'الإعدادات العامة' : 'Main Settings' ?></button>
|
||||
</li>
|
||||
<?php if ($is_super): ?>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link px-4 rounded-pill me-2 fw-semibold" id="whatsapp-tab" data-bs-toggle="pill" data-bs-target="#whatsapp-settings" type="button" role="tab"><i class="bi bi-whatsapp me-2"></i> <?= __('whatsapp_settings') ?></button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link px-4 rounded-pill me-2 fw-semibold" id="loyalty-tab" data-bs-toggle="pill" data-bs-target="#loyalty-settings" type="button" role="tab"><i class="bi bi-star-fill me-2"></i> <?= __('loyalty_settings') ?></button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link px-4 rounded-pill fw-semibold" id="smtp-tab" data-bs-toggle="pill" data-bs-target="#smtp-settings" type="button" role="tab"><i class="bi bi-envelope me-2"></i> <?= __('smtp_settings') ?></button>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="settingsTabsContent">
|
||||
<!-- MAIN SETTINGS -->
|
||||
<div class="tab-pane fade show active" id="main-settings" role="tabpanel">
|
||||
<div class="card p-4 shadow-sm border-0" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-building me-2"></i> <?= is_arabic() ? 'معلومات الشركة' : 'Company Information' ?></h5>
|
||||
<form action="company_profile.php" method="POST" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('name_en') ?></label><input type="text" name="name_en" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['name_en'] ?? '') ?>" required></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('name_ar') ?></label><input type="text" name="name_ar" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['name_ar'] ?? '') ?>" required></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('email') ?></label><input type="email" name="email" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['email'] ?? '') ?>"></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('phone') ?></label><input type="text" name="phone" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['phone'] ?? '') ?>"></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('ctr_no') ?></label><input type="text" name="ctr_no" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['ctr_no'] ?? '') ?>"></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('vat_no') ?></label><input type="text" name="vat_no" class="form-control form-control-sm rounded-3" value="<?= htmlspecialchars($company['vat_no'] ?? '') ?>"></div>
|
||||
|
||||
<div class="col-md-8 mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-6"><label class="form-label small fw-bold"><?= __('logo') ?></label><input type="file" name="logo" class="form-control form-control-sm rounded-3" accept="image/*"><?php if ($company['logo']): ?><img src="<?= $company['logo'] ?>" alt="Logo" class="mt-2 rounded border" style="max-height: 50px;"><?php endif; ?></div>
|
||||
<div class="col-md-6"><label class="form-label small fw-bold"><?= __('favicon') ?></label><input type="file" name="favicon" class="form-control form-control-sm rounded-3" accept="image/*"><?php if ($company['favicon']): ?><img src="<?= $company['favicon'] ?>" alt="Favicon" class="mt-2 rounded border" style="max-height: 32px;"><?php endif; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('address_en') ?></label><textarea name="address_en" class="form-control rounded-3" rows="3"><?= htmlspecialchars($company['address_en'] ?? '') ?></textarea></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label"><?= __('address_ar') ?></label><textarea name="address_ar" class="form-control rounded-3" rows="3"><?= htmlspecialchars($company['address_ar'] ?? '') ?></textarea></div>
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_company_profile" class="btn btn-primary px-5 rounded-4 shadow-sm"><i class="bi bi-save me-2"></i> <?= __('save_changes') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="row g-4 mb-4">
|
||||
<?php if ($is_super): ?>
|
||||
<div class="col-md-6">
|
||||
<div class="card p-4 shadow-sm border-0 h-100" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-whatsapp text-success me-2"></i> <?= __('whatsapp_settings') ?></h5>
|
||||
<form method="POST">
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="whatsapp_enabled" name="whatsapp_enabled" value="1" <?= get_setting('whatsapp_enabled') == '1' ? 'checked' : '' ?>>
|
||||
<label class="form-check-label fw-semibold" for="whatsapp_enabled"><?= __('whatsapp_enabled') ?></label>
|
||||
</div>
|
||||
<div class="mb-3"><label class="form-label small fw-bold"><?= __('wablas_token') ?></label><input type="text" class="form-control rounded-3" name="wablas_token" value="<?= htmlspecialchars(get_setting('wablas_token', '')) ?>"></div>
|
||||
<div class="mb-3"><label class="form-label small fw-bold"><?= __('wablas_server') ?></label><input type="text" class="form-control rounded-3" name="wablas_server" value="<?= htmlspecialchars(get_setting('wablas_server', 'https://console.wablas.com')) ?>"></div>
|
||||
<div class="mb-4"><label class="form-label small fw-bold"><?= __('wablas_security_key') ?></label><input type="text" class="form-control rounded-3" name="wablas_security_key" value="<?= htmlspecialchars(get_setting('wablas_security_key', '')) ?>"></div>
|
||||
<div class="text-end"><button type="submit" name="save_whatsapp_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3"><label class="form-label small fw-bold"><?= __('address_en') ?></label><textarea name="address_en" class="form-control form-control-sm rounded-3" rows="3"><?= htmlspecialchars($company['address_en'] ?? '') ?></textarea></div>
|
||||
<div class="col-md-6 mb-3"><label class="form-label small fw-bold"><?= __('address_ar') ?></label><textarea name="address_ar" class="form-control form-control-sm rounded-3" rows="3"><?= htmlspecialchars($company['address_ar'] ?? '') ?></textarea></div>
|
||||
</div>
|
||||
<div class="text-end mt-2"><button type="submit" name="save_company_profile" class="btn btn-primary px-5 rounded-4 shadow-sm"><i class="bi bi-save me-2"></i> <?= __('save_changes') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card p-4 shadow-sm border-0 h-100" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-star-fill text-warning me-2"></i> <?= __('loyalty_settings') ?></h5>
|
||||
<form method="POST">
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="loyalty_enabled" name="loyalty_enabled" value="1" <?= get_setting('loyalty_enabled') == '1' ? 'checked' : '' ?>>
|
||||
<label class="form-check-label fw-semibold" for="loyalty_enabled"><?= __('loyalty_enabled') ?></label>
|
||||
<?php if ($is_super): ?>
|
||||
<!-- WHATSAPP SETTINGS -->
|
||||
<div class="tab-pane fade" id="whatsapp-settings" role="tabpanel">
|
||||
<div class="card p-4 shadow-sm border-0 mb-4" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-whatsapp text-success me-2"></i> <?= __('whatsapp_settings') ?></h5>
|
||||
<form method="POST">
|
||||
<div class="form-check form-switch mb-4">
|
||||
<input class="form-check-input" type="checkbox" id="whatsapp_enabled" name="whatsapp_enabled" value="1" <?= get_setting('whatsapp_enabled') == '1' ? 'checked' : '' ?>>
|
||||
<label class="form-check-label fw-semibold" for="whatsapp_enabled"><?= __('whatsapp_enabled') ?></label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('wablas_token') ?></label><input type="text" class="form-control form-control-sm rounded-3" name="wablas_token" value="<?= htmlspecialchars(get_setting('wablas_token', '')) ?>"></div>
|
||||
<div class="col-md-4 mb-3"><label class="form-label small fw-bold"><?= __('wablas_server') ?></label><input type="text" class="form-control form-control-sm rounded-3" name="wablas_server" value="<?= htmlspecialchars(get_setting('wablas_server', 'https://console.wablas.com')) ?>"></div>
|
||||
<div class="col-md-4 mb-4"><label class="form-label small fw-bold"><?= __('wablas_security_key') ?></label><input type="text" class="form-control form-control-sm rounded-3" name="wablas_security_key" value="<?= htmlspecialchars(get_setting('wablas_security_key', '')) ?>"></div>
|
||||
</div>
|
||||
|
||||
<hr class="text-muted opacity-25 my-4">
|
||||
|
||||
<h5 class="fw-bold mb-3 mt-3"><i class="bi bi-chat-dots me-2"></i> <?= is_arabic() ? 'قوالب الرسائل' : 'Message Templates' ?></h5>
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('msg_order_created_ar') ?></label>
|
||||
<textarea class="form-control form-control-sm rounded-3 mb-1" name="msg_order_created_ar" rows="4"><?= htmlspecialchars(get_setting('msg_order_created_ar', '')) ?></textarea>
|
||||
<small class="text-muted" style="font-size: 0.75rem;">Tags: {customer_name}, {order_number}, {order_details}, {total_price}</small>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('msg_order_ready_ar') ?></label>
|
||||
<textarea class="form-control form-control-sm rounded-3 mb-1" name="msg_order_ready_ar" rows="4"><?= htmlspecialchars(get_setting('msg_order_ready_ar', '')) ?></textarea>
|
||||
<small class="text-muted" style="font-size: 0.75rem;">Tags: {customer_name}, {order_number}</small>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<label class="form-label small fw-bold"><?= __('msg_payment_ar') ?></label>
|
||||
<textarea class="form-control form-control-sm rounded-3 mb-1" name="msg_payment_ar" rows="4"><?= htmlspecialchars(get_setting('msg_payment_ar', '')) ?></textarea>
|
||||
<small class="text-muted" style="font-size: 0.75rem;">Tags: {customer_name}, {order_number}, {amount}, {remaining_balance}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_whatsapp_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LOYALTY SETTINGS -->
|
||||
<div class="tab-pane fade" id="loyalty-settings" role="tabpanel">
|
||||
<div class="card p-4 shadow-sm border-0 mb-4" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-star-fill text-warning me-2"></i> <?= __('loyalty_settings') ?></h5>
|
||||
<form method="POST">
|
||||
<div class="form-check form-switch mb-4">
|
||||
<input class="form-check-input" type="checkbox" id="loyalty_enabled" name="loyalty_enabled" value="1" <?= get_setting('loyalty_enabled') == '1' ? 'checked' : '' ?>>
|
||||
<label class="form-check-label fw-semibold" for="loyalty_enabled"><?= __('loyalty_enabled') ?></label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('loyalty_points_per_currency') ?></label>
|
||||
<input type="number" step="0.01" class="form-control rounded-3" name="loyalty_points_per_currency" value="<?= htmlspecialchars(get_setting('loyalty_points_per_currency', '1')) ?>">
|
||||
<input type="number" step="0.01" class="form-control form-control-sm rounded-3" name="loyalty_points_per_currency" value="<?= htmlspecialchars(get_setting('loyalty_points_per_currency', '1')) ?>">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<div class="col-md-4 mb-4">
|
||||
<label class="form-label small fw-bold"><?= __('loyalty_currency_per_point') ?></label>
|
||||
<input type="number" step="0.001" class="form-control rounded-3" name="loyalty_currency_per_point" value="<?= htmlspecialchars(get_setting('loyalty_currency_per_point', '0.05')) ?>">
|
||||
<input type="number" step="0.001" class="form-control form-control-sm rounded-3" name="loyalty_currency_per_point" value="<?= htmlspecialchars(get_setting('loyalty_currency_per_point', '0.05')) ?>">
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_loyalty_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_loyalty_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- SMTP SETTINGS -->
|
||||
<div class="tab-pane fade" id="smtp-settings" role="tabpanel">
|
||||
<div class="card p-4 shadow-sm border-0 mb-4" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-envelope text-primary me-2"></i> <?= __('smtp_settings') ?></h5>
|
||||
<form method="POST">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('smtp_host') ?></label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3" name="smtp_host" value="<?= htmlspecialchars(get_setting('smtp_host', '')) ?>">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('smtp_port') ?></label>
|
||||
<input type="number" class="form-control form-control-sm rounded-3" name="smtp_port" value="<?= htmlspecialchars(get_setting('smtp_port', '587')) ?>">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('smtp_secure') ?></label>
|
||||
<select class="form-select form-select-sm rounded-3" name="smtp_secure">
|
||||
<option value="tls" <?= get_setting('smtp_secure', 'tls') == 'tls' ? 'selected' : '' ?>>TLS</option>
|
||||
<option value="ssl" <?= get_setting('smtp_secure') == 'ssl' ? 'selected' : '' ?>>SSL</option>
|
||||
<option value="" <?= get_setting('smtp_secure') == '' ? 'selected' : '' ?>>None</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<label class="form-label small fw-bold"><?= __('smtp_user') ?></label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3" name="smtp_user" value="<?= htmlspecialchars(get_setting('smtp_user', '')) ?>">
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<label class="form-label small fw-bold"><?= __('smtp_pass') ?></label>
|
||||
<input type="password" class="form-control form-control-sm rounded-3" name="smtp_pass" value="<?= htmlspecialchars(get_setting('smtp_pass', '')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_smtp_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($is_super): ?>
|
||||
<div class="card p-4 shadow-sm border-0" style="border-radius: 20px;">
|
||||
<h5 class="fw-bold mb-4"><i class="bi bi-chat-dots me-2"></i> <?= is_arabic() ? 'قوالب الرسائل' : 'Message Templates' ?></h5>
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('msg_order_created_ar') ?></label>
|
||||
<textarea class="form-control rounded-3 mb-1" name="msg_order_created_ar" rows="2"><?= htmlspecialchars(get_setting('msg_order_created_ar', '')) ?></textarea>
|
||||
<small class="text-muted">Tags: {customer_name}, {order_number}, {order_details}, {total_price}</small>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold"><?= __('msg_order_ready_ar') ?></label>
|
||||
<textarea class="form-control rounded-3 mb-1" name="msg_order_ready_ar" rows="2"><?= htmlspecialchars(get_setting('msg_order_ready_ar', '')) ?></textarea>
|
||||
<small class="text-muted">Tags: {customer_name}, {order_number}</small>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label small fw-bold"><?= __('msg_payment_ar') ?></label>
|
||||
<textarea class="form-control rounded-3 mb-1" name="msg_payment_ar" rows="2"><?= htmlspecialchars(get_setting('msg_payment_ar', '')) ?></textarea>
|
||||
<small class="text-muted">Tags: {customer_name}, {order_number}, {amount}, {remaining_balance}</small>
|
||||
</div>
|
||||
<div class="text-end"><button type="submit" name="save_whatsapp_settings" class="btn btn-primary px-4 rounded-3 shadow-sm"><?= __('save') ?></button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
// Save active tab in localStorage
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
let activeTab = localStorage.getItem('activeSettingsTab');
|
||||
if (activeTab) {
|
||||
let tabEl = document.querySelector('button[data-bs-target="' + activeTab + '"]');
|
||||
if (tabEl) {
|
||||
let tab = new bootstrap.Tab(tabEl);
|
||||
tab.show();
|
||||
}
|
||||
}
|
||||
document.querySelectorAll('button[data-bs-toggle="pill"]').forEach(function(el) {
|
||||
el.addEventListener('shown.bs.tab', function(e) {
|
||||
localStorage.setItem('activeSettingsTab', e.target.getAttribute('data-bs-target'));
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
@ -40,6 +40,22 @@ function check_permission($page = null, $user_id = null) {
|
||||
if (isset($permissions_cache[$cache_key])) return $permissions_cache[$cache_key];
|
||||
|
||||
try {
|
||||
// First check if user is super_admin
|
||||
$role = null;
|
||||
if (isset($_SESSION) && isset($_SESSION['user_id']) && $_SESSION['user_id'] == $user_id && isset($_SESSION['role'])) {
|
||||
$role = $_SESSION['role'];
|
||||
} else {
|
||||
$stmt = db()->prepare("SELECT role FROM users WHERE id = ?");
|
||||
$stmt->execute([$user_id]);
|
||||
$role = $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
if ($role === 'super_admin') {
|
||||
$result = ['view' => 1, 'add' => 1, 'edit' => 1, 'delete' => 1];
|
||||
$permissions_cache[$cache_key] = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$stmt = db()->prepare("SELECT can_view as view, can_add as `add`, can_edit as edit, can_delete as `delete` FROM user_permissions WHERE user_id = ? AND page = ?");
|
||||
$stmt->execute([$user_id, $page]);
|
||||
$perms = $stmt->fetch();
|
||||
|
||||
@ -341,56 +341,7 @@ if ($current_user_id && $current_page !== 'login.php' && $current_page !== 'logo
|
||||
<h1 class="h2"><?= __($title ?? 'dashboard') ?></h1>
|
||||
<div class="mb-2 mb-md-0">
|
||||
<div class="d-flex align-items-center">
|
||||
<?php if ($current_role === 'super_admin'): ?>
|
||||
<?php $is_whatsapp_enabled = get_setting('whatsapp_enabled') == '1'; ?>
|
||||
<button id="global_whatsapp_toggle_btn" class="btn btn-sm rounded-pill px-3 me-3 whatsapp-toggle-btn <?= $is_whatsapp_enabled ? 'active' : '' ?>" style="height: 38px; display: flex; align-items: center; font-weight: 600;">
|
||||
<i class="bi <?= $is_whatsapp_enabled ? 'bi-whatsapp' : 'bi-chat-left-dots' ?> me-2"></i>
|
||||
<span><?= $is_whatsapp_enabled ? __('messages_enabled') : __('messages_disabled') ?></span>
|
||||
</button>
|
||||
|
||||
<script>
|
||||
document.getElementById('global_whatsapp_toggle_btn').addEventListener('click', function() {
|
||||
const btn = this;
|
||||
const isActive = btn.classList.contains('active');
|
||||
const newValue = isActive ? '0' : '1';
|
||||
const span = btn.querySelector('span');
|
||||
const icon = btn.querySelector('i');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('key', 'whatsapp_enabled');
|
||||
formData.append('value', newValue);
|
||||
|
||||
fetch('api/update_setting.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
if (newValue === '1') {
|
||||
btn.classList.add('active');
|
||||
span.textContent = '<?= __('messages_enabled') ?>';
|
||||
icon.className = 'bi bi-whatsapp me-2';
|
||||
} else {
|
||||
btn.classList.remove('active');
|
||||
span.textContent = '<?= __('messages_disabled') ?>';
|
||||
icon.className = 'bi bi-chat-left-dots me-2';
|
||||
}
|
||||
|
||||
// Sync with settings page toggle if it exists
|
||||
const settingsToggle = document.getElementById('whatsapp_enabled');
|
||||
if (settingsToggle) settingsToggle.checked = (newValue === '1');
|
||||
} else {
|
||||
alert('Error: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Network error updating setting');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if (count($user_branches) > 1 || $current_role === 'super_admin'): ?>
|
||||
<div class="dropdown me-2">
|
||||
|
||||
@ -25,6 +25,12 @@ $translations = [
|
||||
'branches' => 'Branches',
|
||||
'users' => 'Users',
|
||||
'settings' => 'Settings',
|
||||
'smtp_settings' => 'SMTP Settings',
|
||||
'smtp_host' => 'SMTP Host',
|
||||
'smtp_port' => 'SMTP Port',
|
||||
'smtp_user' => 'SMTP Username',
|
||||
'smtp_pass' => 'SMTP Password',
|
||||
'smtp_secure' => 'SMTP Encryption (tls/ssl)',
|
||||
'whatsapp_settings' => 'WhatsApp Settings',
|
||||
'whatsapp_enabled' => 'WhatsApp Enabled',
|
||||
'wablas_token' => 'Wablas API Token',
|
||||
@ -259,6 +265,12 @@ $translations = [
|
||||
'branches' => 'الفروع',
|
||||
'users' => 'المستخدمين',
|
||||
'settings' => 'الإعدادات',
|
||||
'smtp_settings' => 'إعدادات SMTP',
|
||||
'smtp_host' => 'خادم SMTP',
|
||||
'smtp_port' => 'منفذ SMTP',
|
||||
'smtp_user' => 'اسم مستخدم SMTP',
|
||||
'smtp_pass' => 'كلمة مرور SMTP',
|
||||
'smtp_secure' => 'تشفير SMTP (tls/ssl)',
|
||||
'whatsapp_settings' => 'إعدادات الواتساب',
|
||||
'whatsapp_enabled' => 'تفعيل الواتساب',
|
||||
'wablas_token' => 'رمز API Wablas',
|
||||
|
||||
@ -95,9 +95,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="text-center">
|
||||
<?php if ($company_info['logo']): ?>
|
||||
<img src="<?= $company_info['logo'] ?>" alt="Logo" class="login-logo">
|
||||
<?php else: ?>
|
||||
<h3 class="mb-4 fw-bold"><?= htmlspecialchars(is_arabic() ? $company_info['name_ar'] : $company_info['name_en']) ?></h3>
|
||||
<?php endif; ?>
|
||||
<h3 class="mb-4 fw-bold"><?= htmlspecialchars(is_arabic() ? $company_info['name_ar'] : $company_info['name_en']) ?></h3>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
<?php
|
||||
// Mail configuration sourced from environment variables.
|
||||
// No secrets are stored here; the file just maps env -> config array for MailService.
|
||||
// Mail configuration sourced from settings and environment variables.
|
||||
|
||||
require_once __DIR__ . '/../includes/dotenv.php';
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
function env_val(string $key, $default = null) {
|
||||
$v = getenv($key);
|
||||
return ($v === false || $v === null || $v === '') ? $default : $v;
|
||||
}
|
||||
|
||||
$transport = env_val('MAIL_TRANSPORT', 'smtp');
|
||||
$smtp_host = env_val('SMTP_HOST');
|
||||
$smtp_port = (int) env_val('SMTP_PORT', 587);
|
||||
$smtp_secure = env_val('SMTP_SECURE', 'tls'); // tls | ssl | null
|
||||
$smtp_user = env_val('SMTP_USER');
|
||||
$smtp_pass = env_val('SMTP_PASS');
|
||||
$transport = get_setting('mail_transport') ?: env_val('MAIL_TRANSPORT', 'smtp');
|
||||
$smtp_host = get_setting('smtp_host') ?: env_val('SMTP_HOST');
|
||||
$smtp_port = (int) (get_setting('smtp_port') ?: env_val('SMTP_PORT', 587));
|
||||
$smtp_secure = get_setting('smtp_secure') ?: env_val('SMTP_SECURE', 'tls'); // tls | ssl | null
|
||||
$smtp_user = get_setting('smtp_user') ?: env_val('SMTP_USER');
|
||||
$smtp_pass = get_setting('smtp_pass') ?: env_val('SMTP_PASS');
|
||||
|
||||
$from_email = env_val('MAIL_FROM', 'no-reply@localhost');
|
||||
$from_name = env_val('MAIL_FROM_NAME', 'App');
|
||||
$reply_to = env_val('MAIL_REPLY_TO');
|
||||
$from_email = get_setting('mail_from') ?: env_val('MAIL_FROM', 'no-reply@localhost');
|
||||
$from_name = get_setting('mail_from_name') ?: env_val('MAIL_FROM_NAME', 'App');
|
||||
$reply_to = get_setting('mail_reply_to') ?: env_val('MAIL_REPLY_TO');
|
||||
|
||||
$dkim_domain = env_val('DKIM_DOMAIN');
|
||||
$dkim_selector = env_val('DKIM_SELECTOR');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user