diff --git a/assets/images/items/item_69a567f77a8364.03372918.jpeg b/assets/images/items/item_69a567f77a8364.03372918.jpeg new file mode 100644 index 0000000..1c937c0 Binary files /dev/null and b/assets/images/items/item_69a567f77a8364.03372918.jpeg differ diff --git a/items.php b/items.php index ec036ed..cf22c59 100644 --- a/items.php +++ b/items.php @@ -162,13 +162,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { } elseif ($_POST['action'] === 'update_price') { $item_id = $_POST['item_id']; $service_id = $_POST['service_id']; - $variant_id = $_POST['variant_id'] ?: null; $price = $_POST['price']; - $stmt = db()->prepare("INSERT INTO prices (branch_id, item_id, variant_id, service_id, price) - VALUES (?, ?, ?, ?, ?) + $stmt = db()->prepare("INSERT INTO prices (branch_id, item_id, service_id, price) + VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE price = ?"); - $stmt->execute([$branch_id, $item_id, $variant_id, $service_id, $price, $price]); + $stmt->execute([$branch_id, $item_id, $service_id, $price, $price]); if (isset($_POST['ajax'])) { header('Content-Type: application/json'); @@ -178,35 +177,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { header('Location: items.php?success=price_updated'); exit; - } elseif ($_POST['action'] === 'add_variant') { - $item_id = $_POST['item_id']; - $name_en = $_POST['variant_name_en']; - $name_ar = $_POST['variant_name_ar']; - $stmt = db()->prepare("INSERT INTO item_variants (item_id, name_en, name_ar) VALUES (?, ?, ?)"); - $stmt->execute([$item_id, $name_en, $name_ar]); - header('Location: items.php?success=variant_added'); - exit; - } elseif ($_POST['action'] === 'edit_variant') { - $id = $_POST['id']; - $name_en = $_POST['name_en']; - $name_ar = $_POST['name_ar']; - $stmt = db()->prepare("UPDATE item_variants SET name_en = ?, name_ar = ? WHERE id = ?"); - $stmt->execute([$name_en, $name_ar, $id]); - - if (isset($_POST['ajax'])) { - header('Content-Type: application/json'); - echo json_encode(['success' => true]); - exit; - } - - header('Location: items.php?success=variant_updated'); - exit; - } elseif ($_POST['action'] === 'delete_variant') { - $id = $_POST['id']; - $stmt = db()->prepare("DELETE FROM item_variants WHERE id = ?"); - $stmt->execute([$id]); - header('Location: items.php?success=variant_deleted'); - exit; } } @@ -226,14 +196,7 @@ $stmt->execute([$branch_id]); $prices_raw = $stmt->fetchAll(); $prices = []; foreach ($prices_raw as $p) { - $v_key = $p['variant_id'] ?: 'default'; - $prices[$p['item_id']][$v_key][$p['service_id']] = $p['price']; -} - -$item_variants = db()->query("SELECT * FROM item_variants ORDER BY name_en ASC")->fetchAll(); -$variants_by_item = []; -foreach ($item_variants as $v) { - $variants_by_item[$v['item_id']][] = $v; + $prices[$p['item_id']][$p['service_id']] = $p['price']; } ?> @@ -268,7 +231,7 @@ foreach ($item_variants as $v) { - + @@ -302,7 +265,7 @@ foreach ($item_variants as $v) { % @@ -324,10 +287,10 @@ foreach ($item_variants as $v) {
-
How to use Variants & Services?
+
How to manage Services?

- Services: General actions like "Wash Only", "Urgent Wash", "Iron Only". Add them once and set prices for each item.
- Variants: Specific garment types or materials like "Silk Dress", "Wool Suit", or "Large Carpet". Use them if an item has different versions with unique pricing. + Services: Actions like "Wash Only", "Urgent Wash", "Iron Only". Add them using the Services button at the top, then set prices for each item in the table above.
+ Simplified: We removed "Variants" to make it easier. Now you just define your services and set their prices for each item.

@@ -535,64 +498,35 @@ foreach ($item_variants as $v) {