28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $element =
'emailcollectoraction';
43 public $table_element =
'emailcollector_emailcollectoraction';
48 public $picto =
'emailcollectoraction@emailcollector';
74 public $fields = array(
75 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
76 'fk_emailcollector' => array(
'type' =>
'integer',
'label' =>
'Id of emailcollector',
'foreignkey' =>
'emailcollector.rowid'),
77 'type' => array(
'type' =>
'varchar(128)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1),
78 'actionparam' => array(
'type' =>
'text',
'label' =>
'ParamForAction',
'enabled' => 1,
'visible' => 1,
'position' => 40,
'notnull' => -1),
79 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 500,
'notnull' => 1,),
80 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'position' => 501,
'notnull' => 1,),
81 'fk_user_creat' => array(
'type' =>
'integer',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -2,
'position' => 510,
'notnull' => 1,
'foreignkey' =>
'llx_user.rowid',),
82 'fk_user_modif' => array(
'type' =>
'integer',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -2,
'position' => 511,
'notnull' => -1,),
83 'position' => array(
'type' =>
'integer',
'label' =>
'Position',
'enabled' => 1,
'visible' => 1,
'position' => 600,
'default' =>
'0',),
84 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
85 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'position' => 1000,
'notnull' => 1,
'default' => 1,
'arrayofkeyval' => array(
'0' =>
'Disabled',
'1' =>
'Enabled')),
94 public $fk_emailcollector;
107 public $fk_user_creat;
111 public $fk_user_modif;
133 global
$conf, $langs;
137 $this->ismultientitymanaged = 0;
138 $this->isextrafieldmanaged = 0;
141 $this->fields[
'rowid'][
'visible'] = 0;
143 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
144 $this->fields[
'entity'][
'enabled'] = 0;
148 foreach ($this->fields as $key => $val) {
149 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
150 unset($this->fields[$key]);
155 foreach ($this->fields as $key => $val) {
156 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
157 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
158 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
174 if (empty($this->
type)) {
175 $langs->load(
"errors");
176 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
192 global $langs, $hookmanager, $extrafields;
209 $object->ref =
"copy_of_".$object->ref;
213 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
214 $extrafields->fetch_name_optionals_label($this->table_element);
215 foreach (
$object->array_options as $key => $option) {
216 $shortkey = preg_replace(
'/options_/',
'', $key);
217 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
218 unset(
$object->array_options[$key]);
224 $object->context[
'createfromclone'] =
'createfromclone';
225 $result =
$object->createCommon($user);
229 $this->errors =
$object->errors;
232 unset(
$object->context[
'createfromclone']);
239 $this->db->rollback();
251 public function fetch($id, $ref =
null)
277 public function delete(
User $user, $notrigger = 0)
292 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
294 global $db,
$conf, $langs, $hookmanager;
295 global $dolibarr_main_authentication, $dolibarr_main_demo;
298 if (!empty(
$conf->dol_no_mouse_hover)) {
304 $label =
'<u>'.$langs->trans(
"EmailcollectorAction").
'</u>';
306 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
308 $url =
dol_buildpath(
'/emailcollector/emailcollectoraction_card.php', 1).
'?id='.$this->id;
310 if ($option !=
'nolink') {
312 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
313 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
314 $add_save_lastsearch_values = 1;
316 if ($add_save_lastsearch_values) {
317 $url .=
'&save_lastsearch_values=1';
322 if (empty($notooltip)) {
324 $label = $langs->trans(
"ShowEmailcollectorAction");
325 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
327 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
328 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
337 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
340 $linkstart =
'<a href="'.$url.
'"';
341 $linkstart .= $linkclose.
'>';
344 $result .= $linkstart;
346 $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);
348 if ($withpicto != 2) {
349 $result .= $this->ref;
354 global $action, $hookmanager;
355 $hookmanager->initHooks(array(
'emailcollectoractiondao'));
356 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
357 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
359 $result = $hookmanager->resPrint;
361 $result .= $hookmanager->resPrint;
389 if (empty($this->labelStatus)) {
392 $this->labelStatus[1] = $langs->trans(
'Enabled');
393 $this->labelStatus[0] = $langs->trans(
'Disabled');
397 return $this->labelStatus[$status];
398 } elseif ($mode == 1) {
399 return $this->labelStatus[$status];
400 } elseif ($mode == 2) {
402 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
403 } elseif ($status == 0) {
404 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
406 } elseif ($mode == 3) {
408 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
409 } elseif ($status == 0) {
410 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
412 } elseif ($mode == 4) {
414 return img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
415 } elseif ($status == 0) {
416 return img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
418 } elseif ($mode == 5) {
420 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
421 } elseif ($status == 0) {
422 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
424 } elseif ($mode == 6) {
426 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'', 0, 0, 0,
'',
'valignmiddle');
427 } elseif ($status == 0) {
428 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'', 0, 0, 0,
'',
'valignmiddle');
442 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
443 $sql .=
' fk_user_creat, fk_user_modif';
444 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
445 $sql .=
' WHERE t.rowid = '.((int) $id);
446 $result = $this->db->query($sql);
448 if ($this->db->num_rows($result)) {
449 $obj = $this->db->fetch_object($result);
451 $this->
id = $obj->rowid;
453 $this->user_creation_id = $obj->fk_user_creat;
454 $this->user_modification_id = $obj->fk_user_modif;
455 $this->date_creation = $this->db->jdate($obj->datec);
456 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
459 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type