X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=5f7601497e2a9850a6b375c24800f4e6cd65b7d7;hb=7e830126b96477e969fe3b48d9fc0e78f6c1fe00;hp=a5a96b082b82e22df5d889bb7c9d0b75db909499;hpb=279d7962a249da9cbc3074360e3a68a23a31145e;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index a5a96b08..5f760149 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']; @@ -89,21 +99,20 @@ $opts = array( // default options $opts['sel_hint'] = $by_id || $search_box==false ? '' : _('Press Space tab for search pattern entry'); - if ($opts['box_hint'] === null) // dodaƦ hint dla pustego **** + if ($opts['box_hint'] === null) $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, $opts['default']); + $selected_id = get_post($name, (string)$opts['default']); } if(!is_array($selected_id)) - $selected_id = array($selected_id); // code is generalized for multiple selection support + $selected_id = array((string)$selected_id); // code is generalized for multiple selection support $txt = get_post($search_box); $rel = ''; $limit = ''; - if (isset($_POST['_'.$name.'_update'])) { // select list or search box change if ($by_id) $txt = $_POST[$name]; @@ -134,17 +143,19 @@ $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 ') . ')'; } } } + // sql completion if (count($opts['where'])) { $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; @@ -181,7 +192,8 @@ $opts = array( // default options if (get_post($search_button) && ($txt == $value)) { $selected_id[] = $value; } - if (in_array($value, $selected_id)) { + + if (in_array((string)$value, $selected_id, true)) { $sel = 'selected'; $found = $value; $edit = $opts['editable'] && $contact_row['editable'] @@ -327,7 +339,7 @@ $opts = array( // default options $selected_id = get_post($name, $opts['default']); } if(!is_array($selected_id)) - $selected_id = array($selected_id); // code is generalized for multiple selection support + $selected_id = array((string)$selected_id); // code is generalized for multiple selection support if (isset($_POST[ '_'.$name.'_update'])) { if (!$opts['async']) @@ -343,17 +355,15 @@ $opts = array( // default options //if($name=='SelectStockFromList') display_error($sql); foreach($items as $value=>$descr) { $sel = ''; - if (in_array((string)$value, $selected_id)) { - $sel = "selected='selected'"; + if (in_array((string)$value, $selected_id, true)) { + $sel = 'selected'; $found = $value; } if ($first_id === false) { $first_id = $value; - $first_opt = "\n"; - } - else { - $selector .= "\n"; + $first_opt = $descr; } + $selector .= "\n"; } if ($first_id!==false) { @@ -364,7 +374,7 @@ $opts = array( // default options if ($spec_option !== false) { // if special option used - add it $first_id = $spec_id; $first_opt = $spec_option; - $sel = $found===false ? "selected='selected'" : ''; + $sel = $found===false ? 'selected' : ''; $selector = "\n" . $selector; } @@ -373,6 +383,7 @@ $opts = array( // default options $selected_id = array($first_id); } $_POST[$name] = $multi ? $selected_id : $selected_id[0]; + $selector = "