40 public $element =
'cchargesociales';
45 public $table_element =
'c_chargesociales';
58 public $accountancy_code;
102 $sql =
'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element .
'(';
105 $sql.=
'deductible,';
110 $sql.=
'accountancy_code';
113 $sql .=
') VALUES (';
115 $sql .=
' '.(! isset($this->libelle)?
'NULL':
"'".$this->db->escape($this->libelle).
"'").
',';
116 $sql .=
' '.(! isset($this->deductible)?
'NULL':$this->deductible).
',';
117 $sql .=
' '.(! isset($this->active)?
'NULL':$this->active).
',';
118 $sql .=
' '.(! isset($this->code)?
'NULL':
"'".$this->db->escape($this->code).
"'").
',';
119 $sql .=
' '.(! isset($this->fk_pays)?
'NULL':$this->fk_pays).
',';
120 $sql .=
' '.(! isset($this->module)?
'NULL':
"'".$this->db->escape($this->module).
"'").
',';
121 $sql .=
' '.(! isset($this->accountancy_code)?
'NULL':
"'".$this->db->escape($this->accountancy_code).
"'");
128 $resql = $this->db->query($sql);
131 $this->errors[] =
'Error ' . $this->db->lasterror();
132 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
136 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
151 $this->db->rollback();
169 public function fetch($id, $ref = null)
175 $sql .=
" t.libelle,";
176 $sql .=
" t.deductible,";
177 $sql .=
" t.active,";
179 $sql .=
" t.fk_pays,";
180 $sql .=
" t.module,";
181 $sql .=
" t.accountancy_code";
182 $sql .=
' FROM ' . MAIN_DB_PREFIX . $this->table_element .
' as t';
184 $sql .=
" WHERE t.code = '" . $this->db->escape($ref) .
"'";
186 $sql .=
' WHERE t.id = ' . $id;
189 $resql = $this->db->query($sql);
191 $numrows = $this->db->num_rows(
$resql);
193 $obj = $this->db->fetch_object(
$resql);
195 $this->
id = $obj->id;
197 $this->libelle = $obj->libelle;
198 $this->deductible = $obj->deductible;
199 $this->active = $obj->active;
200 $this->code = $obj->code;
201 $this->fk_pays = $obj->fk_pays;
202 $this->module = $obj->module;
203 $this->accountancy_code = $obj->accountancy_code;
213 $this->errors[] =
'Error ' . $this->db->lasterror();
214 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
253 $sql =
'UPDATE ' . MAIN_DB_PREFIX . $this->table_element .
' SET';
254 $sql .=
' libelle = '.(isset($this->libelle)?
"'".$this->db->escape($this->libelle).
"'":
"null").
',';
255 $sql .=
' deductible = '.(isset($this->deductible)?$this->deductible:
"null").
',';
256 $sql .=
' active = '.(isset($this->active)?$this->active:
"null").
',';
257 $sql .=
' code = '.(isset($this->code)?
"'".$this->db->escape($this->code).
"'":
"null").
',';
258 $sql .=
' fk_pays = '.(isset($this->fk_pays)?$this->fk_pays:
"null").
',';
259 $sql .=
' module = '.(isset($this->module)?
"'".$this->db->escape($this->module).
"'":
"null").
',';
260 $sql .=
' accountancy_code = '.(isset($this->accountancy_code)?
"'".$this->db->escape($this->accountancy_code).
"'":
"null");
261 $sql .=
' WHERE id=' . $this->id;
265 $resql = $this->db->query($sql);
268 $this->errors[] =
'Error ' . $this->db->lasterror();
269 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
284 $this->db->rollback();
302 public function delete(
User $user, $notrigger =
false)
323 $sql =
'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
324 $sql .=
' WHERE id=' . $this->id;
326 $resql = $this->db->query($sql);
329 $this->errors[] =
'Error ' . $this->db->lasterror();
330 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
336 $this->db->rollback();
364 $object->fetch($fromid);
372 $this->context[
'createfromclone'] =
'createfromclone';
373 $result = $object->create($user);
378 $this->errors = $object->errors;
379 dol_syslog(__METHOD__ .
' ' . join(
',', $this->errors), LOG_ERR);
382 unset($this->context[
'createfromclone']);
390 $this->db->rollback();
407 function getNomUrl($withpicto=0, $option=
'', $notooltip=0, $maxlen=24, $morecss=
'')
409 global $langs, $conf, $db;
410 global $dolibarr_main_authentication, $dolibarr_main_demo;
417 $label =
'<u>' . $langs->trans(
"MyModule") .
'</u>';
418 $label.=
'<div width="100%">';
419 $label.=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
421 $link =
'<a href="'.DOL_URL_ROOT.
'/tax/card.php?id='.$this->
id.
'"';
422 $link.= ($notooltip?
'':
' title="'.dol_escape_htmltag($label, 1).
'" class="classfortooltip'.($morecss?
' '.$morecss:
'').
'"');
428 $result.=($link.img_object(($notooltip?
'':$label),
'label', ($notooltip?
'':
'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
429 if ($withpicto != 2) $result.=
' ';
431 $result.= $link . $this->ref . $linkend;
443 return $this->
LibStatut($this->status,$mode);
461 if ($status == 1)
return $langs->trans(
'Enabled');
462 elseif ($status == 0)
return $langs->trans(
'Disabled');
466 if ($status == 1)
return $langs->trans(
'Enabled');
467 elseif ($status == 0)
return $langs->trans(
'Disabled');
471 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4').
' '.$langs->trans(
'Enabled');
472 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5').
' '.$langs->trans(
'Disabled');
476 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4');
477 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5');
481 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4').
' '.$langs->trans(
'Enabled');
482 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5').
' '.$langs->trans(
'Disabled');
486 if ($status == 1)
return $langs->trans(
'Enabled').
' '.
img_picto($langs->trans(
'Enabled'),
'statut4');
487 elseif ($status == 0)
return $langs->trans(
'Disabled').
' '.
img_picto($langs->trans(
'Disabled'),
'statut5');
503 $this->deductible =
'';
508 $this->accountancy_code =
'';
519 if (!is_array($parameters))
return;
520 foreach ($parameters as $parameter) {
521 if (isset($this->$parameter)) {
522 $this->$parameter = trim($this->$parameter);
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Retourne le libelle du status d'un user (actif, inactif)
trimParameters($parameters)
Trim object parameters.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
createFromClone($fromid)
Load an object from its id and create a new one in database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
update(User $user, $notrigger=false)
Update object into database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
create(User $user, $notrigger=false)
Create object into database.
LibStatut($status, $mode=0)
Renvoi le libelle d'un status donne.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
fetch($id, $ref=null)
Load object in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
Return a link to the user card (with optionaly the picto) Use this->id,this->lastname, this->firstname.