From 9d6663cf318d4c7ae8b004fc9a746aa8d707fc58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Nov 2009 21:55:03 +0000 Subject: [PATCH] Fix: Error in function ConvertSecondTotime --- htdocs/fichinter/fiche.php | 12 ++++++++---- htdocs/lib/date.lib.php | 24 ++++++++++++++---------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 0dc1c5a53ea..3b277f9f68a 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -445,7 +445,7 @@ if ($_GET["action"] == 'create') print ''; print ''.$langs->trans("Ref").''; - print ''."\n"; + print ''."\n"; if ($conf->projet->enabled) { @@ -488,7 +488,7 @@ if ($_GET["action"] == 'create') print '
'; print ''; print ''; print ''; - // Societe + // Third party print ""; // Project @@ -584,7 +584,11 @@ elseif ($fichinterid) } // Duration - print ''; + print ''; + //print $fichinter->duree.'-'.$conf->global->MAIN_DURATION_OF_WORKDAY; + print ''; + //print ''; + print ''; // Description (must be a textarea and not html must be allowed (used in list view) print '
'.$langs->trans("Company").''; - $html->select_societes('','socid','s.client = 1',1); + $html->select_societes('','socid','',1); print '
'; print ''; @@ -550,7 +550,7 @@ elseif ($fichinterid) print $html->showrefnav($fichinter,'ref','',1,'ref','ref'); print '
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
'.$langs->trans("TotalDuration").''.ConvertSecondToTime($fichinter->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).'
'.$langs->trans("TotalDuration").''.ConvertSecondToTime($fichinter->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).''.ConvertSecondToTime(90000,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).'
'; diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php index a621d539872..060690f3f9d 100644 --- a/htdocs/lib/date.lib.php +++ b/htdocs/lib/date.lib.php @@ -38,11 +38,13 @@ function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) } -/** \brief Return, in clear text, value of a number of seconds in days, hours and minutes - * \param iSecond Number of seconds - * \param format Output format (all: complete display, hour: displays only hours, min: displays only minutes) - * \param lengthOfDay Length of day (default 86400 seconds) - * \return sTime Formated text of duration +/** \brief Return, in clear text, value of a number of seconds in days, hours and minutes + * \param iSecond Number of seconds + * \param format Output format (all: complete display, hour: displays only hours, min: displays only minutes) + * \param lengthOfDay Length of day (default 86400 seconds) + * \return sTime Formated text of duration + * \example 3600 return 1h00, 86400 return 1d, 90000 return 1day 1hour + * */ function ConvertSecondToTime($iSecond,$format='all',$lengthOfDay=86400) { @@ -55,25 +57,27 @@ function ConvertSecondToTime($iSecond,$format='all',$lengthOfDay=86400) if ($iSecond >= $lengthOfDay) { $sDay=0; - for( $i = $iSecond; $i > $lengthOfDay; $i -= $lengthOfDay ) + for( $i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) { $sDay++; + $iSecond-=$lengthOfDay; } $dayTranslate = $langs->trans("Day"); if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); } $sTime=''; if ($sDay) $sTime.=$sDay.' '.$dayTranslate.' '; - $sHour = date("H",$iSecond)-1; + $sHour = date("H",$iSecond); $sMin = date("i",$iSecond); - if (!empty($sHour) && !empty($sMin)) + //print 'x'.$sHour.'-'.$sMin; + if (intval($sHour) || intval($sMin)) { - $sTime.= $sHour.'h'.$sMin; + $sTime.= $sHour.$langs->trans('h').$sMin; } } else if ($format == 'hour') { - $sTime=date("H",$iSecond)-1; + $sTime=date("H",$iSecond); } else if ($format == 'min') {