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';
34$search_project_user =
GETPOST(
'search_project_user',
'int');
35$mine =
GETPOST(
'mode',
'aZ09') ==
'mine' ? 1 : 0;
36if ($search_project_user == $user->id) {
43$hookmanager->initHooks(array(
'activityindex'));
47if ($user->socid > 0) {
48 $socid = $user->socid;
51if (!$user->hasRight(
'projet',
'lire')) {
56$langs->load(
"projects");
69$projectstatic =
new Project($db);
70$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
71$taskstatic =
new Task($db);
72$tasktmp =
new Task($db);
74$title = $langs->trans(
"Activities");
81$titleall = $langs->trans(
"AllAllowedProjects");
82if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
83 $titleall = $langs->trans(
"AllProjects");
85 $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
90$morehtml .=
'<form name="projectform">';
91$morehtml .=
'<SELECT name="mode">';
92$morehtml .=
'<option name="all" value="all"'.($mine ?
'' :
' selected').
'>'.$titleall.
'</option>';
93$morehtml .=
'<option name="mine" value="'.$user->id.
'"'.(($search_project_user == $user->id) ?
' selected' :
'').
'>'.$langs->trans(
"ProjectsImContactFor").
'</option>';
94$morehtml .=
'</SELECT>';
95$morehtml .=
'<input type="submit" class="button" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
98 $tooltiphelp = $langs->trans(
"MyTasksDesc");
100 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
101 $tooltiphelp = $langs->trans(
"TasksDesc");
103 $tooltiphelp = $langs->trans(
"TasksPublicDesc");
107print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
109print
'<div class="fichecenter"><div class="fichethirdleft">';
113print
'<div class="div-table-responsive-no-min">';
114print
'<table class="noborder centpercent">';
115print
'<tr class="liste_titre">';
116print
'<td width="50%">'.$langs->trans(
'ActivityOnProjectToday').
'</td>';
117print
'<td width="50%" class="right">'.$langs->trans(
"Time").
'</td>';
120$sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
121$sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
122$sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
123$sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
124$sql .=
" WHERE t.fk_projet = p.rowid";
125$sql .=
" AND p.entity = ".((int) $conf->entity);
126$sql .=
" AND tt.fk_element = t.rowid";
127$sql .=
" AND tt.elementtype = 'task'";
128$sql .=
" AND tt.fk_user = ".((int) $user->id);
129$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)).
"'";
130$sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
131$sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
133$resql = $db->query($sql);
137 while ($row = $db->fetch_object($resql)) {
138 print
'<tr class="oddeven">';
140 $projectstatic->id = $row->rowid;
141 $projectstatic->ref = $row->ref;
142 $projectstatic->title = $row->title;
143 $projectstatic->public = $row->public;
144 print $projectstatic->getNomUrl(1,
'', 1);
146 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
155print
'<tr class="liste_total">';
156print
'<td>'.$langs->trans(
'Total').
'</td>';
157print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
163print
'</div><div class="fichetwothirdright">';
167print
'<div class="div-table-responsive-no-min">';
168print
'<table class="noborder centpercent">';
169print
'<tr class="liste_titre">';
170print
'<td>'.$langs->trans(
'ActivityOnProjectYesterday').
'</td>';
171print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
174$sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
175$sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
176$sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
177$sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
178$sql .=
" WHERE t.fk_projet = p.rowid";
179$sql .=
" AND p.entity = ".((int) $conf->entity);
180$sql .=
" AND tt.fk_element = t.rowid";
181$sql .=
" AND tt.elementtype = 'task'";
182$sql .=
" AND tt.fk_user = ".((int) $user->id);
183$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')).
"'";
184$sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
185$sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
187$resql = $db->query($sql);
191 while ($row = $db->fetch_object($resql)) {
192 print
'<tr class="oddeven">';
194 $projectstatic->id = $row->rowid;
195 $projectstatic->ref = $row->ref;
196 $projectstatic->title = $row->title;
197 $projectstatic->public = $row->public;
198 print $projectstatic->getNomUrl(1,
'', 1);
200 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
209print
'<tr class="liste_total">';
210print
'<td>'.$langs->trans(
'Total').
'</td>';
211print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
280 print
'<div class="div-table-responsive-no-min">';
281 print
'<table class="noborder centpercent">';
282 print
'<tr class="liste_titre">';
283 print
'<td>'.$langs->trans(
"ActivityOnProjectThisMonth").
': '.
dol_print_date($now,
"%B %Y").
'</td>';
284 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
287 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
288 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
289 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
290 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
291 $sql .=
" WHERE t.fk_projet = p.rowid";
292 $sql .=
" AND p.entity = ".((int) $conf->entity);
293 $sql .=
" AND tt.fk_element = t.rowid";
294 $sql .=
" AND tt.elementtype = 'task'";
295 $sql .=
" AND tt.fk_user = ".((int) $user->id);
297 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
298 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
300 $resql = $db->query($sql);
302 while ($row = $db->fetch_object($resql)) {
303 print
'<tr class="oddeven">';
305 $projectstatic->id = $row->rowid;
306 $projectstatic->ref = $row->ref;
307 $projectstatic->title = $row->title;
308 print $projectstatic->getNomUrl(1,
'', 1);
310 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
317 print
'<tr class="liste_total">';
318 print
'<td>'.$langs->trans(
'Total').
'</td>';
319 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
327 print
'<div class="div-table-responsive-no-min">';
328 print
'<br><table class="noborder centpercent">';
329 print
'<tr class="liste_titre">';
330 print
'<td>'.$langs->trans(
"ActivityOnProjectThisYear").
': '.strftime(
"%Y", $now).
'</td>';
331 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
334 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
335 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
336 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
337 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
338 $sql .=
" WHERE t.fk_projet = p.rowid";
339 $sql .=
" AND p.entity = ".((int) $conf->entity);
340 $sql .=
" AND tt.fk_element = t.rowid";
341 $sql .=
" AND tt.elementtype = 'task'";
342 $sql .=
" AND tt.fk_user = ".((int) $user->id);
343 $sql .=
" AND YEAR(element_date) = '".strftime(
"%Y", $now).
"'";
344 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
345 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
347 $resql = $db->query($sql);
349 while ($row = $db->fetch_object($resql)) {
350 print
'<tr class="oddeven">';
352 $projectstatic->id = $row->rowid;
353 $projectstatic->ref = $row->ref;
354 $projectstatic->title = $row->title;
355 $projectstatic->public = $row->public;
356 print $projectstatic->getNomUrl(1,
'', 1);
358 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
365 print
'<tr class="liste_total">';
366 print
'<td>'.$langs->trans(
'Total').
'</td>';
367 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
375 $listofprojectcontacttype = array();
376 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
377 $sql .=
" WHERE ctc.element = '".$db->escape($projectstatic->element).
"'";
378 $sql .=
" AND ctc.source = 'internal'";
379 $resql = $db->query($sql);
381 while ($obj = $db->fetch_object($resql)) {
382 $listofprojectcontacttype[$obj->rowid] = $obj->code;
387 if (count($listofprojectcontacttype) == 0) {
388 $listofprojectcontacttype[0] =
'0';
391 $listoftaskcontacttype = array();
392 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
393 $sql .=
" WHERE ctc.element = '".$db->escape($taskstatic->element).
"'";
394 $sql .=
" AND ctc.source = 'internal'";
395 $resql = $db->query($sql);
397 while ($obj = $db->fetch_object($resql)) {
398 $listoftaskcontacttype[$obj->rowid] = $obj->code;
403 if (count($listoftaskcontacttype) == 0) {
404 $listoftaskcontacttype[0] =
'0';
412 $max = (!
getDolGlobalString(
'PROJECT_LIMIT_TASK_PROJECT_AREA') ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
414 $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,";
415 $sql .=
" t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.element_duration) as timespent";
416 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
417 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
418 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
419 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
420 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on tasktime.fk_user = u.rowid";
422 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
424 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
425 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
426 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
429 $sql .=
" AND ect.fk_c_type_contact IN (".$db->sanitize(join(
',', array_keys($listoftaskcontacttype))).
") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((int) $user->id);
432 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
434 $sql .=
" AND p.fk_statut=1";
435 $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";
436 $sql .=
" ORDER BY t.dateo desc, t.rowid desc, t.datee";
437 $sql .= $db->plimit($max + 1);
439 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
440 $resql = $db->query($sql);
442 $num = $db->num_rows($resql);
447 print
'<div class="div-table-responsive-no-min">';
448 print
'<table class="noborder centpercent">';
449 print
'<tr class="liste_titre">';
451 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
453 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
455 print
'<th>'.$langs->trans(
'Task').
'</th>';
456 print
'<th class="center">'.$langs->trans(
'DateStart').
'</th>';
457 print
'<th class="center">'.$langs->trans(
'DateEnd').
'</th>';
458 print
'<th class="right">'.$langs->trans(
'PlannedWorkload').
'</th>';
459 print
'<th class="right">'.$langs->trans(
'TimeSpent').
'</th>';
460 print
'<th class="right">'.$langs->trans(
"ProgressCalculated").
'</td>';
461 print
'<th class="right">'.$langs->trans(
"ProgressDeclared").
'</td>';
464 while ($i < $num && $i < $max) {
465 $obj = $db->fetch_object($resql);
467 $projectstatic->id = $obj->projectid;
468 $projectstatic->ref = $obj->ref;
469 $projectstatic->title = $obj->title;
470 $projectstatic->statut = $obj->status;
471 $projectstatic->public = $obj->public;
472 $projectstatic->dateo = $db->jdate($obj->projdateo);
473 $projectstatic->datee = $db->jdate($obj->projdatee);
475 $taskstatic->projectstatus = $obj->projectstatus;
476 $taskstatic->progress = $obj->progress;
477 $taskstatic->fk_statut = $obj->status;
478 $taskstatic->dateo = $db->jdate($obj->dateo);
479 $taskstatic->datee = $db->jdate($obj->datee);
482 if ($obj->userid && $userstatic->id != $obj->userid) {
483 $result = $userstatic->fetch($obj->userid);
488 if ($userstatic->id) {
489 $username = $userstatic->getNomUrl(0, 0);
492 print
'<tr class="oddeven">';
495 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
499 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
501 print $langs->trans(
"OppStatus".$code);
506 if (!empty($obj->taskid)) {
507 $tasktmp->id = $obj->taskid;
508 $tasktmp->ref = $obj->ref;
509 $tasktmp->label = $obj->label;
510 print $tasktmp->getNomUrl(1,
'withproject',
'task', 1,
'<br>');
512 print $langs->trans(
"NoTasks");
515 print
'<td class="center">'.dol_print_date($db->jdate($obj->dateo),
'day').
'</td>';
516 print
'<td class="center">'.dol_print_date($db->jdate($obj->datee),
'day');
517 if ($taskstatic->hasDelay()) {
521 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
524 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
527 print
'<td class="right">';
528 if (!empty($obj->taskid)) {
529 if (empty($obj->planned_workload) > 0) {
530 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
532 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
535 print $percentcompletion;
537 print
'<td class="right">';
538 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
550 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
566$parameters = array(
'user' => $user);
567$reshook = $hookmanager->executeHooks(
'dashboardActivities', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage projects.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.