36 public $picto =
'generic';
74 if (isset($this->label)) {
75 $this->label = trim($this->label);
79 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_categ (";
83 $sql .=
" ".(!isset($this->label) ?
'NULL' :
"'".$this->db->escape($this->label).
"'");
84 $sql .=
", ".((int) $conf->entity);
89 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
93 $this->errors[] =
"Error ".$this->db->lasterror();
97 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bank_categ");
102 foreach ($this->errors as $errmsg) {
103 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
104 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
106 $this->
db->rollback();
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_categ as t";
129 $sql .=
" WHERE t.rowid = ".((int) $id);
130 $sql .=
" AND t.entity = ".$conf->entity;
132 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
136 $obj = $this->
db->fetch_object(
$resql);
138 $this->
id = $obj->rowid;
139 $this->label = $obj->label;
145 $this->error =
"Error ".$this->db->lasterror();
163 if (isset($this->label)) {
164 $this->label = trim($this->label);
171 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank_categ SET";
172 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null");
173 $sql .=
" WHERE rowid=".((int) $this->
id);
174 $sql .=
" AND entity = ".$conf->entity;
178 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
182 $this->errors[] =
"Error ".$this->db->lasterror();
187 foreach ($this->errors as $errmsg) {
188 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
189 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
191 $this->
db->rollback();
206 public function delete(
User $user, $notrigger = 0)
215 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_account";
216 $sql .=
" WHERE fk_categorie = ".((int) $this->
id);
221 $this->errors[] =
"Error ".$this->db->lasterror();
227 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class";
228 $sql .=
" WHERE fk_categ = ".((int) $this->
id);
233 $this->errors[] =
"Error ".$this->db->lasterror();
239 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_categ";
240 $sql .=
" WHERE rowid=".((int) $this->
id);
245 $this->errors[] =
"Error ".$this->db->lasterror();
251 foreach ($this->errors as $errmsg) {
252 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
253 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
255 $this->
db->rollback();
279 $object->fetch($fromid);
284 $object->context[
'createfromclone'] =
'createfromclone';
285 $result = $object->create($user);
289 $this->error = $object->error;
293 unset($object->context[
'createfromclone']);
300 $this->
db->rollback();
316 $sql =
"SELECT rowid, label FROM ".MAIN_DB_PREFIX.
"bank_categ WHERE entity = ".$conf->entity.
" ORDER BY label";
320 while ($obj = $this->
db->fetch_object(
$resql)) {
322 $tmp->id = $obj->rowid;
323 $tmp->label = $obj->label;
Class to manage bank categories.
create(User $user, $notrigger=0)
Create in database.
update(User $user=null, $notrigger=0)
Update database.
fetch($id)
Load object in memory from database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
__construct(DoliDB $db)
Constructor.
fetchAll()
Returns all bank categories.
initAsSpecimen()
Initialise an instance with random values.
Class to manage Dolibarr database access.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.