diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index b68374b84b9..cf0fb079fcb 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -726,7 +726,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '';
// Remain to take or to pay back
- print '
'.price($sign * $remaintopay).' | ';
+ print '';
+ print price($sign * $remaintopay);
+ if (!empty($conf->prelevement->enabled)) {
+ $numdirectdebitopen = 0;
+ $totaldirectdebit = 0;
+ $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " WHERE fk_facture = ".((int) $objp->facid);
+ $sql .= " AND pfd.traite = 0";
+ $sql .= " AND pfd.ext_payment_id IS NULL";
+
+ $result_sql = $db->query($sql);
+ if ($result_sql) {
+ $obj = $db->fetch_object($result_sql);
+ $numdirectdebitopen = $obj->nb;
+ $totaldirectdebit = $obj->amount;
+ } else {
+ dol_print_error($db);
+ }
+ if ($numdirectdebitopen) {
+ $langs->load("withdrawals");
+ print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
+ }
+ }
+ print ' | ';
//$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
// Amount
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index ba7027b28ee..08a5d2f3c44 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -519,7 +519,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes
}
// Group by because we have a total
- $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef, f.date_lim_reglement';
+ $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
+ $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
+ $sql .= ' f.datef, f.date_lim_reglement';
// Sort invoices by date and serial number: the older one comes first
$sql .= ' ORDER BY f.datef ASC, f.ref ASC';
@@ -685,7 +687,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
print '';
- print ''.price($sign * $remaintopay).' | ';
+ print '';
+ print price($sign * $remaintopay);
+ if (!empty($conf->paymentbybanktransfer->enabled)) {
+ $numdirectdebitopen = 0;
+ $totaldirectdebit = 0;
+ $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid);
+ $sql .= " AND pfd.traite = 0";
+ $sql .= " AND pfd.ext_payment_id IS NULL";
+
+ $result_sql = $db->query($sql);
+ if ($result_sql) {
+ $obj = $db->fetch_object($result_sql);
+ $numdirectdebitopen = $obj->nb;
+ $totaldirectdebit = $obj->amount;
+ } else {
+ dol_print_error($db);
+ }
+ if ($numdirectdebitopen) {
+ $langs->load("withdrawals");
+ print img_warning($langs->trans("WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
+ }
+ }
+ print ' | ';
// Amount
print '';
diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang
index 7b18c1a0d70..68ac879c510 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -150,3 +150,5 @@ ModeWarning=Option for real mode was not set, we stop after this simulation
ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use.
ErrorICSmissing=Missing ICS in Bank account %s
TotalAmountOfdirectDebitOrderDiffersFromSumOfLines=Total amount of direct debit order differs from sum of lines
+WarningSomeDirectDebitOrdersAlreadyExists=Warning: There is already some pending Direct Debit orders (%s) requested for an amount of %s
+WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s
\ No newline at end of file
|