From 7135b89373cd1123fd8d7020124f70f922b51367 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 8 Nov 2015 11:26:04 +0700 Subject: [PATCH 01/12] Fix the unresponsive link after window navigation with Alt + Tab. --- js/inserts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/inserts.js b/js/inserts.js index 0dd141650..c1af82669 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -527,12 +527,13 @@ function setHotKeys() { document.onkeydown = function(ev) { ev = ev||window.event; key = ev.keyCode||ev.which; - if (key == 18 && !ev.ctrlKey) { // start selection, skip Win AltGr - _hotkeys.alt = true; + if (key == 27 && !ev.altKey) { // cancel selection + _hotkeys.alt = false; _hotkeys.focus = -1; return stopEv(ev); } - else if (ev.altKey && !ev.ctrlKey && ((key>47 && key<58) || (key>64 && key<91))) { + else if (ev.altKey && !ev.ctrlKey && ((key>47 && key<58) || (key>64 && key<91))) { + _hotkeys.alt = true; key = String.fromCharCode(key); var n = _hotkeys.focus; var l = document.getElementsBySelector('[accesskey='+key+']'); From 7b5090291c7198148d8f99a9e5cead9bf657410b Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 8 Nov 2015 11:59:55 +0700 Subject: [PATCH 02/12] Some select list such as items, customers, suppliers, and GL accounts can have an icon to open popup window to search for value. This will make searching items easier. --- gl/inquiry/accounts_list.php | 75 ++++++++++++++++ includes/ui/ui_input.inc | 10 ++- includes/ui/ui_lists.inc | 76 ++++++++++++---- includes/ui/ui_view.inc | 31 ++++++- inventory/inquiry/stock_list.php | 106 +++++++++++++++++++++++ purchasing/inquiry/suppliers_list.php | 72 +++++++++++++++ sales/inquiry/customer_branches_list.php | 88 +++++++++++++++++++ sales/inquiry/customers_list.php | 72 +++++++++++++++ 8 files changed, 513 insertions(+), 17 deletions(-) create mode 100644 gl/inquiry/accounts_list.php create mode 100644 inventory/inquiry/stock_list.php create mode 100644 purchasing/inquiry/suppliers_list.php create mode 100644 sales/inquiry/customer_branches_list.php create mode 100644 sales/inquiry/customers_list.php diff --git a/gl/inquiry/accounts_list.php b/gl/inquiry/accounts_list.php new file mode 100644 index 000000000..fcd8958ad --- /dev/null +++ b/gl/inquiry/accounts_list.php @@ -0,0 +1,75 @@ +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_name LIKE " . db_escape("%" . get_post("description"). "%") . " + OR + chart.account_code = " . db_escape(get_post("description")) . " + ) + ORDER BY chart.account_code LIMIT 0, 10"; // We only display 10 items. +$result = db_query($sql, "Failed in retreiving GL account list."); + +$k = 0; //row colour counter + +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["account_code"] . '")'); + 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(); diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 0e58b36bc..247517143 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -962,4 +962,12 @@ function bank_balance_row($bank_acc, $parms='') ."", $parms); } -?> \ No newline at end of file +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 2cc16888e..9290efe2a 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -27,9 +27,9 @@ $all_items = ALL_TEXT; // Options are merged with defaults. function combo_input($name, $selected_id, $sql, $valfield, $namefield, - $options=null) + $options=null, $type=null) { -global $Ajax; +global $Ajax, $path_to_root; $opts = array( // default options 'where'=> array(), // additional constraints @@ -244,7 +244,7 @@ $opts = array( // default options $_POST[$name] = $multi ? $selected_id : $selected_id[0]; - $selector = "\n"; @@ -294,10 +294,58 @@ $opts = array( // default options } default_focus(($search_box && $by_id) ? $search_box : $name); + $img = ""; + $img_title = ""; + $link = ""; + $id = "cbo_" . $name; + 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_purchasable": + $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 "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 . "#cbo_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 ($search_box && $opts['cells']) - $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector"; + $str = ($edit_entry!='' ? "$edit_entry" : '')."$selector$img"; else - $str = $edit_entry.$selector; + $str = $edit_entry.$selector.$img; return $str; } @@ -514,7 +562,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F2 - entry new customer') : _('Select customer'), 'show_inactive' => $show_inactive - ) ); + ), "customer" ); if ($editkey) $ret .= add_edit_combo('customer'); return $ret; @@ -741,7 +789,7 @@ 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") { global $all_items; @@ -764,7 +812,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'select_submit'=> $submit_on_change, 'category' => 2, 'order' => array('c.description','stock_id') - ), $opts) ); + ), $opts), $type ); if ($editkey) $ret .= add_edit_combo('item'); return $ret; @@ -835,7 +883,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), "stock_sales" ); } function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false) @@ -871,7 +919,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, @@ -915,7 +963,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_manufactured"); } function stock_costable_items_list_cells($label, $name, $selected_id=null, @@ -933,7 +981,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("mb_flag!= 'M'"), - 'show_inactive'=>$all), $editkey); + 'show_inactive'=>$all), $editkey, "stock_purchased"); } // // This helper is used in PO/GRN/PI entry and supports editable descriptions. @@ -1644,7 +1692,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals 'async' => false, 'category' => 2, 'show_inactive' => $all - ) ); + ), "account" ); } @@ -2374,5 +2422,3 @@ function payment_services($name) 'spec_id' => '', )); } - -?> diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index cc003088d..28268a881 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -852,6 +852,35 @@ 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; } @@ -1431,4 +1460,4 @@ function payment_link($name, $options) return strtr($link, $patterns); } -?> \ No newline at end of file +?> diff --git a/inventory/inquiry/stock_list.php b/inventory/inquiry/stock_list.php new file mode 100644 index 000000000..afea6fd25 --- /dev/null +++ b/inventory/inquiry/stock_list.php @@ -0,0 +1,106 @@ +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 DISTINCT 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.description LIKE " . db_escape("%" . get_post("description"). "%"); + +$type = ""; +if (isset($_GET['type'])) { + $type = $_GET['type']; +} + +switch ($type) { + case "sales": + $sql .= " AND !s.no_sale"; + break; + case "manufactured": + $sql .= " AND mb_flag = 'M'"; + break; + case "purchasable": + $sql .= " AND mb_flag != 'M'"; + break; + case "costable": + $sql .= " AND mb_flag != 'D'"; + break; + case "all": + // NOTHING TO DO. + break; +} + +$sql .= " ORDER BY i.description LIMIT 0, 10"; // We only display 10 items. + +$result = db_query($sql, "Failed in retreiving item list."); + +$k = 0; //row colour counter + +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["item_code"] . '")'); + 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(); diff --git a/purchasing/inquiry/suppliers_list.php b/purchasing/inquiry/suppliers_list.php new file mode 100644 index 000000000..82138ca1d --- /dev/null +++ b/purchasing/inquiry/suppliers_list.php @@ -0,0 +1,72 @@ +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"), _("Address")); + +table_header($th); + +// Query based on function supplier_list in includes/ui/ui_lists.inc. +$sql = "SELECT supplier_id, supp_name, address FROM ".TB_PREF."suppliers + WHERE supp_name LIKE " . db_escape("%" . get_post("supplier"). "%") . " + ORDER BY supp_name LIMIT 0, 10"; // We only display 10 items. +$result = db_query($sql, "Failed in retreiving supplier list."); + +$k = 0; //row colour counter + +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["supplier_id"] . '")'); + label_cell($myrow["supp_name"]); + label_cell($myrow["address"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Supplier list + +end_page(); diff --git a/sales/inquiry/customer_branches_list.php b/sales/inquiry/customer_branches_list.php new file mode 100644 index 000000000..a28227a78 --- /dev/null +++ b/sales/inquiry/customer_branches_list.php @@ -0,0 +1,88 @@ +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["cbo_customer_id"])." + AND b.br_name LIKE " . db_escape("%" . get_post("branch"). "%") . " + ORDER BY b.br_name LIMIT 0, 10"; // We only display 10 items. + +$result = db_query($sql, "Failed in retreiving branches list."); + +$k = 0; //row colour counter + +while ($myrow = db_fetch_assoc($result)) +{ + + alt_table_row_color($k); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["branch_code"] . '")'); + 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 branches list + +end_page(); diff --git a/sales/inquiry/customers_list.php b/sales/inquiry/customers_list.php new file mode 100644 index 000000000..f2aa22cbe --- /dev/null +++ b/sales/inquiry/customers_list.php @@ -0,0 +1,72 @@ +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"), _("Address")); + +table_header($th); + +// Query based on function customer_list in includes/ui/ui_lists.inc. +$sql = "SELECT debtor_no, name, address FROM ".TB_PREF."debtors_master + WHERE name LIKE " . db_escape("%" . get_post("customer"). "%") . " + ORDER BY name LIMIT 0, 10"; // We only display 10 items. +$result = db_query($sql, "Failed in retreiving customer list."); + +$k = 0; //row colour counter + +while ($myrow = db_fetch_assoc($result)) { + alt_table_row_color($k); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["debtor_no"] . '")'); + label_cell($myrow["name"]); + label_cell($myrow["address"]); + end_row(); +} + +end_table(1); + +div_end(); +// END: Customer list + +end_page(); From 32fa664d0935fd921bdafc190dd40591c8723aa6 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 8 Nov 2015 15:27:33 +0700 Subject: [PATCH 03/12] Check popup window variable condition before display icon for displaying popup window for searching. Fix popup window type costable item select. --- includes/ui/ui_lists.inc | 84 ++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 9290efe2a..a36bae66a 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -29,7 +29,7 @@ $all_items = ALL_TEXT; function combo_input($name, $selected_id, $sql, $valfield, $namefield, $options=null, $type=null) { -global $Ajax, $path_to_root; +global $Ajax, $path_to_root, $use_popup_windows; $opts = array( // default options 'where'=> array(), // additional constraints @@ -298,43 +298,45 @@ $opts = array( // default options $img_title = ""; $link = ""; $id = "cbo_" . $name; - 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_purchasable": - $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 "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 . "#cbo_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 ($use_popup_windows) { + 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_purchasable": + $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 "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 . "#cbo_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 !=="") { @@ -509,7 +511,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') : _('Select supplier'), 'show_inactive'=>$all - )); + ), "supplier"); if ($editkey) $ret .= add_edit_combo('supplier'); return $ret; @@ -612,7 +614,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, 'spec_id' => $all_items, 'select_submit'=> $submit_on_change, 'sel_hint' => _('Select customer branch') - ) ); + ), "branch" ); if ($editkey) { $ret .= add_edit_combo('branch'); @@ -963,7 +965,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'")), false, "stock_manufactured"); + array('where'=>array("mb_flag!='D'")), false, "stock_costable"); } function stock_costable_items_list_cells($label, $name, $selected_id=null, From b20bea9473beebfe2d7c01509a104dff0476f7ee Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 8 Nov 2015 15:31:22 +0700 Subject: [PATCH 04/12] Add feature in some pages to search item dropdown list from popup window. --- admin/gl_setup.php | 6 +++++- gl/manage/gl_accounts.php | 8 ++++++-- inventory/inquiry/stock_status.php | 8 ++++++-- inventory/manage/item_categories.php | 6 +++++- inventory/manage/item_codes.php | 6 +++++- inventory/manage/sales_kits.php | 6 +++++- inventory/prices.php | 8 ++++++-- inventory/purchasing_data.php | 8 ++++++-- inventory/reorder_level.php | 8 ++++++-- manufacturing/manage/bom_edit.php | 6 +++++- sales/manage/customer_branches.php | 6 +++++- 11 files changed, 60 insertions(+), 16 deletions(-) diff --git a/admin/gl_setup.php b/admin/gl_setup.php index aeae18d98..257fa6da1 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -13,7 +13,11 @@ $path_to_root=".."; include($path_to_root . "/includes/session.inc"); -page(_($help_context = "System and General GL Setup")); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "System and General GL Setup"), @$_REQUEST['popup'], false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); diff --git a/gl/manage/gl_accounts.php b/gl/manage/gl_accounts.php index d211a4917..5dd0196cd 100644 --- a/gl/manage/gl_accounts.php +++ b/gl/manage/gl_accounts.php @@ -12,8 +12,12 @@ $page_security = 'SA_GLACCOUNT'; $path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); - -page(_($help_context = "Chart of Accounts")); + +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Chart of Accounts"), @$_REQUEST['popup'], false, "", $js); include($path_to_root . "/includes/ui.inc"); include($path_to_root . "/gl/includes/gl_db.inc"); diff --git a/inventory/inquiry/stock_status.php b/inventory/inquiry/stock_status.php index b6965d296..9e754ddf1 100644 --- a/inventory/inquiry/stock_status.php +++ b/inventory/inquiry/stock_status.php @@ -13,12 +13,16 @@ $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + if (!@$_GET['popup']) { if (isset($_GET['stock_id'])){ - page(_($help_context = "Inventory Item Status"), true); + page(_($help_context = "Inventory Item Status"), true, false, "", $js); } else { - page(_($help_context = "Inventory Item Status")); + page(_($help_context = "Inventory Item Status"), false, false, "", $js); } } if (isset($_GET['stock_id'])) diff --git a/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index c42d910ee..fd256860d 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -13,7 +13,11 @@ $path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); -page(_($help_context = "Item Categories")); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Item Categories"), @$_REQUEST['popup'], 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 4ada6e3eb..9a56928e4 100644 --- a/inventory/manage/item_codes.php +++ b/inventory/manage/item_codes.php @@ -13,7 +13,11 @@ $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Foreign Item Codes")); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Foreign Item Codes"), @$_REQUEST['popup'], 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 a327de2d3..ecd898649 100644 --- a/inventory/manage/sales_kits.php +++ b/inventory/manage/sales_kits.php @@ -13,7 +13,11 @@ $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Sales Kits & Alias Codes")); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Sales Kits & Alias Codes"), @$_REQUEST['popup'], 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 650728ca4..e51f596ca 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -22,8 +22,12 @@ include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -if (!@$_GET['popup']) - page(_($help_context = "Inventory Item Sales prices")); +if (!@$_GET['popup']) { + $js = ""; + if ($use_popup_windows) + $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 96b205e07..4c6ead983 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -21,8 +21,12 @@ include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); -if (!@$_GET['popup']) - page(_($help_context = "Supplier Purchasing Data")); +if (!@$_GET['popup']) { + $js = ""; + if ($use_popup_windows) + $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 c34ba6728..223c26484 100644 --- a/inventory/reorder_level.php +++ b/inventory/reorder_level.php @@ -21,8 +21,12 @@ include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -if (!@$_GET['popup']) - page(_($help_context = "Reorder Levels")); +if (!@$_GET['popup']) { + $js = ""; + if ($use_popup_windows) + $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/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index f69abf5f3..1a3f62535 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -13,7 +13,11 @@ $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_($help_context = "Bill Of Materials")); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + +page(_($help_context = "Bill Of Materials"), @$_REQUEST['popup'], false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index e3b1565fb..f11e8aebf 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -15,7 +15,11 @@ include($path_to_root . "/includes/db_pager.inc"); include($path_to_root . "/includes/session.inc"); -page(_($help_context = "Customer Branches"), @$_REQUEST['popup']); +$js = ""; +if ($use_popup_windows) + $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"); From 2c1c7e649c4296b7912de43a256955657d145e12 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 8 Nov 2015 15:42:28 +0700 Subject: [PATCH 05/12] Use mysqli instead of mysql for queries. --- includes/db/connect_db.inc | 319 +++++++++++++++++-------------------- 1 file changed, 148 insertions(+), 171 deletions(-) diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index bca8b86f5..a1a0b1c1f 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -10,218 +10,195 @@ See the License here . ***********************************************************************/ -function set_global_connection($company=-1) -{ - global $db, $transaction_level, $db_connections; - - cancel_transaction(); // cancel all aborted transactions if any - $transaction_level = 0; - - if ($company == -1) - $company = $_SESSION["wa_current_user"]->company; - - $_SESSION["wa_current_user"]->cur_con = $company; - - $connection = $db_connections[$company]; - - $db = mysql_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]); - mysql_select_db($connection["dbname"], $db); - ///// From MySql release 5.6.6 the sql_mode is no longer empty as it was prior to - ///// this release. Just for safety we set it empty for all 5.6 release and higher. - ///// This non empty sql_mode values can interphere with FA, so all is set empty during - ///// our sessions. - ///// We are, however, investigating the existing code to be compatible in the future. - ///// We are also working on a mysql/mysqli solution to go to release 2.4. - if (strncmp(mysql_get_server_info(), "5.6", 3) >= 0) - db_query("SET sql_mode = ''"); - ///// - return $db; +function set_global_connection($company = -1) { + global $db, $transaction_level, $db_connections; + + cancel_transaction(); + // cancel all aborted transactions if any + $transaction_level = 0; + + if ($company == -1) { + $company = $_SESSION["wa_current_user"]->company; + } + + $_SESSION["wa_current_user"]->cur_con = $company; + + $connection = $db_connections[$company]; + $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]); + mysqli_select_db($db, $connection["dbname"]); + ///// From MySql release 5.6.6 the sql_mode is no longer empty as it was prior to + ///// this release. Just for safety we set it empty for all 5.6 release and higher. + ///// This non empty sql_mode values can interphere with FA, so all is set empty during + ///// our sessions. + ///// We are, however, investigating the existing code to be compatible in the future. + ///// We are also working on a mysql/mysqli solution to go to release 2.4. + if (strncmp(mysqli_get_server_info($db), "5.6", 3) >= 0) + db_query("SET sql_mode = ''"); + ///// + return $db; } $db_duplicate_error_code = 1062; //DB wrapper functions to change only once for whole application -function db_query($sql, $err_msg=null) -{ - global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax, - $db_connections, $db_last_inserted_id; - - // set current db prefix - $cur_prefix = $db_connections[$_SESSION["wa_current_user"]->cur_con]['tbpref']; - $sql = str_replace(TB_PREF, $cur_prefix, $sql); +function db_query($sql, $err_msg = null) { + global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax, $db_connections, $db_last_inserted_id; - if ($show_sql) - { - $Ajax->activate('footer_debug'); - $sql_queries .= "
$sql
\n
"; - } + // set current db prefix + $cur_prefix = $db_connections[$_SESSION["wa_current_user"]->cur_con]['tbpref']; + $sql = str_replace(TB_PREF, $cur_prefix, $sql); - $result = mysql_query($sql, $db); - - if($sql_trail) { - $db_last_inserted_id = mysql_insert_id($db); // preserve in case trail insert is done - if ($select_trail || (strstr($sql, 'SELECT') === false)) { - mysql_query( - "INSERT INTO ".$cur_prefix."sql_trail - (`sql`, `result`, `msg`) - VALUES(".db_escape($sql).",".($result ? 1 : 0).", - ".db_escape($err_msg).")", $db); - } - } + if ($show_sql) { + $Ajax->activate('footer_debug'); + $sql_queries .= "
$sql
\n
"; + } - if ($err_msg != null || $go_debug) { - $exit = $err_msg != null; - if (function_exists('xdebug_call_file')) - check_db_error('
At file '.xdebug_call_file().':'.xdebug_call_line().':
'.$err_msg, $sql, $exit); - else - check_db_error($err_msg, $sql, $exit); - } - return $result; -} + $result = mysqli_query($db, $sql); -function db_fetch_row ($result) -{ + if ($sql_trail) { + $db_last_inserted_id = mysqli_insert_id($db); + // preserve in case trail insert is done + if ($select_trail || (strstr($sql, 'SELECT') === false)) { + mysqli_query($db, "INSERT INTO " . $cur_prefix . "sql_trail + (`sql`, `result`, `msg`) + VALUES(" . db_escape($sql) . "," . ($result ? 1 : 0) . ", + " . db_escape($err_msg) . ")"); + } + } - return mysql_fetch_row($result); + if ($err_msg != null || $go_debug) { + $exit = $err_msg != null; + if (function_exists('xdebug_call_file')) + check_db_error('
At file ' . xdebug_call_file() . ':' . xdebug_call_line() . ':
' . $err_msg, $sql, $exit); + else + check_db_error($err_msg, $sql, $exit); + } + return $result; } -function db_fetch_assoc ($result) -{ - - return mysql_fetch_assoc($result); +function db_fetch_row($result) { + return mysqli_fetch_row($result); } -function db_fetch ($result) -{ +function db_fetch_assoc($result) { + return mysqli_fetch_assoc($result); +} - return mysql_fetch_array($result); +function db_fetch($result) { + //return mysqli_fetch_array($result); + $row = mysqli_fetch_array($result); + if ($row === NULL) + return false; + else + return $row; } -function db_seek (&$result,$record) -{ - return mysql_data_seek($result, $record); +function db_seek(&$result, $record) { + return mysqli_data_seek($result, $record); } -function db_free_result ($result) -{ - if ($result) - mysql_free_result($result); +function db_free_result($result) { + if ($result) { + mysqli_free_result($result); + } } -function db_num_rows ($result) -{ - return mysql_num_rows($result); +function db_num_rows($result) { + return mysqli_num_rows($result); } -function db_num_fields ($result) -{ - return mysql_num_fields($result); +function db_num_fields($result) { + return mysqli_num_fields($result); } -function db_escape($value = "", $nullify = false) -{ - $value = @html_entity_decode($value, ENT_QUOTES, $_SESSION['language']->encoding); - $value = @htmlspecialchars($value, ENT_QUOTES, $_SESSION['language']->encoding=='iso-8859-2' ? 'ISO-8859-1' : $_SESSION['language']->encoding); +function db_escape($value = "", $nullify = false) { + global $db; + $value = @html_entity_decode($value, ENT_QUOTES, $_SESSION['language']->encoding); + $value = @htmlspecialchars($value, ENT_QUOTES, $_SESSION['language']->encoding); - //reset default if second parameter is skipped - $nullify = ($nullify === null) ? (false) : ($nullify); + //reset default if second parameter is skipped + $nullify = ($nullify === null) ? (false) : ($nullify); - //check for null/unset/empty strings - if ((!isset($value)) || (is_null($value)) || ($value === "")) { - $value = ($nullify) ? ("NULL") : ("''"); - } else { - if (is_string($value)) { - //value is a string and should be quoted; determine best method based on available extensions - if (function_exists('mysql_real_escape_string')) { - $value = "'" . mysql_real_escape_string($value) . "'"; - } else { - $value = "'" . mysql_escape_string($value) . "'"; - } - } else if (!is_numeric($value)) { - //value is not a string nor numeric - display_error("ERROR: incorrect data type send to sql query"); - echo '

'; - exit(); - } - } - return $value; -} + //check for null/unset/empty strings + if ((!isset($value)) || (is_null($value)) || ($value === "")) { + $value = ($nullify) ? ("NULL") : ("''"); + } else { + if (is_string($value)) { -function db_error_no () -{ - global $db; - return mysql_errno($db); + $value = "'" . mysqli_real_escape_string($db, $value) . "'"; + } else if (!is_numeric($value)) { + //value is not a string nor numeric + display_error("ERROR: incorrect data type send to sql query"); + echo '

'; + exit(); + } + } + return $value; } -function db_error_msg($conn) -{ - return mysql_error($conn); +function db_error_no() { + return mysqli_connect_errno(); } -function db_insert_id() -{ - global $db_last_inserted_id, $sql_trail, $db; +function db_error_msg($db) { + return mysqli_error($db); +} - return $sql_trail ? $db_last_inserted_id : mysql_insert_id($db); +function db_insert_id() { + global $db_last_inserted_id, $sql_trail, $db; + return $sql_trail ? $db_last_inserted_id : mysqli_insert_id($db); } -function db_num_affected_rows() -{ - global $db; - return mysql_affected_rows($db); +function db_num_affected_rows() { + global $db; + return mysqli_affected_rows($db); } -function db_field_name($result, $n) -{ - return mysql_field_name($result, $n); +function db_field_name($result, $n) { + //return mysqli_field_name($result, $n); + $fieldinfo = mysqli_fetch_field_direct($result, $n); + return $fieldinfo->name; } -function db_create_db($connection) -{ - $db = mysql_connect($connection["host"] , - $connection["dbuser"], $connection["dbpassword"]); - if (!mysql_select_db($connection["dbname"], $db)) - { - $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . ""; - if (!mysql_query($sql) || !mysql_select_db($connection["dbname"], $db)) - return 0; - } - return $db; +function db_create_db($connection) { + $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]); + if (!mysqli_select_db($db, $connection["dbname"])) { + $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . ""; + if (!mysqli_query($db, $sql) || !mysqli_select_db($db, $connection["dbname"])) { + return 0; + } + } + return $db; } -function db_drop_db($connection) -{ +function db_drop_db($connection) { - if ($connection["tbpref"] == "") - { - $sql = "DROP DATABASE IF EXISTS " . $connection["dbname"] . ""; - return mysql_query($sql); - } - else - { - $res = db_query("show table status"); - $all_tables = array(); - while($row = db_fetch($res)) - $all_tables[] = $row; + if ($connection["tbpref"] == "") { + $sql = "DROP DATABASE IF EXISTS " . $connection["dbname"] . ""; + return mysqli_query($db, $sql); + } else { + $res = db_query("show table status"); + $all_tables = array(); + while ($row = db_fetch($res)) { + $all_tables[] = $row; + } // get table structures - foreach ($all_tables as $table) - { - if (strpos($table['Name'], $connection["tbpref"]) === 0) - db_query("DROP TABLE `".$table['Name'] . "`"); - } - //deleting the tables, how?? - return true; - } -} - -function db_close($dbase = null) -{ - global $db; - - if (!$dbase) - $dbase = $db; - return mysql_close($dbase); -} - -?> \ No newline at end of file + foreach ($all_tables as $table) { + if (strpos($table['Name'], $connection["tbpref"]) === 0) { + db_query("DROP TABLE `" . $table['Name'] . "`"); + } + } + //deleting the tables, how?? + return true; + } +} + +function db_close($dbase = null) { + global $db; + + if (!$dbase) { + $dbase = $db; + } + return mysqli_close($dbase); +} From 949e715eef2715cffb9e829e32a9990af2ec3638 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Mon, 9 Nov 2015 20:52:49 +0700 Subject: [PATCH 06/12] Clean up some code after adding the search popup window feature. --- admin/gl_setup.php | 2 +- gl/manage/gl_accounts.php | 2 +- inventory/manage/item_categories.php | 2 +- inventory/manage/item_codes.php | 2 +- inventory/manage/sales_kits.php | 2 +- manufacturing/manage/bom_edit.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 257fa6da1..198a67803 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "System and General GL Setup"), @$_REQUEST['popup'], false, "", $js); +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/gl/manage/gl_accounts.php b/gl/manage/gl_accounts.php index 5dd0196cd..030e52f6e 100644 --- a/gl/manage/gl_accounts.php +++ b/gl/manage/gl_accounts.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Chart of Accounts"), @$_REQUEST['popup'], false, "", $js); +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/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index fd256860d..6a8cde429 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Item Categories"), @$_REQUEST['popup'], false, "", $js); +page(_($help_context = "Item Categories"), 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 9a56928e4..edbe6bc99 100644 --- a/inventory/manage/item_codes.php +++ b/inventory/manage/item_codes.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Foreign Item Codes"), @$_REQUEST['popup'], false, "", $js); +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 ecd898649..fbc0c494a 100644 --- a/inventory/manage/sales_kits.php +++ b/inventory/manage/sales_kits.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Sales Kits & Alias Codes"), @$_REQUEST['popup'], false, "", $js); +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/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index 1a3f62535..3915710c3 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Bill Of Materials"), @$_REQUEST['popup'], false, "", $js); +page(_($help_context = "Bill Of Materials"), false, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); From 8be8ddca0d27a4a758c86ca54793275f7c6af563 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sat, 14 Nov 2015 14:28:01 +0700 Subject: [PATCH 07/12] Add target _blank when opening popup window. --- includes/ui/ui_lists.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index a36bae66a..7e1f56ed0 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -341,7 +341,7 @@ $opts = array( // default options if ($link !=="") { $theme = user_theme(); - $img = ''; + $img = ''; } if ($search_box && $opts['cells']) From 9ad514409194b747fdb630658cab656cfd1a70c4 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sat, 14 Nov 2015 14:32:28 +0700 Subject: [PATCH 08/12] When editing manufactured item, provide the link to open popup window for managing its BOM. Also hide main tabs in bom_edit.php when updating BOM in popup window. --- inventory/manage/items.php | 6 ++++++ manufacturing/manage/bom_edit.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inventory/manage/items.php b/inventory/manage/items.php index ea8312514..f56b13c25 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -398,6 +398,12 @@ function item_settings(&$stock_id) check_row(_("Delete Image:"), 'del_image'); record_status_list_row(_("Item status:"), 'inactive'); + + // When editing manufactured item, provide the link to open popup window for managing its bill of materials. + if (is_manufactured($_POST['mb_flag'])){ + label_row(_("Bill of Material:"), '' . _("Update Bill of Material") . ''); + } + end_outer_table(1); div_start('controls'); diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index 3915710c3..1a3f62535 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -17,7 +17,7 @@ if ($use_popup_windows) $js .= get_js_open_window(900, 500); -page(_($help_context = "Bill Of Materials"), false, false, "", $js); +page(_($help_context = "Bill Of Materials"), @$_REQUEST['popup'], false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); From 0655e88023ab1ae69ec3e083cacf148cd1f08502 Mon Sep 17 00:00:00 2001 From: w3shaman Date: Sun, 13 Dec 2015 14:57:20 +0700 Subject: [PATCH 09/12] Improvement for popup window for searching. We can select item when the search feature is activated from the company setup. Add new feature so we can add or edit Bill of Materials from the manage item page. We can also add Bill of Materials together with new item creation. --- gl/inquiry/accounts_list.php | 25 +- includes/ui/ui_input.inc | 8 +- includes/ui/ui_lists.inc | 342 +++++++++++------------ includes/ui/ui_view.inc | 41 ++- inventory/inquiry/stock_list.php | 85 +++--- inventory/manage/items.php | 146 ++++++---- inventory/prices.php | 3 +- inventory/purchasing_data.php | 3 +- inventory/reorder_level.php | 3 +- manufacturing/manage/bom_edit.php | 143 ++++++++-- purchasing/inquiry/suppliers_list.php | 21 +- sales/inquiry/customer_branches_list.php | 42 +-- sales/inquiry/customers_list.php | 21 +- 13 files changed, 523 insertions(+), 360 deletions(-) diff --git a/gl/inquiry/accounts_list.php b/gl/inquiry/accounts_list.php index fcd8958ad..2d2f7afbe 100644 --- a/gl/inquiry/accounts_list.php +++ b/gl/inquiry/accounts_list.php @@ -5,6 +5,7 @@ ***********************************************************************/ $page_security = "SA_GLACCOUNT"; $path_to_root = "../.."; + include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/ui.inc"); @@ -14,7 +15,7 @@ // Activate Ajax on form submit if(get_post("search")) { - $Ajax->activate("account_tbl"); + $Ajax->activate("account_tbl"); } // BEGIN: Filter form. Use query string so the client_id will not disappear @@ -46,24 +47,24 @@ // 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_name LIKE " . db_escape("%" . get_post("description"). "%") . " - OR - chart.account_code = " . db_escape(get_post("description")) . " - ) - ORDER BY chart.account_code LIMIT 0, 10"; // We only display 10 items. + FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type + WHERE chart.account_type=type.id + AND ( + chart.account_name LIKE " . db_escape("%" . get_post("description"). "%") . " + OR + chart.account_code = " . db_escape(get_post("description")) . " + ) + ORDER BY chart.account_code LIMIT 0, 10"; // We only display 10 items. $result = db_query($sql, "Failed in retreiving GL account list."); $k = 0; //row colour counter while ($myrow = db_fetch_assoc($result)) { alt_table_row_color($k); - ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["account_code"] . '")'); - label_cell($myrow["account_code"]); + ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "' . $_GET["client_id"] . '", "' . $myrow["account_code"] . '")'); + label_cell($myrow["account_code"]); label_cell($myrow["account_name"]); - label_cell($myrow["name"]); + label_cell($myrow["name"]); end_row(); } diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 62f925e16..2c82cd0c2 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -963,11 +963,11 @@ function bank_balance_row($bank_acc, $parms='') } function ahref($label, $href, $target="", $onclick="") { - echo "$label"; + echo "$label"; } function ahref_cell($label, $href, $target="", $onclick="") { - echo "  "; - ahref($label, $href, $target, $onclick); - echo "  "; + echo "  "; + ahref($label, $href, $target, $onclick); + echo "  "; } diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 7e1f56ed0..7293b7d09 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -1,12 +1,12 @@ . ***********************************************************************/ include_once($path_to_root . "/includes/banking.inc"); @@ -29,42 +29,42 @@ $all_items = ALL_TEXT; function combo_input($name, $selected_id, $sql, $valfield, $namefield, $options=null, $type=null) { -global $Ajax, $path_to_root, $use_popup_windows; - -$opts = array( // default options - 'where'=> array(), // additional constraints - 'order' => $namefield, // list sort order - // special option parameters - 'spec_option'=>false, // option text or false - 'spec_id' => 0, // option id - // submit on select parameters - 'default' => '', // default value when $_POST is not set - 'multi' => false, // multiple select - 'select_submit' => false, //submit on select: true/false - 'async' => true, // select update via ajax (true) vs _page_body reload - // search box parameters - 'sel_hint' => null, - 'search_box' => false, // name or true/false - 'type' => 0, // type of extended selector: - // 0 - with (optional) visible search box, search by fragment inside id - // 1 - with hidden search box, search by option text - // 2 - with (optional) visible search box, search by fragment at the start of id - // 3 - TODO reverse: box with hidden selector available via enter; this - // would be convenient for optional ad hoc adding of new item - 'search_submit' => true, //search submit button: true/false - 'size' => 8, // size and max of box tag - 'max' => 50, - 'height' => false, // number of lines in select box - 'cells' => false, // combo displayed as 2 cells - 'search' => array(), // sql field names to search - 'format' => null, // format functions for regular options - 'disabled' => false, - 'box_hint' => null, // box/selectors hints; null = std see below - 'category' => false, // category column name or false - 'show_inactive' => false, // show inactive records. - 'editable' => false // false, or length of editable entry field -); -// ------ merge options with defaults ---------- + global $Ajax, $path_to_root, $use_popup_windows; + + $opts = array( // default options + 'where'=> array(), // additional constraints + 'order' => $namefield, // list sort order + // special option parameters + 'spec_option'=>false, // option text or false + 'spec_id' => 0, // option id + // submit on select parameters + 'default' => '', // default value when $_POST is not set + 'multi' => false, // multiple select + 'select_submit' => false, //submit on select: true/false + 'async' => true, // select update via ajax (true) vs _page_body reload + // search box parameters + 'sel_hint' => null, + 'search_box' => false, // name or true/false + 'type' => 0, // type of extended selector: + // 0 - with (optional) visible search box, search by fragment inside id + // 1 - with hidden search box, search by option text + // 2 - with (optional) visible search box, search by fragment at the start of id + // 3 - TODO reverse: box with hidden selector available via enter; this + // would be convenient for optional ad hoc adding of new item + 'search_submit' => true, //search submit button: true/false + 'size' => 8, // size and max of box tag + 'max' => 50, + 'height' => false, // number of lines in select box + 'cells' => false, // combo displayed as 2 cells + 'search' => array(), // sql field names to search + 'format' => null, // format functions for regular options + 'disabled' => false, + 'box_hint' => null, // box/selectors hints; null = std see below + 'category' => false, // category column name or false + 'show_inactive' => false, // show inactive records. + 'editable' => false // false, or length of editable entry field + ); + // ------ merge options with defaults ---------- if($options != null) $opts = array_merge($opts, $options); if (!is_array($opts['where'])) $opts['where'] = array($opts['where']); @@ -91,11 +91,11 @@ $opts = array( // default options $disabled = $opts['disabled'] ? "disabled" : ''; $multi = $opts['multi']; - + if(!count($opts['search'])) { $opts['search'] = array($by_id ? $valfield : $namefield); } - if ($opts['sel_hint'] === null) + if ($opts['sel_hint'] === null) $opts['sel_hint'] = $by_id || $search_box==false ? '' : _('Press Space tab for search pattern entry'); @@ -196,16 +196,16 @@ $opts = array( // default options if (in_array((string)$value, $selected_id, true)) { $sel = 'selected'; $found = $value; - $edit = $opts['editable'] && $contact_row['editable'] + $edit = $opts['editable'] && $contact_row['editable'] && (@$_POST[$search_box] == $value) ? $contact_row[1] : false; // get non-formatted description if ($edit) break; // selected field is editable - abandon list construction } - // show selected option even if inactive + // show selected option even if inactive if (!$opts['show_inactive'] && @$contact_row['inactive'] && $sel==='') { continue; - } else + } else $optclass = @$contact_row['inactive'] ? "class='inactive'" : ''; if ($first_id === false) { @@ -241,7 +241,7 @@ $opts = array( // default options if ($found===false) { $selected_id = array($first_id); } - + $_POST[$name] = $multi ? $selected_id : $selected_id[0]; $selector = "