PageRenderTime 29ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/projet/ganttview.php

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