Add retained warranty to pdf

This commit is contained in:
John BOTELLA 2018-08-10 16:03:39 +02:00
parent d6d8f98f38
commit 6fad0ea5bd
3 changed files with 45 additions and 1 deletions

View File

@ -4079,7 +4079,7 @@ else if ($id > 0 || ! empty($ref))
{
print $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->retained_warranty_fk_cond_reglement, 'none');
if(!$displayWarranty){
print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): ''));
print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" ');
}
}
print '</td></tr>';

View File

@ -1331,6 +1331,49 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
// Retained warranty
if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) )
{
// Check if this situation invoice is 100% for real
if(!empty($object->lines)){
$displayWarranty = true;
foreach( $object->lines as $i => $line ){
if($line->product_type < 2 && $line->situation_percent < 100){
$displayWarranty = false;
break;
}
}
}
if($displayWarranty){
$pdf->SetTextColor(40,40,40);
$pdf->SetFillColor(255,255,255);
$retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
// Billed - retained warranty
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty) , $useborder, 'R', 1);
// retained warranty
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty") . ' ('.$object->retained_warranty.'%)';
$retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty) , $useborder, 'R', 1);
}
}
}
}

View File

@ -551,6 +551,7 @@ AutoFillDateTo=Set end date for service line with next invoice date
AutoFillDateToShort=Set end date
MaxNumberOfGenerationReached=Max number of gen. reached
ToPayOn=To pay on %s
toPayOn=to pay on %s
RetainedWarranty=Retained Warranty
PaymentConditionsShortRetainedWarranty=Retained warranty payment terms
DefaultPaymentConditionsRetainedWarranty=Default retained warranty payment terms