Finished ajax improvements to sales & purchase modules,
[fa-stable.git] / includes / ui / ui_lists.inc
index e46fe645993dbf01ef29eacb2b98d8445ccebc69..1176cc5f8d538dff76d8e7a721a21c729c6080af 100644 (file)
@@ -94,15 +94,17 @@ $opts = array(              // default options
 
        $rel = "rel='$search_box'"; // set relation to list
    if ($opts['search_submit']) {
-
        if (isset($_POST[$search_submit])) {
-               $Ajax->activate($name);
+               if (!$opts['async'])
+                       $Ajax->activate('_page_body');
+               else
+                       $Ajax->activate($name);
        }
        if ($txt == '') {
-               if ($spec_option === false)
-               $limit = ' LIMIT 1';
+               if ($spec_option === false && $selected_id==null)
+                 $limit = ' LIMIT 1';
                else
-               $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
+                 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
        }
        else
                if ($txt != '*') {
@@ -134,7 +136,7 @@ $opts = array(              // default options
                        $descr = $opts['format']==null ?  $contact_row[1] :
                        call_user_func($opts['format'], $contact_row);
                        $sel = '';
-                       if ($selected_id === $value) {
+                       if ((string)($selected_id) === $value) {
                                $sel = 'selected';
                                $found = $value;
                        }
@@ -354,8 +356,7 @@ return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
        array(
                'spec_option' => $all_option === true ? _("All Locations") : $all_option,
                'spec_id' => $all_items,
-               'select_submit'=> $submit_on_change,
-               'async' => false
+               'select_submit'=> $submit_on_change
        ) );
 }
 
@@ -699,7 +700,8 @@ function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)
                echo "<td>$label</td>\n";
        echo "<td>";
        if ($enabled)
-               $sel = "<select name='$name' onchange='this.form.submit();'>\n";
+               $sel = "<select name='$name' onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>\n";
+               
        else
                $sel =  "<select disabled name='$name'>\n";
        if ($selected_id == null)
@@ -1794,7 +1796,7 @@ function credit_type_list_cells($label, $name, $selected, $submit_on_change=fals
                label_cell($label);
        echo "<td><select name='$name'";
        if ($submit_on_change)
-               echo " onchange='this.form.submit();'>";        // FIX ajax
+               echo " onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>";
        else
                echo ">";
        echo "<option " . ($selected == 'Return'?" selected ":"") . " value='Return'>" . _("Items Returned to Inventory Location"). "</option>\n";