Fixed bug in array_selector
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 7 May 2010 13:37:10 +0000 (13:37 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 7 May 2010 13:37:10 +0000 (13:37 +0000)
CHANGELOG.txt
includes/ui/ui_lists.inc

index ed78295b349246a5efb01c749337c71bc1eb4bd0..bd8af76ff564a01d929b83f678af632538739b8b 100644 (file)
@@ -19,6 +19,10 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+07-May-2010 Janusz Dobrowolski
+# Fixed bug in array_selector for multiply lists
+$ /includes/ui/ui_lists.inc
+
 30-Apr-2010 Janusz Dobrowolski
 + Recovering next reference after voiding of last reference
   /admin/db/voiding_db.inc
index 72d2dd9c261f422a0be830b88780a9c4150ca64e..24dedae2806520dbede7423920a22d39670ec7c0 100644 (file)
@@ -89,7 +89,7 @@ $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')) :'';
@@ -103,7 +103,6 @@ $opts = array(              // default options
        $txt = get_post($search_box);
        $rel = '';
        $limit = '';
-
        if (isset($_POST['_'.$name.'_update'])) { // select list or search box change
                if ($by_id) $txt = $_POST[$name];
 
@@ -145,6 +144,7 @@ $opts = array(              // default options
                                }
                }
        }
+
        // sql completion
        if (count($opts['where'])) {
                $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
@@ -345,16 +345,14 @@ $opts = array(            // default options
                foreach($items as $value=>$descr) {
                        $sel = '';
                        if (in_array((string)$value, $selected_id, true)) {
-                               $sel = "selected='selected'";
+                               $sel = 'selected';
                                $found = $value;
                        }
                        if ($first_id === false) {
                                $first_id = $value;
-                               $first_opt = "<option %s value='$value'>$descr</option>\n";
-                       } 
-                       else {
-                               $selector .= "<option $sel value='$value'>$descr</option>\n";
+                               $first_opt = $descr;
                        }
+                       $selector .= "<option $sel value='$value'>$descr</option>\n";
                }
 
        if ($first_id!==false) {
@@ -365,7 +363,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 = "<option $sel value='$spec_id'>$spec_option</option>\n"
                        . $selector;
        }
@@ -374,6 +372,7 @@ $opts = array(              // default options
                $selected_id = array($first_id);
        }
        $_POST[$name] = $multi ? $selected_id : $selected_id[0];
+
        $selector = "<select autocomplete='off' ".($multi  ? "multiple" : '')
                . ($opts['height']!==false ? ' size="'.$opts['height'].'"' : '')
                . "$disabled name='$name".($multi ? '[]' : '')."' class='combo' title='"