diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index fb4d67d3f14..2731ec59e18 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1,11 +1,12 @@ - * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2014 Cedric GROSS +/* Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2014 Cedric GROSS + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -166,7 +167,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') * This class is an enhanced FPDI class that support method writeHTMLCell */ class FPDI_DolExtended extends FPDI - { + { /** * __call * @@ -432,9 +433,9 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height) // Add a background image on document if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) { - $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image + $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); - $pdf->SetAutoPageBreak(1,0); // Restore pagebreak + $pdf->SetAutoPageBreak(1,0); // Restore pagebreak } } @@ -492,164 +493,162 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) */ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) { - global $mysoc, $conf; + global $mysoc, $conf; - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); - $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); + $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); + $pdf->SetXY($curx, $cury); - $pdf->SetXY($curx, $cury); + if (empty($onlynumber)) + { + $pdf->SetFont('','B',$default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); + $cury+=4; + } - if (empty($onlynumber)) - { - $pdf->SetFont('','B',$default_font_size - $diffsizetitle); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; - } + $outputlangs->load("banks"); - $outputlangs->load("banks"); + // Get format of bank account according to its country + $usedetailedbban=$account->useDetailedBBAN(); - // Get format of bank account according to its country - $usedetailedbban=$account->useDetailedBBAN(); + //$onlynumber=0; $usedetailedbban=0; // For tests + if ($usedetailedbban) + { + $savcurx=$curx; - //$onlynumber=0; $usedetailedbban=0; // For tests - if ($usedetailedbban) - { - $savcurx=$curx; + if (empty($onlynumber)) + { + $pdf->SetFont('','',$default_font_size - $diffsizecontent); + $pdf->SetXY($curx, $cury); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury+=3; + } - if (empty($onlynumber)) - { - $pdf->SetFont('','',$default_font_size - $diffsizecontent); - $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; - } + // Use correct name of bank id according to country + $ibankey="IBANNumber"; + if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; + if (! empty($account->iban)) + { + $ibanDisplay_temp = $outputlangs->convToOutputCharset($account->iban); + $ibanDisplay = ""; - // Use correct name of bank id according to country - $ibankey="IBANNumber"; - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; - if (! empty($account->iban)) - { + for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++){ + $ibanDisplay .= $ibanDisplay_temp[$i]; + if($i%4 == 3 && $i > 0){ + $ibanDisplay .= " "; + } + } - $ibanDisplay_temp = $outputlangs->convToOutputCharset($account->iban); - $ibanDisplay = ""; + $pdf->SetFont('','B',$default_font_size - 3); + $pdf->SetXY($curx, $cury); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); + $cury+=3; + } - for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++){ - $ibanDisplay .= $ibanDisplay_temp[$i]; - if($i%4 == 3 && $i > 0){ - $ibanDisplay .= " "; - } - } + if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+8); - $pdf->SetFont('','B',$default_font_size - 3); - $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); - $cury+=3; - } + if ($usedetailedbban == 1) + { + $fieldstoshow=array('bank','desk','number','key'); + if ($conf->global->BANK_SHOW_ORDER_OPTION==1) $fieldstoshow=array('bank','desk','key','number'); + } + else if ($usedetailedbban == 2) + { + $fieldstoshow=array('bank','number'); + } + else dol_print_error('','Value returned by function useDetailedBBAN not managed'); - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+8); + foreach ($fieldstoshow as $val) + { + if ($val == 'bank') + { + // Bank code + $tmplength=18; + $pdf->SetXY($curx, $cury+5); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); + $pdf->SetXY($curx, $cury+1); + $curx+=$tmplength; + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); + if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); + } + if ($val == 'desk') + { + // Desk + $tmplength=18; + $pdf->SetXY($curx, $cury+5); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); + $pdf->SetXY($curx, $cury+1); + $curx+=$tmplength; + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); + if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); + } + if ($val == 'number') + { + // Number + $tmplength=24; + $pdf->SetXY($curx, $cury+5); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); + $pdf->SetXY($curx, $cury+1); + $curx+=$tmplength; + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); + if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); + } + if ($val == 'key') + { + // Key + $tmplength=13; + $pdf->SetXY($curx, $cury+5); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); + $pdf->SetXY($curx, $cury+1); + $curx+=$tmplength; + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); + if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); + } + } - if ($usedetailedbban == 1) - { - $fieldstoshow=array('bank','desk','number','key'); - if ($conf->global->BANK_SHOW_ORDER_OPTION==1) $fieldstoshow=array('bank','desk','key','number'); - } - else if ($usedetailedbban == 2) - { - $fieldstoshow=array('bank','number'); - } - else dol_print_error('','Value returned by function useDetailedBBAN not managed'); + $curx=$savcurx; + $cury+=10; + } + else + { + $pdf->SetFont('','B',$default_font_size - $diffsizecontent); + $pdf->SetXY($curx, $cury); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury+=3; - foreach ($fieldstoshow as $val) - { - if ($val == 'bank') - { - // Bank code - $tmplength=18; - $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); - } - if ($val == 'desk') - { - // Desk - $tmplength=18; - $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); - } - if ($val == 'number') - { - // Number - $tmplength=24; - $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); - } - if ($val == 'key') - { - // Key - $tmplength=13; - $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); - } - } + $pdf->SetFont('','B',$default_font_size - $diffsizecontent); + $pdf->SetXY($curx, $cury); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); + $cury+=3; - $curx=$savcurx; - $cury+=10; - } - else - { - $pdf->SetFont('','B',$default_font_size - $diffsizecontent); - $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + if ($diffsizecontent <= 2) $cury+=1; + } - $pdf->SetFont('','B',$default_font_size - $diffsizecontent); - $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); - $cury+=3; + // Use correct name of bank id according to country + $bickey="BICNumber"; + if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; - if ($diffsizecontent <= 2) $cury+=1; - } + $pdf->SetFont('','',$default_font_size - $diffsizecontent); - // Use correct name of bank id according to country - $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; + if (empty($onlynumber) && ! empty($account->domiciliation)) + { + $pdf->SetXY($curx, $cury); + $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); + $pdf->MultiCell(100, 3, $val, 0, 'L', 0); + //$nboflines=dol_nboflines_bis($val,120); + //$cury+=($nboflines*3)+2; + $tmpy=$pdf->getStringHeight(100, $val); + $cury+=$tmpy; + } + else if (! $usedetailedbban) $cury+=1; - $pdf->SetFont('','',$default_font_size - $diffsizecontent); + if (! empty($account->bic)) + { + $pdf->SetXY($curx, $cury); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); + } - if (empty($onlynumber) && ! empty($account->domiciliation)) - { - $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); - $pdf->MultiCell(100, 3, $val, 0, 'L', 0); - //$nboflines=dol_nboflines_bis($val,120); - //$cury+=($nboflines*3)+2; - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; - } - else if (! $usedetailedbban) $cury+=1; - - if (! empty($account->bic)) - { - $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); - } - - return $pdf->getY(); + return $pdf->getY(); } /** @@ -681,11 +680,11 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass { // Make substitution $substitutionarray=array( - '__FROM_NAME__' => $fromcompany->nom, - '__FROM_EMAIL__' => $fromcompany->email, - '__TOTAL_TTC__' => $object->total_ttc, - '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__FROM_NAME__' => $fromcompany->nom, + '__FROM_EMAIL__' => $fromcompany->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat ); complete_substitutions_array($substitutionarray,$outputlangs,$object); $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);