From a832f10e69ca5fcf46b0a591c4cc92d35e9948aa Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 20 Feb 2026 02:53:04 +0000 Subject: [PATCH] cancel promotion feature --- index.php | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/index.php b/index.php index 9299a22..68f1b42 100644 --- a/index.php +++ b/index.php @@ -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'; Promo Catalog +
+ +