Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] PDF Customer Invoice


chris23

Recommended Posts

well it work on normal invoice but it just doenst work on PDF

 

The normal invoice runs under admin and uses admin/includes/classes/order.php not includes/classes/order.php. You obviously don't have an error in the former, but do appear to have one in the latter case (as per orig. post.) The PDF invoice uses client side code, not admin side code.

 

Did you try to view an account history? This will confirm whether you have an error with includes/classes/order.php - there shouldn't be a "comments" field in that SQL

 

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

it finally came up in that error so how can i insert this so I dont get this error again.

 

Tim,

 

I would take a backup of includes/classes/order.php before attempting the following

 

Edit includes/classes/order.php

 

FIND:

 

"select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, comments, fedex_track_num, ups_track_num, usps_track_num, fedex_freight_track_num, dhl_track_num, currency, currency_value, date_purchased, orders_status, last_modified " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"

 

and replace with:

 

"select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, fedex_track_num, ups_track_num, usps_track_num, fedex_freight_track_num, dhl_track_num, currency, currency_value, date_purchased, orders_status, last_modified " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"

 

i.e. remove the "comments" entry. This should fix things.

 

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 got it fix about no pdf file comes up any ideas why not?

 

Are you getting a completely blank screen? If you don't have error reporting on, do you get any error messages if you temporarily turn on error reporting?

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,

 

Did you receive my email on your msn messenger account?

(the one in your profile) ?

 

Its about the pdfinvoice models column..

 

greetz, marco

 

Hi Marco,

 

Yes I've got it now - I don't monitor the msn address (use it for IM only and as my spam trap!)

I'll have a look at the code you sent and reply by email asap

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

Link to comment
Share on other sites

I finally have this contrib installed and configured the way I wanted it, love it! :D

 

Too bad it doesn't use the same templates and PDF class as Batch Print Center, so the templates could easily be exchanged between them, I just had to customize the invoice to suit my theme.

 

Great contribution!

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

Too bad it doesn't use the same templates and PDF class as Batch Print Center, so the templates could easily be exchanged between them, I just had to customize the invoice to suit my theme.

 

Hi Aitor,

 

Good point about the PDF class. As in all things PHP there are twenty ways to solve a problem when one would do :'(

I stuck with fpdf rather than ezpdf as it formed part of the original contrib and I'm most familiar with it.

As for templating, I have posted earlier that I am considering a templating system for this contrib to help reduce the work required to change the layout.

Of course this relies on more hours in the day .... >_<

Glad you like the contrib

iHasta luego!

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 how are you? :lol:

 

 

I wanted the customer to see the pdf invoice only if the status is 3 or 6.

 

Originally I have this in my account_history_info.php :

 

<!-- start pdf //-->

<?php
// only display pdf invoice link if * latest * order status is 3 (delivered)
$delivered_query = tep_db_query("select max(osh.date_added) as los,  osh.orders_status_id from " . TABLE_ORDERS_STATUS_HISTORY . " osh where osh.orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "' group by osh.orders_status_id order by los desc limit 1");

$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3){
?>
<tr>
	<td class="main"><b><?php echo PDF_INVOICE; ?></b></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td  class="main"><?php echo tep_image(DIR_WS_IMAGES . 'pdf.gif', 'PDF invoice','','','style="vertical-align:middle"') . sprintf(PDF_DOWNLOAD_LINK,
		tep_href_link(FILENAME_CUSTOMER_PDF, 'order_id=' . $HTTP_GET_VARS['order_id'] , 'SSL')); ?></td>
	  </tr>
	</table>
	</td>
  </tr>
<?php
}
?>
<!-- end pdf //-->

 

 

So I tried to change this part :

 

	$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3){

 

by this :

 

	$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3 or 6){

 

But now the pdf invoice is available for all status :huh:

 

 

Can you help me to have pdf invoice in the customer account only if the status is 3 or 6?

 

Thanks a lot :thumbsup:

Link to comment
Share on other sites

	$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3 or 6){

 

But now the pdf invoice is available for all status :huh:

Can you help me to have pdf invoice in the customer account only if the status is 3 or 6?

 

My Php knowledge is not that much, but I would say that would be more something like:

 

	$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3) || ($delivered_status['orders_status_id'] == 6){

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

Hi Aitor,

Good point about the PDF class. As in all things PHP there are twenty ways to solve a problem when one would do :'(

I stuck with fpdf rather than ezpdf as it formed part of the original contrib and I'm most familiar with it.

As for templating, I have posted earlier that I am considering a templating system for this contrib to help reduce the work required to change the layout.

Of course this relies on more hours in the day .... >_<

Glad you like the contrib

iHasta luego!

 

Hi Chris,

Yeah, it is probably not the best idea to have the invoice layout hardcoded on pdfinvoice.php , even only one template (the invoice) is needed here.

As I said, I also have Batch Print Center installed and that is the one I use the most. It would have been great for me to just get the template I already have there with your contrib, or even have them share templates somewhere (not that I expect to change them anytime soon, but if I ever have to do it, I will have to change it in two places)

Muchas gracias! :)

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

My Php knowledge is not that much, but I would say that would be more something like:

 

	$delivered_status = tep_db_fetch_array($delivered_query);
if ($delivered_status['orders_status_id'] == 3) || ($delivered_status['orders_status_id'] == 6){

 

HI MindTwist :thumbsup:

 

I try your code and I have this error :

 

Parse error: syntax error, unexpected T_BOOLEAN_OR in /home/xxxxxx/public_html/account_history_info.php on line 235

 

 

 

Thanks :thumbsup:

Link to comment
Share on other sites

HI MindTwist :thumbsup:

 

I try your code and I have this error :

 

Parse error: syntax error, unexpected T_BOOLEAN_OR in /home/xxxxxx/public_html/account_history_info.php on line 235

Thanks :thumbsup:

 

Hi Jean,

 

Aitor is on the right lines:

 

if ($delivered_status['orders_status_id'] == 3) || ($delivered_status['orders_status_id'] == 6){

 

should be:

 

if ($delivered_status['orders_status_id'] == 3) || $delivered_status['orders_status_id'] == 6){

 

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

HI MindTwist :thumbsup:

 

I try your code and I have this error :

 

Parse error: syntax error, unexpected T_BOOLEAN_OR in /home/xxxxxx/public_html/account_history_info.php on line 235

Thanks :thumbsup:

 

Oooops, I think there is an extra ) on Chris code, or 2 missing on mine.

 

Here are the 2 options that I think should work:

if ($delivered_status['orders_status_id'] == 3 || $delivered_status['orders_status_id'] == 6){

Or:

if ( ($delivered_status['orders_status_id'] == 3) || ($delivered_status['orders_status_id'] == 6) ){

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

Oooops, I think there is an extra ) on Chris code, or 2 missing on mine.

 

Doh! You're right, I removed one, not the other!

 

Either of your solutions, Aitor, will work.

 

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

Link to comment
Share on other sites

  • 4 weeks later...

HI Chris,

 

back again with a couple of questions for you which I've not been able to figure out myself.

 

First one might be quite straight forward, how would I put the customers phone number and email address on the invoice?

 

Secondly, I'd like to be able to have the product name in bold and the attributes listed in a smaller font but in italics. The way it currently works one change effects both. Any Ideas?

 

And lastly, the column containing the number of items purchased, i have been trying to figure out how to align the number of items at the top of the cell rather than floating in the middle, so that it appear next to the product description. When I have a few rows of attributes it makes the invoice more difficults to read (we use this for the packing slip also)

 

Any help much appreciated.

 

Cheers

 

Dave

Edited by stubbsy
Link to comment
Share on other sites

Hi Dave,

 

Hope you're well.

 

First one might be quite straight forward, how would I put the customers phone number and email address on the invoice?

 

Easy enough:

 

Find (pdfinvoice.php):

 

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

 

After add:

 

	// Draw customer phone
 $pdf->Text(75,117, tep_html_entity_decode(PDF_INV_CUSTOMER_PHONE) . tep_html_entity_decode($order->customer["telephone"]));
// Draw customer email
 $pdf->Text(130,117, tep_html_entity_decode(PDF_INV_CUSTOMER_EMAIL) . tep_html_entity_decode($order->customer["email_address"]));

 

You'll need to add language definitions for PDF_INV_CUSTOMER_PHONE, PDF_INV_CUSTOMER_EMAIL to languages/english/pdfinvoice.php

 

define('PDF_INV_CUSTOMER_PHONE', 'Phone: ');
define('PDF_INV_CUSTOMER_EMAIL','E-mail: ');

 

You may need to add a $pdf->SetFont to the entire details box to reduce the font size.

 

Secondly, I'd like to be able to have the product name in bold and the attributes listed in a smaller font but in italics. The way it currently works one change effects both. Any Ideas?

 

Can't be done using the MultiCell method as currently used - this accepts one font, one size. The whole table code would need recoding using Write() to allow for this formatting :(

Sorry!

And lastly, the column containing the number of items purchased, i have been trying to figure out how to align the number of items at the top of the cell rather than floating in the middle, so that it appear next to the product description. When I have a few rows of attributes it makes the invoice more difficults to read (we use this for the packing slip also)

 

Quick dirty fix:

 

FIND

 

Find (pdfinvoice.php):

 

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(9,($cell_height * $attrib_count), ($order->products[$i]['qty']) ,1,'C');

 

REPLACE with:

 

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
// Pad cell by ($attrib_count * \n) linebreaks to 'force' qty to cell top
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->MultiCell(9,($cell_height), ($order->products[$i]['qty'] . $n_padd) ,1,'C');
// end add padding

 

Note for anyone else reading this post. This last fix only works with the modified attribute layout in post #78 here

 

Cheers

 

Chris

 

PS 2 out of 3 ain't bad :-"

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

Thanks Chris for the quick response (as usual)

 

Yep, I'm fine thanks :)

 

I'm sure I can live with 2 out of 3.

 

For the one where I wanted the quantity at the top of the box, I don't have that quantity code, i have this

 

$attrib_count++;

$product_name_attrib_contact = $order->products[$i]['name'] . $prod_attribs;

$pdf->SetFillColor(245);

$pdf->SetFont(Arial,'',10);

$pdf->SetY($Y_Table_Position);

$pdf->SetX(6);

$pdf->MultiCell(9,($cell_height*$attrib_count),$order->products[$i]['qty'],0,'C',1);

 

cheers

 

Dave

Link to comment
Share on other sites

Dave,

 

Looks like you're been fiddling with colours!

 

All you need to do is replace this bit of yours:

 

$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(9,($cell_height*$attrib_count),$order->products[$i]['qty'],0,'C',1);

 

With this bit of mine:

 

  $pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
// Pad cell by ($attrib_count * \n) linebreaks to 'force' qty to cell top
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->MultiCell(9,($cell_height), ($order->products[$i]['qty'] . $n_padd) ,1,'C');
// end add padding

 

Let me know how you get on. I've tested it my end and it seems to work fine.

 

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

Link to comment
Share on other sites

Hi Chris,

 

With regards the cell padding, I'm trying to add the same logic to the remaining columns; model, tax etc, this works fine on the model column, but on the others I end up with white space under the prices etc and I can't see what is different in the code to be causing it.

 

invoice.gif

 

This is the code I currently have

 

	$attrib_count++;
$product_name_attrib_contact = $order->products[$i]['name'] . $prod_attribs;
$pdf->SetFillColor(245);
$pdf->SetFont(Arial,'',8);
 $pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
// Pad cell by ($attrib_count * \n) linebreaks to 'force' qty to cell top
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->MultiCell(9,($cell_height), ($order->products[$i]['qty'] . $n_padd) ,0,'C',1);
// end add padding

$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(Arial,'',8);
$pdf->MultiCell(78,$cell_height,tep_html_entity_decode($product_name_attrib_contact),0,'L',1);

$pdf->SetFont(Arial,'',8);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(93);
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->SetFont(Arial,'',8);
$pdf->MultiCell(25,($cell_height),tep_html_entity_decode($order->products[$i]['model'] . $n_padd),0,'C',1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(118);
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->SetFont(Arial,'',8);
$pdf->MultiCell(20,($cell_height),$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value'] . $n_padd),0,'C',1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(138);
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->SetFont(Arial,'',8);
$pdf->MultiCell(20,($cell_height),$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value'] . $n_padd),0,'C',1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(158);
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->MultiCell(20,($cell_height),$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value'] . $n_padd),0,'C',1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(178);
$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}
$pdf->MultiCell(20,($cell_height),$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value'] . $n_padd),0,'C',1);

 

Any ideas what the problem is?

 

Thanks

 

Dave

Link to comment
Share on other sites

Hi Chris,

 

With regards the cell padding, I'm trying to add the same logic to the remaining columns; model, tax etc, this works fine on the model column, but on the others I end up with white space under the prices etc and I can't see what is different in the code to be causing it.

Any ideas what the problem is?

 

Thanks

 

Dave

 

Hi Dave,

 

You have placed the $n_padd in slightly the wrong place for each of the currency entries. They need to be just after the closing bracket of the currencies format function

 

Eg for

 

$pdf->MultiCell(20,($cell_height),$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']. $n_padd),1,'C');

 

You need:

$pdf->MultiCell(20,($cell_height),$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . $n_padd ,1,'C');

 

As an aside,you don't need to repeat the

$n_padd="";
for($n_count=0; $n_count<$attrib_count; $n_count++) {
$n_padd.="\n";
}

 

loop - just the first entry is needed to set the number of breaks.

 

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

Link to comment
Share on other sites

Hi Chris,

 

I'm to add order comments to the bottom of the invoice below the order totals but not having any luck. No problem adding the text but pulling the comments from the database has me stumped

 

Any ideas?

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...