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'=>
'text',
'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'])) {
159 $this->fields[
'rowid'][
'visible'] = 0;
161 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
162 $this->fields[
'entity'][
'enabled'] = 0;
166 foreach ($this->fields as $key => $val) {
167 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
168 unset($this->fields[$key]);
173 foreach ($this->fields as $key => $val) {
174 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
175 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
176 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
192 if (empty($this->
type)) {
193 $langs->load(
"errors");
194 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
210 global $langs, $hookmanager, $extrafields;
215 $object =
new self($this->db);
220 $object->fetchCommon($fromid);
223 unset($object->fk_user_creat);
224 unset($object->import_key);
227 $object->ref =
"copy_of_".$object->ref;
228 $object->title = $langs->trans(
"CopyOf").
" ".$object->title;
231 if (is_array($object->array_options) && count($object->array_options) > 0) {
232 $extrafields->fetch_name_optionals_label($this->table_element);
233 foreach ($object->array_options as $key => $option) {
234 $shortkey = preg_replace(
'/options_/',
'', $key);
235 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
238 unset($object->array_options[$key]);
244 $object->context[
'createfromclone'] =
'createfromclone';
245 $result = $object->createCommon($user);
248 $this->error = $object->error;
249 $this->errors = $object->errors;
252 unset($object->context[
'createfromclone']);
259 $this->
db->rollback();
271 public function fetch($id, $ref =
null)
313 public function delete(
User $user, $notrigger =
false)
328 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
330 global $db, $conf, $langs, $hookmanager;
331 global $dolibarr_main_authentication, $dolibarr_main_demo;
334 if (!empty($conf->dol_no_mouse_hover)) {
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') {
349 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
350 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
351 $add_save_lastsearch_values = 1;
353 if ($add_save_lastsearch_values) {
354 $url .=
'&save_lastsearch_values=1';
359 if (empty($notooltip)) {
360 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
361 $label = $langs->trans(
"ShowEmailcollectorAction");
362 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
364 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
365 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
374 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
377 $linkstart =
'<a href="'.$url.
'"';
378 $linkstart .= $linkclose.
'>';
381 $result .= $linkstart;
383 $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);
385 if ($withpicto != 2) {
386 $result .= $this->ref;
391 global $action, $hookmanager;
392 $hookmanager->initHooks(array(
'emailcollectoractiondao'));
393 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
394 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
396 $result = $hookmanager->resPrint;
398 $result .= $hookmanager->resPrint;
412 return $this->
LibStatut($this->status, $mode);
426 if (empty($this->labelStatus)) {
429 $this->labelStatus[1] = $langs->trans(
'Enabled');
430 $this->labelStatus[0] = $langs->trans(
'Disabled');
434 return $this->labelStatus[$status];
435 } elseif ($mode == 1) {
436 return $this->labelStatus[$status];
437 } elseif ($mode == 2) {
439 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
440 } elseif ($status == 0) {
441 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
443 } elseif ($mode == 3) {
445 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
446 } elseif ($status == 0) {
447 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
449 } elseif ($mode == 4) {
451 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
452 } elseif ($status == 0) {
453 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
455 } elseif ($mode == 5) {
457 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
458 } elseif ($status == 0) {
459 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
461 } elseif ($mode == 6) {
463 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
464 } elseif ($status == 0) {
465 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
478 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
479 $sql .=
' fk_user_creat, fk_user_modif';
480 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
481 $sql .=
' WHERE t.rowid = '.((int) $id);
482 $result = $this->
db->query($sql);
484 if ($this->
db->num_rows($result)) {
485 $obj = $this->
db->fetch_object($result);
486 $this->
id = $obj->rowid;
488 $this->user_creation_id = $obj->fk_user_creat;
489 $this->user_modification_id = $obj->fk_user_modif;
490 $this->date_creation = $this->
db->jdate($obj->datec);
491 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
494 $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)
Load object lines in memory from the 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.
isModEnabled($module)
Is Dolibarr module enabled.
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
$conf db
API class for accounts.