Bug 4817: g/l account inquiry can timeout due to slow sql. @Braath Waate.
[fa-stable.git] / sales / inquiry / customer_branches_list.php
1 <?php
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");
21 include_once($path_to_root . "/sales/includes/db/branches_db.inc");
22
23 $js = get_js_select_combo_item();
24
25 page(_($help_context = "Customer Branches"), true, false, "", $js);
26
27 if(get_post("search")) {
28   $Ajax->activate("customer_branch_tbl");
29 }
30
31 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
32
33 start_table(TABLESTYLE_NOBORDER);
34
35 start_row();
36
37 text_cells(_("Branch"), "branch");
38 submit_cells("search", _("Search"), "", _("Search branches"), "default");
39
40 end_row();
41
42 end_table();
43
44 end_form();
45
46 div_start("customer_branch_tbl");
47 start_table(TABLESTYLE);
48
49 $th = array("", _("Ref"), _("Branch"), _("Contact"), _("Phone"));
50
51 table_header($th);
52
53 $k = 0;
54 $name = $_GET["client_id"];
55 $result = get_branches_search($_GET["customer_id"], get_post("branch"));
56 while ($myrow = db_fetch_assoc($result))
57 {
58         alt_table_row_color($k);
59         $value = $myrow['branch_code'];
60         ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
61         label_cell($myrow["branch_ref"]);
62         label_cell($myrow["br_name"]);
63         label_cell($myrow["contact_name"]);
64         label_cell($myrow["phone"]);
65         end_row();
66 }
67
68 end_table(1);
69
70 div_end();
71 end_page(true);