note.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
  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/note.php
  20. * \ingroup project
  21. * \brief Fiche d'information sur un projet
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  27. // Load translation files required by the page
  28. $langs->load('projects');
  29. $action = GETPOST('action', 'aZ09');
  30. $id = GETPOST('id', 'int');
  31. $ref = GETPOST('ref', 'alpha');
  32. $mine = (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mine') ? 1 : 0;
  33. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  34. $object = new Project($db);
  35. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
  36. if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
  37. $object->fetchComments();
  38. }
  39. // Security check
  40. $socid = 0;
  41. //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.
  42. $hookmanager->initHooks(array('projetnote'));
  43. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  44. $permissionnote = $user->hasRight('projet', 'creer'); // Used by the include of actions_setnotes.inc.php
  45. /*
  46. * Actions
  47. */
  48. $parameters = array();
  49. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  50. if ($reshook < 0) {
  51. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  52. }
  53. if (empty($reshook)) {
  54. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  55. }
  56. /*
  57. * View
  58. */
  59. $title = $langs->trans("Notes").' - '.$object->ref.' '.$object->name;
  60. if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  61. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note");
  62. }
  63. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  64. llxHeader("", $title, $help_url);
  65. $form = new Form($db);
  66. $userstatic = new User($db);
  67. $now = dol_now();
  68. if ($id > 0 || !empty($ref)) {
  69. // To verify role of users
  70. //$userAccess = $object->restrictedProjectArea($user,'read');
  71. $userWrite = $object->restrictedProjectArea($user, 'write');
  72. //$userDelete = $object->restrictedProjectArea($user,'delete');
  73. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  74. $head = project_prepare_head($object);
  75. print dol_get_fiche_head($head, 'notes', $langs->trans('Project'), -1, ($object->public ? 'projectpub' : 'project'));
  76. // Project card
  77. if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
  78. $tmpurl = $_SESSION['pageforbacktolist']['project'];
  79. $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
  80. $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  81. } else {
  82. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  83. }
  84. $morehtmlref = '<div class="refidno">';
  85. // Title
  86. $morehtmlref .= $object->title;
  87. // Thirdparty
  88. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  89. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
  90. }
  91. $morehtmlref .= '</div>';
  92. // Define a complementary filter for search of next/prev ref.
  93. if (!$user->hasRight('projet', 'all', 'lire')) {
  94. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  95. $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
  96. }
  97. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  98. print '<div class="fichecenter">';
  99. print '<div class="underbanner clearboth"></div>';
  100. $cssclass = "titlefield";
  101. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  102. print '</div>';
  103. print '<div class="clearboth"></div>';
  104. print dol_get_fiche_end();
  105. }
  106. // End of page
  107. llxFooter();
  108. $db->close();