27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $module =
'webhook';
44 public $element =
'webhook_triggerhistory';
49 public $table_element =
'webhook_history';
59 public $picto =
'fa-calendar-alt';
62 const STATUS_SUCCESS = 1;
63 const STATUS_ERROR = -1;
114 "rowid" => array(
"type" =>
"integer",
"label" =>
"TechnicalID",
"enabled" => 1,
'position' => 1,
'notnull' => 1,
"visible" => 1,
"noteditable" => 1,
"index" => 1,
"css" =>
"left",
"comment" =>
"Id"),
115 "fk_target" => array(
"type" =>
"integer:target:webhook/class/target.class.php:0:(status:=:1)",
"label" =>
"Target",
"enabled" => 1,
'position' => 5,
'notnull' => 1,
"visible" => 1),
116 "trigger_code" => array(
"type" =>
"varchar(128)",
"label" =>
"TriggerCode",
"enabled" => 1,
'position' => 8,
'notnull' => 1,
"visible" => 1),
117 "url" => array(
"type" =>
"varchar(255)",
"label" =>
"Url",
"enabled" => 1,
'position' => 15,
'notnull' => 1,
"visible" => 1,
'csslist' =>
"small tdoverflowmax150"),
118 "trigger_data" => array(
"type" =>
"text",
"label" =>
"TriggerData",
"enabled" => 1,
'position' => 20,
'notnull' => 1,
"visible" => 1,
"csslist" =>
"small tdoverflowmax300"),
119 "note_private" => array(
"type" =>
"text",
"label" =>
"NotePrivate",
"enabled" => 1,
'position' => 62,
'notnull' => 0,
"visible" => 0,
"cssview" =>
"wordbreak",
"validate" => 1),
120 "date_creation" => array(
"type" =>
"datetime",
"label" =>
"DateCreation",
"enabled" => 1,
'position' => 500,
'notnull' => 1,
"visible" => -2),
121 "tms" => array(
"type" =>
"timestamp",
"label" =>
"DateModification",
"enabled" => 1,
'position' => 501,
'notnull' => 0,
"visible" => -2),
122 "fk_user_creat" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"UserAuthor",
"picto" =>
"user",
"enabled" => 1,
'position' => 510,
'notnull' => 1,
"visible" => -2,
"csslist" =>
"tdoverflowmax150"),
123 "import_key" => array(
"type" =>
"varchar(14)",
"label" =>
"ImportId",
"enabled" => 1,
'position' => 1000,
'notnull' => -1,
"visible" => -2,),
124 "status" => array(
"type" =>
"integer",
"label" =>
"Status",
"enabled" => 1,
"position" => 2000,
"notnull" => 1,
'default' =>
'1',
"visible" => 1,
"index" => 1,
"arrayofkeyval" => array(
"1" =>
"Success",
"-1" =>
"Error"),
"validate" => 1),
125 "error_message" => array(
"type" =>
"text",
"label" =>
"ErrorMessage",
"enabled" => 1,
'position' => 50,
'notnull' => 0,
"visible" => 1,
"csslist" =>
"small tdoverflowmax150"),
138 public $note_private;
142 public $date_creation;
150 public $fk_user_creat;
162 public $trigger_data;
174 public $trigger_code;
178 public $error_messsage;
229 $this->ismultientitymanaged = 0;
230 $this->isextrafieldmanaged = 1;
232 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
233 $this->fields[
'rowid'][
'visible'] = 0;
235 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
236 $this->fields[
'entity'][
'enabled'] = 0;
246 foreach ($this->fields as $key => $val) {
247 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
248 unset($this->fields[$key]);
253 if (is_object($langs)) {
254 foreach ($this->fields as $key => $val) {
255 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
256 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
257 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
294 public function fetch($id, $ref =
null, $noextrafields = 0, $nolines = 0)
296 $result = $this->
fetchCommon($id, $ref,
'', $noextrafields);
297 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
311 $this->lines = array();
332 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 1000, $offset = 0,
string $filter =
'', $filtermode =
'AND')
340 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
341 if ($this->isextrafieldmanaged == 1) {
342 $sql .=
" LEFT JOIN ".$this->db->prefix().$this->table_element.
"_extrafields as te ON te.fk_object = t.rowid";
344 if ($this->ismultientitymanaged == 1) {
345 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
347 $sql .=
" WHERE 1 = 1";
352 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
354 $this->errors[] = $errormessage;
355 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
359 if (!empty($sortfield)) {
360 $sql .= $this->db->order($sortfield, $sortorder);
362 if (!empty($limit)) {
363 $sql .= $this->db->plimit($limit, $offset);
366 $resql = $this->db->query($sql);
368 $num = $this->db->num_rows($resql);
370 while ($i < ($limit ? min($limit, $num) : $num)) {
371 $obj = $this->db->fetch_object($resql);
373 $record =
new self($this->db);
374 $record->setVarsFromFetchObj($obj);
376 if (!empty($record->isextrafieldmanaged)) {
377 $record->fetch_optionals();
380 $records[$record->id] = $record;
384 $this->db->free($resql);
388 $this->errors[] =
'Error '.$this->db->lasterror();
389 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
414 public function delete(
User $user, $notrigger = 0)
431 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
448 if ($this->
status <= self::STATUS_SUCCESS) {
459 return $this->
setStatusCommon($user, self::STATUS_ERROR, $notrigger,
'WEBHOOK_MYOBJECT_UNVALIDATE');
469 public function cancel($user, $notrigger = 0)
472 if ($this->
status != self::STATUS_SUCCESS) {
483 return $this->
setStatusCommon($user, self::STATUS_ERROR, $notrigger,
'WEBHOOK_MYOBJECT_CANCEL');
493 public function reopen($user, $notrigger = 0)
496 if ($this->
status == self::STATUS_SUCCESS) {
507 return $this->
setStatusCommon($user, self::STATUS_SUCCESS, $notrigger,
'WEBHOOK_MYOBJECT_REOPEN');
524 return [
'optimize' => $langs->trans(
"ShowTriggerHistory")];
526 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"").
'</u>';
527 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
541 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
543 global
$conf, $langs, $hookmanager;
545 if (!empty(
$conf->dol_no_mouse_hover)) {
551 'id' => (
string) $this->
id,
552 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
555 $classfortooltip =
'classfortooltip';
557 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"TriggerHistory").
'</u>';
558 $label .=
' '.$this->getLibStatut(5);
560 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
562 $baseurl = DOL_DOCUMENT_ROOT.
'/webhook/triggerhistory_card.php';
563 $query = [
'id' => $this->id];
564 if ($option !==
'nolink') {
566 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
567 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
568 $add_save_lastsearch_values = 1;
570 if ($add_save_lastsearch_values) {
571 $query += [
'save_lastsearch_values' => 1];
577 if (empty($notooltip)) {
579 $label = $langs->trans(
"ShowTriggerHistory");
580 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
582 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
583 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
585 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
588 if ($option ==
'nolink') {
589 $linkstart =
'<span';
591 $linkstart =
'<a href="'.$url.
'"';
593 $linkstart .= $linkclose.
'>';
594 if ($option ==
'nolink') {
595 $linkend =
'</span>';
600 $result .= $linkstart;
602 if (empty($this->showphoto_on_popup)) {
604 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
608 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
610 list($class, $module) = explode(
'@', $this->picto);
613 $filename = $filearray[0][
'name'];
614 if (!empty($filename)) {
615 $pospoint = strpos($filearray[0][
'name'],
'.');
617 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
619 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
621 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
626 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
631 if ($withpicto != 2) {
632 $result .= $this->ref;
638 global $action, $hookmanager;
639 $hookmanager->initHooks(array($this->element.
'dao'));
640 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
641 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
643 $result = $hookmanager->resPrint;
645 $result .= $hookmanager->resPrint;
660 global
$conf, $langs;
662 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
664 $return =
'<div class="box-flex-item box-flex-grow-zero">';
665 $return .=
'<div class="info-box info-box-sm">';
666 $return .=
'<span class="info-box-icon bg-infobox-action">';
668 $return .=
'</span>';
669 $return .=
'<div class="info-box-content">';
670 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl().
'</span>';
671 if ($selected >= 0) {
672 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
674 if (is_object($this->thirdparty)) {
675 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
681 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
722 if (is_null($status)) {
726 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
729 $this->labelStatus[self::STATUS_SUCCESS] = $langs->transnoentitiesnoconv(
'Success');
730 $this->labelStatus[self::STATUS_ERROR] = $langs->transnoentitiesnoconv(
'Error');
731 $this->labelStatusShort[self::STATUS_SUCCESS] = $langs->transnoentitiesnoconv(
'Success');
732 $this->labelStatusShort[self::STATUS_ERROR] = $langs->transnoentitiesnoconv(
'Error');
735 $statusType =
'status'.$status;
736 if ($status == self::STATUS_SUCCESS) {
737 $statusType =
'status4';
739 if ($status == self::STATUS_ERROR) {
740 $statusType =
'status8';
743 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
754 $sql =
"SELECT rowid,";
755 $sql .=
" date_creation as datec, tms as datem";
756 if (!empty($this->fields[
'date_validation'])) {
757 $sql .=
", date_validation as datev";
759 if (!empty($this->fields[
'fk_user_creat'])) {
760 $sql .=
", fk_user_creat";
762 if (!empty($this->fields[
'fk_user_modif'])) {
763 $sql .=
", fk_user_modif";
765 if (!empty($this->fields[
'fk_user_valid'])) {
766 $sql .=
", fk_user_valid";
768 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
769 $sql .=
" WHERE t.rowid = ".((int) $id);
771 $result = $this->db->query($sql);
773 if ($this->db->num_rows($result)) {
774 $obj = $this->db->fetch_object($result);
776 $this->
id = $obj->rowid;
778 if (!empty($this->fields[
'fk_user_creat'])) {
779 $this->user_creation_id = $obj->fk_user_creat;
781 if (!empty($this->fields[
'fk_user_modif'])) {
782 $this->user_modification_id = $obj->fk_user_modif;
784 if (!empty($this->fields[
'fk_user_valid'])) {
785 $this->user_validation_id = $obj->fk_user_valid;
787 $this->date_creation = $this->db->jdate($obj->datec);
788 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
789 if (!empty($obj->datev)) {
790 $this->date_validation = empty($obj->datev) ?
'' : $this->db->jdate($obj->datev);
794 $this->db->free($result);
822 $this->lines = array();
825 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_history:=:'.((
int) $this->
id).
')');
827 if (is_numeric($result)) {
831 $this->lines = $result;
850 return parent::validateField(
$fields, $fieldKey, $fieldValue);
887require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
918 $this->isextrafieldmanaged = 0;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
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.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
$parent_element
To overload.
$fk_parent_attribute
To overload.
__construct(DoliDB $db)
Constructor.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
initAsSpecimen()
Initialize object with example values Id must be 0 if object instance is a specimen.
cancel($user, $notrigger=0)
Set cancel status.
$fields
'type' field format: 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortf...
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
LibStatut($status, $mode=0)
Return the label of a given status.
getLabelStatus($mode=0)
Return the label of the status.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null, $noextrafields=0, $nolines=0)
Load object 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)
update(User $user, $notrigger=0)
Update object into database.
reopen($user, $notrigger=0)
Set back to validated status.
fetchAll($sortorder='', $sortfield='', $limit=1000, $offset=0, string $filter='', $filtermode='AND')
Load list of objects in memory from the database.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
getLibStatut($mode=0)
Return the label of the status.
setDraft($user, $notrigger=0)
Set draft status.
create(User $user, $notrigger=0)
Create object into database.
validateField($fields, $fieldKey, $fieldValue)
Return validation test result for a field.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
info($id)
Load the info information in the object.
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_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php