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