Skip to content

Commit

Permalink
Fix #3400
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/core/lib/date.lib.php
  • Loading branch information
eldy committed Aug 20, 2015
1 parent c3fb148 commit 1b40953
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions htdocs/core/lib/date.lib.php
Expand Up @@ -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", 'allwithouthour': total delay days without hour part like "2 days", 'allhourmin': total delay with format 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
Expand All @@ -179,7 +179,7 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours
if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days

if ($format == 'all' || $format == 'allhour' || $format == 'allhourmin')
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
{
if ($iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US

Expand Down
27 changes: 22 additions & 5 deletions htdocs/core/modules/contract/doc/pdf_strato.modules.php
Expand Up @@ -268,18 +268,32 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

// Description of product line

if ($objectligne->datei) {
$datei = dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
if ($objectligne->date_ouverture_prevue) {
$datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true);
} else {
$datei = $langs->trans("Unknown");
}

if ($objectligne->duration) {
$durationi = convertSecondToTime($objectligne->duration);
if ($objectligne->date_fin_validite) {
$durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour');
$datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true);
} else {
$durationi = $langs->trans("Unknown");
$datee = $langs->trans("Unknown");
}

if ($objectligne->date_ouverture) {
$daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true);
} else {
$daters = $langs->trans("Unknown");
}

if ($objectligne->date_cloture) {
$datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true);
} else {
$datere = $langs->trans("Unknown");
}

$txtpredefinedservice='';
$txtpredefinedservice = $objectligne->product_ref;
if ($objectligne->product_label)
Expand All @@ -288,7 +302,10 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$txtpredefinedservice .= $objectligne->product_label;
}

$txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".$datei." - ".$outputlangs->transnoentities("Duration")." : ".$durationi,1,$outputlangs->charset_output).'</strong>';
$txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("DateStartPlannedShort")." : ".$datei." - ".$outputlangs->transnoentities("DateEndPlanned")." : ".$datee,1,$outputlangs->charset_output).'</strong>';
$txt.='<br>';
$txt.='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("DateStartRealShort")." : ".$daters,1,$outputlangs->charset_output);
if ($objectligne->date_cloture) $txt.=dol_htmlentitiesbr(" - ".$outputlangs->transnoentities("DateEndRealShort")." : ".$datere,1,$outputlangs->charset_output).'</strong>';
$desc=dol_htmlentitiesbr($objectligne->desc,1);

$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,dol_concatdesc($txtpredefinedservice,$desc)), 0, 1, 0);
Expand Down

0 comments on commit 1b40953

Please sign in to comment.