25require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35 public $element =
'hook';
40 public $table_element =
'zapier_hook';
45 public $picto =
'hook@zapier';
48 const STATUS_DRAFT = 0;
49 const STATUS_VALIDATED = 1;
50 const STATUS_DISABLED = -1;
76 public $fields = array(
79 'label' =>
'TechnicalID',
100 'label' =>
'UserOwner',
105 'foreignkey' =>
'llx_user.rowid',
108 'type' =>
'varchar(255)',
114 'css' =>
'minwidth200',
118 'type' =>
'varchar(128)',
124 'css' =>
'minwidth200',
125 'help' =>
'Hook module'
128 'type' =>
'varchar(128)',
134 'css' =>
'minwidth200',
135 'help' =>
'Hook action trigger'
138 'type' =>
'varchar(255)',
144 'css' =>
'minwidth200',
146 'showoncombobox' => 1,
148 'date_creation' => array(
149 'type' =>
'datetime',
150 'label' =>
'DateCreation',
156 'import_key' => array(
157 'type' =>
'varchar(14)',
158 'label' =>
'ImportId',
174 'arrayofkeyval' => array(
220 public $fk_user_creat;
225 public $fk_user_modif;
240 global $conf, $langs, $user;
244 $this->ismultientitymanaged = 0;
245 $this->isextrafieldmanaged = 1;
248 $this->fields[
'rowid'][
'visible'] = 0;
250 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
251 $this->fields[
'entity'][
'enabled'] = 0;
255 foreach ($this->fields as $key => $val) {
256 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
257 unset($this->fields[$key]);
262 foreach ($this->fields as $key => $val) {
263 if (is_array($this->fields[
'status'][
'arrayofkeyval'])) {
264 foreach ($this->fields[
'status'][
'arrayofkeyval'] as $key2 => $val2) {
265 $this->fields[
'status'][
'arrayofkeyval'][$key2] = $langs->trans($val2);
292 global $langs, $hookmanager, $extrafields;
309 $object->ref =
"copy_of_".$object->ref;
313 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
314 $extrafields->fetch_name_optionals_label($this->table_element);
315 foreach (
$object->array_options as $key => $option) {
316 $shortkey = preg_replace(
'/options_/',
'', $key);
317 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
321 unset(
$object->array_options[$key]);
327 $object->context[
'createfromclone'] =
'createfromclone';
328 $result =
$object->createCommon($user);
332 $this->errors =
$object->errors;
335 unset(
$object->context[
'createfromclone']);
342 $this->db->rollback();
354 public function fetch($id, $ref =
null)
357 if ($result > 0 && !empty($this->table_element_line)) {
389 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
400 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
401 $sql .=
' WHERE t.entity = '.((int) $conf->entity);
407 $this->errors[] = $errormessage;
408 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
412 if (!empty($sortfield)) {
413 $sql .= $this->db->order($sortfield, $sortorder);
415 if (!empty($limit)) {
416 $sql .= $this->db->plimit($limit, $offset);
419 $resql = $this->db->query($sql);
421 $num = $this->db->num_rows($resql);
423 while ($obj = $this->db->fetch_object($resql)) {
424 $record =
new self($this->db);
426 $record->id = $obj->rowid;
430 $records[$record->id] = $record;
432 $this->db->free($resql);
436 $this->errors[] =
'Error '.$this->db->lasterror();
437 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
462 public function delete(
User $user, $notrigger = 0)
478 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
480 global $db, $conf, $langs, $hookmanager, $action;
481 global $dolibarr_main_authentication, $dolibarr_main_demo;
484 if (!empty($conf->dol_no_mouse_hover)) {
491 $label =
'<u>'.$langs->trans(
"Hook").
'</u>';
493 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
495 $url = DOL_URL_ROOT.
'/zapier/hook_card.php?id='.$this->id;
497 if ($option !=
'nolink') {
499 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
500 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
501 $add_save_lastsearch_values = 1;
503 if ($add_save_lastsearch_values) {
504 $url .=
'&save_lastsearch_values=1';
509 if (empty($notooltip)) {
511 $label = $langs->trans(
"ShowMyObject");
512 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
514 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
515 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
517 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
520 $linkstart =
'<a href="'.$url.
'"';
521 $linkstart .= $linkclose.
'>';
524 $result .= $linkstart;
526 $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);
528 if ($withpicto != 2) {
529 $result .= $this->ref;
534 $hookmanager->initHooks(array(
'hookdao'));
537 'getnomurl' => &$result,
540 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
542 $result = $hookmanager->resPrint;
544 $result .= $hookmanager->resPrint;
580 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
583 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
584 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
585 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
586 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
589 $statusType =
'status5';
590 if ($status == self::STATUS_VALIDATED) {
591 $statusType =
'status4';
594 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
605 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
606 $sql .=
' fk_user_creat, fk_user_modif';
607 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
608 $sql .=
' WHERE t.rowid = '.((int) $id);
609 $result = $this->db->query($sql);
611 if ($this->db->num_rows($result)) {
612 $obj = $this->db->fetch_object($result);
614 $this->
id = $obj->rowid;
616 $this->user_creation_id = $obj->fk_user_creat;
617 $this->user_modification_id = $obj->fk_user_modif;
618 $this->date_creation = $this->db->jdate($obj->datec);
619 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
622 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
info($id)
Load the info information in the object.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load object lines in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
fetch($id, $ref=null)
Load object in memory from the database.
getLibStatut($mode=0)
Return label of the status.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
LibStatut($status, $mode=0)
Return the status.
Class to manage Dolibarr users.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
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.