diff --git a/dev/resources/sepa/text.txt b/dev/resources/sepa/text.txt
index e6c05276be2..dbcfeded5a4 100644
--- a/dev/resources/sepa/text.txt
+++ b/dev/resources/sepa/text.txt
@@ -1,2 +1,8 @@
+Spec for credit transfer:
+https://docs.oracle.com/cd/E39124_01/doc.91/e60210/fields_sepa_pay_file_appx.htm#EOAEL00515
+
+To validate a SEPA file:
+xmllint --schema pain.001.001.03.xsd T200801.xml --noout
+
To test a SEPA file:
https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa
diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php
index b082b7eb170..2e256f3c5ad 100644
--- a/htdocs/admin/modulehelp.php
+++ b/htdocs/admin/modulehelp.php
@@ -262,7 +262,7 @@ print '
';
$picto = 'object_'.$objMod->picto;
-print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto);
+print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto, 0, '', 'titlemodulehelp');
print '
';
dol_fiche_head($head, $mode, '', -1);
diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php
index f7ceb13e874..c0a52337a25 100644
--- a/htdocs/admin/system/database-tables.php
+++ b/htdocs/admin/system/database-tables.php
@@ -28,21 +28,27 @@ require '../../main.inc.php';
$langs->load("admin");
-if (!$user->admin)
+if (!$user->admin) {
accessforbidden();
+}
$action = GETPOST('action', 'alpha');
if ($action == 'convert')
{
- $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
+ $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
$db->query($sql);
}
if ($action == 'convertutf8')
{
- $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
- $db->query($sql);
+ $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
+ $db->query($sql);
+}
+if ($action == 'convertdynamic')
+{
+ $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ROW_FORMAT=DYNAMIC;";
+ $db->query($sql);
}
@@ -82,8 +88,8 @@ if (!$base)
} else {
if ($base == 1)
{
- print '
';
- print '
';
+ print '';
+ print '
';
print '';
print '| '.$langs->trans("TableName").' | ';
print ''.$langs->trans("Type").' | ';
@@ -112,13 +118,17 @@ if (!$base)
print ''.$obj->Name.' | ';
print ''.$obj->Engine.' | ';
- if (isset($obj->Engine) && $obj->Engine == "MyISAM")
- {
+ if (isset($obj->Engine) && $obj->Engine == "MyISAM") {
print ''.$langs->trans("Convert").' InnoDb | ';
} else {
print ' | ';
}
- print ''.$obj->Row_format.' | ';
+ print '';
+ print $obj->Row_format;
+ if (isset($obj->Row_format) && (in_array($obj->Row_format, array("Compact")))) {
+ print ' '.$langs->trans("Convert").' Dynamic';
+ }
+ print ' | ';
print ''.$obj->Rows.' | ';
print ''.$obj->Avg_row_length.' | ';
print ''.$obj->Data_length.' | ';
@@ -127,9 +137,8 @@ if (!$base)
print ''.$obj->Auto_increment.' | ';
print ''.$obj->Check_time.' | ';
print ''.$obj->Collation;
- if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "utf8mb4_unicode_ci", "latin1_swedish_ci"))))
- {
- print ' '.$langs->trans("Convert").' UTF8';
+ if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "utf8mb4_unicode_ci", "latin1_swedish_ci")))) {
+ print ' '.$langs->trans("Convert").' UTF8';
}
print ' | ';
print '
';
@@ -142,8 +151,8 @@ if (!$base)
if ($base == 2)
{
- print '';
- print '
';
+ print '';
+ print '
';
print '';
print '| '.$langs->trans("TableName").' | ';
print 'Nb of tuples | ';
@@ -182,8 +191,8 @@ if (!$base)
if ($base == 4)
{
// Sqlite by PDO or by Sqlite3
- print '';
- print '
';
+ print '';
+ print '
';
print '';
print '| '.$langs->trans("TableName").' | ';
print ''.$langs->trans("NbOfRecord").' | ';
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 1ac0926792e..b64a7bb1381 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1081,7 +1081,7 @@ class BonPrelevement extends CommonObject
if (!$error)
{
/*
- * Create file of direct debit order or credit transfer into a XML file
+ * Create file of type='direct-debit' for direct debit order or type='bank-transfer' for credit transfer into a XML file
*/
dol_syslog(__METHOD__."::Init direct debit or credit transfer file for ".count($factures_prev)." invoices", LOG_DEBUG);
@@ -1399,7 +1399,7 @@ class BonPrelevement extends CommonObject
*
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute transfer
- * @param string $type 'direct-debit' or 'credit-transfer'
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return int >=0 if OK, <0 if KO
*/
public function generate($format = 'ALL', $executiondate = '', $type = 'direct-debit')
@@ -1427,112 +1427,9 @@ class BonPrelevement extends CommonObject
{
$found++;
- if ($type == 'bank-transfer') {
+ if ($type != 'bank-transfer') {
/**
- * SECTION CREATION FICHIER SEPA - CREDIT TRANSFER
- */
- // SEPA Initialisation
- $CrLf = "\n";
-
- $now = dol_now();
-
- $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
-
- $date_actu = $now;
- if (!empty($executiondate)) $date_actu = $executiondate;
-
- $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
- $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
- $fileCrediteurSection = '';
- $fileEmetteurSection = '';
- $i = 0;
-
- /*
- * Section Creditor (sepa Crediteurs bloc lines)
- */
-
- $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
- $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
- $sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
- $sql .= " FROM";
- $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
- $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
- $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,";
- $sql .= " ".MAIN_DB_PREFIX."societe as soc,";
- $sql .= " ".MAIN_DB_PREFIX."c_country as c,";
- $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
- $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
- $sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
- $sql .= " AND pf.fk_facture_fourn = f.rowid";
- $sql .= " AND soc.fk_pays = c.rowid";
- $sql .= " AND soc.rowid = f.fk_soc";
- $sql .= " AND rib.fk_soc = f.fk_soc";
- $sql .= " AND rib.default_rib = 1";
- $sql .= " AND rib.type = 'ban'";
- //print $sql;
-
- // Define $fileCrediteurSection. One section DrctDbtTxInf per invoice.
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
- $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
- $this->total = $this->total + $obj->somme;
- $i++;
- }
- $nbtotalDrctDbtTxInf = $i;
- } else {
- fputs($this->file, 'ERROR CREDITOR '.$sql.$CrLf); // CREDITORS = Suppliers
- $result = -2;
- }
-
- // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
- if ($result != -2)
- {
- $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
- }
-
- /**
- * SECTION CREATION SEPA FILE - CREDTI TRANSFER - ISO200022
- */
- // SEPA File Header
- fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
- fputs($this->file, ''.$CrLf);
- fputs($this->file, ' '.$CrLf);
- // SEPA Group header
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.('CREDTRANS'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf);
- fputs($this->file, ' '.$dateTime_ECMA.''.$CrLf);
- fputs($this->file, ' '.$i.''.$CrLf);
- fputs($this->file, ' '.$this->total.''.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.''.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- // SEPA File Emetteur (mycompany)
- if ($result != -2)
- { fputs($this-> file, $fileEmetteurSection); }
- // SEPA File Creditors
- if ($result != -2)
- { fputs($this-> file, $fileCrediteurSection); }
- // SEPA FILE FOOTER
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.$CrLf);
- fputs($this->file, ''.$CrLf);
- } else {
- /**
- * SECTION CREATION FICHIER SEPA
+ * SECTION CREATION FICHIER SEPA - DIRECT DEBIT
*/
// SEPA Initialisation
$CrLf = "\n";
@@ -1583,7 +1480,7 @@ class BonPrelevement extends CommonObject
{
$obj = $this->db->fetch_object($resql);
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
- $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
+ $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type);
$this->total = $this->total + $obj->somme;
$i++;
}
@@ -1596,7 +1493,7 @@ class BonPrelevement extends CommonObject
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
if ($result != -2)
{
- $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
+ $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
}
/**
@@ -1608,7 +1505,7 @@ class BonPrelevement extends CommonObject
fputs($this->file, ' '.$CrLf);
// SEPA Group header
fputs($this->file, ' '.$CrLf);
- fputs($this->file, ' '.('PREL'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf);
+ fputs($this->file, ' '.('DD/'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf);
fputs($this->file, ' '.$dateTime_ECMA.''.$CrLf);
fputs($this->file, ' '.$i.''.$CrLf);
fputs($this->file, ' '.$this->total.''.$CrLf);
@@ -1633,21 +1530,126 @@ class BonPrelevement extends CommonObject
fputs($this->file, ' '.$CrLf);
fputs($this->file, ' '.$CrLf);
fputs($this->file, ''.$CrLf);
+ } else {
+ /**
+ * SECTION CREATION FICHIER SEPA - CREDIT TRANSFER
+ */
+ // SEPA Initialisation
+ $CrLf = "\n";
+
+ $now = dol_now();
+
+ $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
+
+ $date_actu = $now;
+ if (!empty($executiondate)) $date_actu = $executiondate;
+
+ $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
+ $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
+ $fileCrediteurSection = '';
+ $fileEmetteurSection = '';
+ $i = 0;
+
+ /*
+ * Section Creditor (sepa Crediteurs bloc lines)
+ */
+
+ $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
+ $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
+ $sql .= " f.ref as fac, pf.fk_facture_fourn as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
+ $sql .= " FROM";
+ $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
+ $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
+ $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,";
+ $sql .= " ".MAIN_DB_PREFIX."societe as soc,";
+ $sql .= " ".MAIN_DB_PREFIX."c_country as c,";
+ $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
+ $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
+ $sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
+ $sql .= " AND pf.fk_facture_fourn = f.rowid";
+ $sql .= " AND soc.fk_pays = c.rowid";
+ $sql .= " AND soc.rowid = f.fk_soc";
+ $sql .= " AND rib.fk_soc = f.fk_soc";
+ $sql .= " AND rib.default_rib = 1";
+ $sql .= " AND rib.type = 'ban'";
+ //print $sql;
+
+ // Define $fileCrediteurSection. One section DrctDbtTxInf per invoice.
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
+ $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type);
+ $this->total = $this->total + $obj->somme;
+ $i++;
+ }
+ $nbtotalDrctDbtTxInf = $i;
+ }
+ else
+ {
+ fputs($this->file, 'ERROR CREDITOR '.$sql.$CrLf); // CREDITORS = Suppliers
+ $result = -2;
+ }
+
+ // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
+ if ($result != -2)
+ {
+ $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
+ }
+
+ /**
+ * SECTION CREATION SEPA FILE - CREDIT TRANSFER - ISO200022
+ */
+ // SEPA File Header
+ fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
+ fputs($this->file, ''.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ // SEPA Group header
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.('TRF/'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf);
+ fputs($this->file, ' '.$dateTime_ECMA.''.$CrLf);
+ fputs($this->file, ' '.$i.''.$CrLf);
+ fputs($this->file, ' '.$this->total.''.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.''.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ // SEPA File Emetteur (mycompany)
+ if ($result != -2)
+ { fputs($this-> file, $fileEmetteurSection); }
+ // SEPA File Creditors
+ if ($result != -2)
+ { fputs($this-> file, $fileCrediteurSection); }
+ // SEPA FILE FOOTER
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ''.$CrLf);
}
}
// Build file for Other Countries with unknow format
if (!$found)
{
- if ($type == 'bank-transfer') {
+ if ($type != 'bank-transfer') {
$sql = "SELECT pl.amount";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
- $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
+ $sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
- $sql .= " AND pf.fk_facture_fourn = f.rowid";
+ $sql .= " AND pf.fk_facture = f.rowid";
// Lines
$i = 0;
@@ -1671,11 +1673,11 @@ class BonPrelevement extends CommonObject
$sql = "SELECT pl.amount";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
- $sql .= " ".MAIN_DB_PREFIX."facture as f,";
+ $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
- $sql .= " AND pf.fk_facture = f.rowid";
+ $sql .= " AND pf.fk_facture_fourn = f.rowid";
// Lines
$i = 0;
@@ -1712,6 +1714,22 @@ class BonPrelevement extends CommonObject
}
+ /**
+ * Generate dynamically a RUM number for a customer bank account
+ *
+ * @param string $row_code_client Customer code (soc.code_client)
+ * @param int $row_datec Creation date of bank account (rib.datec)
+ * @param string $row_drum Id of customer bank account (rib.rowid)
+ * @return string RUM number
+ */
+ public static function buildRumNumber($row_code_client, $row_datec, $row_drum)
+ {
+ global $langs;
+ $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation)
+ return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
+ }
+
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Write recipient of request (customer)
@@ -1725,9 +1743,11 @@ class BonPrelevement extends CommonObject
* @param string $ref ref of invoice
* @param int $facid id of invoice
* @param string $rib_dom rib domiciliation
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return void
+ * @see EnregDestinataireSEPA()
*/
- public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '')
+ public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '', $type = 'direct-debit')
{
// phpcs:enable
fputs($this->file, "06");
@@ -1784,22 +1804,6 @@ class BonPrelevement extends CommonObject
fputs($this->file, "\n");
}
-
- /**
- * Build RUM number for a customer bank account
- *
- * @param string $row_code_client Customer code (soc.code_client)
- * @param int $row_datec Creation date of bank account (rib.datec)
- * @param string $row_drum Id of customer bank account (rib.rowid)
- * @return string RUM number
- */
- public static function buildRumNumber($row_code_client, $row_datec, $row_drum)
- {
- global $langs;
- $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation)
- return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
- }
-
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Write recipient of request (customer)
@@ -1821,9 +1825,11 @@ class BonPrelevement extends CommonObject
* @param string $row_datec rib.datec,
* @param string $row_drum rib.rowid used to generate rum
* @param string $row_rum rib.rum Rum defined on company bank account
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return string Return string with SEPA part DrctDbtTxInf
+ * @see EnregDestinataire()
*/
- public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum)
+ public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum, $type = 'direct-debit')
{
// phpcs:enable
global $conf;
@@ -1831,7 +1837,7 @@ class BonPrelevement extends CommonObject
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$CrLf = "\n";
- $Rowing = sprintf("%06d", $row_idfac);
+ $Rowing = sprintf("%010d", $row_idfac);
// Define value for RUM
// Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId)
@@ -1840,57 +1846,108 @@ class BonPrelevement extends CommonObject
// Define date of RUM signature
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
- $XML_DEBITOR = '';
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
- $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$Rum.''.$CrLf;
- $XML_DEBITOR .= ' '.$DtOfSgntr.''.$CrLf;
- $XML_DEBITOR .= ' false'.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$row_bic.''.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf;
- $addressline1 = dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")));
- $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")));
- if (trim($addressline1)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf;
- if (trim($addressline2)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', true)).''.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.preg_replace('/\s/', '', $row_iban).''.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf;
- // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max
- $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max
- $XML_DEBITOR .= ' '.$CrLf;
- $XML_DEBITOR .= ' '.$CrLf;
- return $XML_DEBITOR;
+ if ($type != 'bank-transfer') {
+ // SEPA Paiement Information of buyer for Direct debit
+ $XML_DEBITOR = '';
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
+ $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$Rum.''.$CrLf;
+ $XML_DEBITOR .= ' '.$DtOfSgntr.''.$CrLf;
+ $XML_DEBITOR .= ' false'.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$row_bic.''.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf;
+ $addressline1 = dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")));
+ $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")));
+ if (trim($addressline1)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf;
+ if (trim($addressline2)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', true)).''.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.preg_replace('/\s/', '', $row_iban).''.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ // A string with some information on payment - 140 max
+ $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max
+ $XML_DEBITOR .= ' '.$CrLf;
+ $XML_DEBITOR .= ' '.$CrLf;
+ return $XML_DEBITOR;
+ } else {
+ // SEPA Paiement Information of seller for Credit Transfer
+ $XML_CREDITOR = '';
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
+ $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.round($row_somme, 2).''.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ /*
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$Rum.''.$CrLf;
+ $XML_CREDITOR .= ' '.$DtOfSgntr.''.$CrLf;
+ $XML_CREDITOR .= ' false'.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ */
+ //$XML_CREDITOR .= ' SLEV'.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$row_bic.''.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf;
+ $addressline1 = dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")));
+ $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")));
+ if (trim($addressline1)) $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf;
+ if (trim($addressline2)) $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', true)).''.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.preg_replace('/\s/', '', $row_iban).''.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ // A string with some information on payment - 140 max
+ $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max
+ $XML_CREDITOR .= ' '.$CrLf;
+ $XML_CREDITOR .= ' '.$CrLf;
+ return $XML_CREDITOR;
+ }
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Write sender of request (me)
+ * Write sender of request (me).
*
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return void
+ * @see EnregEmetteurSEPA()
*/
- public function EnregEmetteur()
+ public function EnregEmetteur($type = 'direct-debit')
{
// phpcs:enable
fputs($this->file, "03");
@@ -1962,9 +2019,11 @@ class BonPrelevement extends CommonObject
* @param float $total Total
* @param string $CrLf End of line character
* @param string $format FRST or RCUR or ALL
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return string String with SEPA Sender
+ * @see EnregEmetteur()
*/
- public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST')
+ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST', $type = 'direct-debit')
{
// phpcs:enable
// SEPA INITIALISATION
@@ -1991,7 +2050,7 @@ class BonPrelevement extends CommonObject
$this->raison_sociale = $account->proprio;
}
- // Récupération info demandeur
+ // Get pending payments
$sql = "SELECT rowid, ref";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_bons as pb";
@@ -2002,70 +2061,135 @@ class BonPrelevement extends CommonObject
{
$obj = $this->db->fetch_object($resql);
- // DONNEES BRUTES : par la suite Rows['XXX'] de la requete au dessus
$country = explode(':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY);
$IdBon = sprintf("%05d", $obj->rowid);
$RefBon = $obj->ref;
- // SEPA Paiement Information
- $XML_SEPA_INFO = '';
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.('PREL'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).''.$CrLf;
- $XML_SEPA_INFO .= ' DD'.$CrLf;
- $XML_SEPA_INFO .= ' '.$nombre.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$total.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' SEPA'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' CORE'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$format.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
- $addressline1 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")));
- $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")));
- if ($addressline1) $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf;
- if ($addressline2) $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $this->emetteur_iban).''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- /* $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
- $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;*/
- $XML_SEPA_INFO .= ' SLEV'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$this->emetteur_ics.''.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' SEPA'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- } else {
+ if ($type != 'bank-transfer') {
+ // SEPA Paiement Information of my company for Direct debit
+ $XML_SEPA_INFO = '';
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).''.$CrLf;
+ $XML_SEPA_INFO .= ' DD'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$nombre.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$total.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' SEPA'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' CORE'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$format.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
+ $addressline1 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")));
+ $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")));
+ if ($addressline1) $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf;
+ if ($addressline2) $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $this->emetteur_iban).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ /* $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;*/
+ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_ics.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' SEPA'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ } else {
+ // SEPA Paiement Information of my company for Credit Transfer
+ $XML_SEPA_INFO = '';
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.('TRF/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).''.$CrLf;
+ $XML_SEPA_INFO .= ' TRF'.$CrLf;
+ //$XML_SEPA_INFO .= ' False'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$nombre.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$total.''.$CrLf;
+ /*
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' SEPA'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' TRF'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' SECU'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ */
+ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
+ $addressline1 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")));
+ $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")));
+ if ($addressline1) $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf;
+ if ($addressline2) $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $this->emetteur_iban).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ /* $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;*/
+ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV
+ /*$XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_ics.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' SEPA'.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;
+ $XML_SEPA_INFO .= ' '.$CrLf;*/
+ }
+ }
+ else
+ {
fputs($this->file, 'INCORRECT EMETTEUR '.$XML_SEPA_INFO.$CrLf);
$result = -2;
}
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index 0be8dfc9e52..1de83c99761 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -370,10 +370,15 @@ if ($resql)
// RUM
print '';
- print $thirdpartystatic->display_rib('rum');
- $format = $thirdpartystatic->display_rib('format');
- if ($type != 'bank-transfer') {
- if ($format) print ' ('.$format.')';
+ $rumtoshow = $thirdpartystatic->display_rib('rum');
+ if ($rumtoshow) {
+ print $rumtoshow;
+ $format = $thirdpartystatic->display_rib('format');
+ if ($type != 'bank-transfer') {
+ if ($format) print ' ('.$format.')';
+ }
+ } else {
+ print img_warning($langs->trans("NoBankAccount"));
}
print ' | ';
// Amount
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c15c074a351..0d0a81a5192 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -5311,11 +5311,12 @@ abstract class CommonObject
$new_array_options[$key] = null;
}
break;
- case 'double':
+ case 'price':
+ case 'double':
$value = price2num($value);
if (!is_numeric($value) && $value != '')
{
- dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
+ dol_syslog($langs->trans("ExtraFieldHasWrongValue")." for ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
} elseif ($value == '')
@@ -5363,9 +5364,6 @@ abstract class CommonObject
$new_array_options[$key] = $this->array_options[$key];
}
break;
- case 'price':
- $new_array_options[$key] = price2num($this->array_options[$key]);
- break;
case 'date':
case 'datetime':
// If data is a string instead of a timestamp, we convert it
@@ -5457,7 +5455,7 @@ abstract class CommonObject
{
if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
- if (in_array($tmpval, array('int', 'double'))) $sql .= ", 0";
+ if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0";
else $sql .= ", ''";
}
}
@@ -6733,7 +6731,7 @@ abstract class CommonObject
if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0)
{
$out .= "\n";
- $out .= ' ';
+ $out .= ' ';
$out .= "\n";
$extrafields_collapse_num = '';
@@ -6867,7 +6865,7 @@ abstract class CommonObject
// HTML, select, integer and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'select', 'int')))
{
- if ($action == 'create') $value = $extrafields->attributes[$this->table_element]['default'][$key];
+ if ($action == 'create') $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ? GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none', 3) : $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
}
@@ -6953,7 +6951,7 @@ abstract class CommonObject
'."\n";
}
- $out .= ' '."\n";
+ $out .= ' '."\n";
}
}
@@ -7613,6 +7611,7 @@ abstract class CommonObject
$now = dol_now();
$fieldvalues = $this->setSaveQuery();
+
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index c37a7cfc6ab..549c82a9033 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -539,7 +539,10 @@ class Translate
{
global $conf, $db;
- if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
+ if (!is_string($key)) {
+ //xdebug_print_function_stack('ErrorBadValueForParamNotAString');
+ return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
+ }
$newstr = $key;
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg))
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 1b6c1acf77d..ac552faff5c 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -546,9 +546,9 @@ Module54Desc=Management of contracts (services or recurring subscriptions)
Module55Name=Barcodes
Module55Desc=Barcode management
Module56Name=Payment by credit transfer
-Module56Desc=Management of payment of suppliers by credit transfer orders. It includes generation of SEPA file for European countries.
-Module57Name=Bank Direct Debit payments
-Module57Desc=Management of Direct Debit payment orders. It includes generation of SEPA file for European countries.
+Module56Desc=Management of payment of suppliers by Credit Transfer orders. It includes generation of SEPA file for European countries.
+Module57Name=Payments by Direct Debit
+Module57Desc=Management of Direct Debit orders. It includes generation of SEPA file for European countries.
Module58Name=ClickToDial
Module58Desc=Integration of a ClickToDial system (Asterisk, ...)
Module59Name=Bookmark4u
diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang
index 35654186b71..6cb4796acd6 100644
--- a/htdocs/langs/fr_FR/withdrawals.lang
+++ b/htdocs/langs/fr_FR/withdrawals.lang
@@ -77,7 +77,7 @@ StatusMotif8=Autre motif
CreateForSepaFRST=Créer fichier de prélèvement (SEPA FRST)
CreateForSepaRCUR=Créer fichier de prélèvement (SEPA RCUR)
CreateAll=Créer le fichier de prélèvement (tout)
-CreateFileForPaymentByBankTransfer=Créer fichier pour les virements (tous)
+CreateFileForPaymentByBankTransfer=Créer un fichier de virement
CreateSepaFileForPaymentByBankTransfer=Créer un fichier de virement (SEPA)
CreateGuichet=Seulement guichet
CreateBanque=Seulement banque
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index bf28eda4edf..e3331fcec74 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -178,12 +178,12 @@ if (empty($reshook))
if ($result < 0)
{
$langs->load("errors");
- setEventMessages($langs->trans($object->error), null, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else {
$langs->load("errors");
- setEventMessages($langs->trans($object->error), null, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
if (!$error && !empty($object->id) > 0)
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 980b1d250a0..f65daf470e8 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2742,7 +2742,7 @@ class Societe extends CommonObject
* Return bank number property of thirdparty (label or rum)
*
* @param string $mode 'label' or 'rum' or 'format'
- * @return string Bank number
+ * @return string Bank label or RUM or '' if no bank account found
*/
public function display_rib($mode = 'label')
{
@@ -2752,25 +2752,25 @@ class Societe extends CommonObject
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0, $this->id);
- if ($mode == 'label')
- {
- return $bac->getRibLabel(true);
- } elseif ($mode == 'rum')
- {
- if (empty($bac->rum))
- {
- require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
- $prelevement = new BonPrelevement($this->db);
- $bac->fetch_thirdparty();
- $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
+ if ($bac->id > 0) { // If a bank account has been found for company $this->id
+ if ($mode == 'label') {
+ return $bac->getRibLabel(true);
+ } elseif ($mode == 'rum') {
+ if (empty($bac->rum)) {
+ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
+ $prelevement = new BonPrelevement($this->db);
+ $bac->fetch_thirdparty();
+ $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
+ }
+ return $bac->rum;
+ } elseif ($mode == 'format') {
+ return $bac->frstrecur;
+ } else {
+ return 'BadParameterToFunctionDisplayRib';
}
- return $bac->rum;
- } elseif ($mode == 'format')
- {
- return $bac->frstrecur;
+ } else {
+ return '';
}
-
- return 'BadParameterToFunctionDisplayRib';
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index cfa811b232f..67702d93ee6 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -3987,7 +3987,8 @@ div.boximport {
.fieldrequired { font-weight: bold; color: var(--fieldrequiredcolor); }
td.widthpictotitle { width: 26px; text-align: ; }
-span.widthpictotitle { font-size: 1.7em; };
+span.widthpictotitle { font-size: 1.7em; }
+table.titlemodulehelp tr td img.widthpictotitle { width: 80px; }
.dolgraphtitle { margin-top: 6px; margin-bottom: 4px; }
.dolgraphtitlecssboxes { /* margin: 0px; */ }
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 6c20f4d66c1..fb9f0239d10 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -3862,6 +3862,7 @@ div.boximport {
.fieldrequired { font-weight: bold; color: #000055; }
.widthpictotitle { width: 40px; font-size: 1.4em; text-align: ; }
+table.titlemodulehelp tr td img.widthpictotitle { width: 80px; }
.dolgraphtitle { margin-top: 6px; margin-bottom: 4px; }
.dolgraphtitlecssboxes { /* margin: 0px; */ }