From b75923871c887a17d8a487d37272d62fab0582c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Nov 2015 14:55:14 +0100 Subject: [PATCH] FIX: Too many information were hidden. A lot of users still need bank account on PDF. --- htdocs/core/lib/pdf.lib.php | 137 +++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 65 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 44c4154a038..6389c71b06c 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -173,7 +173,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 * @@ -565,71 +565,77 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $cury+=3; } - /* - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+8); - - if ($usedetailedbban == 1) + if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enought for them { - $fieldstoshow=array('bank','desk','number','key'); - if ($conf->global->BANK_SHOW_ORDER_OPTION==1) $fieldstoshow=array('bank','desk','key','number'); + // Note: + // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) + // desk = code guichet (FR), used only when $usedetailedbban = 1 + // number = account number + // key = check control key used only when $usedetailedbban = 1 + if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); + + 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'); + + foreach ($fieldstoshow as $val) + { + if ($val == 'bank') + { + // Bank code + $tmplength=18; + $pdf->SetXY($curx, $cury+4); + $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+7); + } + if ($val == 'desk') + { + // Desk + $tmplength=18; + $pdf->SetXY($curx, $cury+4); + $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+7); + } + if ($val == 'number') + { + // Number + $tmplength=24; + $pdf->SetXY($curx, $cury+4); + $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+7); + } + if ($val == 'key') + { + // Key + $tmplength=13; + $pdf->SetXY($curx, $cury+4); + $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+7); + } + } + + $curx=$savcurx; + $cury+=8; } - else if ($usedetailedbban == 2) - { - $fieldstoshow=array('bank','number'); - } - else dol_print_error('','Value returned by function useDetailedBBAN not managed'); - - 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); - } - } - - $curx=$savcurx; - $cury+=9; - */ } else { @@ -679,7 +685,8 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); $ibanDisplay = ""; - for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++) + $nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp); + for($i = 0; $i < $nbIbanDisplay_temp; $i++) { $ibanDisplay .= $ibanDisplay_temp[$i]; if($i%4 == 3 && $i > 0) $ibanDisplay .= " ";