Added supplier search in Outstanding Purchase Orders and Purchase Orders Inquiry.
authorJoe <unknown>
Thu, 10 Jul 2014 08:43:31 +0000 (10:43 +0200)
committerJoe <unknown>
Thu, 10 Jul 2014 08:43:31 +0000 (10:43 +0200)
purchasing/includes/db/po_db.inc
purchasing/inquiry/po_search.php
purchasing/inquiry/po_search_completed.php
sales/includes/db/cust_trans_db.inc

index ea541dcf47b087c64675bec5d70396ae8d1241fe..e182cd09d9c75d4ac753ea12a20de3ff69570241 100644 (file)
@@ -247,7 +247,7 @@ function get_short_info($stock_id)
        return db_query($sql,"The stock details for " . $stock_id . " could not be retrieved");
 }
 
-function get_sql_for_po_search_completed()
+function get_sql_for_po_search_completed($supplier_id=ALL_TEXT)
 {
        global $order_number, $selected_stock_item;;
 
@@ -292,14 +292,16 @@ function get_sql_for_po_search_completed()
                {
                        $sql .= " AND line.item_code=".db_escape($selected_stock_item);
                }
-
+               if ($supplier_id != ALL_TEXT)
+                       $sql .= " AND supplier.supplier_id=".db_escape($supplier_id);
+               
        } //end not order number selected
 
        $sql .= " GROUP BY porder.order_no";
        return $sql;
 }      
 
-function get_sql_for_po_search()
+function get_sql_for_po_search($supplier_id=ALL_TEXT)
 {
        global $all_items, $order_number, $selected_stock_item;;
        
@@ -345,6 +347,8 @@ function get_sql_for_po_search()
                {
                        $sql .= " AND line.item_code=".db_escape($selected_stock_item);
                }
+               if ($supplier_id != ALL_TEXT)
+                       $sql .= " AND supplier.supplier_id=".db_escape($supplier_id);
        } //end not order number selected
 
        $sql .= " GROUP BY porder.order_no";
index 220b1e1a325d62e2c36d2452ee939ca1dd268f34..3cf0b6cd4f21d78fbd5196a415d39a058d1cdc96 100644 (file)
@@ -73,6 +73,8 @@ start_row();
 
 stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
 
+supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, true, true);
+
 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
 end_row();
 end_table(1);
@@ -121,7 +123,7 @@ else
 }
 
 //figure out the sql required from the inputs available
-$sql = get_sql_for_po_search();
+$sql = get_sql_for_po_search($_POST['supplier_id']);
 
 //$result = db_query($sql,"No orders were returned");
 
index 9925ac6399a393387a286074b120a8e11c0e1492..03ab7b0ec2a5bd8fa1bb2bb5e14cc185e3f73611 100644 (file)
@@ -74,6 +74,9 @@ start_row();
 
 stock_items_list_cells(_("for item:"), 'SelectStockFromList', null, true);
 
+if (!@$_GET['popup'])
+       supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, true, true);
+
 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
 end_row();
 end_table(1);
@@ -115,7 +118,7 @@ function prt_link($row)
 
 //---------------------------------------------------------------------------------------------
 
-$sql = get_sql_for_po_search_completed();
+$sql = get_sql_for_po_search_completed(!@$_GET['popup'] ? $_POST['supplier_id'] : ALL_TEXT);
 
 $cols = array(
                _("#") => array('fun'=>'trans_view', 'ord'=>''), 
index 19cdaea7b466509e4435e482dd037a5e116a0138..d458e8c88c9c1b30678e25fd7f74fb2a73d6d315 100644 (file)
@@ -417,7 +417,7 @@ function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_i
                        $sql .= " AND sorder.from_stk_loc = ".db_escape($_POST['StockLocation'])." ";
                
                if ($customer_id != ALL_TEXT)
-                       $sql .= " AND sorder.debtor_no = ".db_escape($customer_id) . " AND trans.debtor_no = ".db_escape($customer_id);         
+                       $sql .= " AND trans.debtor_no = ".db_escape($customer_id);              
 
                $sql .= " GROUP BY trans.trans_no ";