Ajax additions
[fa-stable.git] / manufacturing / manage / bom_edit.php
index 94cc504c746759a850cbc263774972678b3c93b2..d06b84d321a6f525bfb6e6d1c0ed5f4355ec1c66 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"),'','');
@@ -102,7 +102,7 @@ function display_bom_items($selected_parent)
                label_cell($myrow["description"]);
         label_cell($myrow["location_name"]);
         label_cell($myrow["WorkCentreDescription"]);
-        label_cell(qty_format($myrow["quantity"]));
+        qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
         label_cell($myrow["units"]);
         edit_link_cell(SID . "NewItem=$selected_parent&selected_component=" . $myrow["id"]);
         delete_link_cell(SID . "delete=" . $myrow["id"]. "&stock_id=" . $_POST['stock_id']);
@@ -110,6 +110,7 @@ function display_bom_items($selected_parent)
 
        } //END WHILE LIST LOOP
        end_table();
+div_end();
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -119,6 +120,7 @@ function on_submit($selected_parent, $selected_component=null)
        if (!check_num('quantity', 0))
        {
                display_error(_("The quantity entered must be numeric and greater than zero."));
+               set_focus('quantity');
                return;
        }
 
@@ -138,8 +140,8 @@ function on_submit($selected_parent, $selected_component=null)
        elseif (!isset($selected_component) && isset($selected_parent))
        {
 
-               /*Selected component is null cos no item selected on first time round 
-               so must be adding a record must be Submitting new entries in the new 
+               /*Selected component is null cos no item selected on first time round
+               so must be adding a record must be Submitting new entries in the new
                component form */
 
                //need to check not recursive bom component of itself!
@@ -157,8 +159,8 @@ function on_submit($selected_parent, $selected_component=null)
                        if (db_num_rows($result) == 0)
                        {
                                $sql = "INSERT INTO ".TB_PREF."bom (parent, component, workcentre_added, loc_code, quantity)
-                                       VALUES ('$selected_parent', '" . $_POST['component'] . "', '" 
-                                       . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " 
+                                       VALUES ('$selected_parent', '" . $_POST['component'] . "', '"
+                                       . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', "
                                        . input_num('quantity') . ")";
 
                                db_query($sql,"check failed");
@@ -199,9 +201,12 @@ start_form(false, true);
 
 echo "<center>" . _("Select a manufacturable item:") . "&nbsp;";
 stock_bom_items_list('stock_id', null, false, true);
+echo "</center>";
 
 end_form();
 
+if (isset($_POST['_stock_id_update']))
+       $Ajax->activate('bom');
 //--------------------------------------------------------------------------------------------------
 
 if (isset($_POST['stock_id']))
@@ -240,7 +245,7 @@ if (isset($_POST['stock_id']))
 
                $_POST['loc_code'] = $myrow["loc_code"];
                $_POST['workcentre_added']  = $myrow["workcentre_added"];
-               $_POST['quantity'] = qty_format($myrow["quantity"]);
+               $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"]));
 
                hidden('selected_parent', $selected_parent);
                hidden('selected_component', $selected_component);
@@ -256,19 +261,19 @@ if (isset($_POST['stock_id']))
                label_cell(_("Component:"));
 
                echo "<td>";
-               stock_component_items_list('component', $selected_parent, $_POST['component'], false, true);
+               stock_component_items_list('component', $selected_parent, null, false, true);
                echo "</td>";
                end_row();
        }
 
        locations_list_row(_("Location to Draw From:"), 'loc_code', null);
        workcenter_list_row(_("Work Centre Added:"), 'workcentre_added', null);
-
+       $dec = get_qty_dec($_POST['component']);
        if (!isset($_POST['quantity']))
        {
-               $_POST['quantity'] = qty_format(1);
+               $_POST['quantity'] = number_format2(1, $dec);
        }
-       qty_row(_("Quantity:"), 'quantity', $_POST['quantity']);
+       qty_row(_("Quantity:"), 'quantity', $_POST['quantity'], null, null, $dec);
 
        end_table(1);
        submit_center('Submit', _("Add/Update"));