25require_once DOL_DOCUMENT_ROOT.
'/core/class/commondict.class.php';
 
   42  public $code_departement;
 
   75  public function create($user, $notrigger = 0)
 
   80    if (isset($this->code_departement)) {
 
   81      $this->code_departement = trim($this->code_departement);
 
   83    if (isset($this->nom)) {
 
   84      $this->nom = trim($this->nom);
 
   86    if (isset($this->active)) {
 
   87      $this->active = (int) $this->active;
 
   94    $sql = 
"INSERT INTO ".$this->db->prefix().
"c_departements(";
 
   96    $sql .= 
"code_departement,";
 
  100    $sql .= 
" ".(!isset($this->
rowid) ? 
'NULL' : 
"'".$this->db->escape($this->
rowid).
"'").
",";
 
  101    $sql .= 
" ".(!isset($this->code_departement) ? 
'NULL' : 
"'".$this->db->escape($this->code_departement).
"'").
",";
 
  102    $sql .= 
" ".(!isset($this->nom) ? 
'NULL' : 
"'".$this->db->escape($this->nom).
"'").
",";
 
  103    $sql .= 
" ".(!isset($this->active) ? 
'NULL' : 
"'".$this->db->escape($this->active).
"'");
 
  108    dol_syslog(get_class($this).
"::create", LOG_DEBUG);
 
  109    $resql = $this->db->query($sql);
 
  112      $this->errors[] = 
"Error ".$this->db->lasterror();
 
  116      $this->
id = $this->db->last_insert_id($this->db->prefix().
"c_departements");
 
  121      foreach ($this->errors as $errmsg) {
 
  122        dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
 
  123        $this->error .= ($this->error ? 
', '.$errmsg : $errmsg);
 
  125      $this->db->rollback();
 
 
  141  public function fetch($id, $code = 
'')
 
  145    $sql .= 
" t.code_departement,";
 
  148    $sql .= 
" FROM ".$this->db->prefix().
"c_departements as t";
 
  150      $sql .= 
" WHERE t.rowid = ".((int) $id);
 
  152      $sql .= 
" WHERE t.code_departement = '".$this->db->escape($code).
"'";
 
  155    dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
 
  156    $resql = $this->db->query($sql);
 
  158      if ($this->db->num_rows($resql)) {
 
  159        $obj = $this->db->fetch_object($resql);
 
  161        $this->
id = $obj->rowid;
 
  162        $this->code_departement = $obj->code_departement; 
 
  163        $this->code = $obj->code_departement;
 
  164        $this->nom = $obj->nom; 
 
  165        $this->
name = $obj->nom;
 
  166        $this->active = $obj->active;
 
  168      $this->db->free($resql);
 
  172      $this->error = 
"Error ".$this->db->lasterror();
 
 
  185  public function update($user = 
null, $notrigger = 0)
 
  190    if (isset($this->code_departement)) {
 
  191      $this->code_departement = trim($this->code_departement);
 
  193    if (isset($this->
name)) {
 
  196    if (isset($this->active)) {
 
  197      $this->active = (int) $this->active;
 
  201    if (empty($this->
name) && !empty($this->nom)) {
 
  202      $this->
name = $this->nom;
 
  206    $sql = 
"UPDATE ".$this->db->prefix().
"c_departements SET";
 
  207    $sql .= 
" code_departement=".(isset($this->code_departement) ? 
"'".$this->db->escape($this->code_departement).
"'" : 
"null").
",";
 
  208    $sql .= 
" nom=".(isset($this->
name) ? 
"'".$this->db->escape($this->
name).
"'" : 
"null").
",";
 
  209    $sql .= 
" active=".(isset($this->active) ? ((int) $this->active) : 
"null");
 
  210    $sql .= 
" WHERE rowid=".((int) $this->
id);
 
  214    dol_syslog(get_class($this).
"::update", LOG_DEBUG);
 
  215    $resql = $this->db->query($sql);
 
  218      $this->errors[] = 
"Error ".$this->db->lasterror();
 
  223      foreach ($this->errors as $errmsg) {
 
  224        dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
 
  225        $this->error .= ($this->error ? 
', '.$errmsg : $errmsg);
 
  227      $this->db->rollback();
 
 
  242  public function delete($user, $notrigger = 0)
 
  246    $sql = 
"DELETE FROM ".$this->db->prefix().
"c_departements";
 
  247    $sql .= 
" WHERE rowid=".((int) $this->
id);
 
  251    dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
 
  252    $resql = $this->db->query($sql);
 
  255      $this->errors[] = 
"Error ".$this->db->lasterror();
 
  260      foreach ($this->errors as $errmsg) {
 
  261        dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
 
  262        $this->error .= ($this->error ? 
', '.$errmsg : $errmsg);
 
  264      $this->db->rollback();
 
 
  282  public function getNomUrl($withpicto = 0, $option = 
'', $notooltip = 0, $morecss = 
'', $save_lastsearch_value = -1)
 
  285    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 optionally 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.
 
$conf db name
Only used if Module[ID]Name translation string is not found.
 
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e rowid