Jump to content
chris23

[CONTRIBUTION] PDF Customer Invoice

Recommended Posts

In Evolution, the mail message contains the base64 encoded message, but there is no readable information.

 

 

Rick,

 

I'm not sure which version of the install instructions you're using and to be totally honest I've lost track of the changes on the board but this is from post #282

 

EDIT includes/functions/general.php

 

 

FIND

 

 

$message->add_string_attachment($string, $filename);

 

and REPLACE with

 

$message->add_string_attachment($string, $filename, 'application/pdf');

 

This will force the mime type for the message and explicitly tell the client the base64 code is a pdf; Thunderbird works this out for itself from the .pdf extension, at least on my box.

 

I'm working right now on some up to date install instructions incorporating all the fixes from the board. Weird thing is, the original version still works on my set up!

 

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

Share this post


Link to post
Share on other sites
Rick,

 

I'm not sure which version of the install instructions you're using and to be totally honest I've lost track of the changes on the board but this is from post #282

 

EDIT includes/functions/general.php

FIND

$message->add_string_attachment($string, $filename);

 

and REPLACE with

 

$message->add_string_attachment($string, $filename, 'application/pdf');

 

This will force the mime type for the message and explicitly tell the client the base64 code is a pdf; Thunderbird works this out for itself from the .pdf extension, at least on my box.

 

I'm working right now on some up to date install instructions incorporating all the fixes from the board. Weird thing is, the original version still works on my set up!

 

HTH

 

Chris

 

Chris,

 

Thanks, that did it. I went back and read Pipeloops subsequent posts saw where he had an issue with Send HTML Email set True. So did I, so I after changing the code above I sent HTML Emails to False and now everything is happy again. Funny, I had read that post at the time it was posted but didn't think much of it then. I guess I need to keep up with things a bit more.

 

Thanks again,

Rick

Share this post


Link to post
Share on other sites
issue with Send HTML Email set True. So did I, so I after changing the code above I sent HTML Emails to False and now everything is happy again.

 

I'd like to know why there's a problem with the HTML enabled / disabled. My setups work OK with either mode set. Anyone else having problems with HTML mode switched on?

 

Glad you're otherwise sorted.

 

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

Share this post


Link to post
Share on other sites

Hi Chris,

 

I think i'm almost there with the barcode invoice task but i now need your help (again :))

 

How would I go about putting this code into the invoice?

 

<IMG SRC="<?php echo 'barcodegen.php?barcode=' . tep_db_input($oID); ?>">

 

Any ideas?

 

Thanks

 

Dave

Share this post


Link to post
Share on other sites
KJ,

 

Have a look at post #280 here

 

I think this will fix you up.

 

Cheers

 

Chris

 

I'm getting happier :) hehe.

 

Good catch,now my test order goes thru OK BUT the confirmation email looks like (with no actual attachment):

-----

Content-Type: application/pdf

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="go_karts_r_us__invoice_3973.pdf"

 

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy

IDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3VidHlwZSAvTGluayAvUmVjdCBbMTE2LjIy

IDgwNS4wNCAzMzIuMjIgNzM1Ljg3XSAvQm9yZGVyIFswIDAgMF0gL0EgPDwvUyAvVVJJIC9VUkkg

KGluZGV4LnBocCk+Pj4+XQovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0

ZXIgL0ZsYXRlRGVjb2RlIC9MZW5ndGggMTU3Mz4+CnN0cmVhbQp4nK1Y227bOBB991fMAn1oi5rm

nZKfuomz3W6aS2u3RYEAC9VWYje2lJXlZvP3OxSpmxXbSbEJYHtIzuEM58xoKA5/9ShRBu57/wBn

mlAK9l+HhBlgOMA5GKFIYGC6gsF7BqMUPvaOJjD4gwGjVmFyDScT1KdEWvXGZ3YDuJKFJJBgqCJa

w2QGL98nP9PFNIZks/oeZ0Ogsi9CI/rn7BVMfiAY7nAIToeSCF7ATeabbD2LHt7AWZRN50A1cEqD...................... (and so on for about another 50 lines)


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites
I'm getting happier :) hehe.

 

Good catch,now my test order goes thru OK BUT the confirmation email looks like (with no actual attachment):

 

 

Hmm...

 

In trying a few other fellow pdf invoice users, I changed:

Use MIME HTML When Sending Emails false

 

And it works... yahoo!!! I know your a bit puzzled at this and are working on it. Pls let me (us) know the fix and until then I am going to keep this changed to "false" (not sure what I'll be losing out on but I really want the attachment sent out)

 

Thanks Chris for all your work & headaches! I speak for all of us here on how we all appreciate it very much :)

KJ


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites
Pls let me (us) know the fix and until then I am going to keep this changed to "false" (not sure what I'll be losing out on but I really want the attachment sent out)

 

I'll certainly post something if I find it, though my setups work with both HTML set to true or false!

 

As to what you're losing turning off HTML - if you're not sending images or using coloured text, then the answer is "absolutely nothing". You'll find that the hyperlinks work in the plain text e-mails but not the html ones, so there's a plus :thumbsup:

 

Pleased you got sorted, even if it was a protracted install!

 

Cheers

 

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

Share this post


Link to post
Share on other sites
How would I go about putting this code into the invoice?

<IMG SRC="<?php echo 'barcodegen.php?barcode=' . tep_db_input($oID); ?>">

Any ideas?

 

Hi Dave,

 

I haven't tested the following so YMMV and I'm not familiar with barcodegen.php but I'm working on the following assumptions.

 

This script generates a barcode image in PNG format, the size of which you don't know until you generate it.

 

The FPDF image method takes the following parameters:

 

Image(string file, float x, float y [, float w [, float h [, string type [, mixed link]]]])

 

So try:

 

$pdf->Image('barcodegen.php?barcode=' . tep_db_input($oID), x, y, 0, 0, 'png', 0);

 

Set x and y to the co-ordinates where you want the barcode inserted. If the image is NOT a png, change to jpg. You may get away with gif as the fpdf I supplied has gif support added.

 

Let me know how you get on.

 

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

Share this post


Link to post
Share on other sites

Hi Chris,

 

thanks for the info, however it gives a couple off errors. I've checked the code in a html document and the barcode generates ok, but gives these errors in fpdf

 

Warning: getimagesize(barcodegen.php?barcode=26493) [function.getimagesize]: failed to open stream: No such file or directory in /home/dbbitz/domains/dirtbikebitz.com/public_html/admin/fpdf/fpdf.php on line 900

Warning: fopen(barcodegen.php?barcode=26493) [function.fopen]: failed to open stream: No such file or directory in /home/dbbitz/domains/dirtbikebitz.com/public_html/admin/fpdf/fpdf.php on line 1566
FPDF error: Can't open image file: barcodegen.php?barcode=26493

 

btw the contribution i'm using is http://addons.oscommerce.com/info/1218 which appears pretty straight forward with only a few lines of code

 

THanks again

 

Dave

Share this post


Link to post
Share on other sites
Hi Chris,

 

thanks for the info, however it gives a couple off errors. I've checked the code in a html document and the barcode generates ok, but gives these errors in fpdf

 

Warning: getimagesize(barcodegen.php?barcode=26493) [function.getimagesize]: failed to open stream: No such file or directory in /home/dbbitz/domains/dirtbikebitz.com/public_html/admin/fpdf/fpdf.php on line 900

Warning: fopen(barcodegen.php?barcode=26493) [function.fopen]: failed to open stream: No such file or directory in /home/dbbitz/domains/dirtbikebitz.com/public_html/admin/fpdf/fpdf.php on line 1566
FPDF error: Can't open image file: barcodegen.php?barcode=26493

 

btw the contribution i'm using is http://addons.oscommerce.com/info/1218 which appears pretty straight forward with only a few lines of code

 

THanks again

 

Dave

 

Hi Dave,

 

You'll need to make sure the path to barcodegen.php is correct. I'm not sure where you've got barcodegen.php installed in relation to you pdf invoice script.

 

Also, having looked at the contrib, you can refine the image function further to automatically set the image type:

 

$pdf->Image('barcodegen.php?barcode=' . tep_db_input($oID), x, y, 0, 0, BC_OUTTYPE, 0);

 

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

Share this post


Link to post
Share on other sites

ah ok,

 

barcodegen.php is in the root of admin which is where I am calling it from in invoice.php and packingslip.php, i'll go have a play and see where it needs to be.

 

Thanks

 

Dave

Edited by stubbsy

Share this post


Link to post
Share on other sites

I ended up giving up trying to get the existing contribution to work with fpdf as once I had specified an absolute URL fdpf did not see the file as a png.

 

I have however found another solution which works like a charm.

 

For anyone who is interested in adding a barcode of the order number to the invoice or packing slip you need to do the following:

 

Download 3 of 9 Barcode Font File for FPDF from here

 

Extract the 2 files: 3of9.php and 3of9.z, and upload them to your font folder in fpdf e.g. admin/fpdf/font/

 

Then add the following code to your invoice/packingslip.php

 

// Add Order Number as Barcode
$pdf->AddFont('3of9', '', '3of9.php');
$pdf->SetFont('3of9', '', 50);
$pdf->Text(x, y, tep_db_input($oID));

 

Replacing x and y with the values you require to place it correctly on your page.

 

You can change the font size by replacing 50 with the required size.

 

Hope this is of use to someone :)

 

Dave

Edited by stubbsy

Share this post


Link to post
Share on other sites

Hello,

 

First of all...

Thanks for the great contibution. :thumbsup:

 

There's only a slight problem for me...

I can't get the pdf packinslip to work, I keep getting a "404 page not found" error when klicking the pdf packingslip button and i don't know where to look to fix this. :'(

 

The rest of the contrib works great but there's only a litle mark up, is it posible to show and to send the customer the pdf invoice with watermark and when you look at the dpf invoice via admin it's without the watermark so you dont have to change this every time you want to print the invoice?

 

 

I hope some one can help me out.

 

 

 

Dent®os©h

Share this post


Link to post
Share on other sites
// Add Order Number as Barcode
$pdf->AddFont('3of9', '', '3of9.php');
$pdf->SetFont('3of9', '', 50);
$pdf->Text(x, y, tep_db_input($oID));

 

Just a quick update to the above, although a barcode is generated it won't scan because the generated code does not begin and end with an apostrophe *.

 

This line needs to be changed to

// Add Order Number as Barcode
$pdf->AddFont('3of9', '', '3of9.php');
$pdf->SetFont('3of9', '', 50);
$pdf->Text(x, y, '*' . tep_db_input($oID) . '*');

for the barcode genereated to scan ok

 

Dave

Share this post


Link to post
Share on other sites
Just install the admin add on to this great contribution. I do have a problem. In admin, my link looks like this

 

http://perfectit.com.sg/admin/HTTPS_SERVER...5023ca821cfb198

 

my pdfinvoice.php is located at perfectit.com.sg/catalog/

 

Could someone point out to me why gone wrong? Thanks in advance

 

 

Edit admin/orders.php

 

FIND:

<a href="' . tep__href_link('../pdfinvoice.php', 'order_id=' . $HTTP_GET_VARS['oID'] . '&passthruID=' . $pass_phrase_hash, 'SSL') . '" TARGET="_blank">

 

and replace with:

<a href="' . tep_catalog_href_link('pdfinvoice.php', 'order_id=' . $HTTP_GET_VARS['oID'] . '&passthruID=' . $pass_phrase_hash, 'SSL') . '" TARGET="_blank">

 

There are two entries like this in orders.php to change.

 

You'd better change your passthru hash now you've posted on the 'net!!

 

Rgds

 

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

Share this post


Link to post
Share on other sites
There's only a slight problem for me...

I can't get the pdf packinslip to work, I keep getting a "404 page not found" error when klicking the pdf packingslip button and i don't know where to look to fix this. :'(

I checked the instalation again and discovered that I forgot to change the filenames.php :-"

But now when I hit the PDF Packingslip button, I get the warning:

Warning: rename() [function.rename]: SAFE MODE Restriction in effect. The script whose uid is 32703 is not allowed to access /tmp owned by uid 0 in /home/*******/*******/fpdf/fpdf.php on line 908

Warning: fopen() [function.fopen]: Unable to access /tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png in /home/*******/*******//fpdf/fpdf.php on line 1566

Warning: fopen(/tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png) [function.fopen]: failed to open stream: No such file or directory in /home/*******/*******/fpdf/fpdf.php on line 1566
FPDF error: Can't open image file: /tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png

 

The image I'm using is a .png image so I don't know why its doing that.

The PDF Invoice isn't creating that error.

 

Hope you can help me,

 

Dent®os©h

Share this post


Link to post
Share on other sites
is it posible to show and to send the customer the pdf invoice with watermark and when you look at the dpf invoice via admin it's without the watermark so you dont have to change this every time you want to print the invoice?

 

 

Yep - this is pretty easy.

 

EDIT pdfinvoice.php

 

FIND:

// see if admin passthru is set and valid
$admin_access = false;
$pass_phrase = "your-pass-phrase-here";
$pass_phrase_hash = md5($pass_phrase);
if (isset($_GET['passthruID'])) {
	if ($_GET['passthruID'] === $pass_phrase_hash) {
		// get customer_id for this order number
		$customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)$_GET['order_id'] . "'");
		$customer_info = tep_db_fetch_array($customer_info_query);
		$customer_id = $customer_info['customers_id'];
		$admin_access = true;
	}
}

 

CHANGE to

 

 

// see if admin passthru is set and valid
$admin_access = false;
$watermark_override = false;
$pass_phrase = "your-pass-phrase-here";
$pass_phrase_hash = md5($pass_phrase);
if (isset($_GET['passthruID'])) {
	if ($_GET['passthruID'] === $pass_phrase_hash) {
		// get customer_id for this order number
		$customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)$_GET['order_id'] . "'");
		$customer_info = tep_db_fetch_array($customer_info_query);
		$customer_id = $customer_info['customers_id'];
		$admin_access = true;
		$watermark_override = true;
	}
}

 

FIND:

 

// add watermark if required

if (PDF_SHOW_WATERMARK == 'true') {
	$pdf->Watermark();
}

 

 

CHANGE TO

 

// add watermark if required

if (PDF_SHOW_WATERMARK == 'true' && (!$watermark_override)) {
	$pdf->Watermark();
}

 

I think this is a good idea, not printing on the admin PDFs so I'll make it a configurable option in the next version

 

Cheers

 

Chris

 

I've just seen your post re: packingslip (we cross posted) so let me look this over.

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

Share this post


Link to post
Share on other sites
Warning: rename() [function.rename]: SAFE MODE Restriction in effect. The script whose uid is 32703 is not allowed to access /tmp owned by uid 0 in /home/*******/*******/fpdf/fpdf.php on line 908

Warning: fopen() [function.fopen]: Unable to access /tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png in /home/*******/*******//fpdf/fpdf.php on line 1566

Warning: fopen(/tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png) [function.fopen]: failed to open stream: No such file or directory in /home/*******/*******/fpdf/fpdf.php on line 1566
FPDF error: Can't open image file: /tmp/gif4fpdf37947adbef5f4c5210fa1f47e30e9ea0xHFy60.png

 

Weird!

 

The fpdf class thinks your png is really a gif and is attempting to convert it by writing a new png to the /tmp directory. You're not allowed to do this as your server is running in safe mode.

 

What I don't get is you're using the same image for PDF Invoice and PDF Packingslip and the image generation code is identical .......


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

Share this post


Link to post
Share on other sites
Weird!

 

The fpdf class thinks your png is really a gif and is attempting to convert it by writing a new png to the /tmp directory. You're not allowed to do this as your server is running in safe mode.

 

What I don't get is you're using the same image for PDF Invoice and PDF Packingslip and the image generation code is identical .......

Isn't it posible to set the image in the code so fpdf doesn't have to look for it in the database and maybe also doesn't try to change it?

 

 

I've also noticed that when using the "Email PDF as Attachment - ADD-ON" it doesn't work with the "idealm_v1.26_official - Payment module"

When Paying via iDEAL (is a Dutch bank payment module) the customor gets a standart email without te PDF invoice attachment.

 

You wouldn't by any chanse know how to fix this? :blush:

 

Dent®os©h

Share this post


Link to post
Share on other sites
You're not allowed to do this as your server is running in safe mode.

Isn't there a way to fool safe mode so fpdf can write to /tmp

 

Dent®os©h

Share this post


Link to post
Share on other sites

I guess it is helpfull for others if i post the fix i had to make for this problem:

 

FPDF error: Some data has already been output, can't send PDF file

 

I started with the file pdfinvoice.php to search for spaces or carriage returns after the ?>, and follow the include/require paths. About the 10th file was the last one that caused the problem to occur. Just remove all the spaces, save, reload the page that should give the pdf.

Share this post


Link to post
Share on other sites
I'd like to know why there's a problem with the HTML enabled / disabled. My setups work OK with either mode set. Anyone else having problems with HTML mode switched on?

I also have the HTML enabled bug in it. :(

As to what you're losing turning off HTML - if you're not sending images or using coloured text, then the answer is "absolutely nothing". You'll find that the hyperlinks work in the plain text e-mails but not the html ones, so there's a plus

Exept when u are using the € as currency. Somehow it doesn't show in text emails but does show in HTML emails. :huh:

 

In text emails you get a ? instead of the € :blink:

 

 

Dent®os©h

Share this post


Link to post
Share on other sites

Hello Chris,

Pdf invoice works very well, I am very grateful for this contribution.

Now I want to open PDF in a new window, but I do not know how to do.

your can help me?

 

Thanks again.

Eusebio.

Share this post


Link to post
Share on other sites

chris,

Firstly: great contribution! i have added both v1.1 and the addon's as you have posted them.

I have one strang thing with the pdf attachments, if the mail is sent to my gmail.com account, the attachment is visible in the webmail. Even if i forward the message to my other mailaddress (then pop'ed to outlook2003) the attachment is ok. But,,, if i pop the email from gmail to my outlook i see only raw ascii (see below). Any idea's?

 

Delivered-To: myname@gmail.com

Received: by 10.86.80.18 with SMTP id d18cs193872fgb;

Fri, 14 Mar 2008 13:12:23 -0700 (PDT)

Received: by 10.78.154.14 with SMTP id b14mr31011997hue.55.1205525541941;

Fri, 14 Mar 2008 13:12:21 -0700 (PDT)

Return-Path: <info@myshop.nl>

Received: from green.qinip.net (green.qinip.net [62.100.30.36])

by mx.google.com with ESMTP id e10si20778882muf.10.2008.03.14.13.12.21;

Fri, 14 Mar 2008 13:12:21 -0700 (PDT)

Received-SPF: neutral (google.com: 62.100.30.36 is neither permitted nor denied by best guess record for domain of info@myshop.nl) client-ip=62.100.30.36;

Authentication-Results: mx.google.com; spf=neutral (google.com: 62.100.30.36 is neither permitted nor denied by best guess record for domain of info@myshop.nl) smtp.mail=info@myshop.nl

Received: from myhost (----)

by green.qinip.net (Postfix) with SMTP id 7871EC5F5

for <peebor@gmail.com>; Fri, 14 Mar 2008 21:12:24 +0100 (CET)

Date: Fri, 14 Mar 2008 21:12:17 +0100

Subject: Bestelnummer: 10040 - myshop

From: "---" <info@myshop.nl>

To: " " <myname@gmail.com>

MIME-Version: 1.0

X-Mailer: osCommerce

Content-Type: multipart/mixed;

boundary="=_e33a5576e9ca36d5afaed96b7c4dbbe4"

Message-Id: <20080314201224.7871EC5F5@green.qinip.net>

 

--=_e33a5576e9ca36d5afaed96b7c4dbbe4

Content-Type: text/plain; charset="iso-8859-1"

Content-Transfer-Encoding: 7bit

 

<..the text content..>

 

--=_e33a5576e9ca36d5afaed96b7c4dbbe4

Content-Type: application/pdf

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="_____invoice_10040.pdf"

 

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy

IDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3VidHlwZSAvTGluayAvUmVjdCBbMTkuODQg

ODEzLjU0IDg4LjcyIDc4OC4wM10gL0JvcmRlciBbMCAwIDBdIC9BIDw8L1MgL1VSSSAvVVJJIChp

bmRleC5waHApPj4+Pl0KL0NvbnRlbnRzIDQgMCBSPj4KZW5kb2JqCjQgMCBvYmoKPDwvRmls

bmRleC5waHApPj4+dGVy

<..etc..>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×