37require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
48 public $element =
'bank_account';
53 public $table_element =
'bank_account';
58 public $picto =
'account';
107 public $clos = self::STATUS_OPEN;
137 public $code_guichet;
175 public $pti_in_ctti = 0;
182 public $sepa_category_purpose =
'CORE';
189 public $sepa_local_instrument =
'CORE';
209 public $owner_address;
225 public $owner_country_id;
229 public $owner_country_code;
237 public $domiciliation;
266 public $type_lib = array();
272 public $account_number;
277 public $fk_accountancy_journal;
282 public $accountancy_journal;
288 public $currency_code;
296 public $account_currency_code;
346 public $ics_transfer;
382 public $fields = array(
383 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
384 'ref' => array(
'type' =>
'varchar(12)',
'label' =>
'Ref',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'showoncombobox' => 1,
'position' => 25),
385 'label' => array(
'type' =>
'varchar(30)',
'label' =>
'Label',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 30),
386 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 35,
'index' => 1),
387 'bank' => array(
'type' =>
'varchar(60)',
'label' =>
'Bank',
'enabled' => 1,
'visible' => -1,
'position' => 40),
388 'code_banque' => array(
'type' =>
'varchar(128)',
'label' =>
'Code banque',
'enabled' => 1,
'visible' => -1,
'position' => 45),
389 'code_guichet' => array(
'type' =>
'varchar(6)',
'label' =>
'Code guichet',
'enabled' => 1,
'visible' => -1,
'position' => 50),
390 'number' => array(
'type' =>
'varchar(255)',
'label' =>
'Number',
'enabled' => 1,
'visible' => -1,
'position' => 55),
391 'cle_rib' => array(
'type' =>
'varchar(5)',
'label' =>
'Cle rib',
'enabled' => 1,
'visible' => -1,
'position' => 60),
392 'bic' => array(
'type' =>
'varchar(11)',
'label' =>
'Bic',
'enabled' => 1,
'visible' => -1,
'position' => 65),
393 'iban_prefix' => array(
'type' =>
'varchar(34)',
'label' =>
'Iban prefix',
'enabled' => 1,
'visible' => -1,
'position' => 70),
394 'country_iban' => array(
'type' =>
'varchar(2)',
'label' =>
'Country iban',
'enabled' => 1,
'visible' => -1,
'position' => 75),
395 'cle_iban' => array(
'type' =>
'varchar(2)',
'label' =>
'Cle iban',
'enabled' => 1,
'visible' => -1,
'position' => 80),
396 'domiciliation' => array(
'type' =>
'varchar(255)',
'label' =>
'Domiciliation',
'enabled' => 1,
'visible' => -1,
'position' => 85),
397 'state_id' => array(
'type' =>
'integer',
'label' =>
'StateId',
'enabled' => 1,
'visible' => -1,
'position' => 90),
398 'fk_pays' => array(
'type' =>
'integer',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 95),
399 'proprio' => array(
'type' =>
'varchar(60)',
'label' =>
'Proprio',
'enabled' => 1,
'visible' => -1,
'position' => 100),
400 'owner_address' => array(
'type' =>
'varchar(255)',
'label' =>
'Owner address',
'enabled' => 1,
'visible' => -1,
'position' => 105),
401 'owner_zip' => array(
'type' =>
'varchar(25)',
'label' =>
'Owner zip',
'enabled' => 1,
'visible' => -1,
'position' => 106),
402 'owner_town' => array(
'type' =>
'varchar(50)',
'label' =>
'Owner town',
'enabled' => 1,
'visible' => -1,
'position' => 107),
403 'owner_country_id' => array(
'type' =>
'integer',
'label' =>
'Owner country',
'enabled' => 1,
'visible' => -1,
'position' => 108),
404 'courant' => array(
'type' =>
'smallint(6)',
'label' =>
'Courant',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 110),
405 'clos' => array(
'type' =>
'smallint(6)',
'label' =>
'Clos',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 115),
406 'rappro' => array(
'type' =>
'smallint(6)',
'label' =>
'Rappro',
'enabled' => 1,
'visible' => -1,
'position' => 120),
407 'url' => array(
'type' =>
'varchar(128)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 125),
408 'account_number' => array(
'type' =>
'varchar(32)',
'label' =>
'Account number',
'enabled' => 1,
'visible' => -1,
'position' => 130),
409 'fk_accountancy_journal' => array(
'type' =>
'integer',
'label' =>
'Accountancy journal ID',
'enabled' => 1,
'visible' => -1,
'position' => 132),
410 'accountancy_journal' => array(
'type' =>
'varchar(20)',
'label' =>
'Accountancy journal',
'enabled' => 1,
'visible' => -1,
'position' => 135),
411 'currency_code' => array(
'type' =>
'varchar(3)',
'label' =>
'Currency code',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 140),
412 'min_allowed' => array(
'type' =>
'integer',
'label' =>
'Min allowed',
'enabled' => 1,
'visible' => -1,
'position' => 145),
413 'min_desired' => array(
'type' =>
'integer',
'label' =>
'Min desired',
'enabled' => 1,
'visible' => -1,
'position' => 150),
414 'comment' => array(
'type' =>
'text',
'label' =>
'Comment',
'enabled' => 1,
'visible' => -1,
'position' => 155),
415 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 156),
416 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 157),
417 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -1,
'position' => 160),
418 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -2,
'notnull' => -1,
'position' => 165),
419 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 170),
420 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 175),
421 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 180),
422 'extraparams' => array(
'type' =>
'varchar(255)',
'label' =>
'Extraparams',
'enabled' => 1,
'visible' => -1,
'position' => 185),
440 const STATUS_OPEN = 0;
441 const STATUS_CLOSED = 1;
467 $this->ismultientitymanaged = 1;
471 $this->type_lib = array(
472 self::TYPE_SAVINGS => $langs->transnoentitiesnoconv(
"BankType0"),
473 self::TYPE_CURRENT => $langs->transnoentitiesnoconv(
"BankType1"),
474 self::TYPE_CASH => $langs->transnoentitiesnoconv(
"BankType2"),
477 $this->labelStatus = array(
478 self::STATUS_OPEN => $langs->transnoentitiesnoconv(
"StatusAccountOpened"),
479 self::STATUS_CLOSED => $langs->transnoentitiesnoconv(
"StatusAccountClosed")
491 $code = strtoupper(trim((
string) $this->sepa_category_purpose));
492 return (in_array($code, self::SEPA_CATEGORY_PURPOSES) ? $code :
'CORE');
503 $code = strtoupper(trim((
string) $this->sepa_local_instrument));
504 return (in_array($code, self::SEPA_LOCAL_INSTRUMENTS) ? $code :
'CORE');
516 if ($val ==
'BankCode') {
517 $string .= $this->code_banque.
' ';
518 } elseif ($val ==
'BankAccountNumber') {
519 $string .= $this->number.
' ';
520 } elseif ($val ==
'DeskCode') {
521 $string .= $this->code_guichet.
' ';
522 } elseif ($val ==
'BankAccountNumberKey') {
523 $string .= $this->cle_rib.
' ';
524 } elseif ($val ==
'BIC') {
525 $string .= $this->bic.
' ';
526 } elseif ($val ==
'IBAN') {
527 $string .= $this->iban.
' ';
531 return trim($string);
542 if (empty($this->rappro)) {
571 $sqlcheck =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"bank_url";
572 $sqlcheck .=
" WHERE fk_bank = ".((int) $line_id);
573 $sqlcheck .=
" AND url_id = ".((int) $url_id);
574 $sqlcheck .=
" AND type = '".$this->db->escape($type).
"'";
575 $resqlcheck = $this->db->query($sqlcheck);
577 $obj = $this->db->fetch_object($resqlcheck);
579 $this->db->free($resqlcheck);
580 return (
int) $obj->rowid;
582 $this->db->free($resqlcheck);
585 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
591 $sql .=
") VALUES (";
592 $sql .= ((int) $line_id);
593 $sql .=
", ".((int) $url_id);
594 $sql .=
", '".$this->db->escape($url).
"'";
595 $sql .=
", '".$this->db->escape($label).
"'";
596 $sql .=
", '".$this->db->escape($type).
"'";
599 dol_syslog(get_class($this).
"::add_url_line", LOG_DEBUG);
600 if ($this->db->query($sql)) {
601 $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bank_url");
604 $this->
error = $this->db->lasterror();
619 public function get_url($fk_bank = 0, $url_id = 0, $type =
'')
625 if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) {
626 $this->
error =
"ErrorBadParameter";
630 $sql =
"SELECT fk_bank, url_id, url, label, type";
631 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_url";
633 $sql .=
" WHERE fk_bank = ".((int) $fk_bank);
635 $sql .=
" WHERE url_id = ".((int) $url_id).
" AND type = '".$this->db->escape($type).
"'";
637 $sql .=
" ORDER BY type, label";
639 dol_syslog(get_class($this).
"::get_url", LOG_DEBUG);
640 $result = $this->db->query($sql);
643 $num = $this->db->num_rows($result);
645 $obj = $this->db->fetch_object($result);
647 $lines[$i][0] = $obj->url;
648 $lines[$i][1] = $obj->url_id;
649 $lines[$i][2] = $obj->label;
650 $lines[$i][3] = $obj->type;
652 $lines[$i][
'url'] = $obj->url;
653 $lines[$i][
'url_id'] = $obj->url_id;
654 $lines[$i][
'label'] = $obj->label;
655 $lines[$i][
'type'] = $obj->type;
656 $lines[$i][
'fk_bank'] = $obj->fk_bank;
660 dol_print_error($this->db);
685 public function addline($date, $oper, $label, $amount, $num_chq, $categorie,
User $user, $emetteur =
'', $banque =
'', $accountancycode =
'', $datev =
null, $num_releve =
'', $amount_main_currency =
null, $note_private =
'')
690 if (is_numeric($oper)) {
691 dol_syslog(__METHOD__.
": using numeric operations is deprecated", LOG_WARNING);
694 if (empty($this->
id) && !empty($this->rowid)) {
695 $this->
id = $this->rowid;
699 $emetteur = trim($emetteur);
700 $banque = trim($banque);
701 $label = trim($label);
705 if (is_numeric($oper)) {
706 $sql =
"SELECT code FROM ".MAIN_DB_PREFIX.
"c_paiement";
707 $sql .=
" WHERE id = ".((int) $oper);
708 $sql .=
" AND entity IN (".getEntity(
'c_paiement').
")";
709 $resql = $this->db->query($sql);
711 $obj = $this->db->fetch_object($resql);
714 dol_print_error($this->db,
'Failed to get payment type code');
721 $this->
error = $langs->trans(
"OperNotDefined");
725 $this->
error = $langs->trans(
"ThisIdNotDefined");
729 $this->
error =
"ErrorCashAccountAcceptsOnlyCashMoney";
735 if (is_null($datev) || empty($datev)) {
740 $accline->datec = $now;
741 $accline->dateo = $date;
742 $accline->datev = $datev;
743 $accline->label = $label;
744 $accline->amount = $amount;
745 $accline->amount_main_currency = $amount_main_currency;
746 $accline->fk_user_author = $user->id;
747 $accline->fk_account = $this->id;
748 $accline->fk_type = $oper;
749 $accline->numero_compte = $accountancycode;
750 $accline->num_releve = $num_releve;
751 $accline->note_private = $note_private;
754 $accline->num_chq = $num_chq;
758 $accline->emetteur = $emetteur;
762 $accline->bank_chq = $banque;
765 if ($accline->insert() > 0) {
766 if ($categorie > 0) {
767 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"category_bankline(";
768 $sql .=
"lineid, fk_categ";
769 $sql .=
") VALUES (";
770 $sql .= ((int) $accline->id).
", ".((int) $categorie);
773 $result = $this->db->query($sql);
775 $this->
error = $this->db->lasterror();
776 $this->db->rollback();
787 $this->db->rollback();
800 public function create($user, $notrigger = 0)
802 global $langs,
$conf;
807 if (!$this->min_allowed) {
808 $this->min_allowed = 0;
810 if (!$this->min_desired) {
811 $this->min_desired = 0;
815 if (empty($this->country_id)) {
816 $langs->load(
'errors');
817 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
821 if (empty($this->
ref)) {
822 $langs->load(
'errors');
823 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
827 if (empty($this->date_solde)) {
828 $langs->load(
'errors');
829 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateInitialBalance"));
835 $balance = $this->balance;
836 if (empty($balance) && !empty($this->
solde)) {
837 dol_syslog(get_class($this).
"::create solde is deprecated use balance", LOG_NOTICE);
838 $balance = $this->solde;
840 if (empty($balance)) {
843 if (empty($this->
status && !empty($this->clos))) {
844 dol_syslog(get_class($this).
"::create clos is deprecated use status", LOG_NOTICE);
845 $this->
status = $this->clos;
848 if (empty($this->country_id) && !empty($this->country_code)) {
849 $country_id =
getCountry($this->country_code,
'3');
850 $this->country_id = is_int($country_id) ? $country_id : 0;
854 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
860 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_account (";
865 $sql .=
", account_number";
866 $sql .=
", fk_accountancy_journal";
868 $sql .=
", code_banque";
869 $sql .=
", code_guichet";
873 $sql .=
", iban_prefix";
874 $sql .=
", domiciliation";
875 $sql .=
", pti_in_ctti";
876 $sql .=
", sepa_category_purpose";
877 $sql .=
", sepa_local_instrument";
879 $sql .=
", owner_address";
880 $sql .=
", owner_zip";
881 $sql .=
", owner_town";
882 $sql .=
", owner_country_id";
883 $sql .=
", currency_code";
885 $sql .=
", min_allowed";
886 $sql .=
", min_desired";
888 $sql .=
", state_id";
891 $sql .=
", ics_transfer";
892 $sql .=
") VALUES (";
893 $sql .=
"'".$this->db->idate($now).
"'";
894 $sql .=
", '".$this->db->escape($this->
ref).
"'";
895 $sql .=
", '".$this->db->escape($this->label).
"'";
896 $sql .=
", ".((int)
$conf->entity);
897 $sql .=
", '".$this->db->escape($this->account_number).
"'";
898 $sql .=
", ".($this->fk_accountancy_journal > 0 ? ((int) $this->fk_accountancy_journal) :
"null");
899 $sql .=
", '".$this->db->escape($this->bank).
"'";
900 $sql .=
", '".$this->db->escape($this->code_banque).
"'";
901 $sql .=
", '".$this->db->escape($this->code_guichet).
"'";
902 $sql .=
", '".$this->db->escape($this->number).
"'";
903 $sql .=
", '".$this->db->escape($this->cle_rib).
"'";
904 $sql .=
", '".$this->db->escape($this->bic).
"'";
905 $sql .=
", '".$this->db->escape($this->iban).
"'";
906 $sql .=
", '".$this->db->escape($this->
address).
"'";
907 $sql .=
", ".((int) $this->pti_in_ctti);
910 $sql .=
", '".$this->db->escape($this->owner_name).
"'";
911 $sql .=
", '".$this->db->escape($this->owner_address).
"'";
912 $sql .=
", '".$this->db->escape($this->owner_zip).
"'";
913 $sql .=
", '".$this->db->escape($this->owner_town).
"'";
914 $sql .=
", ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
915 $sql .=
", '".$this->db->escape($this->currency_code).
"'";
916 $sql .=
", ".((int) $this->rappro);
917 $sql .=
", ".price2num($this->min_allowed,
'MT');
918 $sql .=
", ".price2num($this->min_desired,
'MT');
919 $sql .=
", '".$this->db->escape($this->comment).
"'";
920 $sql .=
", ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
921 $sql .=
", ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
922 $sql .=
", '".$this->db->escape($this->ics).
"'";
923 $sql .=
", '".$this->db->escape($this->ics_transfer).
"'";
926 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
927 $resql = $this->db->query($sql);
929 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bank_account");
931 $result = $this->
update($user, 1);
934 $accline->datec = $now;
935 $accline->label =
'('.$langs->trans(
"InitialBankBalance").
')';
936 $accline->amount = (float)
price2num($balance);
937 $accline->fk_user_author = $user->id;
938 $accline->fk_account = $this->id;
939 $accline->datev = $this->date_solde;
940 $accline->dateo = $this->date_solde;
941 $accline->fk_type =
'SOLD';
943 if ($accline->insert() < 0) {
955 if (!$error && !$notrigger) {
957 $result = $this->call_trigger(
'BANKACCOUNT_CREATE', $user);
967 if ($this->db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
968 $this->
error = $langs->trans(
"ErrorBankLabelAlreadyExists");
971 $this->
error = $this->db->error().
" sql=".$sql;
980 $this->db->rollback();
992 public function update($user, $notrigger = 0)
994 global $langs,
$conf;
996 if (empty($this->country_id) && !empty($this->country_code)) {
997 $country_id =
getCountry($this->country_code,
'3');
998 $this->country_id = is_int($country_id) ? $country_id : 0;
1006 if (empty($this->country_id)) {
1007 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
1011 if (empty($this->
ref)) {
1012 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
1016 if (!$this->label) {
1017 $this->label =
"???";
1020 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET";
1021 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
1022 $sql .=
",label = '".$this->db->escape($this->label).
"'";
1023 $sql .=
",courant = ".((int) $this->
type);
1024 $sql .=
",clos = ".((int) $this->
status);
1025 $sql .=
",rappro = ".((int) $this->rappro);
1026 $sql .=
",url = ".($this->url ?
"'".$this->db->escape($this->url).
"'" :
"null");
1027 $sql .=
",account_number = '".$this->db->escape($this->account_number).
"'";
1028 $sql .=
",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? ((int) $this->fk_accountancy_journal) :
"null");
1029 $sql .=
",bank = '".$this->db->escape($this->bank).
"'";
1030 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
1031 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
1032 $sql .=
",number='".$this->db->escape($this->number).
"'";
1033 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
1034 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
1035 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
1036 $sql .=
",domiciliation='".$this->db->escape($this->
address).
"'";
1037 $sql .=
",pti_in_ctti=".((int) $this->pti_in_ctti);
1040 $sql .=
",proprio = '".$this->db->escape($this->owner_name).
"'";
1041 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
1042 $sql .=
",owner_zip = '".$this->db->escape($this->owner_zip).
"'";
1043 $sql .=
",owner_town = '".$this->db->escape($this->owner_town).
"'";
1044 $sql .=
",owner_country_id = ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
1046 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
1048 $sql .=
",min_allowed = ".($this->min_allowed !=
'' ?
price2num($this->min_allowed) :
"null");
1049 $sql .=
",min_desired = ".($this->min_desired !=
'' ?
price2num($this->min_desired) :
"null");
1050 $sql .=
",comment = '".$this->db->escape($this->comment).
"'";
1052 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
1053 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
1054 $sql .=
",ics = '".$this->db->escape($this->ics).
"'";
1055 $sql .=
",ics_transfer = '".$this->db->escape($this->ics_transfer).
"'";
1057 $sql .=
" WHERE rowid = ".((int) $this->
id);
1059 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1060 $result = $this->db->query($sql);
1070 if (!$error && !empty($this->oldref) && $this->oldref !== $this->
ref) {
1071 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'bank/".$this->db->escape($this->
ref).
"'";
1072 $sql .=
" WHERE filepath = 'bank/".$this->db->escape($this->oldref).
"' and src_object_type = 'bank_account' and entity = ".((int)
$conf->entity);
1073 $resql = $this->db->query($sql);
1076 $this->
error = $this->db->lasterror();
1082 $dirsource =
$conf->bank->dir_output.
'/'.$oldref;
1083 $dirdest =
$conf->bank->dir_output.
'/'.$newref;
1084 if (file_exists($dirsource)) {
1085 dol_syslog(get_class($this).
"::update rename dir ".$dirsource.
" into ".$dirdest, LOG_DEBUG);
1086 if (@rename($dirsource, $dirdest)) {
1092 if (!$error && !$notrigger) {
1094 $result = $this->call_trigger(
'BANKACCOUNT_MODIFY', $user);
1102 $this->
error = $this->db->lasterror();
1103 dol_print_error($this->db);
1107 $this->db->commit();
1110 $this->db->rollback();
1126 global
$conf, $langs;
1129 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1131 dol_syslog(get_class($this).
"::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
1135 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->trans(
"Ref"));
1139 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET";
1140 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
1141 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
1142 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
1143 $sql .=
",number='".$this->db->escape($this->number).
"'";
1144 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
1145 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
1146 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
1147 $sql .=
",domiciliation='".$this->db->escape($this->
address).
"'";
1148 $sql .=
",proprio = '".$this->db->escape($this->owner_name).
"'";
1149 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
1150 $sql .=
",owner_zip = '".$this->db->escape($this->owner_zip).
"'";
1151 $sql .=
",owner_town = '".$this->db->escape($this->owner_town).
"'";
1152 $sql .=
",owner_country_id = ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
1153 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
1154 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
1155 $sql .=
" WHERE rowid = ".((int) $this->
id);
1156 $sql .=
" AND entity = ".((int)
$conf->entity);
1158 dol_syslog(get_class($this).
"::update_bban", LOG_DEBUG);
1160 $result = $this->db->query($sql);
1164 $this->
error = $this->db->lasterror();
1165 dol_print_error($this->db);
1180 if (empty($id) && empty($ref)) {
1181 $this->
error =
"ErrorBadParameters";
1185 $sql =
"SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant as type, ba.clos as status, ba.rappro, ba.url,";
1186 $sql .=
" ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
1187 $sql .=
" ba.domiciliation as address, ba.pti_in_ctti, ba.sepa_category_purpose, ba.sepa_local_instrument, ba.proprio as owner_name, ba.owner_address, ba.owner_zip, ba.owner_town, ba.owner_country_id, ba.state_id, ba.fk_pays as country_id,";
1188 $sql .=
" ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
1189 $sql .=
" ba.min_allowed, ba.min_desired, ba.comment,";
1190 $sql .=
" ba.datec as date_creation, ba.tms as date_modification, ba.ics, ba.ics_transfer,";
1191 $sql .=
' c.code as country_code, c.label as country,';
1192 $sql .=
' d.code_departement as state_code, d.nom as state,';
1193 $sql .=
' aj.code as accountancy_journal';
1194 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1195 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON ba.fk_pays = c.rowid';
1196 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON ba.state_id = d.rowid';
1197 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal';
1198 $sql .=
" WHERE ba.entity IN (".getEntity($this->element).
")";
1200 $sql .=
" AND ba.rowid = ".((int) $id);
1203 $sql .=
" AND ba.ref = '".$this->db->escape($ref).
"'";
1206 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1207 $result = $this->db->query($sql);
1209 if ($this->db->num_rows($result)) {
1210 $obj = $this->db->fetch_object($result);
1212 $this->
id = $obj->rowid;
1213 $this->rowid = $obj->rowid;
1214 $this->
ref = $obj->ref;
1215 $this->label = $obj->label;
1216 $this->
type = $obj->type;
1217 $this->courant = $obj->type;
1218 $this->bank = $obj->bank;
1219 $this->clos = $obj->status;
1220 $this->
status = $obj->status;
1221 $this->rappro = $obj->rappro;
1222 $this->url = $obj->url;
1224 $this->code_banque = $obj->code_banque;
1225 $this->code_guichet = $obj->code_guichet;
1226 $this->number = $obj->number;
1227 $this->cle_rib = $obj->cle_rib;
1228 $this->bic = $obj->bic;
1229 $this->iban = $obj->iban;
1230 $this->
address = $obj->address;
1232 $this->owner_name = $obj->owner_name;
1233 $this->proprio = $this->owner_name;
1234 $this->owner_address = $obj->owner_address;
1235 $this->owner_zip = $obj->owner_zip;
1236 $this->owner_town = $obj->owner_town;
1237 $this->owner_country_id = $obj->owner_country_id;
1239 $this->pti_in_ctti = $obj->pti_in_ctti;
1240 $this->sepa_category_purpose = (in_array($obj->sepa_category_purpose, self::SEPA_CATEGORY_PURPOSES) ? $obj->sepa_category_purpose :
'CORE');
1241 $this->sepa_local_instrument = (in_array($obj->sepa_local_instrument, self::SEPA_LOCAL_INSTRUMENTS) ? $obj->sepa_local_instrument :
'CORE');
1243 $this->state_id = $obj->state_id;
1244 $this->state_code = $obj->state_code;
1245 $this->state = $obj->state;
1247 $this->country_id = $obj->country_id;
1248 $this->country_code = $obj->country_code;
1249 $this->country = $obj->country;
1251 $this->account_number = $obj->account_number;
1252 $this->fk_accountancy_journal = $obj->fk_accountancy_journal;
1253 $this->accountancy_journal = $obj->accountancy_journal;
1255 $this->currency_code = $obj->currency_code;
1256 $this->account_currency_code = $obj->currency_code;
1257 $this->min_allowed = $obj->min_allowed;
1258 $this->min_desired = $obj->min_desired;
1259 $this->comment = $obj->comment;
1261 $this->date_creation = $this->db->jdate($obj->date_creation);
1262 $this->date_modification = $this->db->jdate($obj->date_modification);
1264 $this->ics = $obj->ics;
1265 $this->ics_transfer = $obj->ics_transfer;
1276 $this->
error = $this->db->lasterror();
1277 $this->errors[] = $this->error;
1294 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1295 return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT);
1305 public function delete($user, $notrigger = 0)
1315 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
1316 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1318 $resql = $this->db->query($sql);
1321 $this->
error =
"Error ".$this->db->lasterror();
1326 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
1327 $sql .=
" WHERE rowid = ".((int) $this->
id);
1329 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1330 $result = $this->db->query($sql);
1337 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1342 $this->
error =
"Error ".$this->db->lasterror();
1346 if (!$error && !$notrigger) {
1348 $result = $this->call_trigger(
'BANKACCOUNT_DELETE', $user);
1356 $this->db->commit();
1359 $this->db->rollback();
1388 $langs->load(
'banks');
1390 if ($status == self::STATUS_OPEN) {
1391 $label = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1392 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1393 $statusType =
'status4';
1395 $label = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1396 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1397 $statusType =
'status5';
1400 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1413 $can_be_deleted =
false;
1415 $sql =
"SELECT COUNT(rowid) as nb";
1416 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1417 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1419 $resql = $this->db->query($sql);
1421 $obj = $this->db->fetch_object($resql);
1422 if ($obj->nb <= 1) {
1423 $can_be_deleted =
true;
1426 dol_print_error($this->db);
1428 return $can_be_deleted;
1439 return $this->error;
1450 public function solde($option = 0, $date_end =
'', $field =
'dateo')
1454 $sql =
"SELECT sum(amount) as amount";
1455 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1456 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1458 $sql .=
" AND ".$this->db->sanitize($field).
" <= '".(!empty($date_end) ? $this->db->idate($date_end) : $this->db->idate(
dol_now())).
"'";
1461 $resql = $this->db->query($sql);
1463 if ($this->db->num_rows($resql)) {
1464 $obj = $this->db->fetch_object($resql);
1465 $solde = $obj->amount;
1467 $this->db->free($resql);
1469 $this->errors[] = $this->db->lasterror;
1487 global
$conf, $langs;
1498 $sql =
"SELECT COUNT(b.rowid) as nb,";
1499 $sql .=
" SUM(CASE WHEN b.datev IS NULL OR b.datev < '".$this->db->idate($now -
$conf->bank->rappro->warning_delay).
"' THEN 1 ELSE 0 END) as nblate";
1500 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1501 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1502 $sql .=
" WHERE b.rappro=0";
1503 $sql .=
" AND b.fk_account = ba.rowid";
1504 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1506 $sql .=
" AND clos = 0";
1507 if ($filteraccountid) {
1508 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1510 $resql = $this->db->query($sql);
1512 $langs->load(
"banks");
1514 require_once DOL_DOCUMENT_ROOT.
'/core/class/workboardresponse.class.php';
1517 $response->warning_delay =
$conf->bank->rappro->warning_delay / 60 / 60 / 24;
1518 $response->label = $langs->trans(
"TransactionsToConciliate");
1519 $response->labelShort = $langs->trans(
"TransactionsToConciliateShort");
1520 $response->url = DOL_URL_ROOT.
'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
1521 $response->img = img_object(
'',
"payment");
1523 $obj = $this->db->fetch_object($resql);
1525 $response->nbtodo = (int) $obj->nb;
1526 $response->nbtodolate = (int) $obj->nblate;
1530 dol_print_error($this->db);
1531 $this->
error = $this->db->error();
1550 $sql =
"SELECT count(b.rowid) as nb";
1551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1552 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1553 $sql .=
" WHERE b.fk_account = ba.rowid";
1554 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1555 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1556 $sql .=
" AND clos = 0";
1557 if ($filteraccountid) {
1558 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1561 $resql = $this->db->query($sql);
1563 while ($obj = $this->db->fetch_object($resql)) {
1564 $this->nb[
"banklines"] = $obj->nb;
1566 $this->db->free($resql);
1569 dol_print_error($this->db);
1570 $this->
error = $this->db->error();
1592 $sql =
"SELECT COUNT(ba.rowid) as nb";
1593 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1594 $sql .=
" WHERE ba.rappro > 0 and ba.clos = 0";
1595 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1600 $resql = $this->db->query($sql);
1602 $obj = $this->db->fetch_object($resql);
1603 $nb = (int) $obj->nb;
1605 dol_print_error($this->db);
1622 $langs->loadLangs([
'banks',
'compta']);
1623 include_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1627 $nofetch = !empty($params[
'nofetch']);
1628 $pictos = img_picto(
'', $this->picto).
' <u class="paddingrightnow">'.$langs->trans(
"BankAccount").
'</u>';
1629 if (isset($this->
status)) {
1630 $pictos .=
' '.$this->getLibStatut(5);
1632 $datas[
'picto'] = $pictos;
1633 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1634 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1635 $datas[
'accountnumber'] =
'<br><br><b>'.$langs->trans(
'AccountNumber').
':</b> '.$this->number;
1637 $datas[
'bic'] =
'<br><b>'.$langs->trans(
'BIC').
':</b> '.$this->bic;
1638 $datas[
'accountcurrency'] =
'<br><br><b>'.$langs->trans(
"AccountCurrency").
':</b> '.$this->currency_code;
1641 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1642 $langs->load(
"accountancy");
1643 $datas[
'accountaccounting'] =
'<br><b>'.$langs->trans(
'AccountAccounting').
':</b> '.
length_accountg($this->account_number);
1644 $datas[
'accountancyjournal'] =
'<br><b>'.$langs->trans(
'AccountancyJournal').
':</b> '.$this->accountancy_journal;
1648 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1649 $form =
new Form($this->db);
1650 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_ACCOUNT, 1);
1667 public function getNomUrl($withpicto = 0, $mode =
'', $option =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1669 global
$conf, $langs;
1671 if (!empty(
$conf->dol_no_mouse_hover)) {
1675 include_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1678 $classfortooltip =
'classfortooltip';
1682 'objecttype' => $this->element,
1683 'option' => $option,
1687 $classfortooltip =
'classforajaxtooltip';
1688 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1694 $baseurl = DOL_URL_ROOT.
'/compta/bank/card.php';
1695 $query = [
'id' => $this->id];
1696 if ($mode ==
'transactions') {
1697 $baseurl = DOL_URL_ROOT.
'/compta/bank/bankentries_list.php';
1698 } elseif ($mode ==
'receipts') {
1699 $baseurl = DOL_URL_ROOT.
'/compta/bank/releve.php';
1700 $query = [
'account' => $this->id];
1703 if ($option !=
'nolink') {
1705 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1706 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1707 $add_save_lastsearch_values = 1;
1709 if ($add_save_lastsearch_values) {
1710 $query = array_merge($query, [
'save_lastsearch_values' => 1]);
1716 if (empty($notooltip)) {
1718 $label = $langs->trans(
"BankAccount");
1719 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1721 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1722 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1724 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1727 if ($option ==
'nolink' || empty($url)) {
1728 $linkstart =
'<span';
1730 $linkstart =
'<a href="'.$url.
'"';
1732 $linkstart .= $linkclose.
'>';
1733 if ($option ==
'nolink' || empty($url)) {
1734 $linkend =
'</span>';
1739 $result .= $linkstart;
1742 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1744 if ($withpicto != 2) {
1745 $result .= $this->
ref.($option ==
'reflabel' && $this->label ?
' - '.$this->label :
'');
1747 $result .= $linkend;
1749 global $action, $hookmanager;
1750 $hookmanager->initHooks(array($this->element .
'dao'));
1751 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1752 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1754 $result = $hookmanager->resPrint;
1756 $result .= $hookmanager->resPrint;
1773 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1780 $this->
error =
'IBANNotValid';
1786 $this->
error =
'SwiftNotValid';
1806 if (!empty($this->country_code)) {
1807 return $this->country_code;
1811 if (!empty($this->iban)) {
1814 if (preg_match(
"/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) {
1820 if (!empty($this->socid)) {
1821 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1822 $company =
new Societe($this->db);
1823 $result = $company->fetch($this->socid);
1824 if (!empty($company->country_code)) {
1825 return $company->country_code;
1830 if (!empty(
$mysoc->country_code)) {
1831 return $mysoc->country_code;
1846 global
$conf, $langs;
1853 if (!empty(
$conf->use_javascript_ajax)) {
1855 $out .=
'<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($coords).
'\',\
''.dol_escape_js($langs->trans(
"HelpCopyToClipboard")).
'\');
">';
1856 $out .= img_picto($langs->trans("Address
"), 'map-marker-alt');
1859 $address = dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
1879 public function useDetailedBBAN()
1881 $country_code = $this->getCountryCode();
1883 if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) {
1884 return 1; // France, Spain, Gabon, ... - Not valid for CH
1886 if (in_array($country_code, array('AD', 'AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) {
1887 return 2; // Australia, England...
1897 public function needIBAN()
1901 if (getDolGlobalString('MAIN_IBAN_IS_NEVER_MANDATORY')) {
1905 $country_code = $this->getCountryCode();
1907 $country_code_in_EEC = array(
1912 'CZ', // Czech republic
1919 'GB', // United Kingdom
1925 'IM', // Isle of Man - Included in UK
1930 'MC', // Monaco - Included in France
1939 'UK', // United Kingdom
1940 //'CH', // Switzerland - No. Swizerland in not in EEC
1943 if (in_array($country_code, $country_code_in_EEC)) {
1944 return 1; // France, Spain, ...
1954 public function needBIC()
1956 if (getDolGlobalString('MAIN_IBAN_IS_NEVER_MANDATORY')) {
1960 $country_code = $this->getCountryCode();
1962 $country_code_in_EEC = array(
1974 if (in_array($country_code, $country_code_in_EEC)) {
1975 return 1; // Andorra, Bahrein, ...
1986 public function info($id)
2004 public function getFieldsToShow($includeibanbic = 0)
2006 //Get the required properties depending on the country
2007 $detailedBBAN = $this->useDetailedBBAN();
2009 if ($detailedBBAN == 0) {
2010 $fieldarray = array(
2013 } elseif ($detailedBBAN == 2) {
2014 $fieldarray = array(
2019 $fieldarray = self::getAccountNumberOrder();
2022 //if ($this->needIBAN()) { // return always IBAN and BIC (this was old behaviour)
2023 if ($includeibanbic) {
2024 $fieldarray[] = 'IBAN';
2025 $fieldarray[] = 'BIC';
2029 //Get the order the properties are shown
2043 public static function getAccountNumberOrder()
2047 $fieldlists = array(
2050 'BankAccountNumber',
2051 'BankAccountNumberKey'
2054 if (getDolGlobalString('BANK_SHOW_ORDER_OPTION')) {
2055 if (is_numeric(getDolGlobalString('BANK_SHOW_ORDER_OPTION'))) {
2056 if (getDolGlobalString('BANK_SHOW_ORDER_OPTION') == '1') {
2057 $fieldlists = array(
2060 'BankAccountNumberKey',
2065 //Replace the old AccountNumber key with the new BankAccountNumber key
2066 $fieldlists = explode(
2068 preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION)
2084 public function initAsSpecimen()
2086 // Example of IBAN FR7630001007941234567890185
2087 $this->specimen = 1;
2089 $this->label = 'My Big Company Bank account';
2090 $this->clos = Account::STATUS_OPEN;
2091 $this->type = Account::TYPE_CURRENT;
2092 $this->status = Account::STATUS_OPEN;
2093 $this->code_banque = '30001';
2094 $this->code_guichet = '00794';
2095 $this->number = '12345678901';
2096 $this->cle_rib = '85';
2097 $this->bic = 'AA12';
2098 $this->iban = 'FR7630001007941234567890185';
2100 $this->bank = 'MyBank';
2101 $this->address = 'Rue de Paris';
2102 $this->owner_name = 'Owner';
2103 $this->owner_address = 'Owner address';
2104 $this->owner_zip = 'Owner zip';
2105 $this->owner_town = 'Owner town';
2106 $this->owner_country_id = 1;
2107 $this->country_id = 1;
2120 public static function replaceThirdparty($dbs, $origin_id, $dest_id)
2122 $sql = "UPDATE
".MAIN_DB_PREFIX."bank_url SET url_id =
".((int) $dest_id)." WHERE url_id =
".((int) $origin_id)." AND
type =
'company'";
2124 if ($dbs->query($sql)) {
2127 //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B.
2128 //$this->errors = $dbs->lasterror();
2140 public function getKanbanView($option = '', $arraydata = null)
2144 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
2146 $return = '<div class="box-flex-item box-flex-grow-zero
">';
2147 $return .= '<div class="info-box
info-box-sm
">';
2148 $return .= '<span class="info-box-icon bg-infobox-action
">';
2149 $return .= img_picto('', $this->picto);
2150 $return .= '</span>';
2151 $return .= '<div class="info-box-content
">';
2152 $return .= '<span class="info-box-
ref inline-block tdoverflowmax150 valignmiddle
">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
2153 if ($selected >= 0) {
2154 $return .= '<input id="cb
'.$this->id.'" class="flat checkforselect fright
" type="checkbox
" name="toselect[]
" value="'.$this->id.'"'.($selected ? ' checked="checked
"' : '').'>';
2156 if (property_exists($this, 'type_lib')) {
2157 $return .= '<br><span class="info-box-label opacitymedium
" title="'.$this->type_lib[$this->type].'">'.substr($this->type_lib[$this->type], 0, 24).'...</span>';
2159 if (method_exists($this, 'solde')) {
2160 $return .= '<br><a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?
id=
'.$this->id.'">';
2161 $return .= '<span class="opacitymedium
">'.$langs->trans("Balance
").'</span> : <span class="amount">'.price(price2num($this->solde(1), 'MT'), 0, $langs, 1, -1, -1, $this->currency_code).'</span>';
2163 if (method_exists($this, 'getLibStatut')) {
2164 $return .= '<br><div class="info-box-
status">'.$this->getLibStatut(3).'</div>';
2166 $return .= '</div>';
2167 $return .= '</div>';
2168 $return .= '</div>';
2174require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
2179class AccountLine extends CommonObjectLine
2189 public $element = 'bank';
2194 public $table_element = 'bank';
2199 public $picto = 'accountline';
2240 public $amount_main_currency;
2245 public $fk_user_author;
2250 public $fk_user_rappro;
2260 public $fk_bordereau;
2270 public $bank_account_ref;
2275 public $bank_account_label;
2280 public $numero_compte;
2322 public $user_rappro;
2330 public function __construct(DoliDB $db)
2343 public function fetch($rowid, $ref = '', $num = '')
2346 if (empty($rowid) && empty($ref) && empty($num)) {
2350 $sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,
";
2351 $sql .= " b.fk_user_author, b.fk_user_rappro,
";
2352 $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,
";
2353 $sql .= " b.fk_bordereau, b.banque, b.emetteur,
";
2354 $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label
";
2355 $sql .= " FROM
".MAIN_DB_PREFIX."bank as b,
";
2356 $sql .= " ".MAIN_DB_PREFIX."bank_account as ba
";
2357 $sql .= " WHERE b.fk_account = ba.rowid
";
2358 $sql .= " AND ba.entity IN (
".getEntity('bank_account').")
";
2360 $sql .= " AND b.num_chq =
'".$this->db->escape($num)."'";
2362 $sql .= " AND b.rowid =
'".$this->db->escape($ref)."'";
2364 $sql .= " AND b.rowid =
".((int) $rowid);
2367 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
2368 $result = $this->db->query($sql);
2372 $obj = $this->db->fetch_object($result);
2374 $this->id = $obj->rowid;
2375 $this->rowid = $obj->rowid;
2376 $this->ref = $obj->rowid;
2378 $this->datec = $this->db->jdate($obj->datec);
2379 $this->datev = $this->db->jdate($obj->datev);
2380 $this->dateo = $this->db->jdate($obj->dateo);
2381 $this->amount = $obj->amount;
2382 $this->label = $obj->label;
2383 $this->note = $obj->note;
2385 $this->fk_user_author = $obj->fk_user_author;
2386 $this->fk_user_rappro = $obj->fk_user_rappro;
2388 $this->fk_type = $obj->fk_type; // Type of transaction
2389 $this->rappro = (int) $obj->rappro;
2390 $this->num_releve = $obj->num_releve;
2392 $this->num_chq = $obj->num_chq;
2393 $this->bank_chq = $obj->banque;
2394 $this->fk_bordereau = $obj->fk_bordereau;
2396 $this->fk_account = $obj->fk_account;
2397 $this->bank_account_ref = $obj->bank_account_ref;
2398 $this->bank_account_label = $obj->bank_account_label;
2400 // Retrieve all extrafield
2401 // fetch optionals attributes and labels
2402 $this->fetch_optionals();
2406 $this->db->free($result);
2418 public function insert()
2424 $sql = "INSERT INTO
".MAIN_DB_PREFIX."bank (
";
2430 $sql .= ", amount_main_currency
";
2431 $sql .= ", fk_user_author
";
2432 $sql .= ", num_chq
";
2433 $sql .= ", fk_account
";
2434 $sql .= ", fk_type
";
2435 $sql .= ", emetteur,banque
";
2437 $sql .= ", numero_compte
";
2438 $sql .= ", num_releve
";
2440 $sql .= ") VALUES (
";
2441 $sql .= "'".$this->db->idate($this->datec)."'";
2442 $sql .= ",
'".$this->db->idate($this->dateo)."'";
2443 $sql .= ",
'".$this->db->idate($this->datev)."'";
2444 $sql .= ",
'".$this->db->escape($this->label)."'";
2445 $sql .= ",
".price2num($this->amount);
2446 $sql .= ",
".(empty($this->amount_main_currency) ? "NULL
" : price2num($this->amount_main_currency));
2447 $sql .= ",
".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null");
2448 $sql .= ",
".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null");
2449 $sql .= ",
'".$this->db->escape((string) $this->fk_account)."'";
2450 $sql .= ",
'".$this->db->escape($this->fk_type)."'";
2451 $sql .= ",
".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null");
2452 $sql .= ",
".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null");
2453 $sql .= ",
".(int) $this->rappro;
2454 $sql .= ",
".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''");
2455 $sql .= ",
".($this->num_releve ? "'".$this->db->escape($this->num_releve)."'" : "null");
2456 $sql .= ",
".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
2460 dol_syslog(get_class($this)."::insert
", LOG_DEBUG);
2461 $resql = $this->db->query($sql);
2463 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank');
2464 // Actions on extra fields (by external module or standard code)
2465 $result = $this->insertExtraFields();
2471 $this->error = $this->db->lasterror();
2472 dol_print_error($this->db);
2476 $this->db->commit();
2479 $this->db->rollback();
2491 public function delete($user, $notrigger = 0)
2495 if ($this->rappro) {
2496 // Protection to avoid any delete of consolidated lines
2497 $this->error = "ErrorDeleteNotPossibleLineIsConsolidated
";
2505 $result = $this->call_trigger('BANKACCOUNTLINE_DELETE', $user);
2507 $this->db->rollback();
2510 // End call triggers
2513 // Protection to avoid any delete of accounted lines. Protection on by default
2514 if (!getDolGlobalString('BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING')) {
2515 $sql = "SELECT COUNT(rowid) as nb FROM
".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type =
'bank' AND fk_doc =
".((int) $this->id);
2516 $resql = $this->db->query($sql);
2518 $obj = $this->db->fetch_object($resql);
2519 if ($obj && $obj->nb) {
2520 $this->error = 'ErrorRecordAlreadyInAccountingDeletionNotPossible';
2521 $this->db->rollback();
2525 $this->error = $this->db->lasterror();
2526 $this->db->rollback();
2532 $result = $this->delete_urls($user);
2537 $sql = "DELETE FROM
".MAIN_DB_PREFIX."category_bankline WHERE lineid=
".(int) $this->rowid;
2538 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
2539 $result = $this->db->query($sql);
2544 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank_extrafields WHERE fk_object=
".(int) $this->rowid;
2545 $result = $this->db->query($sql);
2550 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank WHERE rowid=
".(int) $this->rowid;
2551 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
2552 $result = $this->db->query($sql);
2558 $this->db->commit();
2561 $this->db->rollback();
2567 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2574 public function delete_urls($user = null)
2579 if ($this->rappro) {
2580 // Protection to avoid any delete of consolidated lines
2581 $this->error = "ErrorDeleteNotPossibleLineIsConsolidated
";
2587 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank_url WHERE fk_bank=
".(int) $this->rowid;
2588 dol_syslog(get_class($this)."::delete_urls
", LOG_DEBUG);
2589 $result = $this->db->query($sql);
2595 $this->db->commit();
2598 $this->db->rollback();
2611 public function update(User $user, $notrigger = 0)
2615 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2616 $sql .= " amount =
".price2num($this->amount).",
";
2617 $sql .= " datev=
'".$this->db->idate($this->datev)."',
";
2618 $sql .= " dateo=
'".$this->db->idate($this->dateo)."'";
2619 $sql .= " WHERE rowid =
".((int) $this->rowid);
2621 dol_syslog(get_class($this)."::update", LOG_DEBUG);
2622 $resql = $this->db->query($sql);
2624 $this->db->rollback();
2625 $this->error = $this->db->error();
2631 $result = $this->call_trigger('BANKACCOUNTLINE_MODIFY', $user);
2633 $this->db->rollback();
2636 // End call triggers
2639 $this->db->commit();
2649 public function updateLabel()
2653 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2654 $sql .= " label =
'".$this->db->escape($this->label)."'";
2655 $sql .= " WHERE rowid =
".((int) $this->rowid);
2657 dol_syslog(get_class($this)."::update_label
", LOG_DEBUG);
2658 $resql = $this->db->query($sql);
2660 $this->db->commit();
2663 $this->db->rollback();
2664 $this->error = $this->db->error();
2670 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2680 public function update_conciliation(User $user, $cat, $conciliated = 1, $notrigger = 0)
2683 global $conf, $langs;
2687 // Check statement field
2688 if (getDolGlobalString('BANK_STATEMENT_REGEX_RULE')) {
2689 if (!preg_match('/' . getDolGlobalString('BANK_STATEMENT_REGEX_RULE').'/', $this->num_releve)) {
2690 $this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex
", getDolGlobalString('BANK_STATEMENT_REGEX_RULE'));
2691 $this->db->rollback();
2696 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2697 $sql .= " rappro =
".((int) $conciliated);
2698 $sql .= ", num_releve =
'".$this->db->escape($this->num_releve)."'";
2700 $sql .= ", fk_user_rappro =
".((int) $user->id);
2702 $sql .= " WHERE rowid =
".((int) $this->id);
2704 dol_syslog(get_class($this)."::update_conciliation
", LOG_DEBUG);
2705 $resql = $this->db->query($sql);
2707 if (!empty($cat) && $cat > 0) {
2708 $sql = "INSERT INTO
".MAIN_DB_PREFIX."category_bankline (
";
2710 $sql .= ", fk_categ
";
2711 $sql .= ") VALUES (
";
2712 $sql .= ((int) $this->id);
2713 $sql .= ",
".((int) $cat);
2716 dol_syslog(get_class($this)."::update_conciliation
", LOG_DEBUG);
2717 $this->db->query($sql);
2719 // No error check. Can fail if category already affected
2720 // TODO Do no try the insert if link already exists
2723 $this->rappro = (int) $conciliated;
2727 $result = $this->call_trigger('BANKACCOUNTLINE_MODIFY', $user);
2729 $this->db->rollback();
2732 // End call triggers
2735 $this->db->commit();
2738 $this->db->rollback();
2744 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2752 public function datev_change($rowid, $sign = 1)
2755 $sql = "SELECT datev FROM
".MAIN_DB_PREFIX."bank WHERE rowid =
".((int) $rowid);
2756 $resql = $this->db->query($sql);
2758 $obj = $this->db->fetch_object($resql);
2759 $newdate = (int) $this->db->jdate($obj->datev) + (3600 * 24 * $sign);
2761 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2762 $sql .= " datev =
'".$this->db->idate($newdate)."'";
2763 $sql .= " WHERE rowid =
".((int) $rowid);
2765 $result = $this->db->query($sql);
2767 if ($this->db->affected_rows($result)) {
2771 dol_print_error($this->db);
2775 dol_print_error($this->db);
2780 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2787 public function datev_next($id)
2790 return $this->datev_change($id, 1);
2793 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2800 public function datev_previous($id)
2803 return $this->datev_change($id, -1);
2807 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2815 public function dateo_change($rowid, $sign = 1)
2818 $sql = "SELECT dateo FROM
".MAIN_DB_PREFIX."bank WHERE rowid =
".((int) $rowid);
2819 $resql = $this->db->query($sql);
2821 $obj = $this->db->fetch_object($resql);
2822 $newdate = (int) $this->db->jdate($obj->dateo) + (3600 * 24 * $sign);
2824 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2825 $sql .= " dateo =
'".$this->db->idate($newdate)."'";
2826 $sql .= " WHERE rowid =
".((int) $rowid);
2828 $result = $this->db->query($sql);
2830 if ($this->db->affected_rows($result)) {
2834 dol_print_error($this->db);
2838 dol_print_error($this->db);
2843 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2850 public function dateo_next($id)
2853 return $this->dateo_change($id, 1);
2856 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2863 public function dateo_previous($id)
2866 return $this->dateo_change($id, -1);
2876 public function info($id)
2878 $sql = 'SELECT b.rowid, b.datec, b.tms as datem,';
2879 $sql .= ' b.fk_user_author, b.fk_user_rappro';
2880 $sql .= ' FROM '.MAIN_DB_PREFIX.'bank as b';
2881 $sql .= ' WHERE b.rowid = '.((int) $id);
2883 $result = $this->db->query($sql);
2885 if ($this->db->num_rows($result)) {
2886 $obj = $this->db->fetch_object($result);
2888 $this->id = $obj->rowid;
2890 $this->user_creation_id = $obj->fk_user_author;
2891 $this->user_rappro = $obj->fk_user_rappro;
2892 $this->date_creation = $this->db->jdate($obj->datec);
2893 $this->date_modification = $this->db->jdate($obj->datem);
2894 //$this->date_rappro = $obj->daterappro; // Not yet managed
2896 $this->db->free($result);
2898 dol_print_error($this->db);
2912 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0)
2914 global $conf, $langs;
2918 $label = img_picto('', $this->picto).' <u>'.$langs->trans("BankTransactionLine
").'</u>:<br>';
2919 $label .= '<b>'.$langs->trans("Ref
").':</b> '.$this->ref;
2920 if ($this->amount) {
2921 $label .= '<br><strong>'.$langs->trans("Amount
").':</strong> '.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency);
2924 $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid=
'.((int) $this->id).'&save_lastsearch_values=1
" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip
">';
2927 $result .= $linkstart;
2929 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'account'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright
"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright
' : '').'classfortooltip
"'), 0, 0, $notooltip ? 0 : 1);
2931 if ($withpicto != 2) {
2932 $result .= ($this->ref ? $this->ref : $this->id);
2935 $result .= $linkend;
2937 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
2938 $result .= ' <span class="opacitymedium
">(';
2940 if ($option == 'showall') {
2941 $result .= $langs->trans("BankAccount
").': ';
2942 $accountstatic = new Account($this->db);
2943 $accountstatic->id = $this->fk_account;
2944 $accountstatic->ref = $this->bank_account_ref;
2945 $accountstatic->label = $this->bank_account_label;
2946 $result .= $accountstatic->getNomUrl(0).', ';
2948 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
2949 $result .= $langs->trans("BankLineConciliated
").': ';
2950 $result .= yn($this->rappro);
2952 if (isModEnabled('accounting') && ($option == 'showall' || $option == 'showconciliatedandaccounted')) {
2953 $sql = "SELECT COUNT(rowid) as nb, MAX(piece_num) as banktransactionid FROM
".MAIN_DB_PREFIX."accounting_bookkeeping
";
2954 $sql .= " WHERE doc_type =
'bank' AND fk_doc =
".((int) $this->id);
2955 $resql = $this->db->query($sql);
2957 $obj = $this->db->fetch_object($resql);
2958 if ($obj && $obj->nb) {
2959 $result .= ' - '.$langs->trans("Accounted
").': <span title="'.$langs->trans("TransactionNumShort").' '.$obj->banktransactionid.'">'.yn(1).'</span>';
2961 $result .= ' - '.$langs->trans("Accounted
").': '.yn(0);
2965 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
2966 $result .= ')</span>';
2969 global $action, $hookmanager;
2970 $hookmanager->initHooks(array($this->element . 'dao'));
2971 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
2972 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
2974 $result = $hookmanager->resPrint;
2976 $result .= $hookmanager->resPrint;
2989 public function getLibStatut($mode = 0)
2991 return $this->LibStatut($this->status, $mode);
2994 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
3002 public function LibStatut($status, $mode = 0)
3014 public function getVentilExportCompta($mode = 0)
3016 $alreadydispatched = 0;
3020 $sql = " SELECT
".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb
";
3021 $sql .= " FROM
".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type =
'".$this->db->escape($type)."' AND ab.fk_doc =
".((int) $this->id);
3022 $resql = $this->db->query($sql);
3024 $obj = $this->db->fetch_object($resql);
3026 $alreadydispatched = $obj->nb;
3029 $this->error = $this->db->lasterror();
3033 if ($alreadydispatched) {
3034 return $alreadydispatched;
if(! $sortfield) if(! $sortorder) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
getIbanHumanReadable(Account $account)
Returns the iban human readable.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
Class to manage bank accounts.
solde($option=0, $date_end='', $field='dateo')
Return current balance.
fetch($id, $ref='')
Load a bank account into memory from database.
__construct(DoliDB $db)
Constructor.
getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0, $morecss='')
Return clickable name (with picto eventually)
getSepaCategoryPurpose()
Return the category purpose code to write into a SEPA file for this account (PmtTpInf/CtgyPurp/Cd).
add_url_line($line_id, $url_id, $url, $label, $type)
Add a link between bank line record and its source.
const SEPA_CATEGORY_PURPOSES
Allowed codes for the category purpose of a SEPA payment (ISO 20022, ExternalCategoryPurpose1Code sub...
loadStateBoard($filteraccountid=0)
Load the indicators this->nb for the state board.
getCountryCode()
Return account country code.
getLibStatut($mode=0)
Return label of object status.
update_bban($user=null)
Update BBAN (RIB) account fields.
create($user, $notrigger=0)
Create bank account into database.
addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='', $banque='', $accountancycode='', $datev=null, $num_releve='', $amount_main_currency=null, $note_private='')
Add an entry into table llx_bank.
getBannerAddress($htmlkey, $object)
Return full address for banner.
info($id)
Load miscellaneous information for tab "Info".
const TYPE_CASH
Cash account.
update($user, $notrigger=0)
Update bank account card.
__toString()
Shows the account number in the appropriate format.
delete($user, $notrigger=0)
Delete bank account from database.
const TYPE_SAVINGS
Savings account.
getTooltipContentArray($params)
getTooltipContentArray
canBeConciliated()
Return if a bank account need to be conciliated.
can_be_deleted()
Indicates if an account can be deleted or not (without movements)
const TYPE_CURRENT
Current account.
setCategories($categories)
Sets object to supplied categories.
countAccountToReconcile()
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
verif()
Return if an account has valid information for Direct debit payment.
getSepaLocalInstrument()
Return the local instrument code to write into a SEPA file for this account (PmtTpInf/LclInstrm/Cd).
getFieldsToShow($includeibanbic=0)
Returns the fields in order that this bank account should show to the user Will return an array with ...
const SEPA_LOCAL_INSTRUMENTS
Allowed codes for the local instrument of a SEPA payment (ISO 20022, ExternalLocalInstrument1Code sub...
load_board(User $user, $filteraccountid=0)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
get_url($fk_bank=0, $url_id=0, $type='')
TODO Move this into AccountLine Return array with links from llx_bank_url.
LibStatut($status, $mode=0)
Return label of given object status.
Class to manage bank transaction lines.
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
setErrorsFromObject($object)
setErrorsFromObject
getFullAddress($withcountry=0, $sep="\n", $withregion=0, $extralangcode='')
Return full address of contact.
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage Dolibarr database access.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div refaddress div address
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount