X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fcost_update.php;h=f4fa70ba0f0fec5cf7b2ecb1b4372a794edd346e;hb=5077f4be9a7cdf330f63584863f5861bf09cbbd2;hp=6b6c5950434280ae0f5608d13263711471685411;hpb=e3f700d1e11788f176bf02c7b9969780e66dc167;p=fa-stable.git diff --git a/inventory/cost_update.php b/inventory/cost_update.php index 6b6c5950..f4fa70ba 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -1,24 +1,47 @@ . +***********************************************************************/ +$page_security = 'SA_STANDARDCOST'; + +if (@$_GET['page_level'] == 1) + $path_to_root = "../.."; +else + $path_to_root = ".."; -$page_security = 2; -$path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); - include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/banking.inc"); -include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); - include_once($path_to_root . "/inventory/includes/inventory_db.inc"); +include_once($path_to_root . "/includes/ui/items_cart.inc"); + $js = ""; -if ($use_popup_windows) +if ($SysPrefs->use_popup_windows) $js .= get_js_open_window(900, 500); -page(_("Inventory Item Cost Update"), false, false, "", $js); + +if (isset($_GET['FixedAsset'])) { + $_SESSION['page_title'] = _($help_context = "FA Revaluation"); + $_POST['fixed_asset'] = 1; +} else { + $_SESSION['page_title'] = _($help_context = "Inventory Item Cost Update"); +} +page($_SESSION['page_title'], false, false, "", $js); //-------------------------------------------------------------------------------------- -check_db_has_costable_items(_("There are no costable inventory items defined in the system (Purchased or manufactured items).")); +if (get_post('fixed_asset') == 1) + check_db_has_disposable_fixed_assets(_("There are no fixed assets defined in the system.")); +else + check_db_has_costable_items(_("There are no costable inventory items defined in the system (Purchased or manufactured items).")); if (isset($_GET['stock_id'])) { @@ -26,19 +49,21 @@ if (isset($_GET['stock_id'])) } //-------------------------------------------------------------------------------------- - +$should_update = false; if (isset($_POST['UpdateData'])) { + $old_cost = get_unit_cost($_POST['stock_id']); - $old_cost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost']; - $new_cost = $_POST['material_cost'] + $_POST['labour_cost'] + $_POST['overhead_cost']; + $new_cost = input_num('material_cost') + input_num('labour_cost') + + input_num('overhead_cost'); $should_update = true; - if (!is_numeric($_POST['material_cost']) || !is_numeric($_POST['labour_cost']) || - !is_numeric($_POST['overhead_cost'])) + if (!check_num('material_cost') || !check_num('labour_cost') || + !check_num('overhead_cost')) { display_error( _("The entered cost is not numeric.")); + set_focus('material_cost'); $should_update = false; } elseif ($old_cost == $new_cost) @@ -49,69 +74,82 @@ if (isset($_POST['UpdateData'])) if ($should_update) { - $update_no = stock_cost_update($_POST['stock_id'], $_POST['material_cost'], - $_POST['labour_cost'], $_POST['overhead_cost'], $old_cost); + $update_no = stock_cost_update($_POST['stock_id'], + input_num('material_cost'), input_num('labour_cost'), + input_num('overhead_cost'), $old_cost, + $_POST['refline'], $_POST['memo_']); - display_note(_("Cost has been updated.")); + display_notification(_("Cost has been updated.")); if ($update_no > 0) { - display_note(get_gl_view_str(systypes::cost_update(), $update_no, _("View the GL Journal Entries for this Cost Update")), 1, 0); + display_notification(get_gl_view_str(ST_COSTUPDATE, $update_no, _("View the GL Journal Entries for this Cost Update"))); } + } } +if (list_updated('stock_id') || $should_update) { + unset($_POST['memo_']); + $Ajax->activate('cost_table'); +} //----------------------------------------------------------------------------------------- -start_form(false, true); +$action = $_SERVER['PHP_SELF']; +if ($page_nested) + $action .= "?stock_id=".get_post('stock_id'); +start_form(false, false, $action); + +hidden('fixed_asset'); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); -echo "