45  public $element = 
'cchargesociales';
 
   50  public $table_element = 
'c_chargesociales';
 
   76  public $accountancy_code;
 
   81  public $errors = array();
 
  123    $sql = 
'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.
'(';
 
  125    $sql .= 
'deductible,';
 
  130    $sql .= 
'accountancy_code';
 
  131    $sql .= 
') VALUES (';
 
  132    $sql .= 
' '.(!isset($this->libelle) ? 
'NULL' : 
"'".$this->db->escape($this->libelle).
"'").
',';
 
  133    $sql .= 
' '.(!isset($this->deductible) ? 
'NULL' : $this->deductible).
',';
 
  134    $sql .= 
' '.(!isset($this->active) ? 
'NULL' : $this->active).
',';
 
  135    $sql .= 
' '.(!isset($this->code) ? 
'NULL' : 
"'".$this->db->escape($this->code).
"'").
',';
 
  136    $sql .= 
' '.(!isset($this->fk_pays) ? 
'NULL' : $this->fk_pays).
',';
 
  137    $sql .= 
' '.(!isset($this->module) ? 
'NULL' : 
"'".$this->db->escape($this->module).
"'").
',';
 
  138    $sql .= 
' '.(!isset($this->accountancy_code) ? 
'NULL' : 
"'".$this->db->escape($this->accountancy_code).
"'");
 
  143    $resql = $this->db->query($sql);
 
  146      $this->errors[] = 
'Error '.$this->db->lasterror();
 
  147      dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
 
  151      $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
 
  166      $this->db->rollback();
 
 
  184  public function fetch($id, $ref = 
null)
 
  190    $sql .= 
" t.libelle as label,";
 
  191    $sql .= 
" t.deductible,";
 
  192    $sql .= 
" t.active,";
 
  194    $sql .= 
" t.fk_pays,";
 
  195    $sql .= 
" t.module,";
 
  196    $sql .= 
" t.accountancy_code";
 
  197    $sql .= 
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
 
  199      $sql .= 
" WHERE t.code = '".$this->db->escape($ref).
"'";
 
  201      $sql .= 
' WHERE t.id = '.((int) $id);
 
  204    $resql = $this->db->query($sql);
 
  206      $numrows = $this->db->num_rows($resql);
 
  208        $obj = $this->db->fetch_object($resql);
 
  210        $this->
id = $obj->id;
 
  212        $this->libelle = $obj->label;
 
  213        $this->label = $obj->label;
 
  214        $this->deductible = $obj->deductible;
 
  215        $this->active = $obj->active;
 
  216        $this->code = $obj->code;
 
  217        $this->fk_pays = $obj->fk_pays;
 
  218        $this->module = $obj->module;
 
  219        $this->accountancy_code = $obj->accountancy_code;
 
  221      $this->db->free($resql);
 
  229      $this->errors[] = 
'Error '.$this->db->lasterror();
 
  230      dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
 
 
  268    $sql = 
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET';
 
  269    $sql .= 
' libelle = '.(isset($this->libelle) ? 
"'".$this->db->escape($this->libelle).
"'" : 
"null").
',';
 
  270    $sql .= 
' deductible = '.(isset($this->deductible) ? ((int) $this->deductible) : 
"null").
',';
 
  271    $sql .= 
' active = '.(isset($this->active) ? ((int) $this->active) : 
"null").
',';
 
  272    $sql .= 
' code = '.(isset($this->code) ? 
"'".$this->db->escape($this->code).
"'" : 
"null").
',';
 
  273    $sql .= 
' fk_pays = '.((isset($this->fk_pays) && $this->fk_pays > 0) ? ((
int) $this->fk_pays) : 
"null").
',';
 
  274    $sql .= 
' module = '.(isset($this->module) ? 
"'".$this->db->escape($this->module).
"'" : 
"null").
',';
 
  275    $sql .= 
' accountancy_code = '.(isset($this->accountancy_code) ? 
"'".$this->db->escape($this->accountancy_code).
"'" : 
"null");
 
  276    $sql .= 
' WHERE id='.((int) $this->
id);
 
  280    $resql = $this->db->query($sql);
 
  283      $this->errors[] = 
'Error '.$this->db->lasterror();
 
  284      dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
 
  299      $this->db->rollback();
 
 
  316  public function delete(
User $user, $notrigger = 0)
 
  337      $sql = 
'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
 
  338      $sql .= 
' WHERE id = '.((int) $this->
id);
 
  340      $resql = $this->db->query($sql);
 
  343        $this->errors[] = 
'Error '.$this->db->lasterror();
 
  344        dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
 
  350      $this->db->rollback();
 
 
  475        return $langs->trans(
'Enabled');
 
  476      } elseif ($status == 0) {
 
  477        return $langs->trans(
'Disabled');
 
  479    } elseif ($mode == 1) {
 
  481        return $langs->trans(
'Enabled');
 
  482      } elseif ($status == 0) {
 
  483        return $langs->trans(
'Disabled');
 
  485    } elseif ($mode == 2) {
 
  487        return img_picto($langs->trans(
'Enabled'), 
'statut4').
' '.$langs->trans(
'Enabled');
 
  488      } elseif ($status == 0) {
 
  489        return img_picto($langs->trans(
'Disabled'), 
'statut5').
' '.$langs->trans(
'Disabled');
 
  491    } elseif ($mode == 3) {
 
  493        return img_picto($langs->trans(
'Enabled'), 
'statut4');
 
  494      } elseif ($status == 0) {
 
  495        return img_picto($langs->trans(
'Disabled'), 
'statut5');
 
  497    } elseif ($mode == 4) {
 
  499        return img_picto($langs->trans(
'Enabled'), 
'statut4').
' '.$langs->trans(
'Enabled');
 
  500      } elseif ($status == 0) {
 
  501        return img_picto($langs->trans(
'Disabled'), 
'statut5').
' '.$langs->trans(
'Disabled');
 
  503    } elseif ($mode == 5) {
 
  505        return $langs->trans(
'Enabled').
' '.
img_picto($langs->trans(
'Enabled'), 
'statut4');
 
  506      } elseif ($status == 0) {
 
  507        return $langs->trans(
'Disabled').
' '.
img_picto($langs->trans(
'Disabled'), 
'statut5');
 
 
  525    $this->deductible = 
'';
 
  530    $this->accountancy_code = 
'';
 
 
  543    foreach ($parameters as $parameter) {
 
  544      if (isset($this->$parameter)) {
 
  545        $this->$parameter = trim($this->$parameter);
 
 
 
fetch($id, $ref=null)
Load object in memory from the database.
 
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
 
create(User $user, $notrigger=0)
Create object into database.
 
update(User $user, $notrigger=0)
Update object into database.
 
LibStatut($status, $mode=0)
Load an object from its id and create a new one in database.
 
trimParameters($parameters)
Trim object parameters.
 
__construct(DoliDB $db)
Constructor.
 
Class to manage Dolibarr database access.
 
Class to manage Dolibarr users.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.