42 public $errors = array();
52 public $code_departement;
92 public function create($user, $notrigger = 0)
97 if (isset($this->code_departement)) {
98 $this->code_departement = trim($this->code_departement);
100 if (isset($this->nom)) {
101 $this->nom = trim($this->nom);
103 if (isset($this->active)) {
104 $this->active = trim($this->active);
111 $sql =
"INSERT INTO ".$this->db->prefix().
"c_departements(";
113 $sql .=
"code_departement,";
116 $sql .=
") VALUES (";
117 $sql .=
" ".(!isset($this->
rowid) ?
'NULL' :
"'".$this->db->escape($this->
rowid).
"'").
",";
118 $sql .=
" ".(!isset($this->code_departement) ?
'NULL' :
"'".$this->db->escape($this->code_departement).
"'").
",";
119 $sql .=
" ".(!isset($this->nom) ?
'NULL' :
"'".$this->db->escape($this->nom).
"'").
",";
120 $sql .=
" ".(!isset($this->active) ?
'NULL' :
"'".$this->db->escape($this->active).
"'").
"";
125 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
129 $this->errors[] =
"Error ".$this->db->lasterror();
133 $this->
id = $this->
db->last_insert_id($this->
db->prefix().
"c_departements");
138 foreach ($this->errors as $errmsg) {
139 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
140 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
142 $this->
db->rollback();
158 public function fetch($id, $code =
'')
162 $sql .=
" t.code_departement,";
165 $sql .=
" FROM ".$this->db->prefix().
"c_departements as t";
167 $sql .=
" WHERE t.rowid = ".((int) $id);
169 $sql .=
" WHERE t.code_departement = '".$this->db->escape($code).
"'";
172 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
176 $obj = $this->
db->fetch_object(
$resql);
178 $this->
id = $obj->rowid;
179 $this->code_departement = $obj->code_departement;
180 $this->
code = $obj->code_departement;
181 $this->nom = $obj->nom;
182 $this->
name = $obj->nom;
183 $this->active = $obj->active;
189 $this->error =
"Error ".$this->db->lasterror();
202 public function update($user =
null, $notrigger = 0)
204 global $conf, $langs;
208 if (isset($this->code_departement)) {
209 $this->code_departement = trim($this->code_departement);
211 if (isset($this->nom)) {
212 $this->nom = trim($this->nom);
214 if (isset($this->active)) {
215 $this->active = trim($this->active);
223 $sql =
"UPDATE ".$this->db->prefix().
"c_departements SET";
224 $sql .=
" code_departement=".(isset($this->code_departement) ?
"'".$this->db->escape($this->code_departement).
"'" :
"null").
",";
225 $sql .=
" nom=".(isset($this->nom) ?
"'".$this->db->escape($this->nom).
"'" :
"null").
",";
226 $sql .=
" active=".(isset($this->active) ? $this->active :
"null").
"";
227 $sql .=
" WHERE rowid=".((int) $this->
id);
231 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
235 $this->errors[] =
"Error ".$this->db->lasterror();
240 foreach ($this->errors as $errmsg) {
241 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
242 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
244 $this->
db->rollback();
259 public function delete($user, $notrigger = 0)
261 global $conf, $langs;
264 $sql =
"DELETE FROM ".$this->db->prefix().
"c_departements";
265 $sql .=
" WHERE rowid=".((int) $this->
id);
269 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
273 $this->errors[] =
"Error ".$this->db->lasterror();
278 foreach ($this->errors as $errmsg) {
279 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
280 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
282 $this->
db->rollback();
Class to manage dictionary States (used by imports)
fetch($id, $code='')
Load object in memory from database.
create($user, $notrigger=0)
Create object into database.
__construct($db)
Constructor.
update($user=null, $notrigger=0)
Update object into database.
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.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...