X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=51b0e956a4fe93f4dd687e125dfcc61cdee2e546;hb=425fc1ef0f159173f03532054863691d30f5fa17;hp=c29729326aba00e1039f69c72d38b497b0be878f;hpb=2e7f3c8aa39857f625378d8c43bbd3c54993cd45;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index c2972932..51b0e956 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -45,10 +45,6 @@ $opts = array( // default options 'max' => 50, 'cells' => false, // combo displayed as 2 cells 'search' => array(), // sql field names to search - // if _focus is not set on next field before combo_input call - // set this to false to avoid deadlock via onblur handler - 'next_focus' => (!isset($_POST['_focus']) || - (isset($_POST["_{$name}_button"]) && $_POST['_focus']==$name)) ? false : $_POST['_focus'], 'format' => null, // format functions for regular options 'disabled' => false, // FIX todo 'box_hint' => null // box/selectors hints; null = std see below @@ -70,7 +66,7 @@ $opts = array( // default options } if ($opts['sel_hint'] === null) $opts['sel_hint'] = $by_id || $search_box==false ? - '' : _('Press Space tab for search pattern entry'); + '' : _('Press Space tab for search pattern entry'); if ($opts['box_hint'] === null) $opts['box_hint'] = $search_box ? @@ -78,43 +74,45 @@ $opts = array( // default options : _('Enter description fragment to search or * for all')) :''; if ($selected_id == null) { - $selected_id = get_post($name); + $selected_id = get_post($name, null); } $txt = get_post($search_box); $rel = ''; $limit = ''; if (isset($_POST[$select_submit])) { + + if ($by_id) $txt = $_POST[$name]; + if (!$opts['async']) $Ajax->activate('_page_body'); else $Ajax->activate($name); - set_focus($opts['next_focus']); } - if ($search_box && $opts['search_submit']) { + if ($search_box) { // search related sql modifications $rel = "rel='$search_box'"; // set relation to list + if ($opts['search_submit']) { - // if selected from list - set focus on next field if (isset($_POST[$search_submit])) { $Ajax->activate($name); - set_focus($name); } if ($txt == '') { if ($spec_option === false) - $limit = ' LIMIT 1'; + $limit = ' LIMIT 1'; else - $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'"; + $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'"; } else if ($txt != '*') { foreach($opts['search'] as $i=> $s) $opts['search'][$i] = $s . " LIKE '%{$txt}%'"; - $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')'; + $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')'; } } + } // sql completion if (count($opts['where'])) { $sql .= strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; @@ -126,70 +124,49 @@ $opts = array( // default options $sql .= $limit; // ------ make selector ---------- - $selector = ''; - $first_id = $first_opt = ''; + $selector = $first_opt = ''; + $first_id = false; $found = false; -//if($name=='code_id') display_error($sql); +//if($name=='SelectStockFromList') display_error($sql); if($result = db_query($sql)) { while ($contact_row = db_fetch($result)) { $value = $contact_row[0]; $descr = $opts['format']==null ? $contact_row[1] : call_user_func($opts['format'], $contact_row); $sel = ''; - if (isset($_POST[$search_submit])) { - if (($by_id ? $value : $contact_row[1]) === $txt) - $selected_id = $value; - } - // if no initial selection - set the first item - if ($selected_id === "") { - $selected_id = $value; - } - if ($selected_id == $value) { + if ($selected_id === $value) { $sel = 'selected'; $found = $value; - $_POST[$name] = $selected_id; } - if ($first_opt == false) { + if ($first_id === false) { $first_id = $value; $first_opt = $descr; - continue; } $selector .= "\n"; } db_free_result($result); } - // add first option - selected also if no match for selected_id was found - // and no special option defined - $sel = $spec_option===false || $found === $first_id ? 'selected' : ''; - $selector = "\n" - . $selector; - // Prepend special option. if ($spec_option !== false) { // if special option used - add it $first_id = $spec_id; $first_opt = $spec_option; - if (isset($_POST[$search_submit])) { - if ($txt == '') - $selected_id = $spec_id; - } $sel = $found===false ? 'selected' : ''; $selector = "\n" . $selector; } if ($found === false) { - $_POST[$name] = $first_id; + $_POST[$name] = $first_id; } - if ($by_id) { - $txt = $_POST[$name]; - if ($search_box) - $Ajax->addUpdate($name, $search_box, $txt); + $txt = $_POST[$name]; + if ($search_box) + $Ajax->addUpdate($name, $search_box, $txt); } $selector = "\n"; + . $opts['sel_hint']."' $rel>".$selector."\n"; $Ajax->addUpdate($name, "_{$name}_sel", $selector); @@ -206,15 +183,14 @@ $opts = array( // default options } // ------ make combo ---------- -$edit_entry = ''; + $edit_entry = ''; if ($search_box != false) { $edit_entry = "\n"; -// default_focus($search_box); if ($search_submit != false) { global $_search_button; $edit_entry .= sprintf($_search_button, user_theme(), @@ -563,7 +539,7 @@ function stock_items_list_cells($label, $name, $selected_id, $all_option=false, if ($label != null) echo "$label\n"; $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('cells'=>true)); + array('cells'=>true)); return $str; } /* @@ -674,7 +650,7 @@ function stock_costable_items_list($name, $selected_id, function stock_purchasable_items_list($name, $selected_id, $all_option=false, $submit_on_change=false, $opts=array()) { - + global $all_items; $sql = "SELECT stock_id, s.description, c.description FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id @@ -784,7 +760,7 @@ function tax_types_list($name, $selected_id, $none_option=false, $submit_on_chan return combo_input($name, $selected_id, $sql, 'id', 'name', array( 'spec_option' => $none_option, - 'spec_id' => $all_items, + 'spec_id' => 0, 'select_submit'=> $submit_on_change, 'async' => false, ) ); @@ -823,7 +799,7 @@ function tax_groups_list($name, $selected_id, array( 'order' => 'id', 'spec_option' => $none_option, - 'spec_id' => $all_items, + 'spec_id' => 0, 'select_submit'=> $submit_on_change, 'async' => false, ) ); @@ -1258,7 +1234,7 @@ function gl_account_types_list_row($label, $name, $selected_id, $all_option=fals //----------------------------------------------------------------------------------------------- function gl_all_accounts_list($name, $selected_id, $skip_bank_accounts=false, - $show_group=false, $cells=false) + $show_group=false, $cells=false, $all_option=false) { if ($skip_bank_accounts) $sql = "SELECT chart.account_code, chart.account_name, type.name @@ -1275,9 +1251,11 @@ function gl_all_accounts_list($name, $selected_id, $skip_bank_accounts=false, combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name', array( 'format' => '_format_account' . ($show_group ? '2' : ''), + 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option, + 'spec_id' => '', 'order' => 'account_code', 'search_box' => $cells, - 'search_submit' => true, + 'search_submit' => false, 'size' => 12, 'max' => 10, 'cells' => true @@ -1296,21 +1274,21 @@ function _format_account2($row) } function gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts=false, - $show_group=false, $cells=false) + $show_group=false, $cells=false, $all_option=false) { if ($label != null) echo "$label\n"; echo ""; - gl_all_accounts_list($name, $selected_id, $skip_bank_accounts, $show_group, $cells); + gl_all_accounts_list($name, $selected_id, $skip_bank_accounts, $show_group, $cells, $all_option); echo "\n"; } function gl_all_accounts_list_row($label, $name, $selected_id, $skip_bank_accounts=false, - $show_group=false, $cells=false) + $show_group=false, $cells=false, $all_option=false) { echo "\n"; gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts, - $show_group, $cells); + $show_group, $cells, $all_option); echo "\n"; }