diff --git a/index.php b/index.php index c1974df..1310f72 100644 --- a/index.php +++ b/index.php @@ -453,6 +453,68 @@ if (isset($_GET['action']) || isset($_POST['action'])) { exit; } + + if ($action === 'pos_search_items') { + $q = $_GET['q'] ?? ''; + $searchTerm = "%$q%"; + + $sql = "SELECT * FROM stock_items WHERE (name_en LIKE ? OR name_ar LIKE ? OR sku LIKE ?) ORDER BY name_en ASC LIMIT 100"; + $products_raw = db()->prepare($sql); + $products_raw->execute([$searchTerm, $searchTerm, $searchTerm]); + while($p = $products_raw->fetch(PDO::FETCH_ASSOC)) { + $p['original_price'] = (float)$p['sale_price']; + $p['sale_price'] = getPromotionalPrice($p); + + // Render Card HTML + ?> +