29 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $element =
'emailsenderprofile';
47 public $table_element =
'c_email_senderprofile';
52 public $ismultientitymanaged = 1;
57 public $picto =
'emailsenderprofile@monmodule';
60 const STATUS_DISABLED = 0;
61 const STATUS_ENABLED = 1;
93 public $fields = array(
94 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'visible'=>-1,
'enabled'=>1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
'Id',),
95 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'visible'=>-1,
'enabled'=>1,
'position'=>20,
'notnull'=>1,
'index'=>1,),
96 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'visible'=>1,
'enabled'=>1,
'position'=>30,
'notnull'=>1),
97 'email' => array(
'type'=>
'varchar(255)',
'label'=>
'Email',
'visible'=>1,
'enabled'=>1,
'position'=>40,
'notnull'=>-1),
98 'private' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'User',
'visible'=>-1,
'enabled'=>1,
'position'=>50,
'default'=>
'0',
'notnull'=>1),
99 'signature' => array(
'type'=>
'text',
'label'=>
'Signature',
'visible'=>3,
'enabled'=>1,
'position'=>400,
'notnull'=>-1,
'index'=>1,),
100 'position' => array(
'type'=>
'integer',
'label'=>
'Position',
'visible'=>1,
'enabled'=>1,
'position'=>405,
'notnull'=>-1,
'index'=>1,),
101 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'visible'=>-1,
'enabled'=>1,
'position'=>500,
'notnull'=>1,),
102 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'visible'=>-1,
'enabled'=>1,
'position'=>500,
'notnull'=>1,),
103 'active' => array(
'type'=>
'integer',
'label'=>
'Status',
'visible'=>1,
'enabled'=>1,
'default'=>1,
'position'=>1000,
'notnull'=>1,
'index'=>1,
'arrayofkeyval'=>array(0=>
'Disabled', 1=>
'Enabled')),
126 public $date_creation;
147 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->
fields[
'rowid'][
'visible'] = 0;
148 if (empty($conf->multicompany->enabled)) $this->
fields[
'entity'][
'enabled'] = 0;
172 global $hookmanager, $langs;
177 $object =
new self($this->db);
182 $object->fetchCommon($fromid);
185 unset($object->fk_user_creat);
186 unset($object->import_key);
189 $object->ref =
"copy_of_".$object->ref;
190 $object->title = $langs->trans(
"CopyOf").
" ".$object->title;
194 $object->context[
'createfromclone'] =
'createfromclone';
195 $result = $object->createCommon($user);
198 $this->error = $object->error;
199 $this->errors = $object->errors;
202 unset($object->context[
'createfromclone']);
209 $this->
db->rollback();
221 public function fetch($id, $ref = null)
224 if ($result > 0 && !empty($this->table_element_line)) $this->
fetchLines();
235 $this->lines = array();
239 return count($this->lines) ? 1 : 0;
261 public function delete(
User $user, $notrigger =
false)
274 global $db, $conf, $langs;
275 global $dolibarr_main_authentication, $dolibarr_main_demo;
281 $label = $this->label;
290 $result .= ($linkstart.img_object($label,
'label',
'class="classfortooltip"').$linkend);
291 if ($withpicto != 2) $result .=
' ';
293 $result .= $linkstart.$this->label.$linkend;
305 return $this->
LibStatut($this->active, $mode);
321 $label = $labelshort = $langs->trans(
'Enabled');
323 $label = $labelshort = $langs->trans(
'Disabled');
326 $statusType =
'status'.$status;
327 if ($status == self::STATUS_ENABLED) $statusType =
'status4';
329 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
340 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
341 $sql .=
' fk_user_creat, fk_user_modif';
342 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
343 $sql .=
' WHERE t.rowid = '.$id;
344 $result = $this->
db->query($sql);
347 if ($this->
db->num_rows($result))
349 $obj = $this->
db->fetch_object($result);
350 $this->
id = $obj->rowid;
351 if ($obj->fk_user_author)
353 $cuser =
new User($this->
db);
354 $cuser->fetch($obj->fk_user_author);
355 $this->user_creation = $cuser;
358 if ($obj->fk_user_valid)
360 $vuser =
new User($this->
db);
361 $vuser->fetch($obj->fk_user_valid);
362 $this->user_validation = $vuser;
365 if ($obj->fk_user_cloture)
367 $cluser =
new User($this->
db);
368 $cluser->fetch($obj->fk_user_cloture);
369 $this->user_cloture = $cluser;
372 $this->date_creation = $this->
db->jdate($obj->datec);
373 $this->date_modification = $this->
db->jdate($obj->datem);
374 $this->date_validation = $this->
db->jdate($obj->datev);
377 $this->
db->free($result);
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
fetch($id, $ref=null)
Load object in memory from the database.
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
getNomUrl($withpicto=0)
Return a link to the object card (with optionaly the picto)
create(User $user, $notrigger=false)
Create object into database.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
createCommon(User $user, $notrigger=false)
Create object into database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
$conf db
API class for accounts.
fetchLines()
Load object lines in memory from the database.
__construct(DoliDB $db)
Constructor.
update(User $user, $notrigger=false)
Update object into database.
static LibStatut($status, $mode=0)
Return the status.
getLibStatut($mode=0)
Retourne le libelle du status d'un user (actif, inactif)
info($id)
Charge les informations d'ordre info dans l'objet commande.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
updateCommon(User $user, $notrigger=false)
Update object into database.
createFromClone(User $user, $fromid)
Clone and object into another one.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
Class for EmailSenderProfile.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
fetchCommon($id, $ref=null, $morewhere= '')
Load object in memory from the database.