From 0599b38d231c0ae7eb6207c620ae097edb4250df Mon Sep 17 00:00:00 2001 From: sparkyx Date: Thu, 1 Aug 2024 11:29:21 +0200 Subject: [PATCH] WIP PDF : rename PDF_Core::longLine to write_multi, adapt the interline --- include/class/pdf_operation.class.php | 4 +- include/class/print_ledger_detail.class.php | 4 +- .../class/print_ledger_detail_item.class.php | 15 +++--- include/class/print_ledger_fin.class.php | 2 +- include/class/print_ledger_misc.class.php | 6 +-- include/class/print_ledger_simple.class.php | 6 +-- .../print_ledger_simple_without_vat.class.php | 6 +-- include/export/export_balance_pdf.php | 8 ++-- include/export/export_fiche_balance_pdf.php | 12 ++--- include/export/export_gl_pdf.php | 6 +-- include/export/export_poste_detail_pdf.php | 4 +- include/lib/pdf_core.class.php | 48 +++++++++++++++++-- 12 files changed, 81 insertions(+), 40 deletions(-) diff --git a/include/class/pdf_operation.class.php b/include/class/pdf_operation.class.php index b8178e673..769ddade6 100644 --- a/include/class/pdf_operation.class.php +++ b/include/class/pdf_operation.class.php @@ -192,7 +192,7 @@ class PDF_Operation extends PDF { $fiche=new Fiche($this->cn,$fiche_id); $this->pdf->write_cell($width[0],6,$i+1); $this->pdf->write_cell($width[1],6,$fiche->get_quick_code()); - $this->pdf->LongLine($width[2],6,$row['j_text']); + $this->pdf->LongLine($width[2],3,$row['j_text']); $this->pdf->write_cell($width[3],6,nbm($row["qs_price"],2),"",0,"R"); $str=$this->str_vat($row["qs_vat_code"]); $this->pdf->write_cell($width[4],6,$str); @@ -243,7 +243,7 @@ class PDF_Operation extends PDF { $fiche=new Fiche($this->cn,$fiche_id); $this->pdf->write_cell($width[0],6,$i+1); $this->pdf->write_cell($width[1],6,$fiche->get_quick_code()); - $this->pdf->LongLine($width[2],6,$row['j_text']); + $this->pdf->LongLine($width[2],3,$row['j_text']); $this->pdf->write_cell($width[3],6,nbm($row["qp_price"],2),"",0,"R"); $str=$this->str_vat($row["qp_vat_code"]); $this->pdf->write_cell($width[4],6,$str); diff --git a/include/class/print_ledger_detail.class.php b/include/class/print_ledger_detail.class.php index 87bed1772..f1a3f8156 100644 --- a/include/class/print_ledger_detail.class.php +++ b/include/class/print_ledger_detail.class.php @@ -92,10 +92,10 @@ class Print_Ledger_Detail extends Print_Ledger $this->SetFont('DejaVuCond','B',7); $row=$array[$i]; - $this->LongLine(20,7,$row['pj']); + $this->LongLine(20,3,$row['pj']); $this->write_cell(15,7,$row['date_fmt']); $this->write_cell(20,7,$row['internal']); - $this->LongLine(170,7,$row['comment']); + $this->LongLine(170,3,$row['comment']); $this->write_cell(20,7,nbm($row['montant']),0,0,'R'); $this->line_new(); diff --git a/include/class/print_ledger_detail_item.class.php b/include/class/print_ledger_detail_item.class.php index 243ef9217..05a3446d8 100644 --- a/include/class/print_ledger_detail_item.class.php +++ b/include/class/print_ledger_detail_item.class.php @@ -111,6 +111,7 @@ class Print_Ledger_Detail_Item extends Print_Ledger $internal=""; $this->SetFillColor(220,221,255); $high=4; + $high_lg=3; for ( $i=0;$i< $nb ;$i++) { @@ -119,10 +120,10 @@ class Print_Ledger_Detail_Item extends Print_Ledger { // Print the general info line width=270mm - $this->LongLine(20, $high, $row['jr_date'],1, 'L', true); + $this->LongLine(20, $high_lg, $row['jr_date'],1, 'L', true); $this->write_cell(20, $high,$row['jr_pj_number'].".". $row['jr_internal'], 1, 0, 'L', true); - $this->LongLine(50, $high, $row['quick_code']." ".$row['tiers_name'],1,'L',true); - $this->LongLine(80, $high, $row['jr_comment'],1,'L',true); + $this->LongLine(50, $high_lg, $row['quick_code']." ".$row['tiers_name'],1,'L',true); + $this->LongLine(80, $high_lg, $row['jr_comment'],1,'L',true); $this->write_cell(20, $high, nbm($row['htva']), 1, 0, 'R', true); $this->write_cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true); $this->write_cell(20, $high, nbm($row['other_tax_amount']), 1, 0, 'R', true); @@ -152,9 +153,9 @@ class Print_Ledger_Detail_Item extends Print_Ledger // Header detail - $this->LongLine(30,$high,_('QuickCode')); + $this->LongLine(30,$high_lg,_('QuickCode')); $this->write_cell(30,$high,_('Poste')); - $this->LongLine(70,$high,_('Libellé')); + $this->LongLine(70,$high_lg,_('Libellé')); $this->write_cell(20,$high,_('Prix/Unit'),0,0,'R'); $this->write_cell(20,$high,_('Quant.'),0,0,'R'); $this->write_cell(20,$high,_('HTVA'),0,0,'R'); @@ -167,10 +168,10 @@ class Print_Ledger_Detail_Item extends Print_Ledger } } // Print detail sale / purchase - $this->LongLine(30,$high,$row['j_qcode']); + $this->LongLine(30,$high_lg,$row['j_qcode']); $this->write_cell(30,$high,$row['j_poste']); $comment=($row['j_text']=="")?$row['item_name']:$row['j_text']; - $this->LongLine(70,$high,$comment); + $this->LongLine(70,$high_lg,$comment); $this->write_cell(20,$high,nbm($row['price_per_unit']),0,0,'R'); $this->write_cell(20,$high,nbm($row['quantity']),0,0,'R'); $this->write_cell(20,$high,nbm($row['price']),0,0,'R'); diff --git a/include/class/print_ledger_fin.class.php b/include/class/print_ledger_fin.class.php index 7352df6dc..b88bea857 100644 --- a/include/class/print_ledger_fin.class.php +++ b/include/class/print_ledger_fin.class.php @@ -117,7 +117,7 @@ class Print_Ledger_Financial extends Print_Ledger $name=$ledger->get_tiers($this->jrn_type,$row['id']); $this->write_cell(40,5,$name,0,0,'L'); - $this->LongLine(60,5,$row['comment'],0,'L'); + $this->LongLine(60,3,$row['comment'],0,'L'); $amount=$this->cn->get_value('select qf_amount from quant_fin where jr_id=$1',array( $row['id'])); $ret_amount_cur=$this->cn->execute("amount_cur",array($row['id'])); diff --git a/include/class/print_ledger_misc.class.php b/include/class/print_ledger_misc.class.php index 1cdf29456..1e137196f 100644 --- a/include/class/print_ledger_misc.class.php +++ b/include/class/print_ledger_misc.class.php @@ -83,13 +83,13 @@ class Print_Ledger_Misc extends Print_Ledger $row=$a_jrn[$i]; $this->write_cell(10,5, smaller_date($row['date'])); - $this->LongLine(30,5,$row['jr_pj_number']); + $this->LongLine(30,3,$row['jr_pj_number']); $this->write_cell(20,5,$row['jr_internal']); $type=$this->cn->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",array($a_jrn[$i]['jr_def_id'])); $other=mb_substr($ledger->get_tiers($type,$a_jrn[$i]['jr_id']),0,25); - $this->LongLine(25,5,$other,0,'L'); + $this->LongLine(25,3,$other,0,'L'); $positive=$row['montant']; - $this->LongLine(60,5,$row['comment'],0,'L'); + $this->LongLine(60,3,$row['comment'],0,'L'); if ( $type == 'FIN' ) { $positive = $this->cn->get_value("select qf_amount from quant_fin ". " where jr_id=".$row['jr_id']); diff --git a/include/class/print_ledger_simple.class.php b/include/class/print_ledger_simple.class.php index 5ac660b18..00c120955 100644 --- a/include/class/print_ledger_simple.class.php +++ b/include/class/print_ledger_simple.class.php @@ -295,14 +295,14 @@ class Print_Ledger_Simple extends \Print_Ledger } $row=$a_jrn[$i]; $ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id'])); - $this->LongLine(15,5,($row['jr_pj_number']),0); + $this->LongLine(15,3,($row['jr_pj_number']),0); $this->write_cell(10,5,$row['str_date_short'],0,0); $this->write_cell(13,5,$row['jr_internal'],0,0); list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type); - $this->LongLine(40,5,"[".$qc."]".$name,0,'L'); + $this->LongLine(40,3,"[".$qc."]".$name,0,'L'); if ( !$flag_tva ) { - $this->LongLine(65,5,mb_substr($row['jr_comment'],0,150),0,'L'); + $this->LongLine(65,3,mb_substr($row['jr_comment'],0,150),0,'L'); } /* get other amount (without vat, total vat included, private, ND */ diff --git a/include/class/print_ledger_simple_without_vat.class.php b/include/class/print_ledger_simple_without_vat.class.php index 844101732..d82519090 100644 --- a/include/class/print_ledger_simple_without_vat.class.php +++ b/include/class/print_ledger_simple_without_vat.class.php @@ -166,14 +166,14 @@ class Print_Ledger_Simple_Without_Vat extends Print_Ledger { $row=$a_jrn[$i]; - $this->LongLine(15,5,($row['jr_pj_number']),0); + $this->LongLine(15,3,($row['jr_pj_number']),0); $this->write_cell(15,5,$row['str_date_short'],0,0); $this->write_cell(20,5,$row['jr_internal'],0,0); list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type); $this->write_cell(20,5,$qc,0,0); - $this->LongLine(40,5,$name,0,'L'); + $this->LongLine(40,3,$name,0,'L'); - $this->LongLine(105,5,$row['jr_comment'],0,'L'); + $this->LongLine(105,3,$row['jr_comment'],0,'L'); /* get other amount (without vat, total vat included, private, ND */ $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']); diff --git a/include/export/export_balance_pdf.php b/include/export/export_balance_pdf.php index 02946d3a4..0b4dda419 100644 --- a/include/export/export_balance_pdf.php +++ b/include/export/export_balance_pdf.php @@ -118,7 +118,7 @@ $pdf->SetAuthor('NOALYSS'); $pdf->SetFont('DejaVuCond', '', 7); $pdf->setTitle(_("Balance comptable"), true); $pdf->write_cell(30, 6, _('poste')); -$pdf->LongLine(60, 6, _('Libellé')); +$pdf->LongLine(60, 3, _('Libellé')); if ($previous == 1) { $pdf->write_cell(20, 6, 'Débit N-1', 0, 0, 'R'); $pdf->write_cell(20, 6, 'Crédit N-1', 0, 0, 'R'); @@ -171,7 +171,7 @@ if (!empty($array)) { if (${'lvl' . $ind . '_old'} != substr($r['poste'], 0, $ind)) { $pdf->SetFont('DejaVu', 'B', 7); $strTotal=sprintf(_("Totaux %s "),${'lvl' . $ind . '_old'}); - $pdf->LongLine(30, 6, $strTotal,"TB"); + $pdf->LongLine(30, 3, $strTotal,"TB"); $delta = bcsub(${'nlvl' . $ind}['solde_cred'], ${'nlvl' . $ind}['solde_deb']); $side = ($delta < 0) ? "D" : "C"; if ($previous == 1) { @@ -223,8 +223,8 @@ if (!empty($array)) { $label.=" ".mb_chr(0x26a0); } - $pdf->LongLine(30, 6, $label, 0, 'L', $fill); - $pdf->LongLine(60, 6, $value['label'], 0, 'L', $fill); + $pdf->LongLine(30, 3, $label, 0, 'L', $fill); + $pdf->LongLine(60, 3, $value['label'], 0, 'L', $fill); $summary_tab = $bal->summary_add($summary_tab, $value['poste'], $value['sum_deb'], $value['sum_cred']); diff --git a/include/export/export_fiche_balance_pdf.php b/include/export/export_fiche_balance_pdf.php index 393d92fd7..15c6728aa 100644 --- a/include/export/export_fiche_balance_pdf.php +++ b/include/export/export_fiche_balance_pdf.php @@ -88,8 +88,8 @@ if ($histo == 4 || $histo==5) $pdf->write_cell(0,8,$name,0,1,'C'); $pdf->line_new(); $pdf->SetFont('DejaVuCond','',7); - $pdf->LongLine(30,7,'Quick Code',0,'L',0); - $pdf->LongLine(80,7,'Libellé',0,'L',0); + $pdf->LongLine(30,3,'Quick Code',0,'L',0); + $pdf->LongLine(80,3,'Libellé',0,'L',0); $pdf->write_cell(20,7,'Débit',0,0,'R',0); $pdf->write_cell(20,7,'Crédit',0,0,'R',0); $pdf->write_cell(20,7,'Solde',0,0,'R',0); @@ -121,7 +121,7 @@ if ($histo == 4 || $histo==5) $sum_solde=bcsub($sum_deb,$sum_cred); $pdf->write_cell(30,7,$oCard->strAttribut(ATTR_DEF_QUICKCODE),0,0,'L',$fill); - $pdf->LongLine(80,7,$oCard->strAttribut(ATTR_DEF_NAME)." (".$oCard->strAttribut(ATTR_DEF_ACCOUNT).")",0,'L',$fill); + $pdf->LongLine(80,3,$oCard->strAttribut(ATTR_DEF_NAME)." (".$oCard->strAttribut(ATTR_DEF_ACCOUNT).")",0,'L',$fill); $pdf->write_cell(20,7,nbm($solde['debit']),0,0,'R',$fill); $pdf->write_cell(20,7,nbm($solde['credit']),0,0,'R',$fill); $pdf->write_cell(20,7,nbm(abs($solde['solde'])),0,0,'R',$fill); @@ -233,10 +233,10 @@ else $row = $letter->content[$i]; $str_date = shrink_date($row['j_date_fmt']); - $pdf->LongLine($tab[0], 4, $str_date, 0, $align[0], $fill); + $pdf->LongLine($tab[0], 3, $str_date, 0, $align[0], $fill); $pdf->write_cell($tab[1], 4, $row['jr_pj_number'], 0, 0, $align[1], $fill); - $pdf->LongLine($tab[2], 4, $row['jr_internal'], 0, $align[1], $fill); - $pdf->LongLine($tab[3], 4, $row['jr_comment'], 0, $align[2], $fill); + $pdf->LongLine($tab[2], 3, $row['jr_internal'], 0, $align[1], $fill); + $pdf->LongLine($tab[3], 3, $row['jr_comment'], 0, $align[2], $fill); if ($row['j_debit'] == 't') { $prog=bcadd($prog,$row['j_montant']); diff --git a/include/export/export_gl_pdf.php b/include/export/export_gl_pdf.php index 24578f883..cf42ed2a4 100644 --- a/include/export/export_gl_pdf.php +++ b/include/export/export_gl_pdf.php @@ -162,14 +162,14 @@ foreach ($a_accounting as $accounting_item) $i = 0; $side=" ".$acc_account_ledger->get_amount_side($solde); - $pdf->LongLine($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i]); + $pdf->LongLine($width[$i], 3, shrink_date($detail['j_date_fmt']), 0, $lor[$i]); $i++; - $pdf->LongLine($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] ); + $pdf->LongLine($width[$i], 3, $detail['jr_internal'], 0, $lor[$i] ); $i++; /* limit set to 40 for the substring */ // $triple_point = (mb_strlen($detail['description']) > 40 ) ? '...':''; // $pdf->LongLine($width[$i], 6, mb_substr($detail['description'],0,40).$triple_point, 0,$lor[$i]); - $pdf->LongLine($width[$i], 6,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i]); + $pdf->LongLine($width[$i], 3,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i]); $i++; $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i]); $i++; diff --git a/include/export/export_poste_detail_pdf.php b/include/export/export_poste_detail_pdf.php index db7d54c50..583435a45 100644 --- a/include/export/export_poste_detail_pdf.php +++ b/include/export/export_poste_detail_pdf.php @@ -89,7 +89,7 @@ foreach ($a_poste as $poste) $l++; $pdf->write_cell($size[$l],6,_('Journal'),0,0,'C'); $l++; - $pdf->LongLine($size[$l],6,_('Libellé'),0,'L'); + $pdf->LongLine($size[$l],3,_('Libellé'),0,'L'); $l++; $pdf->write_cell($size[$l],6,_('Let'),0,0,'R'); $l++; @@ -160,7 +160,7 @@ foreach ($a_poste as $poste) $l++; $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']); $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description']; - $pdf->LongLine($size[$l],6, $description,0,$align[$l]); + $pdf->LongLine($size[$l],3, $description,0,$align[$l]); $l++; $pdf->write_cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]); $l++; diff --git a/include/lib/pdf_core.class.php b/include/lib/pdf_core.class.php index 47fffea84..28e88953e 100644 --- a/include/lib/pdf_core.class.php +++ b/include/lib/pdf_core.class.php @@ -265,18 +265,58 @@ class PDF_Core extends TFPDF $this->cells[$size]=$Ce; } - function write_cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') + /** + * @brief add a cell the text is not cut and don't return to this line if too large + * @param $width width (in PDF unit ) + * @param $height height (in PDF unit ) + * @param $txt text to print (unicode) + * @param $border border valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right + * @param $interline (unit pt ) space between lines + * @param $align text alignment valid values are L : left,R : right + * @param $fill color true or false + * @param $link url + * @return void*/ + function write_cell ($width, $height=0, $txt='', $border=0, $interline = 0, $align='', $fill=false, $link='') { - $this->add_cell(new Cellule($w,$h,$txt,$border,$ln,$align,$fill,$link,'C')); + $this->add_cell(new Cellule($width,$height,$txt,$border,$interline,$align,$fill,$link,'C')); } + /** + * @brief add a cell with automatic return to the line if the text is too long + * @param $width width (in PDF unit ) + * @param $interline interline (unit pt) + * @param $txt text to print (unicode) + * @param $border border valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right + * @param $align text alignment valid values are L : left,R : right + * @param $fill color true or false + * @return void + */ + function write_multi($width,$interline,$txt,$border=0,$align='',$fill=false) + { + $this->add_cell(new Cellule($width,$interline,$txt,$border,0,$align,$fill,'','M')); + + } + + /** + * @brief add a cell with automatic return to the line if the text is too long, deprecated , + * it calls only PDFCore::write_cell_ + * @see PDF_Core::write_multi() + * @param $w width (in PDF unit ) + * @param $h interline (in pt) + * @param $txt text to display + * @param $border border valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right + * @param $align text align valid values are L : left,R : right + * @param $fill color true or false + * @return void + *@deprecated + */ function LongLine($w,$h,$txt,$border=0,$align='',$fill=false) { - $this->add_cell(new Cellule($w,$h,$txt,$border,0,$align,$fill,'','M')); + $this->write_multi($w,$h,$txt,$border,$align,$fill); } /** - * Print all the cell stored and call Ln (new line) + * @brief Print all the cell stored and call Ln (new line) * @param int $p_step */