29 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
47 public $element =
'widthdraw';
52 public $table_element =
'prelevement_bons';
57 public $picto =
'payment';
59 public $date_echeance;
60 public $raison_sociale;
61 public $reference_remise;
62 public $emetteur_code_guichet;
63 public $emetteur_numero_compte;
64 public $emetteur_code_banque;
65 public $emetteur_number_key;
67 public $emetteur_iban;
77 public $labelStatus = array();
79 public $invoice_in_error = array();
80 public $thirdparty_in_error = array();
82 const STATUS_DRAFT = 0;
83 const STATUS_TRANSFERED = 1;
84 const STATUS_CREDITED = 2;
100 $this->date_echeance =
dol_now();
101 $this->raison_sociale =
"";
102 $this->reference_remise =
"";
104 $this->emetteur_code_guichet =
"";
105 $this->emetteur_numero_compte =
"";
106 $this->emetteur_code_banque =
"";
107 $this->emetteur_number_key =
"";
109 $this->emetteur_iban =
"";
110 $this->emetteur_bic =
"";
111 $this->emetteur_ics =
"";
113 $this->factures = array();
115 $this->methodes_trans = array();
117 $this->methodes_trans[0] =
"Internet";
137 public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type =
'debit-order')
144 $result = $this->
addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key);
150 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_facture (";
151 if ($type !=
'bank-transfer') {
152 $sql .=
"fk_facture";
154 $sql .=
"fk_facture_fourn";
156 $sql .=
",fk_prelevement_lignes";
157 $sql .=
") VALUES (";
159 $sql .=
", ".$line_id;
162 if ($this->
db->query($sql))
167 $this->errors[] = get_class($this).
"::AddFacture ".$this->
db->lasterror;
168 dol_syslog(get_class($this).
"::AddFacture Error $result");
172 $this->errors[] = get_class($this).
"::AddFacture linedid Empty";
173 dol_syslog(get_class($this).
"::AddFacture Error $result");
177 dol_syslog(get_class($this).
"::AddFacture Error $result");
196 public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
206 $sql =
"SELECT rowid";
207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes";
208 $sql .=
" WHERE fk_prelevement_bons = ".$this->id;
209 $sql .=
" AND fk_soc =".$client_id;
210 $sql .=
" AND code_banque = '".$this->db->escape($code_banque).
"'";
211 $sql .=
" AND code_guichet = '".$this->db->escape($code_guichet).
"'";
212 $sql .=
" AND number = '".$this->db->escape($number).
"'";
225 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_lignes (";
226 $sql .=
"fk_prelevement_bons";
228 $sql .=
", client_nom";
230 $sql .=
", code_banque";
231 $sql .=
", code_guichet";
234 $sql .=
") VALUES (";
236 $sql .=
", ".$client_id;
237 $sql .=
", '".$this->db->escape($client_nom).
"'";
238 $sql .=
", '".price2num($amount).
"'";
239 $sql .=
", '".$this->db->escape($code_banque).
"'";
240 $sql .=
", '".$this->db->escape($code_guichet).
"'";
241 $sql .=
", '".$this->db->escape($number).
"'";
242 $sql .=
", '".$this->db->escape($number_key).
"'";
245 if ($this->
db->query($sql))
247 $line_id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"prelevement_lignes");
250 $this->errors[] = get_class($this).
"::addline Error -2 ".$this->
db->lasterror;
251 dol_syslog(get_class($this).
"::addline Error -2");
271 $errors[1027] = $langs->trans(
"DateInvalid");
273 return $errors[abs($error)];
283 public function fetch($rowid, $ref =
'')
287 $sql =
"SELECT p.rowid, p.ref, p.amount, p.note";
288 $sql .=
", p.datec as dc";
289 $sql .=
", p.date_trans as date_trans";
290 $sql .=
", p.method_trans, p.fk_user_trans";
291 $sql .=
", p.date_credit as date_credit";
292 $sql .=
", p.fk_user_credit";
294 $sql .=
", p.statut as status";
295 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
296 $sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
297 if ($rowid > 0) $sql .=
" AND p.rowid = ".$rowid;
298 else $sql .=
" AND p.ref = '".$this->db->escape($ref).
"'";
300 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
301 $result = $this->
db->query($sql);
304 if ($this->
db->num_rows($result))
306 $obj = $this->
db->fetch_object($result);
308 $this->
id = $obj->rowid;
309 $this->ref = $obj->ref;
310 $this->amount = $obj->amount;
311 $this->
note = $obj->note;
312 $this->datec = $this->
db->jdate($obj->dc);
314 $this->date_trans = $this->
db->jdate($obj->date_trans);
315 $this->method_trans = $obj->method_trans;
316 $this->user_trans = $obj->fk_user_trans;
318 $this->date_credit = $this->
db->jdate($obj->date_credit);
319 $this->user_credit = $obj->fk_user_credit;
321 $this->
type = $obj->type;
323 $this->status = $obj->status;
324 $this->
statut = $obj->status;
330 dol_syslog(get_class($this).
"::Fetch Erreur aucune ligne retournee");
351 if ($this->
db->begin())
353 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons";
354 $sql .=
" SET statut = ".self::STATUS_TRANSFERED;
355 $sql .=
" WHERE rowid = ".$this->id;
356 $sql .=
" AND entity = ".$conf->entity;
358 $result = $this->
db->query($sql);
361 dol_syslog(get_class($this).
"::set_credite Erreur 1");
371 for ($i = 0; $i < $num; $i++)
374 dol_syslog(get_class($this).
"::set_credite set_paid fac ".$facs[$i]);
376 $fac->fetch($facs[$i]);
377 $result = $fac->set_paid($user);
383 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_lignes";
384 $sql .=
" SET statut = 2";
385 $sql .=
" WHERE fk_prelevement_bons = ".$this->id;
387 if (!$this->
db->query($sql))
389 dol_syslog(get_class($this).
"::set_credite Erreur 1");
402 $this->
db->rollback();
403 dol_syslog(get_class($this).
"::set_credite ROLLBACK ");
408 dol_syslog(get_class($this).
"::set_credite Ouverture transaction SQL impossible ");
424 global $conf, $langs;
428 if ($this->fetched == 1)
430 if ($date < $this->date_trans)
432 $this->error =
'DateOfMovementLowerThanDateOfFileTransmission';
433 dol_syslog(
"bon-prelevment::set_infocredit 1027 ".$this->error);
439 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons ";
440 $sql .=
" SET fk_user_credit = ".$user->id;
441 $sql .=
", statut = ".self::STATUS_CREDITED;
442 $sql .=
", date_credit = '".$this->db->idate($date).
"'";
443 $sql .=
" WHERE rowid=".$this->id;
444 $sql .=
" AND entity = ".$conf->entity;
445 $sql .=
" AND statut = ".self::STATUS_TRANSFERED;
450 $langs->load(
'withdrawals');
451 $subject = $langs->trans(
"InfoCreditSubject", $this->ref);
452 $message = $langs->trans(
"InfoCreditMessage", $this->ref,
dol_print_date($date,
'dayhour'));
455 $bankaccount = ($this->
type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
458 $amountsperthirdparty = array();
464 for ($i = 0; $i < $num; $i++)
466 if ($this->
type ==
'bank-transfer') {
472 $result = $fac->fetch($facs[$i][0]);
474 $amounts[$fac->id] = $facs[$i][1];
475 $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1];
477 $totalpaye = $fac->getSommePaiement();
478 $totalcreditnotes = $fac->getSumCreditNotesUsed();
479 $totaldeposits = $fac->getSumDepositsUsed();
480 $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits;
483 if (
price2num($alreadypayed + $facs[$i][1],
'MT') == $fac->total_ttc) {
484 $result = $fac->set_paid($user);
486 $this->error = $fac->error;
487 $this->errors = $fac->errors;
494 foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts)
496 if ($this->
type ==
'bank-transfer') {
501 $paiement->datepaye = $date;
502 $paiement->amounts = $cursoramounts;
504 if ($this->
type ==
'bank-transfer') {
505 $paiement->paiementid = 2;
506 $paiement->paiementcode =
'VIR';
508 $paiement->paiementid = 3;
509 $paiement->paiementcode =
'PRE';
512 $paiement->num_payment = $this->ref;
513 $paiement->id_prelevement = $this->id;
515 $paiement_id = $paiement->create($user);
516 if ($paiement_id < 0)
519 $this->error = $paiement->error;
520 $this->errors = $paiement->errors;
521 dol_syslog(get_class($this).
"::set_infocredit AddPayment Error ".$this->error);
523 if ($this->
type ==
'bank-transfer') {
524 $modeforaddpayment =
'payment_supplier';
526 $modeforaddpayment =
'payment';
529 $result = $paiement->addPaymentToBank($user, $modeforaddpayment,
'(WithdrawalPayment)', $bankaccount,
'',
'');
533 $this->error = $paiement->error;
534 $this->errors = $paiement->errors;
535 dol_syslog(get_class($this).
"::set_infocredit AddPaymentToBank Error ".$this->error);
546 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_lignes";
547 $sql .=
" SET statut = 2";
548 $sql .=
" WHERE fk_prelevement_bons = ".$this->id;
550 if (!$this->
db->query($sql)) {
551 dol_syslog(get_class($this).
"::set_infocredit Update lines Error");
556 $this->error = $this->
db->lasterror();
557 dol_syslog(get_class($this).
"::set_infocredit Update Bons Error");
566 $this->date_credit = $date;
567 $this->
statut = self::STATUS_CREDITED;
572 $this->
db->rollback();
592 global $conf, $langs;
596 dol_syslog(get_class($this).
"::set_infotrans Start", LOG_INFO);
597 if ($this->
db->begin())
599 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons ";
600 $sql .=
" SET fk_user_trans = ".$user->id;
601 $sql .=
" , date_trans = '".$this->db->idate($date).
"'";
602 $sql .=
" , method_trans = ".$method;
603 $sql .=
" , statut = ".self::STATUS_TRANSFERED;
604 $sql .=
" WHERE rowid = ".$this->id;
605 $sql .=
" AND entity = ".$conf->entity;
606 $sql .=
" AND statut = 0";
608 if ($this->
db->query($sql))
610 $this->method_trans = $method;
611 $langs->load(
'withdrawals');
612 $subject = $langs->trans(
"InfoTransSubject", $this->ref);
613 $message = $langs->trans(
"InfoTransMessage", $this->ref,
dolGetFirstLastname($user->firstname, $user->lastname));
614 $message .= $langs->trans(
"InfoTransData",
price($this->amount), $this->methodes_trans[$this->method_trans],
dol_print_date($date,
'day'));
623 $this->date_trans = $date;
625 $this->user_trans = $user->id;
630 $this->
db->rollback();
631 dol_syslog(get_class($this).
"::set_infotrans ROLLBACK", LOG_ERR);
636 dol_syslog(get_class($this).
"::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT);
657 if ($this->
type ==
'bank-transfer') {
658 $sql .=
" pf.fk_facture_fourn";
660 $sql .=
" pf.fk_facture";
662 if ($amounts) $sql .=
", SUM(pl.amount)";
663 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
664 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
665 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_facture as pf";
666 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
667 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
668 $sql .=
" AND p.rowid = ".$this->id;
669 $sql .=
" AND p.entity = ".$conf->entity;
671 if ($this->
type ==
'bank-transfer') {
672 $sql .=
" GROUP BY fk_facture_fourn";
674 $sql .=
" GROUP BY fk_facture";
688 $row = $this->
db->fetch_row(
$resql);
689 if (!$amounts) $arr[$i] = $row[0];
701 dol_syslog(get_class($this).
"::getListInvoices Erreur");
719 $sql =
"SELECT sum(pfd.amount) as nb";
720 if ($mode !=
'bank-transfer') {
721 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
723 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
725 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
726 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
727 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
729 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
731 if ($mode !=
'bank-transfer') {
732 $sql .=
" AND f.rowid = pfd.fk_facture";
734 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
736 $sql .=
" AND f.paye = 0";
737 $sql .=
" AND pfd.traite = 0";
738 $sql .=
" AND pfd.ext_payment_id IS NULL";
739 $sql .=
" AND f.total_ttc > 0";
744 $obj = $this->
db->fetch_object(
$resql);
751 dol_syslog(get_class($this).
"::SommeAPrelever Erreur -1");
781 $sql =
"SELECT count(f.rowid) as nb";
782 if ($type ==
'bank-transfer') {
783 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
785 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
787 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
788 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
789 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
791 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
793 if ($type ==
'bank-transfer') {
794 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
796 $sql .=
" AND f.rowid = pfd.fk_facture";
798 $sql .=
" AND pfd.traite = 0";
799 $sql .=
" AND pfd.ext_payment_id IS NULL";
800 $sql .=
" AND f.total_ttc > 0";
802 dol_syslog(get_class($this).
"::NbFactureAPrelever");
807 $obj = $this->
db->fetch_object(
$resql);
813 $this->error = get_class($this).
"::NbFactureAPrelever Erreur -1 sql=".$this->
db->error();
833 public function create($banque = 0, $agence = 0, $mode =
'real', $format =
'ALL', $executiondate =
'', $notrigger = 0, $type =
'direct-debit')
836 global $conf, $langs, $user;
838 dol_syslog(__METHOD__.
"::Bank=".$banque.
" Office=".$agence.
" mode=".$mode.
" format=".$format, LOG_DEBUG);
840 require_once DOL_DOCUMENT_ROOT.
"/compta/facture/class/facture.class.php";
841 require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
843 if ($type !=
'bank-transfer') {
844 if (empty($format)) {
845 $this->error =
'ErrorBadParametersForDirectDebitFileCreate';
852 $datetimeprev = time();
854 if (!empty($executiondate)) $datetimeprev = $executiondate;
856 $month = strftime(
"%m", $datetimeprev);
857 $year = strftime(
"%Y", $datetimeprev);
859 $this->invoice_in_error = array();
860 $this->thirdparty_in_error = array();
864 $factures_prev = array();
865 $factures_result = array();
866 $factures_prev_id = array();
867 $factures_errors = array();
871 $sql =
"SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
872 $sql .=
", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib";
873 $sql .=
", pfd.amount";
874 $sql .=
", s.nom as name";
875 if ($type !=
'bank-transfer') {
876 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
878 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
880 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
881 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
882 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
883 if ($type !=
'bank-transfer') {
884 $sql .=
" AND f.rowid = pfd.fk_facture";
886 $sql .=
" AND f.rowid = pfd.fk_facture_fourn";
888 $sql .=
" AND s.rowid = f.fk_soc";
889 $sql .=
" AND f.fk_statut = 1";
890 $sql .=
" AND f.paye = 0";
891 $sql .=
" AND pfd.traite = 0";
892 $sql .=
" AND f.total_ttc > 0";
893 $sql .=
" AND pfd.ext_payment_id IS NULL";
895 dol_syslog(__METHOD__.
"::Read invoices, sql=".$sql, LOG_DEBUG);
905 $row = $this->
db->fetch_row(
$resql);
906 $factures[$i] = $row;
909 dol_syslog(__METHOD__.
"::Read invoices error Found a null invoice", LOG_ERR);
910 $this->invoice_in_error[$row[0]] =
"Error for invoice id ".$row[0].
", found a null amount";
916 dol_syslog(__METHOD__.
"::Read invoices, ".$i.
" invoices to withdraw", LOG_DEBUG);
919 dol_syslog(__METHOD__.
"::Read invoices error ".$this->db->error(), LOG_ERR);
925 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
930 dol_syslog(__METHOD__.
"::Check BAN", LOG_DEBUG);
932 if (count($factures) > 0)
934 foreach ($factures as $key => $fac)
936 if ($type !=
'bank-transfer') {
941 $resfetch = $tmpinvoice->fetch($fac[0]);
944 if ($soc->fetch($tmpinvoice->socid) >= 0)
947 $bac->fetch(0, $soc->id);
949 if ($type !=
'bank-transfer') {
950 if ($format ==
'FRST' && $bac->frstrecur !=
'FRST')
954 if ($format ==
'RCUR' && ($bac->frstrecur !=
'RCUR' && $bac->frstrecur !=
'RECUR'))
960 if ($bac->verif() >= 1)
962 $factures_prev[$i] = $fac;
964 $factures_prev_id[$i] = $fac[0];
968 dol_syslog(__METHOD__.
"::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$tmpinvoice->socid.
" ".$soc->name, LOG_WARNING);
969 $this->invoice_in_error[$fac[0]] =
"Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0).
" for thirdparty ".$soc->getNomUrl(0);
970 $this->thirdparty_in_error[$soc->id] =
"Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0).
" for thirdparty ".$soc->getNomUrl(0);
973 dol_syslog(__METHOD__.
"::Check BAN Failed to read company", LOG_WARNING);
976 dol_syslog(__METHOD__.
"::Check BAN Failed to read invoice", LOG_WARNING);
980 dol_syslog(__METHOD__.
"::Check BAN No invoice to process", LOG_WARNING);
987 $out = count($factures_prev).
" invoices will be included.";
1000 if (count($factures_prev) > 0)
1002 if ($mode ==
'real') {
1005 print $langs->trans(
"ModeWarning");
1024 $ref = substr($year, -2).$month;
1026 $sql =
"SELECT substring(ref from char_length(ref) - 1)";
1027 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons";
1028 $sql .=
" WHERE ref LIKE '%".$this->db->escape($ref).
"%'";
1029 $sql .=
" AND entity = ".$conf->entity;
1030 $sql .=
" ORDER BY ref DESC LIMIT 1";
1032 dol_syslog(get_class($this).
"::create sql=".$sql, LOG_DEBUG);
1037 $row = $this->
db->fetch_row(
$resql);
1038 $ref =
"T".$ref.str_pad(
dol_substr(
"00".intval($row[0]) + 1, 0, 2), 2,
"0", STR_PAD_LEFT);
1040 if ($type !=
'bank-transfer') {
1041 $dir = $conf->prelevement->dir_output.
'/receipts';
1043 $dir = $conf->paymentbybanktransfer->dir_output.
'/receipts';
1047 $this->filename = $dir.
'/'.$ref.
'.xml';
1050 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_bons (";
1051 $sql .=
"ref, entity, datec, type";
1052 $sql .=
") VALUES (";
1053 $sql .=
"'".$this->db->escape($ref).
"'";
1054 $sql .=
", ".$conf->entity;
1055 $sql .=
", '".$this->db->idate($now).
"'";
1056 $sql .=
", '".($type ==
'bank-transfer' ?
'bank-transfer' :
'debit-order').
"'";
1062 $prev_id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"prelevement_bons");
1063 $this->
id = $prev_id;
1067 dol_syslog(__METHOD__.
"::Create withdraw receipt ".$this->db->lasterror(), LOG_ERR);
1071 dol_syslog(__METHOD__.
"::Get last withdraw receipt ".$this->db->lasterror(), LOG_ERR);
1077 if ($type !=
'bank-transfer') {
1086 if (count($factures_prev) > 0)
1088 foreach ($factures_prev as $fac)
1091 $result = $fact->fetch($fac[0]);
1093 $this->error =
'ERRORBONPRELEVEMENT Failed to load invoice with id '.$fac[0];
1110 $ri = $this->
AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type);
1117 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_facture_demande";
1118 $sql .=
" SET traite = 1";
1119 $sql .=
", date_traite = '".$this->db->idate($now).
"'";
1120 $sql .=
", fk_prelevement_bons = ".$this->id;
1121 $sql .=
" WHERE rowid = ".$fac[1];
1127 $this->errors[] = $this->
db->lasterror();
1128 dol_syslog(__METHOD__.
"::Update Error=".$this->db->lasterror(), LOG_ERR);
1140 dol_syslog(__METHOD__.
"::Init direct debit or credit transfer file for ".count($factures_prev).
" invoices", LOG_DEBUG);
1142 if (count($factures_prev) > 0)
1144 $this->date_echeance = $datetimeprev;
1145 $this->reference_remise = $ref;
1147 $id = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
1148 if ($type ==
'bank-transfer') {
1149 $id = $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT;
1152 if ($account->fetch($id) > 0)
1154 $this->emetteur_code_banque = $account->code_banque;
1155 $this->emetteur_code_guichet = $account->code_guichet;
1156 $this->emetteur_numero_compte = $account->number;
1157 $this->emetteur_number_key = $account->cle_rib;
1158 $this->emetteur_iban = $account->iban;
1159 $this->emetteur_bic = $account->bic;
1161 $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS;
1163 $this->raison_sociale = $account->proprio;
1166 $this->factures = $factures_prev_id;
1167 $this->context[
'factures_prev'] = $factures_prev;
1171 $result = $this->
generate($format, $executiondate, $type);
1178 dol_syslog(__METHOD__.
"::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
1186 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_bons";
1187 $sql .=
" SET amount = ".price2num($this->total);
1188 $sql .=
" WHERE rowid = ".$this->id;
1189 $sql .=
" AND entity = ".$conf->entity;
1195 dol_syslog(__METHOD__.
"::Error update total: ".$this->db->error(), LOG_ERR);
1199 if (!$error && !$notrigger)
1201 $triggername =
'DIRECT_DEBIT_ORDER_CREATE';
1202 if ($type !=
'bank-transfer') {
1203 $triggername =
'CREDIT_TRANSFER_ORDER_CREATE';
1208 if ($result < 0) $error++;
1214 $this->
db->commit();
1215 return count($factures_prev);
1217 $this->
db->rollback();
1233 public function delete($user = null, $notrigger = 0)
1238 $resql1 = $resql2 = $resql3 = $resql4 = 0;
1242 $triggername =
'DIRECT_DEBIT_ORDER_DELETE';
1243 if ($this->
type ==
'bank-transfer') {
1244 $triggername =
'PAYMENTBYBANKTRANFER_DELETE';
1248 if ($result < 0) $error++;
1254 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"prelevement_lignes WHERE fk_prelevement_bons = ".$this->
id.
")";
1255 $resql1 = $this->
db->query($sql);
1261 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement_lignes WHERE fk_prelevement_bons = ".$this->id;
1262 $resql2 = $this->
db->query($sql);
1268 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"prelevement_bons WHERE rowid = ".$this->id;
1269 $resql3 = $this->
db->query($sql);
1275 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".$this->id;
1276 $resql4 = $this->
db->query($sql);
1280 if ($resql1 && $resql2 && $resql3 && $resql4 && !$error)
1282 $this->
db->commit();
1285 $this->
db->rollback();
1301 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1303 global $conf, $langs, $hookmanager;
1305 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
1309 $labeltoshow =
'PaymentByDirectDebit';
1310 if ($this->
type ==
'bank-transfer') {
1311 $labeltoshow =
'PaymentByBankTransfer';
1314 $label =
'<u>'.$langs->trans($labeltoshow).
'</u>';
1316 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1317 if (isset($this->
statut)) {
1318 $label .=
'<br><b>'.$langs->trans(
"Status").
":</b> ".$this->
getLibStatut(5);
1321 $url = DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.$this->id;
1322 if ($this->
type ==
'bank-transfer') {
1323 $url = DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.$this->id;
1326 if ($option !=
'nolink')
1329 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1330 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
1331 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
1335 if (empty($notooltip))
1337 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1339 $label = $langs->trans(
"ShowMyObject");
1340 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1342 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1343 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1351 }
else $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1353 $linkstart =
'<a href="'.$url.
'"';
1354 $linkstart .= $linkclose.
'>';
1357 $result .= $linkstart;
1358 if ($withpicto) $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);
1359 if ($withpicto != 2) $result .= $this->ref;
1360 $result .= $linkend;
1363 global $action, $hookmanager;
1364 $hookmanager->initHooks(array(
'banktransferdao'));
1365 $parameters = array(
'id'=>$this->
id,
'getnomurl'=>$result);
1366 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1367 if ($reshook > 0) $result = $hookmanager->resPrint;
1368 else $result .= $hookmanager->resPrint;
1386 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
1387 $sql .=
" WHERE rowid = ".((int) $rowid);
1389 if ($this->
db->query($sql))
1410 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
1411 $sql .=
" WHERE fk_user=".$user.
" AND fk_action='".$this->
db->escape($action).
"'";
1413 if ($this->
db->query($sql))
1439 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)";
1440 $sql .=
" VALUES ('".$this->db->idate($now).
"', ".$user.
", 'NULL', 'NULL', '".$this->
db->escape($action).
"')";
1443 if ($this->
db->query($sql))
1448 dol_syslog(get_class($this).
"::AddNotification Error $result");
1468 public function generate($format =
'ALL', $executiondate =
'', $type =
'direct-debit')
1470 global $conf, $langs, $mysoc;
1476 dol_syslog(get_class($this).
"::generate build file=".$this->filename.
" type=".$type);
1478 $this->file = fopen($this->filename,
"w");
1479 if (empty($this->file))
1481 $this->error = $langs->trans(
'ErrorFailedToOpenFile', $this->filename);
1489 if ($mysoc->isInEEC())
1493 if ($type !=
'bank-transfer') {
1505 if (!empty($executiondate)) $date_actu = $executiondate;
1509 $fileDebiteurSection =
'';
1510 $fileEmetteurSection =
'';
1517 $sql =
"SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
1518 $sql .=
" pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
1519 $sql .=
" f.ref as fac, pf.fk_facture as idfac,";
1520 $sql .=
" rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
1522 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1523 $sql .=
" ".MAIN_DB_PREFIX.
"facture as f,";
1524 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture as pf,";
1525 $sql .=
" ".MAIN_DB_PREFIX.
"societe as soc,";
1526 $sql .=
" ".MAIN_DB_PREFIX.
"c_country as c,";
1527 $sql .=
" ".MAIN_DB_PREFIX.
"societe_rib as rib";
1528 $sql .=
" WHERE pl.fk_prelevement_bons = ".$this->id;
1529 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1530 $sql .=
" AND pf.fk_facture = f.rowid";
1531 $sql .=
" AND f.fk_soc = soc.rowid";
1532 $sql .=
" AND soc.fk_pays = c.rowid";
1533 $sql .=
" AND rib.fk_soc = f.fk_soc";
1534 $sql .=
" AND rib.default_rib = 1";
1535 $sql .=
" AND rib.type = 'ban'";
1541 $cachearraytotestduplicate = array();
1543 $num = $this->
db->num_rows(
$resql);
1546 $obj = $this->
db->fetch_object(
$resql);
1548 if (!empty($cachearraytotestduplicate[$obj->idfac])) {
1549 $this->error = $langs->trans(
'ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
1550 $this->invoice_in_error[$obj->idfac] = $this->error;
1554 $cachearraytotestduplicate[$obj->idfac] = $obj->rowid;
1556 $daterum = (!empty($obj->date_rum)) ? $this->
db->jdate($obj->date_rum) : $this->
db->jdate($obj->datec);
1557 $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);
1558 $this->total = $this->total + $obj->somme;
1561 $nbtotalDrctDbtTxInf = $i;
1563 $this->error = $this->
db->lasterror();
1564 fputs($this->file,
'ERROR DEBITOR '.$sql.$CrLf);
1571 $fileEmetteurSection .= $this->
EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
1578 fputs($this->file,
'<'.
'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.
'>'.$CrLf);
1579 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);
1580 fputs($this->file,
' <CstmrDrctDbtInitn>'.$CrLf);
1582 fputs($this->file,
' <GrpHdr>'.$CrLf);
1583 fputs($this->file,
' <MsgId>'.(
'DD/'.$dateTime_YMD.
'/REF'.$this->id).
'</MsgId>'.$CrLf);
1584 fputs($this->file,
' <CreDtTm>'.$dateTime_ECMA.
'</CreDtTm>'.$CrLf);
1585 fputs($this->file,
' <NbOfTxs>'.$i.
'</NbOfTxs>'.$CrLf);
1586 fputs($this->file,
' <CtrlSum>'.$this->total.
'</CtrlSum>'.$CrLf);
1587 fputs($this->file,
' <InitgPty>'.$CrLf);
1588 fputs($this->file,
' <Nm>'.strtoupper(
dol_string_unaccent($this->raison_sociale)).
'</Nm>'.$CrLf);
1589 fputs($this->file,
' <Id>'.$CrLf);
1590 fputs($this->file,
' <PrvtId>'.$CrLf);
1591 fputs($this->file,
' <Othr>'.$CrLf);
1592 fputs($this->file,
' <Id>'.$conf->global->PRELEVEMENT_ICS.
'</Id>'.$CrLf);
1593 fputs($this->file,
' </Othr>'.$CrLf);
1594 fputs($this->file,
' </PrvtId>'.$CrLf);
1595 fputs($this->file,
' </Id>'.$CrLf);
1596 fputs($this->file,
' </InitgPty>'.$CrLf);
1597 fputs($this->file,
' </GrpHdr>'.$CrLf);
1600 { fputs($this-> file, $fileEmetteurSection); }
1603 { fputs($this-> file, $fileDebiteurSection); }
1605 fputs($this->file,
' </PmtInf>'.$CrLf);
1606 fputs($this->file,
' </CstmrDrctDbtInitn>'.$CrLf);
1607 fputs($this->file,
'</Document>'.$CrLf);
1620 if (!empty($executiondate)) $date_actu = $executiondate;
1624 $fileCrediteurSection =
'';
1625 $fileEmetteurSection =
'';
1632 $sql =
"SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
1633 $sql .=
" pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
1634 $sql .=
" f.ref as fac, pf.fk_facture_fourn as idfac,";
1635 $sql .=
" rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
1637 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1638 $sql .=
" ".MAIN_DB_PREFIX.
"facture_fourn as f,";
1639 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture as pf,";
1640 $sql .=
" ".MAIN_DB_PREFIX.
"societe as soc,";
1641 $sql .=
" ".MAIN_DB_PREFIX.
"c_country as c,";
1642 $sql .=
" ".MAIN_DB_PREFIX.
"societe_rib as rib";
1643 $sql .=
" WHERE pl.fk_prelevement_bons = ".$this->id;
1644 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1645 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
1646 $sql .=
" AND f.fk_soc = soc.rowid";
1647 $sql .=
" AND soc.fk_pays = c.rowid";
1648 $sql .=
" AND rib.fk_soc = f.fk_soc";
1649 $sql .=
" AND rib.default_rib = 1";
1650 $sql .=
" AND rib.type = 'ban'";
1656 $cachearraytotestduplicate = array();
1658 $num = $this->
db->num_rows(
$resql);
1661 $obj = $this->
db->fetch_object(
$resql);
1663 if (!empty($cachearraytotestduplicate[$obj->idfac])) {
1664 $this->error = $langs->trans(
'ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
1665 $this->invoice_in_error[$obj->idfac] = $this->error;
1669 $cachearraytotestduplicate[$obj->idfac] = $obj->rowid;
1671 $daterum = (!empty($obj->date_rum)) ? $this->
db->jdate($obj->date_rum) : $this->
db->jdate($obj->datec);
1672 $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);
1673 $this->total = $this->total + $obj->somme;
1676 $nbtotalDrctDbtTxInf = $i;
1678 $this->error = $this->
db->lasterror();
1679 fputs($this->file,
'ERROR CREDITOR '.$sql.$CrLf);
1684 if ($result != -2) {
1685 $fileEmetteurSection .= $this->
EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
1692 fputs($this->file,
'<'.
'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.
'>'.$CrLf);
1693 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);
1694 fputs($this->file,
' <CstmrCdtTrfInitn>'.$CrLf);
1696 fputs($this->file,
' <GrpHdr>'.$CrLf);
1697 fputs($this->file,
' <MsgId>'.(
'TRF/'.$dateTime_YMD.
'/REF'.$this->id).
'</MsgId>'.$CrLf);
1698 fputs($this->file,
' <CreDtTm>'.$dateTime_ECMA.
'</CreDtTm>'.$CrLf);
1699 fputs($this->file,
' <NbOfTxs>'.$i.
'</NbOfTxs>'.$CrLf);
1700 fputs($this->file,
' <CtrlSum>'.$this->total.
'</CtrlSum>'.$CrLf);
1701 fputs($this->file,
' <InitgPty>'.$CrLf);
1702 fputs($this->file,
' <Nm>'.strtoupper(
dol_string_unaccent($this->raison_sociale)).
'</Nm>'.$CrLf);
1703 fputs($this->file,
' <Id>'.$CrLf);
1704 fputs($this->file,
' <PrvtId>'.$CrLf);
1705 fputs($this->file,
' <Othr>'.$CrLf);
1706 fputs($this->file,
' <Id>'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.
'</Id>'.$CrLf);
1707 fputs($this->file,
' </Othr>'.$CrLf);
1708 fputs($this->file,
' </PrvtId>'.$CrLf);
1709 fputs($this->file,
' </Id>'.$CrLf);
1710 fputs($this->file,
' </InitgPty>'.$CrLf);
1711 fputs($this->file,
' </GrpHdr>'.$CrLf);
1714 { fputs($this-> file, $fileEmetteurSection); }
1717 { fputs($this-> file, $fileCrediteurSection); }
1719 fputs($this->file,
' </PmtInf>'.$CrLf);
1720 fputs($this->file,
' </CstmrCdtTrfInitn>'.$CrLf);
1721 fputs($this->file,
'</Document>'.$CrLf);
1728 if ($type !=
'bank-transfer') {
1729 $sql =
"SELECT pl.amount";
1731 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1732 $sql .=
" ".MAIN_DB_PREFIX.
"facture as f,";
1733 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture as pf";
1734 $sql .=
" WHERE pl.fk_prelevement_bons = ".$this->id;
1735 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1736 $sql .=
" AND pf.fk_facture = f.rowid";
1743 $num = $this->
db->num_rows(
$resql);
1747 $obj = $this->
db->fetch_object(
$resql);
1748 $this->total = $this->total + $obj->amount;
1757 $sql =
"SELECT pl.amount";
1759 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
1760 $sql .=
" ".MAIN_DB_PREFIX.
"facture_fourn as f,";
1761 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture as pf";
1762 $sql .=
" WHERE pl.fk_prelevement_bons = ".$this->id;
1763 $sql .=
" AND pl.rowid = pf.fk_prelevement_lignes";
1764 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
1771 $num = $this->
db->num_rows(
$resql);
1775 $obj = $this->
db->fetch_object(
$resql);
1776 $this->total = $this->total + $obj->amount;
1786 $langs->load(
'withdrawals');
1789 fputs($this->file, $langs->transnoentitiesnoconv(
'WithdrawalFileNotCapable', $mysoc->country_code));
1792 fclose($this->file);
1793 if (!empty($conf->global->MAIN_UMASK)) {
1794 @chmod($this->file, octdec($conf->global->MAIN_UMASK));
1813 return $pre.
'-'.$row_code_client.
'-'.$row_drum.
'-'.date(
'U', $row_datec);
1834 public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom =
'', $type =
'direct-debit')
1837 fputs($this->file,
"06");
1838 fputs($this->file,
"08");
1840 fputs($this->file,
" ");
1842 fputs($this->file, $this->emetteur_ics);
1846 fputs($this->file,
" ");
1847 fputs($this->file, strftime(
"%d%m", $this->date_echeance));
1848 fputs($this->file, substr(strftime(
"%y", $this->date_echeance), 1));
1852 fputs($this->file, substr(strtoupper($client_nom).
" ", 0, 24));
1855 $domiciliation = strtr($rib_dom, array(
" " =>
"-", CHR(13) =>
" ", CHR(10) =>
""));
1856 fputs($this->file, substr($domiciliation.
" ", 0, 24));
1860 fputs($this->file, substr(
" ", 0, 8));
1864 fputs($this->file, $rib_guichet);
1868 fputs($this->file, substr(
"000000000000000".$rib_number, -11));
1872 $montant = (round($amount, 2) * 100);
1874 fputs($this->file, substr(
"000000000000000".$montant, -16));
1878 fputs($this->file, substr(
"*_".$ref.
"_RDVnet".$rowid.
" ", 0, 31));
1882 fputs($this->file, $rib_banque);
1886 fputs($this->file, substr(
" ", 0, 5));
1888 fputs($this->file,
"\n");
1916 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')
1921 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1924 $Rowing = sprintf(
"%010d", $row_idfac);
1928 $Rum = empty($row_rum) ? $this->
buildRumNumber($row_code_client, $row_datec, $row_drum) : $row_rum;
1933 if ($type !=
'bank-transfer') {
1936 $XML_DEBITOR .=
' <DrctDbtTxInf>'.$CrLf;
1937 $XML_DEBITOR .=
' <PmtId>'.$CrLf;
1939 $XML_DEBITOR .=
' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END !=
"") ? $conf->global->PRELEVEMENT_END_TO_END : (
'AS-'.dol_trunc($row_ref, 20)).
'-'.$Rowing).
'</EndToEndId>'.$CrLf;
1940 $XML_DEBITOR .=
' </PmtId>'.$CrLf;
1941 $XML_DEBITOR .=
' <InstdAmt Ccy="EUR">'.round($row_somme, 2).
'</InstdAmt>'.$CrLf;
1942 $XML_DEBITOR .=
' <DrctDbtTx>'.$CrLf;
1943 $XML_DEBITOR .=
' <MndtRltdInf>'.$CrLf;
1944 $XML_DEBITOR .=
' <MndtId>'.$Rum.
'</MndtId>'.$CrLf;
1945 $XML_DEBITOR .=
' <DtOfSgntr>'.$DtOfSgntr.
'</DtOfSgntr>'.$CrLf;
1946 $XML_DEBITOR .=
' <AmdmntInd>false</AmdmntInd>'.$CrLf;
1947 $XML_DEBITOR .=
' </MndtRltdInf>'.$CrLf;
1948 $XML_DEBITOR .=
' </DrctDbtTx>'.$CrLf;
1949 $XML_DEBITOR .=
' <DbtrAgt>'.$CrLf;
1950 $XML_DEBITOR .=
' <FinInstnId>'.$CrLf;
1951 $XML_DEBITOR .=
' <BIC>'.$row_bic.
'</BIC>'.$CrLf;
1952 $XML_DEBITOR .=
' </FinInstnId>'.$CrLf;
1953 $XML_DEBITOR .=
' </DbtrAgt>'.$CrLf;
1954 $XML_DEBITOR .=
' <Dbtr>'.$CrLf;
1955 $XML_DEBITOR .=
' <Nm>'.dolEscapeXML(strtoupper(
dol_string_unaccent($row_nom))).
'</Nm>'.$CrLf;
1956 $XML_DEBITOR .=
' <PstlAdr>'.$CrLf;
1957 $XML_DEBITOR .=
' <Ctry>'.$row_country_code.
'</Ctry>'.$CrLf;
1958 $addressline1 =
dol_string_unaccent(strtr($row_address, array(CHR(13) =>
", ", CHR(10) =>
"")));
1959 $addressline2 =
dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ?
' ' :
''.$row_town), array(CHR(13) =>
", ", CHR(10) =>
"")));
1960 if (trim($addressline1)) $XML_DEBITOR .=
' <AdrLine>'.dolEscapeXML(
dol_trunc($addressline1, 70,
'right',
'UTF-8',
true)).
'</AdrLine>'.$CrLf;
1961 if (trim($addressline2)) $XML_DEBITOR .=
' <AdrLine>'.dolEscapeXML(
dol_trunc($addressline2, 70,
'right',
'UTF-8',
true)).
'</AdrLine>'.$CrLf;
1962 $XML_DEBITOR .=
' </PstlAdr>'.$CrLf;
1963 $XML_DEBITOR .=
' </Dbtr>'.$CrLf;
1964 $XML_DEBITOR .=
' <DbtrAcct>'.$CrLf;
1965 $XML_DEBITOR .=
' <Id>'.$CrLf;
1966 $XML_DEBITOR .=
' <IBAN>'.preg_replace(
'/\s/',
'', $row_iban).
'</IBAN>'.$CrLf;
1967 $XML_DEBITOR .=
' </Id>'.$CrLf;
1968 $XML_DEBITOR .=
' </DbtrAcct>'.$CrLf;
1969 $XML_DEBITOR .=
' <RmtInf>'.$CrLf;
1971 $XML_DEBITOR .=
' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD !=
"") ? $conf->global->PRELEVEMENT_USTRD :
dol_trunc($row_ref, 135)).
'</Ustrd>'.$CrLf;
1972 $XML_DEBITOR .=
' </RmtInf>'.$CrLf;
1973 $XML_DEBITOR .=
' </DrctDbtTxInf>'.$CrLf;
1974 return $XML_DEBITOR;
1978 $XML_CREDITOR .=
' <CdtTrfTxInf>'.$CrLf;
1979 $XML_CREDITOR .=
' <PmtId>'.$CrLf;
1981 $XML_CREDITOR .=
' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END !=
"") ? $conf->global->PRELEVEMENT_END_TO_END : (
'AS-'.dol_trunc($row_ref, 20)).
'-'.$Rowing).
'</EndToEndId>'.$CrLf;
1982 $XML_CREDITOR .=
' </PmtId>'.$CrLf;
1983 $XML_CREDITOR .=
' <Amt>'.$CrLf;
1984 $XML_CREDITOR .=
' <InstdAmt Ccy="EUR">'.round($row_somme, 2).
'</InstdAmt>'.$CrLf;
1985 $XML_CREDITOR .=
' </Amt>'.$CrLf;
1996 $XML_CREDITOR .=
' <CdtrAgt>'.$CrLf;
1997 $XML_CREDITOR .=
' <FinInstnId>'.$CrLf;
1998 $XML_CREDITOR .=
' <BIC>'.$row_bic.
'</BIC>'.$CrLf;
1999 $XML_CREDITOR .=
' </FinInstnId>'.$CrLf;
2000 $XML_CREDITOR .=
' </CdtrAgt>'.$CrLf;
2001 $XML_CREDITOR .=
' <Cdtr>'.$CrLf;
2002 $XML_CREDITOR .=
' <Nm>'.dolEscapeXML(strtoupper(
dol_string_unaccent($row_nom))).
'</Nm>'.$CrLf;
2003 $XML_CREDITOR .=
' <PstlAdr>'.$CrLf;
2004 $XML_CREDITOR .=
' <Ctry>'.$row_country_code.
'</Ctry>'.$CrLf;
2005 $addressline1 =
dol_string_unaccent(strtr($row_address, array(CHR(13) =>
", ", CHR(10) =>
"")));
2006 $addressline2 =
dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ?
' ' :
''.$row_town), array(CHR(13) =>
", ", CHR(10) =>
"")));
2007 if (trim($addressline1)) $XML_CREDITOR .=
' <AdrLine>'.dolEscapeXML(
dol_trunc($addressline1, 70,
'right',
'UTF-8',
true)).
'</AdrLine>'.$CrLf;
2008 if (trim($addressline2)) $XML_CREDITOR .=
' <AdrLine>'.dolEscapeXML(
dol_trunc($addressline2, 70,
'right',
'UTF-8',
true)).
'</AdrLine>'.$CrLf;
2009 $XML_CREDITOR .=
' </PstlAdr>'.$CrLf;
2010 $XML_CREDITOR .=
' </Cdtr>'.$CrLf;
2011 $XML_CREDITOR .=
' <CdtrAcct>'.$CrLf;
2012 $XML_CREDITOR .=
' <Id>'.$CrLf;
2013 $XML_CREDITOR .=
' <IBAN>'.preg_replace(
'/\s/',
'', $row_iban).
'</IBAN>'.$CrLf;
2014 $XML_CREDITOR .=
' </Id>'.$CrLf;
2015 $XML_CREDITOR .=
' </CdtrAcct>'.$CrLf;
2016 $XML_CREDITOR .=
' <RmtInf>'.$CrLf;
2018 $XML_CREDITOR .=
' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD !=
"") ? $conf->global->PRELEVEMENT_USTRD :
dol_trunc($row_ref, 135)).
'</Ustrd>'.$CrLf;
2019 $XML_CREDITOR .=
' </RmtInf>'.$CrLf;
2020 $XML_CREDITOR .=
' </CdtTrfTxInf>'.$CrLf;
2021 return $XML_CREDITOR;
2037 fputs($this->file,
"03");
2038 fputs($this->file,
"08");
2040 fputs($this->file,
" ");
2042 fputs($this->file, $this->emetteur_ics);
2046 fputs($this->file,
" ");
2047 fputs($this->file, strftime(
"%d%m", $this->date_echeance));
2048 fputs($this->file, substr(strftime(
"%y", $this->date_echeance), 1));
2052 fputs($this->file, substr($this->raison_sociale.
" ", 0, 24));
2056 fputs($this->file, substr($this->reference_remise.
" ", 0, 7));
2060 fputs($this->file, substr(
" ", 0, 17));
2064 fputs($this->file, substr(
" ", 0, 2));
2065 fputs($this->file,
"E");
2066 fputs($this->file, substr(
" ", 0, 5));
2070 fputs($this->file, $this->emetteur_code_guichet);
2074 fputs($this->file, substr(
"000000000000000".$this->emetteur_numero_compte, -11));
2078 fputs($this->file, substr(
" ", 0, 16));
2082 fputs($this->file, substr(
" ", 0, 31));
2086 fputs($this->file, $this->emetteur_code_banque);
2090 fputs($this->file, substr(
" ", 0, 5));
2092 fputs($this->file,
"\n");
2110 public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf =
'\n', $format =
'FRST', $type =
'direct-debit')
2122 $id = ($type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
2124 if ($account->fetch($id) > 0)
2126 $this->emetteur_code_banque = $account->code_banque;
2127 $this->emetteur_code_guichet = $account->code_guichet;
2128 $this->emetteur_numero_compte = $account->number;
2129 $this->emetteur_number_key = $account->cle_rib;
2130 $this->emetteur_iban = $account->iban;
2131 $this->emetteur_bic = $account->bic;
2133 $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS;
2135 $this->raison_sociale = $account->proprio;
2139 $sql =
"SELECT rowid, ref";
2141 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
2142 $sql .=
" WHERE pb.rowid = ".$this->id;
2147 $obj = $this->
db->fetch_object(
$resql);
2149 $country = explode(
':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY);
2150 $IdBon = sprintf(
"%05d", $obj->rowid);
2151 $RefBon = $obj->ref;
2153 if ($type !=
'bank-transfer') {
2155 $XML_SEPA_INFO =
'';
2156 $XML_SEPA_INFO .=
' <PmtInf>'.$CrLf;
2157 $XML_SEPA_INFO .=
' <PmtInfId>'.(
'DD/'.$dateTime_YMD.
'/ID'.$IdBon.
'-'.$RefBon).
'</PmtInfId>'.$CrLf;
2158 $XML_SEPA_INFO .=
' <PmtMtd>DD</PmtMtd>'.$CrLf;
2159 $XML_SEPA_INFO .=
' <NbOfTxs>'.$nombre.
'</NbOfTxs>'.$CrLf;
2160 $XML_SEPA_INFO .=
' <CtrlSum>'.$total.
'</CtrlSum>'.$CrLf;
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;
2170 $XML_SEPA_INFO .=
' <ReqdColltnDt>'.$dateTime_ETAD.
'</ReqdColltnDt>'.$CrLf;
2171 $XML_SEPA_INFO .=
' <Cdtr>'.$CrLf;
2172 $XML_SEPA_INFO .=
' <Nm>'.strtoupper(
dol_string_unaccent($this->raison_sociale)).
'</Nm>'.$CrLf;
2173 $XML_SEPA_INFO .=
' <PstlAdr>'.$CrLf;
2174 $XML_SEPA_INFO .=
' <Ctry>'.$country[1].
'</Ctry>'.$CrLf;
2175 $addressline1 =
dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) =>
", ", CHR(10) =>
"")));
2176 $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) =>
"")));
2177 if ($addressline1) $XML_SEPA_INFO .=
' <AdrLine>'.$addressline1.
'</AdrLine>'.$CrLf;
2178 if ($addressline2) $XML_SEPA_INFO .=
' <AdrLine>'.$addressline2.
'</AdrLine>'.$CrLf;
2179 $XML_SEPA_INFO .=
' </PstlAdr>'.$CrLf;
2180 $XML_SEPA_INFO .=
' </Cdtr>'.$CrLf;
2181 $XML_SEPA_INFO .=
' <CdtrAcct>'.$CrLf;
2182 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2183 $XML_SEPA_INFO .=
' <IBAN>'.preg_replace(
'/\s/',
'', $this->emetteur_iban).
'</IBAN>'.$CrLf;
2184 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2185 $XML_SEPA_INFO .=
' </CdtrAcct>'.$CrLf;
2186 $XML_SEPA_INFO .=
' <CdtrAgt>'.$CrLf;
2187 $XML_SEPA_INFO .=
' <FinInstnId>'.$CrLf;
2188 $XML_SEPA_INFO .=
' <BIC>'.$this->emetteur_bic.
'</BIC>'.$CrLf;
2189 $XML_SEPA_INFO .=
' </FinInstnId>'.$CrLf;
2190 $XML_SEPA_INFO .=
' </CdtrAgt>'.$CrLf;
2199 $XML_SEPA_INFO .=
' <ChrgBr>SLEV</ChrgBr>'.$CrLf;
2200 $XML_SEPA_INFO .=
' <CdtrSchmeId>'.$CrLf;
2201 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2202 $XML_SEPA_INFO .=
' <PrvtId>'.$CrLf;
2203 $XML_SEPA_INFO .=
' <Othr>'.$CrLf;
2204 $XML_SEPA_INFO .=
' <Id>'.$this->emetteur_ics.
'</Id>'.$CrLf;
2205 $XML_SEPA_INFO .=
' <SchmeNm>'.$CrLf;
2206 $XML_SEPA_INFO .=
' <Prtry>SEPA</Prtry>'.$CrLf;
2207 $XML_SEPA_INFO .=
' </SchmeNm>'.$CrLf;
2208 $XML_SEPA_INFO .=
' </Othr>'.$CrLf;
2209 $XML_SEPA_INFO .=
' </PrvtId>'.$CrLf;
2210 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2211 $XML_SEPA_INFO .=
' </CdtrSchmeId>'.$CrLf;
2214 $XML_SEPA_INFO =
'';
2215 $XML_SEPA_INFO .=
' <PmtInf>'.$CrLf;
2216 $XML_SEPA_INFO .=
' <PmtInfId>'.(
'TRF/'.$dateTime_YMD.
'/ID'.$IdBon.
'-'.$RefBon).
'</PmtInfId>'.$CrLf;
2217 $XML_SEPA_INFO .=
' <PmtMtd>TRF</PmtMtd>'.$CrLf;
2219 $XML_SEPA_INFO .=
' <NbOfTxs>'.$nombre.
'</NbOfTxs>'.$CrLf;
2220 $XML_SEPA_INFO .=
' <CtrlSum>'.$total.
'</CtrlSum>'.$CrLf;
2232 $XML_SEPA_INFO .=
' <ReqdExctnDt>'.dol_print_date($dateTime_ETAD,
'dayrfc').
'</ReqdExctnDt>'.$CrLf;
2233 $XML_SEPA_INFO .=
' <Dbtr>'.$CrLf;
2234 $XML_SEPA_INFO .=
' <Nm>'.strtoupper(
dol_string_unaccent($this->raison_sociale)).
'</Nm>'.$CrLf;
2235 $XML_SEPA_INFO .=
' <PstlAdr>'.$CrLf;
2236 $XML_SEPA_INFO .=
' <Ctry>'.$country[1].
'</Ctry>'.$CrLf;
2237 $addressline1 =
dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) =>
", ", CHR(10) =>
"")));
2238 $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) =>
"")));
2239 if ($addressline1) $XML_SEPA_INFO .=
' <AdrLine>'.$addressline1.
'</AdrLine>'.$CrLf;
2240 if ($addressline2) $XML_SEPA_INFO .=
' <AdrLine>'.$addressline2.
'</AdrLine>'.$CrLf;
2241 $XML_SEPA_INFO .=
' </PstlAdr>'.$CrLf;
2242 $XML_SEPA_INFO .=
' </Dbtr>'.$CrLf;
2243 $XML_SEPA_INFO .=
' <DbtrAcct>'.$CrLf;
2244 $XML_SEPA_INFO .=
' <Id>'.$CrLf;
2245 $XML_SEPA_INFO .=
' <IBAN>'.preg_replace(
'/\s/',
'', $this->emetteur_iban).
'</IBAN>'.$CrLf;
2246 $XML_SEPA_INFO .=
' </Id>'.$CrLf;
2247 $XML_SEPA_INFO .=
' </DbtrAcct>'.$CrLf;
2248 $XML_SEPA_INFO .=
' <DbtrAgt>'.$CrLf;
2249 $XML_SEPA_INFO .=
' <FinInstnId>'.$CrLf;
2250 $XML_SEPA_INFO .=
' <BIC>'.$this->emetteur_bic.
'</BIC>'.$CrLf;
2251 $XML_SEPA_INFO .=
' </FinInstnId>'.$CrLf;
2252 $XML_SEPA_INFO .=
' </DbtrAgt>'.$CrLf;
2261 $XML_SEPA_INFO .=
' <ChrgBr>SLEV</ChrgBr>'.$CrLf;
2276 fputs($this->file,
'INCORRECT EMETTEUR '.$XML_SEPA_INFO.$CrLf);
2278 return $XML_SEPA_INFO;
2291 fputs($this->file,
"08");
2292 fputs($this->file,
"08");
2294 fputs($this->file,
" ");
2296 fputs($this->file, $this->emetteur_ics);
2300 fputs($this->file, substr(
" ", 0, 12));
2305 fputs($this->file, substr(
" ", 0, 24));
2309 fputs($this->file, substr(
" ", 0, 24));
2313 fputs($this->file, substr(
" ", 0, 8));
2317 fputs($this->file, substr(
" ", 0, 5));
2321 fputs($this->file, substr(
" ", 0, 11));
2325 $montant = ($total * 100);
2327 fputs($this->file, substr(
"000000000000000".$montant, -16));
2331 fputs($this->file, substr(
" ", 0, 31));
2335 fputs($this->file, substr(
" ", 0, 5));
2339 fputs($this->file, substr(
" ", 0, 5));
2341 fputs($this->file,
"\n");
2366 if (empty($this->labelStatus) || empty($this->labelStatusShort))
2370 $this->labelStatus[self::STATUS_DRAFT] = $langs->trans(
'StatusWaiting');
2371 $this->labelStatus[self::STATUS_TRANSFERED] = $langs->trans(
'StatusTrans');
2372 $this->labelStatus[self::STATUS_CREDITED] = $langs->trans(
'StatusCredited');
2373 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans(
'StatusWaiting');
2374 $this->labelStatusShort[self::STATUS_TRANSFERED] = $langs->trans(
'StatusTrans');
2375 $this->labelStatusShort[self::STATUS_CREDITED] = $langs->trans(
'StatusCredited');
2378 $statusType =
'status1';
2379 if ($status == self::STATUS_TRANSFERED) $statusType =
'status3';
2380 if ($status == self::STATUS_CREDITED) $statusType =
'status6';
2382 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
Add line to withdrawal.
EnregTotal($total)
Write end.
AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type= 'debit-order')
Add invoice to withdrawal.
dol_substr($string, $start, $length, $stringencoding= '', $trunconbytes=0)
Make a substring.
__construct($db)
Constructor.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
nbOfInvoiceToPay($mode= 'direct-debit')
Get number of invoices waiting for payment.
EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom= '', $type= 'direct-debit')
Write recipient of request (customer)
SommeAPrelever($mode= 'direct-debit')
Returns amount waiting for direct debit payment or credit transfer payment.
dol_now($mode= 'auto')
Return date for now.
set_credite()
Set credite and set status of linked invoices.
static buildRumNumber($row_code_client, $row_datec, $row_drum)
Generate dynamically a RUM number for a customer bank account.
Class to manage bank accounts description of third parties.
set_infotrans($user, $date, $method)
Set withdrawal to transmited status.
AddNotification($db, $user, $action)
Add a notification.
Class to manage suppliers invoices.
set_infocredit($user, $date)
Set direct debit or credit transfer order to "paid" status.
getListInvoices($amounts=0)
Get invoice list.
NbFactureAPrelever($type= 'direct-debit')
Get number of invoices to pay.
$conf db
API class for accounts.
Class to manage bank accounts.
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_string_nospecial($str, $newstr= '_', $badcharstoreplace= '')
Clean a string from all punctuation characters to use it as a ref or login.
getNomUrl($withpicto=0, $option= '', $notooltip=0, $morecss= '', $save_lastsearch_value=-1)
Returns clickable name (with picto)
Class to manage third parties objects (customers, suppliers, prospects...)
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)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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 ...
Class to manage withdrawal receipts.
getErrorString($error)
Return error string.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
generate($format= 'ALL', $executiondate= '', $type= 'direct-debit')
Generate a direct debit or credit transfer file.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
getLibStatut($mode=0)
Return status label of object.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
EnregEmetteur($type= 'direct-debit')
Write sender of request (me).
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.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
Class to manage invoices.
DeleteNotification($user, $action)
Delete a notification.
EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf= '\n', $format= 'FRST', $type= 'direct-debit')
Write sender of request (me).
fetch($rowid, $ref= '')
Get object and lines from database.
Class to manage payments for supplier invoices.
DeleteNotificationById($rowid)
Delete a notification def by id.
LibStatut($status, $mode=0)
Return status label for a status.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
if(!empty($search_group)) natural_search(array("g.nom"g note
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.