From: Joe Hunt Date: Wed, 9 Dec 2015 12:34:52 +0000 (+0100) Subject: Enabling popup search in Customers, branches, suppliers, inventory, fixed assets... X-Git-Tag: v2.4.2~19^2~108 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=1ca0c7081f7a4cb3f68f3ffb6ee05739abb6cebf;hp=f9ad5818b3b263cf9ecb9d3d08d833ed79d97fe6;p=fa-stable.git Enabling popup search in Customers, branches, suppliers, inventory, fixed assets and GL Accounts. This is optional and can be disabled by setting $use_pop_search to false. This also works with built in search lists. --- diff --git a/.gitignore b/.gitignore index 12a5b6dd..ef755821 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ installed_extensions.php config.php config_db.php !index.php +/gl/inquiry/accounts_list.php diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 62af2b02..07f70b7b 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -13,7 +13,11 @@ $page_security = 'SA_GLSETUP'; $path_to_root=".."; include($path_to_root . "/includes/session.inc"); -page(_($help_context = "System and General GL Setup")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "System and General GL Setup"), false, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); diff --git a/config.default.php b/config.default.php index 386759e1..cdbb2d44 100644 --- a/config.default.php +++ b/config.default.php @@ -205,3 +205,10 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ If not defined $comp_path/%s/backup/ is used. */ // $backup_path = dirname(__FILE__).'/company/%s/backup/'; + +/* + Optional popup search enabled if this is true. + $max_rows_in_search = 10 is used for maximum rows in search +*/ + $use_popup_search = true; + $max_rows_in_search = 10; diff --git a/gl/inquiry/accounts_list.php b/gl/inquiry/accounts_list.php new file mode 100644 index 00000000..9bccf881 --- /dev/null +++ b/gl/inquiry/accounts_list.php @@ -0,0 +1,81 @@ +max_rows_in_search)) + $limit = $SysPrefs->max_rows_in_search; +else + $limit = 10; + +// Activate Ajax on form submit +if(get_post("search")) { + $Ajax->activate("account_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); + +start_row(); + +text_cells(_("Description"), "description"); +submit_cells("search", _("Search"), "", _("Search GL accounts"), "default"); + +end_row(); + +end_table(); + +end_form(); +// END: Filter form + +// BEGIN: Account list +div_start("account_tbl"); + +start_table(TABLESTYLE); + +$th = array("", _("Account Code"), _("Description"), _("Category")); + +table_header($th); + +// Query based on function gl_all_accounts_list in includes/ui/ui_lists.inc. +$sql = "SELECT chart.account_code, chart.account_name, type.name + FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type + WHERE chart.account_type=type.id + AND ( + chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR + chart.account_name LIKE " . db_escape("%" . get_post("description"). "%") . " OR + chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . " + ) + ORDER BY chart.account_code LIMIT 0, $limit"; // We only display 10 items. +$result = db_query($sql, "Failed in retreiving GL account list."); + +$k = 0; //row colour counter +$name = $_GET["client_id"]; +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + $value = $myrow['account_code']; + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")'); + label_cell($myrow["account_code"]); + label_cell($myrow["account_name"]); + label_cell($myrow["name"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Account list + +end_page(true); \ No newline at end of file diff --git a/gl/manage/gl_accounts.php b/gl/manage/gl_accounts.php index 3f59c1b2..417d51d7 100644 --- a/gl/manage/gl_accounts.php +++ b/gl/manage/gl_accounts.php @@ -13,7 +13,11 @@ $page_security = 'SA_GLACCOUNT'; $path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); -page(_($help_context = "Chart of Accounts")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Chart of Accounts"), false, false, "", $js); include($path_to_root . "/includes/ui.inc"); include($path_to_root . "/gl/includes/gl_db.inc"); diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index cade4c2d..cce4769c 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -38,6 +38,9 @@ class sys_prefs if (!$this->time_zone) $this->time_zone = 'Europe/Berlin'; + + if (!isset($this->use_popup_search)) + $this->use_popup_search = false; ini_set('date.timezone', $this->time_zone); } diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index f5f87cff..b15ba10e 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -287,7 +287,7 @@ function set_icon($icon, $title=false) global $path_to_root; if (basename($icon) === $icon) // standard icons does not contain path separator $icon = "$path_to_root/themes/".user_theme()."/images/$icon"; - return "\n"; + return "\n"; } function button($name, $value, $title=false, $icon=false, $aspect='') @@ -1012,3 +1012,12 @@ function bank_balance_row($bank_acc, $parms='') ."", $parms); } +function ahref($label, $href, $target="", $onclick="") { + echo "$label"; +} + +function ahref_cell($label, $href, $target="", $onclick="") { + echo "  "; + ahref($label, $href, $target, $onclick); + echo "  "; +} diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 01494425..12ebceae 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -25,9 +25,9 @@ define('SELECT_BUTTON', " array(), // additional constraints @@ -239,11 +239,16 @@ $opts = array( // default options $_POST[$name] = $multi ? $selected_id : $selected_id[0]; - $selector = "".$selector."\n"; + else + $selector = "\n"; - if ($by_id && ($search_box != false || $opts['editable']) ) { // on first display show selector list if (isset($_POST[$search_box]) && $opts['editable'] && $edit) { @@ -287,13 +292,87 @@ $opts = array( // default options } default_focus(($search_box && $by_id) ? $search_box : $name); + if ($SysPrefs->use_popup_search) + { + $img = ""; + $img_title = ""; + $link = ""; + $id = $name; + if ($SysPrefs->use_popup_windows) { + //_vd("type= $type"); + switch (strtolower($type)) { + case "stock": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id; + $img_title = _("Search items"); + break; + case "stock_manufactured": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=manufactured&client_id=" . $id; + $img_title = _("Search items"); + break; + case "stock_purchased": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=purchasable&client_id=" . $id; + $img_title = _("Search items"); + break; + case "stock_sales": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=sales&client_id=" . $id; + $img_title = _("Search items"); + break; + case "stock_costable": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id; + $img_title = _("Search items"); + break; + case "kits": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id; + $img_title = _("Search items"); + break; + case "assets": + $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=assets&client_id=" . $id; + $img_title = _("Search items"); + break; + case "customer": + $link = $path_to_root . "/sales/inquiry/customers_list.php?popup=1&client_id=" . $id; + $img_title = _("Search customers"); + break; + case "branch": + $link = $path_to_root . "/sales/inquiry/customer_branches_list.php?popup=1&client_id=" . $id . "#customer_id"; + $img_title = _("Search branches"); + break; + case "supplier": + $link = $path_to_root . "/purchasing/inquiry/suppliers_list.php?popup=1&client_id=" . $id; + $img_title = _("Search suppliers"); + break; + case "account": + $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&client_id=" . $id; + $img_title = _("Search GL accounts"); + break; + } + } + + if ($link !=="") { + $theme = user_theme(); + $img = ''; + } + } + if ($opts['editlink']) $selector .= ' '.$opts['editlink']; - if ($search_box && $opts['cells']) - $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector"; + if ($SysPrefs->use_popup_search) + { + if ($search_box && $opts['cells']) + $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector$img"; + else + $str = $edit_entry.$selector.$img; + } else - $str = $edit_entry.$selector; + { + if ($search_box && $opts['cells']) + $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector"; + else + $str = $edit_entry.$selector; + } return $str; } @@ -462,7 +541,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select supplier'), 'show_inactive'=>$all, 'editlink' => $editkey ? add_edit_combo('supplier') : false - )); + ), "supplier"); return $ret; } @@ -513,7 +592,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select customer'), 'show_inactive' => $show_inactive, 'editlink' => $editkey ? add_edit_combo('customer') : false - ) ); + ), "customer" ); return $ret; } @@ -560,7 +639,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, 'select_submit'=> $submit_on_change, 'sel_hint' => _('Select customer branch'), 'editlink' => $editkey ? add_edit_combo('branch') : false - ) ); + ), "branch" ); return $ret; } //------------------------------------------------------------------------------------------------ @@ -732,9 +811,8 @@ function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, //--------------------------------------------------------------------------------------------------- function stock_items_list($name, $selected_id=null, $all_option=false, - $submit_on_change=false, $opts=array(), $editkey = false) + $submit_on_change=false, $opts=array(), $editkey = false, $type = "stock") { - $sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id"; @@ -746,6 +824,8 @@ function stock_items_list($name, $selected_id=null, $all_option=false, if ($editkey) set_editor('item', $name, $editkey); + if (isset($opts['fixed_asset']) && $opts['fixed_asset']) + $type = 'assets'; $ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description', array_merge( array( @@ -762,7 +842,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'editlink' => $editkey ? add_edit_combo('item') : false, 'editable' => false, 'max' => 255 - ), $opts) ); + ), $opts), $type ); return $ret; } @@ -845,7 +925,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false, 'order' => array('c.description','i.item_code'), 'editable' => 30, 'max' => 255 - ), $opts) ); + ), $opts), $type == 'kits' ? $type : "stock_sales" ); } function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false) @@ -881,7 +961,7 @@ function stock_manufactured_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false) { return stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("mb_flag= 'M'"))); + array('where'=>array("mb_flag= 'M'")), false, "stock_manufactured"); } function stock_manufactured_items_list_cells($label, $name, $selected_id=null, @@ -925,7 +1005,7 @@ function stock_costable_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false) { return stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("mb_flag!='D'"))); + array('where'=>array("mb_flag!='D'")), false, "stock_costable"); } function stock_costable_items_list_cells($label, $name, $selected_id=null, @@ -934,7 +1014,7 @@ function stock_costable_items_list_cells($label, $name, $selected_id=null, if ($label != null) echo "$label\n"; echo stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('where'=>array("mb_flag!='D'"), 'cells'=>true)); + array('where'=>array("mb_flag!='D'"), 'cells'=>true), false, "stock_costable"); } //------------------------------------------------------------------------------------ @@ -943,7 +1023,7 @@ function stock_purchasable_items_list($name, $selected_id=null, { return stock_items_list($name, $selected_id, $all_option, $submit_on_change, array('where'=>array("NOT no_purchase"), - 'show_inactive'=>$all), $editkey); + 'show_inactive'=>$all), $editkey, "stock_purchased"); } // // This helper is used in PO/GRN/PI entry and supports editable descriptions. @@ -1745,7 +1825,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals 'async' => false, 'category' => 2, 'show_inactive' => $all - ) ); + ), "account" ); } function _format_account($row) diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 5352cb91..1284a918 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -888,6 +888,51 @@ function get_js_open_window($width, $height) . " var top = (screen.height - $height) / 2;\n" . " return window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n" . "}\n"; + $js .= get_js_lookup_window(); + return $js; +} + +function get_js_lookup_window() { + $js = "function lookupWindow(url, title) { + var u = url.split('#'); + if (u.length == 2) { + var element = document.getElementById(u[1]); + var options = element.options; + url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value; + } + openWindow(url, title); + }"; + return $js; +} + +function get_js_select_combo_item() { + $js = "function selectComboItem(doc, client_id, value){ + var element = doc.getElementById(client_id); + var options = element.options; + for (var i = 0, optionsLength = options.length; i < optionsLength; i++) { + if (options[i].value == value) { + element.selectedIndex = i; + element.onchange(); + } + } + window.close(); + }"; + return $js; +} +/* for space search option */ +function get_js_set_combo_item() { + $js = "function setComboItem(doc, client_id, value, text){ + var element = doc.getElementById(client_id); + var options = element.options; + options.length = 0; + var option = doc.createElement('option'); + option.value = value; + option.text = text; + element.add(option, 0); + element.selectedIndex = 0; + element.onchange(); + window.close(); + }"; return $js; } diff --git a/inventory/inquiry/stock_list.php b/inventory/inquiry/stock_list.php new file mode 100644 index 00000000..1d1c5890 --- /dev/null +++ b/inventory/inquiry/stock_list.php @@ -0,0 +1,131 @@ +max_rows_in_search)) + $limit = $SysPrefs->max_rows_in_search; +else + $limit = 10; + +// Activate Ajax on form submit +if(get_post("search")) { + $Ajax->activate("item_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); + +start_row(); + +text_cells(_("Description"), "description"); +submit_cells("search", _("Search"), "", _("Search items"), "default"); + +end_row(); + +end_table(); + +end_form(); +// END: Filter form + +// BEGIN: Link to add new item +// hyperlink_params($path_to_root . "/inventory/manage/items.php", _("Add new"), "popup=1"); +// END: Link to add new item + +// BEGIN: Item list +div_start("item_tbl"); + +start_table(TABLESTYLE); + +$th = array("", _("Item Code"), _("Description"), _("Category")); + +table_header($th); + +// Query based on function sales_items_list in includes/ui/ui_lists.inc. +$sql = "SELECT COUNT(i.item_code) AS kit, i.item_code, i.description, c.description category + FROM + ".TB_PREF."stock_master s, + ".TB_PREF."item_codes i + LEFT JOIN + ".TB_PREF."stock_category c + ON i.category_id=c.category_id + WHERE i.stock_id=s.stock_id + AND !i.inactive AND !s.inactive + AND ( i.item_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR + i.description LIKE " . db_escape("%" . get_post("description"). "%") . " OR + c.description LIKE " . db_escape("%" . get_post("description"). "%") . ") "; + +$type = ""; +if (isset($_GET['type'])) { + $type = $_GET['type']; +} +//_vd("type = $type"); +switch ($type) { + case "sales": + $sql .= " AND !s.no_sale AND mb_flag != 'F'"; + break; + case "manufactured": + $sql .= " AND mb_flag = 'M'"; + break; + case "purchasable": + $sql .= " AND NOT no_purchase AND mb_flag != 'F' AND i.item_code=i.stock_id"; + break; + case "costable": + $sql .= " AND mb_flag != 'D' AND mb_flag != 'F' AND i.item_code=i.stock_id"; + break; + case "assets": + $sql .= " AND mb_flag = 'F'"; + break; + case "kits": + $sql .= " AND !i.is_foreign AND i.item_code!=i.stock_id AND mb_flag != 'F'"; + break; + case "all": + $sql .= " AND mb_flag != 'F' AND i.item_code=i.stock_id"; + // NOTHING TO DO. + break; +} + +$sql .= " GROUP BY i.item_code ORDER BY i.description LIMIT 0, $limit"; // We only display 10 items. +//_vd($sql); +$result = db_query($sql, "Failed in retreiving item list."); + +$k = 0; //row colour counter +$name = $_GET["client_id"]; +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + $value = $myrow['item_code']; + if ($mode != 0) { + $text = $myrow['description']; + ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'", "'.$value.'", "'.$text.'")'); + } + else { + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")'); + } + label_cell($myrow["item_code"]); + label_cell($myrow["description"]); + label_cell($myrow["category"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Item list + +end_page(true); diff --git a/inventory/inquiry/stock_status.php b/inventory/inquiry/stock_status.php index 6c0c0ba9..b83c6038 100644 --- a/inventory/inquiry/stock_status.php +++ b/inventory/inquiry/stock_status.php @@ -13,11 +13,15 @@ $page_security = 'SA_ITEMSSTATVIEW'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Inventory Item Status"), isset($_GET['stock_id'])); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); if (isset($_GET['stock_id'])) $_POST['stock_id'] = $_GET['stock_id']; +page(_($help_context = "Inventory Item Status"), isset($_GET['stock_id']), false, "", $js); + include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); diff --git a/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index 21e0b394..cd39e498 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -22,7 +22,11 @@ else { $help_context = "Item Categories"; } -page(_($help_context)); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context), false, false, "", $js); include_once($path_to_root . "/includes/ui.inc"); diff --git a/inventory/manage/item_codes.php b/inventory/manage/item_codes.php index 9fa68ebb..236ac795 100644 --- a/inventory/manage/item_codes.php +++ b/inventory/manage/item_codes.php @@ -13,7 +13,11 @@ $page_security = 'SA_FORITEMCODE'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Foreign Item Codes")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Foreign Item Codes"), false, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); diff --git a/inventory/manage/sales_kits.php b/inventory/manage/sales_kits.php index 2f406678..f7199e8c 100644 --- a/inventory/manage/sales_kits.php +++ b/inventory/manage/sales_kits.php @@ -13,7 +13,11 @@ $page_security = 'SA_SALESKIT'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Sales Kits & Alias Codes")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Sales Kits & Alias Codes"), false, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); diff --git a/inventory/prices.php b/inventory/prices.php index a464e62e..70dd97d8 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -23,7 +23,10 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -page(_($help_context = "Inventory Item Sales prices")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); +page(_($help_context = "Inventory Item Sales prices"), false, false, "", $js); //--------------------------------------------------------------------------------------------------- diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 8c36581d..8be2566b 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -21,7 +21,10 @@ include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); -page(_($help_context = "Supplier Purchasing Data")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); +page(_($help_context = "Supplier Purchasing Data"), false, false, "", $js); check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system.")); check_db_has_suppliers(_("There are no suppliers defined in the system.")); diff --git a/inventory/reorder_level.php b/inventory/reorder_level.php index cc0d6979..6dfba5f0 100644 --- a/inventory/reorder_level.php +++ b/inventory/reorder_level.php @@ -22,7 +22,10 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -page(_($help_context = "Reorder Levels")); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); +page(_($help_context = "Reorder Levels"), false, false, "", $js); check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items).")); diff --git a/purchasing/inquiry/suppliers_list.php b/purchasing/inquiry/suppliers_list.php new file mode 100644 index 00000000..11bb108f --- /dev/null +++ b/purchasing/inquiry/suppliers_list.php @@ -0,0 +1,93 @@ +max_rows_in_search)) + $limit = $SysPrefs->max_rows_in_search; +else + $limit = 10; + +// Activate Ajax on form submit +if(get_post("search")) { + $Ajax->activate("supplier_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); + +start_row(); + +text_cells(_("Supplier"), "supplier"); +submit_cells("search", _("Search"), "", _("Search suppliers"), "default"); + +end_row(); + +end_table(); + +end_form(); +// END: Filter form + +// BEGIN: Link to add new supplier +// hyperlink_params($path_to_root . "/purchasing/manage/suppliers.php", _("Add new"), "popup=1"); +// END: Link to add new supplier + +// BEGIN: Supplier list +div_start("supplier_tbl"); + +start_table(TABLESTYLE); + +$th = array("", _("Supplier"), _("Short Name"), _("Address"), _("Tax ID")); + +table_header($th); + +// Query based on function supplier_list in includes/ui/ui_lists.inc. +$sql = "SELECT supplier_id, supp_name, supp_ref, address, gst_no FROM ".TB_PREF."suppliers + WHERE (supp_name LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR + supp_ref LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR + address LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR + gst_no LIKE " . db_escape("%" . get_post("supplier"). "%") . ") + ORDER BY supp_name LIMIT 0, $limit"; // We only display 10 items. +$result = db_query($sql, "Failed in retreiving supplier list."); + +$k = 0; //row colour counter +$name = $_GET["client_id"]; +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + $value = $myrow['supplier_id']; + if ($mode != 0) { + $text = $myrow['supp_name']; + ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'", "'.$value.'", "'.$text.'")'); + } + else { + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")'); + } + label_cell($myrow["supp_name"]); + label_cell($myrow["supp_ref"]); + label_cell($myrow["address"]); + label_cell($myrow["gst_no"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Supplier list + +end_page(true); diff --git a/reporting/reports_main.php b/reporting/reports_main.php index 9c571eb8..87efba81 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -18,6 +18,8 @@ include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/reporting/includes/reports_classes.inc"); $js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); if (user_use_date_picker()) $js .= get_js_date_picker(); diff --git a/sales/inquiry/customer_branches_list.php b/sales/inquiry/customer_branches_list.php new file mode 100644 index 00000000..3586628e --- /dev/null +++ b/sales/inquiry/customer_branches_list.php @@ -0,0 +1,93 @@ +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); + +start_row(); + +text_cells(_("Branch"), "branch"); +submit_cells("search", _("Search"), "", _("Search branches"), "default"); + +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 +$name = $_GET["client_id"]; +while ($myrow = db_fetch_assoc($result)) +{ + alt_table_row_color($k); + $value = $myrow['branch_code']; + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")'); + label_cell($myrow["branch_ref"]); + label_cell($myrow["br_name"]); + label_cell($myrow["contact_name"]); + label_cell($myrow["phone"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Customer list + +end_page(true); diff --git a/sales/inquiry/customers_list.php b/sales/inquiry/customers_list.php new file mode 100644 index 00000000..6ff94cc1 --- /dev/null +++ b/sales/inquiry/customers_list.php @@ -0,0 +1,94 @@ +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); + +start_row(); + +text_cells(_("Customer"), "customer"); +submit_cells("search", _("Search"), "", _("Search customers"), "default"); + +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); + +$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 +$name = $_GET["client_id"]; +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + $value = $myrow['debtor_no']; + if ($mode != 0) { + $text = $myrow['name']; + ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'", "'.$value.'", "'.$text.'")'); + } + else { + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")'); + } + label_cell($myrow["name"]); + label_cell($myrow["debtor_ref"]); + label_cell($myrow["address"]); + label_cell($myrow["tax_id"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Customer list + +end_page(true); diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index 7cd65cb3..2e1eae54 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -15,7 +15,11 @@ $path_to_root="../.."; include($path_to_root . "/includes/db_pager.inc"); include($path_to_root . "/includes/session.inc"); -page(_($help_context = "Customer Branches"), @$_REQUEST['popup']); +$js = ""; +if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Customer Branches"), @$_REQUEST['popup'], false, "", $js); include($path_to_root . "/includes/ui.inc"); include($path_to_root . "/includes/ui/contacts_view.inc");