From 8e897868b82666b6e0eff0e07d45195307aac57b Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Fri, 3 May 2013 21:33:01 +0100 Subject: [PATCH] Added 'Item Like' parameter to Stock Sheet Report allowing SQL LIKE or regexp filtering by item code. --- reporting/rep303.php | 20 +++++++++++++++----- reporting/reports_main.php | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/reporting/rep303.php b/reporting/rep303.php index 9c2a493b..2f3e7a35 100644 --- a/reporting/rep303.php +++ b/reporting/rep303.php @@ -29,7 +29,7 @@ include_once($path_to_root . "/includes/db/manufacturing_db.inc"); print_stock_check(); -function getTransactions($category, $location) +function getTransactions($category, $location, $item_like) { $sql = "SELECT ".TB_PREF."stock_master.category_id, ".TB_PREF."stock_category.description AS cat_description, @@ -48,6 +48,15 @@ function getTransactions($category, $location) $sql .= " AND ".TB_PREF."stock_master.category_id = ".db_escape($category); if ($location != 'all') $sql .= " AND IF(".TB_PREF."stock_moves.stock_id IS NULL, '1=1',".TB_PREF."stock_moves.loc_code = ".db_escape($location).")"; + if($item_like) + { + $regexp = null; + + if(sscanf($item_like, "/%s", &$regexp)==1) + $sql .= " AND ".TB_PREF."stock_master.stock_id RLIKE ".db_escape($regexp); + else + $sql .= " AND ".TB_PREF."stock_master.stock_id LIKE ".db_escape($item_like); + } $sql .= " GROUP BY ".TB_PREF."stock_master.category_id, ".TB_PREF."stock_category.description, ".TB_PREF."stock_master.stock_id, @@ -70,9 +79,10 @@ function print_stock_check() $check = $_POST['PARAM_3']; $shortage = $_POST['PARAM_4']; $no_zeros = $_POST['PARAM_5']; - $comments = $_POST['PARAM_6']; - $orientation = $_POST['PARAM_7']; - $destination = $_POST['PARAM_8']; + $like = $_POST['PARAM_6']; + $comments = $_POST['PARAM_7']; + $orientation = $_POST['PARAM_8']; + $destination = $_POST['PARAM_9']; if ($destination) include_once($path_to_root . "/reporting/includes/excel_report.inc"); @@ -138,7 +148,7 @@ function print_stock_check() $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); - $res = getTransactions($category, $location); + $res = getTransactions($category, $location, $like); $catt = ''; while ($trans=db_fetch($res)) { diff --git a/reporting/reports_main.php b/reporting/reports_main.php index e1995d14..0c8a9cbf 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -225,6 +225,7 @@ $reports->addReport(RC_INVENTORY, 303, _('Stock &Check Sheets'), _('Inventory Column') => 'YES_NO', _('Show Shortage') => 'YES_NO', _('Suppress Zeros') => 'YES_NO', + _('Item Like') => 'TEXT', _('Comments') => 'TEXTBOX', _('Orientation') => 'ORIENTATION', _('Destination') => 'DESTINATION')); -- 2.30.2