PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/projet/ganttview.php

https://github.com/asterix14/dolibarr
PHP | 254 lines | 138 code | 44 blank | 72 comment | 19 complexity | 489a719ce185586c34bad09e369e14fb MD5 | raw file
Possible License(s): LGPL-2.0
  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. */
  24. require ("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
  29. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
  30. $projectid=isset($_REQUEST["id"])?$_REQUEST["id"]:$_POST["id"];
  31. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  32. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  33. // Security check
  34. $socid=0;
  35. if ($user->societe_id > 0) $socid=$user->societe_id;
  36. $result = restrictedArea($user, 'projet', $projectid);
  37. $userAccess=0;
  38. $langs->load("users");
  39. $langs->load("projects");
  40. /*
  41. * Actions
  42. */
  43. /*
  44. * View
  45. */
  46. $arrayofcss=array('/includes/jsgantt/jsgantt.css');
  47. if (! empty($conf->use_javascript_ajax))
  48. {
  49. $arrayofjs=array(
  50. '/includes/jsgantt/jsgantt.js',
  51. '/projet/jsgantt_language.js.php?lang='.$langs->defaultlang
  52. );
  53. }
  54. $form=new Form($db);
  55. $formother=new FormOther($db);
  56. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  57. llxHeader("",$langs->trans("Tasks"),$help_url,'',0,0,$arrayofjs,$arrayofcss);
  58. $task = new Task($db);
  59. $id = $_REQUEST['id'];
  60. $ref= $_GET['ref'];
  61. if ($id > 0 || ! empty($ref))
  62. {
  63. $project = new Project($db);
  64. $project->fetch($_REQUEST["id"],$_GET["ref"]);
  65. if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
  66. // To verify role of users
  67. $userAccess = $project->restrictedProjectArea($user);
  68. }
  69. $userstatic=new User($db);
  70. $companystatic=new Societe($db);
  71. $tab='gantt';
  72. $head=project_prepare_head($project);
  73. dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
  74. $param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
  75. print '<table class="border" width="100%">';
  76. // Ref
  77. print '<tr><td width="30%">';
  78. print $langs->trans("Ref");
  79. print '</td><td>';
  80. // Define a complementary filter for search of next/prev ref.
  81. $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
  82. $project->next_prev_filter=" rowid in (".$projectsListId.")";
  83. print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
  84. print '</td></tr>';
  85. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
  86. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  87. if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
  88. else print '&nbsp;';
  89. print '</td>';
  90. print '</tr>';
  91. // Visibility
  92. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  93. if ($project->public) print $langs->trans('SharedProject');
  94. else print $langs->trans('PrivateProject');
  95. print '</td></tr>';
  96. // Statut
  97. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
  98. print '</table>';
  99. print '</div>';
  100. /*
  101. * Actions
  102. */
  103. /*
  104. print '<div class="tabsAction">';
  105. if ($user->rights->projet->all->creer || $user->rights->projet->creer)
  106. {
  107. if ($project->public || $userAccess)
  108. {
  109. print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$project->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
  110. }
  111. else
  112. {
  113. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
  114. }
  115. }
  116. else
  117. {
  118. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>';
  119. }
  120. print '</div>';
  121. print '<br>';
  122. */
  123. // Get list of tasks in tasksarray and taskarrayfiltered
  124. // We need all tasks (even not limited to a user because a task to user
  125. // can have a parent that is not affected to him).
  126. $tasksarray=$task->getTasksArray(0, 0, $project->id, $socid, 0);
  127. // We load also tasks limited to a particular user
  128. //$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$project->id,0) : '');
  129. //var_dump($tasksarray);
  130. //var_dump($tasksrole);
  131. if (count($tasksarray)>0)
  132. {
  133. // Show Gant diagram from $taskarray using JSGantt
  134. $dateformat=$langs->trans("FormatDateShort");
  135. $dateformat=strtolower($langs->trans("FormatDateShortJava"));
  136. $array_contacts=array();
  137. $tasks=array();
  138. $project_dependencies=array();
  139. $project_id=$project->id;
  140. $taskcursor=0;
  141. foreach($tasksarray as $key => $val)
  142. {
  143. $task->fetch($val->id);
  144. $tasks[$taskcursor]['task_id']=$val->id;
  145. $tasks[$taskcursor]['task_parent']=$val->fk_parent;
  146. $tasks[$taskcursor]['task_is_group']=0;
  147. $tasks[$taskcursor]['task_milestone']=0;
  148. $tasks[$taskcursor]['task_percent_complete']=$val->progress;
  149. //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1);
  150. $tasks[$taskcursor]['task_name']=$val->label;
  151. $tasks[$taskcursor]['task_start_date']=$val->date_start;
  152. $tasks[$taskcursor]['task_end_date']=$val->date_end;
  153. $tasks[$taskcursor]['task_color']='b4d1ea';
  154. $idofusers=$task->getListContactId('internal');
  155. $idofthirdparty=$task->getListContactId('external');
  156. $s='';
  157. if (count($idofusers)>0)
  158. {
  159. $s.=$langs->trans("Internals").': ';
  160. $i=0;
  161. foreach($idofusers as $key => $valid)
  162. {
  163. $userstatic->fetch($valid);
  164. if ($i) $s.=',';
  165. $s.=$userstatic->login;
  166. $i++;
  167. }
  168. }
  169. if (count($idofusers)>0 && (count($idofthirdparty)>0)) $s.=' - ';
  170. if (count($idofthirdparty)>0)
  171. {
  172. if ($s) $s.=' - ';
  173. $s.=$langs->trans("Externals").': ';
  174. $i=0;
  175. foreach($idofthirdparty as $key => $valid)
  176. {
  177. $companystatic->fetch($valid);
  178. if ($i) $s.=',';
  179. $s.=$companystatic->name;
  180. $i++;
  181. }
  182. }
  183. 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>';
  184. //print "xxx".$val->id.$tasks[$taskcursor]['task_resources'];
  185. $taskcursor++;
  186. }
  187. //var_dump($tasks);
  188. print "\n";
  189. if (! empty($conf->use_javascript_ajax))
  190. {
  191. print '<div id="tabs" style="border: 1px solid #ACACAC;">'."\n";
  192. include_once(DOL_DOCUMENT_ROOT.'/projet/ganttchart.php');
  193. print '</div>'."\n";
  194. }
  195. else
  196. {
  197. $langs->load("admin");
  198. print $langs->trans("AvailableOnlyIfJavascriptAndAjaxNotDisabled");
  199. }
  200. }
  201. else
  202. {
  203. print $langs->trans("NoTasks");
  204. }
  205. $db->close();
  206. llxFooter();
  207. ?>