2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 /**********************************************************************
13 Page for searching customer branch list and select it to customer
14 branch selection in pages that have the customer branch dropdown lists.
15 Author: bogeyman2007 from Discussion Forum. Modified by Joe Hunt
16 ***********************************************************************/
17 $page_security = "SA_SALESORDER";
18 $path_to_root = "../..";
19 include_once($path_to_root . "/includes/session.inc");
20 include_once($path_to_root . "/includes/ui.inc");
22 $js = get_js_select_combo_item();
24 if (isset($SysPrefs->max_rows_in_search))
25 $limit = $SysPrefs->max_rows_in_search;
29 page(_($help_context = "Customer Branches"), true, false, "", $js);
31 // Activate Ajax on form submit
32 if(get_post("search")) {
33 $Ajax->activate("customer_branch_tbl");
36 // BEGIN: Filter form. Use query string so the client_id will not disappear
37 // after ajax form post.
38 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
40 start_table(TABLESTYLE_NOBORDER);
44 text_cells(_("Branch"), "branch");
45 submit_cells("search", _("Search"), "", _("Search branches"), "default");
54 // BEGIN: Link to add new customer branch
55 // hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", _("Add new"), "debtor_no=" . strip_tags($_GET["SelectedBranch"]) . "&popup=1");
56 // END: Link to add new customer branch
58 // BEGIN: Customer branches list
59 div_start("customer_branch_tbl");
61 start_table(TABLESTYLE);
63 $th = array("", _("Ref"), _("Branch"), _("Contact"), _("Phone"));
67 // Query based on function get_sql_for_customer_branches in includes/db/branches_db.inc.
72 p.name as contact_name,
74 FROM ".TB_PREF."cust_branch b
75 LEFT JOIN ".TB_PREF."crm_contacts c
76 ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general'
77 LEFT JOIN ".TB_PREF."crm_persons p
79 WHERE b.debtor_no = ".db_escape($_GET["customer_id"])."
80 AND b.br_name LIKE " . db_escape("%" . get_post("branch"). "%") . "
81 ORDER BY b.br_name LIMIT 0, $limit"; // We only display 10 items.
83 $result = db_query($sql, "Failed in retreiving branches list.");
85 $k = 0; //row colour counter
86 $name = $_GET["client_id"];
87 while ($myrow = db_fetch_assoc($result))
89 alt_table_row_color($k);
90 $value = $myrow['branch_code'];
91 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
92 label_cell($myrow["branch_ref"]);
93 label_cell($myrow["br_name"]);
94 label_cell($myrow["contact_name"]);
95 label_cell($myrow["phone"]);
102 // END: Customer list