26 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $element =
'emailcollectoraction';
43 public $table_element =
'emailcollector_emailcollectoraction';
48 public $ismultientitymanaged = 0;
53 public $isextrafieldmanaged = 0;
58 public $picto =
'emailcollectoraction@emailcollector';
84 public $fields = array(
85 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
86 'fk_emailcollector' => array(
'type'=>
'integer',
'label'=>
'Id of emailcollector',
'foreignkey'=>
'emailcollector.rowid'),
87 'type' => array(
'type'=>
'varchar(128)',
'label'=>
'Type',
'enabled'=>1,
'visible'=>1,
'position'=>10,
'notnull'=>1,
'index'=>1),
88 'actionparam' => array(
'type'=>
'varchar(255)',
'label'=>
'ParamForAction',
'enabled'=>1,
'visible'=>1,
'position'=>40,
'notnull'=>-1),
89 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>500,
'notnull'=>1,),
90 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'position'=>501,
'notnull'=>1,),
91 'fk_user_creat' => array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>-2,
'position'=>510,
'notnull'=>1,
'foreignkey'=>
'llx_user.rowid',),
92 'fk_user_modif' => array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'position'=>511,
'notnull'=>-1,),
93 'position' => array(
'type'=>
'integer',
'label'=>
'Position',
'enabled'=>1,
'visible'=>1,
'position'=>600,
'default'=>
'0',),
94 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
95 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'position'=>1000,
'notnull'=>1,
'default'=>1,
'arrayofkeyval'=>array(
'0'=>
'Disabled',
'1'=>
'Enabled')),
98 public $fk_emailcollector;
105 public $date_creation;
109 public $fk_user_creat;
110 public $fk_user_modif;
154 global $conf, $langs;
158 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->
fields[
'rowid'])) $this->
fields[
'rowid'][
'visible'] = 0;
159 if (empty($conf->multicompany->enabled) && isset($this->
fields[
'entity'])) $this->
fields[
'entity'][
'enabled'] = 0;
162 foreach ($this->
fields as $key => $val)
164 if (isset($val[
'enabled']) && empty($val[
'enabled']))
166 unset($this->
fields[$key]);
171 foreach ($this->
fields as $key => $val)
173 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval']))
175 foreach ($val[
'arrayofkeyval'] as $key2 => $val2)
177 $this->
fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
193 if (empty($this->
type))
195 $langs->load(
"errors");
196 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
212 global $langs, $hookmanager, $extrafields;
217 $object =
new self($this->db);
222 $object->fetchCommon($fromid);
225 unset($object->fk_user_creat);
226 unset($object->import_key);
229 $object->ref =
"copy_of_".$object->ref;
230 $object->title = $langs->trans(
"CopyOf").
" ".$object->title;
233 if (is_array($object->array_options) && count($object->array_options) > 0)
235 $extrafields->fetch_name_optionals_label($this->table_element);
236 foreach ($object->array_options as $key => $option)
238 $shortkey = preg_replace(
'/options_/',
'', $key);
239 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey]))
242 unset($object->array_options[$key]);
248 $object->context[
'createfromclone'] =
'createfromclone';
249 $result = $object->createCommon($user);
252 $this->error = $object->error;
253 $this->errors = $object->errors;
256 unset($object->context[
'createfromclone']);
263 $this->
db->rollback();
275 public function fetch($id, $ref = null)
278 if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
315 public function delete(
User $user, $notrigger =
false)
330 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
332 global $db, $conf, $langs, $hookmanager;
333 global $dolibarr_main_authentication, $dolibarr_main_demo;
336 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
341 $label =
'<u>'.$langs->trans(
"EmailcollectorAction").
'</u>';
343 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
345 $url =
dol_buildpath(
'/emailcollector/emailcollectoraction_card.php', 1).
'?id='.$this->id;
347 if ($option !=
'nolink')
350 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
351 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
352 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
356 if (empty($notooltip))
358 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
360 $label = $langs->trans(
"ShowEmailcollectorAction");
361 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
363 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
364 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
372 }
else $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
374 $linkstart =
'<a href="'.$url.
'"';
375 $linkstart .= $linkclose.
'>';
378 $result .= $linkstart;
379 if ($withpicto) $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);
380 if ($withpicto != 2) $result .= $this->ref;
384 global $action, $hookmanager;
385 $hookmanager->initHooks(array(
'emailcollectoractiondao'));
386 $parameters = array(
'id'=>$this->
id,
'getnomurl'=>$result);
387 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
388 if ($reshook > 0) $result = $hookmanager->resPrint;
389 else $result .= $hookmanager->resPrint;
402 return $this->
LibStatut($this->status, $mode);
416 if (empty($this->labelStatus))
420 $this->labelStatus[1] = $langs->trans(
'Enabled');
421 $this->labelStatus[0] = $langs->trans(
'Disabled');
426 return $this->labelStatus[$status];
427 } elseif ($mode == 1)
429 return $this->labelStatus[$status];
430 } elseif ($mode == 2)
432 if ($status == 1)
return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
433 elseif ($status == 0)
return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
434 } elseif ($mode == 3)
436 if ($status == 1)
return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
437 elseif ($status == 0)
return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
438 } elseif ($mode == 4)
440 if ($status == 1)
return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
441 elseif ($status == 0)
return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
442 } elseif ($mode == 5)
444 if ($status == 1)
return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
445 elseif ($status == 0)
return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
446 } elseif ($mode == 6)
448 if ($status == 1)
return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
449 elseif ($status == 0)
return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
461 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
462 $sql .=
' fk_user_creat, fk_user_modif';
463 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
464 $sql .=
' WHERE t.rowid = '.$id;
465 $result = $this->
db->query($sql);
468 if ($this->
db->num_rows($result))
470 $obj = $this->
db->fetch_object($result);
471 $this->
id = $obj->rowid;
472 if ($obj->fk_user_author)
474 $cuser =
new User($this->
db);
475 $cuser->fetch($obj->fk_user_author);
476 $this->user_creation = $cuser;
479 if ($obj->fk_user_valid)
481 $vuser =
new User($this->
db);
482 $vuser->fetch($obj->fk_user_valid);
483 $this->user_validation = $vuser;
486 if ($obj->fk_user_cloture)
488 $cluser =
new User($this->
db);
489 $cluser->fetch($obj->fk_user_cloture);
490 $this->user_cloture = $cluser;
493 $this->date_creation = $this->
db->jdate($obj->datec);
494 $this->date_modification = $this->
db->jdate($obj->datem);
495 $this->date_validation = $this->
db->jdate($obj->datev);
498 $this->
db->free($result);
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getNomUrl($withpicto=0, $option= '', $notooltip=0, $morecss= '', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
update(User $user, $notrigger=false)
Load object lines 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
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
Class for EmailCollectorAction.
LibStatut($status, $mode=0)
Return the status.
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.
createFromClone(User $user, $fromid)
Clone and object into another one.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return label of the status.
$conf db
API class for accounts.
fetch($id, $ref=null)
Load object in memory from the database.
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.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
updateCommon(User $user, $notrigger=false)
Update object into database.
print $_SERVER["PHP_SELF"]
Edit parameters.
info($id)
Charge les informations d'ordre info dans l'objet commande.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
create(User $user, $notrigger=false)
Create object into database.
fetchCommon($id, $ref=null, $morewhere= '')
Load object in memory from the database.