25require_once DOL_DOCUMENT_ROOT.
'/core/class/commondict.class.php';
38 public $code_departement;
71 public function create($user, $notrigger = 0)
76 if (isset($this->code_departement)) {
77 $this->code_departement = trim($this->code_departement);
79 if (isset($this->nom)) {
80 $this->nom = trim($this->nom);
82 if (isset($this->active)) {
83 $this->active = trim($this->active);
90 $sql =
"INSERT INTO ".$this->db->prefix().
"c_departements(";
92 $sql .=
"code_departement,";
96 $sql .=
" ".(!isset($this->
rowid) ?
'NULL' :
"'".$this->db->escape($this->
rowid).
"'").
",";
97 $sql .=
" ".(!isset($this->code_departement) ?
'NULL' :
"'".$this->db->escape($this->code_departement).
"'").
",";
98 $sql .=
" ".(!isset($this->nom) ?
'NULL' :
"'".$this->db->escape($this->nom).
"'").
",";
99 $sql .=
" ".(!isset($this->active) ?
'NULL' :
"'".$this->db->escape($this->active).
"'");
104 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
105 $resql = $this->db->query($sql);
108 $this->errors[] =
"Error ".$this->db->lasterror();
112 $this->
id = $this->db->last_insert_id($this->db->prefix().
"c_departements");
117 foreach ($this->errors as $errmsg) {
118 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
119 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
121 $this->db->rollback();
137 public function fetch($id, $code =
'')
141 $sql .=
" t.code_departement,";
144 $sql .=
" FROM ".$this->db->prefix().
"c_departements as t";
146 $sql .=
" WHERE t.rowid = ".((int) $id);
148 $sql .=
" WHERE t.code_departement = '".$this->db->escape($code).
"'";
151 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
152 $resql = $this->db->query($sql);
154 if ($this->db->num_rows($resql)) {
155 $obj = $this->db->fetch_object($resql);
157 $this->
id = $obj->rowid;
158 $this->code_departement = $obj->code_departement;
159 $this->code = $obj->code_departement;
160 $this->nom = $obj->nom;
161 $this->
name = $obj->nom;
162 $this->active = $obj->active;
164 $this->db->free($resql);
168 $this->error =
"Error ".$this->db->lasterror();
181 public function update($user =
null, $notrigger = 0)
186 if (isset($this->code_departement)) {
187 $this->code_departement = trim($this->code_departement);
189 if (isset($this->
name)) {
192 if (isset($this->active)) {
193 $this->active = trim($this->active);
197 if (empty($this->
name) && !empty($this->nom)) {
198 $this->
name = $this->nom;
202 $sql =
"UPDATE ".$this->db->prefix().
"c_departements SET";
203 $sql .=
" code_departement=".(isset($this->code_departement) ?
"'".$this->db->escape($this->code_departement).
"'" :
"null").
",";
204 $sql .=
" nom=".(isset($this->
name) ?
"'".$this->db->escape($this->
name).
"'" :
"null").
",";
205 $sql .=
" active=".(isset($this->active) ? ((int) $this->active) :
"null");
206 $sql .=
" WHERE rowid=".((int) $this->
id);
210 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
211 $resql = $this->db->query($sql);
214 $this->errors[] =
"Error ".$this->db->lasterror();
219 foreach ($this->errors as $errmsg) {
220 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
221 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
223 $this->db->rollback();
238 public function delete($user, $notrigger = 0)
242 $sql =
"DELETE FROM ".$this->db->prefix().
"c_departements";
243 $sql .=
" WHERE rowid=".((int) $this->
id);
247 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
248 $resql = $this->db->query($sql);
251 $this->errors[] =
"Error ".$this->db->lasterror();
256 foreach ($this->errors as $errmsg) {
257 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
258 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
260 $this->db->rollback();
278 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
281 return $langs->trans($this->
name);
Parent class of all other dictionary classes.
Class to manage dictionary States (used by imports)
fetch($id, $code='')
Load object in memory from database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
create($user, $notrigger=0)
Create object into database.
__construct($db)
Constructor.
update($user=null, $notrigger=0)
Update object into database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
$conf db name
Only used if Module[ID]Name translation string is not found.