Improvements to dashboard. All titles are outside the tables/graphics for better...
[fa-stable.git] / sales / inquiry / customers_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 list and select it to customer selection
14   in pages that have the supplier 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
22 $mode = get_company_pref('no_customer_list');
23 if ($mode != 0)
24         $js = get_js_set_combo_item();
25 else
26         $js = get_js_select_combo_item();
27
28 page(_($help_context = "Customers"), true, false, "", $js);
29
30 if (isset($SysPrefs->max_rows_in_search))
31         $limit = $SysPrefs->max_rows_in_search;
32 else
33         $limit = 10;
34
35 // Activate Ajax on form submit
36 if(get_post("search")) {
37   $Ajax->activate("customer_tbl");
38 }
39
40 // BEGIN: Filter form. Use query string so the client_id will not disappear
41 // after ajax form post.
42 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
43
44 start_table(TABLESTYLE_NOBORDER);
45
46 start_row();
47
48 text_cells(_("Customer"), "customer");
49 submit_cells("search", _("Search"), "", _("Search customers"), "default");
50
51 end_row();
52
53 end_table();
54
55 end_form();
56 // END: Filter form
57
58 // BEGIN: Link to add new customer
59 // hyperlink_params($path_to_root . "/sales/manage/customers.php", _("Add new"), "popup=1");
60 // END: Link to add new customer
61
62 // BEGIN: Customer list
63 div_start("customer_tbl");
64
65 start_table(TABLESTYLE);
66
67 $th = array("", _("Customer"), _("Short Name"), _("Address"), _("Tax ID"));
68
69 table_header($th);
70
71 // Query based on function customer_list in includes/ui/ui_lists.inc.
72
73 $sql = "SELECT debtor_no, name, debtor_ref, address, tax_id FROM ".TB_PREF."debtors_master 
74   WHERE (  name LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
75      debtor_ref LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
76         address LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
77          tax_id LIKE " . db_escape("%" . get_post("customer") . "%").")
78   ORDER BY name LIMIT 0, $limit"; // We only display 10 items.
79 $result = db_query($sql, "Failed in retreiving customer list.");
80
81 $k = 0; //row colour counter
82 $name = $_GET["client_id"];
83 while ($myrow = db_fetch_assoc($result)) {
84         alt_table_row_color($k);
85         $value = $myrow['debtor_no'];
86         if ($mode != 0) {
87                 $text = $myrow['name'];
88                 ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'",  "'.$value.'", "'.$text.'")');
89         }
90         else {
91                 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
92         }
93         label_cell($myrow["name"]);
94         label_cell($myrow["debtor_ref"]);
95         label_cell($myrow["address"]);
96         label_cell($myrow["tax_id"]);
97         end_row();
98 }
99
100 end_table(1);
101
102 div_end();
103 // END: Customer list
104
105 end_page(true);