40 public $element =
'cchargesociales';
45 public $table_element =
'c_chargesociales';
65 public $accountancy_code;
109 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.
'(';
112 $sql .=
'deductible,';
117 $sql .=
'accountancy_code';
120 $sql .=
') VALUES (';
122 $sql .=
' '.(!isset($this->libelle) ?
'NULL' :
"'".$this->db->escape($this->libelle).
"'").
',';
123 $sql .=
' '.(!isset($this->deductible) ?
'NULL' : $this->deductible).
',';
124 $sql .=
' '.(!isset($this->active) ?
'NULL' : $this->active).
',';
125 $sql .=
' '.(!isset($this->
code) ?
'NULL' :
"'".$this->db->escape($this->
code).
"'").
',';
126 $sql .=
' '.(!isset($this->fk_pays) ?
'NULL' : $this->fk_pays).
',';
127 $sql .=
' '.(!isset($this->module) ?
'NULL' :
"'".$this->db->escape($this->module).
"'").
',';
128 $sql .=
' '.(!isset($this->accountancy_code) ?
'NULL' :
"'".$this->db->escape($this->accountancy_code).
"'");
138 $this->errors[] =
'Error '.$this->db->lasterror();
139 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
143 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
158 $this->
db->rollback();
176 public function fetch($id, $ref = null)
182 $sql .=
" t.libelle,";
183 $sql .=
" t.deductible,";
184 $sql .=
" t.active,";
186 $sql .=
" t.fk_pays,";
187 $sql .=
" t.module,";
188 $sql .=
" t.accountancy_code";
189 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
191 $sql .=
" WHERE t.code = '".$this->db->escape($ref).
"'";
193 $sql .=
' WHERE t.id = '.$id;
198 $numrows = $this->
db->num_rows(
$resql);
200 $obj = $this->
db->fetch_object(
$resql);
202 $this->
id = $obj->id;
204 $this->libelle = $obj->libelle;
205 $this->deductible = $obj->deductible;
206 $this->active = $obj->active;
207 $this->
code = $obj->code;
208 $this->fk_pays = $obj->fk_pays;
209 $this->module = $obj->module;
210 $this->accountancy_code = $obj->accountancy_code;
220 $this->errors[] =
'Error '.$this->db->lasterror();
221 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
260 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET';
261 $sql .=
' libelle = '.(isset($this->libelle) ?
"'".$this->db->escape($this->libelle).
"'" :
"null").
',';
262 $sql .=
' deductible = '.(isset($this->deductible) ? $this->deductible :
"null").
',';
263 $sql .=
' active = '.(isset($this->active) ? $this->active :
"null").
',';
264 $sql .=
' code = '.(isset($this->
code) ?
"'".$this->db->escape($this->
code).
"'" :
"null").
',';
265 $sql .=
' fk_pays = '.(isset($this->fk_pays) ? $this->fk_pays :
"null").
',';
266 $sql .=
' module = '.(isset($this->module) ?
"'".$this->db->escape($this->module).
"'" :
"null").
',';
267 $sql .=
' accountancy_code = '.(isset($this->accountancy_code) ?
"'".$this->db->escape($this->accountancy_code).
"'" :
"null");
268 $sql .=
' WHERE id='.$this->id;
275 $this->errors[] =
'Error '.$this->db->lasterror();
276 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
291 $this->
db->rollback();
309 public function delete(
User $user, $notrigger =
false)
330 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
331 $sql .=
' WHERE id='.$this->id;
336 $this->errors[] =
'Error '.$this->db->lasterror();
337 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
343 $this->
db->rollback();
370 $object->fetch($fromid);
378 $this->context[
'createfromclone'] =
'createfromclone';
379 $result = $object->create($user);
384 $this->errors = $object->errors;
385 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
388 unset($this->context[
'createfromclone']);
396 $this->
db->rollback();
413 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
415 global $langs, $conf, $db;
416 global $dolibarr_main_authentication, $dolibarr_main_demo;
423 $label =
'<u>'.$langs->trans(
"MyModule").
'</u>';
424 $label .=
'<div width="100%">';
425 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
427 $link =
'<a href="'.DOL_URL_ROOT.
'/tax/card.php?id='.$this->
id.
'"';
428 $link .= ($notooltip ?
'' :
' title="'.dol_escape_htmltag($label, 1).
'" class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"');
434 $result .= ($link.img_object(($notooltip ?
'' : $label),
'label', ($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
435 if ($withpicto != 2) $result .=
' ';
437 $result .= $link.$this->ref.$linkend;
449 return $this->
LibStatut($this->status, $mode);
467 if ($status == 1)
return $langs->trans(
'Enabled');
468 elseif ($status == 0)
return $langs->trans(
'Disabled');
469 } elseif ($mode == 1)
471 if ($status == 1)
return $langs->trans(
'Enabled');
472 elseif ($status == 0)
return $langs->trans(
'Disabled');
473 } elseif ($mode == 2)
475 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4').
' '.$langs->trans(
'Enabled');
476 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5').
' '.$langs->trans(
'Disabled');
477 } elseif ($mode == 3)
479 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4');
480 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5');
481 } elseif ($mode == 4)
483 if ($status == 1)
return img_picto($langs->trans(
'Enabled'),
'statut4').
' '.$langs->trans(
'Enabled');
484 elseif ($status == 0)
return img_picto($langs->trans(
'Disabled'),
'statut5').
' '.$langs->trans(
'Disabled');
485 } elseif ($mode == 5)
487 if ($status == 1)
return $langs->trans(
'Enabled').
' '.
img_picto($langs->trans(
'Enabled'),
'statut4');
488 elseif ($status == 0)
return $langs->trans(
'Disabled').
' '.
img_picto($langs->trans(
'Disabled'),
'statut5');
504 $this->deductible =
'';
509 $this->accountancy_code =
'';
520 foreach ($parameters as $parameter) {
521 if (isset($this->$parameter)) {
522 $this->$parameter = trim($this->$parameter);
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Retourne le libelle du status d'un user (actif, inactif)
trimParameters($parameters)
Trim object parameters.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
$conf db
API class for accounts.
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.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $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.
create(User $user, $notrigger=false)
Create object into 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.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
LibStatut($status, $mode=0)
Renvoi le libelle d'un status donne.
fetch($id, $ref=null)
Load object in memory from the database.