From 51fff77355914a0b60dee32f032a31d62e3745c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Feb 2015 19:02:03 +0100 Subject: [PATCH] Fix: time 0 must be different than time unknown. --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/date.lib.php | 2 +- htdocs/core/lib/project.lib.php | 16 ++++++++++++---- htdocs/projet/tasks/index.php | 2 +- htdocs/projet/tasks/task.php | 12 +++++++++--- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6a6474c8306..719a79dcd1c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4097,7 +4097,7 @@ class Form * Function to show a form to select a duration on a page * * @param string $prefix Prefix for input fields - * @param int $iSecond Default preselected duration (number of seconds) + * @param int $iSecond Default preselected duration (number of seconds or '') * @param int $disabled Disable the combo box * @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo * @param string $minunderhours If 1, show minutes selection under the hours @@ -4112,7 +4112,7 @@ class Form $hourSelected=0; $minSelected=0; - if ($iSecond) + if ($iSecond != '') { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 072db988dc1..777b3633cb5 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -166,7 +166,7 @@ function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) /** Return, in clear text, value of a number of seconds in days, hours and minutes * * @param int $iSecond Number of seconds - * @param string $format Output format (all: total delay days hour:min like "2 days 12:30"", allhourmin: total delay hours:min like "60:30", allhour: total delay hours without min/sec like "60:30", fullhour: total delay hour decimal like "60.5" for 60:30, hour: only hours part "12", min: only minutes part "30", sec: only seconds part, month: only month part, year: only year part); + * @param string $format Output format ('all': total delay days hour:min like "2 days 12:30"", 'allhourmin': total delay hours:min like "60:30", 'allhour': total delay hours without min/sec like "60:30", 'fullhour': total delay hour decimal like "60.5" for 60:30, 'hour': only hours part "12", 'min': only minutes part "30", 'sec': only seconds part, 'month': only month part, 'year': only year part); * @param int $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour) * @param int $lengthOfWeek Length of week (default 7) * @return string Formated text of duration diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 27f0a5fe63f..27499f65c73 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -352,11 +352,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print dol_print_date($lines[$i]->date_end,'dayhour'); print ''; + $plannedworkloadoutputformat='allhourmin'; + $timespentoutputformat='allhourmin'; + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (! empty($conf->global->PROJECT_TIMES_PENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + // Planned Workload (in working hours) print ''; - $fullhour=convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); + $fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat); $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) + if ($lines[$i]->planned_workload != '') { print $fullhour; // TODO Add delay taking account of working hours per day and working day per week @@ -367,14 +372,17 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Progress declared print ''; - print $lines[$i]->progress.' %'; + if ($lines[$i]->progress != '') + { + print $lines[$i]->progress.' %'; + } print ''; // Time spent print ''; if ($showlineingray) print ''; else print ''; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'allhourmin'); + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; else print ''; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index a9b059fce81..21c6afb49fa 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -108,7 +108,7 @@ print ''.$langs->trans("RefTask").''; print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("DateStart").''; print ''.$langs->trans("DateEnd").''; -print ''.$langs->trans("PlannedWorkload"); +print ''.$langs->trans("PlannedWorkload"); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks //print '
('.$langs->trans("DelayWorkHour").')'; print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 27774057e4e..06f62c9f4c7 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -441,17 +441,23 @@ if ($id > 0 || ! empty($ref)) // Planned workload print ''.$langs->trans("PlannedWorkload").''; - print convertSecondToTime($object->planned_workload,'allhourmin'); + if ($object->planned_workload != '') + { + print convertSecondToTime($object->planned_workload,'allhourmin'); + } print ''; // Progress declared print ''.$langs->trans("ProgressDeclared").''; - print $object->progress.' %'; + if ($object->progress != '') + { + print $object->progress.' %'; + } print ''; // Progress calculated print ''.$langs->trans("ProgressCalculated").''; - if ($object->planned_workload) + if ($object->planned_workload != '') { $tmparray=$object->getSummaryOfTimeSpent(); if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';