diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index ca6a2e8d589..07e4abb0197 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1389,6 +1389,8 @@ class Account extends CommonObject
$label = ''.$langs->trans("BankAccount").'';
$label .= '
'.$langs->trans('Label').': '.$this->label;
$label .= '
'.$langs->trans('AccountNumber').': '.$this->number;
+ $label .= '
'.$langs->trans('IBAN').': '.$this->iban;
+ $label .= '
'.$langs->trans('BIC').': '.$this->bic;
$label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code;
if (empty($user->rights->banque->lire) || !empty($user->socid))
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 9a80ad91d24..8957da7b9db 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -4078,161 +4078,6 @@ class Facture extends CommonInvoice
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Create a withdrawal request for a direct debit order or a credit transfer order.
- * Use the remain to pay excluding all existing open direct debit requests.
- *
- * @param User $fuser User asking the direct debit transfer
- * @param float $amount Amount we request direct debit for
- * @param string $type 'direct-debit' or 'bank-transfer'
- * @param string $sourcetype Source ('facture' or 'supplier_invoice')
- * @return int <0 if KO, >0 if OK
- */
- public function demande_prelevement($fuser, $amount = 0, $type = 'direct-debit', $sourcetype = 'facture')
- {
- // phpcs:enable
- global $conf;
-
- $error = 0;
-
- dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
-
- if ($this->statut > self::STATUS_DRAFT && $this->paye == 0)
- {
- require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
- $bac = new CompanyBankAccount($this->db);
- $bac->fetch(0, $this->socid);
-
- $sql = 'SELECT count(*)';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
- if ($type == 'bank-transfer') {
- $sql .= ' WHERE fk_facture_fourn = '.$this->id;
- } else {
- $sql .= ' WHERE fk_facture = '.$this->id;
- }
- $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments
- $sql .= ' AND traite = 0';
-
- dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $row = $this->db->fetch_row($resql);
- if ($row[0] == 0)
- {
- $now = dol_now();
-
- $totalpaye = $this->getSommePaiement();
- $totalcreditnotes = $this->getSumCreditNotesUsed();
- $totaldeposits = $this->getSumDepositsUsed();
- //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
-
- // We can also use bcadd to avoid pb with floating points
- // For example print 239.2 - 229.3 - 9.9; does not return 0.
- //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
- //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
- if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
-
- if (is_numeric($amount) && $amount != 0)
- {
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande(';
- if ($type == 'bank-transfer') {
- $sql .= 'fk_facture_fourn, ';
- } else {
- $sql .= 'fk_facture, ';
- }
- $sql .= ' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, entity)';
- $sql .= ' VALUES ('.$this->id;
- $sql .= ",'".price2num($amount)."'";
- $sql .= ",'".$this->db->idate($now)."'";
- $sql .= ",".$fuser->id;
- $sql .= ",'".$this->db->escape($bac->code_banque)."'";
- $sql .= ",'".$this->db->escape($bac->code_guichet)."'";
- $sql .= ",'".$this->db->escape($bac->number)."'";
- $sql .= ",'".$this->db->escape($bac->cle_rib)."'";
- $sql .= ",'".$this->db->escape($sourcetype)."'";
- $sql .= ",".$conf->entity;
- $sql .= ")";
-
- dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->error = $this->db->lasterror();
- dol_syslog(get_class($this).'::demandeprelevement Erreur');
- $error++;
- }
- }
- else
- {
- $this->error = 'WithdrawRequestErrorNilAmount';
- dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount');
- $error++;
- }
-
- if (!$error)
- {
- // Force payment mode of invoice to withdraw
- $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1);
- if ($payment_mode_id > 0)
- {
- $result = $this->setPaymentMethods($payment_mode_id);
- }
- }
-
- if ($error) return -1;
- return 1;
- }
- else
- {
- $this->error = "A request already exists";
- dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours');
- return 0;
- }
- }
- else
- {
- $this->error = $this->db->error();
- dol_syslog(get_class($this).'::demandeprelevement Erreur -2');
- return -2;
- }
- }
- else
- {
- $this->error = "Status of invoice does not allow this";
- dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id");
- return -3;
- }
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Supprime une demande de prelevement
- *
- * @param User $fuser User making delete
- * @param int $did id de la demande a supprimer
- * @return int <0 if OK, >0 if KO
- */
- public function demande_prelevement_delete($fuser, $did)
- {
- // phpcs:enable
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
- $sql .= ' WHERE rowid = '.$did;
- $sql .= ' AND traite = 0';
- if ($this->db->query($sql))
- {
- return 0;
- }
- else
- {
- $this->error = $this->db->lasterror();
- dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error);
- return -1;
- }
- }
-
-
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index 2b181e52078..dd9c1394563 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -114,12 +114,12 @@ if (empty($reshook))
if ($action == "delete")
{
- if ($object->id > 0)
+ if ($object->id > 0)
{
$result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
if ($result == 0)
{
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&mode='.$mode);
exit;
}
}
@@ -487,13 +487,21 @@ if ($object->id > 0)
print "";
print '';
- print '