diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 51b9c5eff46..d4effca3905 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3987,7 +3987,7 @@ class Form { print ''; } - print $langs->trans('Hours'); + print ' '.$langs->trans('HourShort'); if ($minunderhours) print '
'; else print " "; @@ -4000,7 +4000,7 @@ class Form print '>'.$min.''; } print ""; - print $langs->trans('Minutes'). " "; + print ' '.$langs->trans('MinuteShort'). " "; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e473fdc3d98..8c53356fa67 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -629,7 +629,7 @@ class FormFile if (count($file_list) == 0 && $headershown) { - $out.=''.$langs->trans("None").''; + $out.=''.$langs->trans("None").''; } $this->numoffiles++; @@ -1150,7 +1150,7 @@ class FormFile $nboflinks = count($links); if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $var = true; + $var = false; foreach ($links as $link) { $var =! $var; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d8ecc52f6d9..98a2b111c6f 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2014 Laurent Destailleur * Copyright (C) 2010 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -455,12 +455,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t */ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - global $db, $user, $bc, $langs; - global $form, $projectstatic, $taskstatic; + global $form, $formother, $projectstatic, $taskstatic; - $formother = new FormOther($db); + if (! is_object($formother)) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($db); + } $lastprojectid=0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1256dd533e3..7663f520667 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -266,6 +266,7 @@ Afternoon=Afternoon Quadri=Quadri MonthOfDay=Month of the day HourShort=H +MinuteShort=mn Rate=Rate UseLocalTax=Include tax Bytes=Bytes diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php index e83fe30e865..0c2cebc2e27 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -179,7 +179,7 @@ print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("DateStart").''; print ''.$langs->trans("DateEnd").''; print ''.$langs->trans("PlannedWorkload").''; -print ''.$langs->trans("Progress").''; +print ''.$langs->trans("ProgressDeclared").''; print ''.$langs->trans("TimeSpent").''; print ''.$langs->trans("AddDuration").''; print "\n"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ad3736d3abe..2449d638405 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2014 Marcos GarcĂ­a * @@ -141,8 +141,9 @@ class Task extends CommonObject } } - //Update extrafield - if (!$error) { + // Update extrafield + if (! $error) + { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -816,6 +817,47 @@ class Task extends CommonObject return $ret; } + /** + * Calculate total of time spent for task + * + * @param int $id Id of object (here task) + * @return array Array of info for task array('min_date', 'max_date', 'total_duration') + */ + function getSummaryOfTimeSpent($id='') + { + global $langs; + + if (empty($id)) $id=$this->id; + + $result=array(); + + $sql = "SELECT"; + $sql.= " MIN(t.task_datehour) as min_date,"; + $sql.= " MAX(t.task_datehour) as max_date,"; + $sql.= " SUM(t.task_duration) as total_duration"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql.= " WHERE t.fk_task = ".$id; + + dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + + $result['min_date'] = $obj->min_date; + $result['max_date'] = $obj->max_date; + $result['total_duration'] = $obj->total_duration; + + $this->db->free($resql); + return $result; + } + else + { + dol_print_error($this->db); + return $result; + } + } + /** * Load object in memory from database * diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 7aea9314e5a..eaec5ae0816 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -320,7 +320,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; // Progress - print ''.$langs->trans("Progress").''; + print ''.$langs->trans("ProgressDeclared").''; print $formother->select_percent($progress,'progress'); print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index da200d565b6..ac6c72ec44c 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -351,8 +351,8 @@ if ($id > 0 || ! empty($ref)) print $form->select_duration('planned_workload',$object->planned_workload,0,'text'); print ''; - // Progress - print ''.$langs->trans("Progress").''; + // Progress declared + print ''.$langs->trans("ProgressDeclared").''; print $formother->select_percent($object->progress,'progress'); print ''; @@ -383,7 +383,7 @@ if ($id > 0 || ! empty($ref)) { /* * Fiche tache en mode visu - */ + */ $param=($withproject?'&withproject=1':''); $linkback=$withproject?''.$langs->trans("BackToList").'':''; @@ -440,14 +440,20 @@ if ($id > 0 || ! empty($ref)) print convertSecondToTime($object->planned_workload,'allhourmin'); print ''; - // Progress + // Progress declared print ''.$langs->trans("ProgressDeclared").''; print $object->progress.' %'; print ''; - // Progress + // Progress calculated print ''.$langs->trans("ProgressCalculated").''; - print $object->progress.' %'; + if ($object->planned_workload) + { + $tmparray=$object->getSummaryOfTimeSpent(); + if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; + else print '0 %'; + } + else print ''; print ''; // Description @@ -504,7 +510,7 @@ if ($id > 0 || ! empty($ref)) /* * Documents generes - */ + */ $filename=dol_sanitizeFileName($projectstatic->ref). "/". dol_sanitizeFileName($object->ref); $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref). "/" .dol_sanitizeFileName($object->ref); $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index eff94d532e5..f7b9f28e16a 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2006-2014 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -181,7 +181,7 @@ if (! empty($project_ref) && ! empty($withproject)) /* * View -*/ + */ llxHeader("",$langs->trans("Task")); @@ -193,7 +193,7 @@ if ($id > 0 || ! empty($ref)) { /* * Fiche projet en mode visu - */ + */ if ($object->fetch($id) >= 0) { $result=$projectstatic->fetch($object->fk_project); @@ -292,9 +292,37 @@ if ($id > 0 || ! empty($ref)) // Label print ''.$langs->trans("Label").''.$object->label.''; - // Planned workload - print ''.$langs->trans("PlannedWorkload").''.convertSecondToTime($object->planned_workload,'allhourmin').''; - + // 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").''; + print convertSecondToTime($object->planned_workload,'allhourmin'); + print ''; + + // Progress declared + print ''.$langs->trans("ProgressDeclared").''; + print $object->progress.' %'; + print ''; + + // Progress calculated + print ''.$langs->trans("ProgressCalculated").''; + if ($object->planned_workload) + { + $tmparray=$object->getSummaryOfTimeSpent(); + if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; + else print '0 %'; + } + else print ''; + print ''; + // Project if (empty($withproject)) { @@ -316,7 +344,7 @@ if ($id > 0 || ! empty($ref)) /* * Add time spent - */ + */ if ($user->rights->projet->creer) { print '
'; @@ -333,7 +361,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Date").''; print ''.$langs->trans("By").''; print ''.$langs->trans("Note").''; - print ''.$langs->trans("Progress").''; + print ''.$langs->trans("ProgressDeclared").''; print ''.$langs->trans("Duration").''; print ' '; print "\n"; @@ -363,14 +391,14 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Progress + // Progress declared print ''; - print $formother->select_percent($object->progress,'progress'); + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); print ''; // Duration print ''; - print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:''),0,'text'); + print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); print ''; print ''; @@ -384,7 +412,7 @@ if ($id > 0 || ! empty($ref)) /* * List of time spent - */ + */ $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; $sql.= ", u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";