diff --git a/agent/invoice.php b/agent/invoice.php index 4bf4d071b..da87319da 100644 --- a/agent/invoice.php +++ b/agent/invoice.php @@ -180,32 +180,7 @@ if (isset($_GET['invoice_id'])) { $invoice_badge_color = getInvoiceBadgeColor($invoice_status); //Product autocomplete - $products_sql = mysqli_query($mysqli, " - SELECT - IF(product_code IS NULL OR product_code = '', product_name, CONCAT(product_code, ' - ', product_name)) AS label, - product_name, - product_code, - product_type AS type, - product_description AS description, - product_price AS price, - product_tax_id AS tax, - tax_percent, - product_id AS prod_id, - COALESCE(SUM(product_stock.stock_qty), 0) AS available_stock - FROM products - LEFT JOIN product_stock ON product_id = stock_product_id - LEFT JOIN taxes ON product_tax_id = tax_id - WHERE product_archived_at IS NULL - GROUP BY product_id - ORDER BY product_name ASC - "); - - if (mysqli_num_rows($products_sql) > 0) { - while ($row = mysqli_fetch_assoc($products_sql)) { - $products[] = $row; - } - $json_products = json_encode($products); - } + $json_products = getProductsForAutocomplete($mysqli); // Saved Payment Methods $sql_saved_payment_methods = mysqli_query($mysqli, " @@ -815,67 +790,12 @@ require_once "../includes/footer.php"; ?> - + + diff --git a/agent/quote.php b/agent/quote.php index 6b008a83a..4aff7960a 100644 --- a/agent/quote.php +++ b/agent/quote.php @@ -128,14 +128,7 @@ if (isset($_GET['quote_id'])) { } //Product autocomplete - $products_sql = mysqli_query($mysqli, "SELECT product_name AS label, product_description AS description, product_price AS price, product_tax_id AS tax FROM products WHERE product_archived_at IS NULL"); - - if (mysqli_num_rows($products_sql) > 0) { - while ($row = mysqli_fetch_assoc($products_sql)) { - $products[] = $row; - } - $json_products = json_encode($products); - } + $json_products = getProductsForAutocomplete($mysqli); // Quote File Attachments $sql_quote_files = mysqli_query( @@ -403,6 +396,7 @@ if (isset($_GET['quote_id'])) {