dolibarr 21.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 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//$result = 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="'.$_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 $tooltiphelp = $langs->trans("MyTasksDesc");
136} else {
137 if ($user->hasRight('projet', 'all', 'lire') && !$socid) {
138 $tooltiphelp = $langs->trans("TasksDesc");
139 } else {
140 $tooltiphelp = $langs->trans("TasksPublicDesc");
141 }
142}
143
144print_barre_liste($form->textwithpicto($title, $tooltiphelp), 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);
171if ($resql) {
172 $total = 0;
173
174 while ($row = $db->fetch_object($resql)) {
175 print '<tr class="oddeven">';
176 print '<td>';
177 $projectstatic->id = $row->rowid;
178 $projectstatic->ref = $row->ref;
179 $projectstatic->title = $row->title;
180 $projectstatic->public = $row->public;
181 print $projectstatic->getNomUrl(1, '', 1);
182 print '</td>';
183 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
184 print "</tr>\n";
185 $total += $row->nb;
186 }
187
188 $db->free($resql);
189} else {
190 dol_print_error($db);
191}
192print '<tr class="liste_total">';
193print '<td>'.$langs->trans('Total').'</td>';
194print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
195print "</tr>\n";
196print "</table>";
197print '</div>';
198
199
200print '</div><div class="fichetwothirdright">';
201
202
203/* Show list of yesterday's projects */
204print '<div class="div-table-responsive-no-min">';
205print '<table class="noborder centpercent">';
206print '<tr class="liste_titre">';
207print '<td>'.$langs->trans('ActivityOnProjectYesterday').'</td>';
208print '<td class="right">'.$langs->trans("Time").'</td>';
209print "</tr>\n";
210
211$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
212$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
213$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
214$sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
215$sql .= " WHERE t.fk_projet = p.rowid";
216$sql .= " AND p.entity = ".((int) $conf->entity);
217$sql .= " AND tt.fk_element = t.rowid";
218$sql .= " AND tt.elementtype = 'task'";
219$sql .= " AND tt.fk_user = ".((int) $user->id);
220$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'))."'";
221$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
222$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
223
224$resql = $db->query($sql);
225if ($resql) {
226 $total = 0;
227
228 while ($row = $db->fetch_object($resql)) {
229 print '<tr class="oddeven">';
230 print '<td>';
231 $projectstatic->id = $row->rowid;
232 $projectstatic->ref = $row->ref;
233 $projectstatic->title = $row->title;
234 $projectstatic->public = $row->public;
235 print $projectstatic->getNomUrl(1, '', 1);
236 print '</td>';
237 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
238 print "</tr>\n";
239 $total += $row->nb;
240 }
241
242 $db->free($resql);
243} else {
244 dol_print_error($db);
245}
246print '<tr class="liste_total">';
247print '<td>'.$langs->trans('Total').'</td>';
248print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
249print "</tr>\n";
250print "</table>";
251print '</div>';
252
253
254
255/*
256if ($db->type != 'pgsql')
257{
258 print '<br>';
259
260 // Show list of projects active this week
261 print '<div class="div-table-responsive-no-min">';
262 print '<table class="noborder centpercent">';
263 print '<tr class="liste_titre">';
264 print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
265 print '<td class="right">'.$langs->trans("Time").'</td>';
266 print "</tr>\n";
267
268 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
269 $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
270 $sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
271 $sql.= " , ".MAIN_DB_PREFIX."element_time as tt";
272 $sql.= " WHERE t.fk_projet = p.rowid";
273 $sql.= " AND p.entity = ".((int) $conf->entity);
274 $sql.= " AND tt.fk_task = t.rowid";
275 $sql.= " AND tt.fk_user = ".((int) $user->id);
276 $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
277 $sql.= " AND p.rowid in (".$db->sanitize($projectsListId).")";
278 $sql.= " GROUP BY p.rowid, p.ref, p.title";
279
280 $resql = $db->query($sql);
281 if ( $resql )
282 {
283 $total = 0;
284
285 while ($row = $db->fetch_object($resql))
286 {
287 print '<tr class="oddeven">';
288 print '<td>';
289 $projectstatic->id=$row->rowid;
290 $projectstatic->ref=$row->ref;
291 $projectstatic->title=$row->title;
292 $projectstatic->public=$row->public;
293 print $projectstatic->getNomUrl(1, '', 1);
294 print '</td>';
295 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
296 print "</tr>\n";
297 $total += $row->nb;
298 }
299
300 $db->free($resql);
301 }
302 else
303 {
304 dol_print_error($db);
305 }
306 print '<tr class="liste_total">';
307 print '<td>'.$langs->trans('Total').'</td>';
308 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
309 print "</tr>\n";
310 print "</table></div><br>";
311
312}
313*/
314
315/* Show list of projects active this month */
316if (getDolGlobalString('PROJECT_TASK_TIME_MONTH')) {
317 print '<div class="div-table-responsive-no-min">';
318 print '<table class="noborder centpercent">';
319 print '<tr class="liste_titre">';
320 print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now, "%B %Y").'</td>';
321 print '<td class="right">'.$langs->trans("Time").'</td>';
322 print "</tr>\n";
323
324 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
325 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
326 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
327 $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
328 $sql .= " WHERE t.fk_projet = p.rowid";
329 $sql .= " AND p.entity = ".((int) $conf->entity);
330 $sql .= " AND tt.fk_element = t.rowid";
331 $sql .= " AND tt.elementtype = 'task'";
332 $sql .= " AND tt.fk_user = ".((int) $user->id);
333 $sql .= " AND element_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
334 $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
335 $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
336
337 $resql = $db->query($sql);
338 if ($resql) {
339 while ($row = $db->fetch_object($resql)) {
340 print '<tr class="oddeven">';
341 print '<td>';
342 $projectstatic->id = $row->rowid;
343 $projectstatic->ref = $row->ref;
344 $projectstatic->title = $row->title;
345 print $projectstatic->getNomUrl(1, '', 1);
346 print '</td>';
347 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
348 print "</tr>\n";
349 }
350 $db->free($resql);
351 } else {
352 dol_print_error($db);
353 }
354 print '<tr class="liste_total">';
355 print '<td>'.$langs->trans('Total').'</td>';
356 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
357 print "</tr>\n";
358 print "</table>";
359 print '</div>';
360}
361
362/* Show list of projects that were active this year */
363if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) {
364 print '<div class="div-table-responsive-no-min">';
365 print '<br><table class="noborder centpercent">';
366 print '<tr class="liste_titre">';
367 print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.dol_print_date($now, "%Y").'</td>';
368 print '<td class="right">'.$langs->trans("Time").'</td>';
369 print "</tr>\n";
370
371 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
372 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
373 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
374 $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
375 $sql .= " WHERE t.fk_projet = p.rowid";
376 $sql .= " AND p.entity = ".((int) $conf->entity);
377 $sql .= " AND tt.fk_element = t.rowid";
378 $sql .= " AND tt.elementtype = 'task'";
379 $sql .= " AND tt.fk_user = ".((int) $user->id);
380 $sql .= " AND YEAR(element_date) = '".dol_print_date($now, "%Y")."'";
381 $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
382 $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
383
384 $resql = $db->query($sql);
385 if ($resql) {
386 while ($row = $db->fetch_object($resql)) {
387 print '<tr class="oddeven">';
388 print '<td>';
389 $projectstatic->id = $row->rowid;
390 $projectstatic->ref = $row->ref;
391 $projectstatic->title = $row->title;
392 $projectstatic->public = $row->public;
393 print $projectstatic->getNomUrl(1, '', 1);
394 print '</td>';
395 print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
396 print "</tr>\n";
397 }
398 $db->free($resql);
399 } else {
400 dol_print_error($db);
401 }
402 print '<tr class="liste_total">';
403 print '<td>'.$langs->trans('Total').'</td>';
404 print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
405 print "</tr>\n";
406 print "</table>";
407 print '</div>';
408}
409
410if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA')) {
411 // Get id of types of contacts for projects (This list never contains a lot of elements)
412 $listofprojectcontacttype = array();
413 $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
414 $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'";
415 $sql .= " AND ctc.source = 'internal'";
416 $resql = $db->query($sql);
417 if ($resql) {
418 while ($obj = $db->fetch_object($resql)) {
419 $listofprojectcontacttype[$obj->rowid] = $obj->code;
420 }
421 } else {
422 dol_print_error($db);
423 }
424 if (count($listofprojectcontacttype) == 0) {
425 $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
426 }
427 // Get id of types of contacts for tasks (This list never contains a lot of elements)
428 $listoftaskcontacttype = array();
429 $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
430 $sql .= " WHERE ctc.element = '".$db->escape($taskstatic->element)."'";
431 $sql .= " AND ctc.source = 'internal'";
432 $resql = $db->query($sql);
433 if ($resql) {
434 while ($obj = $db->fetch_object($resql)) {
435 $listoftaskcontacttype[$obj->rowid] = $obj->code;
436 }
437 } else {
438 dol_print_error($db);
439 }
440 if (count($listoftaskcontacttype) == 0) {
441 $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found
442 }
443
444
445 // Tasks for all resources of all opened projects and time spent for each task/resource
446 // This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
447 // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
448
449 $max = getDolGlobalInt('PROJECT_LIMIT_TASK_PROJECT_AREA', 1000);
450
451 $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,";
452 $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";
453 $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
454 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
455 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
456 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
457 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
458 if ($mine) {
459 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
460 }
461 $sql .= " WHERE p.entity IN (".getEntity('project').")";
462 if ($mine || !$user->hasRight('projet', 'all', 'lire')) {
463 $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on
464 }
465 if ($mine) { // this may duplicate record if we are contact twice
466 $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);
467 }
468 if ($socid) {
469 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
470 }
471 $sql .= " AND p.fk_statut=1";
472 $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";
473 $sql .= " ORDER BY t.dateo DESC, t.rowid DESC, t.datee DESC";
474 $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit
475
476 dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
477 $resql = $db->query($sql);
478 if ($resql) {
479 $num = $db->num_rows($resql);
480 $i = 0;
481
482 //print load_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
483
484 print '<div class="div-table-responsive-no-min">';
485 print '<table class="noborder centpercent">';
486 print '<tr class="liste_titre">';
487 //print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
488 print '<th>'.$langs->trans('OpenedProjects').'</th>';
489 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
490 print '<th>'.$langs->trans('OpportunityStatus').'</th>';
491 }
492 print '<th>'.$langs->trans('Task').'</th>';
493 print '<th class="center">'.$langs->trans('DateStart').'</th>';
494 print '<th class="center">'.$langs->trans('DateEnd').'</th>';
495 print '<th class="right">'.$langs->trans('PlannedWorkload').'</th>';
496 print '<th class="right">'.$langs->trans('TimeSpent').'</th>';
497 print '<th class="right">'.$langs->trans("ProgressCalculated").'</td>';
498 print '<th class="right">'.$langs->trans("ProgressDeclared").'</td>';
499 print '</tr>';
500
501 while ($i < $num && $i < $max) {
502 $obj = $db->fetch_object($resql);
503
504 $projectstatic->id = $obj->projectid;
505 $projectstatic->ref = $obj->ref;
506 $projectstatic->title = $obj->title;
507 $projectstatic->statut = $obj->status;
508 $projectstatic->public = $obj->public;
509 $projectstatic->date_start = $db->jdate($obj->projdate_start);
510 $projectstatic->date_end = $db->jdate($obj->projdate_end);
511
512 $taskstatic->projectstatus = $obj->projectstatus;
513 $taskstatic->progress = $obj->progress;
514 $taskstatic->fk_statut = $obj->status;
515 $taskstatic->status = $obj->status;
516 $taskstatic->date_start = $db->jdate($obj->date_start);
517 $taskstatic->date_end = $db->jdate($obj->date_end);
518 $taskstatic->dateo = $db->jdate($obj->date_start);
519 $taskstatic->datee = $db->jdate($obj->date_end);
520
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 print '<tr class="oddeven">';
533 //print '<td>'.$username.'</td>';
534 print '<td>';
535 print $projectstatic->getNomUrl(1, '', 0, '', '<br>');
536 print '</td>';
537 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
538 print '<td>';
539 $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
540 if ($code) {
541 print $langs->trans("OppStatus".$code);
542 }
543 print '</td>';
544 }
545 print '<td>';
546 if (!empty($obj->taskid)) {
547 $tasktmp->id = $obj->taskid;
548 $tasktmp->ref = $obj->ref;
549 $tasktmp->label = $obj->label;
550 print $tasktmp->getNomUrl(1, 'withproject', 'task', 1, '<br>');
551 } else {
552 print $langs->trans("NoTasks");
553 }
554 print '</td>';
555 print '<td class="center">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
556 print '<td class="center">'.dol_print_date($db->jdate($obj->date_end), 'day');
557 if ($taskstatic->hasDelay()) {
558 print img_warning($langs->trans("Late"));
559 }
560 print '</td>';
561 print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
562 print convertSecondToTime($obj->planned_workload, 'allhourmin');
563 print '</a></td>';
564 print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
565 print convertSecondToTime($obj->timespent, 'allhourmin');
566 print '</a></td>';
567 print '<td class="right">';
568 if (!empty($obj->taskid)) {
569 if (empty($obj->planned_workload) > 0) {
570 $percentcompletion = $langs->trans("WorkloadNotDefined");
571 } else {
572 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%';
573 }
574 } else {
575 $percentcompletion = 0;
576 }
577 print $percentcompletion;
578 print '</td>';
579 print '<td class="right">';
580 print ($obj->taskid > 0) ? $obj->progress.'%' : '';
581 print '</td>';
582 print "</tr>\n";
583
584 $i++;
585 }
586
587 if ($num > $max) {
588 $colspan = 6;
589 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
590 $colspan++;
591 }
592 print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
593 }
594
595 print "</table>";
596 print '</div>';
597
598
599 $db->free($resql);
600 } else {
601 dol_print_error($db);
602 }
603}
604
605
606print '</div></div>';
607
608$parameters = array('user' => $user);
609$reshook = $hookmanager->executeHooks('dashboardActivities', $parameters, $object); // Note that $action and $object may have been modified by hook
610
611// End of page
612llxFooter();
613$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:459
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:71
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:600
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:244
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.