comment.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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/tasks/task.php
  21. * \ingroup project
  22. * \brief Page of a project task
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('projects', 'companies'));
  36. $id = GETPOST('id', 'int');
  37. $idcomment = GETPOST('idcomment', 'int');
  38. $ref = GETPOST("ref", 'alpha', 1); // task ref
  39. $objectref = GETPOST("taskref", 'alpha'); // task ref
  40. $action = GETPOST('action', 'aZ09');
  41. $confirm = GETPOST('confirm', 'alpha');
  42. $withproject = GETPOST('withproject', 'int');
  43. // Security check
  44. $socid = 0;
  45. //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.
  46. if (!$user->rights->projet->lire) {
  47. accessforbidden();
  48. }
  49. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  50. $hookmanager->initHooks(array('projectcard', 'globalcard'));
  51. $extrafields = new ExtraFields($db);
  52. $object = new Project($db);
  53. // fetch optionals attributes and labels
  54. $extrafields->fetch_name_optionals_label($object->table_element);
  55. // Load object
  56. if ($id > 0 || !empty($ref)) {
  57. $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
  58. if ($ret > 0) {
  59. $object->fetch_thirdparty();
  60. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  61. $object->fetchComments();
  62. }
  63. $id = $object->id;
  64. }
  65. }
  66. // include comment actions
  67. include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
  68. /*
  69. * View
  70. */
  71. $title = $langs->trans('CommentPage');
  72. llxHeader('', $title, '');
  73. $form = new Form($db);
  74. $formother = new FormOther($db);
  75. $formfile = new FormFile($db);
  76. // Tabs for project
  77. $tab = 'project_comment';
  78. $head = project_prepare_head($object);
  79. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
  80. $param = ($mode == 'mine' ? '&mode=mine' : '');
  81. // Project card
  82. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  83. $morehtmlref = '<div class="refidno">';
  84. // Title
  85. $morehtmlref .= $object->title;
  86. // Thirdparty
  87. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  88. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  89. }
  90. $morehtmlref .= '</div>';
  91. // Define a complementary filter for search of next/prev ref.
  92. if (empty($user->rights->projet->all->lire)) {
  93. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  94. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
  95. }
  96. dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  97. print '<div class="fichecenter">';
  98. print '<div class="fichehalfleft">';
  99. print '<div class="underbanner clearboth"></div>';
  100. print '<table class="border centpercent">';
  101. // Visibility
  102. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  103. if ($object->public) {
  104. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  105. print $langs->trans('SharedProject');
  106. } else {
  107. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  108. print $langs->trans('PrivateProject');
  109. }
  110. print '</td></tr>';
  111. // Date start - end
  112. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  113. print dol_print_date($object->date_start, 'day');
  114. $end = dol_print_date($object->date_end, 'day');
  115. if ($end) {
  116. print ' - '.$end;
  117. }
  118. print '</td></tr>';
  119. // Budget
  120. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  121. if (strcmp($object->budget_amount, '')) {
  122. print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  123. }
  124. print '</td></tr>';
  125. // Other attributes
  126. $cols = 2;
  127. // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  128. print '</table>';
  129. print '</div>';
  130. print '<div class="fichehalfright">';
  131. print '<div class="underbanner clearboth"></div>';
  132. print '<table class="border centpercent">';
  133. // Description
  134. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  135. print nl2br($object->description);
  136. print '</td></tr>';
  137. // Categories
  138. if (isModEnabled('categorie')) {
  139. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  140. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  141. print "</td></tr>";
  142. }
  143. // Nb comments
  144. print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
  145. print $object->getNbComments();
  146. print '</td></tr>';
  147. print '</table>';
  148. print '</div>';
  149. print '</div>';
  150. print '<div class="clearboth"></div>';
  151. print dol_get_fiche_end();
  152. print '<br>';
  153. // Include comment tpl view
  154. include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
  155. // End of page
  156. llxFooter();
  157. $db->close();