PDF : standardized color for row even and odd

This commit is contained in:
sparkyx 2025-11-24 13:14:26 +01:00
parent 4a164de70b
commit 6c4208bbab
7 changed files with 26 additions and 16 deletions

View file

@ -255,7 +255,12 @@ class Invoice_PDF extends \PDF
$item->get_by_qcode(trim($this->data['e_march' . $i]));
$fill = $this->is_fill($line);
$this->write_multi($col['quick_code'], 4, $item->get_attribute(ATTR_DEF_QUICKCODE),'','',$fill);
$this->write_multi($col['label'], 4, $this->data['e_march' . $i . '_label'],fill:$fill);
if ( isset ($this->data['e_march' . $i . '_label']))
{
$this->write_multi($col['label'], 4, $this->data['e_march' . $i . '_label'],fill:$fill);
}else {
$this->write_multi($col['label'], 4,$item->get_attribute(ATTR_DEF_NAME),fill:$fill);
}
$this->write_multi($col['quantity'], 4, nbm($this->data['e_quant' . $i]), '', 'R',fill:$fill);
$this->write_multi($col['price'], 4, nbm($this->data['e_march' . $i . '_price']), '', 'R',fill:$fill);
$this->write_multi($col['vat_code'], 4, $this->data['e_march' . $i . '_tva_id'], '', 'C',fill:$fill);

View file

@ -361,12 +361,12 @@ class PDF_Operation extends PDF {
$nb=count($pa_plan);
$this->pdf->SetFont('DejaVu', 'B', 8);
$width=25;
$this->pdf->SetFillColor(220,221,255);
$this->pdf->fill_row(0);
for ($i = 0; $i<$nb; $i++) {
$this->pdf->write_cell($width,8,$pa_plan[$i]['pa_name']);
}
$this->pdf->write_cell($width,8,_('Montant'),0,0,'R');
$this->pdf->SetFillColor(0,0,0);
$this->pdf->fill_row(1);
$this->pdf->line_new(8);
}
private function print_anc_detail($p_j_id, $pa_plan) {

View file

@ -112,7 +112,7 @@ class Print_Ledger_Detail_Item extends Print_Ledger
$nb=Database::num_row($ret_detail);
$this->SetFont('DejaVu', '', 6);
$internal="";
$this->SetFillColor(220,221,255);
$this->fill_row(0);
$high=8;
$high_lg=8;
for ( $i=0;$i< $nb ;$i++)

View file

@ -101,7 +101,7 @@ if (sizeof($array) == 0) {
$pPeriode = new Periode($cn);
$a = $pPeriode->get_date_limit($from_periode);
$b = $pPeriode->get_date_limit($to_periode);
$per_text = sprintf(_("Du %s au %s" ), $a['p_start'] ,$b['p_end']);
$per_text = sprintf(_("du %s au %s" ), $a['p_start'] ,$b['p_end']);
// If compare with previous exercice ,
// we use the landscape mode
@ -117,7 +117,7 @@ $pdf->AddPage();
$pdf->SetAuthor('NOALYSS');
$pdf->SetFont('DejaVuCond', '', 7);
$pdf->setTitle(_("Balance comptable"), true);
$pdf->write_cell(30, 6, _('poste'));
$pdf->write_multi(30, 3, _('Poste'));
$pdf->write_multi(60, 3, _('Libellé'));
if ($previous == 1) {
$pdf->write_cell(20, 6, 'Débit N-1', 0, 0, 'R');
@ -128,7 +128,7 @@ $pdf->write_cell(25, 6, _('Ouverture'), 0, 0, 'R');
$pdf->write_cell(25, 6, _('Total Débit'), 0, 0, 'R');
$pdf->write_cell(25, 6, _('Total Crédit'), 0, 0, 'R');
$pdf->write_cell(25, 6, _('Solde'), 0, 0, 'R');
$pdf->line_new();
$pdf->line_new(10);
$pdf->SetFont('DejaVuCond', '', 8);
$tp_deb = 0;
@ -223,8 +223,8 @@ if (!empty($array)) {
$label.=" ".mb_chr(0x26a0);
}
$pdf->write_multi(30, 3, $label, 0, 'L', $fill);
$pdf->write_multi(60, 3, $value['label'], 0, 'L', $fill);
$pdf->write_multi(30, 5, $label, 0, 'L', $fill);
$pdf->write_multi(60, 5, $value['label'], 0, 'L', $fill);
$summary_tab = $bal->summary_add($summary_tab, $value['poste'],
$value['sum_deb'],
$value['sum_cred']);
@ -232,8 +232,6 @@ if (!empty($array)) {
$pdf->write_cell(22, 6, nbm($value['sum_deb_previous']), 0, 0, 'R', $fill);
$pdf->write_cell(22, 6, nbm($value['sum_cred_previous']), 0, 0, 'R', $fill);
// $pdf->write_cell(22,6,nbm($value['solde_deb_previous']),0,0,'R',$fill);
// $pdf->write_cell(22,6,nbm($value['solde_cred_previous']),0,0,'R',$fill);
$solde_previous = bcsub($value['solde_cred_previous'], $value['solde_deb_previous']);
$side_previous = ($solde_previous < 0) ? " D" : " C";
$side_previous = ($solde_previous == 0) ? "" : $side_previous;
@ -306,8 +304,7 @@ if (!empty($array)) {
if ($previous == 1) {
$pdf->write_cell(22, 6, nbm($tp_deb_previous), 'T', 0, 'R', 0);
$pdf->write_cell(22, 6, nbm($tp_cred_previous), 'T', 0, 'R', 0);
$pdf->write_cell(22, 6, nbm($tp_sold_previous), 'T', 0, 'R', 0);
$pdf->write_cell(22, 6, nbm($tp_solc_previous), 'T', 0, 'R', 0);
$pdf->write_cell(22, 6, nbm(bcsub($tp_cred_previous,$tp_deb_previous,2)), 'T', 0, 'R', 0);
}
$solde = bcsub($tp_sold,$tp_solc);

View file

@ -266,7 +266,7 @@ else
$pdf->write_cell($tab[6], 4, "", 0, 0, 'R', $fill);
$pdf->line_new();
}
$pdf->SetFillColor(0, 0, 0);
$pdf->fill_row(1);
$pdf->SetFont('DejaVuCond', 'B', 8);
$debit = sprintf('Debit : %s', nbm($amount_deb));
$credit = sprintf('Credit : %s', nbm($amount_cred));

View file

@ -103,7 +103,7 @@ if ( $SecUser->active==0)
if ( $SecUser->admin==1)
{
$pdf->SetTextColor(0,0,0);
$pdf->setFillColor(239,251,255);
$pdf->fill_row(0);
$pdf->write_cell(40,7,_('Administrateur'),1,1,'R');
$pdf->line_new();
}

View file

@ -350,7 +350,15 @@ class PDF_Core extends TFPDF
}
return $fill;
}
/**
* @brief set color for row ,
* @param $enable (int)set color 0 or disable 1
* @return 0 or 1
*/
function fill_row($enable)
{
return $this->is_fill($enable);
}
}