PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/projet/tasks/note.php

https://bitbucket.org/speedealing/speedealing
PHP | 217 lines | 131 code | 45 blank | 41 comment | 33 complexity | 2515a0b8dfbd507062a7a1f3b7925971 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.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 <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. $action=GETPOST('action','alpha');
  28. $confirm=GETPOST('confirm','alpha');
  29. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  30. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  31. $id = GETPOST('id','int');
  32. $ref= GETPOST('ref', 'alpha');
  33. $withproject=GETPOST('withproject','int');
  34. $project_ref = GETPOST('project_ref','alpha');
  35. // Security check
  36. $socid=0;
  37. if ($user->societe_id > 0) $socid = $user->societe_id;
  38. if (!$user->rights->projet->lire) accessforbidden();
  39. //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
  40. $object = new Task($db);
  41. $projectstatic = new Project($db);
  42. if ($id > 0 || ! empty($ref))
  43. {
  44. if ($object->fetch($id,$ref) > 0)
  45. {
  46. $projectstatic->fetch($object->fk_project);
  47. if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
  48. }
  49. else
  50. {
  51. dol_print_error($db);
  52. }
  53. }
  54. // Retreive First Task ID of Project if withprojet is on to allow project prev next to work
  55. if (! empty($project_ref) && ! empty($withproject))
  56. {
  57. if ($projectstatic->fetch(0,$project_ref) > 0)
  58. {
  59. $tasksarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
  60. if (count($tasksarray) > 0)
  61. {
  62. $id=$tasksarray[0]->id;
  63. $object->fetch($id);
  64. }
  65. else
  66. {
  67. header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode)?'':'&mode='.$mode));
  68. }
  69. }
  70. }
  71. $permission=($user->rights->projet->creer || $user->rights->projet->all->creer);
  72. /*
  73. * Actions
  74. */
  75. if ($action == 'setnote_public' && ! empty($permission))
  76. {
  77. $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
  78. if ($result < 0) dol_print_error($db,$object->error);
  79. }
  80. else if ($action == 'setnote_private' && ! empty($permission))
  81. {
  82. $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES));
  83. if ($result < 0) dol_print_error($db,$object->error);
  84. }
  85. /*
  86. * View
  87. */
  88. llxHeader('', $langs->trans("Task"));
  89. $form = new Form($db);
  90. $userstatic = new User($db);
  91. $now=dol_now();
  92. if ($object->id > 0)
  93. {
  94. $userWrite = $projectstatic->restrictedProjectArea($user,'write');
  95. if (! empty($withproject))
  96. {
  97. // Tabs for project
  98. $tab='tasks';
  99. $head=project_prepare_head($projectstatic);
  100. dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project'));
  101. $param=($mode=='mine'?'&mode=mine':'');
  102. print '<table class="border" width="100%">';
  103. // Ref
  104. print '<tr><td width="30%">';
  105. print $langs->trans("Ref");
  106. print '</td><td>';
  107. // Define a complementary filter for search of next/prev ref.
  108. if (! $user->rights->projet->all->lire)
  109. {
  110. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,0);
  111. $projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
  112. }
  113. print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1');
  114. print '</td></tr>';
  115. // Project
  116. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>';
  117. // Company
  118. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  119. if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1);
  120. else print '&nbsp;';
  121. print '</td>';
  122. print '</tr>';
  123. // Visibility
  124. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  125. if ($projectstatic->public) print $langs->trans('SharedProject');
  126. else print $langs->trans('PrivateProject');
  127. print '</td></tr>';
  128. // Statut
  129. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projectstatic->getLibStatut(4).'</td></tr>';
  130. print '</table>';
  131. dol_fiche_end();
  132. print '<br>';
  133. }
  134. $head = task_prepare_head($object);
  135. dol_fiche_head($head, 'task_notes', $langs->trans('Task'), 0, 'projecttask');
  136. print '<table class="border" width="100%">';
  137. $param=(GETPOST('withproject')?'&withproject=1':'');
  138. $linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
  139. // Ref
  140. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  141. if (empty($withproject) || empty($projectstatic->id))
  142. {
  143. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
  144. $object->next_prev_filter=" fk_projet in (".$projectsListId.")";
  145. }
  146. else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
  147. print $form->showrefnav($object,'id',$linkback,1,'rowid','ref','',$param);
  148. print '</td></tr>';
  149. // Label
  150. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
  151. // Project
  152. if (empty($withproject))
  153. {
  154. print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
  155. print $projectstatic->getNomUrl(1);
  156. print '</td></tr>';
  157. // Third party
  158. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  159. if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1);
  160. else print'&nbsp;';
  161. print '</td></tr>';
  162. }
  163. print "</table>";
  164. print '<br>';
  165. $colwidth=30;
  166. $moreparam=$param;
  167. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  168. dol_fiche_end();
  169. }
  170. llxFooter();
  171. $db->close();
  172. ?>