50 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
51 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
54 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
55 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
58 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
59 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
61 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
62 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
65 if (!$res && file_exists(
"../main.inc.php")) {
66 $res = @include
"../main.inc.php";
68 if (!$res && file_exists(
"../../main.inc.php")) {
69 $res = @include
"../../main.inc.php";
71 if (!$res && file_exists(
"../../../main.inc.php")) {
72 $res = @include
"../../../main.inc.php";
75 die(
"Include of main fails");
78 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
80 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
85 $langs->loadLangs(array(
"webhook@webhook",
"other"));
90 $action =
GETPOST(
'action',
'aZ09');
91 $confirm =
GETPOST(
'confirm',
'alpha');
92 $cancel =
GETPOST(
'cancel',
'aZ09');
93 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'targetcard';
94 $backtopage =
GETPOST(
'backtopage',
'alpha');
95 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
96 $lineid =
GETPOST(
'lineid',
'int');
101 $diroutputmassaction = $conf->webhook->dir_output.
'/temp/massgeneration/'.$user->id;
102 $hookmanager->initHooks(array(
'targetcard',
'globalcard'));
105 $extrafields->fetch_name_optionals_label($object->table_element);
107 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
110 $search_all =
GETPOST(
"search_all",
'alpha');
112 foreach ($object->fields as $key => $val) {
113 if (
GETPOST(
'search_'.$key,
'alpha')) {
114 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
118 if (empty($action) && empty($id) && empty($ref)) {
123 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
127 $enablepermissioncheck = 0;
128 if ($enablepermissioncheck) {
129 $permissiontoread = $user->rights->webhook->target->read;
130 $permissiontoadd = $user->rights->webhook->target->write;
131 $permissiontodelete = $user->rights->webhook->target->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
132 $permissionnote = $user->rights->webhook->target->write;
133 $permissiondellink = $user->rights->webhook->target->write;
135 $permissiontoread = 1;
136 $permissiontoadd = 1;
137 $permissiontodelete = 1;
139 $permissiondellink = 1;
142 $upload_dir = $conf->webhook->multidir_output[isset($object->entity) ? $object->entity : 1].
'/target';
157 $parameters = array();
158 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
163 if (empty($reshook)) {
166 $backurlforlist =
dol_buildpath(
'/webhook/target_list.php?mode=modulesetup', 1);
168 if (empty($backtopage) || ($cancel && empty($id))) {
169 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
170 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
171 $backtopage = $backurlforlist;
173 $backtopage =
dol_buildpath(
'/webhook/target_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
178 $triggermodname =
'WEBHOOK_TARGET_MODIFY';
181 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
184 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
187 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
193 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
195 if ($action ==
'set_thirdparty' && $permissiontoadd) {
196 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
198 if ($action ==
'classin' && $permissiontoadd) {
199 $object->setProject(
GETPOST(
'projectid',
'int'));
203 $triggersendname =
'WEBHOOK_TARGET_SENTBYMAIL';
204 $autocopy =
'MAIN_MAIL_AUTOCOPY_TARGET_TO';
205 $trackid =
'target'.$object->id;
206 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
222 $title = $langs->trans(
"Target");
243 if ($action ==
'create') {
244 if (empty($permissiontoadd)) {
249 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Target")),
'',
'object_'.$object->picto);
251 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
252 print
'<input type="hidden" name="token" value="'.newToken().
'">';
253 print
'<input type="hidden" name="action" value="add">';
255 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
257 if ($backtopageforcancel) {
258 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
266 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
269 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
274 print
'</table>'.
"\n";
278 print
$form->buttonsSaveCancel(
"Create");
286 if (($id || $ref) && $action ==
'edit') {
287 print
load_fiche_titre($langs->trans(
"Target"),
'',
'object_'.$object->picto);
289 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="action" value="update">';
292 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
294 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
296 if ($backtopageforcancel) {
297 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
302 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
305 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
314 print
$form->buttonsSaveCancel();
320 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
321 $res = $object->fetch_optionals();
329 if ($action ==
'delete') {
330 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteTarget'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
333 if ($action ==
'deleteline') {
334 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
338 if ($action ==
'clone') {
340 $formquestion = array();
341 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
345 if ($action ==
'xxx') {
346 $text = $langs->trans(
'ConfirmActionTarget', $object->ref);
355 $formquestion = array();
366 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
370 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
371 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
372 if (empty($reshook)) {
373 $formconfirm .= $hookmanager->resPrint;
374 } elseif ($reshook > 0) {
375 $formconfirm = $hookmanager->resPrint;
384 $linkback =
'<a href="'.dol_buildpath(
'/webhook/target_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
386 $morehtmlref =
'<div class="refidno">';
421 $morehtmlref .=
'</div>';
424 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
427 print
'<div class="fichecenter">';
428 print
'<div class="fichehalfleft">';
429 print
'<div class="underbanner clearboth"></div>';
430 print
'<table class="border centpercent tableforfield">'.
"\n";
436 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
445 print
'<div class="clearboth"></div>';
454 if (!empty($object->table_element_line)) {
456 $result = $object->getLinesArray();
458 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
459 <input type="hidden" name="token" value="' .
newToken().
'">
460 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
461 <input type="hidden" name="mode" value="">
462 <input type="hidden" name="page_y" value="">
463 <input type="hidden" name="id" value="' . $object->id.
'">
466 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
467 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
470 print
'<div class="div-table-responsive-no-min">';
471 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
472 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
475 if (!empty($object->lines)) {
476 $object->printObjectLines($action, $mysoc, null,
GETPOST(
'lineid',
'int'), 1);
480 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
481 if ($action !=
'editline') {
484 $parameters = array();
485 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
486 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
488 $object->formAddObjectLine(1, $mysoc, $soc);
492 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
503 if ($action !=
'presend' && $action !=
'editline') {
504 print
'<div class="tabsAction">'.
"\n";
505 $parameters = array();
506 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
511 if (empty($reshook)) {
513 if (empty($user->socid)) {
514 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle');
518 if ($object->status == $object::STATUS_VALIDATED) {
519 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
522 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
525 if ($object->status == $object::STATUS_DRAFT) {
526 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
527 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
529 $langs->load(
"errors");
530 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
535 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
555 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
562 if (
GETPOST(
'modelselected')) {
566 if ($action !=
'presend') {
567 print
'<div class="fichecenter"><div class="fichehalfleft">';
568 print
'<a name="builddoc"></a>';
570 $includedocgeneration = 0;
573 if ($includedocgeneration) {
575 $relativepath = $objref.
'/'.$objref.
'.pdf';
576 $filedir = $conf->webhook->dir_output.
'/'.$object->element.
'/'.$objref;
577 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
578 $genallowed = $permissiontoread;
579 $delallowed = $permissiontoadd;
580 print $formfile->showdocuments(
'webhook:Target', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
584 $linktoelem =
$form->showLinkToObjectBlock($object, null, array(
'target'));
585 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
588 print
'</div><div class="fichehalfright">';
592 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-list-alt imgforviewmode',
dol_buildpath(
'/webhook/target_agenda.php', 1).
'?id='.$object->id);
595 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
597 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
599 print
'</div></div>';
603 if (
GETPOST(
'modelselected')) {
608 $modelmail =
'target';
609 $defaulttopic =
'InformationMessage';
610 $diroutput = $conf->webhook->dir_output;
611 $trackid =
'target'.$object->id;
613 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
targetPrepareHead($object)
Prepare array of tabs for Target.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
$formconfirm
if ($action == 'delbookkeepingyear') {