Some more fixes related to ajax combos behaviour and usage
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 9 Jun 2008 22:42:47 +0000 (22:42 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 9 Jun 2008 22:42:47 +0000 (22:42 +0000)
CHANGELOG.txt
includes/ui/ui_lists.inc
inventory/cost_update.php
inventory/includes/item_adjustments_ui.inc
inventory/inquiry/stock_status.php
inventory/prices.php
inventory/purchasing_data.php
inventory/reorder_level.php
manufacturing/inquiry/where_used_inquiry.php
manufacturing/manage/bom_edit.php
purchasing/includes/ui/po_ui.inc

index 26653fd153f291fd03c2e0c314250aa325dfdbff..2c32127d71fb97625bca5afc9cb375853e8254b0 100644 (file)
@@ -20,6 +20,19 @@ Legend:
 $ -> Affected files
 
 ---------------------------------------Release Candidate 1-------------------------------
+10-Jun-2008 Janusz Dobrowolski
+# Some more fixes related to ajax combos usage
+$ /includes/ui/ui_lists.inc
+  /inventory/cost_update.php
+  /inventory/prices.php
+  /inventory/purchasing_data.php
+  /inventory/reorder_level.php
+  /inventory/includes/item_adjustments_ui.inc
+  /inventory/inquiry/stock_status.php
+  /manufacturing/inquiry/where_used_inquiry.php
+  /manufacturing/manage/bom_edit.php
+  /purchasing/includes/ui/po_ui.inc
+
 09-Jun-2008 Janusz Dobrowolski
 # Some additional fixes related to last big committment
 $ /gl/gl_journal.php
index 4b2294e314e9c95313afe8b090d9733a398f4601..102227c4727448887ac46b83e958d464117e358e 100644 (file)
@@ -74,7 +74,7 @@ $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 = '';
@@ -131,54 +131,31 @@ $opts = array(            // default options
                        $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 .= "<option $sel value='$value'>$descr</option>\n";
                }
                db_free_result($result);
        }
-       if ($first_id !== false) {
-               // 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 = "<option $sel value='$first_id'>$first_opt</option>\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 = "<option $sel value='$spec_id'>$spec_option</option>\n"
                        . $selector;
-               $first_id = $spec_id;
        }
 
        if ($found === false) {
                $_POST[$name] = $first_id;
        }
 
-
        if ($by_id) {
                $txt = $_POST[$name];
                if ($search_box)
@@ -203,7 +180,7 @@ $opts = array(              // default options
        }
 // ------ make combo ----------
 
-$edit_entry = '';
+       $edit_entry = '';
        if ($search_box != false) {
                $edit_entry = "<input type='text' name='$search_box' id='$search_box' size='".
                        $opts['size']."' maxlength='".$opts['max'].
@@ -670,7 +647,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
index ed6b494476ffc9bdbaded7d26e9a79b627403bd7..82dfb0db4eaf8d695088b3d1c175c39409f120d9 100644 (file)
@@ -65,6 +65,8 @@ if (isset($_POST['UpdateData']))
        }
 }
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('cost_table');
 //-----------------------------------------------------------------------------------------
 
 start_form(false, true);
@@ -87,7 +89,7 @@ $result = db_query($sql);
 check_db_error("The cost details for the item could not be retrieved", $sql);
 
 $myrow = db_fetch($result);
-
+div_start('cost_table');
 hidden("OldMaterialCost", $myrow["material_cost"]);
 hidden("OldLabourCost", $myrow["labour_cost"]);
 hidden("OldOverheadCost", $myrow["overhead_cost"]);
@@ -113,6 +115,7 @@ else
 }
 
 end_table(1);
+div_end();
 submit_center('UpdateData', _("Update"));
 
 end_form();
index 28f38f0a0723abd90d8c8130922e51e0762b27a1..39c728a46bf4429e2a6caf4560b92478f0302fd4 100644 (file)
@@ -139,7 +139,7 @@ function adjustment_edit_item_controls(&$order, $stock_id=null)
        else
        {
        echo "<td colspan=2>";
-       stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
+       stock_costable_items_list('stock_id', null, false, true);
        echo "</td>";
 
        $item_info = get_item_edit_info($_POST['stock_id']);
index acaa0c0f493ddffb40a466291e40d99eb6016ccd..c0509a73f38d307bed659059efdceb7b97d98912 100644 (file)
@@ -18,6 +18,8 @@ include_once($path_to_root . "/includes/data_checks.inc");
 
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('status_tbl');
 //----------------------------------------------------------------------------------------------------
 
 check_db_has_stock_items(_("There are no items defined in the system."));
@@ -46,6 +48,7 @@ if (is_service($mb_flag))
 
 $loc_details = get_loc_details($_POST['stock_id']);
 
+div_start('status_tbl');
 start_table($table_style);
 
 if ($kitset_or_service == true)
@@ -132,7 +135,7 @@ while ($myrow = db_fetch($loc_details))
 }
 
 end_table();
-
+div_end();
 end_form();
 end_page();
 
index 81b2e2c7f845cc3695e248f0ba39c7738a9aa889..7a8e53e1121bc67e53dff882284339644386120c 100644 (file)
@@ -108,13 +108,15 @@ if (isset($_GET['delete']))
        echo _("The selected price has been deleted.");
 
 }
-
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('price_table');
 //---------------------------------------------------------------------------------------------------
 
 $mb_flag = get_mb_flag($_POST['stock_id']);
 
 $prices_list = get_prices($_POST['stock_id']);
 
+div_start('price_table');
 start_table("$table_style width=30%");
 
 $th = array(_("Currency"), _("Sales Type"), _("Price"), "", "");
@@ -135,7 +137,7 @@ while ($myrow = db_fetch($prices_list))
 
 }
 end_table();
-
+div_end();
 //------------------------------------------------------------------------------------------------
 
 if (db_num_rows($prices_list) == 0)
index 0fd952dc5ceaafa026440b981e7e1cdbd28950e1..8a1b4c0f2cef176859066345ddaa965f5a141791 100644 (file)
@@ -106,7 +106,8 @@ if (isset($_GET['Delete']))
        display_note(_("The purchasing data item has been sucessfully deleted."));
        unset ($supplier_id);
 }
-
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('price_table');
 //--------------------------------------------------------------------------------------------------
 
 start_form(false, true);
@@ -137,7 +138,7 @@ else
                WHERE stock_id = '" . $_POST['stock_id'] . "'";
 
     $result = db_query($sql, "The supplier purchasing details for the selected part could not be retrieved");
-
+  div_start('price_table');
     if (db_num_rows($result) == 0)
     {
        display_note(_("There is no purchasing data set up for the part selected"));
@@ -176,6 +177,7 @@ else
 
         end_table();
     }
+ div_end();
 }
 
 //------------------------------------------------------------------------------------------------
index a39d094e4b7e519974f77ab54629a05dceac3726..dfe6f2dc2862e63b3fd98e5ac3f81e0ee7dda73c 100644 (file)
@@ -21,6 +21,8 @@ if (isset($_GET['stock_id']))
        $_POST['stock_id'] = $_GET['stock_id'];
 }
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('reorders');
 //------------------------------------------------------------------------------------
 
 start_form(false, true);
@@ -37,6 +39,7 @@ stock_item_heading($_POST['stock_id']);
 
 set_global_stock_item($_POST['stock_id']);
 
+div_start('reorders');
 start_table("$table_style width=30%");
 
 $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"));
@@ -77,7 +80,7 @@ while ($myrow = db_fetch($result))
 }
 
 end_table(1);
-
+div_end();
 submit_center('UpdateData', _("Update"));
 
 end_form();
index 0bbacaca3afc28c41f9c061cbb25b32c3878deaa..ca58c439f61a1ca561e7e353af2d784fe4ea5de0 100644 (file)
@@ -22,6 +22,9 @@ echo "<hr></center>";
 
 set_global_stock_item($_POST['stock_id']);
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('usage_table');
+
 if (isset($_POST['stock_id']))
 {
     $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description,".TB_PREF."workcentres.name As WorkCentreName, ".TB_PREF."locations.location_name
@@ -32,6 +35,7 @@ if (isset($_POST['stock_id']))
 
     $result = db_query($sql,"No parent items were returned");
 
+       div_start('usage_table');
        if (db_num_rows($result) == 0)
        {
                display_note(_("The selected item is not used in any BOMs."));
@@ -69,6 +73,7 @@ if (isset($_POST['stock_id']))
 
         end_table();
        }
+       div_end();
 }
 
 end_form();
index a10606b147d308d07986cc58a84d3da948e7199b..2df314090a9420c65b3bbec3435b44799eadaa6b 100644 (file)
@@ -86,7 +86,7 @@ function display_bom_items($selected_parent)
        global $table_style;
 
        $result = get_bom($selected_parent);
-
+div_start('bom');
        start_table("$table_style width=60%");
        $th = array(_("Code"), _("Description"), _("Location"),
                _("Work Centre"), _("Quantity"), _("Units"),'','');
@@ -110,6 +110,7 @@ function display_bom_items($selected_parent)
 
        } //END WHILE LIST LOOP
        end_table();
+div_end();
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -204,6 +205,8 @@ echo "</center>";
 
 end_form();
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('bom');
 //--------------------------------------------------------------------------------------------------
 
 if (isset($_POST['stock_id']))
index d76073bde355eed3985174f3852b6261ddacedaa..0104d2f329a1382b06fcb64ffb8fe2ab24aedab7 100644 (file)
@@ -54,7 +54,7 @@ function display_po_header(&$order)
         if (!isset($_POST['supplier_id']) && (get_global_supplier() != reserved_words::get_all()))
                $_POST['supplier_id'] = get_global_supplier();
 
-       supplier_list_row(_("Supplier:"), 'supplier_id', $_POST['supplier_id'], false, true);
+       supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true);
 
        if ($order->supplier_id != $_POST['supplier_id'])
        {