33 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
44 public $element =
'bank_account';
49 public $table_element =
'bank_account';
54 public $picto =
'account';
91 public $clos = self::STATUS_OPEN;
115 public $code_guichet;
153 public $domiciliation;
159 public $pti_in_ctti = 0;
171 public $owner_address;
182 public $type_lib = array();
189 public $status = array();
195 public $account_number;
200 public $fk_accountancy_journal;
204 public $accountancy_journal;
210 public $currency_code;
217 public $account_currency_code;
267 public $ics_transfer;
299 public $fields = array(
300 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
301 'ref' =>array(
'type'=>
'varchar(12)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'showoncombobox'=>1,
'position'=>25),
302 'label' =>array(
'type'=>
'varchar(30)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
303 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>35,
'index'=>1),
304 'bank' =>array(
'type'=>
'varchar(60)',
'label'=>
'Bank',
'enabled'=>1,
'visible'=>-1,
'position'=>40),
305 'code_banque' =>array(
'type'=>
'varchar(128)',
'label'=>
'Code banque',
'enabled'=>1,
'visible'=>-1,
'position'=>45),
306 'code_guichet' =>array(
'type'=>
'varchar(6)',
'label'=>
'Code guichet',
'enabled'=>1,
'visible'=>-1,
'position'=>50),
307 'number' =>array(
'type'=>
'varchar(255)',
'label'=>
'Number',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
308 'cle_rib' =>array(
'type'=>
'varchar(5)',
'label'=>
'Cle rib',
'enabled'=>1,
'visible'=>-1,
'position'=>60),
309 'bic' =>array(
'type'=>
'varchar(11)',
'label'=>
'Bic',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
310 'iban_prefix' =>array(
'type'=>
'varchar(34)',
'label'=>
'Iban prefix',
'enabled'=>1,
'visible'=>-1,
'position'=>70),
311 'country_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Country iban',
'enabled'=>1,
'visible'=>-1,
'position'=>75),
312 'cle_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Cle iban',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
313 'domiciliation' =>array(
'type'=>
'varchar(255)',
'label'=>
'Domiciliation',
'enabled'=>1,
'visible'=>-1,
'position'=>85),
314 'state_id' =>array(
'type'=>
'integer',
'label'=>
'State id',
'enabled'=>1,
'visible'=>-1,
'position'=>90),
315 'fk_pays' =>array(
'type'=>
'integer',
'label'=>
'Fk pays',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>95),
316 'proprio' =>array(
'type'=>
'varchar(60)',
'label'=>
'Proprio',
'enabled'=>1,
'visible'=>-1,
'position'=>100),
317 'owner_address' =>array(
'type'=>
'text',
'label'=>
'Owner address',
'enabled'=>1,
'visible'=>-1,
'position'=>105),
318 'courant' =>array(
'type'=>
'smallint(6)',
'label'=>
'Courant',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>110),
319 'clos' =>array(
'type'=>
'smallint(6)',
'label'=>
'Clos',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>115),
320 'rappro' =>array(
'type'=>
'smallint(6)',
'label'=>
'Rappro',
'enabled'=>1,
'visible'=>-1,
'position'=>120),
321 'url' =>array(
'type'=>
'varchar(128)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>125),
322 'account_number' =>array(
'type'=>
'varchar(32)',
'label'=>
'Account number',
'enabled'=>1,
'visible'=>-1,
'position'=>130),
323 'fk_accountancy_journal' =>array(
'type'=>
'integer',
'label'=>
'Accountancy journal ID',
'enabled'=>1,
'visible'=>-1,
'position'=>132),
324 'accountancy_journal' =>array(
'type'=>
'varchar(20)',
'label'=>
'Accountancy journal',
'enabled'=>1,
'visible'=>-1,
'position'=>135),
325 'currency_code' =>array(
'type'=>
'varchar(3)',
'label'=>
'Currency code',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>140),
326 'min_allowed' =>array(
'type'=>
'integer',
'label'=>
'Min allowed',
'enabled'=>1,
'visible'=>-1,
'position'=>145),
327 'min_desired' =>array(
'type'=>
'integer',
'label'=>
'Min desired',
'enabled'=>1,
'visible'=>-1,
'position'=>150),
328 'comment' =>array(
'type'=>
'text',
'label'=>
'Comment',
'enabled'=>1,
'visible'=>-1,
'position'=>155),
329 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>156),
330 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>157),
331 'fk_user_author' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user author',
'enabled'=>1,
'visible'=>-1,
'position'=>160),
332 'fk_user_modif' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>165),
333 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>170),
334 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>175),
335 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>180),
336 'extraparams' =>array(
'type'=>
'varchar(255)',
'label'=>
'Extraparams',
'enabled'=>1,
'visible'=>-1,
'position'=>185),
354 const STATUS_OPEN = 0;
355 const STATUS_CLOSED = 1;
371 $this->type_lib = array(
372 self::TYPE_SAVINGS => $langs->trans(
"BankType0"),
373 self::TYPE_CURRENT => $langs->trans(
"BankType1"),
374 self::TYPE_CASH => $langs->trans(
"BankType2"),
377 $this->status = array(
378 self::STATUS_OPEN => $langs->trans(
"StatusAccountOpened"),
379 self::STATUS_CLOSED => $langs->trans(
"StatusAccountClosed")
392 if ($val ==
'BankCode') {
393 $string .= $this->code_banque.
' ';
394 } elseif ($val ==
'BankAccountNumber') {
395 $string .= $this->number.
' ';
396 } elseif ($val ==
'DeskCode') {
397 $string .= $this->code_guichet.
' ';
398 } elseif ($val ==
'BankAccountNumberKey') {
399 $string .= $this->cle_rib.
' ';
400 } elseif ($val ==
'BIC') {
401 $string .= $this->bic.
' ';
402 } elseif ($val ==
'IBAN') {
403 $string .= $this->iban.
' ';
407 return trim($string);
420 if (empty($this->rappro)) {
423 if ($this->courant ==
Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) {
447 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
453 $sql .=
") VALUES (";
454 $sql .=
" ".((int) $line_id);
455 $sql .=
", ".((int) $url_id);
456 $sql .=
", '".$this->db->escape($url).
"'";
457 $sql .=
", '".$this->db->escape($label).
"'";
458 $sql .=
", '".$this->db->escape($type).
"'";
461 dol_syslog(get_class($this).
"::add_url_line", LOG_DEBUG);
462 if ($this->
db->query($sql)) {
463 $rowid = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_url");
466 $this->
error = $this->
db->lasterror();
481 public function get_url($fk_bank =
'', $url_id =
'', $type =
'')
487 if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) {
488 $this->
error =
"ErrorBadParameter";
492 $sql =
"SELECT fk_bank, url_id, url, label, type";
493 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_url";
495 $sql .=
" WHERE fk_bank = ".((int) $fk_bank);
497 $sql .=
" WHERE url_id = ".((int) $url_id).
" AND type = '".$this->
db->escape($type).
"'";
499 $sql .=
" ORDER BY type, label";
501 dol_syslog(get_class($this).
"::get_url", LOG_DEBUG);
502 $result = $this->
db->query($sql);
505 $num = $this->
db->num_rows($result);
507 $obj = $this->
db->fetch_object($result);
509 $lines[$i][0] = $obj->url;
510 $lines[$i][1] = $obj->url_id;
511 $lines[$i][2] = $obj->label;
512 $lines[$i][3] = $obj->type;
514 $lines[$i][
'url'] = $obj->url;
515 $lines[$i][
'url_id'] = $obj->url_id;
516 $lines[$i][
'label'] = $obj->label;
517 $lines[$i][
'type'] = $obj->type;
518 $lines[$i][
'fk_bank'] = $obj->fk_bank;
546 public function addline($date, $oper, $label, $amount, $num_chq, $categorie,
User $user, $emetteur =
'', $banque =
'', $accountancycode =
'', $datev =
null, $num_releve =
'', $amount_main_currency =
null)
551 if (is_numeric($oper)) {
552 dol_syslog(__METHOD__.
": using numeric operations is deprecated", LOG_WARNING);
555 if (empty($this->
id) && !empty($this->
rowid)) {
556 $this->
id = $this->rowid;
560 $emetteur = trim($emetteur);
561 $banque = trim($banque);
562 $label = trim($label);
566 if (is_numeric($oper)) {
567 $sql =
"SELECT code FROM ".MAIN_DB_PREFIX.
"c_paiement";
568 $sql .=
" WHERE id = ".((int) $oper);
569 $sql .=
" AND entity IN (".getEntity(
'c_paiement').
")";
572 $obj = $this->
db->fetch_object(
$resql);
582 $this->
error = $langs->trans(
"OperNotDefined");
586 $this->
error = $langs->trans(
"ThisIdNotDefined");
590 $this->
error =
"ErrorCashAccountAcceptsOnlyCashMoney";
596 if (is_null($datev) || empty($datev)) {
601 $accline->datec = $now;
602 $accline->dateo = $date;
603 $accline->datev = $datev;
604 $accline->label = $label;
605 $accline->amount = $amount;
606 $accline->amount_main_currency = $amount_main_currency;
607 $accline->fk_user_author = $user->id;
608 $accline->fk_account = $this->id;
609 $accline->fk_type = $oper;
610 $accline->numero_compte = $accountancycode;
611 $accline->num_releve = $num_releve;
614 $accline->num_chq = $num_chq;
618 $accline->emetteur = $emetteur;
622 $accline->bank_chq = $banque;
625 if ($accline->insert() > 0) {
626 if ($categorie > 0) {
627 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class(";
628 $sql .=
"lineid, fk_categ";
629 $sql .=
") VALUES (";
630 $sql .= ((int) $accline->id).
", '".$this->
db->escape($categorie).
"'";
633 $result = $this->
db->query($sql);
635 $this->
error = $this->
db->lasterror();
636 $this->
db->rollback();
646 $this->
error = $accline->error;
647 $this->errors = $accline->errors;
648 $this->
db->rollback();
663 global $langs, $conf;
668 if (!$this->min_allowed) {
669 $this->min_allowed = 0;
671 if (!$this->min_desired) {
672 $this->min_desired = 0;
676 if (empty($this->country_id)) {
677 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
681 if (empty($this->
ref)) {
682 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
686 if (empty($this->date_solde)) {
687 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateInitialBalance"));
692 $balance = $this->balance;
693 if (empty($balance) && !empty($this->
solde)) {
694 $balance = $this->solde;
696 if (empty($balance)) {
701 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
707 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_account (";
712 $sql .=
", account_number";
713 $sql .=
", fk_accountancy_journal";
715 $sql .=
", code_banque";
716 $sql .=
", code_guichet";
720 $sql .=
", iban_prefix";
721 $sql .=
", domiciliation";
722 $sql .=
", pti_in_ctti";
724 $sql .=
", owner_address";
725 $sql .=
", currency_code";
727 $sql .=
", min_allowed";
728 $sql .=
", min_desired";
730 $sql .=
", state_id";
733 $sql .=
", ics_transfer";
734 $sql .=
") VALUES (";
735 $sql .=
"'".$this->db->idate($now).
"'";
736 $sql .=
", '".$this->db->escape($this->
ref).
"'";
737 $sql .=
", '".$this->db->escape($this->label).
"'";
738 $sql .=
", ".((int) $conf->entity);
739 $sql .=
", '".$this->db->escape($this->account_number).
"'";
740 $sql .=
", ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
741 $sql .=
", '".$this->db->escape($this->bank).
"'";
742 $sql .=
", '".$this->db->escape($this->code_banque).
"'";
743 $sql .=
", '".$this->db->escape($this->code_guichet).
"'";
744 $sql .=
", '".$this->db->escape($this->number).
"'";
745 $sql .=
", '".$this->db->escape($this->cle_rib).
"'";
746 $sql .=
", '".$this->db->escape($this->bic).
"'";
747 $sql .=
", '".$this->db->escape($this->iban).
"'";
748 $sql .=
", '".$this->db->escape($this->domiciliation).
"'";
749 $sql .=
", ".((int) $this->pti_in_ctti);
750 $sql .=
", '".$this->db->escape($this->proprio).
"'";
751 $sql .=
", '".$this->db->escape($this->owner_address).
"'";
752 $sql .=
", '".$this->db->escape($this->currency_code).
"'";
753 $sql .=
", ".((int) $this->rappro);
754 $sql .=
", ".price2num($this->min_allowed,
'MT');
755 $sql .=
", ".price2num($this->min_desired,
'MT');
756 $sql .=
", '".$this->db->escape($this->comment).
"'";
757 $sql .=
", ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
758 $sql .=
", ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
759 $sql .=
", '".$this->db->escape($this->ics).
"'";
760 $sql .=
", '".$this->db->escape($this->ics_transfer).
"'";
763 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
766 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_account");
768 $result = $this->
update($user, 1);
771 $accline->datec = $this->
db->idate($now);
772 $accline->label =
'('.$langs->trans(
"InitialBankBalance").
')';
774 $accline->fk_user_author = $user->id;
775 $accline->fk_account = $this->id;
776 $accline->datev = $this->
db->idate($this->date_solde);
777 $accline->dateo = $this->
db->idate($this->date_solde);
778 $accline->fk_type =
'SOLD';
780 if ($accline->insert() < 0) {
782 $this->
error = $accline->error;
783 $this->errors = $accline->errors;
793 if (!$error && !$notrigger) {
795 $result = $this->
call_trigger(
'BANKACCOUNT_CREATE', $user);
805 if ($this->
db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
806 $this->
error = $langs->trans(
"ErrorBankLabelAlreadyExists");
809 $this->
error = $this->
db->error().
" sql=".$sql;
818 $this->
db->rollback();
832 global $langs, $conf;
839 if (empty($this->country_id)) {
840 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
844 if (empty($this->
ref)) {
845 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
850 $this->label =
"???";
853 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
855 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
856 $sql .=
",label = '".$this->db->escape($this->label).
"'";
858 $sql .=
",courant = ".((int) $this->courant);
859 $sql .=
",clos = ".((int) $this->clos);
860 $sql .=
",rappro = ".((int) $this->rappro);
861 $sql .=
",url = ".($this->url ?
"'".$this->db->escape($this->url).
"'" :
"null");
862 $sql .=
",account_number = '".$this->db->escape($this->account_number).
"'";
863 $sql .=
",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
864 $sql .=
",bank = '".$this->db->escape($this->bank).
"'";
865 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
866 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
867 $sql .=
",number='".$this->db->escape($this->number).
"'";
868 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
869 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
870 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
871 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
872 $sql .=
",pti_in_ctti=".((int) $this->pti_in_ctti);
873 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
874 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
876 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
878 $sql .=
",min_allowed = ".($this->min_allowed !=
'' ?
price2num($this->min_allowed) :
"null");
879 $sql .=
",min_desired = ".($this->min_desired !=
'' ?
price2num($this->min_desired) :
"null");
880 $sql .=
",comment = '".$this->db->escape($this->comment).
"'";
882 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
883 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
884 $sql .=
",ics = '".$this->db->escape($this->ics).
"'";
885 $sql .=
",ics_transfer = '".$this->db->escape($this->ics_transfer).
"'";
887 $sql .=
" WHERE rowid = ".((int) $this->
id);
889 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
890 $result = $this->
db->query($sql);
900 if (!$error && !$notrigger) {
902 $result = $this->
call_trigger(
'BANKACCOUNT_MODIFY', $user);
910 $this->
error = $this->
db->lasterror();
918 $this->
db->rollback();
934 global $conf, $langs;
937 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
939 dol_syslog(get_class($this).
"::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
943 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->trans(
"Ref"));
947 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
948 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
949 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
950 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
951 $sql .=
",number='".$this->db->escape($this->number).
"'";
952 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
953 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
954 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
955 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
956 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
957 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
958 $sql .=
",state_id = ".($this->state_id > 0 ? $this->state_id :
"null");
959 $sql .=
",fk_pays = ".($this->country_id > 0 ? $this->country_id :
"null");
960 $sql .=
" WHERE rowid = ".((int) $this->
id);
961 $sql .=
" AND entity = ".((int) $conf->entity);
963 dol_syslog(get_class($this).
"::update_bban", LOG_DEBUG);
965 $result = $this->
db->query($sql);
969 $this->
error = $this->
db->lasterror();
983 public function fetch($id, $ref =
'')
985 if (empty($id) && empty($ref)) {
986 $this->
error =
"ErrorBadParameters";
990 $sql =
"SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
991 $sql .=
" ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
992 $sql .=
" ba.domiciliation, ba.pti_in_ctti, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
993 $sql .=
" ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
994 $sql .=
" ba.min_allowed, ba.min_desired, ba.comment,";
995 $sql .=
" ba.datec as date_creation, ba.tms as date_update, ba.ics, ba.ics_transfer,";
996 $sql .=
' c.code as country_code, c.label as country,';
997 $sql .=
' d.code_departement as state_code, d.nom as state';
998 $sql .=
' , aj.code as accountancy_journal';
999 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1000 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON ba.fk_pays = c.rowid';
1001 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON ba.state_id = d.rowid';
1002 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal';
1003 $sql .=
" WHERE ba.entity IN (".getEntity($this->element).
")";
1005 $sql .=
" AND ba.rowid = ".((int) $id);
1008 $sql .=
" AND ba.ref = '".$this->db->escape($ref).
"'";
1011 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1012 $result = $this->
db->query($sql);
1014 if ($this->
db->num_rows($result)) {
1015 $obj = $this->
db->fetch_object($result);
1017 $this->
id = $obj->rowid;
1018 $this->
rowid = $obj->rowid;
1019 $this->
ref = $obj->ref;
1020 $this->label = $obj->label;
1021 $this->
type = $obj->courant;
1022 $this->courant = $obj->courant;
1023 $this->bank = $obj->bank;
1024 $this->clos = $obj->clos;
1025 $this->rappro = $obj->rappro;
1026 $this->url = $obj->url;
1028 $this->code_banque = $obj->code_banque;
1029 $this->code_guichet = $obj->code_guichet;
1030 $this->number = $obj->number;
1031 $this->cle_rib = $obj->cle_rib;
1032 $this->bic = $obj->bic;
1033 $this->iban = $obj->iban;
1034 $this->domiciliation = $obj->domiciliation;
1035 $this->pti_in_ctti = $obj->pti_in_ctti;
1036 $this->proprio = $obj->proprio;
1037 $this->owner_address = $obj->owner_address;
1039 $this->state_id = $obj->state_id;
1040 $this->state_code = $obj->state_code;
1041 $this->state = $obj->state;
1043 $this->country_id = $obj->country_id;
1044 $this->country_code = $obj->country_code;
1045 $this->country = $obj->country;
1047 $this->account_number = $obj->account_number;
1048 $this->fk_accountancy_journal = $obj->fk_accountancy_journal;
1049 $this->accountancy_journal = $obj->accountancy_journal;
1051 $this->currency_code = $obj->currency_code;
1052 $this->account_currency_code = $obj->currency_code;
1053 $this->min_allowed = $obj->min_allowed;
1054 $this->min_desired = $obj->min_desired;
1055 $this->comment = $obj->comment;
1057 $this->date_creation = $this->
db->jdate($obj->date_creation);
1058 $this->date_update = $this->
db->jdate($obj->date_update);
1060 $this->ics = $obj->ics;
1061 $this->ics_transfer = $obj->ics_transfer;
1072 $this->
error = $this->
db->lasterror;
1073 $this->errors[] = $this->error;
1090 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1091 return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT);
1100 public function delete(
User $user =
null)
1110 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
1111 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1116 $this->
error =
"Error ".$this->db->lasterror();
1121 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
1122 $sql .=
" WHERE rowid = ".((int) $this->
id);
1124 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1125 $result = $this->
db->query($sql);
1132 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1137 $this->
error =
"Error ".$this->db->lasterror();
1142 $this->
db->commit();
1145 $this->
db->rollback();
1159 return $this->
LibStatut($this->clos, $mode);
1174 $langs->load(
'banks');
1176 if ($status == self::STATUS_OPEN) {
1177 $label = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1178 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1179 $statusType =
'status4';
1181 $label = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1182 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1183 $statusType =
'status5';
1186 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1199 $can_be_deleted =
false;
1201 $sql =
"SELECT COUNT(rowid) as nb";
1202 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1203 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1207 $obj = $this->
db->fetch_object(
$resql);
1208 if ($obj->nb <= 1) {
1209 $can_be_deleted =
true;
1214 return $can_be_deleted;
1225 return $this->error;
1236 public function solde($option = 0, $date_end =
'', $field =
'dateo')
1240 $sql =
"SELECT sum(amount) as amount";
1241 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1242 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1244 $sql .=
" AND ".$this->db->escape($field).
" <= '".(!empty($date_end) ? $this->
db->idate($date_end) : $this->
db->idate(
dol_now())).
"'";
1250 $obj = $this->
db->fetch_object(
$resql);
1251 $solde = $obj->amount;
1255 $this->errors[] = $this->
db->lasterror;
1273 global $conf, $langs;
1279 $sql =
"SELECT b.rowid, b.datev as datefin";
1280 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1281 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1282 $sql .=
" WHERE b.rappro=0";
1283 $sql .=
" AND b.fk_account = ba.rowid";
1284 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1285 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1286 $sql .=
" AND clos = 0";
1287 if ($filteraccountid) {
1288 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1293 $langs->load(
"banks");
1296 require_once DOL_DOCUMENT_ROOT.
'/core/class/workboardresponse.class.php';
1299 $response->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24;
1300 $response->label = $langs->trans(
"TransactionsToConciliate");
1301 $response->labelShort = $langs->trans(
"TransactionsToConciliateShort");
1302 $response->url = DOL_URL_ROOT.
'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
1305 while ($obj = $this->
db->fetch_object(
$resql)) {
1306 $response->nbtodo++;
1307 if ($this->
db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
1308 $response->nbtodolate++;
1315 $this->
error = $this->
db->error();
1335 $sql =
"SELECT count(b.rowid) as nb";
1336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1337 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1338 $sql .=
" WHERE b.fk_account = ba.rowid";
1339 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1340 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1341 $sql .=
" AND clos = 0";
1342 if ($filteraccountid) {
1343 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1348 while ($obj = $this->
db->fetch_object(
$resql)) {
1349 $this->nb[
"banklines"] = $obj->nb;
1354 $this->
error = $this->
db->error();
1367 global $db, $conf, $user;
1376 $sql =
"SELECT COUNT(ba.rowid) as nb";
1377 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1378 $sql .=
" WHERE ba.rappro > 0 and ba.clos = 0";
1379 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1380 if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) {
1381 $sql .=
" AND ba.courant != 2";
1385 $obj = $this->
db->fetch_object(
$resql);
1404 public function getNomUrl($withpicto = 0, $mode =
'', $option =
'', $save_lastsearch_value = -1, $notooltip = 0)
1406 global $conf, $langs, $user;
1407 include_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1410 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightnow">'.$langs->trans(
"BankAccount").
'</u>';
1411 if (isset($this->status)) {
1412 $label .=
' '.$this->getLibStatut(5);
1414 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1415 $label .=
'<br><b>'.$langs->trans(
'AccountNumber').
':</b> '.$this->number;
1417 $label .=
'<br><b>'.$langs->trans(
'BIC').
':</b> '.$this->bic;
1418 $label .=
'<br><b>'.$langs->trans(
"AccountCurrency").
':</b> '.$this->currency_code;
1420 if (empty($user->rights->banque->lire) || !empty($user->socid)) {
1425 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1426 $langs->load(
"accountancy");
1427 $label .=
'<br><b>'.$langs->trans(
'AccountAccounting').
':</b> '.
length_accountg($this->account_number);
1428 $label .=
'<br><b>'.$langs->trans(
'AccountancyJournal').
':</b> '.$this->accountancy_journal;
1431 $linkclose =
'" title="'.dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
1433 $url = DOL_URL_ROOT.
'/compta/bank/card.php?id='.$this->id;
1434 if ($mode ==
'transactions') {
1435 $url = DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?id='.$this->id;
1436 } elseif ($mode ==
'receipts') {
1437 $url = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$this->id;
1440 if ($option !=
'nolink') {
1442 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1443 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1444 $add_save_lastsearch_values = 1;
1446 if ($add_save_lastsearch_values) {
1447 $url .=
'&save_lastsearch_values=1';
1451 $linkstart =
'<a href="'.$url.$linkclose;
1454 if ($option ==
'nolink') {
1459 $result .= $linkstart;
1461 $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1463 if ($withpicto != 2) {
1464 $result .= $this->
ref.($option ==
'reflabel' && $this->label ?
' - '.$this->label :
'');
1466 $result .= $linkend;
1482 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
1484 $this->error_number = 0;
1489 $this->error_number = 12;
1490 $this->error_message =
'IBANNotValid';
1493 $this->error_number = 12;
1494 $this->error_message =
'SwiftNotValid';
1502 if ($this->error_number == 0) {
1519 if (!empty($this->country_code)) {
1520 return $this->country_code;
1524 if (!empty($this->iban)) {
1527 if (preg_match(
"/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) {
1533 if (!empty($this->socid)) {
1534 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1536 $result = $company->fetch($this->socid);
1537 if (!empty($company->country_code)) {
1538 return $company->country_code;
1543 if (!empty($mysoc->country_code)) {
1544 return $mysoc->country_code;
1562 if (in_array($country_code, array(
'FR',
'ES',
'GA',
'IT',
'NC'))) {
1565 if (in_array($country_code, array(
'AD',
'AU',
'BE',
'CA',
'DE',
'DK',
'GR',
'GB',
'ID',
'IE',
'IR',
'KR',
'NL',
'NZ',
'UK',
'US'))) {
1580 if (!empty($conf->global->MAIN_IBAN_IS_NEVER_MANDATORY)) {
1586 $country_code_in_EEC = array(
1622 if (in_array($country_code, $country_code_in_EEC)) {
1657 if ($detailedBBAN == 0) {
1658 $fieldarray = array(
1661 } elseif ($detailedBBAN == 2) {
1662 $fieldarray = array(
1671 if ($includeibanbic) {
1672 $fieldarray[] =
'IBAN';
1673 $fieldarray[] =
'BIC';
1695 $fieldlists = array(
1698 'BankAccountNumber',
1699 'BankAccountNumberKey'
1702 if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) {
1703 if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) {
1704 if ($conf->global->BANK_SHOW_ORDER_OPTION ==
'1') {
1705 $fieldlists = array(
1708 'BankAccountNumberKey',
1714 $fieldlists = explode(
1716 preg_replace(
'/ ?[^Bank]AccountNumber ?/',
'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION)
1735 $this->specimen = 1;
1737 $this->label =
'My Big Company Bank account';
1738 $this->bank =
'MyBank';
1740 $this->clos = Account::STATUS_OPEN;
1741 $this->code_banque =
'30001';
1742 $this->code_guichet =
'00794';
1743 $this->number =
'12345678901';
1744 $this->cle_rib =
'85';
1745 $this->bic =
'AA12';
1746 $this->iban =
'FR7630001007941234567890185';
1747 $this->domiciliation =
'Banque de France';
1748 $this->proprio =
'Owner';
1749 $this->owner_address =
'Owner address';
1750 $this->country_id = 1;
1763 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_url SET url_id = ".((int) $dest_id).
" WHERE url_id = ".((int) $origin_id).
" AND type='company'";
1765 if ($dbs->query($sql)) {
1794 public $element =
'bank';
1799 public $table_element =
'bank';
1804 public $picto =
'accountline';
1838 public $amount_main_currency;
1843 public $fk_user_author;
1848 public $fk_user_rappro;
1858 public $fk_bordereau;
1868 public $bank_account_ref;
1873 public $bank_account_label;
1878 public $numero_compte;
1917 public function fetch($rowid, $ref =
'', $num =
'')
1922 if (empty($rowid) && empty($ref) && empty($num)) {
1926 $sql =
"SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,";
1927 $sql .=
" b.fk_user_author, b.fk_user_rappro,";
1928 $sql .=
" b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,";
1929 $sql .=
" b.fk_bordereau, b.banque, b.emetteur,";
1930 $sql .=
" ba.ref as bank_account_ref, ba.label as bank_account_label";
1931 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1932 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1933 $sql .=
" WHERE b.fk_account = ba.rowid";
1934 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1936 $sql .=
" AND b.num_chq='".$this->db->escape($num).
"'";
1938 $sql .=
" AND b.rowid='".$this->db->escape($ref).
"'";
1940 $sql .=
" AND b.rowid = ".((int) $rowid);
1943 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1944 $result = $this->
db->query($sql);
1948 $obj = $this->
db->fetch_object($result);
1950 $this->
id = $obj->rowid;
1951 $this->
rowid = $obj->rowid;
1952 $this->
ref = $obj->rowid;
1954 $this->datec = $obj->datec;
1955 $this->datev = $obj->datev;
1956 $this->dateo = $obj->dateo;
1957 $this->amount = $obj->amount;
1958 $this->label = $obj->label;
1959 $this->note = $obj->note;
1961 $this->fk_user_author = $obj->fk_user_author;
1962 $this->fk_user_rappro = $obj->fk_user_rappro;
1964 $this->fk_type = $obj->fk_type;
1965 $this->rappro = $obj->rappro;
1966 $this->num_releve = $obj->num_releve;
1968 $this->num_chq = $obj->num_chq;
1969 $this->bank_chq = $obj->banque;
1970 $this->fk_bordereau = $obj->fk_bordereau;
1972 $this->fk_account = $obj->fk_account;
1973 $this->bank_account_ref = $obj->bank_account_ref;
1974 $this->bank_account_label = $obj->bank_account_label;
1982 $this->
db->free($result);
2000 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank (";
2006 $sql .=
", amount_main_currency";
2007 $sql .=
", fk_user_author";
2008 $sql .=
", num_chq";
2009 $sql .=
", fk_account";
2010 $sql .=
", fk_type";
2011 $sql .=
", emetteur,banque";
2013 $sql .=
", numero_compte";
2014 $sql .=
", num_releve";
2015 $sql .=
") VALUES (";
2016 $sql .=
"'".$this->db->idate($this->datec).
"'";
2017 $sql .=
", '".$this->db->idate($this->dateo).
"'";
2018 $sql .=
", '".$this->db->idate($this->datev).
"'";
2019 $sql .=
", '".$this->db->escape($this->label).
"'";
2020 $sql .=
", ".price2num($this->amount);
2021 $sql .=
", ".(empty($this->amount_main_currency) ?
"NULL" :
price2num($this->amount_main_currency));
2022 $sql .=
", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) :
"null");
2023 $sql .=
", ".($this->num_chq ?
"'".$this->db->escape($this->num_chq).
"'" :
"null");
2024 $sql .=
", '".$this->db->escape($this->fk_account).
"'";
2025 $sql .=
", '".$this->db->escape($this->fk_type).
"'";
2026 $sql .=
", ".($this->emetteur ?
"'".$this->db->escape($this->emetteur).
"'" :
"null");
2027 $sql .=
", ".($this->bank_chq ?
"'".$this->db->escape($this->bank_chq).
"'" :
"null");
2028 $sql .=
", ".(int) $this->rappro;
2029 $sql .=
", ".($this->numero_compte ?
"'".$this->db->escape($this->numero_compte).
"'" :
"''");
2030 $sql .=
", ".($this->num_releve ?
"'".$this->db->escape($this->num_releve).
"'" :
"null");
2033 dol_syslog(get_class($this).
"::insert", LOG_DEBUG);
2036 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'bank');
2044 $this->error = $this->
db->lasterror();
2049 $this->
db->commit();
2052 $this->
db->rollback();
2063 public function delete(
User $user =
null)
2069 if ($this->rappro) {
2071 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
2078 if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) {
2079 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->
id);
2082 $obj = $this->
db->fetch_object(
$resql);
2083 if ($obj && $obj->nb) {
2084 $this->error =
'ErrorRecordAlreadyInAccountingDeletionNotPossible';
2085 $this->
db->rollback();
2089 $this->error = $this->
db->lasterror();
2090 $this->
db->rollback();
2101 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class WHERE lineid=".(int) $this->
rowid;
2102 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
2103 $result = $this->
db->query($sql);
2108 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_extrafields WHERE fk_object=".(int) $this->
rowid;
2109 $result = $this->
db->query($sql);
2114 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid=".(int) $this->
rowid;
2115 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
2116 $result = $this->
db->query($sql);
2122 $this->
db->commit();
2125 $this->
db->rollback();
2143 if ($this->rappro) {
2145 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
2151 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_url WHERE fk_bank=".(int) $this->
rowid;
2152 dol_syslog(get_class($this).
"::delete_urls", LOG_DEBUG);
2153 $result = $this->
db->query($sql);
2159 $this->
db->commit();
2162 $this->
db->rollback();
2179 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2180 $sql .=
" amount = ".price2num($this->amount).
",";
2181 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
2182 $sql .=
" dateo='".$this->db->idate($this->dateo).
"'";
2183 $sql .=
" WHERE rowid = ".((int) $this->
rowid);
2185 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
2188 $this->
db->commit();
2191 $this->
db->rollback();
2192 $this->error = $this->
db->error();
2210 global $conf, $langs;
2215 if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE)) {
2216 if (!preg_match(
'/'.$conf->global->BANK_STATEMENT_REGEX_RULE.
'/', $this->num_releve)) {
2217 $this->errors[] = $langs->trans(
"ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE);
2222 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2223 $sql .=
" rappro = ".((int) $conciliated);
2224 $sql .=
", num_releve = '".$this->db->escape($this->num_releve).
"'";
2226 $sql .=
", fk_user_rappro = ".$user->id;
2228 $sql .=
" WHERE rowid = ".((int) $this->
id);
2230 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2234 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class (";
2236 $sql .=
", fk_categ";
2237 $sql .=
") VALUES (";
2239 $sql .=
", ".((int) $cat);
2242 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2243 $this->
db->query($sql);
2250 $this->
db->commit();
2253 $this->
db->rollback();
2270 $sql =
"SELECT datev FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".((int) $rowid);
2273 $obj = $this->
db->fetch_object(
$resql);
2274 $newdate = $this->
db->jdate($obj->datev) + (3600 * 24 * $sign);
2276 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2277 $sql .=
" datev = '".$this->db->idate($newdate).
"'";
2278 $sql .=
" WHERE rowid = ".((int) $rowid);
2280 $result = $this->
db->query($sql);
2282 if ($this->
db->affected_rows($result)) {
2333 $sql =
"SELECT dateo FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".((int) $rowid);
2336 $obj = $this->
db->fetch_object(
$resql);
2337 $newdate = $this->
db->jdate($obj->dateo) + (3600 * 24 * $sign);
2339 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2340 $sql .=
" dateo = '".$this->db->idate($newdate).
"'";
2341 $sql .=
" WHERE rowid = ".((int) $rowid);
2343 $result = $this->
db->query($sql);
2345 if ($this->
db->affected_rows($result)) {
2393 $sql =
'SELECT b.rowid, b.datec, b.tms as datem,';
2394 $sql .=
' b.fk_user_author, b.fk_user_rappro';
2395 $sql .=
' FROM '.MAIN_DB_PREFIX.
'bank as b';
2396 $sql .=
' WHERE b.rowid = '.((int) $id);
2398 $result = $this->
db->query($sql);
2400 if ($this->
db->num_rows($result)) {
2401 $obj = $this->
db->fetch_object($result);
2402 $this->
id = $obj->rowid;
2404 if ($obj->fk_user_author) {
2405 $cuser =
new User($this->
db);
2406 $cuser->fetch($obj->fk_user_author);
2407 $this->user_creation = $cuser;
2409 if ($obj->fk_user_rappro) {
2410 $ruser =
new User($this->
db);
2411 $ruser->fetch($obj->fk_user_rappro);
2412 $this->user_rappro = $ruser;
2415 $this->date_creation = $this->
db->jdate($obj->datec);
2416 $this->date_modification = $this->
db->jdate($obj->datem);
2419 $this->
db->free($result);
2435 public function getNomUrl($withpicto = 0, $maxlen = 0, $option =
'', $notooltip = 0)
2441 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"BankTransactionLine").
'</u>:<br>';
2442 $label .=
'<b>'.$langs->trans(
"Ref").
':</b> '.$this->ref;
2444 $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">';
2447 $result .= $linkstart;
2449 $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);
2451 if ($withpicto != 2) {
2452 $result .= ($this->
ref ? $this->
ref : $this->id);
2454 $result .= $linkend;
2456 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2457 $result .=
' <span class="opacitymedium">(';
2459 if ($option ==
'showall') {
2460 $result .= $langs->trans(
"BankAccount").
': ';
2461 $accountstatic =
new Account($this->
db);
2462 $accountstatic->id = $this->fk_account;
2463 $accountstatic->ref = $this->bank_account_ref;
2464 $accountstatic->label = $this->bank_account_label;
2465 $result .= $accountstatic->getNomUrl(0).
', ';
2467 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2468 $result .= $langs->trans(
"BankLineConciliated").
': ';
2469 $result .=
yn($this->rappro);
2471 if ($option ==
'showall' || $option ==
'showconciliatedandaccounted') {
2472 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->
id);
2475 $obj = $this->
db->fetch_object(
$resql);
2476 if ($obj && $obj->nb) {
2477 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(1);
2479 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(0);
2483 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2484 $result .=
')</span>';
2499 return $this->
LibStatut($this->status, $mode);
2556 $alreadydispatched = 0;
2560 $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 = ".((int) $this->
id);
2563 $obj = $this->
db->fetch_object(
$resql);
2565 $alreadydispatched = $obj->nb;
2568 $this->error = $this->
db->lasterror();
2572 if ($alreadydispatched) {
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
getIbanHumanReadable(Account $account)
Returns the iban human readable.
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
Class to manage bank accounts.
solde($option=0, $date_end='', $field='dateo')
Return current sold.
fetch($id, $ref='')
Load a bank account into memory from database.
__construct(DoliDB $db)
Constructor.
add_url_line($line_id, $url_id, $url, $label, $type)
Add a link between bank line record and its source.
static replaceThirdparty($dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
update(User $user, $notrigger=0)
Update bank account card.
getCountryCode()
Return account country code.
needIBAN()
Return 1 if IBAN / BIC is mandatory (otherwise option)
getLibStatut($mode=0)
Return label of object status.
info($id)
Load miscellaneous information for tab "Info".
const TYPE_CASH
Cash account.
__toString()
Shows the account number in the appropriate format.
const TYPE_SAVINGS
Savings account.
useDetailedBBAN()
Return if a bank account is defined with detailed information (bank code, desk code,...
static getAccountNumberOrder()
Returns the components of the bank account in order.
load_state_board($filteraccountid=0)
Charge indicateurs this->nb de tableau de bord.
canBeConciliated()
Return if a bank account need to be conciliated.
create(User $user, $notrigger=0)
Create bank account into database.
can_be_deleted()
Renvoi si un compte peut etre supprimer ou non (sans mouvements)
update_bban(User $user=null)
Update BBAN (RIB) account fields.
const TYPE_CURRENT
Current account.
setCategories($categories)
Sets object to supplied categories.
getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0)
Return clicable name (with picto eventually)
countAccountToReconcile()
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
verif()
Return if an account has valid information for Direct debit payment.
initAsSpecimen()
Initialise an instance with random values.
get_url($fk_bank='', $url_id='', $type='')
TODO Move this into AccountLine Return array with links from llx_bank_url.
getFieldsToShow($includeibanbic=0)
Returns the fields in order that this bank account should show to the user Will return an array with ...
load_board(User $user, $filteraccountid=0)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='', $banque='', $accountancycode='', $datev=null, $num_releve='', $amount_main_currency=null)
Add an entry into table ".MAIN_DB_PREFIX."bank.
LibStatut($status, $mode=0)
Return label of given object status.
Class to manage bank transaction lines.
info($id)
Load miscellaneous information for tab "Info".
__construct(DoliDB $db)
Constructor.
update_conciliation(User $user, $cat, $conciliated=1)
Update conciliation field.
getLibStatut($mode=0)
Return label of status (activity, closed)
fetch($rowid, $ref='', $num='')
Load into memory content of a bank transaction line.
dateo_change($rowid, $sign=1)
Increase/decrease operation date of a rowid.
datev_next($id)
Increase value date of a rowid.
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
update(User $user, $notrigger=0)
Update bank account record in database.
insert()
Inserts a transaction to a bank account.
getNomUrl($withpicto=0, $maxlen=0, $option='', $notooltip=0)
Return clickable name (with picto eventually)
delete_urls(User $user=null)
Delete bank line records.
getVentilExportCompta()
Return if a bank line was dispatched into bookkeeping.
datev_change($rowid, $sign=1)
Increase/decrease value date of a rowid.
dateo_previous($id)
Decrease operation date of a rowid.
dateo_next($id)
Increase operation date of a rowid.
datev_previous($id)
Decrease value date of a rowid.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db
API class for accounts.