From 0b0a30d362d4eb0a057703b5d794b0451f60b951 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Dec 2012 20:58:49 +0100 Subject: [PATCH] Fix: Bad position of field with non A4 pages --- .../modules/rapport/pdf_paiement.class.php | 100 +++++++++++------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 394369f4df9..6f4bf70a383 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -62,6 +62,19 @@ class pdf_paiement $this->line_per_page = 25; $this->tab_height = 230; //$this->line_height * $this->line_per_page; + $this->posxdate=$this->marge_gauche+2; + $this->posxpaymenttype=42; + $this->posxinvoice=82; + $this->posxinvoiceamount=122; + $this->posxpaymentamount=162; + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpaymenttype-=10; + $this->posxinvoice-=0; + $this->posxinvoiceamount-=10; + $this->posxpaymentamount-=20; + } + } @@ -104,6 +117,7 @@ class pdf_paiement $file = $dir . "/payments-".$year."-".$month.".pdf"; $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance if (class_exists('TCPDF')) { @@ -143,7 +157,7 @@ class pdf_paiement $var=!$var; $lines[$i][0] = $objp->facnumber; - $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"%d %B %Y",false,$outputlangs,true); + $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true); $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code); $lines[$i][3] = $objp->num_paiement; $lines[$i][4] = price($objp->paiement_amount); @@ -223,44 +237,46 @@ class pdf_paiement // Do not add the BACKGROUND as this is a report //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + $default_font_size = pdf_getPDFFontSize($outputlangs); + $title=$outputlangs->transnoentities("ListOfCustomerPayments"); $title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true); - $pdf->SetFont('','B',12); - $pdf->SetXY(10,10); - $pdf->MultiCell(200, 2, $title, 0, 'C'); + $pdf->SetFont('','B',$default_font_size + 1); + $pdf->SetXY($this->marge_gauche,10); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C'); - $pdf->SetFont('','',10); + $pdf->SetFont('','',$default_font_size); - $pdf->SetXY(11, 16); + $pdf->SetXY($this->posxdate, 16); $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L'); - $pdf->SetXY(11, 22); + $pdf->SetXY($this->posxdate, 22); $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'L'); + // Title line + $pdf->SetXY($this->posxdate, $this->tab_top+2); + $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date'); - $pdf->SetXY(11, $this->tab_top+2); - $pdf->MultiCell(30, 2, 'Date'); + $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10); + $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2); + $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L'); - $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY(42, $this->tab_top+2); - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L'); + $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10); + $pdf->SetXY($this->posxinvoice, $this->tab_top+2); + $pdf->MultiCell($this->posxinvoiceamount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L'); - $pdf->line(80, $this->tab_top, 80, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY(82, $this->tab_top+2); - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Invoice"), 0, 'L'); + $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10); + $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2); + $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R'); - $pdf->line(120, $this->tab_top, 120, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY(122, $this->tab_top+2); - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'L'); + $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10); + $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R'); - $pdf->line(160, $this->tab_top, 160, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY(162, $this->tab_top+2); - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'L'); + $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10); - $pdf->line(10, $this->tab_top + 10, 200, $this->tab_top + 10); - - $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); + $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10); } @@ -275,7 +291,9 @@ class pdf_paiement */ function Body(&$pdf, $page, $lines, $outputlangs) { - $pdf->SetFont('','', 9); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetFont('','', $default_font_size - 1); $oldprowid = 0; $pdf->SetFillColor(220,220,220); $yp = 0; @@ -290,33 +308,35 @@ class pdf_paiement $page++; $pdf->AddPage(); $this->_pagehead($pdf, $page, 0, $outputlangs); - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); $yp = 0; } - $pdf->SetXY(10, $this->tab_top + 10 + $yp); - $pdf->MultiCell(30, $this->line_height, $lines[$j][1], 0, 'L', 1); + $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1); - $pdf->SetXY(40, $this->tab_top + 10 + $yp); - $pdf->MultiCell(80, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1); + $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1); - $pdf->SetXY(120, $this->tab_top + 10 + $yp); - $pdf->MultiCell(40, $this->line_height, '', 0, 'R', 1); + $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1); - $pdf->SetXY(160, $this->tab_top + 10 + $yp); - $pdf->MultiCell(40, $this->line_height, $lines[$j][4], 0, 'R', 1); + $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1); $yp = $yp + 5; } // Invoice number - $pdf->SetXY(80, $this->tab_top + 10 + $yp); - $pdf->MultiCell(40, $this->line_height, $lines[$j][0], 0, 'L', 0); + $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->posxinvoiceamount - $this->posxdate, $this->line_height, $lines[$j][0], 0, 'L', 0); - $pdf->SetXY(120, $this->tab_top + 10 + $yp); - $pdf->MultiCell(40, $this->line_height, $lines[$j][5], 0, 'R', 0); + // Invoice amount + $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0); - $pdf->SetXY(160, $this->tab_top + 10 + $yp); - $pdf->MultiCell(40, $this->line_height, $lines[$j][6], 0, 'R', 0); + // Payment amount + $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0); $yp = $yp + 5; if ($oldprowid <> $lines[$j][7])