X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=manufacturing%2Fmanage%2Fbom_edit.php;h=8b978c7d8c4a57ec16ff496cacae2fca8ad4cd39;hb=78c4b687c8f92a92e2933e7d8ee84d3ef89788ee;hp=2469afad8af4b0ed6bee52784b0003c27e14214e;hpb=99730b8d6deb7e81d2f1ebeb2ce7066d27729485;p=fa-stable.git diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index 2469afad..8b978c7d 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -16,12 +16,14 @@ check_db_has_bom_stock_items(_("There are no manufactured or kit items defined i check_db_has_workcentres(_("There are no work centres defined in the system. BOMs require at least one work centre be defined.")); +simple_page_mode(true); +$selected_component = $selected_id; //-------------------------------------------------------------------------------------------------- -if (isset($_GET["NewItem"])) -{ - $_POST['stock_id'] = $_GET["NewItem"]; -} +//if (isset($_GET["NewItem"])) +//{ +// $_POST['stock_id'] = $_GET["NewItem"]; +//} if (isset($_GET['stock_id'])) { $_POST['stock_id'] = $_GET['stock_id']; @@ -29,7 +31,7 @@ if (isset($_GET['stock_id'])) } /* selected_parent could come from a post or a get */ -if (isset($_GET["selected_parent"])) +/*if (isset($_GET["selected_parent"])) { $selected_parent = $_GET["selected_parent"]; } @@ -37,16 +39,17 @@ 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"])) +/*if (isset($_GET["selected_component"])) { $selected_component = $_GET["selected_component"]; } -elseif (isset($_POST["selected_component"])) +else { - $selected_component = $_POST["selected_component"]; + $selected_component = get_post("selected_component", -1); } - +*/ //-------------------------------------------------------------------------------------------------- @@ -102,10 +105,10 @@ div_start('bom'); label_cell($myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreDescription"]); - label_cell(qty_format($myrow["quantity"], $myrow["component"])); + 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']); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + edit_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } //END WHILE LIST LOOP @@ -115,7 +118,7 @@ div_end(); //-------------------------------------------------------------------------------------------------- -function on_submit($selected_parent, $selected_component=null) +function on_submit($selected_parent, $selected_component=-1) { if (!check_num('quantity', 0)) { @@ -124,7 +127,7 @@ function on_submit($selected_parent, $selected_component=null) return; } - if (isset($selected_parent) && isset($selected_component)) + if ($selected_component != -1) { $sql = "UPDATE ".TB_PREF."bom SET workcentre_added='" . $_POST['workcentre_added'] . "', @@ -135,9 +138,10 @@ function on_submit($selected_parent, $selected_component=null) check_db_error("Could not update this bom component", $sql); db_query($sql,"could not update bom"); - + display_notification(_('Selected component has been updated')); + $Mode = 'RESET'; } - elseif (!isset($selected_component) && isset($selected_parent)) + else { /*Selected component is null cos no item selected on first time round @@ -145,7 +149,7 @@ function on_submit($selected_parent, $selected_component=null) component form */ //need to check not recursive bom component of itself! - If (!check_for_recursive_bom($selected_parent, $_POST['component'])) + if (!check_for_recursive_bom($selected_parent, $_POST['component'])) { /*Now check to see that the component is not already on the bom */ @@ -164,9 +168,8 @@ function on_submit($selected_parent, $selected_component=null) . input_num('quantity') . ")"; db_query($sql,"check failed"); - - //$msg = _("A new component part has been added to the bill of material for this item."); - + display_notification(_("A new component part has been added to the bill of material for this item.")); + $Mode = 'RESET'; } else { @@ -184,103 +187,94 @@ function on_submit($selected_parent, $selected_component=null) //-------------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { - - $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $_GET['delete']. "'"; + $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $selected_component. "'"; db_query($sql,"Could not delete this bom components"); - display_note(_("The component item has been deleted from this bom.")); + display_notification(_("The component item has been deleted from this bom")); + $Mode = 'RESET'; +} +if ($Mode == 'RESET') +{ + $selected_component = -1; + unset($_POST['quantity']); } //-------------------------------------------------------------------------------------------------- start_form(false, true); -//echo $msg; echo "
" . _("Select a manufacturable item:") . " "; stock_bom_items_list('stock_id', null, false, true); -echo "
"; +echo "
"; end_form(); - if (isset($_POST['_stock_id_update'])) - $Ajax->activate('bom'); + $Ajax->activate('_page_body'); //-------------------------------------------------------------------------------------------------- -if (isset($_POST['stock_id'])) +if (get_post('stock_id') != '') { //Parent Item selected so display bom or edit component $selected_parent = $_POST['stock_id']; - if (isset($selected_parent) && isset($_POST['Submit'])) { - if(isset($selected_component)) + if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') on_submit($selected_parent, $selected_component); - else - on_submit($selected_parent); - } //-------------------------------------------------------------------------------------- +start_form(); display_bom_items($selected_parent); - - if (isset($selected_parent) && isset($selected_component)) - { - hyperlink_params($_SERVER['PHP_SELF'], _("Add a new Component"), "NewItem=$selected_parent"); - } - +//end_form(); //-------------------------------------------------------------------------------------- - - start_form(false, true, $_SERVER['PHP_SELF'] . "?" . SID . "NewItem=" . $selected_parent); + echo '
'; +// start_form(false, true); start_table($table_style2); - if (isset($selected_component)) + if ($selected_component != -1) { - //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' - AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component"; - - $result = db_query($sql, "could not get bom"); - $myrow = db_fetch($result); - - $_POST['loc_code'] = $myrow["loc_code"]; - $_POST['workcentre_added'] = $myrow["workcentre_added"]; - $_POST['quantity'] = qty_format($myrow["quantity"], $myrow["component"], $dec); - - hidden('selected_parent', $selected_parent); - hidden('selected_component', $selected_component); + 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' + AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component"; + + $result = db_query($sql, "could not get bom"); + $myrow = db_fetch($result); + + $_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"]); - } else - { //end of if $selected_component - - hidden('selected_parent', $selected_parent); - + { start_row(); label_cell(_("Component:")); echo ""; stock_component_items_list('component', $selected_parent, null, false, true); + if (get_post('_component_update')) + { + $Ajax->activate('quantity'); + } echo ""; end_row(); } + hidden('stock_id', $selected_parent); locations_list_row(_("Location to Draw From:"), 'loc_code', null); workcenter_list_row(_("Work Centre Added:"), 'workcentre_added', null); - - if (!isset($_POST['quantity'])) - { - $_POST['quantity'] = qty_format(1, $_POST['stock_id'], $dec); - } - qty_row(_("Quantity:"), 'quantity', $_POST['quantity'], null, null, $dec); + $dec = get_qty_dec(get_post('component')); + $_POST['quantity'] = number_format2(input_num('quantity',1), $dec); + qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); end_table(1); - submit_center('Submit', _("Add/Update")); - + submit_add_or_update_center($selected_component == -1, '', true); end_form(); } - // ---------------------------------------------------------------------------------- end_page();