2 /**********************************************************************
3 Page for searching item list and select it to item selection
4 in sales order and purchase order.
5 ***********************************************************************/
6 $page_security = "SA_PURCHASEORDER";
7 $path_to_root = "../..";
8 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/includes/ui.inc");
11 $mode = get_company_pref('no_supplier_list');
13 $js = get_js_set_combo_item();
15 $js = get_js_select_combo_item();
17 page(_($help_context = "Suppliers"), true, false, "", $js);
19 if (isset($SysPrefs->max_rows_in_search))
20 $limit = $SysPrefs->max_rows_in_search;
24 // Activate Ajax on form submit
25 if(get_post("search")) {
26 $Ajax->activate("supplier_tbl");
29 // BEGIN: Filter form. Use query string so the client_id will not disappear
30 // after ajax form post.
31 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
33 start_table(TABLESTYLE_NOBORDER);
37 text_cells(_("Supplier"), "supplier");
38 submit_cells("search", _("Search"), "", _("Search suppliers"), "default");
47 // BEGIN: Link to add new supplier
48 // hyperlink_params($path_to_root . "/purchasing/manage/suppliers.php", _("Add new"), "popup=1");
49 // END: Link to add new supplier
51 // BEGIN: Supplier list
52 div_start("supplier_tbl");
54 start_table(TABLESTYLE);
56 $th = array("", _("Supplier"), _("Short Name"), _("Address"), _("Tax ID"));
60 // Query based on function supplier_list in includes/ui/ui_lists.inc.
61 $sql = "SELECT supplier_id, supp_name, supp_ref, address, gst_no FROM ".TB_PREF."suppliers
62 WHERE (supp_name LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR
63 supp_ref LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR
64 address LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR
65 gst_no LIKE " . db_escape("%" . get_post("supplier"). "%") . ")
66 ORDER BY supp_name LIMIT 0, $limit"; // We only display 10 items.
67 $result = db_query($sql, "Failed in retreiving supplier list.");
69 $k = 0; //row colour counter
70 $name = $_GET["client_id"];
71 while ($myrow = db_fetch_assoc($result)) {
72 alt_table_row_color($k);
73 $value = $myrow['supplier_id'];
75 $text = $myrow['supp_name'];
76 ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'", "'.$value.'", "'.$text.'")');
79 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
81 label_cell($myrow["supp_name"]);
82 label_cell($myrow["supp_ref"]);
83 label_cell($myrow["address"]);
84 label_cell($myrow["gst_no"]);