This commit is contained in:
Florian HENRY 2021-05-20 13:41:23 +02:00
parent 62bc6e9e1f
commit 7c6ac86d32

View File

@ -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 '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
if (!in_array($massaction, array('presend', 'predelete' ,'makepayment'))) {
print '<input type="hidden" name="action" value="list">';
}
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="search_status" value="'.$search_status.'">';