diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index b384ccceabe..637d5e6ccca 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -357,7 +357,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; // Planned Workload (in working hours) - print ''; + print ''; $fullhour=convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); $workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($lines[$i]->planned_workload) @@ -422,7 +422,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; print ''; print ''; - print ''; + print ''; print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; print ''; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 32b7d57e9b0..8d5d7c26a53 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -36,6 +36,8 @@ TaskTimeSpent=Time spent on tasks TaskTimeUser=User TaskTimeNote=Note TaskTimeDate=Date +TasksOnOpenedProject=Tasks on opened projects +WorkloadNotDefined=Workload not defined NewTimeSpent=New time spent MyTimeSpent=My time spent MyTasks=My tasks diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index bba783bf51e..6f83a42f2f3 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -49,6 +49,7 @@ $sortorder = GETPOST("sortorder",'alpha'); $socstatic=new Societe($db); $projectstatic=new Project($db); +$userstatic=new User($db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)),1); //var_dump($projectsListId); @@ -156,20 +157,23 @@ print ''; // Tasks for all resources of all opened projects and time spent for each task/resource print '
'; -$sql = "SELECT p.ref, p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; +$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); + +$sql = "SELECT p.ref, p.title, p.rowid as projectid, t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; $sql.= " WHERE p.entity = ".$conf->entity; -if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; +if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; $sql.= " AND p.fk_statut=1"; -$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, u.rowid, t.planned_workload, t.dateo, t.datee"; -$sql.= " ORDER BY u.rowid, t.dateo, t.datee"; +$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; +$sql.= " ORDER BY t.rowid, t.dateo, t.datee"; +$sql.= $db->plimit($max+1); // We want more to know if we have more than limit -$userstatic=new User($db); +$var=true; dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG); $resql = $db->query($sql); @@ -178,75 +182,78 @@ if ( $resql ) $num = $db->num_rows($resql); $i = 0; - if ($num > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) + print '
'; + + print_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'
'; + + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + while ($i < $num && $i < $max) { -/* $langs->load("errors"); - print ''; - print '';*/ - } - else - { - print '
'; + $obj = $db->fetch_object($resql); + $var=!$var; - print_fiche_titre($langs->trans("TimeSpent"),'','').'
'; - - print '
'.$langs->trans('TaskRessourceLinks').''.$langs->trans('Projects').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''.$langs->trans('PlannedWorkload').''.$langs->trans("ProgressDeclared").''; + print ''.$langs->trans('TimeSpent').''.$langs->trans("ProgressCalculated").''; + print '
'; - print $langs->trans("WarningTooManyDataPleaseUseMoreFilters"); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - while ($i < $num) + $username=''; + if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user { - $obj = $db->fetch_object($resql); - $var=!$var; - - $username=''; - if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user - { - $result=$userstatic->fetch($obj->userid); - if (! $result) $userstatic->id=0; - } - if ($userstatic->id) $username = $userstatic->getNomUrl(0,0); - - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - /* I disable this because information is wrong. This percent has no meaning for a particular resource. What do we want ? - * Percent of completion ? - * If we want to show completion, we must remove "user" into list, - if (empty($obj->planned_workload)) { - $percentcompletion = $langs->trans("Unknown"); - } else { - $percentcompletion = intval($obj->task_duration*100/$obj->planned_workload); - }*/ - print ''; - print "\n"; - - $i++; + $result=$userstatic->fetch($obj->userid); + if (! $result) $userstatic->id=0; } + if ($userstatic->id) $username = $userstatic->getNomUrl(0,0); - print "
'.$langs->trans('TaskRessourceLinks').''.$langs->trans('Projects').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''.$langs->trans('TimeSpent').'
'.$username.''; - $projectstatic->id=$obj->projectid; - $projectstatic->ref=$obj->ref; - $projectstatic->title=$obj->title; - print $projectstatic->getNomUrl(1,'',16); - //print ''.$obj->title.''; - print ''.$obj->label.''.dol_print_date($db->jdate($obj->dateo)).''.dol_print_date($db->jdate($obj->datee)).''; - //print $percentcompletion.' %'; - print convertSecondToTime($obj->timespent, 'all'); - print '
"; + print ""; + //print ''.$username.''; + print ''; + $projectstatic->id=$obj->projectid; + $projectstatic->ref=$obj->ref; + $projectstatic->title=$obj->title; + print $projectstatic->getNomUrl(1,'',16); + //print ''.$obj->title.''; + print ''; + print ''.$obj->label.''; + print ''.dol_print_date($db->jdate($obj->dateo),'day').''; + print ''.dol_print_date($db->jdate($obj->datee),'day').''; + print ''; + print convertSecondToTime($obj->planned_workload, 'all'); + print ''; + print ''; + print $obj->progress.'%'; + print ''; + print ''; + print convertSecondToTime($obj->timespent, 'all'); + print ''; + print ''; + if (empty($obj->planned_workload) > 0) { + $percentcompletion = $langs->trans("WorkloadNotDefined"); + } else { + $percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%'; + } + print $percentcompletion; + print ''; + print "\n"; + + $i++; } + if ($num > $max) + { + print ''.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").''; + } + + print ""; + + $db->free($resql); } else diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index f89a7e3398f..850b76bd3b3 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -417,7 +417,7 @@ else print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("DateStart").''; print ''.$langs->trans("DateEnd").''; - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("ProgressDeclared").''; print ''.$langs->trans("TimeSpent").''; print ''.$langs->trans("ProgressCalculated").''; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index cdf90a918a3..caaa134c931 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -86,7 +86,7 @@ else $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); // Get list of tasks in tasksarray and taskarrayfiltered -// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). +// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents). $tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status); // We load also tasks limited to a particular user $tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : ''); @@ -126,7 +126,9 @@ print ''; print ''; print "\n"; -if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) +$max=1000; + +if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?$max:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) { $langs->load("errors"); print ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 6e7ab74b941..09ffb36ce53 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -337,30 +337,6 @@ if ($id > 0 || ! empty($ref)) print ''; } - // Date start - print ''.$langs->trans("DateStart").''; - print dol_print_date($object->date_start,'dayhour'); - print ''; - - // Date end - print ''.$langs->trans("DateEnd").''; - print dol_print_date($object->date_end,'dayhour'); - print ''; - - // Planned workload - print ''.$langs->trans("PlannedWorkload").''.convertSecondToTime($object->planned_workload,'allhourmin').''; - - // Declared progress - print ''.$langs->trans("ProgressDeclared").''; - print $object->progress.' %'; - print ''; - - // Calculated progress - print ''.$langs->trans("ProgressCalculated").''; - if ($object->planned_workload) print round(100 * $object->duration_effective / $object->planned_workload,2).' %'; - else print ''; - print ''; - print ''; dol_fiche_end(); @@ -412,7 +388,7 @@ if ($id > 0 || ! empty($ref)) // Note print ''; - print ''; + print ''; print ''; // Progress declared @@ -469,7 +445,8 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print ''; + print ''; print ''; print ''; @@ -524,7 +501,7 @@ if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("Date").''; if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) { - print ''; + print ''; } else {