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 $js = get_js_select_combo_item();
13 if (isset($SysPrefs->max_rows_in_search))
14 $limit = $SysPrefs->max_rows_in_search;
18 page(_($help_context = "Customer Branches"), true, false, "", $js);
20 // Activate Ajax on form submit
21 if(get_post("search")) {
22 $Ajax->activate("customer_branch_tbl");
25 // BEGIN: Filter form. Use query string so the client_id will not disappear
26 // after ajax form post.
27 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
29 start_table(TABLESTYLE_NOBORDER);
33 text_cells(_("Branch"), "branch");
34 submit_cells("search", _("Search"), "", _("Search branches"), "default");
43 // BEGIN: Link to add new customer branch
44 // hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", _("Add new"), "debtor_no=" . strip_tags($_GET["SelectedBranch"]) . "&popup=1");
45 // END: Link to add new customer branch
47 // BEGIN: Customer branches list
48 div_start("customer_branch_tbl");
50 start_table(TABLESTYLE);
52 $th = array("", _("Ref"), _("Branch"), _("Contact"), _("Phone"));
56 // Query based on function get_sql_for_customer_branches in includes/db/branches_db.inc.
61 p.name as contact_name,
63 FROM ".TB_PREF."cust_branch b
64 LEFT JOIN ".TB_PREF."crm_contacts c
65 ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general'
66 LEFT JOIN ".TB_PREF."crm_persons p
68 WHERE b.debtor_no = ".db_escape($_GET["customer_id"])."
69 AND b.br_name LIKE " . db_escape("%" . get_post("branch"). "%") . "
70 ORDER BY b.br_name LIMIT 0, $limit"; // We only display 10 items.
72 $result = db_query($sql, "Failed in retreiving branches list.");
74 $k = 0; //row colour counter
75 $name = $_GET["client_id"];
76 while ($myrow = db_fetch_assoc($result))
78 alt_table_row_color($k);
79 $value = $myrow['branch_code'];
80 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
81 label_cell($myrow["branch_ref"]);
82 label_cell($myrow["br_name"]);
83 label_cell($myrow["contact_name"]);
84 label_cell($myrow["phone"]);