diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 2876d512c52..29ac7e38862 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -42,6 +42,13 @@ if ($user->societe_id) $socid=$user->societe_id; $object = new PaymentExpenseReport($db); +if ($id > 0) +{ + $result=$object->fetch($id); + if (! $result) dol_print_error($db,'Failed to get payment id '.$id); +} + + /* * Actions */ @@ -77,10 +84,10 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere $db->commit(); $factures=array(); // TODO Get all id of invoices linked to this payment - foreach($factures as $id) + foreach($factures as $invoiceid) { $fac = new Facture($db); - $fac->fetch($id); + $fac->fetch($invoiceid); $outputlangs = $langs; if (! empty($_REQUEST['lang_id'])) @@ -110,12 +117,6 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere llxHeader('', $langs->trans("ExpenseReportPayment")); -if ($id > 0) -{ - $result=$object->fetch($id); - if (! $result) dol_print_error($db,'Failed to get payment id '.$id); -} - $form = new Form($db); $head = payment_expensereport_prepare_head($object); @@ -265,9 +266,11 @@ if ($resql) print ''.$expensereport->getLibStatut(4,$objp->amount).''; print "\n"; + if ($objp->paid == 1) // If at least one invoice is paid, disable delete { - $disable_delete = 1; + $disable_delete = 2; + $title_button = $langs->trans("CantRemovePaymentWithOneInvoicePaid"); } $total = $total + $objp->amount; $i++; @@ -303,7 +306,7 @@ if ($action == '') } else { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } } }