index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/projet/activity/index.php
  22. * \ingroup projet
  23. * \brief Page on activity of projects
  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.'/core/lib/project.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  30. $search_project_user = GETPOST('search_project_user', 'int');
  31. $mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0;
  32. if ($search_project_user == $user->id) {
  33. $mine = 1;
  34. }
  35. // Security check
  36. $socid = 0;
  37. if ($user->socid > 0) {
  38. $socid = $user->socid;
  39. }
  40. //$result = restrictedArea($user, 'projet', $projectid);
  41. if (!$user->rights->projet->lire) {
  42. accessforbidden();
  43. }
  44. $hookmanager = new HookManager($db);
  45. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
  46. $hookmanager->initHooks(array('activityindex'));
  47. // Load translation files required by the page
  48. $langs->load("projects");
  49. /*
  50. * View
  51. */
  52. $now = dol_now();
  53. $tmp = dol_getdate($now);
  54. $day = $tmp['mday'];
  55. $month = $tmp['mon'];
  56. $year = $tmp['year'];
  57. $projectstatic = new Project($db);
  58. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
  59. $taskstatic = new Task($db);
  60. $tasktmp = new Task($db);
  61. $title = $langs->trans("Activities");
  62. //if ($mine) $title=$langs->trans("MyActivities");
  63. llxHeader("", $title);
  64. // Title for combo list see all projects
  65. $titleall = $langs->trans("AllAllowedProjects");
  66. if (!empty($user->rights->projet->all->lire) && !$socid) {
  67. $titleall = $langs->trans("AllProjects");
  68. } else {
  69. $titleall = $langs->trans("AllAllowedProjects").'<br><br>';
  70. }
  71. $morehtml = '';
  72. $morehtml .= '<form name="projectform">';
  73. $morehtml .= '<SELECT name="mode">';
  74. $morehtml .= '<option name="all" value="all"'.($mine ? '' : ' selected').'>'.$titleall.'</option>';
  75. $morehtml .= '<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id) ? ' selected' : '').'>'.$langs->trans("ProjectsImContactFor").'</option>';
  76. $morehtml .= '</SELECT>';
  77. $morehtml .= '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
  78. if ($mine) {
  79. $tooltiphelp = $langs->trans("MyTasksDesc");
  80. } else {
  81. if ($user->rights->projet->all->lire && !$socid) {
  82. $tooltiphelp = $langs->trans("TasksDesc");
  83. } else {
  84. $tooltiphelp = $langs->trans("TasksPublicDesc");
  85. }
  86. }
  87. print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'projecttask', 0, $morehtml);
  88. print '<div class="fichecenter"><div class="fichethirdleft">';
  89. /* Show list of project today */
  90. print '<div class="div-table-responsive-no-min">';
  91. print '<table class="noborder centpercent">';
  92. print '<tr class="liste_titre">';
  93. print '<td width="50%">'.$langs->trans('ActivityOnProjectToday').'</td>';
  94. print '<td width="50%" class="right">'.$langs->trans("Time").'</td>';
  95. print "</tr>\n";
  96. $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
  97. $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
  98. $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
  99. $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
  100. $sql .= " WHERE t.fk_projet = p.rowid";
  101. $sql .= " AND p.entity = ".((int) $conf->entity);
  102. $sql .= " AND tt.fk_task = t.rowid";
  103. $sql .= " AND tt.fk_user = ".((int) $user->id);
  104. $sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
  105. $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
  106. $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
  107. $resql = $db->query($sql);
  108. if ($resql) {
  109. $total = 0;
  110. while ($row = $db->fetch_object($resql)) {
  111. print '<tr class="oddeven">';
  112. print '<td>';
  113. $projectstatic->id = $row->rowid;
  114. $projectstatic->ref = $row->ref;
  115. $projectstatic->title = $row->title;
  116. $projectstatic->public = $row->public;
  117. print $projectstatic->getNomUrl(1, '', 1);
  118. print '</td>';
  119. print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
  120. print "</tr>\n";
  121. $total += $row->nb;
  122. }
  123. $db->free($resql);
  124. } else {
  125. dol_print_error($db);
  126. }
  127. print '<tr class="liste_total">';
  128. print '<td>'.$langs->trans('Total').'</td>';
  129. print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
  130. print "</tr>\n";
  131. print "</table>";
  132. print '</div>';
  133. print '</div><div class="fichetwothirdright">';
  134. /* Affichage de la liste des projets d'hier */
  135. print '<div class="div-table-responsive-no-min">';
  136. print '<table class="noborder centpercent">';
  137. print '<tr class="liste_titre">';
  138. print '<td>'.$langs->trans('ActivityOnProjectYesterday').'</td>';
  139. print '<td class="right">'.$langs->trans("Time").'</td>';
  140. print "</tr>\n";
  141. $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
  142. $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
  143. $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
  144. $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
  145. $sql .= " WHERE t.fk_projet = p.rowid";
  146. $sql .= " AND p.entity = ".((int) $conf->entity);
  147. $sql .= " AND tt.fk_task = t.rowid";
  148. $sql .= " AND tt.fk_user = ".((int) $user->id);
  149. $sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'";
  150. $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
  151. $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
  152. $resql = $db->query($sql);
  153. if ($resql) {
  154. $total = 0;
  155. while ($row = $db->fetch_object($resql)) {
  156. print '<tr class="oddeven">';
  157. print '<td>';
  158. $projectstatic->id = $row->rowid;
  159. $projectstatic->ref = $row->ref;
  160. $projectstatic->title = $row->title;
  161. $projectstatic->public = $row->public;
  162. print $projectstatic->getNomUrl(1, '', 1);
  163. print '</td>';
  164. print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
  165. print "</tr>\n";
  166. $total += $row->nb;
  167. }
  168. $db->free($resql);
  169. } else {
  170. dol_print_error($db);
  171. }
  172. print '<tr class="liste_total">';
  173. print '<td>'.$langs->trans('Total').'</td>';
  174. print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
  175. print "</tr>\n";
  176. print "</table>";
  177. print '</div>';
  178. /*
  179. if ($db->type != 'pgsql')
  180. {
  181. print '<br>';
  182. // Affichage de la liste des projets de la semaine
  183. print '<div class="div-table-responsive-no-min">';
  184. print '<table class="noborder centpercent">';
  185. print '<tr class="liste_titre">';
  186. print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
  187. print '<td class="right">'.$langs->trans("Time").'</td>';
  188. print "</tr>\n";
  189. $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
  190. $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
  191. $sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
  192. $sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
  193. $sql.= " WHERE t.fk_projet = p.rowid";
  194. $sql.= " AND p.entity = ".((int) $conf->entity);
  195. $sql.= " AND tt.fk_task = t.rowid";
  196. $sql.= " AND tt.fk_user = ".((int) $user->id);
  197. $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
  198. $sql.= " AND p.rowid in (".$db->sanitize($projectsListId).")";
  199. $sql.= " GROUP BY p.rowid, p.ref, p.title";
  200. $resql = $db->query($sql);
  201. if ( $resql )
  202. {
  203. $total = 0;
  204. while ($row = $db->fetch_object($resql))
  205. {
  206. print '<tr class="oddeven">';
  207. print '<td>';
  208. $projectstatic->id=$row->rowid;
  209. $projectstatic->ref=$row->ref;
  210. $projectstatic->title=$row->title;
  211. $projectstatic->public=$row->public;
  212. print $projectstatic->getNomUrl(1, '', 1);
  213. print '</td>';
  214. print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
  215. print "</tr>\n";
  216. $total += $row->nb;
  217. }
  218. $db->free($resql);
  219. }
  220. else
  221. {
  222. dol_print_error($db);
  223. }
  224. print '<tr class="liste_total">';
  225. print '<td>'.$langs->trans('Total').'</td>';
  226. print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
  227. print "</tr>\n";
  228. print "</table></div><br>";
  229. }
  230. */
  231. /* Affichage de la liste des projets du mois */
  232. if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) {
  233. print '<div class="div-table-responsive-no-min">';
  234. print '<table class="noborder centpercent">';
  235. print '<tr class="liste_titre">';
  236. print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now, "%B %Y").'</td>';
  237. print '<td class="right">'.$langs->trans("Time").'</td>';
  238. print "</tr>\n";
  239. $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
  240. $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
  241. $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
  242. $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
  243. $sql .= " WHERE t.fk_projet = p.rowid";
  244. $sql .= " AND p.entity = ".((int) $conf->entity);
  245. $sql .= " AND tt.fk_task = t.rowid";
  246. $sql .= " AND tt.fk_user = ".((int) $user->id);
  247. $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
  248. $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
  249. $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
  250. $resql = $db->query($sql);
  251. if ($resql) {
  252. while ($row = $db->fetch_object($resql)) {
  253. print '<tr class="oddeven">';
  254. print '<td>';
  255. $projectstatic->id = $row->rowid;
  256. $projectstatic->ref = $row->ref;
  257. $projectstatic->title = $row->title;
  258. print $projectstatic->getNomUrl(1, '', 1);
  259. print '</td>';
  260. print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
  261. print "</tr>\n";
  262. }
  263. $db->free($resql);
  264. } else {
  265. dol_print_error($db);
  266. }
  267. print '<tr class="liste_total">';
  268. print '<td>'.$langs->trans('Total').'</td>';
  269. print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
  270. print "</tr>\n";
  271. print "</table>";
  272. print '</div>';
  273. }
  274. /* Affichage de la liste des projets de l'annee */
  275. if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) {
  276. print '<div class="div-table-responsive-no-min">';
  277. print '<br><table class="noborder centpercent">';
  278. print '<tr class="liste_titre">';
  279. print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
  280. print '<td class="right">'.$langs->trans("Time").'</td>';
  281. print "</tr>\n";
  282. $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
  283. $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
  284. $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
  285. $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
  286. $sql .= " WHERE t.fk_projet = p.rowid";
  287. $sql .= " AND p.entity = ".((int) $conf->entity);
  288. $sql .= " AND tt.fk_task = t.rowid";
  289. $sql .= " AND tt.fk_user = ".((int) $user->id);
  290. $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'";
  291. $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
  292. $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
  293. $resql = $db->query($sql);
  294. if ($resql) {
  295. while ($row = $db->fetch_object($resql)) {
  296. print '<tr class="oddeven">';
  297. print '<td>';
  298. $projectstatic->id = $row->rowid;
  299. $projectstatic->ref = $row->ref;
  300. $projectstatic->title = $row->title;
  301. $projectstatic->public = $row->public;
  302. print $projectstatic->getNomUrl(1, '', 1);
  303. print '</td>';
  304. print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
  305. print "</tr>\n";
  306. }
  307. $db->free($resql);
  308. } else {
  309. dol_print_error($db);
  310. }
  311. print '<tr class="liste_total">';
  312. print '<td>'.$langs->trans('Total').'</td>';
  313. print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
  314. print "</tr>\n";
  315. print "</table>";
  316. print '</div>';
  317. }
  318. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) {
  319. // Get id of types of contacts for projects (This list never contains a lot of elements)
  320. $listofprojectcontacttype = array();
  321. $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  322. $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'";
  323. $sql .= " AND ctc.source = 'internal'";
  324. $resql = $db->query($sql);
  325. if ($resql) {
  326. while ($obj = $db->fetch_object($resql)) {
  327. $listofprojectcontacttype[$obj->rowid] = $obj->code;
  328. }
  329. } else {
  330. dol_print_error($db);
  331. }
  332. if (count($listofprojectcontacttype) == 0) {
  333. $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
  334. }
  335. // Get id of types of contacts for tasks (This list never contains a lot of elements)
  336. $listoftaskcontacttype = array();
  337. $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  338. $sql .= " WHERE ctc.element = '".$db->escape($taskstatic->element)."'";
  339. $sql .= " AND ctc.source = 'internal'";
  340. $resql = $db->query($sql);
  341. if ($resql) {
  342. while ($obj = $db->fetch_object($resql)) {
  343. $listoftaskcontacttype[$obj->rowid] = $obj->code;
  344. }
  345. } else {
  346. dol_print_error($db);
  347. }
  348. if (count($listoftaskcontacttype) == 0) {
  349. $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found
  350. }
  351. // Tasks for all resources of all opened projects and time spent for each task/resource
  352. // This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
  353. // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
  354. $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
  355. $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
  356. $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
  357. $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
  358. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  359. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
  360. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
  361. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
  362. if ($mine) {
  363. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
  364. }
  365. $sql .= " WHERE p.entity IN (".getEntity('project').")";
  366. if ($mine || empty($user->rights->projet->all->lire)) {
  367. $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on
  368. }
  369. if ($mine) { // this may duplicate record if we are contact twice
  370. $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((int) $user->id);
  371. }
  372. if ($socid) {
  373. $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
  374. }
  375. $sql .= " AND p.fk_statut=1";
  376. $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
  377. $sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee";
  378. $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit
  379. dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
  380. $resql = $db->query($sql);
  381. if ($resql) {
  382. $num = $db->num_rows($resql);
  383. $i = 0;
  384. //print load_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
  385. print '<div class="div-table-responsive-no-min">';
  386. print '<table class="noborder centpercent">';
  387. print '<tr class="liste_titre">';
  388. //print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
  389. print '<th>'.$langs->trans('OpenedProjects').'</th>';
  390. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  391. print '<th>'.$langs->trans('OpportunityStatus').'</th>';
  392. }
  393. print '<th>'.$langs->trans('Task').'</th>';
  394. print '<th class="center">'.$langs->trans('DateStart').'</th>';
  395. print '<th class="center">'.$langs->trans('DateEnd').'</th>';
  396. print '<th class="right">'.$langs->trans('PlannedWorkload').'</th>';
  397. print '<th class="right">'.$langs->trans('TimeSpent').'</th>';
  398. print '<th class="right">'.$langs->trans("ProgressCalculated").'</td>';
  399. print '<th class="right">'.$langs->trans("ProgressDeclared").'</td>';
  400. print '</tr>';
  401. while ($i < $num && $i < $max) {
  402. $obj = $db->fetch_object($resql);
  403. $projectstatic->id = $obj->projectid;
  404. $projectstatic->ref = $obj->ref;
  405. $projectstatic->title = $obj->title;
  406. $projectstatic->statut = $obj->status;
  407. $projectstatic->public = $obj->public;
  408. $projectstatic->dateo = $db->jdate($obj->projdateo);
  409. $projectstatic->datee = $db->jdate($obj->projdatee);
  410. $taskstatic->projectstatus = $obj->projectstatus;
  411. $taskstatic->progress = $obj->progress;
  412. $taskstatic->fk_statut = $obj->status;
  413. $taskstatic->dateo = $db->jdate($obj->dateo);
  414. $taskstatic->datee = $db->jdate($obj->datee);
  415. $username = '';
  416. if ($obj->userid && $userstatic->id != $obj->userid) { // We have a user and it is not last loaded user
  417. $result = $userstatic->fetch($obj->userid);
  418. if (!$result) {
  419. $userstatic->id = 0;
  420. }
  421. }
  422. if ($userstatic->id) {
  423. $username = $userstatic->getNomUrl(0, 0);
  424. }
  425. print '<tr class="oddeven">';
  426. //print '<td>'.$username.'</td>';
  427. print '<td>';
  428. print $projectstatic->getNomUrl(1, '', 0, '', '<br>');
  429. print '</td>';
  430. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  431. print '<td>';
  432. $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
  433. if ($code) {
  434. print $langs->trans("OppStatus".$code);
  435. }
  436. print '</td>';
  437. }
  438. print '<td>';
  439. if (!empty($obj->taskid)) {
  440. $tasktmp->id = $obj->taskid;
  441. $tasktmp->ref = $obj->ref;
  442. $tasktmp->label = $obj->label;
  443. print $tasktmp->getNomUrl(1, 'withproject', 'task', 1, '<br>');
  444. } else {
  445. print $langs->trans("NoTasks");
  446. }
  447. print '</td>';
  448. print '<td class="center">'.dol_print_date($db->jdate($obj->dateo), 'day').'</td>';
  449. print '<td class="center">'.dol_print_date($db->jdate($obj->datee), 'day');
  450. if ($taskstatic->hasDelay()) {
  451. print img_warning($langs->trans("Late"));
  452. }
  453. print '</td>';
  454. print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
  455. print convertSecondToTime($obj->planned_workload, 'allhourmin');
  456. print '</a></td>';
  457. print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
  458. print convertSecondToTime($obj->timespent, 'allhourmin');
  459. print '</a></td>';
  460. print '<td class="right">';
  461. if (!empty($obj->taskid)) {
  462. if (empty($obj->planned_workload) > 0) {
  463. $percentcompletion = $langs->trans("WorkloadNotDefined");
  464. } else {
  465. $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%';
  466. }
  467. }
  468. print $percentcompletion;
  469. print '</td>';
  470. print '<td class="right">';
  471. print ($obj->taskid > 0) ? $obj->progress.'%' : '';
  472. print '</td>';
  473. print "</tr>\n";
  474. $i++;
  475. }
  476. if ($num > $max) {
  477. $colspan = 6;
  478. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  479. $colspan++;
  480. }
  481. print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
  482. }
  483. print "</table>";
  484. print '</div>';
  485. $db->free($resql);
  486. } else {
  487. dol_print_error($db);
  488. }
  489. }
  490. print '</div></div>';
  491. $parameters = array('user' => $user);
  492. $reshook = $hookmanager->executeHooks('dashboardActivities', $parameters, $object); // Note that $action and $object may have been modified by hook
  493. // End of page
  494. llxFooter();
  495. $db->close();