Exemplo n.º 1
0
 }
 if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) {
     setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), 'errors');
     $error++;
 }
 if (!$error) {
     $paymentid = 0;
     $amount = GETPOST('amount_capital') + GETPOST('amount_insurance') + GETPOST('amount_interest');
     if ($amount == 0) {
         setEventMessage($langs->trans('ErrorNoPaymentDefined'), 'errors');
         $error++;
     }
     if (!$error) {
         $db->begin();
         // Create a line of payments
         $payment = new PaymentLoan($db);
         $payment->chid = $chid;
         $payment->datepaid = $datepaid;
         $payment->label = $loan->label;
         $payment->amount_capital = GETPOST('amount_capital');
         $payment->amount_insurance = GETPOST('amount_insurance');
         $payment->amount_interest = GETPOST('amount_interest');
         $payment->paymenttype = GETPOST('paymenttype');
         $payment->num_payment = GETPOST('num_payment');
         $payment->note_private = GETPOST('note_private');
         $payment->note_public = GETPOST('note_public');
         if (!$error) {
             $paymentid = $payment->create($user);
             if ($paymentid < 0) {
                 setEventMessage($payment->error, 'errors');
                 $error++;
Exemplo n.º 2
0
    require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
}
$langs->load('bills');
$langs->load('banks');
$langs->load('companies');
$langs->load('loan');
// Security check
$id = GETPOST("id");
$action = GETPOST("action");
$confirm = GETPOST('confirm');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
$payment = new PaymentLoan($db);
if ($id > 0) {
    $result = $payment->fetch($id);
    if (!$result) {
        dol_print_error($db, 'Failed to get payment id ' . $id);
    }
}
/*
 * Actions
 */
// Delete payment
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) {
    $db->begin();
    $result = $payment->delete($user);
    if ($result > 0) {
        $db->commit();