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);