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';
33$langs->loadLangs(array(
'other'));
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'targetcard';
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
44$lineid =
GETPOST(
'lineid',
'int');
49$diroutputmassaction = $conf->webhook->dir_output.
'/temp/massgeneration/'.$user->id;
50$hookmanager->initHooks(array(
'targetcard',
'globalcard'));
53$extrafields->fetch_name_optionals_label($object->table_element);
55$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
58$search_all =
GETPOST(
"search_all",
'alpha');
60foreach ($object->fields as $key => $val) {
61 if (
GETPOST(
'search_'.$key,
'alpha')) {
62 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
66if (empty($action) && empty($id) && empty($ref)) {
71include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
76$enablepermissioncheck = 0;
77if ($enablepermissioncheck) {
78 $permissiontoread = $user->rights->webhook->target->read;
79 $permissiontoadd = $user->rights->webhook->target->write;
80 $permissiontodelete = $user->rights->webhook->target->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
81 $permissionnote = $user->rights->webhook->target->write;
82 $permissiondellink = $user->rights->webhook->target->write;
84 $permissiontoread = 1;
86 $permissiontodelete = 1;
88 $permissiondellink = 1;
91$upload_dir = $conf->webhook->multidir_output[isset($object->entity) ? $object->entity : 1].
'/target';
106$parameters = array();
107$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
112if (empty($reshook)) {
115 $backurlforlist =
dol_buildpath(
'/webhook/target_list.php?mode=modulesetup', 1);
117 if (empty($backtopage) || ($cancel && empty($id))) {
118 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
119 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
120 $backtopage = $backurlforlist;
122 $backtopage =
dol_buildpath(
'/webhook/target_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
127 $triggermodname =
'WEBHOOK_TARGET_MODIFY';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
142 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
144 if ($action ==
'set_thirdparty' && $permissiontoadd) {
145 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
147 if ($action ==
'classin' && $permissiontoadd) {
148 $object->setProject(
GETPOST(
'projectid',
'int'));
152 $triggersendname =
'WEBHOOK_TARGET_SENTBYMAIL';
153 $autocopy =
'MAIN_MAIL_AUTOCOPY_TARGET_TO';
154 $trackid =
'target'.$object->id;
155 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
165$form =
new Form($db);
169$title = $langs->trans(
"Target");
190if ($action ==
'create') {
191 if (empty($permissiontoadd)) {
196 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Target")),
'',
'object_'.$object->picto);
198 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
199 print
'<input type="hidden" name="token" value="'.newToken().
'">';
200 print
'<input type="hidden" name="action" value="add">';
202 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
204 if ($backtopageforcancel) {
205 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
213 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
216 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
219 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
221 print
'</table>'.
"\n";
225 print $form->buttonsSaveCancel(
"Create");
233if (($id || $ref) && $action ==
'edit') {
234 print
load_fiche_titre($langs->trans(
"Target"),
'',
'object_'.$object->picto);
236 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
237 print
'<input type="hidden" name="token" value="'.newToken().
'">';
238 print
'<input type="hidden" name="action" value="update">';
239 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
241 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
243 if ($backtopageforcancel) {
244 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
249 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
252 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
255 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
261 print $form->buttonsSaveCancel();
267if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
268 $res = $object->fetch_optionals();
276 if ($action ==
'delete') {
277 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteTarget'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
280 if ($action ==
'deleteline') {
281 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
285 if ($action ==
'clone') {
287 $formquestion = array();
288 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
292 if ($action ==
'xxx') {
293 $text = $langs->trans(
'ConfirmActionTarget', $object->ref);
302 $formquestion = array();
313 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
317 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
318 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
319 if (empty($reshook)) {
320 $formconfirm .= $hookmanager->resPrint;
321 } elseif ($reshook > 0) {
322 $formconfirm = $hookmanager->resPrint;
331 $linkback =
'<a href="'.dol_buildpath(
'/webhook/target_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
333 $morehtmlref =
'<div class="refidno">';
368 $morehtmlref .=
'</div>';
371 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
374 print
'<div class="fichecenter">';
375 print
'<div class="fichehalfleft">';
376 print
'<div class="underbanner clearboth"></div>';
377 print
'<table class="border centpercent tableforfield">'.
"\n";
383 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
386 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
392 print
'<div class="clearboth"></div>';
401 if (!empty($object->table_element_line)) {
403 $result = $object->getLinesArray();
405 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
406 <input type="hidden" name="token" value="' . newToken().
'">
407 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
408 <input type="hidden" name="mode" value="">
409 <input type="hidden" name="page_y" value="">
410 <input type="hidden" name="id" value="' . $object->id.
'">
413 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
414 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
417 print
'<div class="div-table-responsive-no-min">';
418 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
419 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
422 if (!empty($object->lines)) {
423 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
427 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
428 if ($action !=
'editline') {
431 $parameters = array();
432 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
437 $object->formAddObjectLine(1, $mysoc, $soc);
441 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
452 if ($action !=
'presend' && $action !=
'editline') {
453 print
'<div class="tabsAction">'.
"\n";
454 $parameters = array();
455 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
460 if (empty($reshook)) {
466 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
469 if ($object->status == $object::STATUS_VALIDATED) {
470 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
474 if ($object->status == $object::STATUS_DRAFT) {
475 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
479 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.newToken(),
'', $permissiontoadd);
499 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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.