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';
103$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
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="'.dolBuildUrl($_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 $htmltooltip = $langs->trans(
"MyTasksDesc");
137 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
138 $htmltooltip = $langs->trans(
"TasksDesc");
140 $htmltooltip = $langs->trans(
"TasksPublicDesc");
144print_barre_liste($form->textwithpicto($title, $htmltooltip), 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);
173 while ($row =
$db->fetch_object($resql)) {
174 print
'<tr class="oddeven">';
176 $projectstatic->id = $row->rowid;
177 $projectstatic->ref = $row->ref;
178 $projectstatic->title = $row->title;
179 $projectstatic->public = $row->public;
180 print $projectstatic->getNomUrl(1,
'', 1);
182 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
191print
'<tr class="liste_total">';
192print
'<td>'.$langs->trans(
'Total').
'</td>';
193print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
199print
'</div><div class="fichetwothirdright">';
203print
'<div class="div-table-responsive-no-min">';
204print
'<table class="noborder centpercent">';
205print
'<tr class="liste_titre">';
206print
'<td>'.$langs->trans(
'ActivityOnProjectYesterday').
'</td>';
207print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
210$sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
211$sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
212$sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
213$sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
214$sql .=
" WHERE t.fk_projet = p.rowid";
215$sql .=
" AND p.entity = ".((int)
$conf->entity);
216$sql .=
" AND tt.fk_element = t.rowid";
217$sql .=
" AND tt.elementtype = 'task'";
218$sql .=
" AND tt.fk_user = ".((int) $user->id);
219$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')).
"'";
220$sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
221$sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
223$resql =
$db->query($sql);
226 while ($row =
$db->fetch_object($resql)) {
227 print
'<tr class="oddeven">';
229 $projectstatic->id = $row->rowid;
230 $projectstatic->ref = $row->ref;
231 $projectstatic->title = $row->title;
232 $projectstatic->public = $row->public;
233 print $projectstatic->getNomUrl(1,
'', 1);
235 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
244print
'<tr class="liste_total">';
245print
'<td>'.$langs->trans(
'Total').
'</td>';
246print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
314 print
'<div class="div-table-responsive-no-min">';
315 print
'<table class="noborder centpercent">';
316 print
'<tr class="liste_titre">';
317 print
'<td>'.$langs->trans(
"ActivityOnProjectThisMonth").
': '.
dol_print_date($now,
"%B %Y").
'</td>';
318 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
321 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
322 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
323 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
324 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
325 $sql .=
" WHERE t.fk_projet = p.rowid";
326 $sql .=
" AND p.entity = ".((int)
$conf->entity);
327 $sql .=
" AND tt.fk_element = t.rowid";
328 $sql .=
" AND tt.elementtype = 'task'";
329 $sql .=
" AND tt.fk_user = ".((int) $user->id);
331 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
332 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
334 $resql =
$db->query($sql);
337 while ($row =
$db->fetch_object($resql)) {
338 print
'<tr class="oddeven">';
340 $projectstatic->id = $row->rowid;
341 $projectstatic->ref = $row->ref;
342 $projectstatic->title = $row->title;
343 print $projectstatic->getNomUrl(1,
'', 1);
345 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
352 print
'<tr class="liste_total">';
353 print
'<td>'.$langs->trans(
'Total').
'</td>';
354 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
362 print
'<div class="div-table-responsive-no-min">';
363 print
'<br><table class="noborder centpercent">';
364 print
'<tr class="liste_titre">';
365 print
'<td>'.$langs->trans(
"ActivityOnProjectThisYear").
': '.
dol_print_date($now,
"%Y").
'</td>';
366 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
369 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
370 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
371 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
372 $sql .=
", ".MAIN_DB_PREFIX.
"element_time as tt";
373 $sql .=
" WHERE t.fk_projet = p.rowid";
374 $sql .=
" AND p.entity = ".((int)
$conf->entity);
375 $sql .=
" AND tt.fk_element = t.rowid";
376 $sql .=
" AND tt.elementtype = 'task'";
377 $sql .=
" AND tt.fk_user = ".((int) $user->id);
378 $sql .=
" AND YEAR(element_date) = '".dol_print_date($now,
"%Y").
"'";
379 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
380 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
382 $resql =
$db->query($sql);
385 while ($row =
$db->fetch_object($resql)) {
386 print
'<tr class="oddeven">';
388 $projectstatic->id = $row->rowid;
389 $projectstatic->ref = $row->ref;
390 $projectstatic->title = $row->title;
391 $projectstatic->public = $row->public;
392 print $projectstatic->getNomUrl(1,
'', 1);
394 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
401 print
'<tr class="liste_total">';
402 print
'<td>'.$langs->trans(
'Total').
'</td>';
403 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
411 $listofprojectcontacttype = array();
412 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
413 $sql .=
" WHERE ctc.element = '".$db->escape($projectstatic->element).
"'";
414 $sql .=
" AND ctc.source = 'internal'";
415 $resql =
$db->query($sql);
417 while ($obj =
$db->fetch_object($resql)) {
418 $listofprojectcontacttype[$obj->rowid] = $obj->code;
423 if (count($listofprojectcontacttype) == 0) {
424 $listofprojectcontacttype[0] =
'0';
427 $listoftaskcontacttype = array();
428 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
429 $sql .=
" WHERE ctc.element = '".$db->escape($taskstatic->element).
"'";
430 $sql .=
" AND ctc.source = 'internal'";
431 $resql =
$db->query($sql);
433 while ($obj =
$db->fetch_object($resql)) {
434 $listoftaskcontacttype[$obj->rowid] = $obj->code;
439 if (count($listoftaskcontacttype) == 0) {
440 $listoftaskcontacttype[0] =
'0';
450 $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,";
451 $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";
452 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
453 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
454 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
455 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
456 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on tasktime.fk_user = u.rowid";
458 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
460 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
461 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
462 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
465 $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);
468 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
470 $sql .=
" AND p.fk_statut=1";
471 $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";
472 $sql .=
" ORDER BY t.dateo DESC, t.rowid DESC, t.datee DESC";
473 $sql .=
$db->plimit($max + 1);
475 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
476 $resql =
$db->query($sql);
478 $num =
$db->num_rows($resql);
483 print
'<div class="div-table-responsive-no-min">';
484 print
'<table class="noborder centpercent">';
485 print
'<tr class="liste_titre">';
487 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
489 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
491 print
'<th>'.$langs->trans(
'Task').
'</th>';
492 print
'<th class="center">'.$langs->trans(
'DateStart').
'</th>';
493 print
'<th class="center">'.$langs->trans(
'DateEnd').
'</th>';
494 print
'<th class="right">'.$langs->trans(
'PlannedWorkload').
'</th>';
495 print
'<th class="right">'.$langs->trans(
'TimeSpent').
'</th>';
496 print
'<th class="right">'.$langs->trans(
"ProgressCalculated").
'</td>';
497 print
'<th class="right">'.$langs->trans(
"ProgressDeclared").
'</td>';
500 while ($i < $num && $i < $max) {
501 $obj =
$db->fetch_object($resql);
503 $projectstatic->id = $obj->projectid;
504 $projectstatic->ref = $obj->ref;
505 $projectstatic->title = $obj->title;
506 $projectstatic->status = $obj->status;
507 $projectstatic->public = $obj->public;
508 $projectstatic->date_start =
$db->jdate($obj->projdate_start);
509 $projectstatic->date_end =
$db->jdate($obj->projdate_end);
511 $taskstatic->projectstatus = $obj->projectstatus;
512 $taskstatic->progress = $obj->progress;
513 $taskstatic->status = $obj->status;
514 $taskstatic->status = $obj->status;
515 $taskstatic->date_start =
$db->jdate($obj->date_start);
516 $taskstatic->date_end =
$db->jdate($obj->date_end);
517 $taskstatic->dateo =
$db->jdate($obj->date_start);
518 $taskstatic->datee =
$db->jdate($obj->date_end);
533 print
'<tr class="oddeven">';
536 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
542 print $langs->trans(
"OppStatus".$code);
547 if (!empty($obj->taskid)) {
548 $tasktmp->id = $obj->taskid;
549 $tasktmp->ref = $obj->ref;
550 $tasktmp->label = $obj->label;
551 print $tasktmp->getNomUrl(1,
'withproject',
'task', 1,
'<br>');
553 print $langs->trans(
"NoTasks");
556 print
'<td class="center">'.dol_print_date(
$db->jdate($obj->date_start),
'day').
'</td>';
557 print
'<td class="center">'.dol_print_date(
$db->jdate($obj->date_end),
'day');
558 if ($taskstatic->hasDelay()) {
562 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
565 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
568 print
'<td class="right">';
569 if (!empty($obj->taskid)) {
570 if (empty($obj->planned_workload) > 0) {
571 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
573 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
576 $percentcompletion = 0;
578 print $percentcompletion;
580 print
'<td class="right">';
581 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
593 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
609$parameters = array(
'user' => $user);
610$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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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, $entity=-1)
Save personal parameter.
dol_now($mode='gmt')
Return date for now.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.