28require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/webhook/class/triggerhistory.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/webhook/lib/webhook_triggerhistory.lib.php';
46$langs->loadLangs(array(
"webhook@webhook",
"other",
"admin"));
53$action =
GETPOST(
'action',
'aZ09');
54$confirm =
GETPOST(
'confirm',
'alpha');
55$cancel =
GETPOST(
'cancel',
'alpha');
56$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
57$backtopage =
GETPOST(
'backtopage',
'alpha');
58$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
59$optioncss =
GETPOST(
'optioncss',
'aZ');
60$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
64$diroutputmassaction =
$conf->webhook->dir_output.
'/temp/massgeneration/'.$user->id;
65$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
69$extrafields->fetch_name_optionals_label(
$object->table_element);
72$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
75$search_all = trim(
GETPOST(
"search_all",
'alpha'));
77foreach (
$object->fields as $key => $val) {
78 if (
GETPOST(
'search_'.$key,
'alpha')) {
79 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
83if (empty($action) && empty($id) && empty($ref)) {
88include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
92$permissiontoread = $permissiontoadd = $permissiontodelete = $permissionnote = $permissiondellink = (!empty($user->admin) ? 1 : 0);
94$upload_dir =
$conf->webhook->multidir_output[!empty(
$object->entity) ?
$object->entity : 1].
'/triggerhistory';
104if (!$permissiontoread) {
115$parameters = array();
116$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
121if (empty($reshook)) {
122 $backurlforlist =
dol_buildpath(
'/webhook/history_list.php', 1);
124 if (empty($backtopage) || ($cancel && empty($id))) {
125 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
126 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
127 $backtopage = $backurlforlist;
129 $backtopage =
dol_buildpath(
'/webhook/history_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
134 $triggermodname =
'WEBHOOK_MYOBJECT_MODIFY';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
151 if ($action ==
'set_thirdparty' && $permissiontoadd) {
152 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
154 if ($action ==
'classin' && $permissiontoadd) {
159 $triggersendname =
'WEBHOOK_MYOBJECT_SENTBYMAIL';
160 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
161 $trackid =
'triggerhistory'.$object->id;
162 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
176$title = $langs->trans(
"TriggerHistory").
" - ".$langs->trans(
'Card');
178if ($action ==
'create') {
179 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"TriggerHistory"));
183llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-webhook page-card');
186if ($action ==
'create') {
187 if (empty($permissiontoadd)) {
193 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
194 print
'<input type="hidden" name="token" value="'.newToken().
'">';
195 print
'<input type="hidden" name="action" value="add">';
197 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
199 if ($backtopageforcancel) {
200 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
202 if ($dol_openinpopup) {
203 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
209 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
212 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
215 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
217 print
'</table>'.
"\n";
221 print $form->buttonsSaveCancel(
"Create");
229if (($id || $ref) && $action ==
'edit') {
232 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
233 print
'<input type="hidden" name="token" value="'.newToken().
'">';
234 print
'<input type="hidden" name="action" value="update">';
235 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
237 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
239 if ($backtopageforcancel) {
240 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
245 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
248 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
251 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
257 print $form->buttonsSaveCancel();
263if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
266 print
dol_get_fiche_head($head,
'card', $langs->trans(
""), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
271 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
272 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteTriggereHistoryRecord'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
275 if ($action ==
'deleteline') {
276 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
280 if ($action ==
'clone') {
282 $formquestion = array();
283 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
310 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
311 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
312 if (empty($reshook)) {
313 $formconfirm .= $hookmanager->resPrint;
314 } elseif ($reshook > 0) {
315 $formconfirm = $hookmanager->resPrint;
324 $linkback =
'<a href="'.dol_buildpath(
'/webhook/triggerhistory_list.php', 1).
'?restore_lastsearch_values=1&mode=modulesetup'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
326 $morehtmlref =
'<div class="refidno">';
358 $morehtmlref .=
'</div>';
361 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'', $morehtmlref);
364 print
'<div class="fichecenter">';
365 print
'<div class="fichehalfleft">';
366 print
'<div class="underbanner clearboth"></div>';
367 print
'<table class="border centpercent tableforfield">'.
"\n";
373 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
376 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
382 print
'<div class="clearboth"></div>';
391 if (!empty(
$object->table_element_line)) {
393 $result =
$object->getLinesArray();
395 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
396 <input type="hidden" name="token" value="' . newToken().
'">
397 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
398 <input type="hidden" name="mode" value="">
399 <input type="hidden" name="page_y" value="">
400 <input type="hidden" name="id" value="' .
$object->id.
'">
403 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
404 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
407 print
'<div class="div-table-responsive-no-min">';
408 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_ERROR && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
409 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
417 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
418 if ($action !=
'editline') {
421 $parameters = array();
422 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
426 if (empty($reshook)) {
432 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_ERROR && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
443 if ($action !=
'presend' && $action !=
'editline') {
444 print
'<div class="tabsAction">'.
"\n";
445 $parameters = array();
446 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
451 if (empty($reshook)) {
463 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
498 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.newToken();
499 $buttonId =
'action-delete-no-ajax';
500 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
502 $buttonId =
'action-delete';
505 print dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
512 if (
GETPOST(
'modelselected')) {
516 if ($action !=
'presend') {
517 print
'<div class="fichecenter"><div class="fichehalfleft">';
518 print
'<a name="builddoc"></a>';
520 $includedocgeneration = 0;
523 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'triggerhistory'), 1);
524 if (is_array($tmparray)) {
525 $linktoelem = $tmparray[
'linktoelem'];
526 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
527 print $htmltoenteralink;
528 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
531 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
534 print
'</div><div class="fichehalfright">';
538 $morehtmlcenter = dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/webhook/history_agenda.php', 1).
'?id='.
$object->id);
540 print
'</div></div>';
544 $modelmail =
'triggerhistory';
545 $defaulttopic =
'InformationMessage';
546 $diroutput =
$conf->webhook->dir_output;
547 $trackid =
'triggerhistory'.$object->id;
549 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
triggerhistoryPrepareHead($object)
Prepare array of tabs for.