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