Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] PDF Customer Invoice


chris23

Recommended Posts

Will there be a update to this modul ???

 

Hi Michael,

 

I will be maintaining the contribution. I have a minor update almost ready for upload.

 

If you use v1.0, the new version will be a painless upgrade

 

Rgds

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Chris,

 

Thanks again for this useful contribution! I've been using it and tweaking the invoice layout for the past couple of days (added a field below Payment Method, Purchase Order Number, and re-aligned some of the other fields to look better). I've got a few suggestions for later versions:

 

-It would be good to have the customer number printed somewhere on the invoice.

 

-It could improve the invoice to enable high resolution or vector images for the invoice logo. The fonts are vector, but the invoice logo image is set for only 72 dpi (600dpi max width). The result is that when the user zooms in to view, or prints the invoice, the logo is the only element on the invoice that get pixelated. Is it possible to alter the image code to allow high resolution jpgs or possibly EPS files for the invoice logo?

 

The instant invoice PDF is a great time saver for the store owner, and a nice added customer service benefit.

Edited by waverider75
Link to comment
Share on other sites

-It would be good to have the customer number printed somewhere on the invoice.

 

Good idea - I'll add this in to the 1.1 version I'm working on.

 

-It could improve the invoice to enable high resolution or vector images for the invoice logo. The fonts are vector, but the invoice logo image is set for only 72 dpi (600dpi max width). The result is that when the user zooms in to view, or prints the invoice, the logo is the only element on the invoice that get pixelated. Is it possible to alter the image code to allow high resolution jpgs or possibly EPS files for the invoice logo?

 

The image quality is a result of the formats (bitmapped) supported by the GD library. However, there is a class that extends the FPDF library that allows the use if ai and eps formats.

 

As I'm in a good mood tonight, I've had a play at integrating this class into pdfinvoice.pdf and it's working fine using a sample eps graphic

 

Full details of the ai, eps supported are found here

 

What I'll do now is delay the release of v1.1 until I've made pdfinvoice.pdf more intelligent; it needs to detect whether the logo image is an ai or eps as a different class and image method needs calling for it to work.

 

I've noticed on the forum that people have been hacking their layouts in pdfinvoice.php which is fine. However, upgrading to v1.1 will mean reapplying the changes you've made. It's not really possible for me to provide a changelog for the file as it's now an even bigger departure from the v1.0 code.

 

Glad you like the contrib and thanks for the ideas and feedback.

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

New version uploaded to contib area - v1.1

--------------------------------------------------

 

Changelog v1.1

 

i) Added invoice date config choice - today or same as order date (date now follows locale format set in /includes/languages/your-lang/your-lang.php)

ii) Decode html entities for all invoice text (better multilingual support - converts e.g. é -> é)

iii) Remove hardcoded address format. Now uses $order->customer['format_id']

iv) Config option to only display pdf link for delivered orders.

v) Remove remaining hardcoded English language

vi) Added support for vector store logo in ai / eps formats

vii) Added customer reference.

 

Upgrade instructions supplied for v1.0 => v1.1

 

French language included - thanks to Jean (Royal38)

 

Enjoy :thumbsup:

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

I've installed v1.1 and on the new pdf I'm getting this error:

 

Instead of the 'Customer Number: #####', this is what shows on the invoice 'PDF_INV_CUSTOMER_REF3'

 

I looked at the code on pdfinvoice.php:

 

	// Draw customer reference
$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . (int)$customer_id);

 

I couldn't find the problem...

Link to comment
Share on other sites

I've installed v1.1 and on the new pdf I'm getting this error:

 

Instead of the 'Customer Number: #####', this is what shows on the invoice 'PDF_INV_CUSTOMER_REF3'

 

I looked at the code on pdfinvoice.php:

 

	// Draw customer reference
$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . (int)$customer_id);

 

I couldn't find the problem...

 

 

i couldnt find no reference for this anywhere so i commented it out. dont ned this info any way.

 

i just gota figure out how to increase the size of the model field.as some of the products have long model name

Link to comment
Share on other sites

i removed the extra price box colums but cant seem to get rid of the extra space.. i wanna increase the size of model field .this the current look

invoicerv1.th.jpg

 

thanks in advance :thumbsup:

Edited by nafri
Link to comment
Share on other sites

I've installed v1.1 and on the new pdf I'm getting this error:

 

Instead of the 'Customer Number: #####', this is what shows on the invoice 'PDF_INV_CUSTOMER_REF3'

 

 

Sorry guys,

 

My mistake. I didn't add the new includes/languages/english/pdfinvoice.php to the latest zip, so you're missing:

 

define ('PDF_INV_CUSTOMER_REF','Customer reference: ');

 

Just add this to the aforementioned file before closing ?> or download the updated version from the contib area.

 

Apologies.

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Quick crash course in fpdf (do also check out the excellent tutorials at http://fpdf.org)

 

To alter the size of each cell, eg for model number heading:

 

Edit catalog/pdfinvoice.php

 

find:

 

$pdf->SetX(15);
$pdf->Cell(27,6,tep_html_entity_decode(TABLE_HEADING_PRODUCTS_MODEL),1,0,'C',1);

 

This says start drawing the cell at x=15, make it 27 wide. Increasing this makes the cell header wider.

 

But we now need to set the following SetX value to be 17+new value, not 15+27, and for each cell to the end of the row.

 

Likewise for the model data row:

 

$pdf->MultiCell(25,6,tep_html_entity_decode($order->products[$i]['model']),1,'C');
$pdf->SetY($Y_Table_Position);

 

Increase the 25 plus all the following SetX positions accordingly.

 

Remember you can't just increase one cell without taking from another or you'll run off the right side of the page.

 

You can always just adjust the font size, so for model number:

 

$pdf->SetFont(PDF_INV_CORE_FONT,'',8);
$pdf->MultiCell(25,6,tep_html_entity_decode($order->products[$i]['model']),1,'C');

 

Change 8 -> 6 (the product description I have reduced to 6 to be able to fit in the product attributes)

 

Layout really is just trial and error I'm afraid (once you get your head around fpdf)

 

HTH

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

I made the changes:

 

define ('PDF_INV_CUSTOMER_REF','Customer reference: ');

 

But now I get this on the PDF:

 

Customer Reference: 0

 

I tested this for muliple different customers, and each one shows the customer number as 0.

 

I'm not sure why. Is anyone else seeing the same results?

Link to comment
Share on other sites

Chris, or for anyone who uses the Purchase Order Contribution v233, to get the Purchase Order Number to display on the invoice:

 

In catalog/pdfinvoice.php

 

after the //Draw Payment Method Text section, add this code:

 

	//Draw Order Purchase Order Text
$temp = substr ($order->info['purchase_order_number'] , 0, 30);
$pdf->Text(80,120, ENTRY_PURCHASE_ORDER_NUMBER . ' ' . $temp);

 

 

In catalog/includes/languages/english/pdfinvoice.php

 

before the final ?> add this code:

 

define('PRINT_PURCHASE_ORDER_NUMBER', 'Purchase Order Number: ');

Link to comment
Share on other sites

Chris, or for anyone who uses the Purchase Order Contribution v233, to get the Purchase Order Number to display on the invoice:

 

In catalog/pdfinvoice.php

 

after the //Draw Payment Method Text section, add this code:

 

	//Draw Order Purchase Order Text
$temp = substr ($order->info['purchase_order_number'] , 0, 30);
$pdf->Text(80,120, ENTRY_PURCHASE_ORDER_NUMBER . ' ' . $temp);

In catalog/includes/languages/english/pdfinvoice.php

 

before the final ?> add this code:

 

define('PRINT_PURCHASE_ORDER_NUMBER', 'Purchase Order Number: ');

 

Chris,

 

This technique will work for any contribution that adds a property to catalog/includes/classes/order.php

 

pdfinvoice.php creates an order object given the order number. You therefore have access to any property in the object.

 

Standard properties are:

 

$order->info
$order->customer
$order->delivery
$order->billing

 

You can pull out any property you require - the trick is squeezing and positioning the cell somewhere on the pdf

 

Regarding your customer reference issue - very odd. I can't replicate this.

 

Does your entry look like:

 

$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . (int)$customer_id);

 

?

 

The $customer_id comes from the session id of the customer so should be set. Anyone else having this problem?

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

I found out the packing_slip.php and invoice.php from the other php invoice contribution works with this version but doesn't give attributes.

 

Quick fix: you could quite easily lift the product attributes code from this contrib and slot it into invoice.php.

 

Is there a way to get pdfinvoice.php to work in the admin section too ???

 

More than likely ;) I haven't really given it much thought as the original contrib does its job well. If there is a widespread demand for this feature, please let me know on the forum. The script would need modifying to bypass the customer login, if the page was being accessed from with admin. I'd need to give some thought to the security implications of this.

 

HTH

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

i got a n error when i click on the pdf :

 

Have you edited pdfinvoice.php at all?

You shouldn't get this message using an unmodified version

The error message is saying that some text is being output before the pdf generation.

Do you have error reporting on and getting php errors generated as these will cause this error message to appear?

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Have you edited pdfinvoice.php at all?

You shouldn't get this message using an unmodified version

The error message is saying that some text is being output before the pdf generation.

Do you have error reporting on and getting php errors generated as these will cause this error message to appear?

 

no i didnt modify the pdfinvoice.php

i got smae php erorr when in put error report on

and i dont use any other version of fpdf

 

what can i do to give you more info so you could have an idea ?

MS2

Link to comment
Share on other sites

what can i do to give you more info so you could have an idea ?

 

Salut azer,

 

This problem can arise as a result of php output buffering. If you have any whitespace after the end of the closing:

 

?>

 

in any of the php files used by the contrib, you may have an issue (my local and remote installs are working fine)

 

Try editing:

 

catalog/pdfinvoice.php

catalog/includes/languages/english/pdfinvoice.php

catalog/includes/languages/english/account_history_info.php

catalog/includes/languages/french/pdfinvoice.php

catalog/includes/languages/french/account_history_info.php

 

and make sure there is absolutely no whitespace after the closing ?>

 

Also ensure there is no whitespace before the opening <?php (I can't see any!)

 

Let me now how you get on

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Quick fix: you could quite easily lift the product attributes code from this contrib and slot it into invoice.php.

More than likely ;) I haven't really given it much thought as the original contrib does its job well. If there is a widespread demand for this feature, please let me know on the forum. The script would need modifying to bypass the customer login, if the page was being accessed from with admin. I'd need to give some thought to the security implications of this.

 

HTH

 

Hi there,

 

I did combine the two earlier today to add the attributes to pdf invoice and packingslip, it was reasonably straight forward. The existing contribution does work ok, but lacks the feartures of this, so from my point of view it would make sense to combine them.

 

The problem I have though is that on my products that do have attributes, they normally have a number of them and they over lap products below or get cut off short.

 

Is there anyway to display all product attributes for each product?

 

Thanks

 

Dave

Link to comment
Share on other sites

Hi Dave,

 

Good to see you loitering around another of my contibs ;)

 

I'll put you down as another vote for a change to allow a display of the PDF admin side.

 

As to attributes, this is a dilemma. The original code truncates the product description - this contrib truncates both the product description and product attributes.

 

Unfortunately, the way fpdf works, even though you can get text to auto return when it gets to the end of the cell, this will cause the cell height to change and break the layout, unless the cell height is set to a high value.

 

I've already reduced the font size for the product / attributes field to allow a longer product desc / attribute string

 

You could try:

 

1. Pinching width from cells left and right of the products box (see earlier post for details), then increase where the text is truncted:

 

substr($product_name_attrib_contact,0,60

 

- increase 60 to allow more text

 

2. Increase the cell height. This is the second value in each MultiCell eg:

 

MultiCell(78,6, ......

 

Increasing 6 will allow more height, thus allowing the line wrapping without breaking the cell height layout.

 

It's difficult to accommodate every store owner's products and attribs - they vary enormously. With fpdf, it's a case of post-install fiddling to perfect your layout.

 

HTH

 

Chris

Edited by chris23

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Hi Chris,

 

lol, yep, we seem to have the same interests :)

 

Thanks for the info, I'll have aplay with the line height option, I'd already had a play with the text length cut off and the font size.

 

Thanks again for your swift help

 

Cheers

 

Dave

Link to comment
Share on other sites

Does your entry look like:

 

$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . (int)$customer_id);

 

?

 

The $customer_id comes from the session id of the customer so should be set. Anyone else having this problem?

 

I had 'customers_id' instead of 'customer_id'

 

It's fixed now. Thanks!

 

Also, the eps logo support works and looks great! I'm finding that it's best to use legecy eps files, as some of the newer ai and eps files didn't work on my tests, but when saved as legecy files (older versions) they work fine.

 

~Chris

Link to comment
Share on other sites

Also, the eps logo support works and looks great! I'm finding that it's best to use legecy eps files, as some of the newer ai and eps files didn't work on my tests, but when saved as legecy files (older versions) they work fine.

 

 

Chris

 

Absolutely right. The eps class does seem a bit limited. I tried using an eps from Xara Extreme (Linux verison; very nice BTW) and Adobe 8 choked on the pdf, but a couple of old ai files seem OK.

 

Having investigated eps generally, there seem to be a lot of flaky implementations of the format, especially the header data. Like you, I suspect that the older and simpler the format, the easier it is for the eps class to render it.

 

When you say "legacy" format, can you enlighten me? I played for ages (in PS CS) with the encoding, preview settings etc, but couldn't finalise on something that rendered reliably.

 

TIA

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...