Problem in Crabe pdf

Hi,

I could try to help you but you need to do the debug by your self.

What you need to do is to calculate what the 3 HT values by looping on the lines.
I give you a code exemple, this is not tested, so you have to debug it :

    $total_ht_13=0;
    $total_ht_17=0;
    $total_ht_24=0;
    foreach ($object["lines"] as $facture_lines){
         if ($facture_lines["tva_tx"] == "13.000"){
               $total_ht_13 += $facture_lines["total_ht"];
         }elseif ($facture_lines["tva_tx"] == "17.000"){
               $total_ht_17 += $facture_lines["total_ht"];
         }elseif ($facture_lines["tva_tx"] == "24.000"){
               $total_ht_24 += $facture_lines["total_ht"];
         }
    }

Then you will be able to display the results

    $pdf->MultiCell($largcol2, $tab2_hl, $total_ht_13, 0, $outputlangs), 0, 'R', 1);

THis needs to be tested of course.

1 Like

Hi

Include this code in pdf, but error 500,check if find error but not find it.

Hello,

Can you send the file, I can chek your code ?
Also have you checked the PHP log to see what is the error 500 ?

Hello

This is code in total ht

// Total HT
		$pdf->SetFillColor(255,255,255);
		$pdf->SetXY($col1x, $tab2_top + 0);
		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
		$pdf->SetXY($col2x, $tab2_top + 0);
		$total_ht_13=0;
		$total_ht_17=0;
		$total_ht_24=0;
		foreach ($object["lines"] as $facture_lines){
     if ($facture_lines["tva_tx"] == "13.000"){
           $total_ht_13 += $facture_lines["total_ht"];
     }elseif ($facture_lines["tva_tx"] == "17.000"){
           $total_ht_17 += $facture_lines["total_ht"];
     }elseif ($facture_lines["tva_tx"] == "24.000"){
           $total_ht_24 += $facture_lines["total_ht"];
     }
	 $pdf->MultiCell($largcol2, $tab2_hl, $total_ht_13, 0, $outputlangs), 0, 'R', 1);
}
1 Like

Hello,

So I made a new template : https://github.com/ksar-ksar/Dymo/blob/master/pdf_as32.modules.php

With the following code :

$total_ht_13=0;
$total_ht_17=0;
$total_ht_24=0;
$nblignes = count($object->lines);
for ($i = 0 ; $i < $nblignes ; $i++){
	if ($object->lines[$i]->tva_tx == "13.000"){
		$total_ht_13 += $object->lines[$i]->total_ht;
	}elseif ($object->lines[$i]->tva_tx == "17.000"){
		$total_ht_17 += $object->lines[$i]->total_ht;
	}elseif ($object->lines[$i]->tva_tx == "24.000"){
		$total_ht_24 += $object->lines[$i]->total_ht;
	}
}

$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT for 13% VAT", 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht_13, 0, $outputlangs), 0, 'R', 1);
		
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT for 17% VAT", 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht_17, 0, $outputlangs), 0, 'R', 1);
		
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT for 24% VAT", 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht_24, 0, $outputlangs), 0, 'R', 1);

The result is : image

Of course it could be improved.

Let me know if it work.

2 Likes

Yes Yes Yes…work perfect!!!

Thanks for all