cancel promotion feature

This commit is contained in:
Flatlogic Bot 2026-02-20 02:53:04 +00:00
parent c970d434dd
commit a832f10e69

View File

@ -601,6 +601,14 @@ function getPromotionalPrice($item) {
$message = "Item deleted successfully!";
}
if (isset($_POST['cancel_all_promotions'])) {
db()->query("UPDATE stock_items SET is_promotion = 0 WHERE is_promotion = 1");
$message = "All active promotions have been cancelled.";
}
// Auto-expire finished promotions
db()->query("UPDATE stock_items SET is_promotion = 0 WHERE is_promotion = 1 AND promotion_end IS NOT NULL AND promotion_end < '" . date('Y-m-d') . "'");
if (isset($_POST['add_category'])) {
db()->prepare("INSERT INTO stock_categories (name_en, name_ar) VALUES (?, ?)")->execute([$_POST['name_en'] ?? '', $_POST['name_ar'] ?? '']);
$message = "Category added!";
@ -1089,36 +1097,6 @@ if (isset($_POST['add_hr_department'])) {
}
}
if (isset($_POST['update_license'])) {
$id = (int)$_POST['id'];
$status = $_POST['status'] ?? null;
$owner = $_POST['owner'] ?? null;
$address = $_POST['address'] ?? null;
$updateData = [];
if ($status !== null) $updateData['status'] = $status;
if ($owner !== null) $updateData['owner'] = $owner;
if ($address !== null) $updateData['address'] = $address;
$res = LicenseService::updateLicense($id, $updateData);
if ($res['success']) {
$message = "License updated successfully!";
} else {
$message = "Error: " . ($res['error'] ?? 'Unknown error');
}
}
if (isset($_POST['issue_license'])) {
$max = (int)($_POST['max_activations'] ?? 1);
$owner = $_POST['owner'] ?? null;
$address = $_POST['address'] ?? null;
$res = LicenseService::issueLicense($max, 'FLAT', $owner, $address);
if ($res['success']) {
$message = "New License Issued: " . $res['license_key'];
} else {
$message = "Error: " . ($res['error'] ?? 'Unknown error');
}
}
if (isset($_POST['pay_payroll'])) {
$id = (int)$_POST['id'];
if ($id) {
@ -3251,6 +3229,11 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<a href="promo-catalog.php" class="btn btn-outline-danger me-2">
<i class="bi bi-file-pdf"></i> <span data-en="Promo Catalog" data-ar="كتالوج العروض">Promo Catalog</span>
</a>
<form method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to cancel all active promotions?');">
<button type="submit" name="cancel_all_promotions" class="btn btn-outline-danger me-2">
<i class="bi bi-x-circle"></i> <span data-en="Cancel All Promotions" data-ar="إلغاء جميع العروض">Cancel All Promotions</span>
</button>
</form>
<button class="btn btn-outline-success me-2" data-bs-toggle="modal" data-bs-target="#importItemsModal">
<i class="bi bi-file-earmark-excel"></i> <span data-en="Import Excel" data-ar="استيراد من اكسل">Import Excel</span>
</button>