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;
472 if (is_object($langs)) {
473 $this->type_lib = array(
474 self::TYPE_SAVINGS => $langs->transnoentitiesnoconv(
"BankType0"),
475 self::TYPE_CURRENT => $langs->transnoentitiesnoconv(
"BankType1"),
476 self::TYPE_CASH => $langs->transnoentitiesnoconv(
"BankType2"),
479 $this->labelStatus = array(
480 self::STATUS_OPEN => $langs->transnoentitiesnoconv(
"StatusAccountOpened"),
481 self::STATUS_CLOSED => $langs->transnoentitiesnoconv(
"StatusAccountClosed")
494 $code = strtoupper(trim((
string) $this->sepa_category_purpose));
495 return (in_array($code, self::SEPA_CATEGORY_PURPOSES) ? $code :
'CORE');
506 $code = strtoupper(trim((
string) $this->sepa_local_instrument));
507 return (in_array($code, self::SEPA_LOCAL_INSTRUMENTS) ? $code :
'CORE');
519 if ($val ==
'BankCode') {
520 $string .= $this->code_banque.
' ';
521 } elseif ($val ==
'BankAccountNumber') {
522 $string .= $this->number.
' ';
523 } elseif ($val ==
'DeskCode') {
524 $string .= $this->code_guichet.
' ';
525 } elseif ($val ==
'BankAccountNumberKey') {
526 $string .= $this->cle_rib.
' ';
527 } elseif ($val ==
'BIC') {
528 $string .= $this->bic.
' ';
529 } elseif ($val ==
'IBAN') {
530 $string .= $this->iban.
' ';
534 return trim($string);
545 if (empty($this->rappro)) {
574 $sqlcheck =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"bank_url";
575 $sqlcheck .=
" WHERE fk_bank = ".((int) $line_id);
576 $sqlcheck .=
" AND url_id = ".((int) $url_id);
577 $sqlcheck .=
" AND type = '".$this->db->escape($type).
"'";
578 $resqlcheck = $this->db->query($sqlcheck);
580 $obj = $this->db->fetch_object($resqlcheck);
582 $this->db->free($resqlcheck);
583 return (
int) $obj->rowid;
585 $this->db->free($resqlcheck);
588 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
594 $sql .=
") VALUES (";
595 $sql .= ((int) $line_id);
596 $sql .=
", ".((int) $url_id);
597 $sql .=
", '".$this->db->escape($url).
"'";
598 $sql .=
", '".$this->db->escape($label).
"'";
599 $sql .=
", '".$this->db->escape($type).
"'";
602 dol_syslog(get_class($this).
"::add_url_line", LOG_DEBUG);
603 if ($this->db->query($sql)) {
604 $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bank_url");
607 $this->
error = $this->db->lasterror();
622 public function get_url($fk_bank = 0, $url_id = 0, $type =
'')
628 if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) {
629 $this->
error =
"ErrorBadParameter";
633 $sql =
"SELECT fk_bank, url_id, url, label, type";
634 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_url";
636 $sql .=
" WHERE fk_bank = ".((int) $fk_bank);
638 $sql .=
" WHERE url_id = ".((int) $url_id).
" AND type = '".$this->db->escape($type).
"'";
640 $sql .=
" ORDER BY type, label";
642 dol_syslog(get_class($this).
"::get_url", LOG_DEBUG);
643 $result = $this->db->query($sql);
646 $num = $this->db->num_rows($result);
648 $obj = $this->db->fetch_object($result);
650 $lines[$i][0] = $obj->url;
651 $lines[$i][1] = $obj->url_id;
652 $lines[$i][2] = $obj->label;
653 $lines[$i][3] = $obj->type;
655 $lines[$i][
'url'] = $obj->url;
656 $lines[$i][
'url_id'] = $obj->url_id;
657 $lines[$i][
'label'] = $obj->label;
658 $lines[$i][
'type'] = $obj->type;
659 $lines[$i][
'fk_bank'] = $obj->fk_bank;
663 dol_print_error($this->db);
688 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 =
'')
693 if (is_numeric($oper)) {
694 dol_syslog(__METHOD__.
": using numeric operations is deprecated", LOG_WARNING);
697 if (empty($this->
id) && !empty($this->rowid)) {
698 $this->
id = $this->rowid;
702 $emetteur = trim($emetteur);
703 $banque = trim($banque);
704 $label = trim($label);
708 if (is_numeric($oper)) {
709 $sql =
"SELECT code FROM ".MAIN_DB_PREFIX.
"c_paiement";
710 $sql .=
" WHERE id = ".((int) $oper);
711 $sql .=
" AND entity IN (".getEntity(
'c_paiement').
")";
712 $resql = $this->db->query($sql);
714 $obj = $this->db->fetch_object($resql);
717 dol_print_error($this->db,
'Failed to get payment type code');
724 $this->
error = $langs->trans(
"OperNotDefined");
728 $this->
error = $langs->trans(
"ThisIdNotDefined");
732 $this->
error =
"ErrorCashAccountAcceptsOnlyCashMoney";
738 if (is_null($datev) || empty($datev)) {
743 $accline->datec = $now;
744 $accline->dateo = $date;
745 $accline->datev = $datev;
746 $accline->label = $label;
747 $accline->amount = $amount;
748 $accline->amount_main_currency = $amount_main_currency;
749 $accline->fk_user_author = $user->id;
750 $accline->fk_account = $this->id;
751 $accline->fk_type = $oper;
752 $accline->numero_compte = $accountancycode;
753 $accline->num_releve = $num_releve;
754 $accline->note_private = $note_private;
757 $accline->num_chq = $num_chq;
761 $accline->emetteur = $emetteur;
765 $accline->bank_chq = $banque;
768 if ($accline->insert() > 0) {
769 if ($categorie > 0) {
770 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"category_bankline(";
771 $sql .=
"lineid, fk_categ";
772 $sql .=
") VALUES (";
773 $sql .= ((int) $accline->id).
", ".((int) $categorie);
776 $result = $this->db->query($sql);
778 $this->
error = $this->db->lasterror();
779 $this->db->rollback();
790 $this->db->rollback();
803 public function create($user, $notrigger = 0)
805 global $langs,
$conf;
810 if (!$this->min_allowed) {
811 $this->min_allowed = 0;
813 if (!$this->min_desired) {
814 $this->min_desired = 0;
818 if (empty($this->country_id)) {
819 $langs->load(
'errors');
820 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
824 if (empty($this->
ref)) {
825 $langs->load(
'errors');
826 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
830 if (empty($this->date_solde)) {
831 $langs->load(
'errors');
832 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateInitialBalance"));
838 $balance = $this->balance;
839 if (empty($balance) && !empty($this->
solde)) {
840 dol_syslog(get_class($this).
"::create solde is deprecated use balance", LOG_NOTICE);
841 $balance = $this->solde;
843 if (empty($balance)) {
846 if (empty($this->
status && !empty($this->clos))) {
847 dol_syslog(get_class($this).
"::create clos is deprecated use status", LOG_NOTICE);
848 $this->
status = $this->clos;
851 if (empty($this->country_id) && !empty($this->country_code)) {
852 $country_id =
getCountry($this->country_code,
'3');
853 $this->country_id = is_int($country_id) ? $country_id : 0;
857 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
863 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_account (";
868 $sql .=
", account_number";
869 $sql .=
", fk_accountancy_journal";
871 $sql .=
", code_banque";
872 $sql .=
", code_guichet";
876 $sql .=
", iban_prefix";
877 $sql .=
", domiciliation";
878 $sql .=
", pti_in_ctti";
879 $sql .=
", sepa_category_purpose";
880 $sql .=
", sepa_local_instrument";
882 $sql .=
", owner_address";
883 $sql .=
", owner_zip";
884 $sql .=
", owner_town";
885 $sql .=
", owner_country_id";
886 $sql .=
", currency_code";
888 $sql .=
", min_allowed";
889 $sql .=
", min_desired";
891 $sql .=
", state_id";
894 $sql .=
", ics_transfer";
895 $sql .=
") VALUES (";
896 $sql .=
"'".$this->db->idate($now).
"'";
897 $sql .=
", '".$this->db->escape($this->
ref).
"'";
898 $sql .=
", '".$this->db->escape($this->label).
"'";
899 $sql .=
", ".((int)
$conf->entity);
900 $sql .=
", '".$this->db->escape($this->account_number).
"'";
901 $sql .=
", ".($this->fk_accountancy_journal > 0 ? ((int) $this->fk_accountancy_journal) :
"null");
902 $sql .=
", '".$this->db->escape($this->bank).
"'";
903 $sql .=
", '".$this->db->escape($this->code_banque).
"'";
904 $sql .=
", '".$this->db->escape($this->code_guichet).
"'";
905 $sql .=
", '".$this->db->escape($this->number).
"'";
906 $sql .=
", '".$this->db->escape($this->cle_rib).
"'";
907 $sql .=
", '".$this->db->escape($this->bic).
"'";
908 $sql .=
", '".$this->db->escape($this->iban).
"'";
909 $sql .=
", '".$this->db->escape($this->
address).
"'";
910 $sql .=
", ".((int) $this->pti_in_ctti);
913 $sql .=
", '".$this->db->escape($this->owner_name).
"'";
914 $sql .=
", '".$this->db->escape($this->owner_address).
"'";
915 $sql .=
", '".$this->db->escape($this->owner_zip).
"'";
916 $sql .=
", '".$this->db->escape($this->owner_town).
"'";
917 $sql .=
", ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
918 $sql .=
", '".$this->db->escape($this->currency_code).
"'";
919 $sql .=
", ".((int) $this->rappro);
920 $sql .=
", ".price2num($this->min_allowed,
'MT');
921 $sql .=
", ".price2num($this->min_desired,
'MT');
922 $sql .=
", '".$this->db->escape($this->comment).
"'";
923 $sql .=
", ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
924 $sql .=
", ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
925 $sql .=
", '".$this->db->escape($this->ics).
"'";
926 $sql .=
", '".$this->db->escape($this->ics_transfer).
"'";
929 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
930 $resql = $this->db->query($sql);
932 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bank_account");
934 $result = $this->
update($user, 1);
937 $accline->datec = $now;
938 $accline->label =
'('.$langs->trans(
"InitialBankBalance").
')';
939 $accline->amount = (float)
price2num($balance);
940 $accline->fk_user_author = $user->id;
941 $accline->fk_account = $this->id;
942 $accline->datev = $this->date_solde;
943 $accline->dateo = $this->date_solde;
944 $accline->fk_type =
'SOLD';
946 if ($accline->insert() < 0) {
958 if (!$error && !$notrigger) {
960 $result = $this->call_trigger(
'BANKACCOUNT_CREATE', $user);
970 if ($this->db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
971 $this->
error = $langs->trans(
"ErrorBankLabelAlreadyExists");
974 $this->
error = $this->db->error().
" sql=".$sql;
983 $this->db->rollback();
995 public function update($user, $notrigger = 0)
997 global $langs,
$conf;
999 if (empty($this->country_id) && !empty($this->country_code)) {
1000 $country_id =
getCountry($this->country_code,
'3');
1001 $this->country_id = is_int($country_id) ? $country_id : 0;
1009 if (empty($this->country_id)) {
1010 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
1014 if (empty($this->
ref)) {
1015 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
1019 if (!$this->label) {
1020 $this->label =
"???";
1023 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET";
1024 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
1025 $sql .=
",label = '".$this->db->escape($this->label).
"'";
1026 $sql .=
",courant = ".((int) $this->
type);
1027 $sql .=
",clos = ".((int) $this->
status);
1028 $sql .=
",rappro = ".((int) $this->rappro);
1029 $sql .=
",url = ".($this->url ?
"'".$this->db->escape($this->url).
"'" :
"null");
1030 $sql .=
",account_number = '".$this->db->escape($this->account_number).
"'";
1031 $sql .=
",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? ((int) $this->fk_accountancy_journal) :
"null");
1032 $sql .=
",bank = '".$this->db->escape($this->bank).
"'";
1033 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
1034 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
1035 $sql .=
",number='".$this->db->escape($this->number).
"'";
1036 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
1037 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
1038 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
1039 $sql .=
",domiciliation='".$this->db->escape($this->
address).
"'";
1040 $sql .=
",pti_in_ctti=".((int) $this->pti_in_ctti);
1043 $sql .=
",proprio = '".$this->db->escape($this->owner_name).
"'";
1044 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
1045 $sql .=
",owner_zip = '".$this->db->escape($this->owner_zip).
"'";
1046 $sql .=
",owner_town = '".$this->db->escape($this->owner_town).
"'";
1047 $sql .=
",owner_country_id = ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
1049 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
1051 $sql .=
",min_allowed = ".($this->min_allowed !=
'' ?
price2num($this->min_allowed) :
"null");
1052 $sql .=
",min_desired = ".($this->min_desired !=
'' ?
price2num($this->min_desired) :
"null");
1053 $sql .=
",comment = '".$this->db->escape($this->comment).
"'";
1055 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
1056 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
1057 $sql .=
",ics = '".$this->db->escape($this->ics).
"'";
1058 $sql .=
",ics_transfer = '".$this->db->escape($this->ics_transfer).
"'";
1060 $sql .=
" WHERE rowid = ".((int) $this->
id);
1062 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1063 $result = $this->db->query($sql);
1073 if (!$error && !empty($this->oldref) && $this->oldref !== $this->
ref) {
1074 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'bank/".$this->db->escape($this->
ref).
"'";
1075 $sql .=
" WHERE filepath = 'bank/".$this->db->escape($this->oldref).
"' and src_object_type = 'bank_account' and entity = ".((int)
$conf->entity);
1076 $resql = $this->db->query($sql);
1079 $this->
error = $this->db->lasterror();
1085 $dirsource =
$conf->bank->dir_output.
'/'.$oldref;
1086 $dirdest =
$conf->bank->dir_output.
'/'.$newref;
1087 if (file_exists($dirsource)) {
1088 dol_syslog(get_class($this).
"::update rename dir ".$dirsource.
" into ".$dirdest, LOG_DEBUG);
1089 if (@rename($dirsource, $dirdest)) {
1095 if (!$error && !$notrigger) {
1097 $result = $this->call_trigger(
'BANKACCOUNT_MODIFY', $user);
1105 $this->
error = $this->db->lasterror();
1106 dol_print_error($this->db);
1110 $this->db->commit();
1113 $this->db->rollback();
1129 global
$conf, $langs;
1132 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1134 dol_syslog(get_class($this).
"::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
1138 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->trans(
"Ref"));
1142 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET";
1143 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
1144 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
1145 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
1146 $sql .=
",number='".$this->db->escape($this->number).
"'";
1147 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
1148 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
1149 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
1150 $sql .=
",domiciliation='".$this->db->escape($this->
address).
"'";
1151 $sql .=
",proprio = '".$this->db->escape($this->owner_name).
"'";
1152 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
1153 $sql .=
",owner_zip = '".$this->db->escape($this->owner_zip).
"'";
1154 $sql .=
",owner_town = '".$this->db->escape($this->owner_town).
"'";
1155 $sql .=
",owner_country_id = ".($this->owner_country_id > 0 ? ((int) $this->owner_country_id) :
"null");
1156 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
1157 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
1158 $sql .=
" WHERE rowid = ".((int) $this->
id);
1159 $sql .=
" AND entity = ".((int)
$conf->entity);
1161 dol_syslog(get_class($this).
"::update_bban", LOG_DEBUG);
1163 $result = $this->db->query($sql);
1167 $this->
error = $this->db->lasterror();
1168 dol_print_error($this->db);
1183 if (empty($id) && empty($ref)) {
1184 $this->
error =
"ErrorBadParameters";
1188 $sql =
"SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant as type, ba.clos as status, ba.rappro, ba.url, ba.entity,";
1189 $sql .=
" ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
1190 $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,";
1191 $sql .=
" ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
1192 $sql .=
" ba.min_allowed, ba.min_desired, ba.comment,";
1193 $sql .=
" ba.datec as date_creation, ba.tms as date_modification, ba.ics, ba.ics_transfer,";
1194 $sql .=
' c.code as country_code, c.label as country,';
1195 $sql .=
' d.code_departement as state_code, d.nom as state,';
1196 $sql .=
' aj.code as accountancy_journal';
1197 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1198 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON ba.fk_pays = c.rowid';
1199 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON ba.state_id = d.rowid';
1200 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal';
1201 $sql .=
" WHERE ba.entity IN (".getEntity($this->element).
")";
1203 $sql .=
" AND ba.rowid = ".((int) $id);
1206 $sql .=
" AND ba.ref = '".$this->db->escape($ref).
"'";
1209 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1210 $result = $this->db->query($sql);
1212 if ($this->db->num_rows($result)) {
1213 $obj = $this->db->fetch_object($result);
1215 $this->
id = $obj->rowid;
1216 $this->rowid = $obj->rowid;
1217 $this->entity = $obj->entity;
1218 $this->
ref = $obj->ref;
1219 $this->label = $obj->label;
1220 $this->
type = $obj->type;
1221 $this->courant = $obj->type;
1222 $this->bank = $obj->bank;
1223 $this->clos = $obj->status;
1224 $this->
status = $obj->status;
1225 $this->rappro = $obj->rappro;
1226 $this->url = $obj->url;
1228 $this->code_banque = $obj->code_banque;
1229 $this->code_guichet = $obj->code_guichet;
1230 $this->number = $obj->number;
1231 $this->cle_rib = $obj->cle_rib;
1232 $this->bic = $obj->bic;
1233 $this->iban = $obj->iban;
1234 $this->
address = $obj->address;
1236 $this->owner_name = $obj->owner_name;
1237 $this->proprio = $this->owner_name;
1238 $this->owner_address = $obj->owner_address;
1239 $this->owner_zip = $obj->owner_zip;
1240 $this->owner_town = $obj->owner_town;
1241 $this->owner_country_id = $obj->owner_country_id;
1243 $this->pti_in_ctti = $obj->pti_in_ctti;
1244 $this->sepa_category_purpose = (in_array($obj->sepa_category_purpose, self::SEPA_CATEGORY_PURPOSES) ? $obj->sepa_category_purpose :
'CORE');
1245 $this->sepa_local_instrument = (in_array($obj->sepa_local_instrument, self::SEPA_LOCAL_INSTRUMENTS) ? $obj->sepa_local_instrument :
'CORE');
1247 $this->state_id = $obj->state_id;
1248 $this->state_code = $obj->state_code;
1249 $this->state = $obj->state;
1251 $this->country_id = $obj->country_id;
1252 $this->country_code = $obj->country_code;
1253 $this->country = $obj->country;
1255 $this->account_number = $obj->account_number;
1256 $this->fk_accountancy_journal = $obj->fk_accountancy_journal;
1257 $this->accountancy_journal = $obj->accountancy_journal;
1259 $this->currency_code = $obj->currency_code;
1260 $this->account_currency_code = $obj->currency_code;
1261 $this->min_allowed = $obj->min_allowed;
1262 $this->min_desired = $obj->min_desired;
1263 $this->comment = $obj->comment;
1265 $this->date_creation = $this->db->jdate($obj->date_creation);
1266 $this->date_modification = $this->db->jdate($obj->date_modification);
1268 $this->ics = $obj->ics;
1269 $this->ics_transfer = $obj->ics_transfer;
1280 $this->
error = $this->db->lasterror();
1281 $this->errors[] = $this->error;
1298 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1299 return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT);
1309 public function delete($user, $notrigger = 0)
1319 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
1320 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1322 $resql = $this->db->query($sql);
1325 $this->
error =
"Error ".$this->db->lasterror();
1330 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
1331 $sql .=
" WHERE rowid = ".((int) $this->
id);
1333 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1334 $result = $this->db->query($sql);
1341 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1346 $this->
error =
"Error ".$this->db->lasterror();
1350 if (!$error && !$notrigger) {
1352 $result = $this->call_trigger(
'BANKACCOUNT_DELETE', $user);
1360 $this->db->commit();
1363 $this->db->rollback();
1392 $langs->load(
'banks');
1394 if ($status == self::STATUS_OPEN) {
1395 $label = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1396 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1397 $statusType =
'status4';
1399 $label = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1400 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1401 $statusType =
'status5';
1404 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1417 $can_be_deleted =
false;
1419 $sql =
"SELECT COUNT(rowid) as nb";
1420 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1421 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1423 $resql = $this->db->query($sql);
1425 $obj = $this->db->fetch_object($resql);
1426 if ($obj->nb <= 1) {
1427 $can_be_deleted =
true;
1430 dol_print_error($this->db);
1432 return $can_be_deleted;
1443 return $this->error;
1454 public function solde($option = 0, $date_end =
'', $field =
'dateo')
1458 $sql =
"SELECT sum(amount) as amount";
1459 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1460 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1462 $sql .=
" AND ".$this->db->sanitize($field).
" <= '".(!empty($date_end) ? $this->db->idate($date_end) : $this->db->idate(
dol_now())).
"'";
1465 $resql = $this->db->query($sql);
1467 if ($this->db->num_rows($resql)) {
1468 $obj = $this->db->fetch_object($resql);
1469 $solde = $obj->amount;
1471 $this->db->free($resql);
1473 $this->errors[] = $this->db->lasterror;
1491 global
$conf, $langs;
1502 $sql =
"SELECT COUNT(b.rowid) as nb,";
1503 $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";
1504 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1505 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1506 $sql .=
" WHERE b.rappro=0";
1507 $sql .=
" AND b.fk_account = ba.rowid";
1508 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1510 $sql .=
" AND clos = 0";
1511 if ($filteraccountid) {
1512 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1514 $resql = $this->db->query($sql);
1516 $langs->load(
"banks");
1518 require_once DOL_DOCUMENT_ROOT.
'/core/class/workboardresponse.class.php';
1521 $response->warning_delay =
$conf->bank->rappro->warning_delay / 60 / 60 / 24;
1522 $response->label = $langs->trans(
"TransactionsToConciliate");
1523 $response->labelShort = $langs->trans(
"TransactionsToConciliateShort");
1524 $response->url = DOL_URL_ROOT.
'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
1525 $response->img = img_object(
'',
"payment");
1527 $obj = $this->db->fetch_object($resql);
1529 $response->nbtodo = (int) $obj->nb;
1530 $response->nbtodolate = (int) $obj->nblate;
1534 dol_print_error($this->db);
1535 $this->
error = $this->db->error();
1554 $sql =
"SELECT count(b.rowid) as nb";
1555 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1556 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1557 $sql .=
" WHERE b.fk_account = ba.rowid";
1558 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1559 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1560 $sql .=
" AND clos = 0";
1561 if ($filteraccountid) {
1562 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1565 $resql = $this->db->query($sql);
1567 while ($obj = $this->db->fetch_object($resql)) {
1568 $this->nb[
"banklines"] = $obj->nb;
1570 $this->db->free($resql);
1573 dol_print_error($this->db);
1574 $this->
error = $this->db->error();
1596 $sql =
"SELECT COUNT(ba.rowid) as nb";
1597 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1598 $sql .=
" WHERE ba.rappro > 0 and ba.clos = 0";
1599 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1604 $resql = $this->db->query($sql);
1606 $obj = $this->db->fetch_object($resql);
1607 $nb = (int) $obj->nb;
1609 dol_print_error($this->db);
1626 $langs->loadLangs([
'banks',
'compta']);
1627 include_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1631 $nofetch = !empty($params[
'nofetch']);
1632 $pictos = img_picto(
'', $this->picto).
' <u class="paddingrightnow">'.$langs->trans(
"BankAccount").
'</u>';
1633 if (isset($this->
status)) {
1634 $pictos .=
' '.$this->getLibStatut(5);
1636 $datas[
'picto'] = $pictos;
1637 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1638 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1639 $datas[
'accountnumber'] =
'<br><br><b>'.$langs->trans(
'AccountNumber').
':</b> '.$this->number;
1641 $datas[
'bic'] =
'<br><b>'.$langs->trans(
'BIC').
':</b> '.$this->bic;
1642 $datas[
'accountcurrency'] =
'<br><br><b>'.$langs->trans(
"AccountCurrency").
':</b> '.$this->currency_code;
1645 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1646 $langs->load(
"accountancy");
1647 $datas[
'accountaccounting'] =
'<br><b>'.$langs->trans(
'AccountAccounting').
':</b> '.
length_accountg($this->account_number);
1648 $datas[
'accountancyjournal'] =
'<br><b>'.$langs->trans(
'AccountancyJournal').
':</b> '.$this->accountancy_journal;
1652 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1653 $form =
new Form($this->db);
1654 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_ACCOUNT, 1);
1671 public function getNomUrl($withpicto = 0, $mode =
'', $option =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1673 global
$conf, $langs;
1675 if (!empty(
$conf->dol_no_mouse_hover)) {
1679 include_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1682 $classfortooltip =
'classfortooltip';
1686 'objecttype' => $this->element,
1687 'option' => $option,
1691 $classfortooltip =
'classforajaxtooltip';
1692 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1698 $baseurl = DOL_URL_ROOT.
'/compta/bank/card.php';
1699 $query = [
'id' => $this->id];
1700 if ($mode ==
'transactions') {
1701 $baseurl = DOL_URL_ROOT.
'/compta/bank/bankentries_list.php';
1702 } elseif ($mode ==
'receipts') {
1703 $baseurl = DOL_URL_ROOT.
'/compta/bank/releve.php';
1704 $query = [
'account' => $this->id];
1707 if ($option !=
'nolink') {
1709 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1710 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1711 $add_save_lastsearch_values = 1;
1713 if ($add_save_lastsearch_values) {
1714 $query = array_merge($query, [
'save_lastsearch_values' => 1]);
1720 if (empty($notooltip)) {
1722 $label = $langs->trans(
"BankAccount");
1723 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1725 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1726 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1728 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1731 if ($option ==
'nolink' || empty($url)) {
1732 $linkstart =
'<span';
1734 $linkstart =
'<a href="'.$url.
'"';
1736 $linkstart .= $linkclose.
'>';
1737 if ($option ==
'nolink' || empty($url)) {
1738 $linkend =
'</span>';
1743 $result .= $linkstart;
1746 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1748 if ($withpicto != 2) {
1749 $result .= $this->
ref.($option ==
'reflabel' && $this->label ?
' - '.$this->label :
'');
1751 $result .= $linkend;
1753 global $action, $hookmanager;
1754 $hookmanager->initHooks(array($this->element .
'dao'));
1755 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1756 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1758 $result = $hookmanager->resPrint;
1760 $result .= $hookmanager->resPrint;
1777 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1784 $this->
error =
'IBANNotValid';
1790 $this->
error =
'SwiftNotValid';
1810 if (!empty($this->country_code)) {
1811 return $this->country_code;
1815 if (!empty($this->iban)) {
1818 if (preg_match(
"/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) {
1824 if (!empty($this->socid)) {
1825 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1826 $company =
new Societe($this->db);
1827 $result = $company->fetch($this->socid);
1828 if (!empty($company->country_code)) {
1829 return $company->country_code;
1834 if (!empty(
$mysoc->country_code)) {
1835 return $mysoc->country_code;
1850 global
$conf, $langs;
1857 if (!empty(
$conf->use_javascript_ajax)) {
1859 $out .=
'<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($coords).
'\',\
''.dol_escape_js($langs->trans(
"HelpCopyToClipboard")).
'\');
">';
1860 $out .= img_picto($langs->trans("Address
"), 'map-marker-alt');
1863 $address = dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
1880 public function getBankFieldLabel($field)
1882 $country_code = $this->getCountryCode();
1884 if ($country_code == 'CA' && $field == 'BankCode') {
1885 return 'InstitutionNumber';
1887 if ($country_code == 'CA' && $field == 'DeskCode') {
1888 return 'TransitNumber';
1890 if ($country_code == 'US' && $field == 'BankCode') {
1891 return 'ABARoutingNumber';
1906 public function useDetailedBBAN()
1908 $country_code = $this->getCountryCode();
1910 if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC', 'DZ'))) {
1911 return 1; // France, Spain, Gabon, ... - Not valid for CH
1913 if ($country_code == 'CA') {
1916 if (in_array($country_code, array('AD', 'AU', 'BE', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) {
1917 return 2; // Australia, England...
1927 public function needIBAN()
1931 if (getDolGlobalString('MAIN_IBAN_IS_NEVER_MANDATORY')) {
1935 $country_code = $this->getCountryCode();
1937 $country_code_in_EEC = array(
1942 'CZ', // Czech republic
1949 'GB', // United Kingdom
1955 'IM', // Isle of Man - Included in UK
1960 'MC', // Monaco - Included in France
1969 'UK', // United Kingdom
1970 //'CH', // Switzerland - No. Swizerland in not in EEC
1973 if (in_array($country_code, $country_code_in_EEC)) {
1974 return 1; // France, Spain, ...
1984 public function needBIC()
1986 if (getDolGlobalString('MAIN_IBAN_IS_NEVER_MANDATORY')) {
1990 $country_code = $this->getCountryCode();
1992 $country_code_in_EEC = array(
2004 if (in_array($country_code, $country_code_in_EEC)) {
2005 return 1; // Andorra, Bahrein, ...
2016 public function info($id)
2034 public function getFieldsToShow($includeibanbic = 0)
2036 //Get the required properties depending on the country
2037 $detailedBBAN = $this->useDetailedBBAN();
2039 if ($detailedBBAN == 0) {
2040 $fieldarray = array(
2043 } elseif ($detailedBBAN == 2) {
2044 $fieldarray = array(
2048 } elseif ($detailedBBAN == 3) {
2049 $fieldarray = array(
2055 $fieldarray = self::getAccountNumberOrder();
2058 //if ($this->needIBAN()) { // return always IBAN and BIC (this was old behaviour)
2059 if ($includeibanbic) {
2060 $fieldarray[] = 'IBAN';
2061 $fieldarray[] = 'BIC';
2065 //Get the order the properties are shown
2079 public static function getAccountNumberOrder()
2083 $fieldlists = array(
2086 'BankAccountNumber',
2087 'BankAccountNumberKey'
2090 if (getDolGlobalString('BANK_SHOW_ORDER_OPTION')) {
2091 if (is_numeric(getDolGlobalString('BANK_SHOW_ORDER_OPTION'))) {
2092 if (getDolGlobalString('BANK_SHOW_ORDER_OPTION') == '1') {
2093 $fieldlists = array(
2096 'BankAccountNumberKey',
2101 //Replace the old AccountNumber key with the new BankAccountNumber key
2102 $fieldlists = explode(
2104 preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION)
2120 public function initAsSpecimen()
2122 // Example of IBAN FR7630001007941234567890185
2123 $this->specimen = 1;
2125 $this->label = 'My Big Company Bank account';
2126 $this->clos = Account::STATUS_OPEN;
2127 $this->type = Account::TYPE_CURRENT;
2128 $this->status = Account::STATUS_OPEN;
2129 $this->code_banque = '30001';
2130 $this->code_guichet = '00794';
2131 $this->number = '12345678901';
2132 $this->cle_rib = '85';
2133 $this->bic = 'AA12';
2134 $this->iban = 'FR7630001007941234567890185';
2136 $this->bank = 'MyBank';
2137 $this->address = 'Rue de Paris';
2138 $this->owner_name = 'Owner';
2139 $this->owner_address = 'Owner address';
2140 $this->owner_zip = 'Owner zip';
2141 $this->owner_town = 'Owner town';
2142 $this->owner_country_id = 1;
2143 $this->country_id = 1;
2156 public static function replaceThirdparty($dbs, $origin_id, $dest_id)
2158 $sql = "UPDATE
".MAIN_DB_PREFIX."bank_url SET url_id =
".((int) $dest_id)." WHERE url_id =
".((int) $origin_id)." AND
type =
'company'";
2160 if ($dbs->query($sql)) {
2163 //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.
2164 //$this->errors = $dbs->lasterror();
2176 public function getKanbanView($option = '', $arraydata = null)
2180 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
2182 $return = '<div class="box-flex-item box-flex-grow-zero
">';
2183 $return .= '<div class="info-box
info-box-sm
">';
2184 $return .= '<span class="info-box-icon bg-infobox-action
">';
2185 $return .= img_picto('', $this->picto);
2186 $return .= '</span>';
2187 $return .= '<div class="info-box-content
">';
2188 $return .= '<span class="info-box-
ref inline-block tdoverflowmax150 valignmiddle
">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
2189 if ($selected >= 0) {
2190 $return .= '<input id="cb
'.$this->id.'" class="flat checkforselect fright
" type="checkbox
" name="toselect[]
" value="'.$this->id.'"'.($selected ? ' checked="checked
"' : '').'>';
2192 if (property_exists($this, 'type_lib')) {
2193 $return .= '<br><span class="info-box-label opacitymedium
" title="'.$this->type_lib[$this->type].'">'.substr($this->type_lib[$this->type], 0, 24).'...</span>';
2195 if (method_exists($this, 'solde')) {
2196 $return .= '<br><a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?
id=
'.$this->id.'">';
2197 $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>';
2199 if (method_exists($this, 'getLibStatut')) {
2200 $return .= '<br><div class="info-box-
status">'.$this->getLibStatut(3).'</div>';
2202 $return .= '</div>';
2203 $return .= '</div>';
2204 $return .= '</div>';
2210require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
2215class AccountLine extends CommonObjectLine
2225 public $element = 'bank';
2230 public $table_element = 'bank';
2235 public $picto = 'accountline';
2276 public $amount_main_currency;
2281 public $fk_user_author;
2286 public $fk_user_rappro;
2296 public $fk_bordereau;
2306 public $bank_account_ref;
2311 public $bank_account_label;
2316 public $numero_compte;
2358 public $user_rappro;
2366 public function __construct(DoliDB $db)
2379 public function fetch($rowid, $ref = '', $num = '')
2382 if (empty($rowid) && empty($ref) && empty($num)) {
2386 $sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,
";
2387 $sql .= " b.fk_user_author, b.fk_user_rappro,
";
2388 $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,
";
2389 $sql .= " b.fk_bordereau, b.banque, b.emetteur,
";
2390 $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label
";
2391 $sql .= " FROM
".MAIN_DB_PREFIX."bank as b,
";
2392 $sql .= " ".MAIN_DB_PREFIX."bank_account as ba
";
2393 $sql .= " WHERE b.fk_account = ba.rowid
";
2394 $sql .= " AND ba.entity IN (
".getEntity('bank_account').")
";
2396 $sql .= " AND b.num_chq =
'".$this->db->escape($num)."'";
2398 $sql .= " AND b.rowid =
'".$this->db->escape($ref)."'";
2400 $sql .= " AND b.rowid =
".((int) $rowid);
2403 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
2404 $result = $this->db->query($sql);
2408 $obj = $this->db->fetch_object($result);
2410 $this->id = $obj->rowid;
2411 $this->rowid = $obj->rowid;
2412 $this->ref = $obj->rowid;
2414 $this->datec = $this->db->jdate($obj->datec);
2415 $this->datev = $this->db->jdate($obj->datev);
2416 $this->dateo = $this->db->jdate($obj->dateo);
2417 $this->amount = $obj->amount;
2418 $this->label = $obj->label;
2419 $this->note = $obj->note;
2421 $this->fk_user_author = $obj->fk_user_author;
2422 $this->fk_user_rappro = $obj->fk_user_rappro;
2424 $this->fk_type = $obj->fk_type; // Type of transaction
2425 $this->rappro = (int) $obj->rappro;
2426 $this->num_releve = $obj->num_releve;
2428 $this->num_chq = $obj->num_chq;
2429 $this->bank_chq = $obj->banque;
2430 $this->fk_bordereau = $obj->fk_bordereau;
2432 $this->fk_account = $obj->fk_account;
2433 $this->bank_account_ref = $obj->bank_account_ref;
2434 $this->bank_account_label = $obj->bank_account_label;
2436 // Retrieve all extrafield
2437 // fetch optionals attributes and labels
2438 $this->fetch_optionals();
2442 $this->db->free($result);
2454 public function insert()
2460 $sql = "INSERT INTO
".MAIN_DB_PREFIX."bank (
";
2466 $sql .= ", amount_main_currency
";
2467 $sql .= ", fk_user_author
";
2468 $sql .= ", num_chq
";
2469 $sql .= ", fk_account
";
2470 $sql .= ", fk_type
";
2471 $sql .= ", emetteur,banque
";
2473 $sql .= ", numero_compte
";
2474 $sql .= ", num_releve
";
2476 $sql .= ") VALUES (
";
2477 $sql .= "'".$this->db->idate($this->datec)."'";
2478 $sql .= ",
'".$this->db->idate($this->dateo)."'";
2479 $sql .= ",
'".$this->db->idate($this->datev)."'";
2480 $sql .= ",
'".$this->db->escape($this->label)."'";
2481 $sql .= ",
".price2num($this->amount);
2482 $sql .= ",
".(empty($this->amount_main_currency) ? "NULL
" : price2num($this->amount_main_currency));
2483 $sql .= ",
".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null");
2484 $sql .= ",
".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null");
2485 $sql .= ",
'".$this->db->escape((string) $this->fk_account)."'";
2486 $sql .= ",
'".$this->db->escape($this->fk_type)."'";
2487 $sql .= ",
".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null");
2488 $sql .= ",
".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null");
2489 $sql .= ",
".(int) $this->rappro;
2490 $sql .= ",
".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''");
2491 $sql .= ",
".($this->num_releve ? "'".$this->db->escape($this->num_releve)."'" : "null");
2492 $sql .= ",
".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
2496 dol_syslog(get_class($this)."::insert
", LOG_DEBUG);
2497 $resql = $this->db->query($sql);
2499 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank');
2500 // Actions on extra fields (by external module or standard code)
2501 $result = $this->insertExtraFields();
2507 $this->error = $this->db->lasterror();
2508 dol_print_error($this->db);
2512 $this->db->commit();
2515 $this->db->rollback();
2527 public function delete($user, $notrigger = 0)
2531 if ($this->rappro) {
2532 // Protection to avoid any delete of consolidated lines
2533 $this->error = "ErrorDeleteNotPossibleLineIsConsolidated
";
2541 $result = $this->call_trigger('BANKACCOUNTLINE_DELETE', $user);
2543 $this->db->rollback();
2546 // End call triggers
2549 // Protection to avoid any delete of accounted lines. Protection on by default
2550 if (!getDolGlobalString('BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING')) {
2551 $sql = "SELECT COUNT(rowid) as nb FROM
".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type =
'bank' AND fk_doc =
".((int) $this->id);
2552 $resql = $this->db->query($sql);
2554 $obj = $this->db->fetch_object($resql);
2555 if ($obj && $obj->nb) {
2556 $this->error = 'ErrorRecordAlreadyInAccountingDeletionNotPossible';
2557 $this->db->rollback();
2561 $this->error = $this->db->lasterror();
2562 $this->db->rollback();
2568 $result = $this->delete_urls($user);
2573 $sql = "DELETE FROM
".MAIN_DB_PREFIX."category_bankline WHERE lineid=
".(int) $this->rowid;
2574 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
2575 $result = $this->db->query($sql);
2580 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank_extrafields WHERE fk_object=
".(int) $this->rowid;
2581 $result = $this->db->query($sql);
2586 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank WHERE rowid=
".(int) $this->rowid;
2587 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
2588 $result = $this->db->query($sql);
2594 $this->db->commit();
2597 $this->db->rollback();
2603 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2610 public function delete_urls($user = null)
2615 if ($this->rappro) {
2616 // Protection to avoid any delete of consolidated lines
2617 $this->error = "ErrorDeleteNotPossibleLineIsConsolidated
";
2623 $sql = "DELETE FROM
".MAIN_DB_PREFIX."bank_url WHERE fk_bank=
".(int) $this->rowid;
2624 dol_syslog(get_class($this)."::delete_urls
", LOG_DEBUG);
2625 $result = $this->db->query($sql);
2631 $this->db->commit();
2634 $this->db->rollback();
2647 public function update(User $user, $notrigger = 0)
2651 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2652 $sql .= " amount =
".price2num($this->amount).",
";
2653 $sql .= " datev=
'".$this->db->idate($this->datev)."',
";
2654 $sql .= " dateo=
'".$this->db->idate($this->dateo)."'";
2655 $sql .= " WHERE rowid =
".((int) $this->rowid);
2657 dol_syslog(get_class($this)."::update", LOG_DEBUG);
2658 $resql = $this->db->query($sql);
2660 $this->db->rollback();
2661 $this->error = $this->db->error();
2667 $result = $this->call_trigger('BANKACCOUNTLINE_MODIFY', $user);
2669 $this->db->rollback();
2672 // End call triggers
2675 $this->db->commit();
2685 public function updateLabel()
2689 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2690 $sql .= " label =
'".$this->db->escape($this->label)."'";
2691 $sql .= " WHERE rowid =
".((int) $this->rowid);
2693 dol_syslog(get_class($this)."::update_label
", LOG_DEBUG);
2694 $resql = $this->db->query($sql);
2696 $this->db->commit();
2699 $this->db->rollback();
2700 $this->error = $this->db->error();
2706 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2716 public function update_conciliation(User $user, $cat, $conciliated = 1, $notrigger = 0)
2719 global $conf, $langs;
2723 // Check statement field
2724 if (getDolGlobalString('BANK_STATEMENT_REGEX_RULE')) {
2725 if (!preg_match('/' . getDolGlobalString('BANK_STATEMENT_REGEX_RULE').'/', $this->num_releve)) {
2726 $this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex
", getDolGlobalString('BANK_STATEMENT_REGEX_RULE'));
2727 $this->db->rollback();
2732 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2733 $sql .= " rappro =
".((int) $conciliated);
2734 $sql .= ", num_releve =
'".$this->db->escape($this->num_releve)."'";
2736 $sql .= ", fk_user_rappro =
".((int) $user->id);
2738 $sql .= " WHERE rowid =
".((int) $this->id);
2740 dol_syslog(get_class($this)."::update_conciliation
", LOG_DEBUG);
2741 $resql = $this->db->query($sql);
2743 if (!empty($cat) && $cat > 0) {
2744 $sql = "INSERT INTO
".MAIN_DB_PREFIX."category_bankline (
";
2746 $sql .= ", fk_categ
";
2747 $sql .= ") VALUES (
";
2748 $sql .= ((int) $this->id);
2749 $sql .= ",
".((int) $cat);
2752 dol_syslog(get_class($this)."::update_conciliation
", LOG_DEBUG);
2753 $this->db->query($sql);
2755 // No error check. Can fail if category already affected
2756 // TODO Do no try the insert if link already exists
2759 $this->rappro = (int) $conciliated;
2763 $result = $this->call_trigger('BANKACCOUNTLINE_MODIFY', $user);
2765 $this->db->rollback();
2768 // End call triggers
2771 $this->db->commit();
2774 $this->db->rollback();
2780 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2788 public function datev_change($rowid, $sign = 1)
2791 $sql = "SELECT datev FROM
".MAIN_DB_PREFIX."bank WHERE rowid =
".((int) $rowid);
2792 $resql = $this->db->query($sql);
2794 $obj = $this->db->fetch_object($resql);
2795 $newdate = (int) $this->db->jdate($obj->datev) + (3600 * 24 * $sign);
2797 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2798 $sql .= " datev =
'".$this->db->idate($newdate)."'";
2799 $sql .= " WHERE rowid =
".((int) $rowid);
2801 $result = $this->db->query($sql);
2803 if ($this->db->affected_rows($result)) {
2807 dol_print_error($this->db);
2811 dol_print_error($this->db);
2816 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2823 public function datev_next($id)
2826 return $this->datev_change($id, 1);
2829 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2836 public function datev_previous($id)
2839 return $this->datev_change($id, -1);
2843 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2851 public function dateo_change($rowid, $sign = 1)
2854 $sql = "SELECT dateo FROM
".MAIN_DB_PREFIX."bank WHERE rowid =
".((int) $rowid);
2855 $resql = $this->db->query($sql);
2857 $obj = $this->db->fetch_object($resql);
2858 $newdate = (int) $this->db->jdate($obj->dateo) + (3600 * 24 * $sign);
2860 $sql = "UPDATE
".MAIN_DB_PREFIX."bank SET
";
2861 $sql .= " dateo =
'".$this->db->idate($newdate)."'";
2862 $sql .= " WHERE rowid =
".((int) $rowid);
2864 $result = $this->db->query($sql);
2866 if ($this->db->affected_rows($result)) {
2870 dol_print_error($this->db);
2874 dol_print_error($this->db);
2879 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2886 public function dateo_next($id)
2889 return $this->dateo_change($id, 1);
2892 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2899 public function dateo_previous($id)
2902 return $this->dateo_change($id, -1);
2912 public function info($id)
2914 $sql = 'SELECT b.rowid, b.datec, b.tms as datem,';
2915 $sql .= ' b.fk_user_author, b.fk_user_rappro';
2916 $sql .= ' FROM '.MAIN_DB_PREFIX.'bank as b';
2917 $sql .= ' WHERE b.rowid = '.((int) $id);
2919 $result = $this->db->query($sql);
2921 if ($this->db->num_rows($result)) {
2922 $obj = $this->db->fetch_object($result);
2924 $this->id = $obj->rowid;
2926 $this->user_creation_id = $obj->fk_user_author;
2927 $this->fk_user_rappro = $obj->fk_user_rappro;
2928 $this->user_rappro = $obj->fk_user_rappro;
2929 $this->date_creation = $this->db->jdate($obj->datec);
2930 $this->date_modification = $this->db->jdate($obj->datem);
2931 //$this->date_rappro = $obj->daterappro; // Not yet managed
2933 $this->db->free($result);
2935 dol_print_error($this->db);
2949 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0)
2951 global $conf, $langs;
2955 $label = img_picto('', $this->picto).' <u>'.$langs->trans("BankTransactionLine
").'</u>:<br>';
2956 $label .= '<b>'.$langs->trans("Ref
").':</b> '.$this->ref;
2957 if ($this->amount) {
2958 $label .= '<br><strong>'.$langs->trans("Amount
").':</strong> '.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency);
2961 $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
">';
2964 $result .= $linkstart;
2966 $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);
2968 if ($withpicto != 2) {
2969 $result .= ($this->ref ? $this->ref : $this->id);
2972 $result .= $linkend;
2974 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
2975 $result .= ' <span class="opacitymedium
">(';
2977 if ($option == 'showall') {
2978 $result .= $langs->trans("BankAccount
").': ';
2979 $accountstatic = new Account($this->db);
2980 $accountstatic->id = $this->fk_account;
2981 $accountstatic->ref = $this->bank_account_ref;
2982 $accountstatic->label = $this->bank_account_label;
2983 $result .= $accountstatic->getNomUrl(0).', ';
2985 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
2986 $result .= $langs->trans("BankLineConciliated
").': ';
2987 $result .= yn($this->rappro);
2989 if (isModEnabled('accounting') && ($option == 'showall' || $option == 'showconciliatedandaccounted')) {
2990 $sql = "SELECT COUNT(rowid) as nb, MAX(piece_num) as banktransactionid FROM
".MAIN_DB_PREFIX."accounting_bookkeeping
";
2991 $sql .= " WHERE doc_type =
'bank' AND fk_doc =
".((int) $this->id);
2992 $resql = $this->db->query($sql);
2994 $obj = $this->db->fetch_object($resql);
2995 if ($obj && $obj->nb) {
2996 $result .= ' - '.$langs->trans("Accounted
").': <span title="'.$langs->trans("TransactionNumShort").' '.$obj->banktransactionid.'">'.yn(1).'</span>';
2998 $result .= ' - '.$langs->trans("Accounted
").': '.yn(0);
3002 if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') {
3003 $result .= ')</span>';
3006 global $action, $hookmanager;
3007 $hookmanager->initHooks(array($this->element . 'dao'));
3008 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
3009 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
3011 $result = $hookmanager->resPrint;
3013 $result .= $hookmanager->resPrint;
3026 public function getLibStatut($mode = 0)
3028 return $this->LibStatut($this->status, $mode);
3031 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
3039 public function LibStatut($status, $mode = 0)
3051 public function getVentilExportCompta($mode = 0)
3053 $alreadydispatched = 0;
3057 $sql = " SELECT
".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb
";
3058 $sql .= " FROM
".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type =
'".$this->db->escape($type)."' AND ab.fk_doc =
".((int) $this->id);
3059 $resql = $this->db->query($sql);
3061 $obj = $this->db->fetch_object($resql);
3063 $alreadydispatched = $obj->nb;
3066 $this->error = $this->db->lasterror();
3070 if ($alreadydispatched) {
3071 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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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, $currencycode='')
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.
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
div refaddress div address