info.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. // Security check
  59. $id = GETPOST("id", 'int');
  60. $socid = 0;
  61. //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.
  62. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  63. if (!$user->rights->projet->lire) {
  64. accessforbidden();
  65. }
  66. /*
  67. * Actions
  68. */
  69. $parameters = array('id'=>$socid);
  70. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  71. if ($reshook < 0) {
  72. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  73. }
  74. // Purge search criteria
  75. 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
  76. $actioncode = '';
  77. $search_agenda_label = '';
  78. }
  79. /*
  80. * View
  81. */
  82. $form = new Form($db);
  83. $object = new Project($db);
  84. if ($id > 0 || !empty($ref)) {
  85. $object->fetch($id, $ref);
  86. $object->fetch_thirdparty();
  87. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  88. $object->fetchComments();
  89. }
  90. $object->info($object->id);
  91. }
  92. $title = $langs->trans("Project").' - '.$object->ref.' '.$object->name;
  93. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  94. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  95. }
  96. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  97. llxHeader("", $title, $help_url);
  98. $head = project_prepare_head($object);
  99. print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  100. // Project card
  101. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  102. $morehtmlref = '<div class="refidno">';
  103. // Title
  104. $morehtmlref .= $object->title;
  105. // Thirdparty
  106. if ($object->thirdparty->id > 0) {
  107. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  108. }
  109. $morehtmlref .= '</div>';
  110. // Define a complementary filter for search of next/prev ref.
  111. if (!$user->rights->projet->all->lire) {
  112. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  113. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  114. }
  115. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  116. print '<div class="fichecenter">';
  117. print '<div class="underbanner clearboth"></div>';
  118. dol_print_object_info($object, 1);
  119. print '</div>';
  120. print '<div class="clearboth"></div>';
  121. print dol_get_fiche_end();
  122. // Actions buttons
  123. $out = '';
  124. $permok = $user->rights->agenda->myactions->create;
  125. if ($permok) {
  126. $out .= '&projectid='.$object->id;
  127. }
  128. //print '<div class="tabsAction">';
  129. $morehtmlcenter = '';
  130. if (!empty($conf->agenda->enabled)) {
  131. $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
  132. $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);
  133. }
  134. //print '</div>';
  135. if (!empty($object->id)) {
  136. print '<br>';
  137. $param = '&id='.$object->id;
  138. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  139. $param .= '&contextpage='.$contextpage;
  140. }
  141. if ($limit > 0 && $limit != $conf->liste_limit) {
  142. $param .= '&limit='.$limit;
  143. }
  144. print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  145. // List of all actions
  146. $filters = array();
  147. $filters['search_agenda_label'] = $search_agenda_label;
  148. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  149. }
  150. // End of page
  151. llxFooter();
  152. $db->close();