note.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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->rights->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->rights->projet->creer || $user->rights->projet->all->creer);
  80. /*
  81. * Actions
  82. */
  83. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  84. if ($reshook < 0) {
  85. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  86. }
  87. if (empty($reshook)) {
  88. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  89. }
  90. /*
  91. * View
  92. */
  93. $form = new Form($db);
  94. $userstatic = new User($db);
  95. $now = dol_now();
  96. $title = $object->ref . ' - ' . $langs->trans("Notes");
  97. if (!empty($withproject)) {
  98. $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
  99. }
  100. $help_url = '';
  101. llxHeader('', $title, $help_url);
  102. if ($object->id > 0) {
  103. $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
  104. if (!empty($withproject)) {
  105. // Tabs for project
  106. $tab = 'tasks';
  107. $head = project_prepare_head($projectstatic);
  108. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
  109. $param = ($mode == 'mine' ? '&mode=mine' : '');
  110. // Project card
  111. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  112. $morehtmlref = '<div class="refidno">';
  113. // Title
  114. $morehtmlref .= $projectstatic->title;
  115. // Thirdparty
  116. if ($projectstatic->thirdparty->id > 0) {
  117. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  118. }
  119. $morehtmlref .= '</div>';
  120. // Define a complementary filter for search of next/prev ref.
  121. if (empty($user->rights->projet->all->lire)) {
  122. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  123. $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  124. }
  125. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  126. print '<div class="fichecenter">';
  127. print '<div class="fichehalfleft">';
  128. print '<div class="underbanner clearboth"></div>';
  129. print '<table class="border tableforfield centpercent">';
  130. // Usage
  131. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
  132. print '<tr><td class="tdtop">';
  133. print $langs->trans("Usage");
  134. print '</td>';
  135. print '<td>';
  136. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  137. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  138. $htmltext = $langs->trans("ProjectFollowOpportunity");
  139. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  140. print '<br>';
  141. }
  142. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  143. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  144. $htmltext = $langs->trans("ProjectFollowTasks");
  145. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  146. print '<br>';
  147. }
  148. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  149. 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"' : '')).'"> ';
  150. $htmltext = $langs->trans("ProjectBillTimeDescription");
  151. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  152. print '<br>';
  153. }
  154. if (isModEnabled('eventorganization')) {
  155. 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"' : '')).'"> ';
  156. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  157. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  158. }
  159. print '</td></tr>';
  160. }
  161. // Visibility
  162. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  163. if ($projectstatic->public) {
  164. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  165. print $langs->trans('SharedProject');
  166. } else {
  167. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  168. print $langs->trans('PrivateProject');
  169. }
  170. print '</td></tr>';
  171. // Budget
  172. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  173. if (strcmp($projectstatic->budget_amount, '')) {
  174. print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  175. }
  176. print '</td></tr>';
  177. // Date start - end project
  178. print '<tr><td>'.$langs->trans("Dates").'</td><td>';
  179. $start = dol_print_date($projectstatic->date_start, 'day');
  180. print ($start ? $start : '?');
  181. $end = dol_print_date($projectstatic->date_end, 'day');
  182. print ' - ';
  183. print ($end ? $end : '?');
  184. if ($projectstatic->hasDelay()) {
  185. print img_warning("Late");
  186. }
  187. print '</td></tr>';
  188. // Other attributes
  189. $cols = 2;
  190. //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  191. print '</table>';
  192. print '</div>';
  193. print '<div class="fichehalfright">';
  194. print '<div class="underbanner clearboth"></div>';
  195. print '<table class="border centpercent tableforfield">';
  196. // Description
  197. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  198. print nl2br($projectstatic->description);
  199. print '</td></tr>';
  200. // Categories
  201. if (isModEnabled('categorie')) {
  202. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  203. print $form->showCategories($projectstatic->id, 'project', 1);
  204. print "</td></tr>";
  205. }
  206. print '</table>';
  207. print '</div>';
  208. print '</div>';
  209. print '<div class="clearboth"></div>';
  210. print dol_get_fiche_end();
  211. print '<br>';
  212. }
  213. $head = task_prepare_head($object);
  214. print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
  215. $param = (GETPOST('withproject') ? '&withproject=1' : '');
  216. $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
  217. if (!GETPOST('withproject') || empty($projectstatic->id)) {
  218. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
  219. $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
  220. } else {
  221. $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
  222. }
  223. $morehtmlref = '';
  224. // Project
  225. if (empty($withproject)) {
  226. $morehtmlref .= '<div class="refidno">';
  227. $morehtmlref .= $langs->trans("Project").': ';
  228. $morehtmlref .= $projectstatic->getNomUrl(1);
  229. $morehtmlref .= '<br>';
  230. // Third party
  231. $morehtmlref .= $langs->trans("ThirdParty").': ';
  232. $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
  233. $morehtmlref .= '</div>';
  234. }
  235. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
  236. print '<div class="fichecenter">';
  237. print '<div class="underbanner clearboth"></div>';
  238. $cssclass = 'titlefield';
  239. $moreparam = $param;
  240. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  241. print '</div>';
  242. print dol_get_fiche_end();
  243. }
  244. // End of page
  245. llxFooter();
  246. $db->close();