Page 1 of 2
Order tax details in invoice
Posted: 12 Aug 2009, 15:04
by josbregman
Hi,
So far I managed to modify the invoice pretty much the way I wanted, except for one detail, I can't get the order tax details in the invoice pdf.
I think it's configured in ps_checkout.php.
In account.order.details.php it's reffered like this: ps_checkout::show_tax_details( $db->f('order_tax_details'), $db->f('order_currency') );
Now the big question: how can I get this in delivery.pdf.php? Just copy-paste doesn't do the job...
Thanks!
Jos
Re: Order tax details in invoice
Posted: 13 Aug 2009, 05:58
by rosder
I also have this problem. So help us, please.
Re: Order tax details in invoice
Posted: 14 Aug 2009, 11:30
by josbregman
I just got one step closer to the solution:
First you have to include the ps_checkout.php, because there's the calculation of the taxes made:
Code: Select all
include(CLASSPATH.'ps_checkout.php');
After that, you can easily tell the pdf to use it:
Code: Select all
$pdf->Cell(50,10,(ps_checkout::show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency'))),0,0,'L');
(Please note the () in which the " ps_checkout::show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency')) " should be placed.)
Now, I have one little problem remaining, the output is like this:
<br />De totale belasting (BTW) omvat:<br />€380,00 (19% Belasting (BTW))<br />
I need to remove the ' <br /> ' somehow. Or, better, to tell the pdf to actually put a line break instead.
Can someone help me with this?
Thanks!
Re: Order tax details in invoice
Posted: 14 Aug 2009, 12:38
by rosder
First of all, thank you.
But I have another problem.
How can I get more product information (produkt name AND description) on the PDF-document?
Re: Order tax details in invoice
Posted: 30 Aug 2009, 17:57
by Jan
This needs to be customized in the code
![Sad :-(](./images/smilies/icon_sad.gif)
(so you will load the data from database and will change the pdf template, so this information will be displayed)
Jan
Re: Order tax details in invoice
Posted: 08 Sep 2009, 07:55
by rosder
I changed in delivery.pdf.php the following lines from
Code: Select all
$pdf->SetFont($pdfFont,'',7);
$pdf->Cell(70,4,$db->f('order_item_name'),0,0,'L');
to
Code: Select all
$pdf->SetFont($pdfFont,'',5);
$pdf->Cell(70,4,$db->f('order_item_name')[b]." ".ereg_replace("<br/>"," ",$db->f('product_attribute'))[/b],0,0,'L');
Now I want to have a linebreak between $db->f('order_item_name') and $db->f('product_attribute').
How to do this?
Re: Order tax details in invoice
Posted: 08 Sep 2009, 19:17
by Jan
Hi, see tcpdf site (examples) to see how to add page break to site.
Jan
Re: Order tax details in invoice
Posted: 09 Sep 2009, 08:21
by rosder
Thx.
I took this:
Code: Select all
$pdf->Cell(70,4,$db->f('order_item_name').$pdf->writeHTML('<br>', true, 0, true, 0).ereg_replace("<br/>"," ",$db->f('product_attribute')),0,0,'L');
But it doesn't work the right way. The break is shown after productnumber:
productnumber
productname product_attribute product_quantity price etc.
I want a break after produktname:
productnumber produktname __________product_quantity price etc.
_____________product_attribute
Re: Order tax details in invoice
Posted: 25 Sep 2009, 15:40
by gmarin
Hi all,
I want to reply to the original post.
You have to add a fonction to phoca.tcpdf.php
It's a copy of the original function show_tax_details.
Modified like this :
function show_tax_details( $details, $currency = '' ) {
global $discount_factor, $CURRENCY_DISPLAY, $VM_LANG;
if( !isset( $discount_factor) || !empty($_REQUEST['discount_factor'])) {
$discount_factor = 1;
}
$auth = $_SESSION['auth'];
if( !is_array( $details )) {
$details = @unserialize( $details );
if( !is_array($details)) {
return false;
}
}
if( sizeof( $details) > 1 ) {
$this->Ln(5);
$this->SetX(110);
$this->SetFont($fD['font'],'B',9);
$this->Cell(40,5,$VM_LANG->_('VM_TAXDETAILS_LABEL'),0,0,'R');
foreach ($details as $rate => $value ) {
if( !$auth['show_price_including_tax']) {
$value /= $discount_factor;
}
$this->Ln(5);
$this->SetFont($pdfFont,'',9);
$this->SetX(130);
$rate = str_replace( '-', $CURRENCY_DISPLAY->decimal, $rate )*100;
$this->Cell(40,5,$CURRENCY_DISPLAY->getFullValue( $value, 5, $currency ).' ('.$rate.'% '.$VM_LANG->_('PHPSHOP_CART_TAX').')',0,0,'R');
}
}
}
You have to call it from delivery.pdf.php
$pdf->Cell(40,5,($pdf->show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency'))),0,0,'R');
you can custumize the function to apply to your invoice
Bye
Gilbert
Re: Order tax details in invoice
Posted: 05 Oct 2009, 21:26
by Jan
Ok, thank you for this guide. Jan