Fix: try another method for show linked objects in pdf
This commit is contained in:
parent
addc8db9e7
commit
625ba43c93
@ -282,7 +282,6 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a draft watermark on PDF files
|
||||
*
|
||||
@ -1250,7 +1249,6 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a currency code into its symbol
|
||||
*
|
||||
@ -1607,4 +1605,48 @@ function pdf_getCurrencySymbol(&$pdf, $currency_code)
|
||||
return $currency_sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show linked objects for PDF generation
|
||||
*
|
||||
* @param object $object Object
|
||||
* @param Translate $outputlangs Object lang for output
|
||||
* @return void
|
||||
*/
|
||||
function pdf_getLinkedObjects($object,$outputlangs)
|
||||
{
|
||||
$linkedobjects=array();
|
||||
|
||||
$object->fetchObjectLinked();
|
||||
|
||||
foreach($object->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
if ($objecttype == 'propal')
|
||||
{
|
||||
$outputlangs->load('propal');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
|
||||
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
|
||||
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
|
||||
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
|
||||
}
|
||||
}
|
||||
else if ($objecttype == 'commande')
|
||||
{
|
||||
$outputlangs->load('orders');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
|
||||
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref) . ($objects[$i]->ref_client ? ' ('.$objects[$i]->ref_client.')' : '');
|
||||
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
|
||||
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $linkedobjects;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1121,44 +1121,20 @@ class pdf_crabe extends ModelePDFFactures
|
||||
|
||||
$posy+=2;
|
||||
|
||||
// Add list of linked orders and proposals
|
||||
// TODO mutualiser
|
||||
$object->fetchObjectLinked();
|
||||
|
||||
foreach($object->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
if ($objecttype == 'propal')
|
||||
{
|
||||
$outputlangs->load('propal');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 2);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DatePropal")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'R');
|
||||
}
|
||||
}
|
||||
else if ($objecttype == 'commande')
|
||||
// Add list of linked objects
|
||||
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||
if (! empty($linkedobjects))
|
||||
{
|
||||
foreach($linkedobjects as $linkedobject)
|
||||
{
|
||||
$outputlangs->load('orders');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 2);
|
||||
$text=$objects[$i]->ref;
|
||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'R');
|
||||
}
|
||||
}
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 2);
|
||||
$pdf->MultiCell(100, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'R');
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->MultiCell(100, 3, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
if ($showaddress)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user