PHP 7.4 Bugs in some reports.
[fa-stable.git] / sales / inquiry / customer_branches_list.php
index 3586628ec4c317079d33b1baacad23430bdb5e83..e5199def055133fb61804c91c6fdc5c975b3416b 100644 (file)
@@ -1,29 +1,33 @@
 <?php
 /**********************************************************************
-  Page for searching item list and select it to item selection
-  in sales order and purchase order.
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+/**********************************************************************
+  Page for searching customer branch list and select it to customer
+  branch selection in pages that have the customer branch dropdown lists.
+  Author: bogeyman2007 from Discussion Forum. Modified by Joe Hunt
 ***********************************************************************/
 $page_security = "SA_SALESORDER";
 $path_to_root = "../..";
 include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/ui.inc");
+include_once($path_to_root . "/sales/includes/db/branches_db.inc");
 
 $js = get_js_select_combo_item();
 
-if (isset($SysPrefs->max_rows_in_search))
-       $limit = $SysPrefs->max_rows_in_search;
-else
-       $limit = 10;
-
 page(_($help_context = "Customer Branches"), true, false, "", $js);
 
-// Activate Ajax on form submit
 if(get_post("search")) {
   $Ajax->activate("customer_branch_tbl");
 }
 
-// BEGIN: Filter form. Use query string so the client_id will not disappear
-// after ajax form post.
 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
 
 start_table(TABLESTYLE_NOBORDER);
@@ -38,41 +42,17 @@ end_row();
 end_table();
 
 end_form();
-// END: Filter form
 
-// BEGIN: Link to add new customer branch
-// hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", _("Add new"), "debtor_no=" . strip_tags($_GET["SelectedBranch"]) . "&popup=1");
-// END: Link to add new customer branch
-
-// BEGIN: Customer branches list
 div_start("customer_branch_tbl");
-
 start_table(TABLESTYLE);
 
 $th = array("", _("Ref"), _("Branch"), _("Contact"), _("Phone"));
 
 table_header($th);
 
-// Query based on function get_sql_for_customer_branches in includes/db/branches_db.inc.
-$sql = "SELECT 
-    b.branch_code,
-    b.branch_ref,
-    b.br_name,
-    p.name as contact_name,
-    p.phone
-  FROM ".TB_PREF."cust_branch b
-  LEFT JOIN ".TB_PREF."crm_contacts c
-    ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general'
-  LEFT JOIN ".TB_PREF."crm_persons p
-    on c.person_id=p.id
-  WHERE b.debtor_no = ".db_escape($_GET["customer_id"])."
-    AND b.br_name LIKE " . db_escape("%" . get_post("branch"). "%") . "
-  ORDER BY b.br_name LIMIT 0, $limit"; // We only display 10 items.
-
-$result = db_query($sql, "Failed in retreiving branches list.");
-
-$k = 0; //row colour counter
+$k = 0;
 $name = $_GET["client_id"];
+$result = get_branches_search($_GET["customer_id"], get_post("branch"));
 while ($myrow = db_fetch_assoc($result))
 {
        alt_table_row_color($k);
@@ -88,6 +68,4 @@ while ($myrow = db_fetch_assoc($result))
 end_table(1);
 
 div_end();
-// END: Customer list
-
 end_page(true);