PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/projet/note.php

https://github.com/asterix14/dolibarr
PHP | 211 lines | 129 code | 41 blank | 41 comment | 26 complexity | 5ab2eff448131db42c87b08f4469720a 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/note.php
  19. * \ingroup project
  20. * \brief Fiche d'information sur un projet
  21. */
  22. require("../main.inc.php");
  23. require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  24. require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
  25. $langs->load('projects');
  26. $id = isset($_GET["id"])?$_GET["id"]:'';
  27. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  28. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  29. // Security check
  30. $socid=0;
  31. if ($user->societe_id > 0) $socid=$user->societe_id;
  32. $result = restrictedArea($user, 'projet', $id);
  33. /******************************************************************************/
  34. /* Actions */
  35. /******************************************************************************/
  36. if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
  37. {
  38. $project = new Project($db);
  39. $project->fetch($_GET['id']);
  40. $db->begin();
  41. $res=$project->update_note_public($_POST["note_public"],$user);
  42. if ($res < 0)
  43. {
  44. $mesg='<div class="error">'.$project->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. $project = new Project($db);
  55. $project->fetch($_GET['id']);
  56. $db->begin();
  57. $res=$project->update_note($_POST["note_private"],$user);
  58. if ($res < 0)
  59. {
  60. $mesg='<div class="error">'.$project->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. $userstatic=new User($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. $project = new Project($db);
  81. if ($project->fetch($id, $ref))
  82. {
  83. if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
  84. // To verify role of users
  85. $userAccess = $project->restrictedProjectArea($user);
  86. $head = project_prepare_head($project);
  87. dol_fiche_head($head, 'note', $langs->trans('Project'), 0, ($project->public?'projectpub':'project'));
  88. print '<table class="border" width="100%">';
  89. //$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
  90. // Ref
  91. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  92. // Define a complementary filter for search of next/prev ref.
  93. $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
  94. $project->next_prev_filter=" rowid in (".$projectsListId.")";
  95. print $form->showrefnav($project,'ref','',1,'ref','ref');
  96. print '</td></tr>';
  97. // Label
  98. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
  99. // Third party
  100. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  101. if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
  102. else print'&nbsp;';
  103. print '</td></tr>';
  104. // Visibility
  105. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  106. if ($project->public) print $langs->trans('SharedProject');
  107. else print $langs->trans('PrivateProject');
  108. print '</td></tr>';
  109. // Statut
  110. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</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='.$project->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">'.$project->note_public."</textarea><br>";
  120. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  121. print '</form>';
  122. }
  123. else
  124. {
  125. print ($project->note_public?nl2br($project->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='.$project->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">'.$project->note_private."</textarea><br>";
  139. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  140. print '</form>';
  141. }
  142. else
  143. {
  144. print ($project->note_private?nl2br($project->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 && $_GET['action'] <> 'edit')
  155. {
  156. if ($userAccess)
  157. {
  158. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
  159. }
  160. else
  161. {
  162. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>';
  163. }
  164. }
  165. print '</div>';
  166. }
  167. }
  168. $db->close();
  169. llxFooter();
  170. ?>