From aa1d683221528a10d8f9f3b6005f8967482271ec Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 5 Nov 2024 08:41:10 +0100 Subject: [PATCH] PDF : fix several unalignment: doc et PHP8.3 Compatibility --- .../acc_ledger_history_generic.class.php | 1 + include/class/print_ledger.class.php | 32 +++++++++-- .../class/print_ledger_detail_item.class.php | 8 +-- include/class/print_ledger_misc.class.php | 17 +++--- include/class/print_ledger_simple.class.php | 8 +-- .../print_ledger_simple_without_vat.class.php | 1 + include/export/export_gl_pdf.php | 21 ++++---- include/export/export_poste_detail_pdf.php | 53 ++++++++++--------- 8 files changed, 88 insertions(+), 53 deletions(-) diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 6dbe37ad0..4ccacdcba 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -429,6 +429,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History jrn.jr_def_id as jr_def_id, jrn.jr_montant as montant, substr(jrn.jr_comment,1,35) as comment, + jrn.jr_comment str_comment, to_char(jrn.jr_date,'DD-MM-YYYY') as date, to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid, jr_pj_number, diff --git a/include/class/print_ledger.class.php b/include/class/print_ledger.class.php index 719dbe74f..8f92ebca3 100644 --- a/include/class/print_ledger.class.php +++ b/include/class/print_ledger.class.php @@ -28,12 +28,38 @@ * @brief Strategie class for the print_ledger class * */ +#[AllowDynamicProperties] class Print_Ledger extends PDF { protected $filter_operation; // See Acc_Ledger_History::filter_operation - private $ledger ; //!< concerned Ledger - private $from ; //! integer parm_periode.p_id , start periode; - private $to ; //! integer parm_periode.p_id , end periode; + private $ledger ; //!< concerned Ledger + private $from ; //SetFont('DejaVu', '', 6); $internal=""; $this->SetFillColor(220,221,255); - $high=4; - $high_lg=3; + $high=8; + $high_lg=8; for ( $i=0;$i< $nb ;$i++) { diff --git a/include/class/print_ledger_misc.class.php b/include/class/print_ledger_misc.class.php index 91cb7034d..9fa94f920 100644 --- a/include/class/print_ledger_misc.class.php +++ b/include/class/print_ledger_misc.class.php @@ -78,28 +78,29 @@ class Print_Ledger_Misc extends Print_Ledger $this->SetFont('DejaVu', '', 6); if ( $a_jrn == null ) return; $ledger=$this->get_ledger(); + $border='0'; for ( $i=0;$iwrite_cell(10,5, smaller_date($row['date'])); - $this->write_multi(30,3,$row['jr_pj_number']); - $this->write_cell(20,5,$row['jr_internal']); + $this->write_cell(10,3, smaller_date($row['date']),border:$border); + $this->write_multi(30,3,$row['jr_pj_number'],border:$border); + $this->write_cell(20,3,$row['jr_internal'],border:$border); $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->write_multi(25,3,$other,0,'L'); + $this->write_multi(25,3,$other,$border,'L'); $positive=$row['montant']; - $this->write_multi(60,3,$row['comment'],0,'L'); + $this->write_multi(60,3,$row['str_comment'],$border,'L'); if ( $type == 'FIN' ) { $positive = $this->cn->get_value("select qf_amount from quant_fin ". " where jr_id=".$row['jr_id']); } if ( $row['currency_id'] != 0 ) { - $this->write_cell(20,5,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),2).$row['cr_code_iso'],0,0,'R'); + $this->write_cell(20,3,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),2).$row['cr_code_iso'],border:$border); } else { - $this->write_cell(20,5,""); + $this->write_cell(20,3,"",border:$border); } - $this->write_cell(15,5,nbm($positive),0,0,'R'); + $this->write_cell(15,3,nbm($positive),$border,0,'R'); $this->line_new(5); } diff --git a/include/class/print_ledger_simple.class.php b/include/class/print_ledger_simple.class.php index feeda422d..a3ea4bc55 100644 --- a/include/class/print_ledger_simple.class.php +++ b/include/class/print_ledger_simple.class.php @@ -318,14 +318,14 @@ class Print_Ledger_Simple extends \Print_Ledger } $row=$a_jrn[$i]; $ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id'])); - $this->write_multi(15,3,($row['jr_pj_number']),0); - $this->write_cell(10,5,$row['str_date_short'],0,0); + $this->write_multi(15,5,($row['jr_pj_number']),0); + $this->write_multi(11,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->write_multi(40,3,"[".$qc."]".$name,0,'L'); + $this->write_multi(40,5,"[".$qc."]".$name,0,'L'); if ( !$flag_tva ) { - $this->write_multi(65,3,mb_substr($row['jr_comment'],0,150),0,'L'); + $this->write_multi(65,5,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 1596efed2..d7901df02 100644 --- a/include/class/print_ledger_simple_without_vat.class.php +++ b/include/class/print_ledger_simple_without_vat.class.php @@ -32,6 +32,7 @@ class Print_Ledger_Simple_Without_Vat extends Print_Ledger { + public function __construct ($p_cn,$p_jrn,$p_from,$p_to,$p_filter_operation) { diff --git a/include/export/export_gl_pdf.php b/include/export/export_gl_pdf.php index 6e690d65a..0d37cfdbf 100644 --- a/include/export/export_gl_pdf.php +++ b/include/export/export_gl_pdf.php @@ -96,6 +96,7 @@ foreach ($a_accounting as $accounting_item) $solde_d = 0.0; $solde_c = 0.0; $current_exercice=""; + $idx=0; foreach ($acc_account_ledger->row as $detail) { @@ -146,7 +147,7 @@ foreach ($a_accounting as $accounting_item) $solde_c = 0.0; $pdf->line_new(); $pdf->SetFont('DejaVuCond','',6); - + $idx=0; } if ($detail['cred_montant'] > 0) @@ -161,25 +162,27 @@ foreach ($a_accounting as $accounting_item) } $i = 0; + $idx++; + $fill=$pdf->is_fill($idx); $side=" ".$acc_account_ledger->get_amount_side($solde); - $pdf->write_multi($width[$i], 3, shrink_date($detail['j_date_fmt']), 0, $lor[$i]); + $pdf->write_multi($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i],fill:$fill); $i++; - $pdf->write_multi($width[$i], 3, $detail['jr_internal'], 0, $lor[$i] ); + $pdf->write_multi($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] ,fill:$fill); $i++; /* limit set to 40 for the substring */ // $triple_point = (mb_strlen($detail['description']) > 40 ) ? '...':''; // $pdf->write_multi($width[$i], 6, mb_substr($detail['description'],0,40).$triple_point, 0,$lor[$i]); - $pdf->write_multi($width[$i], 3,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i]); + $pdf->write_multi($width[$i], 6,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i],fill:$fill); $i++; - $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i]); + $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i],fill:$fill); $i++; - $pdf->write_cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i]); + $pdf->write_cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i],fill:$fill); $i++; - $pdf->write_cell($width[$i], 6, ($detail['deb_montant'] > 0 ? nbm( $detail['deb_montant']) : ''), 0, 0, $lor[$i]); + $pdf->write_cell($width[$i], 6, ($detail['deb_montant'] > 0 ? nbm( $detail['deb_montant']) : ''), 0, 0, $lor[$i],fill:$fill); $i++; - $pdf->write_cell($width[$i], 6, ($detail['cred_montant'] > 0 ? nbm( $detail['cred_montant']) : ''), 0, 0, $lor[$i]); + $pdf->write_cell($width[$i], 6, ($detail['cred_montant'] > 0 ? nbm( $detail['cred_montant']) : ''), 0, 0, $lor[$i],fill:$fill); $i++; - $pdf->write_cell($width[$i], 6, nbm(abs( $solde)).$side, 0, 0, $lor[$i]); + $pdf->write_cell($width[$i], 6, nbm(abs( $solde)).$side, 0, 0, $lor[$i],fill:$fill); $i++; $pdf->line_new(); diff --git a/include/export/export_poste_detail_pdf.php b/include/export/export_poste_detail_pdf.php index 9be956220..e44027875 100644 --- a/include/export/export_poste_detail_pdf.php +++ b/include/export/export_poste_detail_pdf.php @@ -66,6 +66,7 @@ if ( count($a_poste) == 0 ) $size=array(13,25,13,65,12,20,20,20); $align=array('L','C','C','L','R','R','R','R'); $operation=new Acc_Operation($cn); + foreach ($a_poste as $poste) { $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']); @@ -83,21 +84,21 @@ foreach ($a_poste as $poste) $pdf->SetFont('DejaVuCond','',8); $l=0; - $pdf->write_cell($size[$l],6,_('Date'),0,0,'L'); + $pdf->write_cell($size[$l],8,_('Date'),0,0,'L'); $l++; - $pdf->write_cell($size[$l],6,_('Ref'),0,0,'C'); + $pdf->write_cell($size[$l],8,_('Ref'),0,0,'C'); $l++; - $pdf->write_cell($size[$l],6,_('Journal'),0,0,'C'); + $pdf->write_cell($size[$l],8,_('Journal'),0,0,'C'); $l++; - $pdf->write_multi($size[$l],3,_('Libellé'),0,'L'); + $pdf->write_multi($size[$l],8,_('Libellé'),0,'L'); $l++; - $pdf->write_cell($size[$l],6,_('Let'),0,0,'R'); + $pdf->write_cell($size[$l],8,_('Let'),0,0,'R'); $l++; - $pdf->write_cell($size[$l],6,_('Debit'),0,0,'R'); + $pdf->write_cell($size[$l],8,_('Debit'),0,0,'R'); $l++; - $pdf->write_cell($size[$l],6,_('Credit'),0,0,'R'); + $pdf->write_cell($size[$l],8,_('Credit'),0,0,'R'); $l++; - $pdf->write_cell($size[$l],6,_('Prog'),0,0,'R'); + $pdf->write_cell($size[$l],8,_('Prog'),0,0,'R'); $l++; $pdf->line_new(); $tot_deb=0; @@ -129,12 +130,12 @@ foreach ($a_poste as $poste) $str_diff_solde=sprintf("%12.2f ",$diff_solde); $pdf->SetFont('DejaVu','B',8); - $pdf->write_cell(15,6,_('totaux'),0,0,'L'); - $pdf->write_cell(15,6,$current_exercice,0,0,'L'); - $pdf->write_cell(40,6,$solde,0,'L'); - $pdf->write_cell(40,6,$str_debit,0,0,'R'); - $pdf->write_cell(40,6,$str_credit,0,0,'R'); - $pdf->write_cell(40,6,$str_diff_solde,0,0,'R'); + $pdf->write_cell(15,8,_('totaux'),0,0,'L'); + $pdf->write_cell(15,8,$current_exercice,0,0,'L'); + $pdf->write_cell(40,8,$solde,0,'L'); + $pdf->write_cell(40,8,$str_debit,0,0,'R'); + $pdf->write_cell(40,8,$str_credit,0,0,'R'); + $pdf->write_cell(40,8,$str_diff_solde,0,0,'R'); $pdf->line_new(); /* * reset total and current_exercice @@ -147,26 +148,26 @@ foreach ($a_poste as $poste) $l=0; $diff=bcsub($row['deb_montant'],$row['cred_montant']); $prog=bcadd($prog,$diff); - + $fill=(isset($_GET['oper_detail']))?$pdf->is_fill(0):$pdf->is_fill($e); $date=shrink_date($row['j_date_fmt']); - $pdf->write_cell($size[$l],6,$date,0,0,$align[$l]); + $pdf->write_cell($size[$l],8,$date,0,0,$align[$l],fill:$fill); $l++; if ( $row['jr_pj_number'] == '') - $pdf->write_cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]); + $pdf->write_cell($size[$l],8,$row['jr_internal'],0,0,$align[$l],fill:$fill); else - $pdf->write_cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]); + $pdf->write_cell($size[$l],8,$row['jr_pj_number'],0,0,$align[$l],fill:$fill); $l++; - $pdf->write_cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]); + $pdf->write_cell($size[$l],8,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l],fill:$fill); $l++; $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']); $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description']; - $pdf->write_multi($size[$l],3, $description,0,$align[$l]); + $pdf->write_multi($size[$l],8, $description,0,$align[$l],fill:$fill); $l++; - $pdf->write_cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]); + $pdf->write_cell($size[$l],8,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l],fill:$fill); $l++; - $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]); + $pdf->write_cell($size[$l],8,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l],fill:$fill); $l++; - $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]); + $pdf->write_cell($size[$l],8,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l],fill:$fill); $l++; $solde="="; if ( $prog < 0 ) @@ -175,9 +176,9 @@ foreach ($a_poste as $poste) { $solde=_("D"); } - $pdf->write_cell($size[$l],6,(sprintf('% 12.2f %s',abs($prog),$solde)),0,0,$align[$l]); + $pdf->write_cell($size[$l],8,(sprintf('% 12.2f %s',abs($prog),$solde)),0,0,$align[$l],fill:$fill); $l++; - $pdf->line_new(); + $pdf->line_new(8); $tot_deb=bcadd($tot_deb,$row['deb_montant']); $tot_cred=bcadd($tot_cred,$row['cred_montant']); /* -------------------------------------- */ @@ -237,7 +238,7 @@ foreach ($a_poste as $poste) $str_diff_solde=sprintf("%12.2f ",$diff_solde); $pdf->SetFont('DejaVu','B',8); - + $pdf->line_new(); $pdf->write_cell(160,5,_("Débit"),0,0,'R'); $pdf->write_cell(30,5,$str_debit,0,0,'R'); $pdf->line_new();