Fixed a couple of bugs in stock list and account list search.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 9 Dec 2015 22:04:55 +0000 (23:04 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 9 Dec 2015 22:04:55 +0000 (23:04 +0100)
gl/inquiry/accounts_list.php
includes/ui/ui_lists.inc
inventory/inquiry/stock_list.php

index 9bccf881e2626b1cc47dd78c72a7ab22119ac1e8..eb8b0e2b6d507400534c28cdfbc245508490b5e9 100644 (file)
@@ -54,7 +54,6 @@ $sql = "SELECT chart.account_code, chart.account_name, type.name
                        FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
                        WHERE chart.account_type=type.id
         AND (
-          chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR
           chart.account_name LIKE " . db_escape("%" . get_post("description"). "%") . " OR
           chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . "
         ) 
index 12ebceaef666c6434fc81170dbf772ddc0dac024..29afc214baa777b2c056c385aef3306b5bb24cce 100644 (file)
@@ -299,7 +299,6 @@ $opts = array(              // default options
                $link = "";
                $id = $name;
                if ($SysPrefs->use_popup_windows) {
-                       //_vd("type= $type");
                switch (strtolower($type)) {
                        case "stock":
                                $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id;
@@ -321,6 +320,11 @@ $opts = array(             // default options
                                $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id;
                                $img_title = _("Search items");
                                break;
+                       case "component":
+                               $parent = $opts['parent'];
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=component&parent=".$parent."&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
                        case "kits":
                                $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
                                $img_title = _("Search items");
@@ -986,18 +990,19 @@ function stock_manufactured_items_list_row($label, $name, $selected_id=null,
 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
        $all_option=false, $submit_on_change=false, $editkey = false)
 {
+       $parent = db_escape($parent_stock_id);
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("stock_id != ".db_escape($parent_stock_id))), $editkey);
+               array('where'=>array("stock_id != $parent"), 'parent'=> $parent_stock_id), $editkey, "component");
 }
 
+
 function stock_component_items_list_cells($label, $name, $parent_stock_id, 
        $selected_id=null, $all_option=false, $submit_on_change=false, $editkey = false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
        echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("stock_id != ".db_escape($parent_stock_id)), 'cells'=>true),
-               $editkey);
+               array('where'=>array("stock_id != $parent"), 'cells'=>true, 'parent'=> $parent_stock_id), $editkey, "component");
 }
 //------------------------------------------------------------------------------------
 
index 1d1c5890b6f67bbbac1cc035da1649a827497f30..d087c41e7a7f26f860f39ee93b3f40661ff9d87e 100644 (file)
@@ -59,11 +59,8 @@ table_header($th);
 
 // Query based on function sales_items_list in includes/ui/ui_lists.inc.
 $sql = "SELECT COUNT(i.item_code) AS kit, i.item_code, i.description, c.description category
-  FROM
-    ".TB_PREF."stock_master s,
-    ".TB_PREF."item_codes i
-  LEFT JOIN
-    ".TB_PREF."stock_category c
+  FROM ".TB_PREF."stock_master s, ".TB_PREF."item_codes i
+  LEFT JOIN ".TB_PREF."stock_category c
     ON i.category_id=c.category_id
   WHERE i.stock_id=s.stock_id
     AND !i.inactive AND !s.inactive
@@ -75,7 +72,7 @@ $type = "";
 if (isset($_GET['type'])) {
   $type = $_GET['type'];
 }
-//_vd("type = $type");
+
 switch ($type) {
   case "sales":
     $sql .= " AND !s.no_sale AND mb_flag != 'F'";
@@ -89,6 +86,9 @@ switch ($type) {
   case "costable":
     $sql .= " AND mb_flag != 'D' AND mb_flag != 'F' AND  i.item_code=i.stock_id";
     break;
+  case "component":
+    $sql .= " AND  i.item_code=i.stock_id AND i.stock_id != ".$_GET['parent']." AND mb_flag != 'F' ";
+    break;
   case "assets":
     $sql .= " AND mb_flag = 'F'";
     break;
@@ -102,7 +102,7 @@ switch ($type) {
 }
 
 $sql .= " GROUP BY i.item_code ORDER BY i.description LIMIT 0, $limit"; // We only display 10 items.
-//_vd($sql);
+
 $result = db_query($sql, "Failed in retreiving item list.");
 
 $k = 0; //row colour counter