diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 6bf02d5d580..067a7cb959a 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -363,13 +363,53 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
-if ($massaction == 'makepayment_confirm') {
+if ($action == 'makepayment_confirm') {
+ /*require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
$arrayofselected = is_array($toselect) ? $toselect : array();
+ if (!empty($invoices_id)) {
+ $bankid=GETPOST('bankid','int');
+ $paiementid=GETPOST('paiementid','int');
+ $paiementdate=dol_mktime(12,0,0,GETPOST('datepaimentmonth','int'),GETPOST('datepaimentday','int'),GETPOST('datepaimentyear','year'));
+ foreach ($arrayofselected as $toselectid) {
+ $facture = new Facture($db);
+ $result = $facture->fetch($invoice_id);
+ if ($result < 0) {
+ setEventMessage($facture->error, 'errors');
+ } else {
+ if (empty($facture->paye)) {
- $loc = dol_buildpath('/compta/paiement.php', 2).'?action=create&facids='.implode(',', $arrayofselected);
-
- header('Location: '.$loc);
- exit;
+ $paiementAmount = $facture->getSommePaiement();
+ $totalcreditnotes = $facture->getSumCreditNotesUsed();
+ $totaldeposits = $facture->getSumDepositsUsed();
+ $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
+ $remaintopay = price2num($facture->total_ttc - $totalpay);
+ if ($remaintopay!=0) {
+ $resultBank = $facture->setBankAccount($bankid);
+ if ($resultBank < 0) {
+ setEventMessage($facture->error, 'errors');
+ } else {
+ $paiement = new Paiement($this->db);
+ $paiement->datepaye = $paiementdate;
+ $paiement->amounts[$facture->id] = $remaintopay; // Array with all payments dispatching with invoice id
+ $paiement->multicurrency_amounts[$facture->id] = $remaintopay;
+ $paiement->paiementid = $paiementid;
+ $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
+ if ($paiement_id < 0) {
+ setEventMessage($facture->ref . ' ' . $paiement->error, 'errors');
+ } else {
+ $result = $paiement->addPaymentToBank($user, 'payment', '', $bankid, '', '');
+ if ($result < 0) {
+ setEventMessages($facture->ref . ' ' . $paiement->error, $paiement->errors, 'errors');
+ }
+ }
+ }
+ }
+ } else {
+ setEventMessage($facture->ref.' Total 0 € Pas de réglement enregistré', 'errors');
+ }
+ }
+ }
+ }*/
} elseif ($massaction == 'withdrawrequest') {
$langs->load("withdrawals");
@@ -985,7 +1025,9 @@ if ($resql) {
}
print '';
print '';
- print '';
+ if (!in_array($massaction, array('presend', 'predelete' ,'makepayment'))) {
+ print '';
+ }
print '';
print '';
print '';