note.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?php
  2. /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/projet/tasks/note.php
  19. * \ingroup project
  20. * \brief Page to show information on a task
  21. */
  22. require "../../main.inc.php";
  23. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  24. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  26. // Load translation files required by the page
  27. $langs->load('projects');
  28. $action = GETPOST('action', 'aZ09');
  29. $confirm = GETPOST('confirm', 'alpha');
  30. $mine = GETPOST('mode') == 'mine' ? 1 : 0;
  31. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  32. $id = GETPOST('id', 'int');
  33. $ref = GETPOST('ref', 'alpha');
  34. $withproject = GETPOST('withproject', 'int');
  35. $project_ref = GETPOST('project_ref', 'alpha');
  36. // Security check
  37. $socid = 0;
  38. //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.
  39. if (!$user->hasRight('projet', 'lire')) {
  40. accessforbidden();
  41. }
  42. $hookmanager->initHooks(array('projettasknote'));
  43. $object = new Task($db);
  44. $projectstatic = new Project($db);
  45. if ($id > 0 || !empty($ref)) {
  46. if ($object->fetch($id, $ref) > 0) {
  47. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  48. $object->fetchComments();
  49. }
  50. $projectstatic->fetch($object->fk_project);
  51. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
  52. $projectstatic->fetchComments();
  53. }
  54. if (!empty($projectstatic->socid)) {
  55. $projectstatic->fetch_thirdparty();
  56. }
  57. $object->project = clone $projectstatic;
  58. } else {
  59. dol_print_error($db);
  60. }
  61. }
  62. // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
  63. if (!empty($project_ref) && !empty($withproject)) {
  64. if ($projectstatic->fetch(0, $project_ref) > 0) {
  65. $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
  66. if (count($tasksarray) > 0) {
  67. $id = $tasksarray[0]->id;
  68. $object->fetch($id);
  69. } else {
  70. header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
  71. }
  72. }
  73. }
  74. if ($id > 0 || $ref) {
  75. $object->fetch($id, $ref);
  76. }
  77. //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
  78. restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
  79. $permissionnote = ($user->hasRight('projet', 'creer') || $user->hasRight('projet', 'all', 'creer'));
  80. /*
  81. * Actions
  82. */
  83. $parameters = array();
  84. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  85. if ($reshook < 0) {
  86. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  87. }
  88. if (empty($reshook)) {
  89. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  90. }
  91. /*
  92. * View
  93. */
  94. $form = new Form($db);
  95. $userstatic = new User($db);
  96. $now = dol_now();
  97. $title = $object->ref . ' - ' . $langs->trans("Notes");
  98. if (!empty($withproject)) {
  99. $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
  100. }
  101. $help_url = '';
  102. llxHeader('', $title, $help_url);
  103. if ($object->id > 0) {
  104. $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
  105. if (!empty($withproject)) {
  106. // Tabs for project
  107. $tab = 'tasks';
  108. $head = project_prepare_head($projectstatic);
  109. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
  110. $param = (isset($mode) && $mode == 'mine' ? '&mode=mine' : '');
  111. // Project card
  112. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  113. $morehtmlref = '<div class="refidno">';
  114. // Title
  115. $morehtmlref .= $projectstatic->title;
  116. // Thirdparty
  117. if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
  118. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  119. }
  120. $morehtmlref .= '</div>';
  121. // Define a complementary filter for search of next/prev ref.
  122. if (!$user->hasRight('projet', 'all', 'lire')) {
  123. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  124. $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  125. }
  126. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  127. print '<div class="fichecenter">';
  128. print '<div class="fichehalfleft">';
  129. print '<div class="underbanner clearboth"></div>';
  130. print '<table class="border tableforfield centpercent">';
  131. // Usage
  132. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
  133. print '<tr><td class="tdtop">';
  134. print $langs->trans("Usage");
  135. print '</td>';
  136. print '<td>';
  137. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  138. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  139. $htmltext = $langs->trans("ProjectFollowOpportunity");
  140. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  141. print '<br>';
  142. }
  143. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  144. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  145. $htmltext = $langs->trans("ProjectFollowTasks");
  146. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  147. print '<br>';
  148. }
  149. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  150. print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
  151. $htmltext = $langs->trans("ProjectBillTimeDescription");
  152. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  153. print '<br>';
  154. }
  155. if (isModEnabled('eventorganization')) {
  156. print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> ';
  157. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  158. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  159. }
  160. print '</td></tr>';
  161. }
  162. // Visibility
  163. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  164. if ($projectstatic->public) {
  165. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  166. print $langs->trans('SharedProject');
  167. } else {
  168. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  169. print $langs->trans('PrivateProject');
  170. }
  171. print '</td></tr>';
  172. // Budget
  173. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  174. if (strcmp($projectstatic->budget_amount, '')) {
  175. print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  176. }
  177. print '</td></tr>';
  178. // Date start - end project
  179. print '<tr><td>'.$langs->trans("Dates").'</td><td>';
  180. $start = dol_print_date($projectstatic->date_start, 'day');
  181. print ($start ? $start : '?');
  182. $end = dol_print_date($projectstatic->date_end, 'day');
  183. print ' - ';
  184. print ($end ? $end : '?');
  185. if ($projectstatic->hasDelay()) {
  186. print img_warning("Late");
  187. }
  188. print '</td></tr>';
  189. // Other attributes
  190. $cols = 2;
  191. //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  192. print '</table>';
  193. print '</div>';
  194. print '<div class="fichehalfright">';
  195. print '<div class="underbanner clearboth"></div>';
  196. print '<table class="border centpercent tableforfield">';
  197. // Description
  198. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  199. print nl2br($projectstatic->description);
  200. print '</td></tr>';
  201. // Categories
  202. if (isModEnabled('categorie')) {
  203. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  204. print $form->showCategories($projectstatic->id, 'project', 1);
  205. print "</td></tr>";
  206. }
  207. print '</table>';
  208. print '</div>';
  209. print '</div>';
  210. print '<div class="clearboth"></div>';
  211. print dol_get_fiche_end();
  212. print '<br>';
  213. }
  214. $head = task_prepare_head($object);
  215. print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
  216. $param = (GETPOST('withproject') ? '&withproject=1' : '');
  217. $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
  218. if (!GETPOST('withproject') || empty($projectstatic->id)) {
  219. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
  220. $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
  221. } else {
  222. $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
  223. }
  224. $morehtmlref = '';
  225. // Project
  226. if (empty($withproject)) {
  227. $morehtmlref .= '<div class="refidno">';
  228. $morehtmlref .= $langs->trans("Project").': ';
  229. $morehtmlref .= $projectstatic->getNomUrl(1);
  230. $morehtmlref .= '<br>';
  231. // Third party
  232. $morehtmlref .= $langs->trans("ThirdParty").': ';
  233. $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
  234. $morehtmlref .= '</div>';
  235. }
  236. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
  237. print '<div class="fichecenter">';
  238. print '<div class="underbanner clearboth"></div>';
  239. $cssclass = 'titlefield';
  240. $moreparam = $param;
  241. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  242. print '</div>';
  243. print dol_get_fiche_end();
  244. }
  245. // End of page
  246. llxFooter();
  247. $db->close();