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) {
41 if ($user->socid > 0) {
42 $socid = $user->socid;
45 if (!$user->rights->projet->lire) {
52 $hookmanager->initHooks(array(
'activityindex'));
55 $langs->load(
"projects");
68 $projectstatic =
new Project($db);
69 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
70 $taskstatic =
new Task($db);
71 $tasktmp =
new Task($db);
73 $title = $langs->trans(
"Activities");
80 $titleall = $langs->trans(
"AllAllowedProjects");
81 if (!empty($user->rights->projet->all->lire) && !$socid) {
82 $titleall = $langs->trans(
"AllProjects");
84 $titleall = $langs->trans(
"AllAllowedProjects").
'<br><br>';
89 $morehtml .=
'<form name="projectform">';
90 $morehtml .=
'<SELECT name="mode">';
91 $morehtml .=
'<option name="all" value="all"'.($mine ?
'' :
' selected').
'>'.$titleall.
'</option>';
92 $morehtml .=
'<option name="mine" value="'.$user->id.
'"'.(($search_project_user == $user->id) ?
' selected' :
'').
'>'.$langs->trans(
"ProjectsImContactFor").
'</option>';
93 $morehtml .=
'</SELECT>';
94 $morehtml .=
'<input type="submit" class="button" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
97 $tooltiphelp = $langs->trans(
"MyTasksDesc");
99 if ($user->rights->projet->all->lire && !$socid) {
100 $tooltiphelp = $langs->trans(
"TasksDesc");
102 $tooltiphelp = $langs->trans(
"TasksPublicDesc");
106 print_barre_liste(
$form->textwithpicto($title, $tooltiphelp), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, -1,
'projecttask', 0, $morehtml);
108 print
'<div class="fichecenter"><div class="fichethirdleft">';
112 print
'<div class="div-table-responsive-no-min">';
113 print
'<table class="noborder centpercent">';
114 print
'<tr class="liste_titre">';
115 print
'<td width="50%">'.$langs->trans(
'ActivityOnProjectToday').
'</td>';
116 print
'<td width="50%" class="right">'.$langs->trans(
"Time").
'</td>';
119 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
121 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
122 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
123 $sql .=
" WHERE t.fk_projet = p.rowid";
124 $sql .=
" AND p.entity = ".((int) $conf->entity);
125 $sql .=
" AND tt.fk_task = t.rowid";
126 $sql .=
" AND tt.fk_user = ".((int) $user->id);
127 $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)).
"'";
128 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
129 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
131 $resql = $db->query($sql);
135 while ($row = $db->fetch_object(
$resql)) {
136 print
'<tr class="oddeven">';
138 $projectstatic->id = $row->rowid;
139 $projectstatic->ref = $row->ref;
140 $projectstatic->title = $row->title;
141 $projectstatic->public = $row->public;
142 print $projectstatic->getNomUrl(1,
'', 1);
144 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
153 print
'<tr class="liste_total">';
154 print
'<td>'.$langs->trans(
'Total').
'</td>';
155 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
161 print
'</div><div class="fichetwothirdright">';
165 print
'<div class="div-table-responsive-no-min">';
166 print
'<table class="noborder centpercent">';
167 print
'<tr class="liste_titre">';
168 print
'<td>'.$langs->trans(
'ActivityOnProjectYesterday').
'</td>';
169 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
172 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
173 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
174 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
175 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
176 $sql .=
" WHERE t.fk_projet = p.rowid";
177 $sql .=
" AND p.entity = ".((int) $conf->entity);
178 $sql .=
" AND tt.fk_task = t.rowid";
179 $sql .=
" AND tt.fk_user = ".((int) $user->id);
180 $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')).
"'";
181 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
182 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
184 $resql = $db->query($sql);
188 while ($row = $db->fetch_object(
$resql)) {
189 print
'<tr class="oddeven">';
191 $projectstatic->id = $row->rowid;
192 $projectstatic->ref = $row->ref;
193 $projectstatic->title = $row->title;
194 $projectstatic->public = $row->public;
195 print $projectstatic->getNomUrl(1,
'', 1);
197 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
206 print
'<tr class="liste_total">';
207 print
'<td>'.$langs->trans(
'Total').
'</td>';
208 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
276 if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) {
277 print
'<div class="div-table-responsive-no-min">';
278 print
'<table class="noborder centpercent">';
279 print
'<tr class="liste_titre">';
280 print
'<td>'.$langs->trans(
"ActivityOnProjectThisMonth").
': '.
dol_print_date($now,
"%B %Y").
'</td>';
281 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
284 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
285 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
286 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
287 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
288 $sql .=
" WHERE t.fk_projet = p.rowid";
289 $sql .=
" AND p.entity = ".((int) $conf->entity);
290 $sql .=
" AND tt.fk_task = t.rowid";
291 $sql .=
" AND tt.fk_user = ".((int) $user->id);
293 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
294 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
296 $resql = $db->query($sql);
298 while ($row = $db->fetch_object(
$resql)) {
299 print
'<tr class="oddeven">';
301 $projectstatic->id = $row->rowid;
302 $projectstatic->ref = $row->ref;
303 $projectstatic->title = $row->title;
304 print $projectstatic->getNomUrl(1,
'', 1);
306 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
313 print
'<tr class="liste_total">';
314 print
'<td>'.$langs->trans(
'Total').
'</td>';
315 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
322 if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) {
323 print
'<div class="div-table-responsive-no-min">';
324 print
'<br><table class="noborder centpercent">';
325 print
'<tr class="liste_titre">';
326 print
'<td>'.$langs->trans(
"ActivityOnProjectThisYear").
': '.strftime(
"%Y", $now).
'</td>';
327 print
'<td class="right">'.$langs->trans(
"Time").
'</td>';
330 $sql =
"SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
332 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
333 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task_time as tt";
334 $sql .=
" WHERE t.fk_projet = p.rowid";
335 $sql .=
" AND p.entity = ".((int) $conf->entity);
336 $sql .=
" AND tt.fk_task = t.rowid";
337 $sql .=
" AND tt.fk_user = ".((int) $user->id);
338 $sql .=
" AND YEAR(task_date) = '".strftime(
"%Y", $now).
"'";
339 $sql .=
" AND p.rowid in (".$db->sanitize($projectsListId).
")";
340 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public";
342 $resql = $db->query($sql);
344 while ($row = $db->fetch_object(
$resql)) {
345 print
'<tr class="oddeven">';
347 $projectstatic->id = $row->rowid;
348 $projectstatic->ref = $row->ref;
349 $projectstatic->title = $row->title;
350 $projectstatic->public = $row->public;
351 print $projectstatic->getNomUrl(1,
'', 1);
353 print
'<td class="right">'.convertSecondToTime($row->nb,
'allhourmin').
'</td>';
360 print
'<tr class="liste_total">';
361 print
'<td>'.$langs->trans(
'Total').
'</td>';
362 print
'<td class="right">'.convertSecondToTime($total,
'allhourmin').
'</td>';
368 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) {
370 $listofprojectcontacttype = array();
371 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
372 $sql .=
" WHERE ctc.element = '".$db->escape($projectstatic->element).
"'";
373 $sql .=
" AND ctc.source = 'internal'";
374 $resql = $db->query($sql);
376 while ($obj = $db->fetch_object(
$resql)) {
377 $listofprojectcontacttype[$obj->rowid] = $obj->code;
382 if (count($listofprojectcontacttype) == 0) {
383 $listofprojectcontacttype[0] =
'0';
386 $listoftaskcontacttype = array();
387 $sql =
"SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
388 $sql .=
" WHERE ctc.element = '".$db->escape($taskstatic->element).
"'";
389 $sql .=
" AND ctc.source = 'internal'";
390 $resql = $db->query($sql);
392 while ($obj = $db->fetch_object(
$resql)) {
393 $listoftaskcontacttype[$obj->rowid] = $obj->code;
398 if (count($listoftaskcontacttype) == 0) {
399 $listoftaskcontacttype[0] =
'0';
407 $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
409 $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,";
410 $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";
411 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
412 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
413 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
414 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_time as tasktime on tasktime.fk_task = t.rowid";
415 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on tasktime.fk_user = u.rowid";
417 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ect";
419 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
420 if ($mine || empty($user->rights->projet->all->lire)) {
421 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
424 $sql .=
" AND ect.fk_c_type_contact IN (".$db->sanitize(join(
',', array_keys($listoftaskcontacttype))).
") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((
int) $user->id);
427 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
429 $sql .=
" AND p.fk_statut=1";
430 $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";
431 $sql .=
" ORDER BY t.dateo desc, t.rowid desc, t.datee";
432 $sql .= $db->plimit($max + 1);
434 dol_syslog(
'projet:index.php: affectationpercent', LOG_DEBUG);
435 $resql = $db->query($sql);
437 $num = $db->num_rows(
$resql);
442 print
'<div class="div-table-responsive-no-min">';
443 print
'<table class="noborder centpercent">';
444 print
'<tr class="liste_titre">';
446 print
'<th>'.$langs->trans(
'OpenedProjects').
'</th>';
447 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
448 print
'<th>'.$langs->trans(
'OpportunityStatus').
'</th>';
450 print
'<th>'.$langs->trans(
'Task').
'</th>';
451 print
'<th class="center">'.$langs->trans(
'DateStart').
'</th>';
452 print
'<th class="center">'.$langs->trans(
'DateEnd').
'</th>';
453 print
'<th class="right">'.$langs->trans(
'PlannedWorkload').
'</th>';
454 print
'<th class="right">'.$langs->trans(
'TimeSpent').
'</th>';
455 print
'<th class="right">'.$langs->trans(
"ProgressCalculated").
'</td>';
456 print
'<th class="right">'.$langs->trans(
"ProgressDeclared").
'</td>';
459 while ($i < $num && $i < $max) {
460 $obj = $db->fetch_object(
$resql);
462 $projectstatic->id = $obj->projectid;
463 $projectstatic->ref = $obj->ref;
464 $projectstatic->title = $obj->title;
465 $projectstatic->statut = $obj->status;
466 $projectstatic->public = $obj->public;
467 $projectstatic->dateo = $db->jdate($obj->projdateo);
468 $projectstatic->datee = $db->jdate($obj->projdatee);
470 $taskstatic->projectstatus = $obj->projectstatus;
471 $taskstatic->progress = $obj->progress;
472 $taskstatic->fk_statut = $obj->status;
473 $taskstatic->dateo = $db->jdate($obj->dateo);
474 $taskstatic->datee = $db->jdate($obj->datee);
477 if ($obj->userid && $userstatic->id != $obj->userid) {
478 $result = $userstatic->fetch($obj->userid);
483 if ($userstatic->id) {
484 $username = $userstatic->getNomUrl(0, 0);
487 print
'<tr class="oddeven">';
490 print $projectstatic->getNomUrl(1,
'', 0,
'',
'<br>');
492 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
494 $code =
dol_getIdFromCode($db, $obj->opp_status,
'c_lead_status',
'rowid',
'code');
496 print $langs->trans(
"OppStatus".$code);
501 if (!empty($obj->taskid)) {
502 $tasktmp->id = $obj->taskid;
503 $tasktmp->ref = $obj->ref;
504 $tasktmp->label = $obj->label;
505 print $tasktmp->getNomUrl(1,
'withproject',
'task', 1,
'<br>');
507 print $langs->trans(
"NoTasks");
510 print
'<td class="center">'.dol_print_date($db->jdate($obj->dateo),
'day').
'</td>';
511 print
'<td class="center">'.dol_print_date($db->jdate($obj->datee),
'day');
512 if ($taskstatic->hasDelay()) {
516 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
519 print
'<td class="right"><a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$obj->taskid.
'&withproject=1">';
522 print
'<td class="right">';
523 if (!empty($obj->taskid)) {
524 if (empty($obj->planned_workload) > 0) {
525 $percentcompletion = $langs->trans(
"WorkloadNotDefined");
527 $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).
'%';
530 print $percentcompletion;
532 print
'<td class="right">';
533 print ($obj->taskid > 0) ? $obj->progress.
'%' :
'';
542 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
545 print
'<tr><td colspan="'.$colspan.
'">'.$langs->trans(
"WarningTooManyDataPleaseUseMoreFilters").
'</td></tr>';
559 print
'</div></div>';
561 $parameters = array(
'user' => $user);
562 $reshook = $hookmanager->executeHooks(
'dashboardActivities', $parameters, $object);
Class to manage projects.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.