agenda.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. /* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/projet/agenda.php
  20. * \ingroup project
  21. * \brief Page with events on project
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. // Load translation files required by the page
  30. $langs->load("projects");
  31. $id = GETPOST('id', 'int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $socid = GETPOST('socid', 'int');
  34. $action = GETPOST('action', 'aZ09');
  35. $contextpage = GETPOST('contextpage', 'aZ09');
  36. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  37. $sortfield = GETPOST("sortfield", "aZ09comma");
  38. $sortorder = GETPOST("sortorder", 'aZ09comma');
  39. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  40. $page = is_numeric($page) ? $page : 0;
  41. $page = $page == -1 ? 0 : $page;
  42. if (!$sortfield) {
  43. $sortfield = "a.datep,a.id";
  44. }
  45. if (!$sortorder) {
  46. $sortorder = "DESC";
  47. }
  48. $offset = $limit * $page;
  49. $pageprev = $page - 1;
  50. $pagenext = $page + 1;
  51. if (GETPOST('actioncode', 'array')) {
  52. $actioncode = GETPOST('actioncode', 'array', 3);
  53. if (!count($actioncode)) {
  54. $actioncode = '0';
  55. }
  56. } else {
  57. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
  58. }
  59. $search_rowid = GETPOST('search_rowid');
  60. $search_agenda_label = GETPOST('search_agenda_label');
  61. $hookmanager->initHooks(array('projectcardinfo'));
  62. // Security check
  63. $id = GETPOST("id", 'int');
  64. $socid = 0;
  65. //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  66. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  67. if (!$user->rights->projet->lire) {
  68. accessforbidden();
  69. }
  70. /*
  71. * Actions
  72. */
  73. $parameters = array('id'=>$socid);
  74. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  75. if ($reshook < 0) {
  76. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  77. }
  78. // Purge search criteria
  79. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  80. $actioncode = '';
  81. $search_agenda_label = '';
  82. }
  83. /*
  84. * View
  85. */
  86. $form = new Form($db);
  87. $object = new Project($db);
  88. if ($id > 0 || !empty($ref)) {
  89. $object->fetch($id, $ref);
  90. $object->fetch_thirdparty();
  91. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  92. $object->fetchComments();
  93. }
  94. $object->info($object->id);
  95. }
  96. $agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/'.$langs->trans("Agenda") : '';
  97. $title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name;
  98. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  99. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  100. }
  101. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  102. llxHeader("", $title, $help_url);
  103. $head = project_prepare_head($object);
  104. print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  105. // Project card
  106. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  107. $morehtmlref = '<div class="refidno">';
  108. // Title
  109. $morehtmlref .= $object->title;
  110. // Thirdparty
  111. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  112. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
  113. }
  114. $morehtmlref .= '</div>';
  115. // Define a complementary filter for search of next/prev ref.
  116. if (empty($user->rights->projet->all->lire)) {
  117. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  118. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  119. }
  120. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  121. print '<div class="fichecenter">';
  122. print '<div class="underbanner clearboth"></div>';
  123. dol_print_object_info($object, 1);
  124. print '</div>';
  125. print '<div class="clearboth"></div>';
  126. print dol_get_fiche_end();
  127. // Actions buttons
  128. $out = '';
  129. $permok = $user->hasRight('agenda', 'myactions', 'create');
  130. if ($permok) {
  131. $out .= '&projectid='.$object->id;
  132. }
  133. //print '</div>';
  134. if (!empty($object->id)) {
  135. print '<br>';
  136. //print '<div class="tabsAction">';
  137. $morehtmlright = '';
  138. // Show link to change view in message
  139. $messagingUrl = DOL_URL_ROOT.'/projet/messaging.php?id='.$object->id;
  140. $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
  141. // Show link to change view in agenda
  142. $messagingUrl = DOL_URL_ROOT.'/projet/agenda.php?id='.$object->id;
  143. $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
  144. // // Show link to send an email (if read and not closed)
  145. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  146. // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
  147. // $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus);
  148. // // Show link to add a private message (if read and not closed)
  149. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  150. // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
  151. // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
  152. // Show link to add event
  153. if (isModEnabled('agenda')) {
  154. $addActionBtnRight = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
  155. $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight);
  156. }
  157. $param = '&id='.$object->id;
  158. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  159. $param .= '&contextpage='.$contextpage;
  160. }
  161. if ($limit > 0 && $limit != $conf->liste_limit) {
  162. $param .= '&limit='.$limit;
  163. }
  164. print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
  165. // List of all actions
  166. $filters = array();
  167. $filters['search_agenda_label'] = $search_agenda_label;
  168. $filters['search_rowid'] = $search_rowid;
  169. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  170. }
  171. // End of page
  172. llxFooter();
  173. $db->close();