29require
"../../main.inc.php";
30require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36$langs->loadLangs(array(
'projects',
'companies'));
41$hookmanager->initHooks(array(
'activityindex'));
43$action =
GETPOST(
'action',
'aZ09');
44$search_project_user =
GETPOST(
'search_project_user');
45$mine = (
GETPOST(
'mode',
'aZ09') ==
'mine' || $search_project_user == $user->id) ? 1 : 0;
46if ($mine == 0 && $search_project_user ===
'') {
49if ($search_project_user == $user->id) {
55if ($user->socid > 0) {
56 $socid = $user->socid;
59if (!$user->hasRight(
'projet',
'lire')) {
69$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
74 if ($action ==
'refresh_search_project_user' && $user->hasRight(
'projet',
'lire')) {
75 $search_project_user =
GETPOSTINT(
'search_project_user');
76 $tabparam = array(
"MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX" => $search_project_user);
78 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
95$projectstatic =
new Project($db);
96$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
97$taskstatic =
new Task($db);
98$tasktmp =
new Task($db);
100$title = $langs->trans(
"Activities");
103llxHeader(
"", $title,
'',
'', 0, 0,
'',
'',
'',
'mod-project project-activity page-dashboard');
107$titleall = $langs->trans(
"AllAllowedProjects");
108if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
109 $titleall = $langs->trans(
"AllProjects");
111 $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
116$morehtml .=
'<form name="projectform" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
117$morehtml .=
'<input type="hidden" name="token" value="'.newToken().
'">';
118$morehtml .=
'<input type="hidden" name="action" value="refresh_search_project_user">';
120$morehtml .=
'<SELECT name="search_project_user" id="search_project_user">';
121$morehtml .=
'<option name="all" value="0"'.($mine ?
'' :
' selected').
'>'.$titleall.
'</option>';
122$morehtml .=
'<option name="mine" value="'.$user->id.
'"'.(($search_project_user == $user->id) ?
' selected' :
'').
'>'.$langs->trans(
"ProjectsImContactFor").
'</option>';
123$morehtml .=
'</SELECT>';
124$morehtml .=
ajax_combobox(
"search_project_user", array(), 0, 0,
'resolve',
'-1',
'small');
125$morehtml .=
'<input type="submit" class="button smallpaddingimp" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
128 $tooltiphelp = $langs->trans(
"MyTasksDesc");
130 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
131 $tooltiphelp = $langs->trans(
"TasksDesc");
133 $tooltiphelp = $langs->trans(
"TasksPublicDesc");
137print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
139print
'<div class="fichecenter"><div class="fichethirdleft">';
143print
'<div class="div-table-responsive-no-min">';
144print
'<table class="noborder centpercent">';
145print
'<tr class="liste_titre">';
146print
'<td width="50%">'.$langs->trans(
'ActivityOnProjectToday').
'</td>';
147print
'<td width="50%" class="right">'.$langs->trans(
"Time").
'</td>';
150$sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
151$sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
152$sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
153$sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
154$sql .=
" WHERE t.fk_projet = p.rowid";
155$sql .=
" AND p.entity = ".((int) $conf->entity);
156$sql .=
" AND tt.fk_element = t.rowid";
157$sql .=
" AND tt.elementtype = 'task'";
158$sql .=
" AND tt.fk_user = ".((int) $user->id);
159$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)).
"'";
160$sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
161$sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
163$resql = $db->query($sql);
167 while ($row = $db->fetch_object($resql)) {
168 print
'<tr class="oddeven">';
170 $projectstatic->id = $row->rowid;
171 $projectstatic->ref = $row->ref;
172 $projectstatic->title = $row->title;
173 $projectstatic->public = $row->public;
174 print $projectstatic->getNomUrl(1,
'', 1);
176 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
185print
'<tr class="liste_total">';
186print
'<td>'.$langs->trans(
'Total').
'</td>';
187print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
193print
'</div><div class="fichetwothirdright">';
197print
'<div class="div-table-responsive-no-min">';
198print
'<table class="noborder centpercent">';
199print
'<tr class="liste_titre">';
200print
'<td>'.$langs->trans(
'ActivityOnProjectYesterday').
'</td>';
201print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
204$sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
205$sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
206$sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
207$sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
208$sql .=
" WHERE t.fk_projet = p.rowid";
209$sql .=
" AND p.entity = ".((int) $conf->entity);
210$sql .=
" AND tt.fk_element = t.rowid";
211$sql .=
" AND tt.elementtype = 'task'";
212$sql .=
" AND tt.fk_user = ".((int) $user->id);
213$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')).
"'";
214$sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
215$sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
217$resql = $db->query($sql);
221 while ($row = $db->fetch_object($resql)) {
222 print
'<tr class="oddeven">';
224 $projectstatic->id = $row->rowid;
225 $projectstatic->ref = $row->ref;
226 $projectstatic->title = $row->title;
227 $projectstatic->public = $row->public;
228 print $projectstatic->getNomUrl(1,
'', 1);
230 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
239print
'<tr class="liste_total">';
240print
'<td>'.$langs->trans(
'Total').
'</td>';
241print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
310 print
'<div class="div-table-responsive-no-min">';
311 print
'<table class="noborder centpercent">';
312 print
'<tr class="liste_titre">';
313 print
'<td>'.$langs->trans(
"ActivityOnProjectThisMonth").
': '.
dol_print_date($now,
"%B %Y").
'</td>';
314 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
317 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
318 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
319 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
320 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
321 $sql .=
" WHERE t.fk_projet = p.rowid";
322 $sql .=
" AND p.entity = ".((int) $conf->entity);
323 $sql .=
" AND tt.fk_element = t.rowid";
324 $sql .=
" AND tt.elementtype = 'task'";
325 $sql .=
" AND tt.fk_user = ".((int) $user->id);
327 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
328 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
330 $resql = $db->query($sql);
332 while ($row = $db->fetch_object($resql)) {
333 print
'<tr class="oddeven">';
335 $projectstatic->id = $row->rowid;
336 $projectstatic->ref = $row->ref;
337 $projectstatic->title = $row->title;
338 print $projectstatic->getNomUrl(1,
'', 1);
340 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
347 print
'<tr class="liste_total">';
348 print
'<td>'.$langs->trans(
'Total').
'</td>';
349 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
357 print
'<div class="div-table-responsive-no-min">';
358 print
'<br><table class="noborder centpercent">';
359 print
'<tr class="liste_titre">';
360 print
'<td>'.$langs->trans(
"ActivityOnProjectThisYear").
': '.
dol_print_date($now,
"%Y").
'</td>';
361 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
364 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
365 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
366 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
367 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
368 $sql .=
" WHERE t.fk_projet = p.rowid";
369 $sql .=
" AND p.entity = ".((int) $conf->entity);
370 $sql .=
" AND tt.fk_element = t.rowid";
371 $sql .=
" AND tt.elementtype = 'task'";
372 $sql .=
" AND tt.fk_user = ".((int) $user->id);
373 $sql .=
" AND YEAR(element_date) = '".dol_print_date($now,
"%Y").
"'";
374 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
375 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
377 $resql = $db->query($sql);
379 while ($row = $db->fetch_object($resql)) {
380 print
'<tr class="oddeven">';
382 $projectstatic->id = $row->rowid;
383 $projectstatic->ref = $row->ref;
384 $projectstatic->title = $row->title;
385 $projectstatic->public = $row->public;
386 print $projectstatic->getNomUrl(1,
'', 1);
388 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
395 print
'<tr class="liste_total">';
396 print
'<td>'.$langs->trans(
'Total').
'</td>';
397 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
405 $listofprojectcontacttype = array();
406 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
407 $sql .=
" WHERE ctc.element = '".$db->escape($projectstatic->element).
"'";
408 $sql .=
" AND ctc.source = 'internal'";
409 $resql = $db->query($sql);
411 while ($obj = $db->fetch_object($resql)) {
412 $listofprojectcontacttype[$obj->rowid] = $obj->code;
417 if (count($listofprojectcontacttype) == 0) {
418 $listofprojectcontacttype[0] =
'0';
421 $listoftaskcontacttype = array();
422 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
423 $sql .=
" WHERE ctc.element = '".$db->escape($taskstatic->element).
"'";
424 $sql .=
" AND ctc.source = 'internal'";
425 $resql = $db->query($sql);
427 while ($obj = $db->fetch_object($resql)) {
428 $listoftaskcontacttype[$obj->rowid] = $obj->code;
433 if (count($listoftaskcontacttype) == 0) {
434 $listoftaskcontacttype[0] =
'0';
444 $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,";
445 $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";
446 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
447 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
448 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
449 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
450 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on tasktime.fk_user = u.rowid";
452 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
454 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
455 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
456 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
459 $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);
462 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
464 $sql .=
" AND p.fk_statut=1";
465 $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";
466 $sql .=
" ORDER BY t.dateo DESC, t.rowid DESC, t.datee DESC";
467 $sql .= $db->plimit($max + 1);
469 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
470 $resql = $db->query($sql);
472 $num = $db->num_rows($resql);
477 print
'<div class="div-table-responsive-no-min">';
478 print
'<table class="noborder centpercent">';
479 print
'<tr class="liste_titre">';
481 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
483 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
485 print
'<th>'.$langs->trans(
'Task').
'</th>';
486 print
'<th class="center">'.$langs->trans(
'DateStart').
'</th>';
487 print
'<th class="center">'.$langs->trans(
'DateEnd').
'</th>';
488 print
'<th class="right">'.$langs->trans(
'PlannedWorkload').
'</th>';
489 print
'<th class="right">'.$langs->trans(
'TimeSpent').
'</th>';
490 print
'<th class="right">'.$langs->trans(
"ProgressCalculated").
'</td>';
491 print
'<th class="right">'.$langs->trans(
"ProgressDeclared").
'</td>';
494 while ($i < $num && $i < $max) {
495 $obj = $db->fetch_object($resql);
497 $projectstatic->id = $obj->projectid;
498 $projectstatic->ref = $obj->ref;
499 $projectstatic->title = $obj->title;
500 $projectstatic->statut = $obj->status;
501 $projectstatic->public = $obj->public;
502 $projectstatic->date_start = $db->jdate($obj->projdate_start);
503 $projectstatic->date_end = $db->jdate($obj->projdate_end);
505 $taskstatic->projectstatus = $obj->projectstatus;
506 $taskstatic->progress = $obj->progress;
507 $taskstatic->fk_statut = $obj->status;
508 $taskstatic->status = $obj->status;
509 $taskstatic->date_start = $db->jdate($obj->date_start);
510 $taskstatic->date_end = $db->jdate($obj->date_end);
511 $taskstatic->dateo = $db->jdate($obj->date_start);
512 $taskstatic->datee = $db->jdate($obj->date_end);
515 if ($obj->userid && $userstatic->id != $obj->userid) {
516 $result = $userstatic->fetch($obj->userid);
521 if ($userstatic->id) {
522 $username = $userstatic->getNomUrl(0, 0);
525 print
'<tr class="oddeven">';
528 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
532 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
534 print $langs->trans(
"OppStatus".$code);
539 if (!empty($obj->taskid)) {
540 $tasktmp->id = $obj->taskid;
541 $tasktmp->ref = $obj->ref;
542 $tasktmp->label = $obj->label;
543 print $tasktmp->getNomUrl(1,
'withproject',
'task', 1,
'<br>');
545 print $langs->trans(
"NoTasks");
548 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_start),
'day').
'</td>';
549 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_end),
'day');
550 if ($taskstatic->hasDelay()) {
554 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
557 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
560 print
'<td class="right">';
561 if (!empty($obj->taskid)) {
562 if (empty($obj->planned_workload) > 0) {
563 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
565 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
568 $percentcompletion = 0;
570 print $percentcompletion;
572 print
'<td class="right">';
573 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
585 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
601$parameters = array(
'user' => $user);
602$reshook = $hookmanager->executeHooks(
'dashboardActivities', $parameters, $object);
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
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.
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_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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.