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_SALESORDER";
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_customer_list');
13 $js = get_js_set_combo_item();
15 $js = get_js_select_combo_item();
17 page(_($help_context = "Customers"), 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("customer_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(_("Customer"), "customer");
38 submit_cells("search", _("Search"), "", _("Search customers"), "default");
47 // BEGIN: Link to add new customer
48 // hyperlink_params($path_to_root . "/sales/manage/customers.php", _("Add new"), "popup=1");
49 // END: Link to add new customer
51 // BEGIN: Customer list
52 div_start("customer_tbl");
54 start_table(TABLESTYLE);
56 $th = array("", _("Customer"), _("Short Name"), _("Address"), _("Tax ID"));
60 // Query based on function customer_list in includes/ui/ui_lists.inc.
62 $sql = "SELECT debtor_no, name, debtor_ref, address, tax_id FROM ".TB_PREF."debtors_master
63 WHERE ( name LIKE " . db_escape("%" . get_post("customer"). "%") . " OR
64 debtor_ref LIKE " . db_escape("%" . get_post("customer"). "%") . " OR
65 address LIKE " . db_escape("%" . get_post("customer"). "%") . " OR
66 tax_id LIKE " . db_escape("%" . get_post("customer") . "%").")
67 ORDER BY name LIMIT 0, $limit"; // We only display 10 items.
68 $result = db_query($sql, "Failed in retreiving customer list.");
70 $k = 0; //row colour counter
71 $name = $_GET["client_id"];
72 while ($myrow = db_fetch_assoc($result)) {
73 alt_table_row_color($k);
74 $value = $myrow['debtor_no'];
76 $text = $myrow['name'];
77 ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'", "'.$value.'", "'.$text.'")');
80 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
82 label_cell($myrow["name"]);
83 label_cell($myrow["debtor_ref"]);
84 label_cell($myrow["address"]);
85 label_cell($myrow["tax_id"]);