Exemplo n.º 1
0
    // Si aucun prix n'est rentré
    if ($object_ligne->value_unit == 0) {
        $error++;
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors');
    }
    // S'il y'a eu au moins une erreur
    if (!$error) {
        $object_ligne->fk_expensereport = $_POST['fk_expensereport'];
        $type = 0;
        // TODO What if service ?
        $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
        $object_ligne->vatrate = price2num($vatrate);
        $object_ligne->total_ttc = $tmp[2];
        $object_ligne->total_ht = $tmp[0];
        $object_ligne->total_tva = $tmp[1];
        $result = $object_ligne->insert();
        if ($result > 0) {
            $db->commit();
            header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
            exit;
        } else {
            dol_print_error($db, $object->error);
            $db->rollback();
        }
    }
    $action = '';
}
if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes") {
    $object = new ExpenseReport($db);
    $object->fetch($id);
    $object_ligne = new ExpenseReportLine($db);