From: Maxime Bourget Date: Sun, 9 Jun 2013 09:18:36 +0000 (+0100) Subject: Filter item with like and regexp. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=9d5ce0f333787c7c6e349c3822762f946b105669;p=order_line_extra.git Filter item with like and regexp. --- diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 87a83f0..49a8790 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -185,7 +185,7 @@ $row_id = $row['id']; "; } -function get_order_details_extra($customer_id, $location) { +function get_order_details_extra($customer_id, $location, $item_like) { $sql = "SELECT sod.id , so.order_no , stk_code @@ -208,6 +208,15 @@ function get_order_details_extra($customer_id, $location) { WHERE sod.quantity > qty_sent "; + if($item_like) { + if($item_like[0]=='/') { + $regexp = substr($item_like, 1); + $sql .= " AND stk_code RLIKE '$regexp'"; + } + else + $sql .= " AND stk_code LIKE '$item_like'"; + } + return $sql; } diff --git a/order_lines_view.php b/order_lines_view.php index 3fd66b7..72d38fc 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -57,6 +57,19 @@ else { } customer_list_cells(_("Select a customer: "), 'customer_id', $customer_id, true, true); +if($customer_id !== null) { + if(!isset($_POST['item_like'])) { + if(isset($_GET['item_like'])) { + $item_like = $_GET['item_like']; + $_POST['item_like'] = $item_like; + } + else $item_like = null; + } + else $item_like = $_POST['item_like']; + text_cells_ex('Filter Item', 'item_like', 50, null, $item_like, + null, null, null, true ); +} + @@ -71,7 +84,7 @@ end_table(1); // Orders inquiry table // if($customer_id) { - $sql = get_order_details_extra($customer_id, 'DEF'); + $sql = get_order_details_extra($customer_id, 'DEF', $item_like); $cols = array( 'detail_id' => 'skip' , _("Order #") => array('fun'=>'view_link', 'ord' => '')