Skip to content
Snippets Groups Projects
Commit ee1e7471 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: A lot of bug into generation of sticker pages or address pages

form members module:
- Position of element was wrong for non A4 pages.
- Removed bugged definition of 5164 sticker template.
- Solve problem of image proportions.
- Margin of right was wrong.

Conflicts:
	htdocs/core/modules/member/doc/pdf_standard.class.php
	htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
parent f6cda9de
Branches
Tags
No related merge requests found
...@@ -77,7 +77,7 @@ $_Avery_Labels = array ( ...@@ -77,7 +77,7 @@ $_Avery_Labels = array (
'width'=>101.6, 'width'=>101.6,
'height'=>50.8, 'height'=>50.8,
'font-size'=>8), 'font-size'=>8),
'5164'=>array('name'=>'5164 (Letter)', /* Bugged '5164'=>array('name'=>'5164 (Letter)',
'paper-size'=>'letter', 'paper-size'=>'letter',
'metric'=>'in', 'metric'=>'in',
'marginLeft'=>0.148, 'marginLeft'=>0.148,
...@@ -88,7 +88,7 @@ $_Avery_Labels = array ( ...@@ -88,7 +88,7 @@ $_Avery_Labels = array (
'SpaceY'=>0, 'SpaceY'=>0,
'width'=>4.0, 'width'=>4.0,
'height'=>3.33, 'height'=>3.33,
'font-size'=>12), 'font-size'=>12), */
'8600'=>array('name'=>'8600 (Letter)', '8600'=>array('name'=>'8600 (Letter)',
'paper-size'=>'letter', 'paper-size'=>'letter',
'metric'=>'mm', 'metric'=>'mm',
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
...@@ -122,12 +123,16 @@ class pdf_standard ...@@ -122,12 +123,16 @@ class pdf_standard
* @param Translate $outputlangs Output langs * @param Translate $outputlangs Output langs
* @param string $textright Text right * @param string $textright Text right
* @param int $idmember Id member * @param int $idmember Id member
* @param string $photo Photo member * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void * @return void
*/ */
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
{ {
global $mysoc,$conf,$langs; global $mysoc,$conf,$langs;
global $forceimgscalewidth,$forceimgscaleheight;
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
// We are in a new page, then we must add a page // We are in a new page, then we must add a page
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) { if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
...@@ -192,14 +197,31 @@ class pdf_standard ...@@ -192,14 +197,31 @@ class pdf_standard
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
} }
$xleft=2; $ytop=2+(empty($header)?0:1+$this->_Line_Height);
$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
$defaultratio=($maxwidthtouse/$maxheighttouse);
// Define widthtouse and heighttouse
$widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image
$tmp=dol_getImageSize($photo, false);
if ($tmp['height'])
{
$imgratio=$tmp['width']/$tmp['height'];
if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
}
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
// Center // Center
if ($textright=='') // Only a left part if ($textright=='') // Only a left part
{ {
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); // Output left area
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else else
{ {
$pdf->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
} }
} }
...@@ -207,35 +229,35 @@ class pdf_standard ...@@ -207,35 +229,35 @@ class pdf_standard
{ {
if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
{ {
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+21, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
else if ($textright == '%LOGO%' || $textright == '%PHOTO%') else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
{ {
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
} }
else else // text on halft left and text on half right
{ {
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
} }
else // Only a right part else // Only a right part
{ {
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20); // Output right area
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+1,20); if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else else
{ {
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
...@@ -126,6 +127,10 @@ class pdf_standardlabel ...@@ -126,6 +127,10 @@ class pdf_standardlabel
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='') function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
{ {
global $mysoc,$conf,$langs; global $mysoc,$conf,$langs;
global $forceimgscalewidth,$forceimgscaleheight;
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
// We are in a new page, then we must add a page // We are in a new page, then we must add a page
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) { if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
...@@ -180,14 +185,31 @@ class pdf_standardlabel ...@@ -180,14 +185,31 @@ class pdf_standardlabel
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
} }
// Middle
$xleft=2; $ytop=2+(empty($header)?0:1+$this->_Line_Height);
$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
$defaultratio=($maxwidthtouse/$maxheighttouse);
// Define widthtouse and heighttouse
$widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image
$tmp=dol_getImageSize($photo, false);
if ($tmp['height'])
{
$imgratio=$tmp['width']/$tmp['height'];
if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
}
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
// Center
if ($textright=='') // Only a left part if ($textright=='') // Only a left part
{ {
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); // Output left area
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else else
{ {
$pdf->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
} }
} }
...@@ -195,34 +217,35 @@ class pdf_standardlabel ...@@ -195,34 +217,35 @@ class pdf_standardlabel
{ {
if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
{ {
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+21, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
else if ($textright == '%LOGO%' || $textright == '%PHOTO%') else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
{ {
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
} }
else else // text on halft left and text on half right
{ {
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
} }
else // Only a right part else // Only a right part
{ {
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20); // Output right area
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+1,20); if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else else
{ {
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
} }
} }
......
...@@ -204,3 +204,13 @@ Quarter1=1st. Quarter ...@@ -204,3 +204,13 @@ Quarter1=1st. Quarter
Quarter2=2nd. Quarter Quarter2=2nd. Quarter
Quarter3=3rd. Quarter Quarter3=3rd. Quarter
Quarter4=4th. Quarter Quarter4=4th. Quarter
BarCodePrintsheet=Imprimer code barre
PageToGenerateBarCodeSheets=With this tool, you can print sheets of bar code stickers. Choose format of your sticker page, type of barcode and value of barcode, then click on button <b>%s</b>.
NumberOfStickers=Number of stickers to print on page
PrintsheetForOneBarCode=Print several stickers for one barcode
BuildPageToPrint=Generate page to print
FillBarCodeTypeAndValueManually=Fill barcode type and value manually
FillBarCodeTypeAndValueFromProduct=Fill barcode type and value from a product
FillBarCodeTypeAndValueFromThirdParty=Fill barcode type and value from a thirdparty
BarcodeStickersMask=xxx
\ No newline at end of file
...@@ -204,3 +204,12 @@ Quarter1=1er trimestre ...@@ -204,3 +204,12 @@ Quarter1=1er trimestre
Quarter2=2eme trimestre Quarter2=2eme trimestre
Quarter3=3eme trimestre Quarter3=3eme trimestre
Quarter4=4eme trimestre Quarter4=4eme trimestre
BarCodePrintsheet=Imprimer code barre
PageToGenerateBarCodeSheets=Avec cet outils, vous pouvez imprimer une planche d'étiquette de code-barres. Sélectionner votre format de planche d'étiquette, le type de code-barre et la valeur du code-barre puis cliquer sur le bouton <b>%s</b>.
NumberOfStickers=Nombre d'étiquettes à imprimer sur la/les planches
PrintsheetForOneBarCode=Imprimer des étiquettes d'un code barre particulier
BuildPageToPrint=Générer la page à imprimer
FillBarCodeTypeAndValueManually=Remplir le type et la valeur du code barre manuellement
FillBarCodeTypeAndValueFromProduct=Remplir le type et la valeur du code barre depuis un produit
FillBarCodeTypeAndValueFromThirdParty=Remplir le type et la valeur du code barre depuis un tiers
BarcodeStickersMask=xxx
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment