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 $date_creation;
225 public $fk_user_creat;
230 public $fk_user_modif;
245 global $conf, $langs, $user;
249 $this->ismultientitymanaged = 0;
250 $this->isextrafieldmanaged = 1;
253 $this->fields[
'rowid'][
'visible'] = 0;
255 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
256 $this->fields[
'entity'][
'enabled'] = 0;
260 foreach ($this->fields as $key => $val) {
261 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
262 unset($this->fields[$key]);
267 foreach ($this->fields as $key => $val) {
268 if (is_array($this->fields[
'status'][
'arrayofkeyval'])) {
269 foreach ($this->fields[
'status'][
'arrayofkeyval'] as $key2 => $val2) {
270 $this->fields[
'status'][
'arrayofkeyval'][$key2] = $langs->trans($val2);
297 global $langs, $hookmanager, $extrafields;
314 $object->ref =
"copy_of_".$object->ref;
318 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
319 $extrafields->fetch_name_optionals_label($this->table_element);
320 foreach (
$object->array_options as $key => $option) {
321 $shortkey = preg_replace(
'/options_/',
'', $key);
322 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
326 unset(
$object->array_options[$key]);
332 $object->context[
'createfromclone'] =
'createfromclone';
333 $result =
$object->createCommon($user);
337 $this->errors =
$object->errors;
340 unset(
$object->context[
'createfromclone']);
347 $this->db->rollback();
359 public function fetch($id, $ref =
null)
362 if ($result > 0 && !empty($this->table_element_line)) {
394 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
405 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
406 $sql .=
' WHERE t.entity = '.((int) $conf->entity);
412 $this->errors[] = $errormessage;
413 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
417 if (!empty($sortfield)) {
418 $sql .= $this->db->order($sortfield, $sortorder);
420 if (!empty($limit)) {
421 $sql .= $this->db->plimit($limit, $offset);
424 $resql = $this->db->query($sql);
426 $num = $this->db->num_rows($resql);
428 while ($obj = $this->db->fetch_object($resql)) {
429 $record =
new self($this->db);
431 $record->id = $obj->rowid;
435 $records[$record->id] = $record;
437 $this->db->free($resql);
441 $this->errors[] =
'Error '.$this->db->lasterror();
442 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
467 public function delete(
User $user, $notrigger = 0)
483 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
485 global $db, $conf, $langs, $hookmanager, $action;
486 global $dolibarr_main_authentication, $dolibarr_main_demo;
489 if (!empty($conf->dol_no_mouse_hover)) {
496 $label =
'<u>'.$langs->trans(
"Hook").
'</u>';
498 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
500 $url = DOL_URL_ROOT.
'/zapier/hook_card.php?id='.$this->id;
502 if ($option !=
'nolink') {
504 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
505 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
506 $add_save_lastsearch_values = 1;
508 if ($add_save_lastsearch_values) {
509 $url .=
'&save_lastsearch_values=1';
514 if (empty($notooltip)) {
516 $label = $langs->trans(
"ShowMyObject");
517 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
519 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
520 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
522 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
525 $linkstart =
'<a href="'.$url.
'"';
526 $linkstart .= $linkclose.
'>';
529 $result .= $linkstart;
531 $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);
533 if ($withpicto != 2) {
534 $result .= $this->ref;
539 $hookmanager->initHooks(array(
'hookdao'));
542 'getnomurl' => &$result,
545 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
547 $result = $hookmanager->resPrint;
549 $result .= $hookmanager->resPrint;
585 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
588 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
589 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
590 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
591 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
594 $statusType =
'status5';
595 if ($status == self::STATUS_VALIDATED) {
596 $statusType =
'status4';
599 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
610 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
611 $sql .=
' fk_user_creat, fk_user_modif';
612 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
613 $sql .=
' WHERE t.rowid = '.((int) $id);
614 $result = $this->db->query($sql);
616 if ($this->db->num_rows($result)) {
617 $obj = $this->db->fetch_object($result);
619 $this->
id = $obj->rowid;
621 $this->user_creation_id = $obj->fk_user_creat;
622 $this->user_modification_id = $obj->fk_user_modif;
623 $this->date_creation = $this->db->jdate($obj->datec);
624 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
627 $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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.