adding tabs to settings

This commit is contained in:
Flatlogic Bot 2026-03-14 19:07:03 +00:00
parent 030b415fea
commit c1cd5b183c

View File

@ -109,170 +109,213 @@ include 'includes/header.php';
<?= $message ?> <?= $message ?>
<div class="card border-0 shadow-sm"> <form method="POST" enctype="multipart/form-data">
<div class="card-body"> <div class="row">
<form method="POST" enctype="multipart/form-data"> <div class="col-12 col-lg-3 mb-4">
<div class="row"> <div class="card border-0 shadow-sm sticky-top" style="top: 20px; z-index: 10;">
<div class="col-md-6 mb-3"> <div class="card-body p-0">
<label class="form-label">Company Name</label> <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<input type="text" name="company_name" class="form-control" value="<?= htmlspecialchars($settings['company_name'] ?? '') ?>" required <?= !has_permission('settings_add') ? 'readonly' : '' ?>> <button class="nav-link active rounded-0 text-start py-3 px-4 border-bottom" id="v-pills-general-tab" data-bs-toggle="pill" data-bs-target="#v-pills-general" type="button" role="tab" aria-controls="v-pills-general" aria-selected="true">
</div> <i class="bi bi-info-circle me-2"></i> General Info
<div class="col-md-6 mb-3"> </button>
<label class="form-label">Email</label> <button class="nav-link rounded-0 text-start py-3 px-4 border-bottom" id="v-pills-financial-tab" data-bs-toggle="pill" data-bs-target="#v-pills-financial" type="button" role="tab" aria-controls="v-pills-financial" aria-selected="false">
<input type="email" name="email" class="form-control" value="<?= htmlspecialchars($settings['email'] ?? '') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>> <i class="bi bi-currency-dollar me-2"></i> Financial & Taxes
</div> </button>
<div class="col-md-6 mb-3"> <button class="nav-link rounded-0 text-start py-3 px-4 border-bottom" id="v-pills-system-tab" data-bs-toggle="pill" data-bs-target="#v-pills-system" type="button" role="tab" aria-controls="v-pills-system" aria-selected="false">
<label class="form-label">Phone</label> <i class="bi bi-gear me-2"></i> System Settings
<input type="text" name="phone" class="form-control" value="<?= htmlspecialchars($settings['phone'] ?? '') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>> </button>
</div> <button class="nav-link rounded-0 text-start py-3 px-4" id="v-pills-branding-tab" data-bs-toggle="pill" data-bs-target="#v-pills-branding" type="button" role="tab" aria-controls="v-pills-branding" aria-selected="false">
<div class="col-md-12 mb-3"> <i class="bi bi-image me-2"></i> Branding
<label class="form-label">Address</label> </button>
<textarea name="address" class="form-control" rows="3" <?= !has_permission('settings_add') ? 'readonly' : '' ?>><?= htmlspecialchars($settings['address'] ?? '') ?></textarea>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Legal & Tax Information</h5>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">CTR No (Company Tax Registration)</label>
<input type="text" name="ctr_number" class="form-control" value="<?= htmlspecialchars($settings['ctr_number'] ?? '') ?>" placeholder="e.g. 123456789" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">VAT No (Value Added Tax Number)</label>
<input type="text" name="vat_number" class="form-control" value="<?= htmlspecialchars($settings['vat_number'] ?? '') ?>" placeholder="e.g. VAT-987654321" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Financial Settings</h5>
<div class="row">
<div class="col-md-3 mb-3">
<label class="form-label">VAT Rate (%)</label>
<div class="input-group">
<input type="number" step="0.01" name="vat_rate" class="form-control" value="<?= htmlspecialchars($settings['vat_rate'] ?? 0) ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
<span class="input-group-text">%</span>
</div>
</div>
<div class="col-md-3 mb-3">
<label class="form-label">Currency Symbol</label>
<input type="text" name="currency_symbol" class="form-control" value="<?= htmlspecialchars($settings['currency_symbol'] ?? '$') ?>" placeholder="e.g. $, €, £" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-3 mb-3">
<label class="form-label">Currency Position</label>
<select name="currency_position" class="form-select" <?= !has_permission('settings_add') ? 'disabled' : '' ?>>
<option value="before" <?= ($settings['currency_position'] ?? 'before') === 'before' ? 'selected' : '' ?>>Before (e.g. $10.00)</option>
<option value="after" <?= ($settings['currency_position'] ?? 'before') === 'after' ? 'selected' : '' ?>>After (e.g. 10.00 OMR)</option>
</select>
</div>
<div class="col-md-3 mb-3">
<label class="form-label">Decimal Places</label>
<input type="number" name="currency_decimals" class="form-control" value="<?= htmlspecialchars($settings['currency_decimals'] ?? 2) ?>" min="0" max="4" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">System Settings</h5>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">System Timezone</label>
<select name="timezone" class="form-select" <?= !has_permission('settings_add') ? 'disabled' : '' ?> >
<?php
$timezones = timezone_identifiers_list();
$current_tz = $settings['timezone'] ?? 'UTC';
foreach ($timezones as $tz):
?>
<option value="<?= htmlspecialchars($tz) ?>" <?= $current_tz === $tz ? 'selected' : '' ?> >
<?= htmlspecialchars($tz) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Daily WhatsApp Summary Report</h5>
<div class="row">
<div class="col-md-12 mb-3">
<div class="form-check form-switch mt-2">
<input class="form-check-input" type="checkbox" name="whatsapp_report_enabled" id="whatsapp_report_enabled" <?= ($settings['whatsapp_report_enabled'] ?? 0) ? 'checked' : '' ?> <?= !has_permission('settings_add') ? 'disabled' : '' ?> />
<label class="form-check-label fw-bold" for="whatsapp_report_enabled">Enable Daily WhatsApp Report</label>
<div class="form-text">Sends a daily summary of orders per outlet (cash, card, bank, etc.) via Wablas.</div>
</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_report_number" class="form-control" value="<?= htmlspecialchars($settings['whatsapp_report_number'] ?? '') ?>" placeholder="e.g. 9689XXXXXXX" <?= !has_permission('settings_add') ? 'readonly' : '' ?> />
<div class="form-text">Number with country code to receive the daily summary.</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Report Time</label>
<input type="time" name="whatsapp_report_time" class="form-control" value="<?= htmlspecialchars($settings['whatsapp_report_time'] ?? '23:59:00') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?> />
<div class="form-text">System time when the report should be generated and sent.</div>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Commission System</h5>
<div class="row">
<div class="col-md-6 mb-3">
<div class="form-check form-switch mt-2">
<input class="form-check-input" type="checkbox" name="commission_enabled" id="commissionEnabled" <?= ($settings['commission_enabled'] ?? 0) ? 'checked' : '' ?> <?= !has_permission('settings_add') ? 'disabled' : '' ?>>
<label class="form-check-label fw-bold" for="commissionEnabled">Enable Commissions for Cashiers</label>
<div class="form-text">When enabled, commissions will be calculated for each order based on the cashier's commission rate.</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<hr class="my-4"> <div class="col-12 col-lg-9">
<h5 class="mb-3">Branding</h5> <div class="card border-0 shadow-sm mb-4">
<div class="row align-items-center"> <div class="card-body">
<div class="col-md-6 mb-3"> <div class="tab-content" id="v-pills-tabContent">
<label class="form-label">Company Logo</label>
<div class="d-flex align-items-center gap-3"> <!-- General Info Tab -->
<?php if (!empty($settings['logo_url'])): ?> <div class="tab-pane fade show active" id="v-pills-general" role="tabpanel" aria-labelledby="v-pills-general-tab">
<div class="border rounded p-1 bg-light"> <h4 class="mb-4">General Information</h4>
<img src="<?= htmlspecialchars('../' . $settings['logo_url']) ?>" alt="Logo" style="height: 60px; max-width: 100px; object-fit: contain;"> <div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">Company Name</label>
<input type="text" name="company_name" class="form-control" value="<?= htmlspecialchars($settings['company_name'] ?? '') ?>" required <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Email</label>
<input type="email" name="email" class="form-control" value="<?= htmlspecialchars($settings['email'] ?? '') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Phone</label>
<input type="text" name="phone" class="form-control" value="<?= htmlspecialchars($settings['phone'] ?? '') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-12 mb-3">
<label class="form-label">Address</label>
<textarea name="address" class="form-control" rows="3" <?= !has_permission('settings_add') ? 'readonly' : '' ?>><?= htmlspecialchars($settings['address'] ?? '') ?></textarea>
</div>
</div> </div>
<?php endif; ?>
<?php if (has_permission('settings_add')): ?>
<input type="file" name="logo" class="form-control" accept="image/*">
<?php endif; ?>
</div>
<?php if (has_permission('settings_add')): ?>
<div class="form-text">Recommended: PNG or SVG with transparent background.</div>
<?php endif; ?>
</div>
<div class="col-md-6 mb-3"> <hr class="my-4">
<label class="form-label">Favicon</label> <h5 class="mb-3">Legal & Tax Information</h5>
<div class="d-flex align-items-center gap-3"> <div class="row">
<?php if (!empty($settings['favicon_url'])): ?> <div class="col-md-6 mb-3">
<div class="border rounded p-1 bg-light"> <label class="form-label">CTR No (Company Tax Registration)</label>
<img src="<?= htmlspecialchars('../' . $settings['favicon_url']) ?>" alt="Favicon" style="height: 32px; width: 32px; object-fit: contain;"> <input type="text" name="ctr_number" class="form-control" value="<?= htmlspecialchars($settings['ctr_number'] ?? '') ?>" placeholder="e.g. 123456789" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">VAT No (Value Added Tax Number)</label>
<input type="text" name="vat_number" class="form-control" value="<?= htmlspecialchars($settings['vat_number'] ?? '') ?>" placeholder="e.g. VAT-987654321" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
</div> </div>
<?php endif; ?> </div>
<?php if (has_permission('settings_add')): ?>
<input type="file" name="favicon" class="form-control" accept=".ico,.png,.svg"> <!-- Financial & Taxes Tab -->
<?php endif; ?> <div class="tab-pane fade" id="v-pills-financial" role="tabpanel" aria-labelledby="v-pills-financial-tab">
<h4 class="mb-4">Financial Settings</h4>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">VAT Rate (%)</label>
<div class="input-group">
<input type="number" step="0.01" name="vat_rate" class="form-control" value="<?= htmlspecialchars($settings['vat_rate'] ?? 0) ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
<span class="input-group-text">%</span>
</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Currency Symbol</label>
<input type="text" name="currency_symbol" class="form-control" value="<?= htmlspecialchars($settings['currency_symbol'] ?? '$') ?>" placeholder="e.g. $, €, £" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Currency Position</label>
<select name="currency_position" class="form-select" <?= !has_permission('settings_add') ? 'disabled' : '' ?>>
<option value="before" <?= ($settings['currency_position'] ?? 'before') === 'before' ? 'selected' : '' ?>>Before (e.g. $10.00)</option>
<option value="after" <?= ($settings['currency_position'] ?? 'before') === 'after' ? 'selected' : '' ?>>After (e.g. 10.00 OMR)</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Decimal Places</label>
<input type="number" name="currency_decimals" class="form-control" value="<?= htmlspecialchars($settings['currency_decimals'] ?? 2) ?>" min="0" max="4" <?= !has_permission('settings_add') ? 'readonly' : '' ?>>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Commission System</h5>
<div class="row">
<div class="col-md-12 mb-3">
<div class="form-check form-switch mt-2">
<input class="form-check-input" type="checkbox" name="commission_enabled" id="commissionEnabled" <?= ($settings['commission_enabled'] ?? 0) ? 'checked' : '' ?> <?= !has_permission('settings_add') ? 'disabled' : '' ?>>
<label class="form-check-label fw-bold" for="commissionEnabled">Enable Commissions for Cashiers</label>
<div class="form-text">When enabled, commissions will be calculated for each order based on the cashier's commission rate.</div>
</div>
</div>
</div>
</div>
<!-- System Settings Tab -->
<div class="tab-pane fade" id="v-pills-system" role="tabpanel" aria-labelledby="v-pills-system-tab">
<h4 class="mb-4">System Settings</h4>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">System Timezone</label>
<select name="timezone" class="form-select" <?= !has_permission('settings_add') ? 'disabled' : '' ?> >
<?php
$timezones = timezone_identifiers_list();
$current_tz = $settings['timezone'] ?? 'UTC';
foreach ($timezones as $tz):
?>
<option value="<?= htmlspecialchars($tz) ?>" <?= $current_tz === $tz ? 'selected' : '' ?> >
<?= htmlspecialchars($tz) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<hr class="my-4">
<h5 class="mb-3">Daily WhatsApp Summary Report</h5>
<div class="row">
<div class="col-md-12 mb-3">
<div class="form-check form-switch mt-2">
<input class="form-check-input" type="checkbox" name="whatsapp_report_enabled" id="whatsapp_report_enabled" <?= ($settings['whatsapp_report_enabled'] ?? 0) ? 'checked' : '' ?> <?= !has_permission('settings_add') ? 'disabled' : '' ?> />
<label class="form-check-label fw-bold" for="whatsapp_report_enabled">Enable Daily WhatsApp Report</label>
<div class="form-text">Sends a daily summary of orders per outlet (cash, card, bank, etc.) via Wablas.</div>
</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_report_number" class="form-control" value="<?= htmlspecialchars($settings['whatsapp_report_number'] ?? '') ?>" placeholder="e.g. 9689XXXXXXX" <?= !has_permission('settings_add') ? 'readonly' : '' ?> />
<div class="form-text">Number with country code to receive the daily summary.</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Report Time</label>
<input type="time" name="whatsapp_report_time" class="form-control" value="<?= htmlspecialchars($settings['whatsapp_report_time'] ?? '23:59:00') ?>" <?= !has_permission('settings_add') ? 'readonly' : '' ?> />
<div class="form-text">System time when the report should be generated and sent.</div>
</div>
</div>
</div>
<!-- Branding Tab -->
<div class="tab-pane fade" id="v-pills-branding" role="tabpanel" aria-labelledby="v-pills-branding-tab">
<h4 class="mb-4">Branding</h4>
<div class="row align-items-center">
<div class="col-md-12 mb-4">
<label class="form-label">Company Logo</label>
<div class="d-flex align-items-center gap-3">
<?php if (!empty($settings['logo_url'])): ?>
<div class="border rounded p-2 bg-light d-flex align-items-center justify-content-center" style="width: 120px; height: 80px;">
<img src="<?= htmlspecialchars('../' . $settings['logo_url']) ?>" alt="Logo" style="max-height: 100%; max-width: 100%; object-fit: contain;">
</div>
<?php endif; ?>
<div class="flex-grow-1">
<?php if (has_permission('settings_add')): ?>
<input type="file" name="logo" class="form-control" accept="image/*">
<div class="form-text mt-2">Recommended: PNG or SVG with transparent background.</div>
<?php else: ?>
<span class="text-muted">Logo file</span>
<?php endif; ?>
</div>
</div>
</div>
<hr class="my-2">
<div class="col-md-12 mb-3 mt-3">
<label class="form-label">Favicon</label>
<div class="d-flex align-items-center gap-3">
<?php if (!empty($settings['favicon_url'])): ?>
<div class="border rounded p-2 bg-light d-flex align-items-center justify-content-center" style="width: 60px; height: 60px;">
<img src="<?= htmlspecialchars('../' . $settings['favicon_url']) ?>" alt="Favicon" style="max-height: 100%; max-width: 100%; object-fit: contain;">
</div>
<?php endif; ?>
<div class="flex-grow-1">
<?php if (has_permission('settings_add')): ?>
<input type="file" name="favicon" class="form-control" accept=".ico,.png,.svg">
<div class="form-text mt-2">Recommended: 32x32 ICO or PNG.</div>
<?php else: ?>
<span class="text-muted">Favicon file</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div> </div>
<?php if (has_permission('settings_add')): ?>
<div class="form-text">Recommended: 32x32 ICO or PNG.</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php if (has_permission('settings_add')): ?> <?php if (has_permission('settings_add')): ?>
<div class="mt-4"> <div class="d-flex justify-content-end mb-5">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary btn-lg px-5 shadow-sm">
<i class="bi bi-save"></i> Save Changes <i class="bi bi-save me-2"></i> Save All Changes
</button> </button>
</div> </div>
<?php endif; ?> <?php endif; ?>
</form> </div>
</div> </div>
</div> </form>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>