Bugfix [0000080] - BOM line was not editable.
[fa-stable.git] / manufacturing / manage / bom_edit.php
index 09dfd5e9039f129bf3c94b0d658e6d8bfc5430a4..3d71cbd4dd40d9b61c31aa7caf378c98bf73d1ea 100644 (file)
@@ -20,39 +20,6 @@ simple_page_mode(true);
 $selected_component = $selected_id;
 //--------------------------------------------------------------------------------------------------
 
-//if (isset($_GET["NewItem"]))
-//{
-//     $_POST['stock_id'] = $_GET["NewItem"];
-//}
-//if (isset($_GET['stock_id']))
-//{
-//     $_POST['stock_id'] = $_GET['stock_id'];
-//     $selected_parent =  $_GET['stock_id'];
-//}
-
-/* selected_parent could come from a post or a get */
-/*if (isset($_GET["selected_parent"]))
-{
-       $selected_parent = $_GET["selected_parent"];
-}
-else if (isset($_POST["selected_parent"]))
-{
-       $selected_parent = $_POST["selected_parent"];
-}
-*/
-/* selected_component could also come from a post or a get */
-/*if (isset($_GET["selected_component"]))
-{
-       $selected_component = $_GET["selected_component"];
-}
-else
-{
-       $selected_component = get_post("selected_component", -1);
-}
-*/
-
-//--------------------------------------------------------------------------------------------------
-
 function check_for_recursive_bom($ultimate_parent, $component_to_check)
 {
 
@@ -189,7 +156,7 @@ function on_submit($selected_parent, $selected_component=-1)
 
 if ($Mode == 'Delete')
 {
-       $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $selected_component. "'";
+       $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $selected_id. "'";
        db_query($sql,"Could not delete this bom components");
 
        display_notification(_("The component item has been deleted from this bom"));
@@ -198,7 +165,7 @@ if ($Mode == 'Delete')
 
 if ($Mode == 'RESET')
 {
-       $selected_component = -1;
+       $selected_id = -1;
        unset($_POST['quantity']);
 }
 
@@ -219,7 +186,7 @@ if (get_post('selected_parent') != '')
 { //Parent Item selected so display bom or edit component
        $selected_parent = $_POST['selected_parent'];
        if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
-               on_submit($selected_parent, $selected_component);
+               on_submit($selected_parent, $selected_id);
        //--------------------------------------------------------------------------------------
 
 start_form();
@@ -231,12 +198,12 @@ start_form();
 
        start_table($table_style2);
 
-       if ($selected_component != -1)
+       if ($selected_id != -1)
        {
                if ($Mode == 'Edit') {
                        //editing a selected component from the link to the line item
                        $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description FROM ".TB_PREF."bom,".TB_PREF."stock_master
-                               WHERE id='$selected_component'
+                               WHERE id='$selected_id'
                                AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component";
 
                        $result = db_query($sql, "could not get bom");
@@ -245,9 +212,9 @@ start_form();
                        $_POST['loc_code'] = $myrow["loc_code"];
                        $_POST['workcentre_added']  = $myrow["workcentre_added"];
                        $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"]));
-               }
-               hidden('component', $selected_component);
                label_row(_("Component:"), $myrow["component"] . " - " . $myrow["description"]);
+               }
+               hidden('selected_id', $selected_id);
        }
        else
        {
@@ -272,7 +239,7 @@ start_form();
        qty_row(_("Quantity:"), 'quantity', null, null, null, $dec);
 
        end_table(1);
-       submit_add_or_update_center($selected_component == -1, '', true);
+       submit_add_or_update_center($selected_id == -1, '', true);
        end_form();
 }
 // ----------------------------------------------------------------------------------