comment.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/comment.php
  21. * \ingroup project
  22. * \brief Page of a project
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('projects', 'companies'));
  37. $id = GETPOST('id', 'int');
  38. $idcomment = GETPOST('idcomment', 'int');
  39. $ref = GETPOST("ref", 'alpha', 1); // task ref
  40. $objectref = GETPOST("taskref", 'alpha'); // task ref
  41. $action = GETPOST('action', 'aZ09');
  42. $confirm = GETPOST('confirm', 'alpha');
  43. $withproject = GETPOST('withproject', 'int');
  44. // Security check
  45. $socid = 0;
  46. //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.
  47. if (!$user->hasRight('projet', 'lire')) {
  48. accessforbidden();
  49. }
  50. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  51. $hookmanager->initHooks(array('projectcard', 'globalcard'));
  52. $extrafields = new ExtraFields($db);
  53. $object = new Project($db);
  54. // fetch optionals attributes and labels
  55. $extrafields->fetch_name_optionals_label($object->table_element);
  56. // Load object
  57. if ($id > 0 || !empty($ref)) {
  58. $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
  59. if ($ret > 0) {
  60. $object->fetch_thirdparty();
  61. if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
  62. $object->fetchComments();
  63. }
  64. $id = $object->id;
  65. }
  66. }
  67. // include comment actions
  68. include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
  69. /*
  70. * View
  71. */
  72. $title = $langs->trans('CommentPage');
  73. llxHeader('', $title, '');
  74. $form = new Form($db);
  75. $formother = new FormOther($db);
  76. $formfile = new FormFile($db);
  77. // Tabs for project
  78. $tab = 'project_comment';
  79. $head = project_prepare_head($object);
  80. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
  81. $param = ($mode == 'mine' ? '&mode=mine' : '');
  82. // Project card
  83. if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
  84. $tmpurl = $_SESSION['pageforbacktolist']['project'];
  85. $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
  86. $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  87. } else {
  88. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  89. }
  90. $morehtmlref = '<div class="refidno">';
  91. // Title
  92. $morehtmlref .= $object->title;
  93. // Thirdparty
  94. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  95. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
  96. }
  97. $morehtmlref .= '</div>';
  98. // Define a complementary filter for search of next/prev ref.
  99. if (!$user->hasRight('projet', 'all', 'lire')) {
  100. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  101. $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
  102. }
  103. dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  104. print '<div class="fichecenter">';
  105. print '<div class="fichehalfleft">';
  106. print '<div class="underbanner clearboth"></div>';
  107. print '<table class="border centpercent">';
  108. // Visibility
  109. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  110. if ($object->public) {
  111. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  112. print $langs->trans('SharedProject');
  113. } else {
  114. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  115. print $langs->trans('PrivateProject');
  116. }
  117. print '</td></tr>';
  118. // Budget
  119. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  120. if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
  121. print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  122. }
  123. print '</td></tr>';
  124. // Date start - end project
  125. print '<tr><td>'.$langs->trans("Dates").'</td><td>';
  126. print dol_print_date($object->date_start, 'day');
  127. $end = dol_print_date($object->date_end, 'day');
  128. if ($end) {
  129. print ' - '.$end;
  130. }
  131. print '</td></tr>';
  132. // Other attributes
  133. $cols = 2;
  134. // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  135. print '</table>';
  136. print '</div>';
  137. print '<div class="fichehalfright">';
  138. print '<div class="underbanner clearboth"></div>';
  139. print '<table class="border centpercent">';
  140. // Description
  141. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  142. print nl2br($object->description);
  143. print '</td></tr>';
  144. // Categories
  145. if (isModEnabled('categorie')) {
  146. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  147. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  148. print "</td></tr>";
  149. }
  150. // Nb comments
  151. print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
  152. print $object->getNbComments();
  153. print '</td></tr>';
  154. print '</table>';
  155. print '</div>';
  156. print '</div>';
  157. print '<div class="clearboth"></div>';
  158. print dol_get_fiche_end();
  159. print '<br>';
  160. // Include comment tpl view
  161. include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
  162. // End of page
  163. llxFooter();
  164. $db->close();