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';
35$langs->loadLangs(array(
'projects',
'companies'));
40$hookmanager->initHooks(array(
'activityindex'));
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 ===
'') {
48if ($search_project_user == $user->id) {
54if ($user->socid > 0) {
55 $socid = $user->socid;
58if (!$user->hasRight(
'projet',
'lire')) {
68$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
73 if ($action ==
'refresh_search_project_user' && $user->hasRight(
'projet',
'lire')) {
74 $search_project_user =
GETPOSTINT(
'search_project_user');
75 $tabparam = array(
"MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX" => $search_project_user);
77 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
94$projectstatic =
new Project($db);
95$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
96$taskstatic =
new Task($db);
97$tasktmp =
new Task($db);
99$title = $langs->trans(
"Activities");
102llxHeader(
"", $title,
'',
'', 0, 0,
'',
'',
'',
'mod-project project-activity page-dashboard');
106$titleall = $langs->trans(
"AllAllowedProjects");
107if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
108 $titleall = $langs->trans(
"AllProjects");
110 $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
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">';
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").
'">';
127 $tooltiphelp = $langs->trans(
"MyTasksDesc");
129 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
130 $tooltiphelp = $langs->trans(
"TasksDesc");
132 $tooltiphelp = $langs->trans(
"TasksPublicDesc");
136print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
138print
'<div class="fichecenter"><div class="fichethirdleft">';
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>';
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";
162$resql = $db->query($sql);
166 while ($row = $db->fetch_object($resql)) {
167 print
'<tr class="oddeven">';
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);
175 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
184print
'<tr class="liste_total">';
185print
'<td>'.$langs->trans(
'Total').
'</td>';
186print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
192print
'</div><div class="fichetwothirdright">';
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>';
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";
216$resql = $db->query($sql);
220 while ($row = $db->fetch_object($resql)) {
221 print
'<tr class="oddeven">';
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);
229 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
238print
'<tr class="liste_total">';
239print
'<td>'.$langs->trans(
'Total').
'</td>';
240print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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>';
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);
326 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
327 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
329 $resql = $db->query($sql);
331 while ($row = $db->fetch_object($resql)) {
332 print
'<tr class="oddeven">';
334 $projectstatic->id = $row->rowid;
335 $projectstatic->ref = $row->ref;
336 $projectstatic->title = $row->title;
337 print $projectstatic->getNomUrl(1,
'', 1);
339 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
346 print
'<tr class="liste_total">';
347 print
'<td>'.$langs->trans(
'Total').
'</td>';
348 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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>';
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";
376 $resql = $db->query($sql);
378 while ($row = $db->fetch_object($resql)) {
379 print
'<tr class="oddeven">';
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);
387 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
394 print
'<tr class="liste_total">';
395 print
'<td>'.$langs->trans(
'Total').
'</td>';
396 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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);
410 while ($obj = $db->fetch_object($resql)) {
411 $listofprojectcontacttype[$obj->rowid] = $obj->code;
416 if (count($listofprojectcontacttype) == 0) {
417 $listofprojectcontacttype[0] =
'0';
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);
426 while ($obj = $db->fetch_object($resql)) {
427 $listoftaskcontacttype[$obj->rowid] = $obj->code;
432 if (count($listoftaskcontacttype) == 0) {
433 $listoftaskcontacttype[0] =
'0';
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";
451 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
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).
")";
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);
461 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
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);
468 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
469 $resql = $db->query($sql);
471 $num = $db->num_rows($resql);
476 print
'<div class="div-table-responsive-no-min">';
477 print
'<table class="noborder centpercent">';
478 print
'<tr class="liste_titre">';
480 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
482 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
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>';
493 while ($i < $num && $i < $max) {
494 $obj = $db->fetch_object($resql);
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);
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);
514 if ($obj->userid && $userstatic->id != $obj->userid) {
515 $result = $userstatic->fetch($obj->userid);
520 if ($userstatic->id) {
521 $username = $userstatic->getNomUrl(0, 0);
524 print
'<tr class="oddeven">';
527 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
531 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
533 print $langs->trans(
"OppStatus".$code);
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>');
544 print $langs->trans(
"NoTasks");
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()) {
553 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
556 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
559 print
'<td class="right">';
560 if (!empty($obj->taskid)) {
561 if (empty($obj->planned_workload) > 0) {
562 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
564 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
567 print $percentcompletion;
569 print
'<td class="right">';
570 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
582 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
598$parameters = array(
'user' => $user);
599$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.
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.
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.