30 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
41 public $element =
'user_bank_account';
46 public $table_element =
'user_rib';
93 public function create(
User $user =
null, $notrigger = 0)
97 $sql =
"INSERT INTO ".$this->db->prefix().
"user_rib (fk_user, datec)";
98 $sql .=
" VALUES (".$this->userid.
", '".$this->db->idate($now).
"')";
99 $resql = $this->db->query(
$sql);
101 if ($this->db->affected_rows($resql)) {
102 $this->
id = $this->db->last_insert_id($this->db->prefix().
"user_rib");
104 return $this->
update($user);
109 print $this->db->error();
131 $sql =
"UPDATE ".$this->db->prefix().
"user_rib SET";
132 $sql .=
" bank = '".$this->db->escape($this->bank).
"'";
133 $sql .=
",code_banque='".$this->db->escape($this->code_banque).
"'";
134 $sql .=
",code_guichet='".$this->db->escape($this->code_guichet).
"'";
135 $sql .=
",number='".$this->db->escape($this->number).
"'";
136 $sql .=
",cle_rib='".$this->db->escape($this->cle_rib).
"'";
137 $sql .=
",bic='".$this->db->escape($this->bic).
"'";
138 $sql .=
",iban_prefix = '".$this->db->escape($this->iban).
"'";
139 $sql .=
",domiciliation='".$this->db->escape($this->address ? $this->address :$this->domiciliation).
"'";
140 $sql .=
",proprio = '".$this->db->escape($this->proprio).
"'";
141 $sql .=
",owner_address = '".$this->db->escape($this->owner_address).
"'";
142 $sql .=
",currency_code = '".$this->db->escape($this->currency_code).
"'";
143 $sql .=
",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) :
"null");
144 $sql .=
",fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) :
"null");
146 if (trim($this->label) !=
'') {
147 $sql .=
",label = '".$this->db->escape($this->label).
"'";
149 $sql .=
",label = NULL";
151 $sql .=
" WHERE rowid = ".((int) $this->
id);
153 $result = $this->db->query(
$sql);
156 $this->errors[] = $this->db->lasterror();
160 if (!$error && !$notrigger) {
162 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_MODIFY', $user);
171 $this->db->rollback();
187 public function fetch($id, $ref =
'', $userid = 0)
189 if (empty($id) && empty($ref) && empty($userid)) {
193 $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";
194 $sql .=
", ur.proprio as owner_name, ur.owner_address, ur.label, ur.datec, ur.tms as datem";
195 $sql .=
', ur.currency_code, ur.state_id, ur.fk_country as country_id';
196 $sql .=
', c.code as country_code, c.label as country';
197 $sql .=
', d.code_departement as state_code, d.nom as state';
198 $sql .=
" FROM ".$this->db->prefix().
"user_rib as ur";
199 $sql .=
' LEFT JOIN '.$this->db->prefix().
'c_country as c ON ur.fk_country=c.rowid';
200 $sql .=
' LEFT JOIN '.$this->db->prefix().
'c_departements as d ON ur.state_id=d.rowid';
203 $sql .=
" WHERE ur.rowid = ".((int) $id);
206 $sql .=
" WHERE ur.label = '".$this->db->escape($ref).
"'";
209 $sql .=
" WHERE ur.fk_user = ".((int) $userid);
212 $resql = $this->db->query(
$sql);
214 if ($this->db->num_rows($resql)) {
215 $obj = $this->db->fetch_object($resql);
217 $this->
id = $obj->rowid;
218 $this->userid = $obj->fk_user;
219 $this->bank = $obj->bank;
220 $this->code_banque = $obj->code_banque;
221 $this->code_guichet = $obj->code_guichet;
222 $this->number = $obj->number;
223 $this->cle_rib = $obj->cle_rib;
224 $this->bic = $obj->bic;
225 $this->iban = $obj->iban;
229 $this->domiciliation = $obj->address;
230 $this->address = $obj->address;
232 $this->proprio = $obj->owner_name;
233 $this->owner_name = $obj->owner_name;
234 $this->owner_address = $obj->owner_address;
235 $this->label = $obj->label;
236 $this->datec = $this->db->jdate($obj->datec);
237 $this->datem = $this->db->jdate($obj->datem);
238 $this->currency_code = $obj->currency_code;
240 $this->state_id = $obj->state_id;
241 $this->state_code = $obj->state_code;
242 $this->state = $obj->state;
244 $this->country_id = $obj->country_id;
245 $this->country_code = $obj->country_code;
246 $this->country = $obj->country;
248 $this->db->free($resql);
264 public function delete(
User $user =
null, $notrigger = 0)
285 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
286 $sql .=
" WHERE rowid = ".((int) $this->
id);
288 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
289 $result = $this->db->query(
$sql);
302 $this->
error =
"Error ".$this->db->lasterror();
310 $this->db->rollback();
325 if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) {
326 if ($this->label && $displayriblabel) {
327 $rib = $this->label.
" : ";
342 if (!empty($this->country_code)) {
343 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
345 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.
update(User $user=null, $notrigger=0)
Update bank account.
create(User $user=null, $notrigger=0)
Create bank information record.
getRibLabel($displayriblabel=true)
Return RIB.
__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.
Class to manage Dolibarr users.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type