Merge pull request #7245 from fappels/develop_supplier_order_PDF_pictures
New show product picture in supplier proposals
This commit is contained in:
commit
d95a39b191
@ -110,17 +110,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
|
||||
if ($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$this->posxtva=99;
|
||||
$this->posxtva=95;
|
||||
$this->posxup=114;
|
||||
$this->posxqty=130;
|
||||
$this->posxqty=132;
|
||||
$this->posxunit=147;
|
||||
} else {
|
||||
$this->posxtva=112;
|
||||
$this->posxtva=110;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
}
|
||||
|
||||
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
|
||||
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
|
||||
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
@ -167,6 +167,44 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$outputlangs->load("products");
|
||||
$outputlangs->load("orders");
|
||||
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
// Loop on each lines to detect if there is at least one image to show
|
||||
$realpatharray=array();
|
||||
if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
|
||||
{
|
||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||
{
|
||||
if (empty($object->lines[$i]->fk_product)) continue;
|
||||
|
||||
$objphoto = new Product($this->db);
|
||||
$objphoto->fetch($object->lines[$i]->fk_product);
|
||||
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
||||
{
|
||||
$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
|
||||
$dir = $conf->product->dir_output.'/'.$pdir;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
|
||||
$dir = $conf->product->dir_output.'/'.$pdir;
|
||||
}
|
||||
|
||||
$realpath='';
|
||||
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
|
||||
{
|
||||
$filename=$obj['photo'];
|
||||
//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
|
||||
$realpath = $dir.$filename;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($realpath) $realpatharray[$i]=$realpath;
|
||||
}
|
||||
}
|
||||
if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
|
||||
|
||||
if ($conf->fournisseur->dir_output.'/commande')
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
@ -338,16 +376,52 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
// Define size of image if we need it
|
||||
$imglinesize=array();
|
||||
if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
|
||||
|
||||
$pdf->setTopMargin($tab_top_newpage);
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
|
||||
$pageposbefore=$pdf->getPage();
|
||||
|
||||
$showpricebeforepagebreak=1;
|
||||
$posYAfterImage=0;
|
||||
$posYAfterDescription=0;
|
||||
|
||||
// We start with Photo of product line
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
|
||||
{
|
||||
$pdf->AddPage('','',true);
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
$pdf->setPage($pageposbefore+1);
|
||||
|
||||
$curY = $tab_top_newpage;
|
||||
$showpricebeforepagebreak=0;
|
||||
}
|
||||
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
|
||||
{
|
||||
$curX = $this->posxpicture-1;
|
||||
$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
|
||||
// $pdf->Image does not increase value return by getY, so we save it manually
|
||||
$posYAfterImage=$curY+$imglinesize['height'];
|
||||
}
|
||||
// Description of product line
|
||||
$curX = $this->posxdesc-1;
|
||||
$showpricebeforepagebreak=1;
|
||||
|
||||
$pdf->startTransaction();
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
|
||||
if ($posYAfterImage > 0)
|
||||
{
|
||||
$descWidth = $this->posxpicture-$curX;
|
||||
}
|
||||
else
|
||||
{
|
||||
$descWidth = $this->posxtva-$curX;
|
||||
}
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
|
||||
|
||||
$pageposafter=$pdf->getPage();
|
||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||
{
|
||||
@ -355,7 +429,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$pageposafter=$pageposbefore;
|
||||
//print $pageposafter.'-'.$pageposbefore;exit;
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
|
||||
$posyafter=$pdf->GetY();
|
||||
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
|
||||
{
|
||||
@ -472,6 +546,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
|
||||
$this->tva[$vatrate] += $tvaligne;
|
||||
|
||||
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||
@ -924,7 +999,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
|
||||
{
|
||||
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
|
||||
$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->SetXY($this->posxtva-3, $tab_top+1);
|
||||
@ -932,7 +1007,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
|
||||
$pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->SetXY($this->posxup-1, $tab_top+1);
|
||||
|
||||
@ -108,7 +108,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$this->posxqty=145;
|
||||
$this->posxdiscount=162;
|
||||
$this->postotalht=174;
|
||||
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
|
||||
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
|
||||
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
@ -357,7 +357,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$posYAfterDescription=0;
|
||||
|
||||
// We start with Photo of product line
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
|
||||
{
|
||||
$pdf->AddPage('','',true);
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
@ -368,7 +368,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$showpricebeforepagebreak=0;
|
||||
}
|
||||
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']))
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
|
||||
{
|
||||
$curX = $this->posxpicture-1;
|
||||
$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
|
||||
@ -380,7 +380,15 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$curX = $this->posxdesc-1;
|
||||
|
||||
$pdf->startTransaction();
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
|
||||
if ($posYAfterImage > 0)
|
||||
{
|
||||
$descWidth = $this->posxpicture-$curX;
|
||||
}
|
||||
else
|
||||
{
|
||||
$descWidth = $this->posxtva-$curX;
|
||||
}
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
|
||||
|
||||
$pageposafter=$pdf->getPage();
|
||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||
@ -389,7 +397,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$pageposafter=$pageposbefore;
|
||||
//print $pageposafter.'-'.$pageposbefore;exit;
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
|
||||
|
||||
$pageposafter=$pdf->getPage();
|
||||
$posyafter=$pdf->GetY();
|
||||
@ -1131,20 +1139,10 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
|
||||
{
|
||||
$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
|
||||
//$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
|
||||
{
|
||||
//$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
|
||||
$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
|
||||
$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
|
||||
//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->SetXY($this->posxtva-5, $tab_top+1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user