dolibarr 21.0.0-alpha
index.php
Go to the documentation of this file.
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 * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29require "../../main.inc.php";
30require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34
35// Load translation files required by the page
36$langs->loadLangs(array('projects', 'companies'));
37
38$hookmanager = new HookManager($db);
39
40// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
41$hookmanager->initHooks(array('activityindex'));
42
43$action = GETPOST('action', 'aZ09');
44$search_project_user = GETPOST('search_project_user');
45$mine = (GETPOST('mode', 'aZ09') == 'mine' || $search_project_user == $user->id) ? 1 : 0;
46if ($mine == 0 && $search_project_user === '') {
47 $search_project_user = getDolGlobalString('MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX');
48}
49if ($search_project_user == $user->id) {
50 $mine = 1;
51}
52
53// Security check
54$socid = 0;
55if ($user->socid > 0) {
56 $socid = $user->socid;
57}
58//$result = restrictedArea($user, 'projet', $projectid);
59if (!$user->hasRight('projet', 'lire')) {
61}
62
63
64/*
65 * Actions
66 */
67
68$parameters = array();
69$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
70if ($reshook < 0) {
71 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
72}
73if (empty($reshook)) {
74 if ($action == 'refresh_search_project_user' && $user->hasRight('projet', 'lire')) {
75 $search_project_user = GETPOSTINT('search_project_user');
76 $tabparam = array("MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX" => $search_project_user);
77
78 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
79 $result = dol_set_user_param($db, $conf, $user, $tabparam);
80 }
81}
82
83
84/*
85 * View
86 */
87
88$now = dol_now();
89$tmp = dol_getdate($now);
90$day = $tmp['mday'];
91$month = $tmp['mon'];
92$year = $tmp['year'];
93
94$form = new Form($db);
95$projectstatic = new Project($db);
96$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
97$taskstatic = new Task($db);
98$tasktmp = new Task($db);
99
100$title = $langs->trans("Activities");
101//if ($mine) $title=$langs->trans("MyActivities");
102
103llxHeader("", $title, '', '', 0, 0, '', '', '', 'mod-project project-activity page-dashboard');
104
105
106// Title for combo list see all projects
107$titleall = $langs->trans("AllAllowedProjects");
108if ($user->hasRight('projet', 'all', 'lire') && !$socid) {
109 $titleall = $langs->trans("AllProjects");
110} else {
111 $titleall = $langs->trans("AllAllowedProjects").'<br><br>';
112}
113
114
115$morehtml = '';
116$morehtml .= '<form name="projectform" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
117$morehtml .= '<input type="hidden" name="token" value="'.newToken().'">';
118$morehtml .= '<input type="hidden" name="action" value="refresh_search_project_user">';
119
120$morehtml .= '<SELECT name="search_project_user" id="search_project_user">';
121$morehtml .= '<option name="all" value="0"'.($mine ? '' : ' selected').'>'.$titleall.'</option>';
122$morehtml .= '<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id) ? ' selected' : '').'>'.$langs->trans("ProjectsImContactFor").'</option>';
123$morehtml .= '</SELECT>';
124$morehtml .= ajax_combobox("search_project_user", array(), 0, 0, 'resolve', '-1', 'small');
125$morehtml .= '<input type="submit" class="button smallpaddingimp" name="refresh" value="'.$langs->trans("Refresh").'">';
126
127if ($mine) {
128 $tooltiphelp = $langs->trans("MyTasksDesc");
129} else {
130 if ($user->hasRight('projet', 'all', 'lire') && !$socid) {
131 $tooltiphelp = $langs->trans("TasksDesc");
132 } else {
133 $tooltiphelp = $langs->trans("TasksPublicDesc");
134 }
135}
136
137print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'projecttask', 0, $morehtml);
138
139print '<div class="fichecenter"><div class="fichethirdleft">';
140
141/* Show list of project today */
142
143print '<div class="div-table-responsive-no-min">';
144print '<table class="noborder centpercent">';
145print '<tr class="liste_titre">';
146print '<td width="50%">'.$langs->trans('ActivityOnProjectToday').'</td>';
147print '<td width="50%" class="right">'.$langs->trans("Time").'</td>';
148print "</tr>\n";
149
150$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
151$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
152$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
153$sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
154$sql .= " WHERE t.fk_projet = p.rowid";
155$sql .= " AND p.entity = ".((int) $conf->entity);
156$sql .= " AND tt.fk_element = t.rowid";
157$sql .= " AND tt.elementtype = 'task'";
158$sql .= " AND tt.fk_user = ".((int) $user->id);
159$sql .= " AND element_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
160$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
161$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
162
163$resql = $db->query($sql);
164if ($resql) {
165 $total = 0;
166
167 while ($row = $db->fetch_object($resql)) {
168 print '<tr class="oddeven">';
169 print '<td>';
170 $projectstatic->id = $row->rowid;
171 $projectstatic->ref = $row->ref;
172 $projectstatic->title = $row->title;
173 $projectstatic->public = $row->public;
174 print $projectstatic->getNomUrl(1, '', 1);
175 print '</td>';
176 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
177 print "</tr>\n";
178 $total += $row->nb;
179 }
180
181 $db->free($resql);
182} else {
183 dol_print_error($db);
184}
185print '<tr class="liste_total">';
186print '<td>'.$langs->trans('Total').'</td>';
187print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
188print "</tr>\n";
189print "</table>";
190print '</div>';
191
192
193print '</div><div class="fichetwothirdright">';
194
195
196/* Show list of yesterday's projects */
197print '<div class="div-table-responsive-no-min">';
198print '<table class="noborder centpercent">';
199print '<tr class="liste_titre">';
200print '<td>'.$langs->trans('ActivityOnProjectYesterday').'</td>';
201print '<td class="right">'.$langs->trans("Time").'</td>';
202print "</tr>\n";
203
204$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
205$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
206$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
207$sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
208$sql .= " WHERE t.fk_projet = p.rowid";
209$sql .= " AND p.entity = ".((int) $conf->entity);
210$sql .= " AND tt.fk_element = t.rowid";
211$sql .= " AND tt.elementtype = 'task'";
212$sql .= " AND tt.fk_user = ".((int) $user->id);
213$sql .= " AND element_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'))."'";
214$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
215$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
216
217$resql = $db->query($sql);
218if ($resql) {
219 $total = 0;
220
221 while ($row = $db->fetch_object($resql)) {
222 print '<tr class="oddeven">';
223 print '<td>';
224 $projectstatic->id = $row->rowid;
225 $projectstatic->ref = $row->ref;
226 $projectstatic->title = $row->title;
227 $projectstatic->public = $row->public;
228 print $projectstatic->getNomUrl(1, '', 1);
229 print '</td>';
230 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
231 print "</tr>\n";
232 $total += $row->nb;
233 }
234
235 $db->free($resql);
236} else {
237 dol_print_error($db);
238}
239print '<tr class="liste_total">';
240print '<td>'.$langs->trans('Total').'</td>';
241print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
242print "</tr>\n";
243print "</table>";
244print '</div>';
245
246
247
248/*
249if ($db->type != 'pgsql')
250{
251 print '<br>';
252
253 // Show list of projects active this week
254 print '<div class="div-table-responsive-no-min">';
255 print '<table class="noborder centpercent">';
256 print '<tr class="liste_titre">';
257 print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
258 print '<td class="right">'.$langs->trans("Time").'</td>';
259 print "</tr>\n";
260
261 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
262 $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
263 $sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
264 $sql.= " , ".MAIN_DB_PREFIX."element_time as tt";
265 $sql.= " WHERE t.fk_projet = p.rowid";
266 $sql.= " AND p.entity = ".((int) $conf->entity);
267 $sql.= " AND tt.fk_task = t.rowid";
268 $sql.= " AND tt.fk_user = ".((int) $user->id);
269 $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
270 $sql.= " AND p.rowid in (".$db->sanitize($projectsListId).")";
271 $sql.= " GROUP BY p.rowid, p.ref, p.title";
272
273 $resql = $db->query($sql);
274 if ( $resql )
275 {
276 $total = 0;
277
278 while ($row = $db->fetch_object($resql))
279 {
280 print '<tr class="oddeven">';
281 print '<td>';
282 $projectstatic->id=$row->rowid;
283 $projectstatic->ref=$row->ref;
284 $projectstatic->title=$row->title;
285 $projectstatic->public=$row->public;
286 print $projectstatic->getNomUrl(1, '', 1);
287 print '</td>';
288 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
289 print "</tr>\n";
290 $total += $row->nb;
291 }
292
293 $db->free($resql);
294 }
295 else
296 {
297 dol_print_error($db);
298 }
299 print '<tr class="liste_total">';
300 print '<td>'.$langs->trans('Total').'</td>';
301 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
302 print "</tr>\n";
303 print "</table></div><br>";
304
305}
306*/
307
308/* Show list of projects active this month */
309if (getDolGlobalString('PROJECT_TASK_TIME_MONTH')) {
310 print '<div class="div-table-responsive-no-min">';
311 print '<table class="noborder centpercent">';
312 print '<tr class="liste_titre">';
313 print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now, "%B %Y").'</td>';
314 print '<td class="right">'.$langs->trans("Time").'</td>';
315 print "</tr>\n";
316
317 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
318 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
319 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
320 $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
321 $sql .= " WHERE t.fk_projet = p.rowid";
322 $sql .= " AND p.entity = ".((int) $conf->entity);
323 $sql .= " AND tt.fk_element = t.rowid";
324 $sql .= " AND tt.elementtype = 'task'";
325 $sql .= " AND tt.fk_user = ".((int) $user->id);
326 $sql .= " AND element_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
327 $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
328 $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
329
330 $resql = $db->query($sql);
331 if ($resql) {
332 while ($row = $db->fetch_object($resql)) {
333 print '<tr class="oddeven">';
334 print '<td>';
335 $projectstatic->id = $row->rowid;
336 $projectstatic->ref = $row->ref;
337 $projectstatic->title = $row->title;
338 print $projectstatic->getNomUrl(1, '', 1);
339 print '</td>';
340 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
341 print "</tr>\n";
342 }
343 $db->free($resql);
344 } else {
345 dol_print_error($db);
346 }
347 print '<tr class="liste_total">';
348 print '<td>'.$langs->trans('Total').'</td>';
349 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
350 print "</tr>\n";
351 print "</table>";
352 print '</div>';
353}
354
355/* Show list of projects that were active this year */
356if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) {
357 print '<div class="div-table-responsive-no-min">';
358 print '<br><table class="noborder centpercent">';
359 print '<tr class="liste_titre">';
360 print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.dol_print_date($now, "%Y").'</td>';
361 print '<td class="right">'.$langs->trans("Time").'</td>';
362 print "</tr>\n";
363
364 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
365 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
366 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
367 $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
368 $sql .= " WHERE t.fk_projet = p.rowid";
369 $sql .= " AND p.entity = ".((int) $conf->entity);
370 $sql .= " AND tt.fk_element = t.rowid";
371 $sql .= " AND tt.elementtype = 'task'";
372 $sql .= " AND tt.fk_user = ".((int) $user->id);
373 $sql .= " AND YEAR(element_date) = '".dol_print_date($now, "%Y")."'";
374 $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
375 $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
376
377 $resql = $db->query($sql);
378 if ($resql) {
379 while ($row = $db->fetch_object($resql)) {
380 print '<tr class="oddeven">';
381 print '<td>';
382 $projectstatic->id = $row->rowid;
383 $projectstatic->ref = $row->ref;
384 $projectstatic->title = $row->title;
385 $projectstatic->public = $row->public;
386 print $projectstatic->getNomUrl(1, '', 1);
387 print '</td>';
388 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
389 print "</tr>\n";
390 }
391 $db->free($resql);
392 } else {
393 dol_print_error($db);
394 }
395 print '<tr class="liste_total">';
396 print '<td>'.$langs->trans('Total').'</td>';
397 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
398 print "</tr>\n";
399 print "</table>";
400 print '</div>';
401}
402
403if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA')) {
404 // Get id of types of contacts for projects (This list never contains a lot of elements)
405 $listofprojectcontacttype = array();
406 $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
407 $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'";
408 $sql .= " AND ctc.source = 'internal'";
409 $resql = $db->query($sql);
410 if ($resql) {
411 while ($obj = $db->fetch_object($resql)) {
412 $listofprojectcontacttype[$obj->rowid] = $obj->code;
413 }
414 } else {
415 dol_print_error($db);
416 }
417 if (count($listofprojectcontacttype) == 0) {
418 $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
419 }
420 // Get id of types of contacts for tasks (This list never contains a lot of elements)
421 $listoftaskcontacttype = array();
422 $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
423 $sql .= " WHERE ctc.element = '".$db->escape($taskstatic->element)."'";
424 $sql .= " AND ctc.source = 'internal'";
425 $resql = $db->query($sql);
426 if ($resql) {
427 while ($obj = $db->fetch_object($resql)) {
428 $listoftaskcontacttype[$obj->rowid] = $obj->code;
429 }
430 } else {
431 dol_print_error($db);
432 }
433 if (count($listoftaskcontacttype) == 0) {
434 $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found
435 }
436
437
438 // Tasks for all resources of all opened projects and time spent for each task/resource
439 // This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
440 // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
441
442 $max = getDolGlobalInt('PROJECT_LIMIT_TASK_PROJECT_AREA', 1000);
443
444 $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 projdate_start, p.datee as projdate_end,";
445 $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo as date_start, t.datee as date_end, SUM(tasktime.element_duration) as timespent";
446 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
447 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
448 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
449 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
450 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
451 if ($mine) {
452 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
453 }
454 $sql .= " WHERE p.entity IN (".getEntity('project').")";
455 if ($mine || !$user->hasRight('projet', 'all', 'lire')) {
456 $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on
457 }
458 if ($mine) { // this may duplicate record if we are contact twice
459 $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(implode(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((int) $user->id);
460 }
461 if ($socid) {
462 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
463 }
464 $sql .= " AND p.fk_statut=1";
465 $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, p.dateo, p.datee, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
466 $sql .= " ORDER BY t.dateo DESC, t.rowid DESC, t.datee DESC";
467 $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit
468
469 dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
470 $resql = $db->query($sql);
471 if ($resql) {
472 $num = $db->num_rows($resql);
473 $i = 0;
474
475 //print load_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
476
477 print '<div class="div-table-responsive-no-min">';
478 print '<table class="noborder centpercent">';
479 print '<tr class="liste_titre">';
480 //print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
481 print '<th>'.$langs->trans('OpenedProjects').'</th>';
482 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
483 print '<th>'.$langs->trans('OpportunityStatus').'</th>';
484 }
485 print '<th>'.$langs->trans('Task').'</th>';
486 print '<th class="center">'.$langs->trans('DateStart').'</th>';
487 print '<th class="center">'.$langs->trans('DateEnd').'</th>';
488 print '<th class="right">'.$langs->trans('PlannedWorkload').'</th>';
489 print '<th class="right">'.$langs->trans('TimeSpent').'</th>';
490 print '<th class="right">'.$langs->trans("ProgressCalculated").'</td>';
491 print '<th class="right">'.$langs->trans("ProgressDeclared").'</td>';
492 print '</tr>';
493
494 while ($i < $num && $i < $max) {
495 $obj = $db->fetch_object($resql);
496
497 $projectstatic->id = $obj->projectid;
498 $projectstatic->ref = $obj->ref;
499 $projectstatic->title = $obj->title;
500 $projectstatic->statut = $obj->status;
501 $projectstatic->public = $obj->public;
502 $projectstatic->date_start = $db->jdate($obj->projdate_start);
503 $projectstatic->date_end = $db->jdate($obj->projdate_end);
504
505 $taskstatic->projectstatus = $obj->projectstatus;
506 $taskstatic->progress = $obj->progress;
507 $taskstatic->fk_statut = $obj->status;
508 $taskstatic->status = $obj->status;
509 $taskstatic->date_start = $db->jdate($obj->date_start);
510 $taskstatic->date_end = $db->jdate($obj->date_end);
511 $taskstatic->dateo = $db->jdate($obj->date_start);
512 $taskstatic->datee = $db->jdate($obj->date_end);
513
514 $username = '';
515 if ($obj->userid && $userstatic->id != $obj->userid) { // We have a user and it is not last loaded user
516 $result = $userstatic->fetch($obj->userid);
517 if (!$result) {
518 $userstatic->id = 0;
519 }
520 }
521 if ($userstatic->id) {
522 $username = $userstatic->getNomUrl(0, 0);
523 }
524
525 print '<tr class="oddeven">';
526 //print '<td>'.$username.'</td>';
527 print '<td>';
528 print $projectstatic->getNomUrl(1, '', 0, '', '<br>');
529 print '</td>';
530 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
531 print '<td>';
532 $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
533 if ($code) {
534 print $langs->trans("OppStatus".$code);
535 }
536 print '</td>';
537 }
538 print '<td>';
539 if (!empty($obj->taskid)) {
540 $tasktmp->id = $obj->taskid;
541 $tasktmp->ref = $obj->ref;
542 $tasktmp->label = $obj->label;
543 print $tasktmp->getNomUrl(1, 'withproject', 'task', 1, '<br>');
544 } else {
545 print $langs->trans("NoTasks");
546 }
547 print '</td>';
548 print '<td class="center">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
549 print '<td class="center">'.dol_print_date($db->jdate($obj->date_end), 'day');
550 if ($taskstatic->hasDelay()) {
551 print img_warning($langs->trans("Late"));
552 }
553 print '</td>';
554 print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
555 print convertSecondToTime($obj->planned_workload, 'allhourmin');
556 print '</a></td>';
557 print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
558 print convertSecondToTime($obj->timespent, 'allhourmin');
559 print '</a></td>';
560 print '<td class="right">';
561 if (!empty($obj->taskid)) {
562 if (empty($obj->planned_workload) > 0) {
563 $percentcompletion = $langs->trans("WorkloadNotDefined");
564 } else {
565 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%';
566 }
567 } else {
568 $percentcompletion = 0;
569 }
570 print $percentcompletion;
571 print '</td>';
572 print '<td class="right">';
573 print ($obj->taskid > 0) ? $obj->progress.'%' : '';
574 print '</td>';
575 print "</tr>\n";
576
577 $i++;
578 }
579
580 if ($num > $max) {
581 $colspan = 6;
582 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
583 $colspan++;
584 }
585 print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
586 }
587
588 print "</table>";
589 print '</div>';
590
591
592 $db->free($resql);
593 } else {
594 dol_print_error($db);
595 }
596}
597
598
599print '</div></div>';
600
601$parameters = array('user' => $user);
602$reshook = $hookmanager->executeHooks('dashboardActivities', $parameters, $object); // Note that $action and $object may have been modified by hook
603
604// End of page
605llxFooter();
606$db->close();
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:457
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage hooks.
Class to manage projects.
Class to manage tasks.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:596
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:242
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:615
llxFooter()
Footer empty.
Definition document.php:107
dol_set_user_param($db, $conf, &$user, $tab)
Save personal parameter.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.