27 require
"../../main.inc.php";
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 $search_project_user =
GETPOST(
'search_project_user',
'int');
34 $mine =
GETPOST(
'mode',
'aZ09') ==
'mine' ? 1 : 0;
35 if ($search_project_user == $user->id) $mine = 1;
39 if ($user->socid > 0) $socid = $user->socid;
46 $hookmanager->initHooks(array(
'activityindex'));
49 $langs->load(
"projects");
62 $projectstatic =
new Project($db);
63 $taskstatic =
new Task($db);
64 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
65 $taskstatic =
new Task($db);
66 $tasktmp =
new Task($db);
68 $title = $langs->trans(
"Activities");
75 $titleall = $langs->trans(
"AllAllowedProjects");
76 if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans(
"AllProjects");
77 else $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
81 $morehtml .=
'<form name="projectform">';
82 $morehtml .=
'<SELECT name="mode">';
83 $morehtml .=
'<option name="all" value="all"'.($mine ?
'' :
' selected').
'>'.$titleall.
'</option>';
84 $morehtml .=
'<option name="mine" value="'.$user->id.
'"'.(($search_project_user == $user->id) ?
' selected' :
'').
'>'.$langs->trans(
"ProjectsImContactFor").
'</option>';
85 $morehtml .=
'</SELECT>';
86 $morehtml .=
'<input type="submit" class="button" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
88 if ($mine) $tooltiphelp = $langs->trans(
"MyTasksDesc");
90 if ($user->rights->projet->all->lire && !$socid) $tooltiphelp = $langs->trans(
"TasksDesc");
91 else $tooltiphelp = $langs->trans(
"TasksPublicDesc");
94 print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
96 print '<div class="fichecenter"><div class="fichethirdleft">';
99 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))
102 if (!empty($conf->projet->enabled) && $user->rights->projet->lire)
104 $listofsearchfields[
'search_task'] = array(
'text'=>
'Task');
107 if (count($listofsearchfields))
109 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
110 print
'<input type="hidden" name="token" value="'.newToken().
'">';
111 print
'<div class="div-table-responsive-no-min">';
112 print
'<table class="noborder nohover centpercent">';
114 foreach ($listofsearchfields as $key => $value)
116 if ($i == 0) print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
117 print
'<tr '.$bc[
false].
'>';
118 print
'<td class="nowrap"><label for="'.$key.
'">'.$langs->trans($value[
"text"]).
'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.
'" id="'.$key.
'" size="18"></td>';
119 if ($i == 0) print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
132 print
'<div class="div-table-responsive-no-min">';
133 print
'<table class="noborder centpercent">';
134 print
'<tr class="liste_titre">';
135 print
'<td width="50%">'.$langs->trans(
'ActivityOnProjectToday').
'</td>';
136 print
'<td width="50%" class="right">'.$langs->trans(
"Time").
'</td>';
139 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
141 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
142 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
143 $sql .=
" WHERE t.fk_projet = p.rowid";
144 $sql .=
" AND p.entity = ".$conf->entity;
145 $sql .=
" AND tt.fk_task = t.rowid";
146 $sql .=
" AND tt.fk_user = ".$user->id;
147 $sql .=
" AND task_date BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year)).
"' AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year)).
"'";
148 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
149 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
151 $resql = $db->query($sql);
156 while ($row = $db->fetch_object(
$resql))
158 print
'<tr class="oddeven">';
160 $projectstatic->id = $row->rowid;
161 $projectstatic->ref = $row->ref;
162 $projectstatic->title = $row->title;
163 $projectstatic->public = $row->public;
164 print $projectstatic->getNomUrl(1,
'', 1);
166 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
175 print
'<tr class="liste_total">';
176 print
'<td>'.$langs->trans(
'Total').
'</td>';
177 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
183 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
187 print
'<div class="div-table-responsive-no-min">';
188 print
'<table class="noborder centpercent">';
189 print
'<tr class="liste_titre">';
190 print
'<td>'.$langs->trans(
'ActivityOnProjectYesterday').
'</td>';
191 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
194 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
195 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
196 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
197 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
198 $sql .=
" WHERE t.fk_projet = p.rowid";
199 $sql .=
" AND p.entity = ".$conf->entity;
200 $sql .=
" AND tt.fk_task = t.rowid";
201 $sql .=
" AND tt.fk_user = ".$user->id;
202 $sql .=
" AND task_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')).
"'";
203 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
204 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
206 $resql = $db->query($sql);
211 while ($row = $db->fetch_object(
$resql))
213 print
'<tr class="oddeven">';
215 $projectstatic->id = $row->rowid;
216 $projectstatic->ref = $row->ref;
217 $projectstatic->title = $row->title;
218 $projectstatic->public = $row->public;
219 print $projectstatic->getNomUrl(1,
'', 1);
221 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
230 print
'<tr class="liste_total">';
231 print
'<td>'.$langs->trans(
'Total').
'</td>';
232 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
300 if (!empty($conf->global->PROJECT_TASK_TIME_MONTH))
302 print
'<div class="div-table-responsive-no-min">';
303 print
'<table class="noborder centpercent">';
304 print
'<tr class="liste_titre">';
305 print
'<td>'.$langs->trans(
"ActivityOnProjectThisMonth").
': '.
dol_print_date($now,
"%B %Y").
'</td>';
306 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
309 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
311 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
312 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
313 $sql .=
" WHERE t.fk_projet = p.rowid";
314 $sql .=
" AND p.entity = ".$conf->entity;
315 $sql .=
" AND tt.fk_task = t.rowid";
316 $sql .=
" AND tt.fk_user = ".$user->id;
318 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
319 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
321 $resql = $db->query($sql);
324 while ($row = $db->fetch_object(
$resql))
326 print
'<tr class="oddeven">';
328 $projectstatic->id = $row->rowid;
329 $projectstatic->ref = $row->ref;
330 $projectstatic->title = $row->title;
331 print $projectstatic->getNomUrl(1,
'', 1);
333 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
340 print
'<tr class="liste_total">';
341 print
'<td>'.$langs->trans(
'Total').
'</td>';
342 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
349 if (!empty($conf->global->PROJECT_TASK_TIME_YEAR))
351 print
'<div class="div-table-responsive-no-min">';
352 print
'<br><table class="noborder centpercent">';
353 print
'<tr class="liste_titre">';
354 print
'<td>'.$langs->trans(
"ActivityOnProjectThisYear").
': '.strftime(
"%Y", $now).
'</td>';
355 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
358 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
359 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
360 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
361 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
362 $sql .=
" WHERE t.fk_projet = p.rowid";
363 $sql .=
" AND p.entity = ".$conf->entity;
364 $sql .=
" AND tt.fk_task = t.rowid";
365 $sql .=
" AND tt.fk_user = ".$user->id;
366 $sql .=
" AND YEAR(task_date) = '".strftime(
"%Y", $now).
"'";
367 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
368 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
370 $resql = $db->query($sql);
373 while ($row = $db->fetch_object(
$resql))
375 print
'<tr class="oddeven">';
377 $projectstatic->id = $row->rowid;
378 $projectstatic->ref = $row->ref;
379 $projectstatic->title = $row->title;
380 $projectstatic->public = $row->public;
381 print $projectstatic->getNomUrl(1,
'', 1);
383 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
390 print
'<tr class="liste_total">';
391 print
'<td>'.$langs->trans(
'Total').
'</td>';
392 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
398 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA))
401 $listofprojectcontacttype = array();
402 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
403 $sql .=
" WHERE ctc.element = '".$db->escape($projectstatic->element).
"'";
404 $sql .=
" AND ctc.source = 'internal'";
405 $resql = $db->query($sql);
408 while ($obj = $db->fetch_object(
$resql))
410 $listofprojectcontacttype[$obj->rowid] = $obj->code;
413 if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] =
'0';
415 $listoftaskcontacttype = array();
416 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
417 $sql .=
" WHERE ctc.element = '".$db->escape($taskstatic->element).
"'";
418 $sql .=
" AND ctc.source = 'internal'";
419 $resql = $db->query($sql);
422 while ($obj = $db->fetch_object(
$resql))
424 $listoftaskcontacttype[$obj->rowid] = $obj->code;
427 if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] =
'0';
434 $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
436 $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,";
437 $sql .=
" t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
438 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
439 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
440 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
441 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_time as tasktime on tasktime.fk_task = t.rowid";
442 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on tasktime.fk_user = u.rowid";
445 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
447 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
448 if ($mine || empty($user->rights->projet->all->lire)) $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
451 $sql .=
" AND ect.fk_c_type_contact IN (".join(
',', array_keys($listoftaskcontacttype)).
") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id;
453 if ($socid) $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.
")";
454 $sql .=
" AND p.fk_statut=1";
455 $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";
456 $sql .=
" ORDER BY t.dateo desc, t.rowid desc, t.datee";
457 $sql .= $db->plimit($max + 1);
459 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
460 $resql = $db->query($sql);
463 $num = $db->num_rows(
$resql);
468 print
'<div class="div-table-responsive-no-min">';
469 print
'<table class="noborder centpercent">';
470 print
'<tr class="liste_titre">';
472 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
473 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
474 print
'<th>'.$langs->trans(
'Task').
'</th>';
475 print
'<th class="center">'.$langs->trans(
'DateStart').
'</th>';
476 print
'<th class="center">'.$langs->trans(
'DateEnd').
'</th>';
477 print
'<th class="right">'.$langs->trans(
'PlannedWorkload').
'</th>';
478 print
'<th class="right">'.$langs->trans(
'TimeSpent').
'</th>';
479 print
'<th class="right">'.$langs->trans(
"ProgressCalculated").
'</td>';
480 print
'<th class="right">'.$langs->trans(
"ProgressDeclared").
'</td>';
483 while ($i < $num && $i < $max)
485 $obj = $db->fetch_object(
$resql);
487 $projectstatic->id = $obj->projectid;
488 $projectstatic->ref = $obj->ref;
489 $projectstatic->title = $obj->title;
490 $projectstatic->statut = $obj->status;
491 $projectstatic->public = $obj->public;
492 $projectstatic->dateo = $db->jdate($obj->projdateo);
493 $projectstatic->datee = $db->jdate($obj->projdatee);
495 $taskstatic->projectstatus = $obj->projectstatus;
496 $taskstatic->progress = $obj->progress;
497 $taskstatic->fk_statut = $obj->status;
498 $taskstatic->dateo = $db->jdate($obj->dateo);
499 $taskstatic->datee = $db->jdate($obj->datee);
502 if ($obj->userid && $userstatic->id != $obj->userid)
504 $result = $userstatic->fetch($obj->userid);
505 if (!$result) $userstatic->id = 0;
507 if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0);
509 print
'<tr class="oddeven">';
512 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
514 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
517 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
518 if ($code) print $langs->trans(
"OppStatus".$code);
522 if (!empty($obj->taskid))
524 $tasktmp->id = $obj->taskid;
525 $tasktmp->ref = $obj->ref;
526 $tasktmp->label = $obj->label;
527 print $tasktmp->getNomUrl(1,
'withproject',
'task', 1,
'<br>');
528 }
else print $langs->trans(
"NoTasks");
530 print
'<td class="center">'.dol_print_date($db->jdate($obj->dateo),
'day').
'</td>';
531 print
'<td class="center">'.dol_print_date($db->jdate($obj->datee),
'day');
532 if ($taskstatic->hasDelay()) print
img_warning($langs->trans(
"Late"));
534 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
537 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
540 print
'<td class="right">';
541 if (!empty($obj->taskid))
543 if (empty($obj->planned_workload) > 0) {
544 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
546 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
549 print $percentcompletion;
551 print
'<td class="right">';
552 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
562 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++;
563 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
577 print
'</div></div></div>';
579 $parameters = array(
'user' => $user);
580 $reshook = $hookmanager->executeHooks(
'dashboardActivities', $parameters, $object);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
dol_now($mode= 'auto')
Return date for now.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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.
Class to manage projects.
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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_time_plus_duree($time, $duration_value, $duration_unit)
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.