26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 public $element =
'emailcollectoraction';
41 public $table_element =
'emailcollector_emailcollectoraction';
46 public $ismultientitymanaged = 0;
51 public $isextrafieldmanaged = 0;
56 public $picto =
'emailcollectoraction@emailcollector';
82 public $fields = array(
83 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
84 'fk_emailcollector' => array(
'type'=>
'integer',
'label'=>
'Id of emailcollector',
'foreignkey'=>
'emailcollector.rowid'),
85 'type' => array(
'type'=>
'varchar(128)',
'label'=>
'Type',
'enabled'=>1,
'visible'=>1,
'position'=>10,
'notnull'=>1,
'index'=>1),
86 'actionparam' => array(
'type'=>
'text',
'label'=>
'ParamForAction',
'enabled'=>1,
'visible'=>1,
'position'=>40,
'notnull'=>-1),
87 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>500,
'notnull'=>1,),
88 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'position'=>501,
'notnull'=>1,),
89 'fk_user_creat' => array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>-2,
'position'=>510,
'notnull'=>1,
'foreignkey'=>
'llx_user.rowid',),
90 'fk_user_modif' => array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'position'=>511,
'notnull'=>-1,),
91 'position' => array(
'type'=>
'integer',
'label'=>
'Position',
'enabled'=>1,
'visible'=>1,
'position'=>600,
'default'=>
'0',),
92 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
93 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'position'=>1000,
'notnull'=>1,
'default'=>1,
'arrayofkeyval'=>array(
'0'=>
'Disabled',
'1'=>
'Enabled')),
96 public $fk_emailcollector;
103 public $date_creation;
107 public $fk_user_creat;
108 public $fk_user_modif;
121 global $conf, $langs;
125 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
126 $this->fields[
'rowid'][
'visible'] = 0;
128 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
129 $this->fields[
'entity'][
'enabled'] = 0;
133 foreach ($this->fields as $key => $val) {
134 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
135 unset($this->fields[$key]);
140 foreach ($this->fields as $key => $val) {
141 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
142 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
143 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
159 if (empty($this->
type)) {
160 $langs->load(
"errors");
161 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
177 global $langs, $hookmanager, $extrafields;
182 $object =
new self($this->db);
187 $object->fetchCommon($fromid);
190 unset($object->fk_user_creat);
191 unset($object->import_key);
194 $object->ref =
"copy_of_".$object->ref;
198 if (is_array($object->array_options) && count($object->array_options) > 0) {
199 $extrafields->fetch_name_optionals_label($this->table_element);
200 foreach ($object->array_options as $key => $option) {
201 $shortkey = preg_replace(
'/options_/',
'', $key);
202 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
203 unset($object->array_options[$key]);
209 $object->context[
'createfromclone'] =
'createfromclone';
210 $result = $object->createCommon($user);
213 $this->error = $object->error;
214 $this->errors = $object->errors;
217 unset($object->context[
'createfromclone']);
224 $this->db->rollback();
236 public function fetch($id, $ref =
null)
262 public function delete(
User $user, $notrigger =
false)
277 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
279 global $db, $conf, $langs, $hookmanager;
280 global $dolibarr_main_authentication, $dolibarr_main_demo;
283 if (!empty($conf->dol_no_mouse_hover)) {
289 $label =
'<u>'.$langs->trans(
"EmailcollectorAction").
'</u>';
291 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
293 $url =
dol_buildpath(
'/emailcollector/emailcollectoraction_card.php', 1).
'?id='.$this->id;
295 if ($option !=
'nolink') {
297 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
298 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
299 $add_save_lastsearch_values = 1;
301 if ($add_save_lastsearch_values) {
302 $url .=
'&save_lastsearch_values=1';
307 if (empty($notooltip)) {
308 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
309 $label = $langs->trans(
"ShowEmailcollectorAction");
310 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
312 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
313 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
322 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
325 $linkstart =
'<a href="'.$url.
'"';
326 $linkstart .= $linkclose.
'>';
329 $result .= $linkstart;
331 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
333 if ($withpicto != 2) {
334 $result .= $this->ref;
339 global $action, $hookmanager;
340 $hookmanager->initHooks(array(
'emailcollectoractiondao'));
341 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
342 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
344 $result = $hookmanager->resPrint;
346 $result .= $hookmanager->resPrint;
360 return $this->
LibStatut($this->status, $mode);
374 if (empty($this->labelStatus)) {
377 $this->labelStatus[1] = $langs->trans(
'Enabled');
378 $this->labelStatus[0] = $langs->trans(
'Disabled');
382 return $this->labelStatus[$status];
383 } elseif ($mode == 1) {
384 return $this->labelStatus[$status];
385 } elseif ($mode == 2) {
387 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
388 } elseif ($status == 0) {
389 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
391 } elseif ($mode == 3) {
393 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
394 } elseif ($status == 0) {
395 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
397 } elseif ($mode == 4) {
399 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
400 } elseif ($status == 0) {
401 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
403 } elseif ($mode == 5) {
405 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
406 } elseif ($status == 0) {
407 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
409 } elseif ($mode == 6) {
411 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
412 } elseif ($status == 0) {
413 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
427 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
428 $sql .=
' fk_user_creat, fk_user_modif';
429 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
430 $sql .=
' WHERE t.rowid = '.((int) $id);
431 $result = $this->db->query($sql);
433 if ($this->db->num_rows($result)) {
434 $obj = $this->db->fetch_object($result);
435 $this->
id = $obj->rowid;
437 $this->user_creation_id = $obj->fk_user_creat;
438 $this->user_modification_id = $obj->fk_user_modif;
439 $this->date_creation = $this->db->jdate($obj->datec);
440 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
443 $this->db->free($result);
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
updateCommon(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr database access.
Class for EmailCollectorAction.
fetch($id, $ref=null)
Load object in memory from the database.
update(User $user, $notrigger=false)
Update object into database.
LibStatut($status, $mode=0)
Return the status.
create(User $user, $notrigger=false)
Create object into database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
__construct(DoliDB $db)
Constructor.
createFromClone(User $user, $fromid)
Clone and object into another one.
info($id)
Charge les informations d'ordre info dans l'objet commande.
getLibStatut($mode=0)
Return label of the status.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type