32 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
43 public $element =
'bank_account';
48 public $table_element =
'bank_account';
53 public $picto =
'account';
90 public $clos = self::STATUS_OPEN;
114 public $code_guichet;
152 public $domiciliation;
158 public $pti_in_ctti = 0;
170 public $owner_address;
181 public $type_lib = array();
188 public $status = array();
194 public $account_number;
199 public $fk_accountancy_journal;
203 public $accountancy_journal;
209 public $currency_code;
216 public $account_currency_code;
266 public $ics_transfer;
298 public $fields = array(
299 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
300 'ref' =>array(
'type'=>
'varchar(12)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'showoncombobox'=>1,
'position'=>25),
301 'label' =>array(
'type'=>
'varchar(30)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
302 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>35,
'index'=>1),
303 'bank' =>array(
'type'=>
'varchar(60)',
'label'=>
'Bank',
'enabled'=>1,
'visible'=>-1,
'position'=>40),
304 'code_banque' =>array(
'type'=>
'varchar(128)',
'label'=>
'Code banque',
'enabled'=>1,
'visible'=>-1,
'position'=>45),
305 'code_guichet' =>array(
'type'=>
'varchar(6)',
'label'=>
'Code guichet',
'enabled'=>1,
'visible'=>-1,
'position'=>50),
306 'number' =>array(
'type'=>
'varchar(255)',
'label'=>
'Number',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
307 'cle_rib' =>array(
'type'=>
'varchar(5)',
'label'=>
'Cle rib',
'enabled'=>1,
'visible'=>-1,
'position'=>60),
308 'bic' =>array(
'type'=>
'varchar(11)',
'label'=>
'Bic',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
309 'iban_prefix' =>array(
'type'=>
'varchar(34)',
'label'=>
'Iban prefix',
'enabled'=>1,
'visible'=>-1,
'position'=>70),
310 'country_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Country iban',
'enabled'=>1,
'visible'=>-1,
'position'=>75),
311 'cle_iban' =>array(
'type'=>
'varchar(2)',
'label'=>
'Cle iban',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
312 'domiciliation' =>array(
'type'=>
'varchar(255)',
'label'=>
'Domiciliation',
'enabled'=>1,
'visible'=>-1,
'position'=>85),
313 'state_id' =>array(
'type'=>
'integer',
'label'=>
'State id',
'enabled'=>1,
'visible'=>-1,
'position'=>90),
314 'fk_pays' =>array(
'type'=>
'integer',
'label'=>
'Fk pays',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>95),
315 'proprio' =>array(
'type'=>
'varchar(60)',
'label'=>
'Proprio',
'enabled'=>1,
'visible'=>-1,
'position'=>100),
316 'owner_address' =>array(
'type'=>
'text',
'label'=>
'Owner address',
'enabled'=>1,
'visible'=>-1,
'position'=>105),
317 'courant' =>array(
'type'=>
'smallint(6)',
'label'=>
'Courant',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>110),
318 'clos' =>array(
'type'=>
'smallint(6)',
'label'=>
'Clos',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>115),
319 'rappro' =>array(
'type'=>
'smallint(6)',
'label'=>
'Rappro',
'enabled'=>1,
'visible'=>-1,
'position'=>120),
320 'url' =>array(
'type'=>
'varchar(128)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>125),
321 'account_number' =>array(
'type'=>
'varchar(32)',
'label'=>
'Account number',
'enabled'=>1,
'visible'=>-1,
'position'=>130),
322 'fk_accountancy_journal' =>array(
'type'=>
'integer',
'label'=>
'Accountancy journal ID',
'enabled'=>1,
'visible'=>-1,
'position'=>132),
323 'accountancy_journal' =>array(
'type'=>
'varchar(20)',
'label'=>
'Accountancy journal',
'enabled'=>1,
'visible'=>-1,
'position'=>135),
324 'currency_code' =>array(
'type'=>
'varchar(3)',
'label'=>
'Currency code',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>140),
325 'min_allowed' =>array(
'type'=>
'integer',
'label'=>
'Min allowed',
'enabled'=>1,
'visible'=>-1,
'position'=>145),
326 'min_desired' =>array(
'type'=>
'integer',
'label'=>
'Min desired',
'enabled'=>1,
'visible'=>-1,
'position'=>150),
327 'comment' =>array(
'type'=>
'text',
'label'=>
'Comment',
'enabled'=>1,
'visible'=>-1,
'position'=>155),
328 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>156),
329 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>157),
330 'fk_user_author' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user author',
'enabled'=>1,
'visible'=>-1,
'position'=>160),
331 'fk_user_modif' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>165),
332 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>170),
333 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>175),
334 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>180),
335 'extraparams' =>array(
'type'=>
'varchar(255)',
'label'=>
'Extraparams',
'enabled'=>1,
'visible'=>-1,
'position'=>185),
353 const STATUS_OPEN = 0;
354 const STATUS_CLOSED = 1;
370 $this->type_lib = array(
371 self::TYPE_SAVINGS => $langs->trans(
"BankType0"),
372 self::TYPE_CURRENT => $langs->trans(
"BankType1"),
373 self::TYPE_CASH => $langs->trans(
"BankType2"),
376 $this->status = array(
377 self::STATUS_OPEN => $langs->trans(
"StatusAccountOpened"),
378 self::STATUS_CLOSED => $langs->trans(
"StatusAccountClosed")
391 if ($val ==
'BankCode') {
392 $string .= $this->code_banque.
' ';
393 } elseif ($val ==
'BankAccountNumber') {
394 $string .= $this->number.
' ';
395 } elseif ($val ==
'DeskCode') {
396 $string .= $this->code_guichet.
' ';
397 } elseif ($val ==
'BankAccountNumberKey') {
398 $string .= $this->cle_rib.
' ';
399 } elseif ($val ==
'BIC') {
400 $string .= $this->bic.
' ';
401 } elseif ($val ==
'IBAN') {
402 $string .= $this->iban.
' ';
406 return trim($string);
419 if (empty($this->rappro)) {
422 if ($this->courant ==
Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) {
446 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_url (";
452 $sql .=
") VALUES (";
453 $sql .=
" ".((int) $line_id);
454 $sql .=
", ".((int) $url_id);
455 $sql .=
", '".$this->db->escape($url).
"'";
456 $sql .=
", '".$this->db->escape($label).
"'";
457 $sql .=
", '".$this->db->escape($type).
"'";
460 dol_syslog(get_class($this).
"::add_url_line", LOG_DEBUG);
461 if ($this->
db->query($sql)) {
462 $rowid = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_url");
465 $this->
error = $this->
db->lasterror();
480 public function get_url($fk_bank =
'', $url_id =
'', $type =
'')
486 if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) {
487 $this->
error =
"ErrorBadParameter";
491 $sql =
"SELECT fk_bank, url_id, url, label, type";
492 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_url";
494 $sql .=
" WHERE fk_bank = ".((int) $fk_bank);
496 $sql .=
" WHERE url_id = ".((int) $url_id).
" AND type = '".$this->
db->escape($type).
"'";
498 $sql .=
" ORDER BY type, label";
500 dol_syslog(get_class($this).
"::get_url", LOG_DEBUG);
501 $result = $this->
db->query($sql);
504 $num = $this->
db->num_rows($result);
506 $obj = $this->
db->fetch_object($result);
508 $lines[$i][0] = $obj->url;
509 $lines[$i][1] = $obj->url_id;
510 $lines[$i][2] = $obj->label;
511 $lines[$i][3] = $obj->type;
513 $lines[$i][
'url'] = $obj->url;
514 $lines[$i][
'url_id'] = $obj->url_id;
515 $lines[$i][
'label'] = $obj->label;
516 $lines[$i][
'type'] = $obj->type;
517 $lines[$i][
'fk_bank'] = $obj->fk_bank;
545 public function addline($date, $oper, $label, $amount, $num_chq, $categorie,
User $user, $emetteur =
'', $banque =
'', $accountancycode =
'', $datev =
null, $num_releve =
'', $amount_main_currency =
null)
548 if (is_numeric($oper)) {
549 dol_syslog(__METHOD__.
": using numeric operations is deprecated", LOG_WARNING);
552 if (empty($this->
id) && !empty($this->
rowid)) {
553 $this->
id = $this->rowid;
557 $emetteur = trim($emetteur);
558 $banque = trim($banque);
559 $label = trim($label);
563 if (is_numeric($oper)) {
564 $sql =
"SELECT code FROM ".MAIN_DB_PREFIX.
"c_paiement";
565 $sql .=
" WHERE id = ".((int) $oper);
566 $sql .=
" AND entity IN (".getEntity(
'c_paiement').
")";
569 $obj = $this->
db->fetch_object(
$resql);
579 $this->
error =
"oper not defined";
583 $this->
error =
"this->id not defined";
587 $this->
error =
"ErrorCashAccountAcceptsOnlyCashMoney";
593 if (is_null($datev) || empty($datev)) {
598 $accline->datec = $now;
599 $accline->dateo = $date;
600 $accline->datev = $datev;
601 $accline->label = $label;
602 $accline->amount = $amount;
603 $accline->amount_main_currency = $amount_main_currency;
604 $accline->fk_user_author = $user->id;
605 $accline->fk_account = $this->id;
606 $accline->fk_type = $oper;
607 $accline->numero_compte = $accountancycode;
608 $accline->num_releve = $num_releve;
611 $accline->num_chq = $num_chq;
615 $accline->emetteur = $emetteur;
619 $accline->bank_chq = $banque;
622 if ($accline->insert() > 0) {
623 if ($categorie > 0) {
624 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class(";
625 $sql .=
"lineid, fk_categ";
626 $sql .=
") VALUES (";
627 $sql .= ((int) $accline->id).
", '".$this->
db->escape($categorie).
"'";
630 $result = $this->
db->query($sql);
632 $this->
error = $this->
db->lasterror();
633 $this->
db->rollback();
643 $this->
error = $accline->error;
644 $this->errors = $accline->errors;
645 $this->
db->rollback();
660 global $langs, $conf;
665 if (!$this->min_allowed) {
666 $this->min_allowed = 0;
668 if (!$this->min_desired) {
669 $this->min_desired = 0;
673 if (empty($this->country_id)) {
674 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
678 if (empty($this->
ref)) {
679 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
683 if (empty($this->date_solde)) {
684 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateInitialBalance"));
689 $balance = $this->balance;
690 if (empty($balance) && !empty($this->
solde)) {
691 $balance = $this->solde;
693 if (empty($balance)) {
698 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
704 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_account (";
709 $sql .=
", account_number";
710 $sql .=
", fk_accountancy_journal";
712 $sql .=
", code_banque";
713 $sql .=
", code_guichet";
717 $sql .=
", iban_prefix";
718 $sql .=
", domiciliation";
719 $sql .=
", pti_in_ctti";
721 $sql .=
", owner_address";
722 $sql .=
", currency_code";
724 $sql .=
", min_allowed";
725 $sql .=
", min_desired";
727 $sql .=
", state_id";
730 $sql .=
", ics_transfer";
731 $sql .=
") VALUES (";
732 $sql .=
"'".$this->db->idate($now).
"'";
733 $sql .=
", '".$this->db->escape($this->
ref).
"'";
734 $sql .=
", '".$this->db->escape($this->label).
"'";
735 $sql .=
", ".((int) $conf->entity);
736 $sql .=
", '".$this->db->escape($this->account_number).
"'";
737 $sql .=
", ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
738 $sql .=
", '".$this->db->escape($this->bank).
"'";
739 $sql .=
", '".$this->db->escape($this->code_banque).
"'";
740 $sql .=
", '".$this->db->escape($this->code_guichet).
"'";
741 $sql .=
", '".$this->db->escape($this->number).
"'";
742 $sql .=
", '".$this->db->escape($this->cle_rib).
"'";
743 $sql .=
", '".$this->db->escape($this->bic).
"'";
744 $sql .=
", '".$this->db->escape($this->iban).
"'";
745 $sql .=
", '".$this->db->escape($this->domiciliation).
"'";
746 $sql .=
", ".((int) $this->pti_in_ctti);
747 $sql .=
", '".$this->db->escape($this->proprio).
"'";
748 $sql .=
", '".$this->db->escape($this->owner_address).
"'";
749 $sql .=
", '".$this->db->escape($this->currency_code).
"'";
750 $sql .=
", ".((int) $this->rappro);
751 $sql .=
", ".price2num($this->min_allowed,
'MT');
752 $sql .=
", ".price2num($this->min_desired,
'MT');
753 $sql .=
", '".$this->db->escape($this->comment).
"'";
754 $sql .=
", ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
755 $sql .=
", ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
756 $sql .=
", '".$this->db->escape($this->ics).
"'";
757 $sql .=
", '".$this->db->escape($this->ics_transfer).
"'";
760 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
763 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_account");
765 $result = $this->
update($user, 1);
768 $accline->datec = $this->
db->idate($now);
769 $accline->label =
'('.$langs->trans(
"InitialBankBalance").
')';
771 $accline->fk_user_author = $user->id;
772 $accline->fk_account = $this->id;
773 $accline->datev = $this->
db->idate($this->date_solde);
774 $accline->dateo = $this->
db->idate($this->date_solde);
775 $accline->fk_type =
'SOLD';
777 if ($accline->insert() < 0) {
779 $this->
error = $accline->error;
780 $this->errors = $accline->errors;
790 if (!$error && !$notrigger) {
792 $result = $this->
call_trigger(
'BANKACCOUNT_CREATE', $user);
802 if ($this->
db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
803 $this->
error = $langs->trans(
"ErrorBankLabelAlreadyExists");
806 $this->
error = $this->
db->error().
" sql=".$sql;
815 $this->
db->rollback();
829 global $langs, $conf;
836 if (empty($this->country_id)) {
837 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country"));
841 if (empty($this->
ref)) {
842 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
847 $this->label =
"???";
850 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
852 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
853 $sql .=
",label = '".$this->db->escape($this->label).
"'";
855 $sql .=
",courant = ".((int) $this->courant);
856 $sql .=
",clos = ".((int) $this->clos);
857 $sql .=
",rappro = ".((int) $this->rappro);
858 $sql .=
",url = ".($this->url ?
"'".$this->db->escape($this->url).
"'" :
"null");
859 $sql .=
",account_number = '".$this->db->escape($this->account_number).
"'";
860 $sql .=
",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->
db->escape($this->fk_accountancy_journal) :
"null");
861 $sql .=
",bank = '".$this->db->escape($this->bank).
"'";
862 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
863 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
864 $sql .=
",number='".$this->db->escape($this->number).
"'";
865 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
866 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
867 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
868 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
869 $sql .=
",pti_in_ctti=".((int) $this->pti_in_ctti);
870 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
871 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
873 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
875 $sql .=
",min_allowed = ".($this->min_allowed !=
'' ?
price2num($this->min_allowed) :
"null");
876 $sql .=
",min_desired = ".($this->min_desired !=
'' ?
price2num($this->min_desired) :
"null");
877 $sql .=
",comment = '".$this->db->escape($this->comment).
"'";
879 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
880 $sql .=
",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
881 $sql .=
",ics = '".$this->db->escape($this->ics).
"'";
882 $sql .=
",ics_transfer = '".$this->db->escape($this->ics_transfer).
"'";
884 $sql .=
" WHERE rowid = ".((int) $this->
id);
886 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
887 $result = $this->
db->query($sql);
897 if (!$error && !$notrigger) {
899 $result = $this->
call_trigger(
'BANKACCOUNT_MODIFY', $user);
907 $this->
error = $this->
db->lasterror();
915 $this->
db->rollback();
931 global $conf, $langs;
934 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
936 dol_syslog(get_class($this).
"::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
940 $this->
error = $langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->trans(
"Ref"));
944 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_account SET ";
945 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
946 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
947 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
948 $sql .=
",number='".$this->db->escape($this->number).
"'";
949 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
950 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
951 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
952 $sql .=
",domiciliation='".$this->db->escape($this->domiciliation).
"'";
953 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
954 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
955 $sql .=
",state_id = ".($this->state_id > 0 ? $this->state_id :
"null");
956 $sql .=
",fk_pays = ".($this->country_id > 0 ? $this->country_id :
"null");
957 $sql .=
" WHERE rowid = ".((int) $this->
id);
958 $sql .=
" AND entity = ".((int) $conf->entity);
960 dol_syslog(get_class($this).
"::update_bban", LOG_DEBUG);
962 $result = $this->
db->query($sql);
966 $this->
error = $this->
db->lasterror();
980 public function fetch($id, $ref =
'')
984 if (empty($id) && empty($ref)) {
985 $this->
error =
"ErrorBadParameters";
989 $sql =
"SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
990 $sql .=
" ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
991 $sql .=
" ba.domiciliation, ba.pti_in_ctti, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
992 $sql .=
" ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
993 $sql .=
" ba.min_allowed, ba.min_desired, ba.comment,";
994 $sql .=
" ba.datec as date_creation, ba.tms as date_update, ba.ics, ba.ics_transfer,";
995 $sql .=
' c.code as country_code, c.label as country,';
996 $sql .=
' d.code_departement as state_code, d.nom as state';
997 $sql .=
' , aj.code as accountancy_journal';
998 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
999 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON ba.fk_pays = c.rowid';
1000 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON ba.state_id = d.rowid';
1001 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal';
1002 $sql .=
" WHERE ba.entity IN (".getEntity($this->element).
")";
1004 $sql .=
" AND ba.rowid = ".((int) $id);
1007 $sql .=
" AND ba.ref = '".$this->db->escape($ref).
"'";
1010 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1011 $result = $this->
db->query($sql);
1013 if ($this->
db->num_rows($result)) {
1014 $obj = $this->
db->fetch_object($result);
1016 $this->
id = $obj->rowid;
1017 $this->
rowid = $obj->rowid;
1018 $this->
ref = $obj->ref;
1019 $this->label = $obj->label;
1020 $this->
type = $obj->courant;
1021 $this->courant = $obj->courant;
1022 $this->bank = $obj->bank;
1023 $this->clos = $obj->clos;
1024 $this->rappro = $obj->rappro;
1025 $this->url = $obj->url;
1027 $this->code_banque = $obj->code_banque;
1028 $this->code_guichet = $obj->code_guichet;
1029 $this->number = $obj->number;
1030 $this->cle_rib = $obj->cle_rib;
1031 $this->bic = $obj->bic;
1032 $this->iban = $obj->iban;
1033 $this->domiciliation = $obj->domiciliation;
1034 $this->pti_in_ctti = $obj->pti_in_ctti;
1035 $this->proprio = $obj->proprio;
1036 $this->owner_address = $obj->owner_address;
1038 $this->state_id = $obj->state_id;
1039 $this->state_code = $obj->state_code;
1040 $this->state = $obj->state;
1042 $this->country_id = $obj->country_id;
1043 $this->country_code = $obj->country_code;
1044 $this->country = $obj->country;
1046 $this->account_number = $obj->account_number;
1047 $this->fk_accountancy_journal = $obj->fk_accountancy_journal;
1048 $this->accountancy_journal = $obj->accountancy_journal;
1050 $this->currency_code = $obj->currency_code;
1051 $this->account_currency_code = $obj->currency_code;
1052 $this->min_allowed = $obj->min_allowed;
1053 $this->min_desired = $obj->min_desired;
1054 $this->comment = $obj->comment;
1056 $this->date_creation = $this->
db->jdate($obj->date_creation);
1057 $this->date_update = $this->
db->jdate($obj->date_update);
1059 $this->ics = $obj->ics;
1060 $this->ics_transfer = $obj->ics_transfer;
1071 $this->
error = $this->
db->lasterror;
1072 $this->errors[] = $this->error;
1089 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1090 return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT);
1099 public function delete(
User $user =
null)
1111 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
1112 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1117 $this->
error =
"Error ".$this->db->lasterror();
1122 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_account";
1123 $sql .=
" WHERE rowid = ".((int) $this->
rowid);
1125 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1126 $result = $this->
db->query($sql);
1133 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1138 $this->
error =
"Error ".$this->db->lasterror();
1143 $this->
db->commit();
1146 $this->
db->rollback();
1160 return $this->
LibStatut($this->clos, $mode);
1175 $langs->load(
'banks');
1177 if ($status == self::STATUS_OPEN) {
1178 $label = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1179 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountOpened");
1180 $statusType =
'status4';
1182 $label = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1183 $labelshort = $langs->transnoentitiesnoconv(
"StatusAccountClosed");
1184 $statusType =
'status5';
1187 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1200 $can_be_deleted =
false;
1202 $sql =
"SELECT COUNT(rowid) as nb";
1203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1204 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1208 $obj = $this->
db->fetch_object(
$resql);
1209 if ($obj->nb <= 1) {
1210 $can_be_deleted =
true;
1215 return $can_be_deleted;
1226 return $this->error;
1237 public function solde($option = 0, $date_end =
'', $field =
'dateo')
1241 $sql =
"SELECT sum(amount) as amount";
1242 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank";
1243 $sql .=
" WHERE fk_account = ".((int) $this->
id);
1245 $sql .=
" AND ".$this->db->escape($field).
" <= '".(!empty($date_end) ? $this->
db->idate($date_end) : $this->
db->idate(
dol_now())).
"'";
1251 $obj = $this->
db->fetch_object(
$resql);
1252 $solde = $obj->amount;
1256 $this->errors[] = $this->
db->lasterror;
1274 global $conf, $langs;
1280 $sql =
"SELECT b.rowid, b.datev as datefin";
1281 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1282 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1283 $sql .=
" WHERE b.rappro=0";
1284 $sql .=
" AND b.fk_account = ba.rowid";
1285 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1286 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1287 $sql .=
" AND clos = 0";
1288 if ($filteraccountid) {
1289 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1294 $langs->load(
"banks");
1297 require_once DOL_DOCUMENT_ROOT.
'/core/class/workboardresponse.class.php';
1300 $response->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24;
1301 $response->label = $langs->trans(
"TransactionsToConciliate");
1302 $response->labelShort = $langs->trans(
"TransactionsToConciliateShort");
1303 $response->url = DOL_URL_ROOT.
'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
1306 while ($obj = $this->
db->fetch_object(
$resql)) {
1307 $response->nbtodo++;
1308 if ($this->
db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
1309 $response->nbtodolate++;
1316 $this->
error = $this->
db->error();
1336 $sql =
"SELECT count(b.rowid) as nb";
1337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b,";
1338 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba";
1339 $sql .=
" WHERE b.fk_account = ba.rowid";
1340 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1341 $sql .=
" AND (ba.rappro = 1 AND ba.courant != 2)";
1342 $sql .=
" AND clos = 0";
1343 if ($filteraccountid) {
1344 $sql .=
" AND ba.rowid = ".((int) $filteraccountid);
1349 while ($obj = $this->
db->fetch_object(
$resql)) {
1350 $this->nb[
"banklines"] = $obj->nb;
1355 $this->
error = $this->
db->error();
1368 global $db, $conf, $user;
1377 $sql =
"SELECT COUNT(ba.rowid) as nb";
1378 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
1379 $sql .=
" WHERE ba.rappro > 0 and ba.clos = 0";
1380 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1381 if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) {
1382 $sql .=
" AND ba.courant != 2";
1386 $obj = $this->
db->fetch_object(
$resql);
1405 public function getNomUrl($withpicto = 0, $mode =
'', $option =
'', $save_lastsearch_value = -1, $notooltip = 0)
1407 global $conf, $langs, $user;
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;
1416 $label .=
'<br><b>'.$langs->trans(
'IBAN').
':</b> '.$this->iban;
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;
1978 $this->
db->free($result);
1992 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank (";
1998 $sql .=
", amount_main_currency";
1999 $sql .=
", fk_user_author";
2000 $sql .=
", num_chq";
2001 $sql .=
", fk_account";
2002 $sql .=
", fk_type";
2003 $sql .=
", emetteur,banque";
2005 $sql .=
", numero_compte";
2006 $sql .=
", num_releve";
2007 $sql .=
") VALUES (";
2008 $sql .=
"'".$this->db->idate($this->datec).
"'";
2009 $sql .=
", '".$this->db->idate($this->dateo).
"'";
2010 $sql .=
", '".$this->db->idate($this->datev).
"'";
2011 $sql .=
", '".$this->db->escape($this->label).
"'";
2012 $sql .=
", ".price2num($this->amount);
2013 $sql .=
", ".(empty($this->amount_main_currency) ?
"NULL" :
price2num($this->amount_main_currency));
2014 $sql .=
", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) :
"null");
2015 $sql .=
", ".($this->num_chq ?
"'".$this->db->escape($this->num_chq).
"'" :
"null");
2016 $sql .=
", '".$this->db->escape($this->fk_account).
"'";
2017 $sql .=
", '".$this->db->escape($this->fk_type).
"'";
2018 $sql .=
", ".($this->emetteur ?
"'".$this->db->escape($this->emetteur).
"'" :
"null");
2019 $sql .=
", ".($this->bank_chq ?
"'".$this->db->escape($this->bank_chq).
"'" :
"null");
2020 $sql .=
", ".(int) $this->rappro;
2021 $sql .=
", ".($this->numero_compte ?
"'".$this->db->escape($this->numero_compte).
"'" :
"''");
2022 $sql .=
", ".($this->num_releve ?
"'".$this->db->escape($this->num_releve).
"'" :
"null");
2025 dol_syslog(get_class($this).
"::insert", LOG_DEBUG);
2029 $this->error = $this->
db->lasterror();
2033 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'bank');
2044 public function delete(
User $user =
null)
2050 if ($this->rappro) {
2052 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
2059 if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) {
2060 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->
id);
2063 $obj = $this->
db->fetch_object(
$resql);
2064 if ($obj && $obj->nb) {
2065 $this->error =
'ErrorRecordAlreadyInAccountingDeletionNotPossible';
2066 $this->
db->rollback();
2070 $this->error = $this->
db->lasterror();
2071 $this->
db->rollback();
2082 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class WHERE lineid=".(int) $this->
rowid;
2083 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
2084 $result = $this->
db->query($sql);
2089 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid=".(int) $this->
rowid;
2090 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
2091 $result = $this->
db->query($sql);
2097 $this->
db->commit();
2100 $this->
db->rollback();
2118 if ($this->rappro) {
2120 $this->error =
"ErrorDeleteNotPossibleLineIsConsolidated";
2126 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_url WHERE fk_bank=".(int) $this->
rowid;
2127 dol_syslog(get_class($this).
"::delete_urls", LOG_DEBUG);
2128 $result = $this->
db->query($sql);
2134 $this->
db->commit();
2137 $this->
db->rollback();
2154 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2155 $sql .=
" amount = ".price2num($this->amount).
",";
2156 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
2157 $sql .=
" dateo='".$this->db->idate($this->dateo).
"'";
2158 $sql .=
" WHERE rowid = ".((int) $this->
rowid);
2160 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
2163 $this->
db->commit();
2166 $this->
db->rollback();
2167 $this->error = $this->
db->error();
2185 global $conf, $langs;
2190 if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE)) {
2191 if (!preg_match(
'/'.$conf->global->BANK_STATEMENT_REGEX_RULE.
'/', $this->num_releve)) {
2192 $this->errors[] = $langs->trans(
"ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE);
2197 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2198 $sql .=
" rappro = ".((int) $conciliated);
2199 $sql .=
", num_releve = '".$this->db->escape($this->num_releve).
"'";
2201 $sql .=
", fk_user_rappro = ".$user->id;
2203 $sql .=
" WHERE rowid = ".((int) $this->
id);
2205 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2209 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class (";
2211 $sql .=
", fk_categ";
2212 $sql .=
") VALUES (";
2214 $sql .=
", ".((int) $cat);
2217 dol_syslog(get_class($this).
"::update_conciliation", LOG_DEBUG);
2218 $this->
db->query($sql);
2225 $this->
db->commit();
2228 $this->
db->rollback();
2245 $sql =
"SELECT datev FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".((int) $rowid);
2248 $obj = $this->
db->fetch_object(
$resql);
2249 $newdate = $this->
db->jdate($obj->datev) + (3600 * 24 * $sign);
2251 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2252 $sql .=
" datev = '".$this->db->idate($newdate).
"'";
2253 $sql .=
" WHERE rowid = ".((int) $rowid);
2255 $result = $this->
db->query($sql);
2257 if ($this->
db->affected_rows($result)) {
2308 $sql =
"SELECT dateo FROM ".MAIN_DB_PREFIX.
"bank WHERE rowid = ".((int) $rowid);
2311 $obj = $this->
db->fetch_object(
$resql);
2312 $newdate = $this->
db->jdate($obj->dateo) + (3600 * 24 * $sign);
2314 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank SET";
2315 $sql .=
" dateo = '".$this->db->idate($newdate).
"'";
2316 $sql .=
" WHERE rowid = ".((int) $rowid);
2318 $result = $this->
db->query($sql);
2320 if ($this->
db->affected_rows($result)) {
2368 $sql =
'SELECT b.rowid, b.datec, b.tms as datem,';
2369 $sql .=
' b.fk_user_author, b.fk_user_rappro';
2370 $sql .=
' FROM '.MAIN_DB_PREFIX.
'bank as b';
2371 $sql .=
' WHERE b.rowid = '.((int) $id);
2373 $result = $this->
db->query($sql);
2375 if ($this->
db->num_rows($result)) {
2376 $obj = $this->
db->fetch_object($result);
2377 $this->
id = $obj->rowid;
2379 if ($obj->fk_user_author) {
2380 $cuser =
new User($this->
db);
2381 $cuser->fetch($obj->fk_user_author);
2382 $this->user_creation = $cuser;
2384 if ($obj->fk_user_rappro) {
2385 $ruser =
new User($this->
db);
2386 $ruser->fetch($obj->fk_user_rappro);
2387 $this->user_rappro = $ruser;
2390 $this->date_creation = $this->
db->jdate($obj->datec);
2391 $this->date_modification = $this->
db->jdate($obj->datem);
2394 $this->
db->free($result);
2410 public function getNomUrl($withpicto = 0, $maxlen = 0, $option =
'', $notooltip = 0)
2416 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"BankTransactionLine").
'</u>:<br>';
2417 $label .=
'<b>'.$langs->trans(
"Ref").
':</b> '.$this->ref;
2419 $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">';
2422 $result .= $linkstart;
2424 $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);
2426 if ($withpicto != 2) {
2427 $result .= ($this->
ref ? $this->
ref : $this->id);
2429 $result .= $linkend;
2431 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2432 $result .=
' <span class="opacitymedium">(';
2434 if ($option ==
'showall') {
2435 $result .= $langs->trans(
"BankAccount").
': ';
2436 $accountstatic =
new Account($this->
db);
2437 $accountstatic->id = $this->fk_account;
2438 $accountstatic->ref = $this->bank_account_ref;
2439 $accountstatic->label = $this->bank_account_label;
2440 $result .= $accountstatic->getNomUrl(0).
', ';
2442 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2443 $result .= $langs->trans(
"BankLineConciliated").
': ';
2444 $result .=
yn($this->rappro);
2446 if ($option ==
'showall' || $option ==
'showconciliatedandaccounted') {
2447 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->
id);
2450 $obj = $this->
db->fetch_object(
$resql);
2451 if ($obj && $obj->nb) {
2452 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(1);
2454 $result .=
' - '.$langs->trans(
"Accounted").
': '.
yn(0);
2458 if ($option ==
'showall' || $option ==
'showconciliated' || $option ==
'showconciliatedandaccounted') {
2459 $result .=
')</span>';
2474 return $this->
LibStatut($this->status, $mode);
2531 $alreadydispatched = 0;
2535 $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);
2538 $obj = $this->
db->fetch_object(
$resql);
2540 $alreadydispatched = $obj->nb;
2543 $this->error = $this->
db->lasterror();
2547 if ($alreadydispatched) {