2 /**********************************************************************
3 Page for searching GL account list and select it to GL account
4 selection in page that has GL account dropdown list.
5 ***********************************************************************/
6 $page_security = "SA_GLACCOUNT";
7 $path_to_root = "../..";
8 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/includes/ui.inc");
11 $js = get_js_select_combo_item();
13 page(_($help_context = "GL Accounts"), true, false, "", $js);
15 if (isset($SysPrefs->max_rows_in_search))
16 $limit = $SysPrefs->max_rows_in_search;
20 // Activate Ajax on form submit
21 if(get_post("search")) {
22 $Ajax->activate("account_tbl");
25 // BEGIN: Filter form. Use query string so the client_id will not disappear
26 // after ajax form post.
27 start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
29 start_table(TABLESTYLE_NOBORDER);
33 text_cells(_("Description"), "description");
34 submit_cells("search", _("Search"), "", _("Search GL accounts"), "default");
43 // BEGIN: Account list
44 div_start("account_tbl");
46 start_table(TABLESTYLE);
48 $th = array("", _("Account Code"), _("Description"), _("Category"));
52 // Query based on function gl_all_accounts_list in includes/ui/ui_lists.inc.
53 $sql = "SELECT chart.account_code, chart.account_name, type.name
54 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
55 WHERE chart.account_type=type.id
57 chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR
58 chart.account_name LIKE " . db_escape("%" . get_post("description"). "%") . " OR
59 chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . "
61 ORDER BY chart.account_code LIMIT 0, $limit"; // We only display 10 items.
62 $result = db_query($sql, "Failed in retreiving GL account list.");
64 $k = 0; //row colour counter
65 $name = $_GET["client_id"];
66 while ($myrow = db_fetch_assoc($result)) {
67 alt_table_row_color($k);
68 $value = $myrow['account_code'];
69 ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
70 label_cell($myrow["account_code"]);
71 label_cell($myrow["account_name"]);
72 label_cell($myrow["name"]);