PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/projet/tasks/note.php

https://github.com/asterix14/dolibarr
PHP | 205 lines | 126 code | 38 blank | 41 comment | 25 complexity | 26cf633ce6b60a38c2690add9f57edf0 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
  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 2 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 <http://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. $langs->load('projects');
  27. $id = isset($_GET["id"])?$_GET["id"]:'';
  28. // Security check
  29. $socid=0;
  30. if ($user->societe_id > 0) $socid = $user->societe_id;
  31. if (!$user->rights->projet->lire) accessforbidden();
  32. //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
  33. /******************************************************************************/
  34. /* Actions */
  35. /******************************************************************************/
  36. if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
  37. {
  38. $task = new Task($db);
  39. $task->fetch($_GET['id']);
  40. $db->begin();
  41. $res=$task->update_note_public($_POST["note_public"],$user);
  42. if ($res < 0)
  43. {
  44. $mesg='<div class="error">'.$task->error.'</div>';
  45. $db->rollback();
  46. }
  47. else
  48. {
  49. $db->commit();
  50. }
  51. }
  52. if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
  53. {
  54. $task = new Task($db);
  55. $task->fetch($_GET['id']);
  56. $db->begin();
  57. $res=$task->update_note($_POST["note_private"],$user);
  58. if ($res < 0)
  59. {
  60. $mesg='<div class="error">'.$task->error.'</div>';
  61. $db->rollback();
  62. }
  63. else
  64. {
  65. $db->commit();
  66. }
  67. }
  68. /*
  69. * View
  70. */
  71. llxHeader();
  72. $form = new Form($db);
  73. $project = new Project($db);
  74. $id = $_GET['id'];
  75. $ref= $_GET['ref'];
  76. if ($id > 0 || ! empty($ref))
  77. {
  78. if ($mesg) print $mesg;
  79. $now=gmmktime();
  80. $task = new Task($db);
  81. $projectstatic = new Project($db);
  82. $userstatic = new User($db);
  83. if ($task->fetch($id, $ref))
  84. {
  85. $result=$projectstatic->fetch($task->fk_project);
  86. if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
  87. // To verify role of users
  88. //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
  89. //$arrayofuseridoftask=$task->getListContactId('internal');
  90. $head = task_prepare_head($task);
  91. dol_fiche_head($head, 'note', $langs->trans('Task'), 0, 'projecttask');
  92. print '<table class="border" width="100%">';
  93. //$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
  94. // Ref
  95. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  96. $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
  97. $task->next_prev_filter=" fk_projet in (".$projectsListId.")";
  98. print $form->showrefnav($task,'id','',1,'rowid','ref','','');
  99. print '</td></tr>';
  100. // Label
  101. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$task->label.'</td></tr>';
  102. // Project
  103. print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
  104. print $projectstatic->getNomUrl(1);
  105. print '</td></tr>';
  106. // Third party
  107. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  108. if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1);
  109. else print'&nbsp;';
  110. print '</td></tr>';
  111. // Note publique
  112. print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
  113. print '<td valign="top" colspan="3">';
  114. if ($_GET["action"] == 'edit')
  115. {
  116. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
  117. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  118. print '<input type="hidden" name="action" value="update_public">';
  119. print '<textarea name="note_public" cols="80" rows="8">'.$task->note_public."</textarea><br>";
  120. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  121. print '</form>';
  122. }
  123. else
  124. {
  125. print ($task->note_public?nl2br($task->note_public):"&nbsp;");
  126. }
  127. print "</td></tr>";
  128. // Note privee
  129. if (! $user->societe_id)
  130. {
  131. print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
  132. print '<td valign="top" colspan="3">';
  133. if ($_GET["action"] == 'edit')
  134. {
  135. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
  136. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  137. print '<input type="hidden" name="action" value="update_private">';
  138. print '<textarea name="note_private" cols="80" rows="8">'.$task->note_private."</textarea><br>";
  139. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  140. print '</form>';
  141. }
  142. else
  143. {
  144. print ($task->note_private?nl2br($task->note_private):"&nbsp;");
  145. }
  146. print "</td></tr>";
  147. }
  148. print "</table>";
  149. print '</div>';
  150. /*
  151. * Actions
  152. */
  153. print '<div class="tabsAction">';
  154. if (($user->rights->projet->creer || $user->rights->projet->all->creer) && $_GET['action'] <> 'edit')
  155. {
  156. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
  157. }
  158. else
  159. {
  160. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>';
  161. }
  162. print '</div>';
  163. }
  164. }
  165. $db->close();
  166. llxFooter();
  167. ?>