agenda.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2018 Florain Henry <florian.henry@open-concept.pro
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/resource/agenda.php
  26. * \ingroup resource
  27. * \brief Page of resource events
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
  34. // Load translation files required by the page
  35. $langs->load("companies");
  36. // Get parameters
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $cancel = GETPOST('cancel', 'aZ09');
  41. $backtopage = GETPOST('backtopage', 'alpha');
  42. if (GETPOST('actioncode', 'array')) {
  43. $actioncode = GETPOST('actioncode', 'array', 3);
  44. if (!count($actioncode)) {
  45. $actioncode = '0';
  46. }
  47. } else {
  48. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
  49. }
  50. $search_agenda_label = GETPOST('search_agenda_label');
  51. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  52. $sortfield = GETPOST('sortfield', 'aZ09comma');
  53. $sortorder = GETPOST('sortorder', 'aZ09comma');
  54. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  55. if (empty($page) || $page == -1) {
  56. $page = 0;
  57. } // If $page is not defined, or '' or -1
  58. $offset = $limit * $page;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. if (!$sortfield) {
  62. $sortfield = 'a.datep,a.id';
  63. }
  64. if (!$sortorder) {
  65. $sortorder = 'DESC,DESC';
  66. }
  67. // Initialize technical objects
  68. //$object=new MyObject($db);
  69. $extrafields = new ExtraFields($db);
  70. $hookmanager->initHooks(array('agendaresource'));
  71. $object = new DolResource($db);
  72. // Load object
  73. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  74. $result = restrictedArea($user, 'resource', $object->id, 'resource');
  75. // Security check
  76. if (!$user->rights->resource->read) {
  77. accessforbidden();
  78. }
  79. /*
  80. * Actions
  81. */
  82. $parameters = array('id'=>$id);
  83. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  84. if ($reshook < 0) {
  85. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  86. }
  87. if (empty($reshook)) {
  88. // Cancel
  89. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  90. header("Location: ".$backtopage);
  91. exit;
  92. }
  93. // Purge search criteria
  94. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  95. $actioncode = '';
  96. $search_agenda_label = '';
  97. }
  98. }
  99. /*
  100. * View
  101. */
  102. $contactstatic = new Contact($db);
  103. $form = new Form($db);
  104. if ($object->id > 0) {
  105. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  106. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  107. $langs->load("companies");
  108. $picto = 'resource';
  109. $title = $langs->trans("Agenda");
  110. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  111. $title = $object->ref." - ".$title;
  112. }
  113. llxHeader('', $title);
  114. if (!empty($conf->notification->enabled)) {
  115. $langs->load("mails");
  116. }
  117. $type = $langs->trans('ResourceSingular');
  118. $head = resource_prepare_head($object);
  119. $titre = $langs->trans("ResourceSingular");
  120. print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto);
  121. $linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  122. $morehtmlref = '<div class="refidno">';
  123. $morehtmlref .= '</div>';
  124. $shownav = 1;
  125. if ($user->socid && !in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
  126. $shownav = 0;
  127. }
  128. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  129. print '<div class="fichecenter">';
  130. print '<div class="underbanner clearboth"></div>';
  131. print '</div>';
  132. print dol_get_fiche_end();
  133. if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
  134. $param = '&id='.$object->id.'&socid='.$socid;
  135. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  136. $param .= '&contextpage='.urlencode($contextpage);
  137. }
  138. if ($limit > 0 && $limit != $conf->liste_limit) {
  139. $param .= '&limit='.urlencode($limit);
  140. }
  141. print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  142. // List of all actions
  143. $filters = array();
  144. $filters['search_agenda_label'] = $search_agenda_label;
  145. // TODO Replace this with same code than into list.php
  146. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  147. }
  148. }
  149. // End of page
  150. llxFooter();
  151. $db->close();