From: Janusz Dobrowolski Date: Tue, 19 Oct 2010 08:01:21 +0000 (+0000) Subject: New combo3 class searchable from start of the code (used in gl accounts list). X-Git-Tag: v2.4.2~19^2~559 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=87af4ea9405a74c0e4be19b9076f6d6d64b20e29 New combo3 class searchable from start of the code (used in gl accounts list). --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 036f1ff7..f5e867a2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +19-Oct-2010 Janusz Dobrowolski +! Accounts list compares keypresses to starting fragment of GL code (combo3) +$ /includes/ui/ui_lists.inc + /js/inserts.js + 17-Oct-2010 Joe Hunt ! Changed Inventory Sales Report to use average cost by actual trans dates if non zero $ /reporting/rep304.php @@ -28,7 +33,7 @@ $ /reporting/rep304.php $ /gl/inquiry/balance_sheet.php /gl/inquiry/gl_trial_balance.php /gl/inquiry/profit_loss.php - + 15-Oct-2010 Joe Hunt # [0000263] Customer Credit Note didn't update units when shifting items. $ /sales/includes/ui/sales_credit_ui.inc diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 7b276fdf..fccb1cee 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -46,9 +46,10 @@ $opts = array( // default options 'sel_hint' => null, 'search_box' => false, // name or true/false 'type' => 0, // type of extended selector: - // 0 - with (optional) visible search box, search by id + // 0 - with (optional) visible search box, search by fragment inside id // 1 - with hidden search box, search by option text - // 2 - TODO reverse: box with hidden selector available via enter; this + // 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 @@ -77,8 +78,17 @@ $opts = array( // default options $select_submit = $opts['select_submit']; $spec_id = $opts['spec_id']; $spec_option = $opts['spec_option']; - $by_id = ($opts['type'] == 0); - $class = $by_id ? 'combo':'combo2'; + if ($opts['type'] == 0) { + $by_id = true; + $class = 'combo'; + } elseif($opts['type'] == 1) { + $by_id = false; + $class = 'combo2'; + } else { + $by_id = true; + $class = 'combo3'; + } + $disabled = $opts['disabled'] ? "disabled" : ''; $multi = $opts['multi']; @@ -133,13 +143,14 @@ $opts = array( // default options if ($spec_option === false && $selected_id == array()) $limit = ' LIMIT 1'; else - $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'"; + $opts['where'][] = $valfield . "=". db_escape(get_post($name, $spec_id)); } else if ($txt != '*') { foreach($opts['search'] as $i=> $s) - $opts['search'][$i] = $s . " LIKE '%{$txt}%'"; + $opts['search'][$i] = $s . " LIKE " + .db_escape(($class=='combo3' ? '' : '%').$txt.'%'); $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')'; } } @@ -511,7 +522,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, global $all_items; $sql = "SELECT branch_code, branch_ref FROM ".TB_PREF."cust_branch - WHERE debtor_no='" . $customer_id . "' "; + WHERE debtor_no=" . db_escape($customer_id)." "; if ($editkey) set_editor('branch', $name, $editkey); @@ -1579,6 +1590,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals 'format' => '_format_account', 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option, 'spec_id' => '', + 'type' => 2, 'order' => array('type.class_id','type.id','account_code'), 'search_box' => $cells, 'search_submit' => false, diff --git a/js/inserts.js b/js/inserts.js index 4513d2e8..b9564ed9 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -68,14 +68,21 @@ function _set_combo_input(e) { var select = document.getElementsByName(this.getAttribute('rel'))[0]; if(select && select.selectedIndex>=0) { var len = select.length; - var byid = this.className=='combo'; + var byid = this.className=='combo' || this.className=='combo3'; var ac = this.value.toUpperCase(); select.options[select.selectedIndex].selected = false; for (i = 0; i < len; i++) { var txt = byid ? select.options[i].value : select.options[i].text; - if (txt.toUpperCase().indexOf(ac) >= 0) { - select.options[i].selected = true; - break; + if (this.className=='combo3') { + if(txt.toUpperCase().indexOf(ac) == 0) { + select.options[i].selected = true; + break; + } + } else { + if(txt.toUpperCase().indexOf(ac) >= 0) { + select.options[i].selected = true; + break; + } } } } @@ -91,7 +98,7 @@ function _set_combo_input(e) { } function _update_box(s) { - var byid = s.className=='combo'; + var byid = s.className=='combo' || s.className=='combo3'; var rel = s.getAttribute('rel'); var box = document.getElementsByName(rel)[0]; if(box && s.selectedIndex>=0) { @@ -115,14 +122,14 @@ function _set_combo_select(e) { // if(this.className=='combo') // _update_box(this); if ((this.selectedIndex != this.getAttribute('_last')) - ||(this.className=='combo' && _update_box(this)) + ||((this.className=='combo' || this.className=='combo3') && _update_box(this)) ) this.onchange(); } e.onchange = function() { var s = this; - this.setAttribute('_last', this.selectedIndex); - if(s.className=='combo') + this.setAttribute('_last', this.selectedIndex); + if(s.className=='combo' || this.className=='combo3') _update_box(s); if(s.selectedIndex>=0) { var sname = '_'+s.name+'_update'; @@ -185,11 +192,11 @@ var inserts = { if(e.onfocus==undefined) { e.onfocus = function() { save_focus(this); - if (this.className == 'combo') + if (this.className == 'combo' || this.className == 'combo3') this.select(); }; } - if (e.className == 'combo' || e.className == 'combo2') { + if (e.className == 'combo' || e.className == 'combo2' || e.className == 'combo3') { _set_combo_input(e); } else @@ -295,7 +302,7 @@ var inserts = { save_focus(this); }; var c = e.className; - if (c == 'combo' || c == 'combo2') + if (c == 'combo' || c == 'combo2' || c == 'combo3') _set_combo_select(e); } },