30 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
48 public $element =
'widthdraw';
53 public $table_element =
'prelevement_bons';
58 public $picto =
'payment';
60 public $date_echeance;
61 public $raison_sociale;
62 public $reference_remise;
63 public $emetteur_code_guichet;
64 public $emetteur_numero_compte;
65 public $emetteur_code_banque;
66 public $emetteur_number_key;
67 public $sepa_xml_pti_in_ctti;
69 public $emetteur_iban;
80 public $labelStatus = array();
82 public $factures = array();
84 public $invoice_in_error = array();
85 public $thirdparty_in_error = array();
96 const STATUS_DRAFT = 0;
97 const STATUS_TRANSFERED = 1;
98 const STATUS_CREDITED = 2;
99 const STATUS_DEBITED = 2;
109 global $conf, $langs;
113 $this->filename =
'';
115 $this->date_echeance =
dol_now();
116 $this->raison_sociale =
"";
117 $this->reference_remise =
"";
119 $this->emetteur_code_guichet =
"";
120 $this->emetteur_numero_compte =
"";
121 $this->emetteur_code_banque =
"";
122 $this->emetteur_number_key =
"";
123 $this->sepa_xml_pti_in_ctti =
false;
125 $this->emetteur_iban =
"";
126 $this->emetteur_bic =
"";
127 $this->emetteur_ics =
"";
129 $this->factures = array();
131 $this->methodes_trans = array();
133 $this->methodes_trans[0] =
"Internet";
153 public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type =
'debit-order')
160 $result = $this->
addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key);
164 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement (";
165 if ($type !=
'bank-transfer') {
166 $sql .=
"fk_facture";
168 $sql .=
"fk_facture_fourn";
170 $sql .=
",fk_prelevement_lignes";
171 $sql .=
") VALUES (";
172 $sql .= ((int) $invoice_id);
173 $sql .=
", ".((int) $line_id);
176 if ($this->
db->query($sql)) {
180 $this->errors[] = get_class($this).
"::AddFacture ".$this->
db->lasterror;
181 dol_syslog(get_class($this).
"::AddFacture Error $result");
185 $this->errors[] = get_class($this).
"::AddFacture linedid Empty";
186 dol_syslog(get_class($this).
"::AddFacture Error $result");
190 dol_syslog(get_class($this).
"::AddFacture Error $result");
209 public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
218 $sql =
"SELECT rowid";
219 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes";
220 $sql .=
" WHERE fk_prelevement_bons = ".((int) $this->
id);
221 $sql .=
" AND fk_soc =".((int) $client_id);
222 $sql .=
" AND code_banque = '".$this->db->escape($code_banque).
"'";
223 $sql .=
" AND code_guichet = '".$this->db->escape($code_guichet).
"'";
224 $sql .=
" AND number = '".$this->db->escape($number).
"'";
236 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_lignes (";
237 $sql .=
"fk_prelevement_bons";
239 $sql .=
", client_nom";
241 $sql .=
", code_banque";
242 $sql .=
", code_guichet";
245 $sql .=
") VALUES (";
247 $sql .=
", ".((int) $client_id);
248 $sql .=
", '".$this->db->escape($client_nom).
"'";
249 $sql .=
", ".((float)
price2num($amount));
250 $sql .=
", '".$this->db->escape($code_banque).
"'";
251 $sql .=
", '".$this->db->escape($code_guichet).
"'";
252 $sql .=
", '".$this->db->escape($number).
"'";
253 $sql .=
", '".$this->db->escape($number_key).
"'";
256 if ($this->
db->query($sql)) {
257 $line_id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"prelevement_lignes");
260 $this->errors[] = get_class($this).
"::addline Error -2 ".$this->
db->lasterror;
261 dol_syslog(get_class($this).
"::addline Error -2");
281 $errors[1027] = $langs->trans(
"DateInvalid");
283 return $errors[abs($error)];
293 public function fetch($rowid, $ref =
'')
297 $sql =
"SELECT p.rowid, p.ref, p.amount, p.note";
298 $sql .=
", p.datec as dc";
299 $sql .=
", p.date_trans as date_trans";
300 $sql .=
", p.method_trans, p.fk_user_trans";
301 $sql .=
", p.date_credit as date_credit";
302 $sql .=
", p.fk_user_credit";
304 $sql .=
", p.statut as status";
305 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
306 $sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
308 $sql .=
" AND p.rowid = ".((int) $rowid);
310 $sql .=
" AND p.ref = '".$this->db->escape($ref).
"'";
313 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
314 $result = $this->
db->query($sql);
316 if ($this->
db->num_rows($result)) {
317 $obj = $this->
db->fetch_object($result);
319 $this->
id = $obj->rowid;
320 $this->
ref = $obj->ref;
321 $this->amount = $obj->amount;
322 $this->note = $obj->note;
323 $this->datec = $this->
db->jdate($obj->dc);
325 $this->date_trans = $this->
db->jdate($obj->date_trans);
326 $this->method_trans = $obj->method_trans;
327 $this->user_trans = $obj->fk_user_trans;
329 $this->date_credit = $this->
db->jdate($obj->date_credit);
330 $this->user_credit = $obj->fk_user_credit;
332 $this->
type = $obj->type;
334 $this->status = $obj->status;
335 $this->statut = $obj->status;
341 dol_syslog(get_class($this).
"::Fetch Erreur aucune ligne retournee");
360 global $conf, $langs;
364 if ($this->fetched == 1) {
365 if ($date < $this->date_trans) {
366 $langs->load(
"errors");
367 $this->error = $langs->trans(
'ErrorDateOfMovementLowerThanDateOfFileTransmission');
368 dol_syslog(
"bon-prelevment::set_infocredit 1027 ".$this->error);
374 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons ";
375 $sql .=
" SET fk_user_credit = ".$user->id;
376 $sql .=
", statut = ".self::STATUS_CREDITED;
377 $sql .=
", date_credit = '".$this->db->idate($date).
"'";
378 $sql .=
" WHERE rowid=".((int) $this->
id);
379 $sql .=
" AND entity = ".((int) $conf->entity);
380 $sql .=
" AND statut = ".self::STATUS_TRANSFERED;
384 $langs->load(
'withdrawals');
385 $subject = $langs->trans(
"InfoCreditSubject", $this->
ref);
386 $message = $langs->trans(
"InfoCreditMessage", $this->
ref,
dol_print_date($date,
'dayhour'));
389 $bankaccount = ($this->
type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
392 $amountsperthirdparty = array();
398 for ($i = 0; $i < $num; $i++) {
399 if ($this->
type ==
'bank-transfer') {
405 $result = $fac->fetch($facs[$i][0]);
407 $amounts[$fac->id] = $facs[$i][1];
408 $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1];
410 $totalpaid = $fac->getSommePaiement();
411 $totalcreditnotes = $fac->getSumCreditNotesUsed();
412 $totaldeposits = $fac->getSumDepositsUsed();
413 $alreadypayed = $totalpaid + $totalcreditnotes + $totaldeposits;
416 if (
price2num($alreadypayed + $facs[$i][1],
'MT') == $fac->total_ttc) {
417 $result = $fac->setPaid($user);
419 $this->error = $fac->error;
420 $this->errors = $fac->errors;
427 foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) {
428 if ($this->
type ==
'bank-transfer') {
433 $paiement->datepaye = $date;
434 $paiement->amounts = $cursoramounts;
436 if ($this->
type ==
'bank-transfer') {
437 $paiement->paiementid = 2;
438 $paiement->paiementcode =
'VIR';
440 $paiement->paiementid = 3;
441 $paiement->paiementcode =
'PRE';
444 $paiement->num_payment = $this->ref;
445 $paiement->id_prelevement = $this->id;
447 $paiement_id = $paiement->create($user);
448 if ($paiement_id < 0) {
450 $this->error = $paiement->error;
451 $this->errors = $paiement->errors;
452 dol_syslog(get_class($this).
"::set_infocredit AddPayment Error ".$this->error);
454 if ($this->
type ==
'bank-transfer') {
455 $modeforaddpayment =
'payment_supplier';
457 $modeforaddpayment =
'payment';
460 $result = $paiement->addPaymentToBank($user, $modeforaddpayment,
'(WithdrawalPayment)', $bankaccount,
'',
'');
463 $this->error = $paiement->error;
464 $this->errors = $paiement->errors;
465 dol_syslog(get_class($this).
"::set_infocredit AddPaymentToBank Error ".$this->error);
473 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_lignes";
474 $sql .=
" SET statut = 2";
475 $sql .=
" WHERE fk_prelevement_bons = ".((int) $this->
id);
477 if (!$this->
db->query($sql)) {
478 dol_syslog(get_class($this).
"::set_infocredit Update lines Error");
483 $this->error = $this->
db->lasterror();
484 dol_syslog(get_class($this).
"::set_infocredit Update Bons Error");
492 $this->date_credit = $date;
493 $this->statut = self::STATUS_CREDITED;
498 $this->
db->rollback();
518 global $conf, $langs;
522 dol_syslog(get_class($this).
"::set_infotrans Start", LOG_INFO);
523 if ($this->
db->begin()) {
524 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons ";
525 $sql .=
" SET fk_user_trans = ".$user->id;
526 $sql .=
" , date_trans = '".$this->db->idate($date).
"'";
527 $sql .=
" , method_trans = ".((int) $method);
528 $sql .=
" , statut = ".self::STATUS_TRANSFERED;
529 $sql .=
" WHERE rowid = ".((int) $this->
id);
530 $sql .=
" AND entity = ".((int) $conf->entity);
531 $sql .=
" AND statut = 0";
533 if ($this->
db->query($sql)) {
534 $this->method_trans = $method;
535 $langs->load(
'withdrawals');
536 $subject = $langs->trans(
"InfoTransSubject", $this->
ref);
537 $message = $langs->trans(
"InfoTransMessage", $this->
ref,
dolGetFirstLastname($user->firstname, $user->lastname));
538 $message .= $langs->trans(
"InfoTransData",
price($this->amount), $this->methodes_trans[$this->method_trans],
dol_print_date($date,
'day'));
546 $this->date_trans = $date;
548 $this->user_trans = $user->id;
553 $this->
db->rollback();
554 dol_syslog(get_class($this).
"::set_infotrans ROLLBACK", LOG_ERR);
559 dol_syslog(get_class($this).
"::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT);
580 if ($this->
type ==
'bank-transfer') {
581 $sql .=
" pf.fk_facture_fourn";
583 $sql .=
" pf.fk_facture";
586 $sql .=
", SUM(pl.amount)";
588 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
589 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
590 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
591 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
592 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
593 $sql .=
" AND p.rowid = ".((int) $this->
id);
594 $sql .=
" AND p.entity = ".((int) $conf->entity);
596 if ($this->
type ==
'bank-transfer') {
597 $sql .=
" GROUP BY fk_facture_fourn";
599 $sql .=
" GROUP BY fk_facture";
610 $row = $this->
db->fetch_row(
$resql);
624 dol_syslog(get_class($this).
"::getListInvoices Erreur");
642 $sql =
"SELECT sum(pfd.amount) as nb";
643 if ($mode !=
'bank-transfer') {
644 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
646 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
648 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
649 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
650 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
651 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
653 if ($mode !=
'bank-transfer') {
654 $sql .=
" AND f.rowid = pfd.fk_facture";
656 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
658 $sql .=
" AND f.paye = 0";
659 $sql .=
" AND pfd.traite = 0";
660 $sql .=
" AND pfd.ext_payment_id IS NULL";
661 $sql .=
" AND f.total_ttc > 0";
665 $obj = $this->
db->fetch_object(
$resql);
672 dol_syslog(get_class($this).
"::SommeAPrelever Erreur -1");
702 $sql =
"SELECT count(f.rowid) as nb";
703 if ($type ==
'bank-transfer') {
704 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
706 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
708 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
709 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
710 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
711 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
713 if ($type ==
'bank-transfer') {
714 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
716 $sql .=
" AND f.rowid = pfd.fk_facture";
718 $sql .=
" AND pfd.traite = 0";
719 $sql .=
" AND pfd.ext_payment_id IS NULL";
720 $sql .=
" AND f.total_ttc > 0";
722 dol_syslog(get_class($this).
"::NbFactureAPrelever");
726 $obj = $this->
db->fetch_object(
$resql);
732 $this->error = get_class($this).
"::NbFactureAPrelever Erreur -1 sql=".$this->
db->error();
752 public function create($banque = 0, $agence = 0, $mode =
'real', $format =
'ALL', $executiondate =
'', $notrigger = 0, $type =
'direct-debit')
755 global $conf, $langs, $user;
757 dol_syslog(__METHOD__.
"::Bank=".$banque.
" Office=".$agence.
" mode=".$mode.
" format=".$format, LOG_DEBUG);
759 require_once DOL_DOCUMENT_ROOT.
"/compta/facture/class/facture.class.php";
760 require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
762 if ($type !=
'bank-transfer') {
763 if (empty($format)) {
764 $this->error =
'ErrorBadParametersForDirectDebitFileCreate';
771 $datetimeprev =
dol_now(
'gmt');
773 if (!empty($executiondate)) {
774 $datetimeprev = $executiondate;
780 $this->invoice_in_error = array();
781 $this->thirdparty_in_error = array();
785 $factures_prev = array();
786 $factures_result = array();
787 $factures_prev_id = array();
788 $factures_errors = array();
791 $sql =
"SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
792 $sql .=
", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib";
793 $sql .=
", pfd.amount";
794 $sql .=
", s.nom as name";
795 if ($type !=
'bank-transfer') {
796 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
798 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
800 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
801 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
802 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
803 if ($type !=
'bank-transfer') {
804 $sql .=
" AND f.rowid = pfd.fk_facture";
806 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
808 $sql .=
" AND s.rowid = f.fk_soc";
809 $sql .=
" AND f.fk_statut = 1";
810 $sql .=
" AND f.paye = 0";
811 $sql .=
" AND pfd.traite = 0";
812 $sql .=
" AND f.total_ttc > 0";
813 $sql .=
" AND pfd.ext_payment_id IS NULL";
815 dol_syslog(__METHOD__.
"::Read invoices,", LOG_DEBUG);
823 $row = $this->
db->fetch_row(
$resql);
824 $factures[$i] = $row;
827 dol_syslog(__METHOD__.
"::Read invoices error Found a null invoice", LOG_ERR);
828 $this->invoice_in_error[$row[0]] =
"Error for invoice id ".$row[0].
", found a null amount";
834 dol_syslog(__METHOD__.
"::Read invoices, ".$i.
" invoices to withdraw", LOG_DEBUG);
837 dol_syslog(__METHOD__.
"::Read invoices error ".$this->db->error(), LOG_ERR);
842 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
847 dol_syslog(__METHOD__.
"::Check BAN", LOG_DEBUG);
849 if (count($factures) > 0) {
850 foreach ($factures as $key => $fac) {
851 if ($type !=
'bank-transfer') {
856 $resfetch = $tmpinvoice->fetch($fac[0]);
857 if ($resfetch >= 0) {
858 if ($soc->fetch($tmpinvoice->socid) >= 0) {
860 $bac->fetch(0, $soc->id);
862 if ($type !=
'bank-transfer') {
863 if ($format ==
'FRST' && $bac->frstrecur !=
'FRST') {
866 if ($format ==
'RCUR' && ($bac->frstrecur !=
'RCUR' && $bac->frstrecur !=
'RECUR')) {
871 if ($bac->verif() >= 1) {
872 $factures_prev[$i] = $fac;
874 $factures_prev_id[$i] = $fac[0];
878 dol_syslog(__METHOD__.
"::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$tmpinvoice->socid.
" ".$soc->name, LOG_WARNING);
879 $this->invoice_in_error[$fac[0]] =
"Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0).
" for thirdparty ".$soc->getNomUrl(0);
880 $this->thirdparty_in_error[$soc->id] =
"Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0).
" for thirdparty ".$soc->getNomUrl(0);
883 dol_syslog(__METHOD__.
"::Check BAN Failed to read company", LOG_WARNING);
886 dol_syslog(__METHOD__.
"::Check BAN Failed to read invoice", LOG_WARNING);
890 dol_syslog(__METHOD__.
"::Check BAN No invoice to process", LOG_WARNING);
897 $out = count($factures_prev).
" invoices will be included.";
910 if (count($factures_prev) > 0) {
911 if ($mode ==
'real') {
914 print $langs->trans(
"ModeWarning");
932 $ref = substr($year, -2).$month;
934 $sql =
"SELECT substring(ref from char_length(ref) - 1)";
935 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons";
936 $sql .=
" WHERE ref LIKE '_".$this->db->escape($ref).
"%'";
937 $sql .=
" AND entity = ".((int) $conf->entity);
938 $sql .=
" ORDER BY ref DESC LIMIT 1";
940 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
944 $row = $this->
db->fetch_row(
$resql);
947 $ref =
"T".$ref.sprintf(
"%02d", (intval($row[0]) + 1));
953 if ($type !=
'bank-transfer') {
954 $dir = $conf->prelevement->dir_output.
'/receipts';
956 $dir = $conf->paymentbybanktransfer->dir_output.
'/receipts';
962 $this->filename = $dir.
'/'.$ref.
'.xml';
965 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_bons (";
966 $sql .=
"ref, entity, datec, type";
967 $sql .=
") VALUES (";
968 $sql .=
"'".$this->db->escape($ref).
"'";
969 $sql .=
", ".((int) $conf->entity);
970 $sql .=
", '".$this->db->idate($now).
"'";
971 $sql .=
", '".($type ==
'bank-transfer' ?
'bank-transfer' :
'debit-order').
"'";
976 $prev_id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"prelevement_bons");
977 $this->
id = $prev_id;
981 dol_syslog(__METHOD__.
"::Create withdraw receipt ".$this->db->lasterror(), LOG_ERR);
985 dol_syslog(__METHOD__.
"::Get last withdraw receipt ".$this->db->lasterror(), LOG_ERR);
990 if ($type !=
'bank-transfer') {
999 if (count($factures_prev) > 0) {
1000 foreach ($factures_prev as $fac) {
1002 $result = $fact->fetch($fac[0]);
1004 $this->error =
'ERRORBONPRELEVEMENT Failed to load invoice with id '.$fac[0];
1021 $ri = $this->
AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type);
1027 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_demande";
1028 $sql .=
" SET traite = 1";
1029 $sql .=
", date_traite = '".$this->db->idate($now).
"'";
1030 $sql .=
", fk_prelevement_bons = ".((int) $this->
id);
1031 $sql .=
" WHERE rowid = ".((int) $fac[1]);
1036 $this->errors[] = $this->
db->lasterror();
1037 dol_syslog(__METHOD__.
"::Update Error=".$this->db->lasterror(), LOG_ERR);
1048 dol_syslog(__METHOD__.
"::Init direct debit or credit transfer file for ".count($factures_prev).
" invoices", LOG_DEBUG);
1050 if (count($factures_prev) > 0) {
1051 $this->date_echeance = $datetimeprev;
1052 $this->reference_remise = $ref;
1054 $id = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
1055 if ($type ==
'bank-transfer') {
1056 $id = $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT;
1059 if ($account->fetch($id) > 0) {
1060 $this->emetteur_code_banque = $account->code_banque;
1061 $this->emetteur_code_guichet = $account->code_guichet;
1062 $this->emetteur_numero_compte = $account->number;
1063 $this->emetteur_number_key = $account->cle_rib;
1064 $this->sepa_xml_pti_in_ctti = (bool) $account->pti_in_ctti;
1065 $this->emetteur_iban = $account->iban;
1066 $this->emetteur_bic = $account->bic;
1068 $this->emetteur_ics = ($type ==
'bank-transfer' ? $account->ics_transfer : $account->ics);
1070 $this->raison_sociale = $account->proprio;
1073 $this->factures = $factures_prev_id;
1074 $this->context[
'factures_prev'] = $factures_prev;
1078 $result = $this->
generate($format, $executiondate, $type);
1085 dol_syslog(__METHOD__.
"::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
1093 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons";
1094 $sql .=
" SET amount = ".price2num($this->total);
1095 $sql .=
" WHERE rowid = ".((int) $this->
id);
1096 $sql .=
" AND entity = ".((int) $conf->entity);
1101 dol_syslog(__METHOD__.
"::Error update total: ".$this->db->error(), LOG_ERR);
1105 if (!$error && !$notrigger) {
1106 $triggername =
'DIRECT_DEBIT_ORDER_CREATE';
1107 if ($type !=
'bank-transfer') {
1108 $triggername =
'CREDIT_TRANSFER_ORDER_CREATE';
1120 $this->
db->commit();
1121 return count($factures_prev);
1123 $this->
db->rollback();
1139 public function delete($user =
null, $notrigger = 0)
1144 $resql1 = $resql2 = $resql3 = $resql4 = 0;
1147 $triggername =
'DIRECT_DEBIT_ORDER_DELETE';
1148 if ($this->
type ==
'bank-transfer') {
1149 $triggername =
'PAYMENTBYBANKTRANFER_DELETE';
1160 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->
id).
")";
1161 $resql1 = $this->
db->query($sql);
1168 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->
id);
1169 $resql2 = $this->
db->query($sql);
1176 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement_bons WHERE rowid = ".((int) $this->
id);
1177 $resql3 = $this->
db->query($sql);
1184 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".((int) $this->
id);
1185 $resql4 = $this->
db->query($sql);
1191 if ($resql1 && $resql2 && $resql3 && $resql4 && !$error) {
1192 $this->
db->commit();
1195 $this->
db->rollback();
1211 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1213 global $conf, $langs, $hookmanager;
1215 if (!empty($conf->dol_no_mouse_hover)) {
1221 $labeltoshow =
'PaymentByDirectDebit';
1222 if (!empty($this->
type) && $this->
type ==
'bank-transfer') {
1223 $labeltoshow =
'PaymentByBankTransfer';
1226 $label =
'<u>'.$langs->trans($labeltoshow).
'</u>';
1228 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1229 if (isset($this->statut)) {
1230 $label .=
'<br><b>'.$langs->trans(
"Status").
":</b> ".$this->
getLibStatut(5);
1233 $url = DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.$this->id;
1234 if (!empty($this->
type) && $this->
type ==
'bank-transfer') {
1235 $url = DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.$this->id;
1238 if ($option !=
'nolink') {
1240 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1241 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1242 $add_save_lastsearch_values = 1;
1244 if ($add_save_lastsearch_values) {
1245 $url .=
'&save_lastsearch_values=1';
1250 if (empty($notooltip)) {
1251 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1252 $label = $langs->trans(
"ShowMyObject");
1253 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1255 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1256 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1258 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1261 $linkstart =
'<a href="'.$url.
'"';
1262 $linkstart .= $linkclose.
'>';
1265 $result .= $linkstart;
1267 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1269 if ($withpicto != 2) {
1270 $result .= $this->ref;
1272 $result .= $linkend;
1274 global $action, $hookmanager;
1275 $hookmanager->initHooks(array(
'banktransferdao'));
1276 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1277 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1279 $result = $hookmanager->resPrint;
1281 $result .= $hookmanager->resPrint;
1296 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
1297 $sql .=
" WHERE rowid = ".((int) $rowid);
1299 if ($this->
db->query($sql)) {
1315 if (is_object($user)) {
1316 $userid = $user->id;
1321 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
1322 $sql .=
" WHERE fk_user=".((int) $userid).
" AND fk_action='".$this->
db->escape($action).
"'";
1324 if ($this->
db->query($sql)) {
1345 if (is_object($user)) {
1346 $userid = $user->id;
1354 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)";
1355 $sql .=
" VALUES ('".$this->db->idate($now).
"', ".((int) $userid).
", 'NULL', 'NULL', '".$this->
db->escape($action).
"')";
1358 if ($this->
db->query($sql)) {
1362 dol_syslog(get_class($this).
"::addNotification Error $result");
1382 public function generate($format =
'ALL', $executiondate =
'', $type =
'direct-debit')
1384 global $conf, $langs, $mysoc;
1390 dol_syslog(get_class($this).
"::generate build file=".$this->filename.
" type=".$type);
1392 $this->file = fopen($this->filename,
"w");
1393 if (empty($this->file)) {
1394 $this->error = $langs->trans(
'ErrorFailedToOpenFile', $this->filename);
1402 if ($mysoc->isInEEC()) {
1405 if ($type !=
'bank-transfer') {
1417 if (!empty($executiondate)) {
1418 $date_actu = $executiondate;
1423 $fileDebiteurSection =
'';
1424 $fileEmetteurSection =
'';
1431 $sql =
"SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
1432 $sql .=
" pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
1433 $sql .=
" f.ref as fac, pf.fk_facture as idfac,";
1434 $sql .=
" rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
1436 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1437 $sql .=
" ".MAIN_DB_PREFIX.
"facture as f,";
1438 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf,";
1439 $sql .=
" ".MAIN_DB_PREFIX.
"societe as soc,";
1440 $sql .=
" ".MAIN_DB_PREFIX.
"c_country as c,";
1441 $sql .=
" ".MAIN_DB_PREFIX.
"societe_rib as rib";
1442 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $this->
id);
1443 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1444 $sql .=
" AND pf.fk_facture = f.rowid";
1445 $sql .=
" AND f.fk_soc = soc.rowid";
1446 $sql .=
" AND soc.fk_pays = c.rowid";
1447 $sql .=
" AND rib.fk_soc = f.fk_soc";
1448 $sql .=
" AND rib.default_rib = 1";
1449 $sql .=
" AND rib.type = 'ban'";
1454 $cachearraytotestduplicate = array();
1456 $num = $this->
db->num_rows(
$resql);
1458 $obj = $this->
db->fetch_object(
$resql);
1460 if (!empty($cachearraytotestduplicate[$obj->idfac])) {
1461 $this->error = $langs->trans(
'ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
1462 $this->invoice_in_error[$obj->idfac] = $this->error;
1466 $cachearraytotestduplicate[$obj->idfac] = $obj->rowid;
1468 $daterum = (!empty($obj->date_rum)) ? $this->
db->jdate($obj->date_rum) : $this->
db->jdate($obj->datec);
1469 $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);
1470 $this->total = $this->total + $obj->somme;
1473 $nbtotalDrctDbtTxInf = $i;
1475 $this->error = $this->
db->lasterror();
1476 fputs($this->file,
'ERROR DEBITOR '.$sql.$CrLf);
1481 if ($result != -2) {
1482 $fileEmetteurSection .= $this->
EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
1489 fputs($this->file,
'<'.
'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.
'>'.$CrLf);
1490 fputs($this->file,
'<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);
1491 fputs($this->file,
' <CstmrDrctDbtInitn>'.$CrLf);
1493 fputs($this->file,
' <GrpHdr>'.$CrLf);
1494 fputs($this->file,
' <MsgId>'.(
'DD/'.$dateTime_YMD.
'/REF'.$this->id).
'</MsgId>'.$CrLf);
1495 fputs($this->file,
' <CreDtTm>'.$dateTime_ECMA.
'</CreDtTm>'.$CrLf);
1496 fputs($this->file,
' <NbOfTxs>'.$i.
'</NbOfTxs>'.$CrLf);
1497 fputs($this->file,
' <CtrlSum>'.$this->total.
'</CtrlSum>'.$CrLf);
1498 fputs($this->file,
' <InitgPty>'.$CrLf);
1500 fputs($this->file,
' <Id>'.$CrLf);
1501 fputs($this->file,
' <PrvtId>'.$CrLf);
1502 fputs($this->file,
' <Othr>'.$CrLf);
1503 fputs($this->file,
' <Id>'.$this->emetteur_ics.
'</Id>'.$CrLf);
1504 fputs($this->file,
' </Othr>'.$CrLf);
1505 fputs($this->file,
' </PrvtId>'.$CrLf);
1506 fputs($this->file,
' </Id>'.$CrLf);
1507 fputs($this->file,
' </InitgPty>'.$CrLf);
1508 fputs($this->file,
' </GrpHdr>'.$CrLf);
1510 if ($result != -2) {
1511 fputs($this-> file, $fileEmetteurSection);
1514 if ($result != -2) {
1515 fputs($this-> file, $fileDebiteurSection);
1518 fputs($this->file,
' </PmtInf>'.$CrLf);
1519 fputs($this->file,
' </CstmrDrctDbtInitn>'.$CrLf);
1520 fputs($this->file,
'</Document>'.$CrLf);
1533 if (!empty($executiondate)) {
1534 $date_actu = $executiondate;
1539 $fileCrediteurSection =
'';
1540 $fileEmetteurSection =
'';
1547 $sql =
"SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
1548 $sql .=
" pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
1549 $sql .=
" f.ref as fac, pf.fk_facture_fourn as idfac, f.ref_supplier as fac_ref_supplier,";
1550 $sql .=
" rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
1552 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1553 $sql .=
" ".MAIN_DB_PREFIX.
"facture_fourn as f,";
1554 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf,";
1555 $sql .=
" ".MAIN_DB_PREFIX.
"societe as soc,";
1556 $sql .=
" ".MAIN_DB_PREFIX.
"c_country as c,";
1557 $sql .=
" ".MAIN_DB_PREFIX.
"societe_rib as rib";
1558 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $this->
id);
1559 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1560 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
1561 $sql .=
" AND f.fk_soc = soc.rowid";
1562 $sql .=
" AND soc.fk_pays = c.rowid";
1563 $sql .=
" AND rib.fk_soc = f.fk_soc";
1564 $sql .=
" AND rib.default_rib = 1";
1565 $sql .=
" AND rib.type = 'ban'";
1570 $cachearraytotestduplicate = array();
1572 $num = $this->
db->num_rows(
$resql);
1574 $obj = $this->
db->fetch_object(
$resql);
1576 if (!empty($cachearraytotestduplicate[$obj->idfac])) {
1577 $this->error = $langs->trans(
'ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
1578 $this->invoice_in_error[$obj->idfac] = $this->error;
1582 $cachearraytotestduplicate[$obj->idfac] = $obj->rowid;
1584 $daterum = (!empty($obj->date_rum)) ? $this->
db->jdate($obj->date_rum) : $this->
db->jdate($obj->datec);
1585 $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_ref_supplier, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type);
1586 $this->total = $this->total + $obj->somme;
1589 $nbtotalDrctDbtTxInf = $i;
1591 $this->error = $this->
db->lasterror();
1592 fputs($this->file,
'ERROR CREDITOR '.$sql.$CrLf);
1597 if ($result != -2) {
1598 $fileEmetteurSection .= $this->
EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
1605 fputs($this->file,
'<'.
'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.
'>'.$CrLf);
1606 fputs($this->file,
'<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);
1607 fputs($this->file,
' <CstmrCdtTrfInitn>'.$CrLf);
1609 fputs($this->file,
' <GrpHdr>'.$CrLf);
1610 fputs($this->file,
' <MsgId>'.(
'TRF/'.$dateTime_YMD.
'/REF'.$this->id).
'</MsgId>'.$CrLf);
1611 fputs($this->file,
' <CreDtTm>'.$dateTime_ECMA.
'</CreDtTm>'.$CrLf);
1612 fputs($this->file,
' <NbOfTxs>'.$i.
'</NbOfTxs>'.$CrLf);
1613 fputs($this->file,
' <CtrlSum>'.$this->total.
'</CtrlSum>'.$CrLf);
1614 fputs($this->file,
' <InitgPty>'.$CrLf);
1616 fputs($this->file,
' <Id>'.$CrLf);
1617 fputs($this->file,
' <PrvtId>'.$CrLf);
1618 fputs($this->file,
' <Othr>'.$CrLf);
1619 fputs($this->file,
' <Id>'.$this->emetteur_ics.
'</Id>'.$CrLf);
1620 fputs($this->file,
' </Othr>'.$CrLf);
1621 fputs($this->file,
' </PrvtId>'.$CrLf);
1622 fputs($this->file,
' </Id>'.$CrLf);
1623 fputs($this->file,
' </InitgPty>'.$CrLf);
1624 fputs($this->file,
' </GrpHdr>'.$CrLf);
1626 if ($result != -2) {
1627 fputs($this-> file, $fileEmetteurSection);
1630 if ($result != -2) {
1631 fputs($this-> file, $fileCrediteurSection);
1634 fputs($this->file,
' </PmtInf>'.$CrLf);
1635 fputs($this->file,
' </CstmrCdtTrfInitn>'.$CrLf);
1636 fputs($this->file,
'</Document>'.$CrLf);
1642 if ($type !=
'bank-transfer') {
1643 $sql =
"SELECT pl.amount";
1645 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1646 $sql .=
" ".MAIN_DB_PREFIX.
"facture as f,";
1647 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
1648 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $this->
id);
1649 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1650 $sql .=
" AND pf.fk_facture = f.rowid";
1656 $num = $this->
db->num_rows(
$resql);
1659 $obj = $this->
db->fetch_object(
$resql);
1660 $this->total = $this->total + $obj->amount;
1669 $sql =
"SELECT pl.amount";
1671 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1672 $sql .=
" ".MAIN_DB_PREFIX.
"facture_fourn as f,";
1673 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
1674 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $this->
id);
1675 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1676 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
1682 $num = $this->
db->num_rows(
$resql);
1685 $obj = $this->
db->fetch_object(
$resql);
1686 $this->total = $this->total + $obj->amount;
1696 $langs->load(
'withdrawals');
1699 fputs($this->file, $langs->transnoentitiesnoconv(
'WithdrawalFileNotCapable', $mysoc->country_code));
1702 fclose($this->file);
1703 if (!empty($conf->global->MAIN_UMASK)) {
1704 @chmod($this->filename, octdec($conf->global->MAIN_UMASK));
1723 return $pre.($row_code_client ?
'-'.$row_code_client :
'').
'-'.$row_drum.
'-'.date(
'U', $row_datec);
1744 public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom =
'', $type =
'direct-debit')
1747 fputs($this->file,
"06");
1748 fputs($this->file,
"08");
1750 fputs($this->file,
" ");
1752 fputs($this->file, $this->emetteur_ics);
1756 fputs($this->file,
" ");
1757 fputs($this->file,
dol_print_date($this->date_echeance,
"%d%m",
'gmt'));
1758 fputs($this->file, substr(
dol_print_date($this->date_echeance,
"%y",
'gmt'), 1));
1762 fputs($this->file, substr(strtoupper($client_nom).
" ", 0, 24));
1765 $domiciliation = strtr($rib_dom, array(
" " =>
"-", CHR(13) =>
" ", CHR(10) =>
""));
1766 fputs($this->file, substr($domiciliation.
" ", 0, 24));
1770 fputs($this->file, substr(
" ", 0, 8));
1774 fputs($this->file, $rib_guichet);
1778 fputs($this->file, substr(
"000000000000000".$rib_number, -11));
1782 $montant = (round($amount, 2) * 100);
1784 fputs($this->file, substr(
"000000000000000".$montant, -16));
1788 fputs($this->file, substr(
"*_".$ref.
"_RDVnet".$rowid.
" ", 0, 31));
1792 fputs($this->file, $rib_banque);
1796 fputs($this->file, substr(
" ", 0, 5));
1798 fputs($this->file,
"\n");
1826 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')
1831 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1834 $Rowing = sprintf(
"%010d", $row_idfac);
1838 $Rum = (empty($row_rum) ? $this->
buildRumNumber($row_code_client, $row_datec, $row_drum) : $row_rum);
1843 if ($type !=
'bank-transfer') {
1846 $XML_DEBITOR .=
' <DrctDbtTxInf>'.$CrLf;
1847 $XML_DEBITOR .=
' <PmtId>'.$CrLf;
1849 $XML_DEBITOR .=
' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END !=
"") ? $conf->global->PRELEVEMENT_END_TO_END : (
'DD-'.dol_trunc($row_idfac.
'-'.$row_ref, 20,
'right',
'UTF-8', 1)).
'-'.$Rowing).
'</EndToEndId>'.$CrLf;
1850 $XML_DEBITOR .=
' </PmtId>'.$CrLf;
1851 $XML_DEBITOR .=
' <InstdAmt Ccy="EUR">'.round($row_somme, 2).
'</InstdAmt>'.$CrLf;
1852 $XML_DEBITOR .=
' <DrctDbtTx>'.$CrLf;
1853 $XML_DEBITOR .=
' <MndtRltdInf>'.$CrLf;
1854 $XML_DEBITOR .=
' <MndtId>'.$Rum.
'</MndtId>'.$CrLf;
1855 $XML_DEBITOR .=
' <DtOfSgntr>'.$DtOfSgntr.
'</DtOfSgntr>'.$CrLf;
1856 $XML_DEBITOR .=
' <AmdmntInd>false</AmdmntInd>'.$CrLf;
1857 $XML_DEBITOR .=
' </MndtRltdInf>'.$CrLf;
1858 $XML_DEBITOR .=
' </DrctDbtTx>'.$CrLf;
1859 $XML_DEBITOR .=
' <DbtrAgt>'.$CrLf;
1860 $XML_DEBITOR .=
' <FinInstnId>'.$CrLf;
1861 $XML_DEBITOR .=
' <BIC>'.$row_bic.
'</BIC>'.$CrLf;
1862 $XML_DEBITOR .=
' </FinInstnId>'.$CrLf;
1863 $XML_DEBITOR .=
' </DbtrAgt>'.$CrLf;
1864 $XML_DEBITOR .=
' <Dbtr>'.$CrLf;
1866 $XML_DEBITOR .=
' <PstlAdr>'.$CrLf;
1867 $XML_DEBITOR .=
' <Ctry>'.$row_country_code.
'</Ctry>'.$CrLf;
1868 $addressline1 = strtr($row_address, array(CHR(13) =>
", ", CHR(10) =>
""));
1869 $addressline2 = strtr($row_zip.(($row_zip && $row_town) ?
' ' : (string) $row_town), array(CHR(13) =>
", ", CHR(10) =>
""));
1870 if (trim($addressline1)) {
1873 if (trim($addressline2)) {
1876 $XML_DEBITOR .=
' </PstlAdr>'.$CrLf;
1877 $XML_DEBITOR .=
' </Dbtr>'.$CrLf;
1878 $XML_DEBITOR .=
' <DbtrAcct>'.$CrLf;
1879 $XML_DEBITOR .=
' <Id>'.$CrLf;
1880 $XML_DEBITOR .=
' <IBAN>'.preg_replace(
'/\s/',
'', $row_iban).
'</IBAN>'.$CrLf;
1881 $XML_DEBITOR .=
' </Id>'.$CrLf;
1882 $XML_DEBITOR .=
' </DbtrAcct>'.$CrLf;
1883 $XML_DEBITOR .=
' <RmtInf>'.$CrLf;
1885 $XML_DEBITOR .=
' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD !=
"") ? $conf->global->PRELEVEMENT_USTRD :
dol_trunc($row_ref, 135,
'right',
'UTF-8', 1)).
'</Ustrd>'.$CrLf;
1886 $XML_DEBITOR .=
' </RmtInf>'.$CrLf;
1887 $XML_DEBITOR .=
' </DrctDbtTxInf>'.$CrLf;
1888 return $XML_DEBITOR;
1892 $XML_CREDITOR .=
' <CdtTrfTxInf>'.$CrLf;
1893 $XML_CREDITOR .=
' <PmtId>'.$CrLf;
1895 $XML_CREDITOR .=
' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END !=
"") ? $conf->global->PRELEVEMENT_END_TO_END : (
'CT-'.dol_trunc($row_idfac.
'-'.$row_ref, 20,
'right',
'UTF-8', 1)).
'-'.$Rowing).
'</EndToEndId>'.$CrLf;
1896 $XML_CREDITOR .=
' </PmtId>'.$CrLf;
1897 if (!empty($this->sepa_xml_pti_in_ctti)) {
1898 $XML_CREDITOR .=
' <PmtTpInf>' . $CrLf;
1901 if (!empty($conf->global->PAYMENTBYBANKTRANSFER_FORCE_HIGH_PRIORITY)) {
1902 $instrprty =
'HIGH';
1904 $instrprty =
'NORM';
1906 $XML_CREDITOR .=
' <InstrPrty>'.$instrprty.
'</InstrPrty>' . $CrLf;
1907 $XML_CREDITOR .=
' <SvcLvl>' . $CrLf;
1908 $XML_CREDITOR .=
' <Cd>SEPA</Cd>' . $CrLf;
1909 $XML_CREDITOR .=
' </SvcLvl>' . $CrLf;
1910 $XML_CREDITOR .=
' <CtgyPurp>' . $CrLf;
1911 $XML_CREDITOR .=
' <Cd>CORE</Cd>' . $CrLf;
1912 $XML_CREDITOR .=
' </CtgyPurp>' . $CrLf;
1913 $XML_CREDITOR .=
' </PmtTpInf>' . $CrLf;
1915 $XML_CREDITOR .=
' <Amt>'.$CrLf;
1916 $XML_CREDITOR .=
' <InstdAmt Ccy="EUR">'.round($row_somme, 2).
'</InstdAmt>'.$CrLf;
1917 $XML_CREDITOR .=
' </Amt>'.$CrLf;
1928 $XML_CREDITOR .=
' <CdtrAgt>'.$CrLf;
1929 $XML_CREDITOR .=
' <FinInstnId>'.$CrLf;
1930 $XML_CREDITOR .=
' <BIC>'.$row_bic.
'</BIC>'.$CrLf;
1931 $XML_CREDITOR .=
' </FinInstnId>'.$CrLf;
1932 $XML_CREDITOR .=
' </CdtrAgt>'.$CrLf;
1933 $XML_CREDITOR .=
' <Cdtr>'.$CrLf;
1935 $XML_CREDITOR .=
' <PstlAdr>'.$CrLf;
1936 $XML_CREDITOR .=
' <Ctry>'.$row_country_code.
'</Ctry>'.$CrLf;
1937 $addressline1 = strtr($row_address, array(CHR(13) =>
", ", CHR(10) =>
""));
1938 $addressline2 = strtr($row_zip.(($row_zip && $row_town) ?
' ' : (string) $row_town), array(CHR(13) =>
", ", CHR(10) =>
""));
1939 if (trim($addressline1)) {
1942 if (trim($addressline2)) {
1945 $XML_CREDITOR .=
' </PstlAdr>'.$CrLf;
1946 $XML_CREDITOR .=
' </Cdtr>'.$CrLf;
1947 $XML_CREDITOR .=
' <CdtrAcct>'.$CrLf;
1948 $XML_CREDITOR .=
' <Id>'.$CrLf;
1949 $XML_CREDITOR .=
' <IBAN>'.preg_replace(
'/\s/',
'', $row_iban).
'</IBAN>'.$CrLf;
1950 $XML_CREDITOR .=
' </Id>'.$CrLf;
1951 $XML_CREDITOR .=
' </CdtrAcct>'.$CrLf;
1952 $XML_CREDITOR .=
' <RmtInf>'.$CrLf;
1954 $XML_CREDITOR .=
' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD !=
"") ? $conf->global->PRELEVEMENT_USTRD :
dol_trunc($row_ref, 135,
'right',
'UTF-8', 1)).
'</Ustrd>'.$CrLf;
1955 $XML_CREDITOR .=
' </RmtInf>'.$CrLf;
1956 $XML_CREDITOR .=
' </CdtTrfTxInf>'.$CrLf;
1957 return $XML_CREDITOR;
1973 fputs($this->file,
"03");
1974 fputs($this->file,
"08");
1976 fputs($this->file,
" ");
1978 fputs($this->file, $this->emetteur_ics);
1982 fputs($this->file,
" ");
1983 fputs($this->file,
dol_print_date($this->date_echeance,
"%d%m",
'gmt'));
1984 fputs($this->file, substr(
dol_print_date($this->date_echeance,
"%y",
'gmt'), 1));
1988 fputs($this->file, substr($this->raison_sociale.
" ", 0, 24));
1992 fputs($this->file, substr($this->reference_remise.
" ", 0, 7));
1996 fputs($this->file, substr(
" ", 0, 17));
2000 fputs($this->file, substr(
" ", 0, 2));
2001 fputs($this->file,
"E");
2002 fputs($this->file, substr(
" ", 0, 5));
2006 fputs($this->file, $this->emetteur_code_guichet);
2010 fputs($this->file, substr(
"000000000000000".$this->emetteur_numero_compte, -11));
2014 fputs($this->file, substr(
" ", 0, 16));
2018 fputs($this->file, substr(
" ", 0, 31));
2022 fputs($this->file, $this->emetteur_code_banque);
2026 fputs($this->file, substr(
" ", 0, 5));
2028 fputs($this->file,
"\n");
2046 public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf =
'\n', $format =
'FRST', $type =
'direct-debit')
2058 $id = ($type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
2060 if ($account->fetch($id) > 0) {
2061 $this->emetteur_code_banque = $account->code_banque;
2062 $this->emetteur_code_guichet = $account->code_guichet;
2063 $this->emetteur_numero_compte = $account->number;
2064 $this->emetteur_number_key = $account->cle_rib;
2065 $this->sepa_xml_pti_in_ctti = (bool) $account->pti_in_ctti;
2066 $this->emetteur_iban = $account->iban;
2067 $this->emetteur_bic = $account->bic;
2069 $this->emetteur_ics = ($type ==
'bank-transfer' ? $account->ics_transfer : $account->ics);
2071 $this->raison_sociale = $account->proprio;
2075 $sql =
"SELECT rowid, ref";
2077 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
2078 $sql .=
" WHERE pb.rowid = ".((int) $this->
id);
2082 $obj = $this->
db->fetch_object(
$resql);
2084 $country = explode(
':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY);
2085 $IdBon = sprintf(
"%05d", $obj->rowid);
2086 $RefBon = $obj->ref;
2088 if ($type !=
'bank-transfer') {
2090 $XML_SEPA_INFO =
'';
2091 $XML_SEPA_INFO .=
' <PmtInf>'.$CrLf;
2092 $XML_SEPA_INFO .=
' <PmtInfId>'.(
'DD/'.$dateTime_YMD.
'/ID'.$IdBon.
'-'.$RefBon).
'</PmtInfId>'.$CrLf;
2093 $XML_SEPA_INFO .=
' <PmtMtd>DD</PmtMtd>'.$CrLf;
2094 $XML_SEPA_INFO .=
' <NbOfTxs>'.$nombre.
'</NbOfTxs>'.$CrLf;
2095 $XML_SEPA_INFO .=
' <CtrlSum>'.$total.
'</CtrlSum>'.$CrLf;
2096 $XML_SEPA_INFO .=
' <PmtTpInf>'.$CrLf;
2097 $XML_SEPA_INFO .=
' <SvcLvl>'.$CrLf;
2098 $XML_SEPA_INFO .=
' <Cd>SEPA</Cd>'.$CrLf;
2099 $XML_SEPA_INFO .=
' </SvcLvl>'.$CrLf;
2100 $XML_SEPA_INFO .=
' <LclInstrm>'.$CrLf;
2101 $XML_SEPA_INFO .=
' <Cd>CORE</Cd>'.$CrLf;
2102 $XML_SEPA_INFO .=
' </LclInstrm>'.$CrLf;
2103 $XML_SEPA_INFO .=
' <SeqTp>'.$format.
'</SeqTp>'.$CrLf;
2104 $XML_SEPA_INFO .=
' </PmtTpInf>'.$CrLf;
2105 $XML_SEPA_INFO .=
' <ReqdColltnDt>'.$dateTime_ETAD.
'</ReqdColltnDt>'.$CrLf;
2106 $XML_SEPA_INFO .=
' <Cdtr>'.$CrLf;
2108 $XML_SEPA_INFO .=
' <PstlAdr>'.$CrLf;
2109 $XML_SEPA_INFO .=
' <Ctry>'.$country[1].
'</Ctry>'.$CrLf;
2110 $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) =>
", ", CHR(10) =>
""));
2111 $addressline2 = 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) =>
""));
2112 if ($addressline1) {
2115 if ($addressline2) {
2118 $XML_SEPA_INFO .=
' </PstlAdr>'.$CrLf;
2119 $XML_SEPA_INFO .=
' </Cdtr>'.$CrLf;
2120 $XML_SEPA_INFO .=
' <CdtrAcct>'.$CrLf;
2121 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2122 $XML_SEPA_INFO .=
' <IBAN>'.preg_replace(
'/\s/',
'', $this->emetteur_iban).
'</IBAN>'.$CrLf;
2123 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2124 $XML_SEPA_INFO .=
' </CdtrAcct>'.$CrLf;
2125 $XML_SEPA_INFO .=
' <CdtrAgt>'.$CrLf;
2126 $XML_SEPA_INFO .=
' <FinInstnId>'.$CrLf;
2127 $XML_SEPA_INFO .=
' <BIC>'.$this->emetteur_bic.
'</BIC>'.$CrLf;
2128 $XML_SEPA_INFO .=
' </FinInstnId>'.$CrLf;
2129 $XML_SEPA_INFO .=
' </CdtrAgt>'.$CrLf;
2138 $XML_SEPA_INFO .=
' <ChrgBr>SLEV</ChrgBr>'.$CrLf;
2139 $XML_SEPA_INFO .=
' <CdtrSchmeId>'.$CrLf;
2140 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2141 $XML_SEPA_INFO .=
' <PrvtId>'.$CrLf;
2142 $XML_SEPA_INFO .=
' <Othr>'.$CrLf;
2143 $XML_SEPA_INFO .=
' <Id>'.$this->emetteur_ics.
'</Id>'.$CrLf;
2144 $XML_SEPA_INFO .=
' <SchmeNm>'.$CrLf;
2145 $XML_SEPA_INFO .=
' <Prtry>SEPA</Prtry>'.$CrLf;
2146 $XML_SEPA_INFO .=
' </SchmeNm>'.$CrLf;
2147 $XML_SEPA_INFO .=
' </Othr>'.$CrLf;
2148 $XML_SEPA_INFO .=
' </PrvtId>'.$CrLf;
2149 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2150 $XML_SEPA_INFO .=
' </CdtrSchmeId>'.$CrLf;
2153 $XML_SEPA_INFO =
'';
2154 $XML_SEPA_INFO .=
' <PmtInf>'.$CrLf;
2155 $XML_SEPA_INFO .=
' <PmtInfId>'.(
'TRF/'.$dateTime_YMD.
'/ID'.$IdBon.
'-'.$RefBon).
'</PmtInfId>'.$CrLf;
2156 $XML_SEPA_INFO .=
' <PmtMtd>TRF</PmtMtd>'.$CrLf;
2158 $XML_SEPA_INFO .=
' <NbOfTxs>'.$nombre.
'</NbOfTxs>'.$CrLf;
2159 $XML_SEPA_INFO .=
' <CtrlSum>'.$total.
'</CtrlSum>'.$CrLf;
2160 if (!empty($this->sepa_xml_pti_in_ctti) && !empty($format)) {
2161 $XML_SEPA_INFO .=
' <PmtTpInf>' . $CrLf;
2162 $XML_SEPA_INFO .=
' <SvcLvl>' . $CrLf;
2163 $XML_SEPA_INFO .=
' <Cd>SEPA</Cd>' . $CrLf;
2164 $XML_SEPA_INFO .=
' </SvcLvl>' . $CrLf;
2165 $XML_SEPA_INFO .=
' <LclInstrm>' . $CrLf;
2166 $XML_SEPA_INFO .=
' <Cd>CORE</Cd>' . $CrLf;
2167 $XML_SEPA_INFO .=
' </LclInstrm>' . $CrLf;
2168 $XML_SEPA_INFO .=
' <SeqTp>' . $format .
'</SeqTp>' . $CrLf;
2169 $XML_SEPA_INFO .=
' </PmtTpInf>' . $CrLf;
2171 $XML_SEPA_INFO .=
' <ReqdExctnDt>'.dol_print_date($dateTime_ETAD,
'dayrfc').
'</ReqdExctnDt>'.$CrLf;
2172 $XML_SEPA_INFO .=
' <Dbtr>'.$CrLf;
2174 $XML_SEPA_INFO .=
' <PstlAdr>'.$CrLf;
2175 $XML_SEPA_INFO .=
' <Ctry>'.$country[1].
'</Ctry>'.$CrLf;
2176 $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) =>
", ", CHR(10) =>
""));
2177 $addressline2 = 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) =>
""));
2178 if ($addressline1) {
2181 if ($addressline2) {
2184 $XML_SEPA_INFO .=
' </PstlAdr>'.$CrLf;
2185 $XML_SEPA_INFO .=
' </Dbtr>'.$CrLf;
2186 $XML_SEPA_INFO .=
' <DbtrAcct>'.$CrLf;
2187 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2188 $XML_SEPA_INFO .=
' <IBAN>'.preg_replace(
'/\s/',
'', $this->emetteur_iban).
'</IBAN>'.$CrLf;
2189 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2190 $XML_SEPA_INFO .=
' </DbtrAcct>'.$CrLf;
2191 $XML_SEPA_INFO .=
' <DbtrAgt>'.$CrLf;
2192 $XML_SEPA_INFO .=
' <FinInstnId>'.$CrLf;
2193 $XML_SEPA_INFO .=
' <BIC>'.$this->emetteur_bic.
'</BIC>'.$CrLf;
2194 $XML_SEPA_INFO .=
' </FinInstnId>'.$CrLf;
2195 $XML_SEPA_INFO .=
' </DbtrAgt>'.$CrLf;
2204 $XML_SEPA_INFO .=
' <ChrgBr>SLEV</ChrgBr>'.$CrLf;
2219 fputs($this->file,
'INCORRECT EMETTEUR '.$this->raison_sociale.$CrLf);
2220 $XML_SEPA_INFO =
'';
2222 return $XML_SEPA_INFO;
2235 fputs($this->file,
"08");
2236 fputs($this->file,
"08");
2238 fputs($this->file,
" ");
2240 fputs($this->file, $this->emetteur_ics);
2244 fputs($this->file, substr(
" ", 0, 12));
2249 fputs($this->file, substr(
" ", 0, 24));
2253 fputs($this->file, substr(
" ", 0, 24));
2257 fputs($this->file, substr(
" ", 0, 8));
2261 fputs($this->file, substr(
" ", 0, 5));
2265 fputs($this->file, substr(
" ", 0, 11));
2269 $montant = ($total * 100);
2271 fputs($this->file, substr(
"000000000000000".$montant, -16));
2275 fputs($this->file, substr(
" ", 0, 31));
2279 fputs($this->file, substr(
" ", 0, 5));
2283 fputs($this->file, substr(
" ", 0, 5));
2285 fputs($this->file,
"\n");
2296 return $this->
LibStatut($this->statut, $mode);
2310 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
2313 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'StatusWaiting');
2314 $this->labelStatus[self::STATUS_TRANSFERED] = $langs->transnoentitiesnoconv(
'StatusTrans');
2315 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'StatusWaiting');
2316 $this->labelStatusShort[self::STATUS_TRANSFERED] = $langs->transnoentitiesnoconv(
'StatusTrans');
2317 if ($this->
type ==
'bank-transfer') {
2318 $this->labelStatus[self::STATUS_DEBITED] = $langs->transnoentitiesnoconv(
'StatusDebited');
2319 $this->labelStatusShort[self::STATUS_DEBITED] = $langs->transnoentitiesnoconv(
'StatusDebited');
2321 $this->labelStatus[self::STATUS_CREDITED] = $langs->transnoentitiesnoconv(
'StatusCredited');
2322 $this->labelStatusShort[self::STATUS_CREDITED] = $langs->transnoentitiesnoconv(
'StatusCredited');
2326 $statusType =
'status1';
2327 if ($status == self::STATUS_TRANSFERED) {
2328 $statusType =
'status3';
2330 if ($status == self::STATUS_CREDITED || $status == self::STATUS_DEBITED) {
2331 $statusType =
'status6';
2334 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
2348 global $conf, $langs;
Class to manage bank accounts.
Class to manage withdrawal receipts.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
static buildRumNumber($row_code_client, $row_datec, $row_drum)
Generate dynamically a RUM number for a customer bank account.
SommeAPrelever($mode='direct-debit')
Returns amount waiting for direct debit payment or credit transfer payment.
EnregEmetteur($type='direct-debit')
Write sender of request (me).
EnregTotal($total)
Write end.
fetch($rowid, $ref='')
Get object and lines from database.
generate($format='ALL', $executiondate='', $type='direct-debit')
Generate a direct debit or credit transfer file.
deleteNotificationById($rowid)
Delete a notification def by id.
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')
Write recipient of request (customer)
addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
Add line to withdrawal.
__construct($db)
Constructor.
EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom='', $type='direct-debit')
Write recipient of request (customer)
NbFactureAPrelever($type='direct-debit')
Get number of invoices to pay.
create($banque=0, $agence=0, $mode='real', $format='ALL', $executiondate='', $notrigger=0, $type='direct-debit')
Create a direct debit order or a credit transfer order TODO delete params banque and agence when not ...
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Returns clickable name (with picto)
LibStatut($status, $mode=0)
Return status label for a status.
set_infotrans($user, $date, $method)
Set withdrawal to transmited status.
getErrorString($error)
Return error string.
set_infocredit($user, $date)
Set direct debit or credit transfer order to "paid" status.
nbOfInvoiceToPay($mode='direct-debit')
Get number of invoices waiting for payment.
AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type='debit-order')
Add invoice to withdrawal.
getLibStatut($mode=0)
Return status label of object.
getListInvoices($amounts=0)
Get invoice list.
addNotification($db, $user, $action)
Add a notification.
EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n', $format='FRST', $type='direct-debit')
Write sender of request (me).
deleteNotification($user, $action)
Delete a notification.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db
API class for accounts.