Jump to content
chris23

[CONTRIBUTION] PDF Customer Invoice

Recommended Posts

Can someone tell me how to manually set true value so pdf's attach rather then through admin/configuration menu. I have a contribution installed that is not allowing the configuration menu to display the option to turn on and off pdf attachments. I understand this contribution is defaulted to false?

Share this post


Link to post
Share on other sites
PHP Fatal error: Call to undefined function tep_session_is_registered() in /var/www/vhosts/xxxxx/httpdocs/catalog/pdfinvoice.php on line 33, referer: http://www.xxxxx/catalog/account_history_i...php?order_id=23

 

This error comes while trying to open a pdf invoice from the account history, no pdf is shown. It seems like the error existed after installing the pdf invoice attachment add-on. Never noticed it though, cause the email attachment function works great.

 

The problem seems complicated, has to do with session? Spent about 4 hours finding out whats wrong.... Any ideas?

 

When you modified pdfinvoice.php for pdf attachment, did you replace:

 

require('includes/application_top.php');

 

with

 

// prevents reinclusion if called from checkout_process.php
require_once('includes/application_top.php');

 

as it looks like application_top is not being included - implying you have neither line ..

 

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
Can someone tell me how to manually set true value so pdf's attach rather then through admin/configuration menu. I have a contribution installed that is not allowing the configuration menu to display the option to turn on and off pdf attachments. I understand this contribution is defaulted to false?

 

 

EDIT pdfinvoice.php

 

AFTER

// prevents reinclusion if called from checkout_process.php
require_once('includes/application_top.php');

 

ADD

 

define('PDF_INVOICE_EMAIL_ATTACHMENT', true);

 

That will activate the email attachment - set true to false to toggle it off if you have problems.

 

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

Hi I installed the PDF Packing slip addon, but for some reason it is calculating weight wrong on the packing slip if I have for instance:

 

2 x lead weight

1 x toilet roll

 

If the lead weight weighs 5 kg and toilet roll weighs 1kg it will show as just 6KG so it aint adding the quantities for me, what could be wrong?

 

 

Any ideas on whats wrong?

 

Kind regards

Chris

Share this post


Link to post
Share on other sites
Hi I installed the PDF Packing slip addon, but for some reason it is calculating weight wrong on the packing slip if I have for instance:

 

2 x lead weight

1 x toilet roll

 

If the lead weight weighs 5 kg and toilet roll weighs 1kg it will show as just 6KG so it aint adding the quantities for me, what could be wrong?

 

 

Any ideas on whats wrong?

 

Kind regards

Chris

 

Any idea what's wrong - yep, I'm a village idiot!

 

EDIT pdfpackingslip.php

 

FIND

 

// Now work out totals for line count, item count and total weight:
$lines = sizeof($order->products);
$weight = 0;
$items = 0;
for ($i = 0; $i < $lines; $i++) {
$weight += $order->products[$i]['products_weight'];
$items += $order->products[$i]['qty'];
}

 

REPLACE WITH:

 

// Now work out totals for line count, item count and total weight:
$lines = sizeof($order->products);
$weight = 0;
$items = 0;
for ($i = 0; $i < $lines; $i++) {
$weight += ($order->products[$i]['products_weight'] * $order->products[$i]['qty']);
$items += $order->products[$i]['qty'];
}

 

I'll get a fixed copy of the file uploaded.

 

Sorry!

 

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!!, Thanks very much that now it works perfect, I also found a good use for this on the admin/orders.php & admin/invoice.php and I also use another modified invoice(non PDF) for which we send to our supplier, with only cost price fields...

 

Our supplier/dropshipper charges nearly £10 regardless of how big an item is, so people get a bit angry when an item which costs £4.99 costs £14.99 total when delivered, so I have used your code and modified it to add a warning if the weight is below 3kg and trhe supplier will deliver to us for free so we can post via a cheaper method.

 

If anyone is interested maybe i could upload it as a contribution sometime... below will show you this on the orders only, but its still only 2 steps on the admin/invoice.php (same code)

 

Remembering my site is heavily modified ----- >>

 

 

Run SQL(change the fields autoincrement 2008 and 2007 to values that are free in your configuration):

 

-- Table structure for table `configuration`
--

CREATE TABLE IF NOT EXISTS `configuration` (
 `configuration_id` int(11) NOT NULL auto_increment,
 `configuration_title` varchar(255) collate latin1_general_ci NOT NULL,
 `configuration_key` varchar(255) collate latin1_general_ci NOT NULL,
 `configuration_value` text collate latin1_general_ci,
 `configuration_description` varchar(255) collate latin1_general_ci NOT NULL,
 `configuration_group_id` int(11) NOT NULL default '0',
 `sort_order` int(5) default NULL,
 `last_modified` datetime default NULL,
 `date_added` datetime NOT NULL default '0000-00-00 00:00:00',
 `use_function` varchar(255) collate latin1_general_ci default NULL,
 `set_function` varchar(2047) collate latin1_general_ci default NULL,
 PRIMARY KEY  (`configuration_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2008;

--
-- Dumping data for table `configuration`
--

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES
(2007, '(For Supplier) Low Weight Warning for Invoices', 'LOW_WEIGHT_WARNING_SUPPLIER', '3.00', 'A warning message is shown on invoices and orders page etc.. for any weight equal to or below this inputted value', 3, 15, '2008-10-09 16:51:53', '2008-10-09 13:43:01', NULL, NULL);

 

 

Open orders.php:

 

Find:

 

<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

 

 

add after:

 

<?php
 if (($action == 'edit') && ($order_exists == true)) {
$order = new order($oID);

 // Now work out totals for line count, item count and total weight:
$lines = sizeof($order->products);
$weight = 0;
$items = 0;
for ($i = 0; $i < $lines; $i++) {
$weight += ($order->products[$i]['products_weight'] * $order->products[$i]['qty']);
$items += $order->products[$i]['qty'];
}
?>

 

Find code below which looks like this:

 

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
		<td class="main"><a href="java script: updateOrderField('<?php echo $oID; ?>', 'orders', 'payment_method', '<?php echo addslashes($order->info['payment_method']); ?>');" class="ajaxLink"><?php echo $order->info['payment_method']; ?></a></td>
	  </tr>

 

Add after:

 

<?php echo ('<b>Total Weight:</b> ') . '<font color=red><b>' . number_format($weight,2) . ' </b></font><b>KG</b>'; ?>

	  <?php 

	  if ($weight<=LOW_WEIGHT_WARNING_SUPPLIER){
	  echo ('<BR><font size="1" color=red><b>WARNING: PRODUCTS WEIGHT IS EQUAL TO OR BELOW ' .LOW_WEIGHT_WARNING_SUPPLIER. ' KILO\'S!!</b><br>PLEASE REMEMBER TO HAVE THE ITEM(s) SENT DIRECTLY TO US SO WE CAN SHIP VIA OUR OWN METHOD(s)</font>'); 
	  }else{}

	  ?>

 

 

 

This will now show the total weight and display a warning if the weight displayed is less than the figure entered in configuration/maximum values

Share this post


Link to post
Share on other sites

Hi Chris,

I've worked with your additions of your post 470, which works great. But after implementing ideal (dutch payment system), no emails are sent anymore. I don't get any errors in my logs. Any idea what went wrong? No spoiling of the forum by posting the entire code, but downoad my checkout_process.php

http://cid-ac338778d14d3f01.skydrive.live....%7C_process.php

 

I really hope you could help me out. Thanx!

Share this post


Link to post
Share on other sites
Support for PDF Customer Invoice contribution

 

This contribution will add a link to a customer's order history detail page (account_history_info.php). When clicked, this link

will generate a PDF copy invoice for the order.

This contribution is based on PDF Invoice (http://www.oscommerce.com/community/contributions,3027)

Apart from recoding PDF Invoice to work client side, I have added the following features, configurable from within admin:

 

1. Font can be chosen - arial, times, courier, helvetica.

2. Colours for the invoice elements can be chosen. Hex values supplied are automatically converted to RGB as needed by FPDF so you can easily

match up your stylesheet.css colours to the invoice colours for a consistent look.

3. An optional watermark (text of your choice e.g. "Copy Invoice") can be added to the invoice.

4. An optional VAT tax reference can be added to the invoice.

5. Choice of displaying generated PDF inline or by forcing a download - set within admin configuration.

6. PDF Metadata (Store owner, Invoice number etc) is automatically added to the PDF.

7. Choice of store logos - png, gif, jpg.

8. Custom footer splash (marketing text) can be added.

9. Store logo size can be easily 'tweaked'.

 

The invoice will also display product attributes, if applicable (something which is missing from PDF Invoice)

 

Download contribution at http://www.oscommerce.com/community/contributions,5321

Share this post


Link to post
Share on other sites

I added PDF Customer Invoice v1.2 and PDF Packing Slip. The shipping address has disappeared. When I upload the original admin/includes/classes/order.php the shipping address comes back but of course the weight goes to zero. The order.php page has been modified but I was careful when I installed the packing slip mod to watch for changes in the code from other mods. Where do I look to restore the shipping address?

 

Dan

Share this post


Link to post
Share on other sites

Hi,

 

PDF Customer Invoice v1.2 is working great from out of the customer history details screen.

 

I'm having 2 wierd issues though and hopefully somebody can help me out:

 

1. If I set the Force Download to 'true' and click the pdf link, the pdf isn't downloaded but an errormessage appears in stead: "Can't find pdfinvoice.php from www.mydomain". When set to false, the pdf opens perfectly within the browser.

 

2. I've also installed the Admin invoice.php from contrib 3027. If I click on admin on the Invoice button of the order the new screen comes up but gives me a 500 - page not found error. Only reference to this I could find was to add [Header('Pragma: public');] to fpdf.php but that's already there by default so can't be the issue here.

 

anybody some ideas? Thnx!

Share this post


Link to post
Share on other sites

Hello,

I've just installed this great contribution and I use the send MIME mail option with HTML enable in the admin panel.

With the add-on pdf invoice attached in the email, it's not working, the email received is not decoded I think.

 

Do I have to have th MIME option to false (ie send email with text only) ?

 

Thanks

Share this post


Link to post
Share on other sites
I added PDF Customer Invoice v1.2 and PDF Packing Slip. The shipping address has disappeared. When I upload the original admin/includes/classes/order.php the shipping address comes back but of course the weight goes to zero. The order.php page has been modified but I was careful when I installed the packing slip mod to watch for changes in the code from other mods. Where do I look to restore the shipping address?

 

Dan

 

Dan,

 

I've no idea why modifying your admin/includes/classes/order.php would cause you to lose the shipping address.

 

All I did was add the customer_id (so that the customer ID appears on the packing slip) to the customer information array; I didn't remove or amend any of the other details.

 

Have you added any other mods to this file?

 

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
Hello,

I've just installed this great contribution and I use the send MIME mail option with HTML enable in the admin panel.

With the add-on pdf invoice attached in the email, it's not working, the email received is not decoded I think.

 

Do I have to have th MIME option to false (ie send email with text only) ?

 

Thanks

 

Hi,

 

Setting the HTML e-mails to false has been known to work for some users.

 

If you look back on this thread, there have been numerous problems encountered with the attachment but unfortunately I've been unable to replicate the issues encountered!

 

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
1. If I set the Force Download to 'true' and click the pdf link, the pdf isn't downloaded but an errormessage appears in stead: "Can't find pdfinvoice.php from www.mydomain". When set to false, the pdf opens perfectly within the browser.

 

2. I've also installed the Admin invoice.php from contrib 3027. If I click on admin on the Invoice button of the order the new screen comes up but gives me a 500 - page not found error. Only reference to this I could find was to add [Header('Pragma: public');] to fpdf.php but that's already there by default so can't be the issue here.

 

Hi,

 

Issue 1. Very odd. The option "Force download" sets the headers send by the FPDF class. Are you using the FPDF class provided with the contribution or did you have an existing version installed?

 

Issue 2. Can you confirm the error code you're getting? "Page not found is a 404" error, 500 is a server error (normally either a PHP code error or a .htaccess problem)

 

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 Christian,

 

Thanks for your post. Can you let me know which contribution you intend using (there are several CCGV contibs out there; Vger's CCGV(Trad) is by far the best IMHO)?

It should be possible to add the extra information to the PDF.

 

Kind regards,

Chris

Hi Chris,

Thanks for your reply. After reading hundreds of pages of forum posts I have to say that I can not use CCGV(Trad). Reasons: It is not php 5 compatible. It is not Paypal IPN 2.xx compatible. It is not OsCommerce MS2.2 rc2a compatible. While I appreciate the contributors unwillingness to sway with every last whim of the crowd it seems unreasonable to not keep the code updated to the latest security developments.

I guess I'll keep looking.

Thanks

Christian


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites
Hi,

 

Issue 1. Very odd. The option "Force download" sets the headers send by the FPDF class. Are you using the FPDF class provided with the contribution or did you have an existing version installed?

 

Issue 2. Can you confirm the error code you're getting? "Page not found is a 404" error, 500 is a server error (normally either a PHP code error or a .htaccess problem)

 

Rgds,

 

Chris

 

Hi Chris,

 

some answers:

 

Issue 1: nope, installed the contrib as is, according fpdf.php it's version 1.53. Most weird is that, by looking at the message, the system is trying to download the pdfinvoice.php file and not a pdf itself. But that's through the eyes of a fpdf newbie...

 

Issue 2: it's the 500 one: (HTTP error - 500 - internal server error). I've now also detected that my domain log gives an error when trying to open the pdf:

PHP Warning: require(fpdf/fpdf.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory

and

PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required 'fpdf/fpdf.php' (include_path='.:')

Share this post


Link to post
Share on other sites
Hi Chris,

 

some answers:

 

Issue 1: nope, installed the contrib as is, according fpdf.php it's version 1.53. Most weird is that, by looking at the message, the system is trying to download the pdfinvoice.php file and not a pdf itself. But that's through the eyes of a fpdf newbie...

 

Issue 2: it's the 500 one: (HTTP error - 500 - internal server error). I've now also detected that my domain log gives an error when trying to open the pdf:

PHP Warning: require(fpdf/fpdf.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory

and

PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required 'fpdf/fpdf.php' (include_path='.:')

 

Still not sure what's going on with issue 1, I'll keep pondering this

 

Issue 2. The admin version of PDF invoice (contrib 3027) expects to find the fpdf class under the "admin" folder. You have fpdf installed from my contribution under catalog but you either need to tell your admin version to use the catalog side fpdf or upload fpdf under admin

 

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

Chris

 

I have this 1.2 installed and i have three problems

 

1: Customer Reference is showing as 0 on all invoices, how can i get this to be the true reference or how can it be removed.

2: Date does not show as D/M/Y despite adjusting files as shown in previous posts

3: Where it shows the Payment method part, this is not complete i get Payment Method: Credit/Debit Card or Pa when it should be Payment Method: Credit/Debit cards or Paypal is there a way of putting the Credit/Debit Card or Paypal below Payment method: so that it doesn't run off the page?

 

Nick

Share this post


Link to post
Share on other sites
I have this 1.2 installed and i have three problems

 

1: Customer Reference is showing as 0 on all invoices, how can i get this to be the true reference or how can it be removed.

 

Nick,

 

Can you confirm which version you have - is it the August 2008 version uploaded by luckyno?

This version has a bug fix from earlier versions where the customer reference displayed as 0 when the PDF was accessed from admin.

 

Does the customer reference display from the client side?

 

2: Date does not show as D/M/Y despite adjusting files as shown in previous posts

 

What date formats do you have set in /includes/language/english.php? pdfinvoice.php takes its date format from here and should follow the date format used by the rest of your site.

 

3: Where it shows the Payment method part, this is not complete i get Payment Method: Credit/Debit Card or Pa when it should be Payment Method: Credit/Debit cards or Paypal is there a way of putting the Credit/Debit Card or Paypal below Payment method: so that it doesn't run off the page?

 

The easiest solution here is to increase the size of the 'totals' cell - this has come up many times on this thread but the general principle is move the x coordinate of the cell to the left by a set number, then increase the cell size by the same amount. For the totals cell, edit pdfinoice.php:

 

FIND the block:

 

for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
$pdf->SetY($Y_Table_Position + 5);
$pdf->SetX(102);
$temp = substr ($order->totals[$i]['text'],0 ,3);
if ($temp == '<b>')
	{
	$pdf->SetFont(PDF_INV_CORE_FONT,'B',10);
	$temp2 = substr($order->totals[$i]['text'], 3);
	$order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4);
	}
$pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');
$Y_Table_Position += 5;
}

 

Change SetX(102) down and increase MultiCell(94, .....) by the same amount. Keep playing until the text fits. You could also reduce the font size for the totals block. This works fine as the totals block is right aligned.

 

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
Nick,

 

Can you confirm which version you have - is it the August 2008 version uploaded by luckyno?

This version has a bug fix from earlier versions where the customer reference displayed as 0 when the PDF was accessed from admin.

 

Does the customer reference display from the client side?

 

 

 

What date formats do you have set in /includes/language/english.php? pdfinvoice.php takes its date format from here and should follow the date format used by the rest of your site.

 

 

 

The easiest solution here is to increase the size of the 'totals' cell - this has come up many times on this thread but the general principle is move the x coordinate of the cell to the left by a set number, then increase the cell size by the same amount. For the totals cell, edit pdfinoice.php:

 

FIND the block:

 

for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
$pdf->SetY($Y_Table_Position + 5);
$pdf->SetX(102);
$temp = substr ($order->totals[$i]['text'],0 ,3);
if ($temp == '<b>')
	{
	$pdf->SetFont(PDF_INV_CORE_FONT,'B',10);
	$temp2 = substr($order->totals[$i]['text'], 3);
	$order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4);
	}
$pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');
$Y_Table_Position += 5;
}

 

Change SetX(102) down and increase MultiCell(94, .....) by the same amount. Keep playing until the text fits. You could also reduce the font size for the totals block. This works fine as the totals block is right aligned.

 

HTH

 

Chris

Chris

Thank you for the quick reply, i currently cant view the invoices from the customers side at all, i need to go back one step at a time to see what is wrong.

 

Nick

Share this post


Link to post
Share on other sites

Hi Chris

Great contribution have just installed Version 1.1 and the problem I am having is with product attributes not showing properly

See photo

I know this does work properly as posting 164

 

Can you please help

 

Product%20Attrub%20pdf%20invoice.jpg

Share this post


Link to post
Share on other sites
Great contribution have just installed Version 1.1 and the problem I am having is with product attributes not showing properly

 

Jonathan,

Can you get any attributes at all to display or do you only have an issue with long attributes that could be forcing a line break?

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
Jonathan,

Can you get any attributes at all to display or do you only have an issue with long attributes that could be forcing a line break?

Chris

 

On the image Exact thrack length you req..

 

is part of the attrubute so the answer is yes

 

This is what it should look like

invoice.jpg

Share this post


Link to post
Share on other sites
On the image Exact thrack length you req..

 

is part of the attrubute so the answer is yes

 

This is what it should look like

invoice.jpg

 

I have fixed this problem by using the replacement code in posting 78

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

×