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