25require
'../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/webhook/class/target.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/webhook/lib/webhook_target.lib.php';
32global $conf, $db, $hookmanager, $langs, $user;
35$langs->loadLangs(array(
'other'));
40$action =
GETPOST(
'action',
'aZ09');
41$confirm =
GETPOST(
'confirm',
'alpha');
42$cancel =
GETPOST(
'cancel',
'aZ09');
43$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'targetcard';
44$backtopage =
GETPOST(
'backtopage',
'alpha');
45$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
46$lineid =
GETPOST(
'lineid',
'int');
51$diroutputmassaction = $conf->webhook->dir_output.
'/temp/massgeneration/'.$user->id;
52$hookmanager->initHooks(array(
'targetcard',
'globalcard'));
55$extrafields->fetch_name_optionals_label($object->table_element);
57$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
60$search_all =
GETPOST(
"search_all",
'alpha');
62foreach ($object->fields as $key => $val) {
63 if (
GETPOST(
'search_'.$key,
'alpha')) {
64 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
68if (empty($action) && empty($id) && empty($ref)) {
73include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
78$enablepermissioncheck = 0;
79if ($enablepermissioncheck) {
80 $permissiontoread = $user->hasRight(
'webhook',
'target',
'read');
81 $permissiontoadd = $user->hasRight(
'webhook',
'target',
'write');
82 $permissiontodelete = $user->hasRight(
'webhook',
'target',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
83 $permissionnote = $user->hasRight(
'webhook',
'target',
'write');
84 $permissiondellink = $user->hasRight(
'webhook',
'target',
'write');
86 $permissiontoread = 1;
88 $permissiontodelete = 1;
90 $permissiondellink = 1;
93$upload_dir = $conf->webhook->multidir_output[isset($object->entity) ? $object->entity : 1].
'/target';
100if (empty($conf->webhook->enabled)) {
103if (!$permissiontoread) {
112$parameters = array();
113$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
118if (empty($reshook)) {
121 $backurlforlist =
dol_buildpath(
'/webhook/target_list.php?mode=modulesetup', 1);
123 if (empty($backtopage) || ($cancel && empty($id))) {
124 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
125 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
126 $backtopage = $backurlforlist;
128 $backtopage =
dol_buildpath(
'/webhook/target_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
133 $triggermodname =
'WEBHOOK_TARGET_MODIFY';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
142 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
148 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
150 if ($action ==
'set_thirdparty' && $permissiontoadd) {
151 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
153 if ($action ==
'classin' && $permissiontoadd) {
154 $object->setProject(
GETPOST(
'projectid',
'int'));
158 $triggersendname =
'WEBHOOK_TARGET_SENTBYMAIL';
159 $autocopy =
'MAIN_MAIL_AUTOCOPY_TARGET_TO';
160 $trackid =
'target'.$object->id;
161 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
171$form =
new Form($db);
175$title = $langs->trans(
"Target");
196if ($action ==
'create') {
197 if (empty($permissiontoadd)) {
202 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Target")),
'',
'object_'.$object->picto);
204 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
205 print
'<input type="hidden" name="token" value="'.newToken().
'">';
206 print
'<input type="hidden" name="action" value="add">';
208 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
210 if ($backtopageforcancel) {
211 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
219 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
222 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
225 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
227 print
'</table>'.
"\n";
231 print $form->buttonsSaveCancel(
"Create");
239if (($id || $ref) && $action ==
'edit') {
240 print
load_fiche_titre($langs->trans(
"Target"),
'',
'object_'.$object->picto);
242 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
243 print
'<input type="hidden" name="token" value="'.newToken().
'">';
244 print
'<input type="hidden" name="action" value="update">';
245 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
247 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
249 if ($backtopageforcancel) {
250 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
255 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
258 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
261 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
267 print $form->buttonsSaveCancel();
273if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
274 $res = $object->fetch_optionals();
282 if ($action ==
'delete') {
283 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteTarget'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
286 if ($action ==
'deleteline') {
287 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
291 if ($action ==
'clone') {
293 $formquestion = array();
294 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
298 if ($action ==
'xxx') {
299 $text = $langs->trans(
'ConfirmActionTarget', $object->ref);
308 $formquestion = array();
319 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
323 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
324 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
325 if (empty($reshook)) {
326 $formconfirm .= $hookmanager->resPrint;
327 } elseif ($reshook > 0) {
328 $formconfirm = $hookmanager->resPrint;
337 $linkback =
'<a href="'.dol_buildpath(
'/webhook/target_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
339 $morehtmlref =
'<div class="refidno">';
374 $morehtmlref .=
'</div>';
377 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
380 print
'<div class="fichecenter">';
381 print
'<div class="fichehalfleft">';
382 print
'<div class="underbanner clearboth"></div>';
383 print
'<table class="border centpercent tableforfield">'.
"\n";
389 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
392 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
398 print
'<div class="clearboth"></div>';
407 if (!empty($object->table_element_line)) {
409 $result = $object->getLinesArray();
411 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
412 <input type="hidden" name="token" value="' . newToken().
'">
413 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
414 <input type="hidden" name="mode" value="">
415 <input type="hidden" name="page_y" value="">
416 <input type="hidden" name="id" value="' . $object->id.
'">
419 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
423 print
'<div class="div-table-responsive-no-min">';
424 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
425 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
428 if (!empty($object->lines)) {
429 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
433 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
434 if ($action !=
'editline') {
437 $parameters = array();
438 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
442 if (empty($reshook)) {
443 $object->formAddObjectLine(1, $mysoc, $soc);
448 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
459 if ($action !=
'presend' && $action !=
'editline') {
460 print
'<div class="tabsAction">'.
"\n";
461 $parameters = array();
462 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
467 if (empty($reshook)) {
473 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
476 if ($object->status == $object::STATUS_VALIDATED) {
477 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
481 if ($object->status == $object::STATUS_DRAFT) {
482 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
486 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.newToken(),
'', $permissiontoadd);
506 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'', $permissiontodelete);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
targetPrepareHead($object)
Prepare array of tabs for Target.