31 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $element =
'bank_account';
47 public $table_element =
'bank_account';
52 public $picto =
'account';
89 public $clos = self::STATUS_OPEN;
113 public $code_guichet;
149 public $owner_address;
160 public $type_lib = array();
167 public $status = array();
173 public $account_number;
178 public $fk_accountancy_journal;
184 public $currency_code;
191 public $account_currency_code;
246 public $fields = array(
247 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
248 'ref' =>array(
'type'=>
'varchar(12)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'showoncombobox'=>1,
'position'=>25),
249 'label' =>array(
'type'=>
'varchar(30)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
250 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>35,
'index'=>1),
251 'bank' =>array(
'type'=>
'varchar(60)',
'label'=>
'Bank',
'enabled'=>1,
'visible'=>-1,
'position'=>40),
252 'code_banque' =>array(
'type'=>
'varchar(128)',
'label'=>
'Code banque',
'enabled'=>1,
'visible'=>-1,
'position'=>45),
253 'code_guichet' =>array(
'type'=>
'varchar(6)',
'label'=>
'Code guichet',
'enabled'=>1,
'visible'=>-1,
'position'=>50),
254 'number' =>array(
'type'=>
'varchar(255)',
'label'=>
'Number',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
255 'cle_rib' =>array(
'type'=>
'varchar(5)',
'label'=>
'Cle rib',
'enabled'=>1,
'visible'=>-1,
'position'=>60),
256 'bic' =>array(
'type'=>
'varchar(11)',
'label'=>
'Bic',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
257 'iban_prefix' =>array(
'type'=>
'varchar(34)',
'label'=>
'Iban prefix',
'enabled'=>1,
'visible'=>-1,
'position'=>70),
258 'country_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Country iban',
'enabled'=>1,
'visible'=>-1,
'position'=>75),
259 'cle_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Cle iban',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
260 'domiciliation' =>array(
'type'=>
'varchar(255)',
'label'=>
'Domiciliation',
'enabled'=>1,
'visible'=>-1,
'position'=>85),
261 'state_id' =>array(
'type'=>
'integer',
'label'=>
'State id',
'enabled'=>1,
'visible'=>-1,
'position'=>90),
262 'fk_pays' =>array(
'type'=>
'integer',
'label'=>
'Fk pays',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>95),
263 'proprio' =>array(
'type'=>
'varchar(60)',
'label'=>
'Proprio',
'enabled'=>1,
'visible'=>-1,
'position'=>100),
264 'owner_address' =>array(
'type'=>
'text',
'label'=>
'Owner address',
'enabled'=>1,
'visible'=>-1,
'position'=>105),
265 'courant' =>array(
'type'=>
'smallint(6)',
'label'=>
'Courant',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>110),
266 'clos' =>array(
'type'=>
'smallint(6)',
'label'=>
'Clos',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>115),
267 'rappro' =>array(
'type'=>
'smallint(6)',
'label'=>
'Rappro',
'enabled'=>1,
'visible'=>-1,
'position'=>120),
268 'url' =>array(
'type'=>
'varchar(128)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>125),
269 'account_number' =>array(
'type'=>
'varchar(32)',
'label'=>
'Account number',
'enabled'=>1,
'visible'=>-1,
'position'=>130),
270 'accountancy_journal' =>array(
'type'=>
'varchar(20)',
'label'=>
'Accountancy journal',
'enabled'=>1,
'visible'=>-1,
'position'=>135),
271 'currency_code' =>array(
'type'=>
'varchar(3)',
'label'=>
'Currency code',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>140),
272 'min_allowed' =>array(
'type'=>
'integer',
'label'=>
'Min allowed',
'enabled'=>1,
'visible'=>-1,
'position'=>145),
273 'min_desired' =>array(
'type'=>
'integer',
'label'=>
'Min desired',
'enabled'=>1,
'visible'=>-1,
'position'=>150),
274 'comment' =>array(
'type'=>
'text',
'label'=>
'Comment',
'enabled'=>1,
'visible'=>-1,
'position'=>155),
275 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>156),
276 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>157),
277 'fk_user_author' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user author',
'enabled'=>1,
'visible'=>-1,
'position'=>160),
278 'fk_user_modif' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>165),
279 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>0,
'position'=>170),
280 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>175),
281 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>180),
282 'extraparams' =>array(
'type'=>
'varchar(255)',
'label'=>
'Extraparams',
'enabled'=>1,
'visible'=>-1,
'position'=>185),
283 'fk_accountancy_journal' =>array(
'type'=>
'integer',
'label'=>
'Fk accountancy journal',
'enabled'=>1,
'visible'=>-1,
'position'=>190),
300 const STATUS_OPEN = 0;
301 const STATUS_CLOSED = 1;
316 $this->type_lib = array(
317 self::TYPE_SAVINGS => $langs->trans(
"BankType0"),
318 self::TYPE_CURRENT => $langs->trans(
"BankType1"),
319 self::TYPE_CASH => $langs->trans(
"BankType2"),
322 $this->status = array(
323 self::STATUS_OPEN => $langs->trans(
"StatusAccountOpened"),
324 self::STATUS_CLOSED => $langs->trans(
"StatusAccountClosed")
337 if ($val ==
'BankCode') {
338 $string .= $this->code_banque.
' ';
339 } elseif ($val ==
'BankAccountNumber') {
340 $string .= $this->number.
' ';
341 } elseif ($val ==
'DeskCode') {
342 $string .= $this->code_guichet.
' ';
343 } elseif ($val ==
'BankAccountNumberKey') {
344 $string .= $this->cle_rib.
' ';
345 } elseif ($val ==
'BIC') {
346 $string .= $this->bic.
' ';
347 } elseif ($val ==
'IBAN') {
348 $string .= $this->iban.
' ';
352 return trim($string);
365 if (empty($this->rappro))
return -1;
366 if ($this->courant ==
Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT))
return -2;
367 if ($this->clos)
return -3;
386 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
392 $sql .=
") VALUES (";
393 $sql .=
" ".((int) $line_id);
394 $sql .=
", '".$this->db->escape($url_id).
"'";
395 $sql .=
", '".$this->db->escape($url).
"'";
396 $sql .=
", '".$this->db->escape($label).
"'";
397 $sql .=
", '".$this->db->escape($type).
"'";
400 dol_syslog(get_class($this).
"::add_url_line", LOG_DEBUG);
401 if ($this->
db->query($sql))
403 $rowid = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_url");
406 $this->
error = $this->
db->lasterror();
421 public function get_url($fk_bank =
'', $url_id =
'', $type =
'')
427 if (!empty($fk_bank) && (!empty($url_id) || !empty($type)))
429 $this->
error =
"ErrorBadParameter";
433 $sql =
"SELECT fk_bank, url_id, url, label, type";
434 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_url";
436 $sql .=
" WHERE fk_bank = ".$fk_bank;
437 }
else { $sql .=
" WHERE url_id = ".$url_id.
" AND type = '".$this->
db->escape($type).
"'";
439 $sql .=
" ORDER BY type, label";
441 dol_syslog(get_class($this).
"::get_url", LOG_DEBUG);
442 $result = $this->
db->query($sql);
446 $num = $this->
db->num_rows($result);
449 $obj = $this->
db->fetch_object($result);
451 $lines[$i][0] = $obj->url;
452 $lines[$i][1] = $obj->url_id;
453 $lines[$i][2] = $obj->label;
454 $lines[$i][3] = $obj->type;
456 $lines[$i][
'url'] = $obj->url;
457 $lines[$i][
'url_id'] = $obj->url_id;
458 $lines[$i][
'label'] = $obj->label;
459 $lines[$i][
'type'] = $obj->type;
460 $lines[$i][
'fk_bank'] = $obj->fk_bank;
484 public function addline($date, $oper, $label, $amount, $num_chq, $categorie,
User $user, $emetteur =
'', $banque =
'', $accountancycode =
'', $datev = null)
487 if (is_numeric($oper)) {
488 dol_syslog(__METHOD__.
": using numeric operations is deprecated", LOG_WARNING);
492 $emetteur = trim($emetteur);
493 $banque = trim($banque);
497 if (is_numeric($oper))
499 $sql =
"SELECT code FROM ".MAIN_DB_PREFIX.
"c_paiement";
500 $sql .=
" WHERE id=".$oper;
501 $sql .=
" AND entity IN (".getEntity(
'c_paiement').
")";
505 $obj = $this->
db->fetch_object(
$resql);
516 $this->
error =
"oper not defined";
521 $this->
error =
"this->rowid not defined";
526 $this->
error =
"ErrorCashAccountAcceptsOnlyCashMoney";
532 if (is_null($datev) || empty($datev)) $datev = $date;
535 $accline->datec = $now;
536 $accline->dateo = $date;
537 $accline->datev = $datev;
538 $accline->label = $label;
539 $accline->amount = $amount;
540 $accline->fk_user_author = $user->id;
541 $accline->fk_account = $this->rowid;
542 $accline->fk_type = $oper;
543 $accline->numero_compte = $accountancycode;
546 $accline->num_chq = $num_chq;
550 $accline->emetteur = $emetteur;
554 $accline->bank_chq = $banque;
557 if ($accline->insert() > 0) {
558 if ($categorie > 0) {
559 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class (";
560 $sql .=
"lineid, fk_categ";
561 $sql .=
") VALUES (";
562 $sql .= $accline->id.
", ".$categorie;
565 $result = $this->
db->query($sql);
567 $this->
error = $this->
db->lasterror();
568 $this->
db->rollback();
578 $this->
error = $accline->error;
579 $this->errors = $accline->errors;
580 $this->
db->rollback();
595 global $langs, $conf, $hookmanager;
600 if (!$this->min_allowed) $this->min_allowed = 0;
601 if (!$this->min_desired) $this->min_desired = 0;
602 $this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
603 $this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
606 if (empty($this->country_id))
608 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
612 if (empty($this->ref))
614 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
618 if (empty($this->date_solde))
620 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateInitialBalance"));
626 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
632 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_account (";
637 $sql .=
", account_number";
638 $sql .=
", fk_accountancy_journal";
640 $sql .=
", code_banque";
641 $sql .=
", code_guichet";
645 $sql .=
", iban_prefix";
646 $sql .=
", domiciliation";
648 $sql .=
", owner_address";
649 $sql .=
", currency_code";
651 $sql .=
", min_allowed";
652 $sql .=
", min_desired";
654 $sql .=
", state_id";
656 $sql .=
") VALUES (";
657 $sql .=
"'".$this->db->idate($now).
"'";
658 $sql .=
", '".$this->db->escape($this->ref).
"'";
659 $sql .=
", '".$this->db->escape($this->label).
"'";
660 $sql .=
", ".$conf->entity;
661 $sql .=
", '".$this->db->escape($this->account_number).
"'";
662 $sql .=
", ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
663 $sql .=
", '".$this->db->escape($this->bank).
"'";
664 $sql .=
", '".$this->db->escape($this->code_banque).
"'";
665 $sql .=
", '".$this->db->escape($this->code_guichet).
"'";
666 $sql .=
", '".$this->db->escape($this->number).
"'";
667 $sql .=
", '".$this->db->escape($this->cle_rib).
"'";
668 $sql .=
", '".$this->db->escape($this->bic).
"'";
669 $sql .=
", '".$this->db->escape($this->iban).
"'";
670 $sql .=
", '".$this->db->escape($this->domiciliation).
"'";
671 $sql .=
", '".$this->db->escape($this->proprio).
"'";
672 $sql .=
", '".$this->db->escape($this->owner_address).
"'";
673 $sql .=
", '".$this->db->escape($this->currency_code).
"'";
674 $sql .=
", ".$this->rappro;
675 $sql .=
", ".price2num($this->min_allowed);
676 $sql .=
", ".price2num($this->min_desired);
677 $sql .=
", '".$this->db->escape($this->comment).
"'";
678 $sql .=
", ".($this->state_id > 0 ? $this->state_id :
"null");
679 $sql .=
", ".$this->country_id;
682 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
686 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_account");
688 $result = $this->
update($user, 1);
692 $accline->datec = $this->
db->idate($now);
693 $accline->label =
'('.$langs->trans(
"InitialBankBalance").
')';
695 $accline->fk_user_author = $user->id;
696 $accline->fk_account = $this->id;
697 $accline->datev = $this->
db->idate($this->date_solde);
698 $accline->dateo = $this->
db->idate($this->date_solde);
699 $accline->fk_type =
'SOLD';
701 if ($accline->insert() < 0) {
703 $this->
error = $accline->error;
704 $this->errors = $accline->errors;
710 if ($result < 0) $error++;
713 if (!$error && !$notrigger)
716 $result = $this->
call_trigger(
'BANKACCOUNT_CREATE', $user);
717 if ($result < 0) $error++;
724 if ($this->
db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
726 $this->
error = $langs->trans(
"ErrorBankLabelAlreadyExists");
729 $this->
error = $this->
db->error().
" sql=".$sql;
739 $this->
db->rollback();
753 global $langs, $conf, $hookmanager;
760 $this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
761 $this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
764 if (empty($this->country_id))
766 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
770 if (empty($this->ref))
772 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
776 if (!$this->label) $this->label =
"???";
778 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
780 $sql .=
" ref = '".$this->db->escape($this->ref).
"'";
781 $sql .=
",label = '".$this->db->escape($this->label).
"'";
783 $sql .=
",courant = ".$this->courant;
784 $sql .=
",clos = ".$this->clos;
785 $sql .=
",rappro = ".$this->rappro;
786 $sql .=
",url = ".($this->url ?
"'".$this->db->escape($this->url).
"'" :
"null");
787 $sql .=
",account_number = '".$this->db->escape($this->account_number).
"'";
788 $sql .=
",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
789 $sql .=
",bank = '".$this->db->escape($this->bank).
"'";
790 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
791 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
792 $sql .=
",number='".$this->db->escape($this->number).
"'";
793 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
794 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
795 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
796 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
797 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
798 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
800 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
802 $sql .=
",min_allowed = ".($this->min_allowed !=
'' ?
price2num($this->min_allowed) :
"null");
803 $sql .=
",min_desired = ".($this->min_desired !=
'' ?
price2num($this->min_desired) :
"null");
804 $sql .=
",comment = '".$this->db->escape($this->comment).
"'";
806 $sql .=
",state_id = ".($this->state_id > 0 ? $this->state_id :
"null");
807 $sql .=
",fk_pays = ".$this->country_id;
809 $sql .=
" WHERE rowid = ".$this->id;
811 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
812 $result = $this->
db->query($sql);
819 if ($result < 0) $error++;
822 if (!$error && !$notrigger)
825 $result = $this->
call_trigger(
'BANKACCOUNT_UPDATE', $user);
826 if ($result < 0) $error++;
831 $this->
error = $this->
db->lasterror();
840 $this->
db->rollback();
856 global $conf, $langs;
859 $this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
860 $this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
863 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
865 dol_syslog(get_class($this).
"::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
870 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->trans(
"Ref"));
874 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
875 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
876 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
877 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
878 $sql .=
",number='".$this->db->escape($this->number).
"'";
879 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
880 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
881 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
882 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
883 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
884 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
885 $sql .=
",state_id = ".($this->state_id > 0 ? $this->state_id :
"null");
886 $sql .=
",fk_pays = ".$this->country_id;
887 $sql .=
" WHERE rowid = ".$this->id;
888 $sql .=
" AND entity = ".$conf->entity;
890 dol_syslog(get_class($this).
"::update_bban", LOG_DEBUG);
892 $result = $this->
db->query($sql);
897 $this->
error = $this->
db->lasterror();
911 public function fetch($id, $ref =
'')
915 if (empty($id) && empty($ref))
917 $this->
error =
"ErrorBadParameters";
921 $sql =
"SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
922 $sql .=
" ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
923 $sql .=
" ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
924 $sql .=
" ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
925 $sql .=
" ba.min_allowed, ba.min_desired, ba.comment,";
926 $sql .=
" ba.datec as date_creation, ba.tms as date_update,";
927 $sql .=
' c.code as country_code, c.label as country,';
928 $sql .=
' d.code_departement as state_code, d.nom as state';
929 $sql .=
' , aj.code as accountancy_journal';
930 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
931 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON ba.fk_pays = c.rowid';
932 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON ba.state_id = d.rowid';
933 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal';
934 $sql .=
" WHERE ba.entity IN (".getEntity($this->element).
")";
935 if ($id) $sql .=
" AND ba.rowid = ".$id;
936 if ($ref) $sql .=
" AND ba.ref = '".$this->db->escape($ref).
"'";
938 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
939 $result = $this->
db->query($sql);
942 if ($this->
db->num_rows($result))
944 $obj = $this->
db->fetch_object($result);
946 $this->
id = $obj->rowid;
947 $this->
rowid = $obj->rowid;
948 $this->ref = $obj->ref;
949 $this->label = $obj->label;
950 $this->
type = $obj->courant;
951 $this->courant = $obj->courant;
952 $this->bank = $obj->bank;
953 $this->clos = $obj->clos;
954 $this->rappro = $obj->rappro;
955 $this->url = $obj->url;
957 $this->code_banque = $obj->code_banque;
958 $this->code_guichet = $obj->code_guichet;
959 $this->number = $obj->number;
960 $this->cle_rib = $obj->cle_rib;
961 $this->bic = $obj->bic;
962 $this->iban = $obj->iban;
963 $this->domiciliation = $obj->domiciliation;
964 $this->proprio = $obj->proprio;
965 $this->owner_address = $obj->owner_address;
967 $this->state_id = $obj->state_id;
968 $this->state_code = $obj->state_code;
969 $this->state = $obj->state;
971 $this->country_id = $obj->country_id;
972 $this->country_code = $obj->country_code;
973 $this->country = $obj->country;
975 $this->account_number = $obj->account_number;
976 $this->fk_accountancy_journal = $obj->fk_accountancy_journal;
977 $this->accountancy_journal = $obj->accountancy_journal;
979 $this->currency_code = $obj->currency_code;
980 $this->account_currency_code = $obj->currency_code;
981 $this->min_allowed = $obj->min_allowed;
982 $this->min_desired = $obj->min_desired;
983 $this->comment = $obj->comment;
985 $this->date_creation = $this->
db->jdate($obj->date_creation);
986 $this->date_update = $this->
db->jdate($obj->date_update);
997 $this->
error = $this->
db->lasterror;
998 $this->errors[] = $this->error;
1016 if (!is_array($categories)) {
1017 $categories = array($categories);
1021 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1023 $existing = $c->containing($this->
id, Categorie::TYPE_ACCOUNT,
'id');
1026 if (is_array($existing)) {
1027 $to_del = array_diff($existing, $categories);
1028 $to_add = array_diff($categories, $existing);
1031 $to_add = $categories;
1035 foreach ($to_del as $del) {
1036 if ($c->fetch($del) > 0) {
1037 $c->del_type($this, Categorie::TYPE_ACCOUNT);
1040 foreach ($to_add as $add) {
1041 if ($c->fetch($add) > 0) {
1042 $c->add_type($this, Categorie::TYPE_ACCOUNT);
1055 public function delete(
User $user = null)
1066 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
1067 $sql .=
" WHERE fk_account = ".$this->id;
1073 $this->
error =
"Error ".$this->db->lasterror();
1079 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_account";
1080 $sql .=
" WHERE rowid = ".$this->rowid;
1082 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1083 $result = $this->
db->query($sql);
1093 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1098 $this->
error =
"Error ".$this->db->lasterror();
1104 $this->
db->commit();
1107 $this->
db->rollback();
1121 return $this->
LibStatut($this->clos, $mode);
1136 $langs->load(
'banks');
1138 if ($status == self::STATUS_OPEN) {
1139 $label = $langs->trans(
"StatusAccountOpened");
1140 $labelshort = $langs->trans(
"StatusAccountOpened");
1141 $statusType =
'status4';
1143 $label = $langs->trans(
"StatusAccountClosed");
1144 $labelshort = $langs->trans(
"StatusAccountClosed");
1145 $statusType =
'status5';
1148 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1161 $can_be_deleted =
false;
1163 $sql =
"SELECT COUNT(rowid) as nb";
1164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1165 $sql .=
" WHERE fk_account=".$this->id;
1169 $obj = $this->
db->fetch_object(
$resql);
1170 if ($obj->nb <= 1) $can_be_deleted =
true;
1174 return $can_be_deleted;
1185 return $this->error;
1198 $sql =
"SELECT sum(amount) as amount";
1199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1200 $sql .=
" WHERE fk_account = ".$this->id;
1201 if ($option == 1) $sql .=
" AND dateo <= '".$this->db->idate(
dol_now()).
"'";
1208 $obj = $this->
db->fetch_object(
$resql);
1209 $solde = $obj->amount;
1213 $this->errors[] = $this->
db->lasterror;
1231 global $conf, $langs;
1233 if ($user->socid)
return -1;
1235 $sql =
"SELECT b.rowid, b.datev as datefin";
1236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1237 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1238 $sql .=
" WHERE b.rappro=0";
1239 $sql .=
" AND b.fk_account = ba.rowid";
1240 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1241 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1242 $sql .=
" AND clos = 0";
1243 if ($filteraccountid) $sql .=
" AND ba.rowid = ".$filteraccountid;
1248 $langs->load(
"banks");
1251 require_once DOL_DOCUMENT_ROOT.
'/core/class/workboardresponse.class.php';
1254 $response->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24;
1255 $response->label = $langs->trans(
"TransactionsToConciliate");
1256 $response->labelShort = $langs->trans(
"TransactionsToConciliateShort");
1257 $response->url = DOL_URL_ROOT.
'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
1260 while ($obj = $this->
db->fetch_object(
$resql))
1262 $response->nbtodo++;
1263 if ($this->
db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
1264 $response->nbtodolate++;
1271 $this->
error = $this->
db->error();
1287 if ($user->socid)
return -1;
1289 $sql =
"SELECT count(b.rowid) as nb";
1290 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1291 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1292 $sql .=
" WHERE b.fk_account = ba.rowid";
1293 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1294 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1295 $sql .=
" AND clos = 0";
1296 if ($filteraccountid) $sql .=
" AND ba.rowid = ".$filteraccountid;
1301 while ($obj = $this->
db->fetch_object(
$resql))
1303 $this->nb[
"banklines"] = $obj->nb;
1308 $this->
error = $this->
db->error();
1321 global $db, $conf, $user;
1330 $sql =
"SELECT COUNT(ba.rowid) as nb";
1331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1332 $sql .=
" WHERE ba.rappro > 0 and ba.clos = 0";
1333 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1334 if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql .=
" AND ba.courant != 2";
1338 $obj = $this->
db->fetch_object(
$resql);
1355 public function getNomUrl($withpicto = 0, $mode =
'', $option =
'', $save_lastsearch_value = -1, $notooltip = 0)
1357 global $conf, $langs, $user;
1360 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightnow">'.$langs->trans(
"BankAccount").
'</u>';
1361 if (isset($this->status)) {
1362 $label .=
' '.$this->getLibStatut(5);
1364 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1365 $label .=
'<br><b>'.$langs->trans(
'AccountNumber').
':</b> '.$this->number;
1366 $label .=
'<br><b>'.$langs->trans(
'IBAN').
':</b> '.$this->iban;
1367 $label .=
'<br><b>'.$langs->trans(
'BIC').
':</b> '.$this->bic;
1368 $label .=
'<br><b>'.$langs->trans(
"AccountCurrency").
':</b> '.$this->currency_code;
1370 if (empty($user->rights->banque->lire) || !empty($user->socid))
1375 if (!empty($conf->accounting->enabled))
1377 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1378 $langs->load(
"accountancy");
1379 $label .=
'<br><b>'.$langs->trans(
'AccountAccounting').
':</b> '.
length_accountg($this->account_number);
1380 $label .=
'<br><b>'.$langs->trans(
'AccountancyJournal').
':</b> '.$this->accountancy_journal;
1383 $linkclose =
'" title="'.dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
1385 $url = DOL_URL_ROOT.
'/compta/bank/card.php?id='.$this->id;
1386 if ($mode ==
'transactions')
1388 $url = DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?id='.$this->id;
1389 } elseif ($mode ==
'receipts')
1391 $url = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$this->id;
1394 if ($option !=
'nolink')
1397 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1398 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
1399 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
1402 $linkstart =
'<a href="'.$url.$linkclose;
1405 if ($option ==
'nolink') {
1410 $result .= $linkstart;
1411 if ($withpicto) $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1412 if ($withpicto != 2) $result .= $this->ref.($option ==
'reflabel' && $this->label ?
' - '.$this->label :
'');
1413 $result .= $linkend;
1429 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1431 $this->error_number = 0;
1437 $this->error_number = 12;
1438 $this->error_message =
'IBANSWIFTControlError';
1446 if ($this->error_number == 0)
1464 if (!empty($this->country_code))
return $this->country_code;
1467 if (!empty($this->iban))
1471 if (preg_match(
"/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg))
return $reg[1];
1475 if (!empty($this->socid))
1477 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1479 $result = $company->fetch($this->socid);
1480 if (!empty($company->country_code))
return $company->country_code;
1484 if (!empty($mysoc->country_code))
return $mysoc->country_code;
1501 if (in_array($country_code, array(
'FR',
'ES',
'GA',
'IT',
'NC')))
return 1;
1502 if (in_array($country_code, array(
'AU',
'BE',
'CA',
'DE',
'DK',
'GR',
'GB',
'ID',
'IE',
'IR',
'KR',
'NL',
'NZ',
'UK',
'US')))
return 2;
1515 $country_code_in_EEC = array(
1551 if (in_array($country_code, $country_code_in_EEC))
return 1;
1584 if ($detailedBBAN == 0) {
1585 $fieldarray = array(
1588 } elseif ($detailedBBAN == 2) {
1589 $fieldarray = array(
1594 $fieldarray = self::getAccountNumberOrder();
1598 if ($includeibanbic)
1600 $fieldarray[] =
'IBAN';
1601 $fieldarray[] =
'BIC';
1623 $fieldlists = array(
1626 'BankAccountNumber',
1627 'BankAccountNumberKey'
1630 if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) {
1631 if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) {
1632 if ($conf->global->BANK_SHOW_ORDER_OPTION ==
'1') {
1633 $fieldlists = array(
1636 'BankAccountNumberKey',
1642 $fieldlists = explode(
1644 preg_replace(
'/ ?[^Bank]AccountNumber ?/',
'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION)
1662 $this->specimen = 1;
1664 $this->label =
'My Big Company Bank account';
1665 $this->bank =
'MyBank';
1667 $this->clos = Account::STATUS_OPEN;
1668 $this->code_banque =
'123';
1669 $this->code_guichet =
'456';
1670 $this->number =
'ABC12345';
1671 $this->cle_rib =
'50';
1672 $this->bic =
'AA12';
1673 $this->iban =
'FR999999999';
1674 $this->domiciliation =
'My bank address';
1675 $this->proprio =
'Owner';
1676 $this->owner_address =
'Owner address';
1677 $this->country_id = 1;
1700 public $element =
'bank';
1705 public $table_element =
'bank';
1710 public $picto =
'accountline';
1748 public $fk_user_author;
1753 public $fk_user_rappro;
1763 public $fk_bordereau;
1773 public $bank_account_ref;
1778 public $bank_account_label;
1783 public $numero_compte;
1822 public function fetch($rowid, $ref =
'', $num =
'')
1827 if (empty($rowid) && empty($ref) && empty($num))
return -1;
1829 $sql =
"SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,";
1830 $sql .=
" b.fk_user_author, b.fk_user_rappro,";
1831 $sql .=
" b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,";
1832 $sql .=
" b.fk_bordereau, b.banque, b.emetteur,";
1834 $sql .=
" ba.ref as bank_account_ref, ba.label as bank_account_label";
1835 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1836 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1837 $sql .=
" WHERE b.fk_account = ba.rowid";
1838 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1839 if ($num) $sql .=
" AND b.num_chq='".$this->db->escape($num).
"'";
1840 elseif ($ref) $sql .=
" AND b.rowid='".$this->db->escape($ref).
"'";
1841 else $sql .=
" AND b.rowid = ".((int) $rowid);
1843 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1844 $result = $this->
db->query($sql);
1849 $obj = $this->
db->fetch_object($result);
1852 $this->
id = $obj->rowid;
1853 $this->
rowid = $obj->rowid;
1854 $this->ref = $obj->rowid;
1856 $this->datec = $obj->datec;
1857 $this->datev = $obj->datev;
1858 $this->dateo = $obj->dateo;
1859 $this->amount = $obj->amount;
1860 $this->label = $obj->label;
1861 $this->
note = $obj->note;
1863 $this->fk_user_author = $obj->fk_user_author;
1864 $this->fk_user_rappro = $obj->fk_user_rappro;
1866 $this->fk_type = $obj->fk_type;
1867 $this->rappro = $obj->rappro;
1868 $this->num_releve = $obj->num_releve;
1870 $this->num_chq = $obj->num_chq;
1871 $this->bank_chq = $obj->banque;
1872 $this->fk_bordereau = $obj->fk_bordereau;
1874 $this->fk_account = $obj->fk_account;
1875 $this->bank_account_ref = $obj->bank_account_ref;
1876 $this->bank_account_label = $obj->bank_account_label;
1880 $this->
db->free($result);
1894 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank (";
1900 $sql .=
", fk_user_author";
1901 $sql .=
", num_chq";
1902 $sql .=
", fk_account";
1903 $sql .=
", fk_type";
1904 $sql .=
", emetteur,banque";
1906 $sql .=
", numero_compte";
1907 $sql .=
") VALUES (";
1908 $sql .=
"'".$this->db->idate($this->datec).
"'";
1909 $sql .=
", '".$this->db->idate($this->dateo).
"'";
1910 $sql .=
", '".$this->db->idate($this->datev).
"'";
1911 $sql .=
", '".$this->db->escape($this->label).
"'";
1912 $sql .=
", ".price2num($this->amount);
1913 $sql .=
", ".($this->fk_user_author > 0 ? $this->fk_user_author :
"null");
1914 $sql .=
", ".($this->num_chq ?
"'".$this->db->escape($this->num_chq).
"'" :
"null");
1915 $sql .=
", '".$this->db->escape($this->fk_account).
"'";
1916 $sql .=
", '".$this->db->escape($this->fk_type).
"'";
1917 $sql .=
", ".($this->emetteur ?
"'".$this->db->escape($this->emetteur).
"'" :
"null");
1918 $sql .=
", ".($this->bank_chq ?
"'".$this->db->escape($this->bank_chq).
"'" :
"null");
1919 $sql .=
", ".(int) $this->rappro;
1920 $sql .=
", ".($this->numero_compte ?
"'".$this->db->escape($this->numero_compte).
"'" :
"''");
1923 dol_syslog(get_class($this).
"::insert", LOG_DEBUG);
1927 $this->error = $this->
db->lasterror();
1931 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'bank');
1942 public function delete(
User $user = null)
1951 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
1958 if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING))
1960 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id;
1963 $obj = $this->
db->fetch_object(
$resql);
1964 if ($obj && $obj->nb) {
1965 $this->error =
'ErrorRecordAlreadyInAccountingDeletionNotPossible';
1966 $this->
db->rollback();
1970 $this->error = $this->
db->lasterror();
1971 $this->
db->rollback();
1983 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class WHERE lineid=".(int) $this->
rowid;
1984 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1985 $result = $this->
db->query($sql);
1986 if (!$result) $nbko++;
1988 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid=".(int) $this->
rowid;
1989 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1990 $result = $this->
db->query($sql);
1991 if (!$result) $nbko++;
1995 $this->
db->commit();
1998 $this->
db->rollback();
2019 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
2025 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_url WHERE fk_bank=".(int) $this->
rowid;
2026 dol_syslog(get_class($this).
"::delete_urls", LOG_DEBUG);
2027 $result = $this->
db->query($sql);
2028 if (!$result) $nbko++;
2032 $this->
db->commit();
2035 $this->
db->rollback();
2052 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2053 $sql .=
" amount = ".price2num($this->amount).
",";
2054 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
2055 $sql .=
" dateo='".$this->db->idate($this->dateo).
"'";
2056 $sql .=
" WHERE rowid = ".$this->rowid;
2058 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
2062 $this->
db->commit();
2065 $this->
db->rollback();
2066 $this->error = $this->
db->error();
2084 global $conf, $langs;
2089 if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE))
2091 if (!preg_match(
'/'.$conf->global->BANK_STATEMENT_REGEX_RULE.
'/', $this->num_releve))
2093 $this->errors[] = $langs->trans(
"ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE);
2098 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2099 $sql .=
" rappro = ".$conciliated;
2100 $sql .=
", num_releve = '".$this->db->escape($this->num_releve).
"'";
2101 if ($conciliated) $sql .=
", fk_user_rappro = ".$user->id;
2102 $sql .=
" WHERE rowid = ".$this->id;
2104 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2110 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class (";
2112 $sql .=
", fk_categ";
2113 $sql .=
") VALUES (";
2118 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2119 $this->
db->query($sql);
2126 $this->
db->commit();
2129 $this->
db->rollback();
2146 $sql =
"SELECT datev FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".$rowid;
2150 $obj = $this->
db->fetch_object(
$resql);
2151 $newdate = $this->
db->jdate($obj->datev) + (3600 * 24 * $sign);
2153 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2154 $sql .=
" datev = '".$this->db->idate($newdate).
"'";
2155 $sql .=
" WHERE rowid = ".$rowid;
2157 $result = $this->
db->query($sql);
2160 if ($this->
db->affected_rows($result))
2210 $sql =
"SELECT dateo FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".$rowid;
2214 $obj = $this->
db->fetch_object(
$resql);
2215 $newdate = $this->
db->jdate($obj->dateo) + (3600 * 24 * $sign);
2217 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2218 $sql .=
" dateo = '".$this->db->idate($newdate).
"'";
2219 $sql .=
" WHERE rowid = ".$rowid;
2221 $result = $this->
db->query($sql);
2224 if ($this->
db->affected_rows($result))
2271 $sql =
'SELECT b.rowid, b.datec, b.tms as datem,';
2272 $sql .=
' b.fk_user_author, b.fk_user_rappro';
2273 $sql .=
' FROM '.MAIN_DB_PREFIX.
'bank as b';
2274 $sql .=
' WHERE b.rowid = '.$id;
2276 $result = $this->
db->query($sql);
2279 if ($this->
db->num_rows($result))
2281 $obj = $this->
db->fetch_object($result);
2282 $this->
id = $obj->rowid;
2284 if ($obj->fk_user_author)
2286 $cuser =
new User($this->
db);
2287 $cuser->fetch($obj->fk_user_author);
2288 $this->user_creation = $cuser;
2290 if ($obj->fk_user_rappro)
2292 $ruser =
new User($this->
db);
2293 $ruser->fetch($obj->fk_user_rappro);
2294 $this->user_rappro = $ruser;
2297 $this->date_creation = $this->
db->jdate($obj->datec);
2298 $this->date_modification = $this->
db->jdate($obj->datem);
2301 $this->
db->free($result);
2317 public function getNomUrl($withpicto = 0, $maxlen = 0, $option =
'', $notooltip = 0)
2323 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Transaction").
'</u>:<br>';
2324 $label .=
'<b>'.$langs->trans(
"Ref").
':</b> '.$this->ref;
2326 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/line.php?rowid='.$this->
id.
'&save_lastsearch_values=1" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
2329 $result .= $linkstart;
2330 if ($withpicto) $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);
2331 if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id);
2332 $result .= $linkend;
2334 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') $result .=
' <span class="opacitymedium">(';
2335 if ($option ==
'showall')
2337 $result .= $langs->trans(
"BankAccount").
': ';
2338 $accountstatic =
new Account($this->
db);
2339 $accountstatic->id = $this->fk_account;
2340 $accountstatic->ref = $this->bank_account_ref;
2341 $accountstatic->label = $this->bank_account_label;
2342 $result .= $accountstatic->getNomUrl(0).
', ';
2344 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted')
2346 $result .= $langs->trans(
"BankLineConciliated").
': ';
2347 $result .=
yn($this->rappro);
2349 if ($option ==
'showall' || $option ==
'showconciliatedandaccounted')
2351 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id;
2354 $obj = $this->
db->fetch_object(
$resql);
2355 if ($obj && $obj->nb) {
2356 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(1);
2358 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(0);
2362 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') $result .=
')</span>';
2376 return $this->
LibStatut($this->status, $mode);
2433 $alreadydispatched = 0;
2437 $sql =
" SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='".$this->
db->escape($type).
"' AND ab.fk_doc = ".$this->id;
2441 $obj = $this->
db->fetch_object(
$resql);
2444 $alreadydispatched = $obj->nb;
2447 $this->error = $this->
db->lasterror();
2451 if ($alreadydispatched)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
static getAccountNumberOrder()
Returns the components of the bank account in order.
can_be_deleted()
Renvoi si un compte peut etre supprimer ou non (sans mouvements)
update_bban(User $user=null)
Update BBAN (RIB) account fields.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
useDetailedBBAN()
Return if a bank account is defined with detailed information (bank code, desk code, number and key).
load_board(User $user, $filteraccountid=0)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
Class to manage Dolibarr database access.
datev_next($id)
Increase value date of a rowid.
Class to manage bank transaction lines.
const TYPE_CURRENT
Current account.
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
canBeConciliated()
Return if a bank account need to be conciliated.
__construct(DoliDB $db)
Constructor.
$conf db
API class for accounts.
Class to manage bank accounts.
getLibStatut($mode=0)
Return label of object status.
insert()
Inserts a transaction to a bank account.
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
dateo_change($rowid, $sign=1)
Increase/decrease operation date of a rowid.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
needIBAN()
Return 1 if IBAN / BIC is mandatory (otherwise option)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dateo_previous($id)
Decrease operation date of a rowid.
setCategories($categories)
Sets object to supplied categories.
addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur= '', $banque= '', $accountancycode= '', $datev=null)
Add an entry into table ".MAIN_DB_PREFIX."bank.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getCountryCode()
Return account country code.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getLibStatut($mode=0)
Return label of status (activity, closed)
get_url($fk_bank= '', $url_id= '', $type= '')
TODO Move this into AccountLine Return array with links from llx_bank_url.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
deleteExtraFields()
Delete all extra fields values for the current object.
delete_urls(User $user=null)
Delete bank line records.
datev_change($rowid, $sign=1)
Increase/decrease value date of a rowid.
update_conciliation(User $user, $cat, $conciliated=1)
Update conciliation field.
verif()
Return if an account has valid information for Direct debit payment.
update(User $user, $notrigger=0)
Update bank account record in database.
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...
getNomUrl($withpicto=0, $maxlen=0, $option= '', $notooltip=0)
Return clickable name (with picto eventually)
const TYPE_CASH
Cash account.
print $_SERVER["PHP_SELF"]
Edit parameters.
add_url_line($line_id, $url_id, $url, $label, $type)
Add a link between bank line record and its source.
__toString()
Shows the account number in the appropriate format.
create(User $user, $notrigger=0)
Create bank account into database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
solde($option=0)
Return current sold.
checkIbanForAccount($account)
Check IBAN number informations for a bank account.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
load_state_board($filteraccountid=0)
Charge indicateurs this->nb de tableau de bord.
getNomUrl($withpicto=0, $mode= '', $option= '', $save_lastsearch_value=-1, $notooltip=0)
Return clicable name (with picto eventually)
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getFieldsToShow($includeibanbic=0)
Returns the fields in order that this bank account should show to the user Will return an array with ...
update(User $user, $notrigger=0)
Update bank account card.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
const TYPE_SAVINGS
Savings account.
info($id)
Load miscellaneous information for tab "Info".
info($id)
Load miscellaneous information for tab "Info".
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
dateo_next($id)
Increase operation date of a rowid.
__construct(DoliDB $db)
Constructor.
initAsSpecimen()
Initialise an instance with random values.
getVentilExportCompta()
Return if a bank line was dispatched into bookkeeping.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
datev_previous($id)
Decrease value date of a rowid.
fetch($rowid, $ref= '', $num= '')
Load into memory content of a bank transaction line.
if(!empty($search_group)) natural_search(array("g.nom"g note
fetch($id, $ref= '')
Load a bank account into memory from database.
LibStatut($status, $mode=0)
Return label of given object status.
countAccountToReconcile()
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...