29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $element =
'emailcollectoraction';
44 public $table_element =
'emailcollector_emailcollectoraction';
49 public $picto =
'emailcollectoraction@emailcollector';
75 public $fields = array(
76 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
77 'fk_emailcollector' => array(
'type' =>
'integer',
'label' =>
'Id of emailcollector',
'enabled' => 1,
'visible' => 0,
'foreignkey' =>
'emailcollector.rowid',
'position' => 0,),
78 'type' => array(
'type' =>
'varchar(128)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1),
79 'actionparam' => array(
'type' =>
'text',
'label' =>
'ParamForAction',
'enabled' => 1,
'visible' => 1,
'position' => 40,
'notnull' => -1),
80 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 500,
'notnull' => 1,),
81 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'position' => 501,
'notnull' => 1,),
82 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -2,
'position' => 510,
'notnull' => 1,
'foreignkey' =>
'llx_user.rowid',),
83 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -2,
'position' => 511,
'notnull' => -1,),
84 'position' => array(
'type' =>
'integer',
'label' =>
'Position',
'enabled' => 1,
'visible' => 1,
'position' => 600,
'default' =>
'0',),
85 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
86 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'position' => 1000,
'notnull' => 1,
'default' =>
'1',
'arrayofkeyval' => array(0 =>
'Disabled', 1 =>
'Enabled')),
95 public $fk_emailcollector;
108 public $fk_user_creat;
112 public $fk_user_modif;
134 global
$conf, $langs;
138 $this->ismultientitymanaged = 0;
139 $this->isextrafieldmanaged = 0;
142 $this->fields[
'rowid'][
'visible'] = 0;
144 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
145 $this->fields[
'entity'][
'enabled'] = 0;
149 foreach ($this->fields as $key => $val) {
150 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
151 unset($this->fields[$key]);
156 if (is_object($langs)) {
157 foreach ($this->fields as $key => $val) {
158 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
159 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
160 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
177 if (empty($this->
type)) {
178 $langs->load(
"errors");
179 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
195 global $langs, $hookmanager, $extrafields;
212 $object->ref =
"copy_of_".$object->ref;
216 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
217 $extrafields->fetch_name_optionals_label($this->table_element);
218 foreach (
$object->array_options as $key => $option) {
219 $shortkey = preg_replace(
'/options_/',
'', $key);
220 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
221 unset(
$object->array_options[$key]);
227 $object->context[
'createfromclone'] =
'createfromclone';
228 $result =
$object->createCommon($user);
232 $this->errors =
$object->errors;
235 unset(
$object->context[
'createfromclone']);
242 $this->db->rollback();
254 public function fetch($id, $ref =
null)
280 public function delete(
User $user, $notrigger = 0)
295 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
297 global $db,
$conf, $langs, $hookmanager;
298 global $dolibarr_main_authentication, $dolibarr_main_demo;
301 if (!empty(
$conf->dol_no_mouse_hover)) {
307 $label =
'<u>'.$langs->trans(
"EmailcollectorAction").
'</u>';
309 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
311 $url =
dol_buildpath(
'/emailcollector/emailcollectoraction_card.php', 1).
'?id='.$this->id;
313 if ($option !=
'nolink') {
315 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
316 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
317 $add_save_lastsearch_values = 1;
319 if ($add_save_lastsearch_values) {
320 $url .=
'&save_lastsearch_values=1';
325 if (empty($notooltip)) {
327 $label = $langs->trans(
"ShowEmailcollectorAction");
328 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
330 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
331 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
340 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
343 $linkstart =
'<a href="'.$url.
'"';
344 $linkstart .= $linkclose.
'>';
347 $result .= $linkstart;
349 $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);
351 if ($withpicto != 2) {
352 $result .= $this->ref;
357 global $action, $hookmanager;
358 $hookmanager->initHooks(array(
'emailcollectoractiondao'));
359 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
360 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
362 $result = $hookmanager->resPrint;
364 $result .= $hookmanager->resPrint;
392 if (empty($this->labelStatus)) {
395 $this->labelStatus[1] = $langs->trans(
'Enabled');
396 $this->labelStatus[0] = $langs->trans(
'Disabled');
400 return $this->labelStatus[$status];
401 } elseif ($mode == 1) {
402 return $this->labelStatus[$status];
403 } elseif ($mode == 2) {
405 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
406 } elseif ($status == 0) {
407 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
409 } elseif ($mode == 3) {
411 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
412 } elseif ($status == 0) {
413 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
415 } elseif ($mode == 4) {
417 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
418 } elseif ($status == 0) {
419 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
421 } elseif ($mode == 5) {
423 return $this->labelStatus[$status].
' '.img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
424 } elseif ($status == 0) {
425 return $this->labelStatus[$status].
' '.img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
427 } elseif ($mode == 6) {
429 return $this->labelStatus[$status].
' '.img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
430 } elseif ($status == 0) {
431 return $this->labelStatus[$status].
' '.img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
445 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
446 $sql .=
' fk_user_creat, fk_user_modif';
447 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
448 $sql .=
' WHERE t.rowid = '.((int) $id);
449 $result = $this->db->query($sql);
451 if ($this->db->num_rows($result)) {
452 $obj = $this->db->fetch_object($result);
454 $this->
id = $obj->rowid;
456 $this->user_creation_id = $obj->fk_user_creat;
457 $this->user_modification_id = $obj->fk_user_modif;
458 $this->date_creation = $this->db->jdate($obj->datec);
459 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
462 $this->db->free($result);
464 dol_print_error($this->db);
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class for EmailCollectorAction.
fetch($id, $ref=null)
Load object in memory from the database.
create(User $user, $notrigger=0)
Create object into database.
LibStatut($status, $mode=0)
Return the status.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
__construct(DoliDB $db)
Constructor.
createFromClone(User $user, $fromid)
Clone and object into another one.
info($id)
Charge les information 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.
update(User $user, $notrigger=0)
Update object into database.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.