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';
45$langs->loadLangs(array(
'projects',
'companies'));
48$hookmanager->initHooks(array(
'activityindex'));
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 ===
'') {
56if ($search_project_user == $user->id) {
62if ($user->socid > 0) {
63 $socid = $user->socid;
66if (!$user->hasRight(
'projet',
'lire')) {
76$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
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);
85 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
101$form =
new Form($db);
102$projectstatic =
new Project($db);
103$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
104$taskstatic =
new Task($db);
105$tasktmp =
new Task($db);
107$title = $langs->trans(
"Activities");
110llxHeader(
"", $title,
'',
'', 0, 0,
'',
'',
'',
'mod-project project-activity page-dashboard');
114$titleall = $langs->trans(
"AllAllowedProjects");
115if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
116 $titleall = $langs->trans(
"AllProjects");
118 $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
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">';
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").
'">';
135 $tooltiphelp = $langs->trans(
"MyTasksDesc");
137 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
138 $tooltiphelp = $langs->trans(
"TasksDesc");
140 $tooltiphelp = $langs->trans(
"TasksPublicDesc");
144print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
146print
'<div class="fichecenter"><div class="fichethirdleft">';
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>';
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";
170$resql = $db->query($sql);
174 while ($row = $db->fetch_object($resql)) {
175 print
'<tr class="oddeven">';
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);
183 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
192print
'<tr class="liste_total">';
193print
'<td>'.$langs->trans(
'Total').
'</td>';
194print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
200print
'</div><div class="fichetwothirdright">';
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>';
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";
224$resql = $db->query($sql);
228 while ($row = $db->fetch_object($resql)) {
229 print
'<tr class="oddeven">';
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);
237 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
246print
'<tr class="liste_total">';
247print
'<td>'.$langs->trans(
'Total').
'</td>';
248print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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>';
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);
334 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
335 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
337 $resql = $db->query($sql);
339 while ($row = $db->fetch_object($resql)) {
340 print
'<tr class="oddeven">';
342 $projectstatic->id = $row->rowid;
343 $projectstatic->ref = $row->ref;
344 $projectstatic->title = $row->title;
345 print $projectstatic->getNomUrl(1,
'', 1);
347 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
354 print
'<tr class="liste_total">';
355 print
'<td>'.$langs->trans(
'Total').
'</td>';
356 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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>';
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";
384 $resql = $db->query($sql);
386 while ($row = $db->fetch_object($resql)) {
387 print
'<tr class="oddeven">';
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);
395 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
402 print
'<tr class="liste_total">';
403 print
'<td>'.$langs->trans(
'Total').
'</td>';
404 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
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);
418 while ($obj = $db->fetch_object($resql)) {
419 $listofprojectcontacttype[$obj->rowid] = $obj->code;
424 if (count($listofprojectcontacttype) == 0) {
425 $listofprojectcontacttype[0] =
'0';
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);
434 while ($obj = $db->fetch_object($resql)) {
435 $listoftaskcontacttype[$obj->rowid] = $obj->code;
440 if (count($listoftaskcontacttype) == 0) {
441 $listoftaskcontacttype[0] =
'0';
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";
459 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
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).
")";
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);
469 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
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);
476 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
477 $resql = $db->query($sql);
479 $num = $db->num_rows($resql);
484 print
'<div class="div-table-responsive-no-min">';
485 print
'<table class="noborder centpercent">';
486 print
'<tr class="liste_titre">';
488 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
490 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
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>';
501 while ($i < $num && $i < $max) {
502 $obj = $db->fetch_object($resql);
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);
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);
522 if ($obj->userid && $userstatic->id != $obj->userid) {
523 $result = $userstatic->fetch($obj->userid);
528 if ($userstatic->id) {
529 $username = $userstatic->getNomUrl(0, 0);
532 print
'<tr class="oddeven">';
535 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
539 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
541 print $langs->trans(
"OppStatus".$code);
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>');
552 print $langs->trans(
"NoTasks");
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()) {
561 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
564 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
567 print
'<td class="right">';
568 if (!empty($obj->taskid)) {
569 if (empty($obj->planned_workload) > 0) {
570 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
572 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
575 $percentcompletion = 0;
577 print $percentcompletion;
579 print
'<td class="right">';
580 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
592 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
608$parameters = array(
'user' => $user);
609$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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.