agenda.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 <http://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. if (GETPOST('actioncode','array'))
  37. {
  38. $actioncode=GETPOST('actioncode','array',3);
  39. if (! count($actioncode)) $actioncode='0';
  40. }
  41. else
  42. {
  43. $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));
  44. }
  45. $search_agenda_label=GETPOST('search_agenda_label');
  46. // Security check
  47. $id = GETPOST('id','int');
  48. $ref = GETPOST('ref', 'alpha');
  49. if ($user->societe_id) $id=$user->societe_id;
  50. // Protection if external user
  51. if ($user->socid > 0)
  52. {
  53. accessforbidden();
  54. }
  55. if( ! $user->rights->resource->read)
  56. {
  57. accessforbidden();
  58. }
  59. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  60. $sortfield = GETPOST("sortfield",'alpha');
  61. $sortorder = GETPOST("sortorder",'alpha');
  62. $page = GETPOST("page",'int');
  63. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  64. $offset = $limit * $page;
  65. $pageprev = $page - 1;
  66. $pagenext = $page + 1;
  67. if (! $sortfield) $sortfield='a.datep,a.id';
  68. if (! $sortorder) $sortorder='DESC,DESC';
  69. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  70. $hookmanager->initHooks(array('agendaresource'));
  71. /*
  72. * Actions
  73. */
  74. $parameters=array('id'=>$id);
  75. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  76. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  77. if (empty($reshook))
  78. {
  79. // Cancel
  80. if (GETPOST('cancel','alpha') && ! empty($backtopage))
  81. {
  82. header("Location: ".$backtopage);
  83. exit;
  84. }
  85. // Purge search criteria
  86. 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
  87. {
  88. $actioncode='';
  89. $search_agenda_label='';
  90. }
  91. }
  92. /*
  93. * View
  94. */
  95. $contactstatic = new Contact($db);
  96. $form = new Form($db);
  97. if ($id > 0 || $ref)
  98. {
  99. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  100. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  101. $langs->load("companies");
  102. $picto = 'resource';
  103. $object = new Dolresource($db);
  104. $result = $object->fetch($id);
  105. $title=$langs->trans("Agenda");
  106. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref." - ".$title;
  107. llxHeader('',$title);
  108. if (! empty($conf->notification->enabled)) $langs->load("mails");
  109. $type = $langs->trans('ResourceSingular');
  110. $head = resource_prepare_head($object);
  111. $titre=$langs->trans("ResourceSingular");
  112. dol_fiche_head($head, 'agenda', $titre, -1, $picto);
  113. $linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  114. $shownav = 1;
  115. if ($user->societe_id && ! in_array('resource', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
  116. dol_banner_tab($object, 'id', $linkback, $shownav, 'id');
  117. print '<div class="fichecenter">';
  118. print '<div class="underbanner clearboth"></div>';
  119. print '</div>';
  120. dol_fiche_end();
  121. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  122. {
  123. print '<br>';
  124. $param='&id='.$id;
  125. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  126. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  127. print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  128. // List of all actions
  129. $filters=array();
  130. $filters['search_agenda_label']=$search_agenda_label;
  131. // TODO Replace this with same code than into list.php
  132. show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  133. }
  134. }
  135. // End of page
  136. llxFooter();
  137. $db->close();