From: Maxime Bourget Date: Fri, 3 May 2013 20:33:01 +0000 (+0100) Subject: Added 'Item Like' parameter to Stock Sheet Report allowing SQL LIKE or regexp filteri... X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=4cff565461e1e3633c0c79ef5686d8bd76f45535;p=textcart.git Added 'Item Like' parameter to Stock Sheet Report allowing SQL LIKE or regexp filtering by item code. --- diff --git a/reporting/rep303.php b/reporting/rep303.php index 9c2a493..2f3e7a3 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 e1995d1..0c8a9cb 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'));