Rerun /reporting/includes/report_classes.inc
[fa-stable.git] / sales / inquiry / customers_list.php
index 99a80c40ea1bda859f29236ceadcbc07332f9585..b6c7df97221dce08e08899db9ab317aaedb7b140 100644 (file)
@@ -18,6 +18,7 @@ $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/customers_db.inc");
 
 $mode = get_company_pref('no_customer_list');
 if ($mode != 0)
@@ -27,18 +28,10 @@ else
 
 page(_($help_context = "Customers"), true, false, "", $js);
 
-if (isset($SysPrefs->max_rows_in_search))
-       $limit = $SysPrefs->max_rows_in_search;
-else
-       $limit = 10;
-
-// Activate Ajax on form submit
 if(get_post("search")) {
   $Ajax->activate("customer_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);
@@ -53,13 +46,7 @@ end_row();
 end_table();
 
 end_form();
-// END: Filter form
-
-// BEGIN: Link to add new customer
-// hyperlink_params($path_to_root . "/sales/manage/customers.php", _("Add new"), "popup=1");
-// END: Link to add new customer
 
-// BEGIN: Customer list
 div_start("customer_tbl");
 
 start_table(TABLESTYLE);
@@ -68,18 +55,9 @@ $th = array("", _("Customer"), _("Short Name"), _("Address"), _("Tax ID"));
 
 table_header($th);
 
-// Query based on function customer_list in includes/ui/ui_lists.inc.
-
-$sql = "SELECT debtor_no, name, debtor_ref, address, tax_id FROM ".TB_PREF."debtors_master 
-  WHERE (  name LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
-     debtor_ref LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
-        address LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
-         tax_id LIKE " . db_escape("%" . get_post("customer") . "%").")
-  ORDER BY name LIMIT 0, $limit"; // We only display 10 items.
-$result = db_query($sql, "Failed in retreiving customer list.");
-
-$k = 0; //row colour counter
+$k = 0;
 $name = $_GET["client_id"];
+$result = get_customers_search(get_post("customer"));
 while ($myrow = db_fetch_assoc($result)) {
        alt_table_row_color($k);
        $value = $myrow['debtor_no'];
@@ -100,6 +78,5 @@ while ($myrow = db_fetch_assoc($result)) {
 end_table(1);
 
 div_end();
-// END: Customer list
 
 end_page(true);