info.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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/info.php
  20. * \ingroup project
  21. * \brief Page with events on project
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. // Load translation files required by the page
  29. $langs->load("projects");
  30. $id = GETPOST('id', 'int');
  31. $ref = GETPOST('ref', 'alpha');
  32. $socid = GETPOST('socid', 'int');
  33. $action = GETPOST('action', 'aZ09');
  34. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  35. $sortfield = GETPOST("sortfield", "aZ09comma");
  36. $sortorder = GETPOST("sortorder", 'aZ09comma');
  37. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  38. $page = is_numeric($page) ? $page : 0;
  39. $page = $page == -1 ? 0 : $page;
  40. if (!$sortfield) {
  41. $sortfield = "a.datep,a.id";
  42. }
  43. if (!$sortorder) {
  44. $sortorder = "DESC";
  45. }
  46. $offset = $limit * $page;
  47. $pageprev = $page - 1;
  48. $pagenext = $page + 1;
  49. if (GETPOST('actioncode', 'array')) {
  50. $actioncode = GETPOST('actioncode', 'array', 3);
  51. if (!count($actioncode)) {
  52. $actioncode = '0';
  53. }
  54. } else {
  55. $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));
  56. }
  57. $search_agenda_label = GETPOST('search_agenda_label');
  58. $hookmanager->initHooks(array('projectcardinfo'));
  59. // Security check
  60. $id = GETPOST("id", 'int');
  61. $socid = 0;
  62. //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.
  63. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  64. if (!$user->rights->projet->lire) {
  65. accessforbidden();
  66. }
  67. /*
  68. * Actions
  69. */
  70. $parameters = array('id'=>$socid);
  71. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  72. if ($reshook < 0) {
  73. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  74. }
  75. // Purge search criteria
  76. 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
  77. $actioncode = '';
  78. $search_agenda_label = '';
  79. }
  80. /*
  81. * View
  82. */
  83. $form = new Form($db);
  84. $object = new Project($db);
  85. if ($id > 0 || !empty($ref)) {
  86. $object->fetch($id, $ref);
  87. $object->fetch_thirdparty();
  88. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  89. $object->fetchComments();
  90. }
  91. $object->info($object->id);
  92. }
  93. $title = $langs->trans("Project").' - '.$object->ref.' '.$object->name;
  94. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  95. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  96. }
  97. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  98. llxHeader("", $title, $help_url);
  99. $head = project_prepare_head($object);
  100. print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  101. // Project card
  102. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  103. $morehtmlref = '<div class="refidno">';
  104. // Title
  105. $morehtmlref .= $object->title;
  106. // Thirdparty
  107. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  108. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  109. }
  110. $morehtmlref .= '</div>';
  111. // Define a complementary filter for search of next/prev ref.
  112. if (empty($user->rights->projet->all->lire)) {
  113. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  114. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  115. }
  116. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  117. print '<div class="fichecenter">';
  118. print '<div class="underbanner clearboth"></div>';
  119. dol_print_object_info($object, 1);
  120. print '</div>';
  121. print '<div class="clearboth"></div>';
  122. print dol_get_fiche_end();
  123. // Actions buttons
  124. $out = '';
  125. $permok = $user->rights->agenda->myactions->create;
  126. if ($permok) {
  127. $out .= '&projectid='.$object->id;
  128. }
  129. //print '<div class="tabsAction">';
  130. $morehtmlcenter = '';
  131. if (isModEnabled('agenda')) {
  132. $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
  133. $morehtmlcenter .= 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);
  134. }
  135. //print '</div>';
  136. if (!empty($object->id)) {
  137. print '<br>';
  138. $param = '&id='.$object->id;
  139. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  140. $param .= '&contextpage='.$contextpage;
  141. }
  142. if ($limit > 0 && $limit != $conf->liste_limit) {
  143. $param .= '&limit='.$limit;
  144. }
  145. print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  146. // List of all actions
  147. $filters = array();
  148. $filters['search_agenda_label'] = $search_agenda_label;
  149. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  150. }
  151. // End of page
  152. llxFooter();
  153. $db->close();