show products in qr order

This commit is contained in:
Flatlogic Bot 2026-02-28 17:39:42 +00:00
parent aa6cc744d0
commit 1aec2c17d6
5 changed files with 51 additions and 6 deletions

View File

@ -23,6 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
$promo_date_from = !empty($_POST['promo_date_from']) ? $_POST['promo_date_from'] : null;
$promo_date_to = !empty($_POST['promo_date_to']) ? $_POST['promo_date_to'] : null;
$is_loyalty = isset($_POST['is_loyalty']) ? 1 : 0;
$show_in_qorder = isset($_POST['show_in_qorder']) ? 1 : 0;
$image_url = null;
if ($id) {
@ -49,16 +50,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
if (!has_permission('products_edit')) {
$message = '<div class="alert alert-danger">Access Denied: You do not have permission to edit products.</div>';
} else {
$stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, vat_percent = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ? WHERE id = ?");
$stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $id]);
$stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, vat_percent = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ?, show_in_qorder = ? WHERE id = ?");
$stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder, $id]);
$message = '<div class="alert alert-success">Product updated successfully!</div>';
}
} elseif ($action === 'add_product') {
if (!has_permission('products_add')) {
$message = '<div class="alert alert-danger">Access Denied: You do not have permission to add products.</div>';
} else {
$stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, vat_percent, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty]);
$stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, vat_percent, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty, show_in_qorder) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder]);
$message = '<div class="alert alert-success">Product created successfully!</div>';
}
}
@ -211,6 +212,11 @@ include 'includes/header.php';
<i class="bi bi-star-fill"></i> Loyalty
</span>
<?php endif; ?>
<?php if ($product["show_in_qorder"]): ?>
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary rounded-pill ms-1" style="font-size: 0.7rem;">
<i class="bi bi-qr-code"></i> QR Menu
</span>
<?php endif; ?>
</div>
<small class="text-muted"><?= htmlspecialchars($product['name_ar'] ?? '') ?></small>
</div>
@ -369,6 +375,14 @@ include 'includes/header.php';
</div>
<input class="form-check-input ms-0" type="checkbox" name="is_loyalty" id="productIsLoyalty" style="width: 2.5rem; height: 1.25rem;">
</div>
<div class="form-check form-switch p-3 bg-light rounded-3 border d-flex justify-content-between align-items-center mb-3">
<div class="ms-1">
<label class="form-check-label fw-bold text-dark mb-0" for="productShowInQorder">Show in QR Order</label>
<div class="small text-muted">Make this product visible in the customer QR menu</div>
</div>
<input class="form-check-input ms-0" type="checkbox" name="show_in_qorder" id="productShowInQorder" style="width: 2.5rem; height: 1.25rem;" checked>
</div>
<h6 class="fw-bold border-bottom pb-2 mb-3"><i class="bi bi-percent me-1"></i> Promotion Settings</h6>
<div class="row g-3">
@ -404,6 +418,7 @@ function prepareAddForm() {
document.getElementById('productForm').reset();
document.getElementById('productId').value = '';
document.getElementById('productImagePreview').style.display = 'none';
document.getElementById('productShowInQorder').checked = true;
}
function prepareEditForm(p) {
@ -423,6 +438,7 @@ function prepareEditForm(p) {
document.getElementById('productPromoFrom').value = p.promo_date_from || '';
document.getElementById('productPromoTo').value = p.promo_date_to || '';
document.getElementById('productIsLoyalty').checked = p.is_loyalty == 1;
document.getElementById('productShowInQorder').checked = p.show_in_qorder == 1;
if (p.image_url) {
const preview = document.getElementById('productImagePreview');

5
cookies.txt Normal file
View File

@ -0,0 +1,5 @@
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_127.0.0.1 FALSE / FALSE 1772904726 PHPSESSID p7okqi6joq82i0rfhlmbbj2pgd

View File

@ -0,0 +1 @@
ALTER TABLE `products` ADD COLUMN IF NOT EXISTS `show_in_qorder` TINYINT(1) DEFAULT 1;

23
patch_badge.php Normal file
View File

@ -0,0 +1,23 @@
<?php
$content = file_get_contents('admin/products.php');
$search = <<<HTML
<?php if ($product['is_loyalty']): ?>
<span class="badge bg-info bg-opacity-10 text-info border border-info rounded-pill ms-1" style="font-size: 0.7rem;">
<i class="bi bi-star-fill"></i> Loyalty
</span>
<?php endif; ?>
HTML;
$replace = $search . <<<HTML
<?php if ($product['show_in_qorder']): ?>
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary rounded-pill ms-1" style="font-size: 0.7rem;">
<i class="bi bi-qr-code"></i> QR Menu
</span>
<?php endif; ?>
HTML;
$content = str_replace($search, $replace, $content);
file_put_contents('admin/products.php', $content);
echo "Badge added.\n";

View File

@ -34,7 +34,7 @@ if ($table_id > 0) {
$outlet_id = (int)($table_info['outlet_id'] ?? 0);
$categories = $pdo->query("SELECT * FROM categories WHERE is_deleted = 0 ORDER BY sort_order")->fetchAll();
$all_products = $pdo->query("SELECT p.*, c.name as category_name, c.name_ar as category_name_ar FROM products p JOIN categories c ON p.category_id = c.id WHERE p.is_deleted = 0 AND c.is_deleted = 0")->fetchAll();
$all_products = $pdo->query("SELECT p.*, c.name as category_name, c.name_ar as category_name_ar FROM products p JOIN categories c ON p.category_id = c.id WHERE p.is_deleted = 0 AND p.show_in_qorder = 1 AND c.is_deleted = 0")->fetchAll();
// Fetch variants
$variants_raw = $pdo->query("SELECT * FROM product_variants WHERE is_deleted = 0 ORDER BY price_adjustment ASC")->fetchAll();