target_card.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file target_card.php
  19. * \ingroup webhook
  20. * \brief Page to create/edit/view target
  21. */
  22. // Load Dolibarr environment
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/webhook/class/target.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/webhook/lib/webhook_target.lib.php';
  29. global $conf, $db, $hookmanager, $langs, $user;
  30. // Load translation files required by the page
  31. $langs->loadLangs(array('other'));
  32. // Get parameters
  33. $id = GETPOST('id', 'int');
  34. $ref = GETPOST('ref', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. $confirm = GETPOST('confirm', 'alpha');
  37. $cancel = GETPOST('cancel', 'aZ09');
  38. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'targetcard'; // To manage different context of search
  39. $backtopage = GETPOST('backtopage', 'alpha');
  40. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  41. $lineid = GETPOST('lineid', 'int');
  42. // Initialize technical objects
  43. $object = new Target($db);
  44. $extrafields = new ExtraFields($db);
  45. $diroutputmassaction = $conf->webhook->dir_output.'/temp/massgeneration/'.$user->id;
  46. $hookmanager->initHooks(array('targetcard', 'globalcard')); // Note that conf->hooks_modules contains array
  47. // Fetch optionals attributes and labels
  48. $extrafields->fetch_name_optionals_label($object->table_element);
  49. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  50. // Initialize array of search criterias
  51. $search_all = GETPOST("search_all", 'alpha');
  52. $search = array();
  53. foreach ($object->fields as $key => $val) {
  54. if (GETPOST('search_'.$key, 'alpha')) {
  55. $search[$key] = GETPOST('search_'.$key, 'alpha');
  56. }
  57. }
  58. if (empty($action) && empty($id) && empty($ref)) {
  59. $action = 'view';
  60. }
  61. // Load object
  62. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  63. // Permissions
  64. // There is several ways to check permission.
  65. // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
  66. $enablepermissioncheck = 0;
  67. if ($enablepermissioncheck) {
  68. $permissiontoread = $user->hasRight('webhook', 'target', 'read');
  69. $permissiontoadd = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  70. $permissiontodelete = $user->hasRight('webhook', 'target', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  71. $permissionnote = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_setnotes.inc.php
  72. $permissiondellink = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_dellink.inc.php
  73. } else {
  74. $permissiontoread = 1;
  75. $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  76. $permissiontodelete = 1;
  77. $permissionnote = 1;
  78. $permissiondellink = 1;
  79. }
  80. $upload_dir = $conf->webhook->multidir_output[isset($object->entity) ? $object->entity : 1].'/target';
  81. // Security check (enable the most restrictive one)
  82. //if ($user->socid > 0) accessforbidden();
  83. //if ($user->socid > 0) $socid = $user->socid;
  84. //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  85. //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
  86. if (empty($conf->webhook->enabled)) {
  87. accessforbidden();
  88. }
  89. if (!$permissiontoread) {
  90. accessforbidden();
  91. }
  92. /*
  93. * Actions
  94. */
  95. $parameters = array();
  96. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  97. if ($reshook < 0) {
  98. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  99. }
  100. if (empty($reshook)) {
  101. $error = 0;
  102. $backurlforlist = dol_buildpath('/webhook/target_list.php?mode=modulesetup', 1);
  103. if (empty($backtopage) || ($cancel && empty($id))) {
  104. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  105. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  106. $backtopage = $backurlforlist;
  107. } else {
  108. $backtopage = dol_buildpath('/webhook/target_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
  109. }
  110. }
  111. }
  112. $triggermodname = 'WEBHOOK_TARGET_MODIFY'; // Name of trigger action code to execute when we modify record
  113. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  114. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  115. // Actions when linking object each other
  116. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
  117. // Actions when printing a doc from card
  118. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  119. // Action to move up and down lines of object
  120. //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
  121. // Action to build doc
  122. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  123. if ($action == 'set_thirdparty' && $permissiontoadd) {
  124. $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
  125. }
  126. if ($action == 'classin' && $permissiontoadd) {
  127. $object->setProject(GETPOST('projectid', 'int'));
  128. }
  129. // Actions to send emails
  130. $triggersendname = 'WEBHOOK_TARGET_SENTBYMAIL';
  131. $autocopy = 'MAIN_MAIL_AUTOCOPY_TARGET_TO';
  132. $trackid = 'target'.$object->id;
  133. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  134. }
  135. /*
  136. * View
  137. */
  138. $form = new Form($db);
  139. $formfile = new FormFile($db);
  140. $formproject = new FormProjets($db);
  141. $title = $langs->trans("Target");
  142. $help_url = '';
  143. llxHeader('', $title, $help_url);
  144. // Example : Adding jquery code
  145. // print '<script type="text/javascript">
  146. // jQuery(document).ready(function() {
  147. // function init_myfunc()
  148. // {
  149. // jQuery("#myid").removeAttr(\'disabled\');
  150. // jQuery("#myid").attr(\'disabled\',\'disabled\');
  151. // }
  152. // init_myfunc();
  153. // jQuery("#mybutton").click(function() {
  154. // init_myfunc();
  155. // });
  156. // });
  157. // </script>';
  158. // Part to create
  159. if ($action == 'create') {
  160. if (empty($permissiontoadd)) {
  161. accessforbidden('NotEnoughPermissions', 0, 1);
  162. exit;
  163. }
  164. print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Target")), '', 'object_'.$object->picto);
  165. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  166. print '<input type="hidden" name="token" value="'.newToken().'">';
  167. print '<input type="hidden" name="action" value="add">';
  168. if ($backtopage) {
  169. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  170. }
  171. if ($backtopageforcancel) {
  172. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  173. }
  174. print dol_get_fiche_head(array(), '');
  175. // Set some default values
  176. //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
  177. print '<table class="border centpercent tableforfieldcreate">'."\n";
  178. // Common attributes
  179. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
  180. // Other attributes
  181. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  182. print '</table>'."\n";
  183. print dol_get_fiche_end();
  184. print $form->buttonsSaveCancel("Create");
  185. print '</form>';
  186. //dol_set_focus('input[name="ref"]');
  187. }
  188. // Part to edit record
  189. if (($id || $ref) && $action == 'edit') {
  190. print load_fiche_titre($langs->trans("Target"), '', 'object_'.$object->picto);
  191. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  192. print '<input type="hidden" name="token" value="'.newToken().'">';
  193. print '<input type="hidden" name="action" value="update">';
  194. print '<input type="hidden" name="id" value="'.$object->id.'">';
  195. if ($backtopage) {
  196. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  197. }
  198. if ($backtopageforcancel) {
  199. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  200. }
  201. print dol_get_fiche_head();
  202. print '<table class="border centpercent tableforfieldedit">'."\n";
  203. // Common attributes
  204. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
  205. // Other attributes
  206. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
  207. print '</table>';
  208. print dol_get_fiche_end();
  209. print $form->buttonsSaveCancel();
  210. print '</form>';
  211. }
  212. // Part to show record
  213. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  214. $res = $object->fetch_optionals();
  215. $head = targetPrepareHead($object);
  216. print dol_get_fiche_head($head, 'card', $langs->trans("Target"), -1, $object->picto);
  217. $formconfirm = '';
  218. // Confirmation to delete
  219. if ($action == 'delete') {
  220. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteTarget'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  221. }
  222. // Confirmation to delete line
  223. if ($action == 'deleteline') {
  224. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
  225. }
  226. // Clone confirmation
  227. if ($action == 'clone') {
  228. // Create an array for form
  229. $formquestion = array();
  230. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  231. }
  232. // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
  233. if ($action == 'xxx') {
  234. $text = $langs->trans('ConfirmActionTarget', $object->ref);
  235. /*if (isModEnabled('notification'))
  236. {
  237. require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
  238. $notify = new Notify($db);
  239. $text .= '<br>';
  240. $text .= $notify->confirmMessage('TARGET_CLOSE', $object->socid, $object);
  241. }*/
  242. $formquestion = array();
  243. /*
  244. $forcecombo=0;
  245. if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
  246. $formquestion = array(
  247. // 'text' => $langs->trans("ConfirmClone"),
  248. // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
  249. // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
  250. // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
  251. );
  252. */
  253. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
  254. }
  255. // Call Hook formConfirm
  256. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  257. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  258. if (empty($reshook)) {
  259. $formconfirm .= $hookmanager->resPrint;
  260. } elseif ($reshook > 0) {
  261. $formconfirm = $hookmanager->resPrint;
  262. }
  263. // Print form confirm
  264. print $formconfirm;
  265. // Object card
  266. // ------------------------------------------------------------
  267. $linkback = '<a href="'.dol_buildpath('/webhook/target_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  268. $morehtmlref = '<div class="refidno">';
  269. /*
  270. // Ref customer
  271. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  272. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  273. // Thirdparty
  274. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  275. // Project
  276. if (isModEnabled('projet')) {
  277. $langs->load("projects");
  278. $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
  279. if ($permissiontoadd) {
  280. //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
  281. $morehtmlref .= ' : ';
  282. if ($action == 'classify') {
  283. //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
  284. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  285. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  286. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  287. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  288. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  289. $morehtmlref .= '</form>';
  290. } else {
  291. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  292. }
  293. } else {
  294. if (!empty($object->fk_project)) {
  295. $proj = new Project($db);
  296. $proj->fetch($object->fk_project);
  297. $morehtmlref .= ': '.$proj->getNomUrl();
  298. } else {
  299. $morehtmlref .= '';
  300. }
  301. }
  302. }*/
  303. $morehtmlref .= '</div>';
  304. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  305. print '<div class="fichecenter">';
  306. print '<div class="fichehalfleft">';
  307. print '<div class="underbanner clearboth"></div>';
  308. print '<table class="border centpercent tableforfield">'."\n";
  309. // Common attributes
  310. //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
  311. //unset($object->fields['fk_project']); // Hide field already shown in banner
  312. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  313. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  314. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  315. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  316. print '</table>';
  317. print '</div>';
  318. print '</div>';
  319. print '<div class="clearboth"></div>';
  320. print dol_get_fiche_end();
  321. /*
  322. * Lines
  323. */
  324. if (!empty($object->table_element_line)) {
  325. // Show object lines
  326. $result = $object->getLinesArray();
  327. print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
  328. <input type="hidden" name="token" value="' . newToken().'">
  329. <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
  330. <input type="hidden" name="mode" value="">
  331. <input type="hidden" name="page_y" value="">
  332. <input type="hidden" name="id" value="' . $object->id.'">
  333. ';
  334. if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
  335. include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  336. }
  337. print '<div class="div-table-responsive-no-min">';
  338. if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
  339. print '<table id="tablelines" class="noborder noshadow" width="100%">';
  340. }
  341. if (!empty($object->lines)) {
  342. $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
  343. }
  344. // Form to add new line
  345. if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
  346. if ($action != 'editline') {
  347. // Add products/services form
  348. $parameters = array();
  349. $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  350. if ($reshook < 0) {
  351. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  352. }
  353. if (empty($reshook)) {
  354. $object->formAddObjectLine(1, $mysoc, $soc);
  355. }
  356. }
  357. }
  358. if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
  359. print '</table>';
  360. }
  361. print '</div>';
  362. print "</form>\n";
  363. }
  364. // Buttons for actions
  365. if ($action != 'presend' && $action != 'editline') {
  366. print '<div class="tabsAction">'."\n";
  367. $parameters = array();
  368. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  369. if ($reshook < 0) {
  370. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  371. }
  372. if (empty($reshook)) {
  373. // Send
  374. /*if (empty($user->socid)) {
  375. print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
  376. }*/
  377. print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
  378. // Disable
  379. if ($object->status == $object::STATUS_VALIDATED) {
  380. print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
  381. }
  382. // Enable
  383. if ($object->status == $object::STATUS_DRAFT) {
  384. print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
  385. }
  386. // Clone
  387. print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken(), '', $permissiontoadd);
  388. /*
  389. if ($permissiontoadd) {
  390. if ($object->status == $object::STATUS_ENABLED) {
  391. print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
  392. } else {
  393. print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
  394. }
  395. }
  396. if ($permissiontoadd) {
  397. if ($object->status == $object::STATUS_VALIDATED) {
  398. print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
  399. } else {
  400. print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
  401. }
  402. }
  403. */
  404. // Delete (need delete permission, or if draft, just need create/modify permission)
  405. print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete);
  406. }
  407. print '</div>'."\n";
  408. }
  409. }
  410. // End of page
  411. llxFooter();
  412. $db->close();