comment.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 <http://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','alpha');
  41. $confirm=GETPOST('confirm','alpha');
  42. $withproject=GETPOST('withproject','int');
  43. $project_ref=GETPOST('project_ref','alpha');
  44. $planned_workload=((GETPOST('planned_workloadhour','int')!='' || GETPOST('planned_workloadmin','int')!='') ? (GETPOST('planned_workloadhour','int')>0?GETPOST('planned_workloadhour','int')*3600:0) + (GETPOST('planned_workloadmin','int')>0?GETPOST('planned_workloadmin','int')*60:0) : '');
  45. // Security check
  46. $socid=0;
  47. //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  48. if (! $user->rights->projet->lire) accessforbidden();
  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. $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
  55. // Load object
  56. if ($id > 0 || ! empty($ref))
  57. {
  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(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
  62. $id=$object->id;
  63. }
  64. }
  65. // include comment actions
  66. include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php';
  67. /*
  68. * View
  69. */
  70. llxHeader('', $langs->trans("CommentPage"));
  71. $form = new Form($db);
  72. $formother = new FormOther($db);
  73. $formfile = new FormFile($db);
  74. // Tabs for project
  75. $tab = 'project_comment';
  76. $head = project_prepare_head($object);
  77. dol_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
  78. $param = ($mode == 'mine' ? '&mode=mine' : '');
  79. // Project card
  80. $linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
  81. $morehtmlref = '<div class="refidno">';
  82. // Title
  83. $morehtmlref .= $object->title;
  84. // Thirdparty
  85. if ($object->thirdparty->id > 0) {
  86. $morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
  87. }
  88. $morehtmlref .= '</div>';
  89. // Define a complementary filter for search of next/prev ref.
  90. if (! $user->rights->projet->all->lire) {
  91. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  92. $object->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")";
  93. }
  94. dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  95. print '<div class="fichecenter">';
  96. print '<div class="fichehalfleft">';
  97. print '<div class="underbanner clearboth"></div>';
  98. print '<table class="border" width="100%">';
  99. // Visibility
  100. print '<tr><td class="titlefield">' . $langs->trans("Visibility") . '</td><td>';
  101. if ($object->public) print $langs->trans('SharedProject');
  102. else
  103. print $langs->trans('PrivateProject');
  104. print '</td></tr>';
  105. // Date start - end
  106. print '<tr><td>' . $langs->trans("DateStart") . ' - ' . $langs->trans("DateEnd") . '</td><td>';
  107. print dol_print_date($object->date_start, 'day');
  108. $end = dol_print_date($object->date_end, 'day');
  109. if ($end) print ' - ' . $end;
  110. print '</td></tr>';
  111. // Budget
  112. print '<tr><td>' . $langs->trans("Budget") . '</td><td>';
  113. if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  114. print '</td></tr>';
  115. // Other attributes
  116. $cols = 2;
  117. // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  118. print '</table>';
  119. print '</div>';
  120. print '<div class="fichehalfright">';
  121. print '<div class="ficheaddleft">';
  122. print '<div class="underbanner clearboth"></div>';
  123. print '<table class="border" width="100%">';
  124. // Description
  125. print '<td class="titlefield tdtop">' . $langs->trans("Description") . '</td><td>';
  126. print nl2br($object->description);
  127. print '</td></tr>';
  128. // Categories
  129. if ($conf->categorie->enabled) {
  130. print '<tr><td valign="middle">' . $langs->trans("Categories") . '</td><td>';
  131. print $form->showCategories($object->id, 'project', 1);
  132. print "</td></tr>";
  133. }
  134. // Nb comments
  135. print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
  136. print $object->getNbComments();
  137. print '</td></tr>';
  138. print '</table>';
  139. print '</div>';
  140. print '</div>';
  141. print '</div>';
  142. print '<div class="clearboth"></div>';
  143. dol_fiche_end();
  144. print '<br>';
  145. // Include comment tpl view
  146. include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php';
  147. // End of page
  148. llxFooter();
  149. $db->close();