Fix: time 0 must be different than time unknown.

This commit is contained in:
Laurent Destailleur 2015-02-28 19:02:03 +01:00
parent 804058c25e
commit 51fff77355
5 changed files with 25 additions and 11 deletions

View File

@ -4097,7 +4097,7 @@ class Form
* Function to show a form to select a duration on a page * Function to show a form to select a duration on a page
* *
* @param string $prefix Prefix for input fields * @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 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 $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 * @param string $minunderhours If 1, show minutes selection under the hours
@ -4112,7 +4112,7 @@ class Form
$hourSelected=0; $minSelected=0; $hourSelected=0; $minSelected=0;
if ($iSecond) if ($iSecond != '')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

View File

@ -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 /** Return, in clear text, value of a number of seconds in days, hours and minutes
* *
* @param int $iSecond Number of seconds * @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 $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour)
* @param int $lengthOfWeek Length of week (default 7) * @param int $lengthOfWeek Length of week (default 7)
* @return string Formated text of duration * @return string Formated text of duration

View File

@ -352,11 +352,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print dol_print_date($lines[$i]->date_end,'dayhour'); print dol_print_date($lines[$i]->date_end,'dayhour');
print '</td>'; print '</td>';
$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) // Planned Workload (in working hours)
print '<td align="right">'; print '<td align="right">';
$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 $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; print $fullhour;
// TODO Add delay taking account of working hours per day and working day per week // 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 // Progress declared
print '<td align="right">'; print '<td align="right">';
print $lines[$i]->progress.' %'; if ($lines[$i]->progress != '')
{
print $lines[$i]->progress.' %';
}
print '</td>'; print '</td>';
// Time spent // Time spent
print '<td align="right">'; print '<td align="right">';
if ($showlineingray) print '<i>'; if ($showlineingray) print '<i>';
else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'allhourmin'); if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
else print '--:--'; else print '--:--';
if ($showlineingray) print '</i>'; if ($showlineingray) print '</i>';
else print '</a>'; else print '</a>';

View File

@ -108,7 +108,7 @@ print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>'; print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>'; print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="center">'.$langs->trans("PlannedWorkload"); print '<td align="right">'.$langs->trans("PlannedWorkload");
// TODO Replace 86400 and 7 to take account working hours per day and working day per weeks // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
//print '<br>('.$langs->trans("DelayWorkHour").')'; //print '<br>('.$langs->trans("DelayWorkHour").')';
print '</td>'; print '</td>';

View File

@ -441,17 +441,23 @@ if ($id > 0 || ! empty($ref))
// Planned workload // Planned workload
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
print convertSecondToTime($object->planned_workload,'allhourmin'); if ($object->planned_workload != '')
{
print convertSecondToTime($object->planned_workload,'allhourmin');
}
print '</td></tr>'; print '</td></tr>';
// Progress declared // Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
print $object->progress.' %'; if ($object->progress != '')
{
print $object->progress.' %';
}
print '</td></tr>'; print '</td></tr>';
// Progress calculated // Progress calculated
print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
if ($object->planned_workload) if ($object->planned_workload != '')
{ {
$tmparray=$object->getSummaryOfTimeSpent(); $tmparray=$object->getSummaryOfTimeSpent();
if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';