Пример #1
0
    $old_cost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost'];
    $new_cost = input_num('material_cost') + input_num('labour_cost') + input_num('overhead_cost');
    $should_update = true;
    if (!check_num('material_cost') || !check_num('labour_cost') || !check_num('overhead_cost')) {
        display_error(tr("The entered cost is not numeric."));
        set_focus('material_cost');
        $should_update = false;
    } elseif ($old_cost == $new_cost) {
        display_error(tr("The new cost is the same as the old cost. Cost was not updated."));
        $should_update = false;
    }
    if ($should_update) {
        $update_no = stock_cost_update($_POST['stock_id'], input_num('material_cost'), input_num('labour_cost'), input_num('overhead_cost'), $old_cost);
        display_note(tr("Cost has been updated."));
        if ($update_no > 0) {
            display_note(get_gl_view_str(systypes::cost_update(), $update_no, tr("View the GL Journal Entries for this Cost Update")), 1, 0);
        }
    }
}
//-----------------------------------------------------------------------------------------
start_form(false, true);
if (!isset($_POST['stock_id'])) {
    $_POST['stock_id'] = get_global_stock_item();
}
echo "<center>" . tr("Item:") . "&nbsp;";
stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
echo "</center><hr>";
set_global_stock_item($_POST['stock_id']);
$sql = "SELECT description, units, last_cost, actual_cost, material_cost, labour_cost,\n\toverhead_cost, mb_flag\n\tFROM stock_master\n\tWHERE stock_id='" . $_POST['stock_id'] . "'\n\tGROUP BY description, units, last_cost, actual_cost, material_cost, labour_cost, overhead_cost, mb_flag";
$result = db_query($sql);
check_db_error("The cost details for the item could not be retrieved", $sql);