X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=manufacturing%2Fmanage%2Fbom_edit.php;h=fe373a1c373c3bcf9aa6812aea9b86c0fb81f601;hb=510d6e1925c4d1621ae3efd85e117cc9bb4320f0;hp=a10606b147d308d07986cc58a84d3da948e7199b;hpb=d67d5295b9342c011697ce4df325197e29898588;p=fa-stable.git diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index a10606b1..fe373a1c 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -1,7 +1,16 @@ . +***********************************************************************/ +$page_security = 'SA_BOM'; +$path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); page(_("Bill Of Materials")); @@ -16,12 +25,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 +40,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 +48,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); } - +*/ //-------------------------------------------------------------------------------------------------- @@ -56,7 +68,7 @@ function check_for_recursive_bom($ultimate_parent, $component_to_check) /* returns true ie 1 if the bom contains the parent part as a component ie the bom is recursive otherwise false ie 0 */ - $sql = "SELECT component FROM ".TB_PREF."bom WHERE parent='$component_to_check'"; + $sql = "SELECT component FROM ".TB_PREF."bom WHERE parent=".db_escape($component_to_check); $result = db_query($sql,"could not check recursive bom"); if ($result != 0) @@ -86,7 +98,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,19 +114,20 @@ 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']); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + delete_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); +div_end(); } //-------------------------------------------------------------------------------------------------- -function on_submit($selected_parent, $selected_component=null) +function on_submit($selected_parent, $selected_component=-1) { if (!check_num('quantity', 0)) { @@ -123,20 +136,21 @@ 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'] . "', - loc_code='" . $_POST['loc_code'] . "', + $sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($_POST['workcentre_added']) + . ",loc_code=".db_escape($_POST['loc_code']) . ", quantity= " . input_num('quantity') . " - WHERE parent='" . $selected_parent . "' - AND id='" . $selected_component . "'"; + WHERE parent=".db_escape($selected_parent) . " + AND id=".db_escape($selected_component); 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 @@ -144,28 +158,27 @@ 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 */ $sql = "SELECT component FROM ".TB_PREF."bom - WHERE parent='$selected_parent' - AND component='" . $_POST['component'] . "' - AND workcentre_added='" . $_POST['workcentre_added'] . "' - AND loc_code='" . $_POST['loc_code'] . "'" ; + WHERE parent=".db_escape($selected_parent)." + AND component=".db_escape($_POST['component']) . " + AND workcentre_added=".db_escape($_POST['workcentre_added']) . " + AND loc_code=".db_escape($_POST['loc_code']); $result = db_query($sql,"check failed"); 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 (".db_escape($selected_parent).", ".db_escape($_POST['component']) . "," + .db_escape($_POST['workcentre_added']) . ", ".db_escape($_POST['loc_code']) . ", " . 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 { @@ -183,101 +196,96 @@ 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=".db_escape($selected_id); 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_id = -1; + unset($_POST['quantity']); } //-------------------------------------------------------------------------------------------------- -start_form(false, true); -//echo $msg; +start_form(); -echo "