PageRenderTime 87ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/projet/ganttview.php

https://gitlab.com/imagination/dolibarr
PHP | 257 lines | 140 code | 44 blank | 73 comment | 19 complexity | 858764928b301fe3a385f38c6e299992 MD5 | raw file
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/ganttview.php
  21. * \ingroup projet
  22. * \brief Gantt diagramm of a project
  23. * \version $Id: ganttview.php,v 1.14 2011/07/31 23:23:38 eldy Exp $
  24. */
  25. require ("../main.inc.php");
  26. require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php");
  28. require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
  29. require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
  30. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
  31. $projectid=isset($_REQUEST["id"])?$_REQUEST["id"]:$_POST["id"];
  32. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  33. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  34. // Security check
  35. $socid=0;
  36. if ($user->societe_id > 0) $socid=$user->societe_id;
  37. $result = restrictedArea($user, 'projet', $projectid);
  38. $userAccess=0;
  39. $langs->load("users");
  40. $langs->load("projects");
  41. /*
  42. * Actions
  43. */
  44. /*
  45. * View
  46. */
  47. $arrayofcss=array(
  48. '/includes/jsgantt/jsgantt.css'
  49. );
  50. if (! empty($conf->use_javascript_ajax))
  51. {
  52. $arrayofjs=array(
  53. '/includes/jsgantt/jsgantt.js',
  54. '/projet/jsgantt_language.js.php?lang='.$langs->defaultlang
  55. );
  56. }
  57. $form=new Form($db);
  58. $formother=new FormOther($db);
  59. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  60. llxHeader("",$langs->trans("Tasks"),$help_url,'',0,0,$arrayofjs,$arrayofcss);
  61. $task = new Task($db);
  62. $id = $_REQUEST['id'];
  63. $ref= $_GET['ref'];
  64. if ($id > 0 || ! empty($ref))
  65. {
  66. $project = new Project($db);
  67. $project->fetch($_REQUEST["id"],$_GET["ref"]);
  68. if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
  69. // To verify role of users
  70. $userAccess = $project->restrictedProjectArea($user);
  71. }
  72. $userstatic=new User($db);
  73. $companystatic=new Societe($db);
  74. $tab='gantt';
  75. $head=project_prepare_head($project);
  76. dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
  77. $param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
  78. print '<table class="border" width="100%">';
  79. // Ref
  80. print '<tr><td width="30%">';
  81. print $langs->trans("Ref");
  82. print '</td><td>';
  83. // Define a complementary filter for search of next/prev ref.
  84. $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
  85. $project->next_prev_filter=" rowid in (".$projectsListId.")";
  86. print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
  87. print '</td></tr>';
  88. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
  89. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  90. if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
  91. else print '&nbsp;';
  92. print '</td>';
  93. print '</tr>';
  94. // Visibility
  95. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  96. if ($project->public) print $langs->trans('SharedProject');
  97. else print $langs->trans('PrivateProject');
  98. print '</td></tr>';
  99. // Statut
  100. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
  101. print '</table>';
  102. print '</div>';
  103. /*
  104. * Actions
  105. */
  106. /*
  107. print '<div class="tabsAction">';
  108. if ($user->rights->projet->all->creer || $user->rights->projet->creer)
  109. {
  110. if ($project->public || $userAccess)
  111. {
  112. print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$project->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
  113. }
  114. else
  115. {
  116. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
  117. }
  118. }
  119. else
  120. {
  121. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>';
  122. }
  123. print '</div>';
  124. print '<br>';
  125. */
  126. // Get list of tasks in tasksarray and taskarrayfiltered
  127. // We need all tasks (even not limited to a user because a task to user
  128. // can have a parent that is not affected to him).
  129. $tasksarray=$task->getTasksArray(0, 0, $project->id, $socid, 0);
  130. // We load also tasks limited to a particular user
  131. //$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$project->id,0) : '');
  132. //var_dump($tasksarray);
  133. //var_dump($tasksrole);
  134. if (sizeof($tasksarray)>0)
  135. {
  136. // Show Gant diagram from $taskarray using JSGantt
  137. $dateformat=$langs->trans("FormatDateShort");
  138. $dateformat=strtolower($langs->trans("FormatDateShortJava"));
  139. $array_contacts=array();
  140. $tasks=array();
  141. $project_dependencies=array();
  142. $project_id=$project->id;
  143. $taskcursor=0;
  144. foreach($tasksarray as $key => $val)
  145. {
  146. $task->fetch($val->id);
  147. $tasks[$taskcursor]['task_id']=$val->id;
  148. $tasks[$taskcursor]['task_parent']=$val->fk_parent;
  149. $tasks[$taskcursor]['task_is_group']=0;
  150. $tasks[$taskcursor]['task_milestone']=0;
  151. $tasks[$taskcursor]['task_percent_complete']=$val->progress;
  152. //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1);
  153. $tasks[$taskcursor]['task_name']=$val->label;
  154. $tasks[$taskcursor]['task_start_date']=$val->date_start;
  155. $tasks[$taskcursor]['task_end_date']=$val->date_end;
  156. $tasks[$taskcursor]['task_color']='b4d1ea';
  157. $idofusers=$task->getListContactId('internal');
  158. $idofthirdparty=$task->getListContactId('external');
  159. $s='';
  160. if (sizeof($idofusers)>0)
  161. {
  162. $s.=$langs->trans("Internals").': ';
  163. $i=0;
  164. foreach($idofusers as $key => $valid)
  165. {
  166. $userstatic->fetch($valid);
  167. if ($i) $s.=',';
  168. $s.=$userstatic->login;
  169. $i++;
  170. }
  171. }
  172. if (sizeof($idofusers)>0 && (sizeof($idofthirdparty)>0)) $s.=' - ';
  173. if (sizeof($idofthirdparty)>0)
  174. {
  175. if ($s) $s.=' - ';
  176. $s.=$langs->trans("Externals").': ';
  177. $i=0;
  178. foreach($idofthirdparty as $key => $valid)
  179. {
  180. $companystatic->fetch($valid);
  181. if ($i) $s.=',';
  182. $s.=$companystatic->name;
  183. $i++;
  184. }
  185. }
  186. if ($s) $tasks[$taskcursor]['task_resources']='<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>';
  187. //print "xxx".$val->id.$tasks[$taskcursor]['task_resources'];
  188. $taskcursor++;
  189. }
  190. //var_dump($tasks);
  191. print "\n";
  192. if (! empty($conf->use_javascript_ajax))
  193. {
  194. print '<div id="tabs" style="border: 1px solid #ACACAC;">'."\n";
  195. include_once(DOL_DOCUMENT_ROOT.'/projet/ganttchart.php');
  196. print '</div>'."\n";
  197. }
  198. else
  199. {
  200. $langs->load("admin");
  201. print $langs->trans("AvailableOnlyIfJavascriptAndAjaxNotDisabled");
  202. }
  203. }
  204. else
  205. {
  206. print $langs->trans("NoTasks");
  207. }
  208. $db->close();
  209. llxFooter('$Date: 2011/07/31 23:23:38 $ - $Revision: 1.14 $');
  210. ?>