31require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
42 public $element =
'user_bank_account';
47 public $table_element =
'user_rib';
94 public function create($user =
null, $notrigger = 0)
98 $sql =
"INSERT INTO ".$this->db->prefix().
"user_rib (fk_user, datec)";
99 $sql .=
" VALUES (".$this->userid.
", '".$this->db->idate($now).
"')";
100 $resql = $this->db->query($sql);
102 if ($this->db->affected_rows($resql)) {
103 $this->
id = $this->db->last_insert_id($this->db->prefix().
"user_rib");
105 return $this->
update($user);
110 print $this->db->error();
122 public function update($user =
null, $notrigger = 0)
132 $sql =
"UPDATE ".$this->db->prefix().
"user_rib SET";
133 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
134 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
135 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
136 $sql .=
",number='".$this->db->escape($this->number).
"'";
137 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
138 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
139 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
140 $sql .=
",domiciliation='".$this->db->escape($this->
address).
"'";
141 $sql .=
",proprio = '".$this->db->escape($this->owner_name).
"'";
142 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
143 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
144 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
145 $sql .=
",fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
147 if (trim($this->label) !=
'') {
148 $sql .=
",label = '".$this->db->escape($this->label).
"'";
150 $sql .=
",label = NULL";
152 $sql .=
" WHERE rowid = ".((int) $this->
id);
154 $result = $this->db->query($sql);
157 $this->errors[] = $this->db->lasterror();
161 if (!$error && !$notrigger) {
163 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_MODIFY', $user);
172 $this->db->rollback();
188 public function fetch($id, $ref =
'', $userid = 0)
190 if (empty($id) && empty($ref) && empty($userid)) {
194 $sql =
"SELECT ur.rowid, ur.fk_user, ur.entity, ur.bank, ur.number, ur.code_banque, ur.code_guichet, ur.cle_rib, ur.bic, ur.iban_prefix as iban, ur.domiciliation as address";
195 $sql .=
", ur.proprio as owner_name, ur.owner_address, ur.label, ur.datec, ur.tms as datem";
196 $sql .=
', ur.currency_code, ur.state_id, ur.fk_country as country_id';
197 $sql .=
', c.code as country_code, c.label as country';
198 $sql .=
', d.code_departement as state_code, d.nom as state';
199 $sql .=
" FROM ".$this->db->prefix().
"user_rib as ur";
200 $sql .=
' LEFT JOIN '.$this->db->prefix().
'c_country as c ON ur.fk_country=c.rowid';
201 $sql .=
' LEFT JOIN '.$this->db->prefix().
'c_departements as d ON ur.state_id=d.rowid';
204 $sql .=
" WHERE ur.rowid = ".((int) $id);
207 $sql .=
" WHERE ur.label = '".$this->db->escape($ref).
"'";
210 $sql .=
" WHERE ur.fk_user = ".((int) $userid);
213 $resql = $this->db->query($sql);
215 if ($this->db->num_rows($resql)) {
216 $obj = $this->db->fetch_object($resql);
218 $this->
id = $obj->rowid;
219 $this->userid = $obj->fk_user;
220 $this->bank = $obj->bank;
221 $this->code_banque = $obj->code_banque;
222 $this->code_guichet = $obj->code_guichet;
223 $this->number = $obj->number;
224 $this->cle_rib = $obj->cle_rib;
225 $this->bic = $obj->bic;
226 $this->iban = $obj->iban;
230 $this->
address = $obj->address;
232 $this->owner_name = $obj->owner_name;
233 $this->proprio = $obj->owner_name;
234 $this->owner_address = $obj->owner_address;
236 $this->label = $obj->label;
237 $this->datec = $this->db->jdate($obj->datec);
238 $this->datem = $this->db->jdate($obj->datem);
239 $this->currency_code = $obj->currency_code;
241 $this->state_id = $obj->state_id;
242 $this->state_code = $obj->state_code;
243 $this->state = $obj->state;
245 $this->country_id = $obj->country_id;
246 $this->country_code = $obj->country_code;
247 $this->country = $obj->country;
249 $this->db->free($resql);
265 public function delete($user =
null, $notrigger = 0)
286 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
287 $sql .=
" WHERE rowid = ".((int) $this->
id);
289 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
290 $result = $this->db->query($sql);
303 $this->
error =
"Error ".$this->db->lasterror();
311 $this->db->rollback();
326 if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) {
327 if ($this->label && $displayriblabel) {
328 $rib = $this->label.
" : ";
343 if (!empty($this->country_code)) {
344 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
346 return in_array($this->country_code, $country_code_in_EEC);
Class to manage bank accounts.
solde($option=0, $date_end='', $field='dateo')
Return current balance.
const TYPE_CURRENT
Current account.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage bank accounts description of users.
getRibLabel($displayriblabel=true)
Return RIB.
update($user=null, $notrigger=0)
Update bank account.
create($user=null, $notrigger=0)
Create bank information record.
__construct(DoliDB $db)
Constructor.
checkCountryBankAccount()
Return if a country of userBank is inside the EEC (European Economic Community)
fetch($id, $ref='', $userid=0)
Load record from database.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
dol_now($mode='auto')
Return date for now.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div refaddress div address
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type