X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=86968c9fbe644a6c13336ae6dc7a082fb5902af2;hb=ef2f5f6ff03591f558e3296864bbb8b5cbb1b65d;hp=4d15b0095a4f291e1db4deface6e06b9ab973ce8;hpb=c2dd0246dfc1625b90f4212767fbac3706796a08;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 4d15b009..86968c9f 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -6,10 +6,10 @@ include_once($path_to_root . "/includes/types.inc"); include_once($path_to_root . "/includes/current_user.inc"); $_search_button = " "; + ."%s/images/locate.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Set filter")."'> "; $_select_button = " "; + ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> "; $all_items = reserved_words::get_all(); @@ -30,6 +30,7 @@ $opts = array( // default options 'spec_option'=>false, // option text or false 'spec_id' => 0, // option id // submit on select parameters + 'default' => '', // default value when $_POST is not set 'select_submit' => false, //submit on select: true/false 'async' => true, // select update via ajax (true) vs _page_body reload // search box parameters @@ -50,7 +51,8 @@ $opts = array( // default options 'box_hint' => null // box/selectors hints; null = std see below ); // ------ merge options with defaults ---------- - $opts = array_merge($opts, $options); + if($options != null) + $opts = array_merge($opts, $options); if (!is_array($opts['where'])) $opts['where'] = array($opts['where']); $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box']; @@ -67,15 +69,15 @@ $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 ? + $opts['box_hint'] = $search_box && $search_submit != false ? ($by_id ? _('Enter code fragment to search or * for all') : _('Enter description fragment to search or * for all')) :''; if ($selected_id == null) { - $selected_id = get_post($name, null); + $selected_id = get_post($name, $opts['default']); } $txt = get_post($search_box); $rel = ''; @@ -160,15 +162,14 @@ $opts = array( // default options } if ($found === false) { - $_POST[$name] = $first_id; + $selected_id = $first_id; } + $_POST[$name] = $selected_id; - if ($by_id) { + if ($by_id && $search_box != false) { $txt = $_POST[$name]; - if ($search_box) - $Ajax->addUpdate($name, $search_box, $txt); + $Ajax->addUpdate($name, $search_box, $txt); } - $selector = "\n"; @@ -225,19 +226,21 @@ $opts = array( // default options 'spec_id' => 0, // option id 'select_submit' => false, //submit on select: true/false 'async' => true, // select update via ajax (true) vs _page_body reload + 'default' => '', // default value when $_POST is not set // search box parameters 'sel_hint' => null, 'disabled' => false ); // ------ merge options with defaults ---------- - $opts = array_merge($opts, $options); + if($options != null) + $opts = array_merge($opts, $options); $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit']; $spec_id = $opts['spec_id']; $spec_option = $opts['spec_option']; $disabled = $opts['disabled'] ? "disabled" : ''; if ($selected_id == null) { - $selected_id = get_post($name, null); + $selected_id = get_post($name, $opts['default']); } if (isset($_POST[$select_submit])) { @@ -472,33 +475,29 @@ function currencies_list($name, $selected_id=null, $submit_on_change=false) $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies"; // default to the company currency - if ($selected_id == "") - { - $selected_id = get_company_currency(); - $_POST[$name] = $selected_id; - } return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency', array( 'select_submit'=> $submit_on_change, - 'async' => false + 'default' => get_company_currency(), + 'async' => false ) ); } -function currencies_list_cells($label, $name, $selected_id=null) +function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false) { if ($label != null) echo "