public function put($rest, $id)
 {
     $req = $rest->request();
     $info = $req->post();
     $old_cost = get_standard_cost($id);
     $update_no = stock_cost_update($id, $info['material_cost'], $info['labour_cost'], $info['overhead_cost'], $old_cost);
     api_success_response(json_encode(array('stock_id' => $id)));
 }
Ejemplo n.º 2
0
}
//--------------------------------------------------------------------------------------
if (isset($_POST['UpdateData'])) {
    $old_cost = get_standard_cost($_POST['stock_id']);
    $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(_("The entered cost is not numeric."));
        set_focus('material_cost');
        $should_update = false;
    } elseif ($old_cost == $new_cost) {
        display_error(_("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_notification(_("Cost has been updated."));
        if ($update_no > 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')) {
    $Ajax->activate('cost_table');
}
//-----------------------------------------------------------------------------------------
$action = $_SERVER['PHP_SELF'];
if (@$_GET['popup']) {
    $action .= "?stock_id=" . get_post('stock_id');
}
start_form(false, false, $action);