Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] PDF Customer Invoice


chris23

Recommended Posts

Hi,

 

Is there anybody who has used this contribution with the STS contribution.

 

I installed pdf customer invoice. All runs well except the images used are the original ones from oscommerce and not the ones in my sts directory.

 

I hope someone can give my some pointers.

Link to comment
Share on other sites

The watermark issue is manualy fixed..

 

don't no why but if I uncomment following in pdfinvoice.php

 

// add watermark if required

if(PDF_SHOW_WATERMARK == 'true'){

$pdf->Watermark();

}

 

To

 

// add watermark if required

//if(PDF_SHOW_WATERMARK == 'true')

{

$pdf->Watermark();

}

 

So the verification of the true is not active, but it works !

I looked again in phpmyadmin, but the field does exist and it is set to true ?!

it seems like it isn't checking database correctly..

but it doesn't really matter, one issue solved

 

This should not be necessary. All the configuration constants are loaded into pdfinvoice.php via the inclusion of application_top.

 

There could be something wrong with your installation if these are being ignored. This is probably why your "force download" option is also being ignored.

 

Are your other customisations like colours, text, images being honoured when the pdf is generated?

 

 

next issue customer numbers auto fill, is an better problem.. (dig.. dig...)...help is appreciated...

 

I must be feeling kind today! The contrib you have doesn't add the extra customer number to the orders object so you'll have to manually query for it:

 

FIND in pdfinvoice.php:

 

// Draw customer reference
$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . $customer_info['customers_additional_customers_number']);

 

REPLACE with:

 

// Draw customer reference
$customer_add_number_query = tep_db_query("select customers_additional_customers_number from " . TABLE_CUSTOMERS . " where customers_id = '". $customer_id . "'");
$customer_add_number = tep_db_fetch_array($customer_add_number_query);
$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . $customer_add_number['customers_additional_customers_number']);

 

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

Hi,

 

Is there anybody who has used this contribution with the STS contribution.

 

I installed pdf customer invoice. All runs well except the images used are the original ones from oscommerce and not the ones in my sts directory.

 

I hope someone can give my some pointers.

 

Hi Geert,

 

I don't use the STS contrib myself but should be able to set the path to the images folder for STS by editing the path under "Choose logo" in admin

 

The usual path is images/your_logo.gif

 

For STS it's probably something like STS/images/your_logo.gif (please note this is just for illustration - I don't know STS's directory layout!)

 

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

First off all, thank you for your kindness...

 

// Draw customer reference
$customer_add_number_query = tep_db_query("select customers_additional_customers_number from " . TABLE_CUSTOMERS . " where customers_id = '". $customer_id . "'");
$customer_add_number = tep_db_fetch_array($customer_add_number_query);
$pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . $customer_add_number['customers_additional_customers_number']);

 

Works perfect on customer login (account history info)

But can't get a customer number when generating throught Admin ?!..

Link to comment
Share on other sites

chris23,

 

Another question, is it possible to show the product options not after each other, but in a row?

 

and is it possible to show an message in account_history_info.php when there is NO invoice (no shipping status)

That the order invoice is pending along the status?

 

regards Marcot

Link to comment
Share on other sites

Chris23, do you also hevan an solution why the customer number is generated on the client side.

but not on the admin pdf invoice side ?

 

The code I gave you will only work client side. If you want admin access you need a more complex query:

 

REPLACE your code:

 

$customer_add_number_query = tep_db_query("select customers_additional_customers_number from " . TABLE_CUSTOMERS . " where customers_id = '". $customer_id . "'");

 

WITH:

$customer_add_number_query = tep_db_query("select customers_additional_customers_number from " . TABLE_CUSTOMERS ." left join " . TABLE_ORDERS . " using (customers_id) where orders_id='". (int)$HTTP_GET_VARS['order_id'] . "'");

 

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

chris23,

Another question, is it possible to show the product options not after each other, but in a row?

 

Not sure what you're after here, but have a look at this post (number 78) which separates the attributes into separate lines. Is this what you want?

 

and is it possible to show an message in account_history_info.php when there is NO invoice (no shipping status)

That the order invoice is pending along the status?

 

Yep!

 

Quick and dirty fix:

 

Edit account_history_info.php

 

Find the code block

 

<!-- start pdf //-->

 

-- code --

 

<!-- end pdf //-->

 

 

and REPLACE with

 

<!-- 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 || DISPLAY_PDF_DELIVERED_ONLY == 'false' ){
?>
<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
 }
 else{
 ?>

<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">A PDF copy of your invoice will appear here when your order is shipped.</td>
	  </tr>
	</table>
	</td>
  </tr>

<?php
}
?>

<!-- end pdf //-->

 

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

Chris your solution works great for account history info.

No status no invoice... perfect (I only changed it to multi language).

 

Another question: I'm trying to have the product attributes in a row..

And according to your forum link it works wel. but I've one problem.

see screen shot:

example2.jpg

 

The models column doesn't resize? with the rest of the columns?

 

this is the code:

 

output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {

 $prod_attribs='';

 // set cell height

 $cell_height = 5;

 // if product name length is > 45 (arial at font size 10) , we get a line break, so start $attrib_count=1
 // adjust upwards for smaller fonts sizes; trial and error!

 $attrib_count = (strlen($order->products[$i]['name']) > 45 ) ? 1 : 0;

//get attribs and concat. Use attrib count to increase cell height for row
	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	$prod_attribs .= "\n- " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	$attrib_count++;
	}
}
$attrib_count++;
$product_name_attrib_contact = $order->products[$i]['name'] . $prod_attribs;

$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');


$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);
	$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(115,$cell_height,tep_html_entity_decode($product_name_attrib_contact),1,'L');


$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
$pdf->MultiCell(25,6,tep_html_entity_decode($order->products[$i]['model']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(155);

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(22,6,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);

$pdf->SetX(177);
$pdf->MultiCell(22,6,$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$Y_Table_Position += ($cell_height*$attrib_count);

//Check for product line overflow
 $item_count++;
if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){
	$pdf->AddPage();
	//Fields Name position
	$Y_Fields_Name_position = 125;
	//Table position, under Fields Name
	$Y_Table_Position = 70;
	output_table_heading($Y_Table_Position-6);
	if ($i == 20) $item_count = 1;
}
}

 

 

Any idea's to solve this issue ?

 

regards Marco

Link to comment
Share on other sites

Hi Christian,

 

Thank you for a great contribution. I selected your contribution over many others simply because you did a great job writing the instructions. It's easy to tell when someone takes the time to get it right. Thank you.

 

I have installed it and it works great. No problems at all.

 

Suggestions:

 

Tell people how to change up the invoice. For example, I'm here in the U.S. so I had to change the page format to letter (default is A4), but it was a little confusing. I figured it out and it works great.

 

I also had to change some of the cell locations and sizes so everything would fit nicely on the page. That was a little confusing, but I figured that out too.

 

Add the comments section in the OSC order process to the invoice. I use this area for PO#s, special delivery instructions, etc...

 

Question:

 

How can I setup the invoice to save to a certain name? For example, when the customer selects "Save a copy", the pop-up window displays "stickypod_invoice" instead of "pdfinvoice".

 

I also installed your Admin patch and I can't tell you how much time that's going to save me.

 

Many thanks again for a great contrib!

Sticky Pod

Edited by stickypod

Anyone can buy a camera... it's what you do with it that counts!

Sticky Pod

www.stickypod.com

Link to comment
Share on other sites

Suggestions:

1. Tell people how to change up the invoice. For example, I'm here in the U.S. so I had to change the page format to letter (default is A4), but it was a little confusing. I figured it out and it works great.

2. Add the comments section in the OSC order process to the invoice. I use this area for PO#s, special delivery instructions, etc...

 

Hi,

 

Thanks for posting - glad you find the contrib useful.

 

Regarding your suggestions:

 

1. I see where you're coming from regarding instructions for changing the layout of the invoice but unfortunately the only way to really get your head around the FPDF library is to go through the tutorials. The FPDF class is in effect a markup language in its own right! Any write up of mine would be a (poor) duplication of the tutorials on the FPDF site. The pdfinvoice.php file could probably do with some better (more) commenting to help people with customisations. Your A4 / letter issue is an oversight on my part and I'll add this as a configuration option in the next release.

 

2. Again, another good idea and one which should probably be configured as an option to show / hide. I did consider adding other items from the orders class but the limiting factor is trying to squeeze things in somewhere without the invoice becoming cluttered.

 

Question:

How can I setup the invoice to save to a certain name? For example, when the customer selects "Save a copy", the pop-up window displays "stickypod_invoice" instead of "pdfinvoice".

 

This is interesting. If you are displaying the PDF inline (default) , then choose "Save As", the filename defaults to pdfinvoice.pdf (from the filename pdfinvoice.php). The embedded Acrobat Reader should use the filename format set in pdfinvoice.php but on most os / browser combos, this is ignored.

 

If you set force download to true, the invoice will be saved with the name:

 

yourstore_invoice_ordernumber.pdf eg stickypod_invoice_1.pdf

 

If you're getting this from the "Save as", you're doing well!!!! If you want to change this, EDIT pdfinvoice.pdf:

 

	$file_name = safe_filename(STORE_NAME);
$file_name .= "_invoice_" . $HTTP_GET_VARS['order_id'] . ".pdf";

 

Change STORE_NAME to what you want as the prefix. You can also remove the _invoice_ and the order number if you don't want it.

 

Note the safe_filename function is there to change unsafe characters and spaces in the storename to a string suitable for use in filenames. Best run your choice of words through it.

 

Hope this helps,

 

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

Hello Chris23

 

I've managed to change te column size by adding ($cell_height*$attrib_count) to the column height.

But when there are 2 products on the invoice with an models name to large for the width of the models column.

the rest of the name is inserted in the column of the second product.. (that also has en models name..)

so this doesn't really look pro... two models written is one column...

 

do you have an solution..? some kind of line count for the models column i think ..?

Link to comment
Share on other sites

Hi Chris,

 

Thanks for the feedback and the code snippet. In my studies of the catalog/pdfinvoice.php file, I found a bad reference. It's this line:

 

// Draw customer reference

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

 

The PDF_INV_CUSTOMER_REF was not defined in the languages/english/pdfinvoice.php. I changed up this line to be a reference to the credit card number instead. Of course it only shows the last digits. This is a must for taxes in the U.S. and would make a good update. Just replace the above code with (you will need to adjust the text location for your invoice):

 

// Draw customer cc number

$temp = substr ($order->info['cc_number'] , 0, 80);

$pdf->Text(20,123, tep_html_entity_decode(PRINT_CC_NUMBER) . ' ' . tep_html_entity_decode($temp));

 

With regards to the "Comments" section, this cannot be done without some serious changes. The COMMENTS section in MySQL saves only the most recent comments. So unfortunately this would not show the customers original comments or PO #.

 

Regarding the instructions, I would just give people the basic principle. For example:

 

$pdf->SetX(50); = the left edge of a box or cell

$pdf->Text(113,77,tep_html_entity_decode(ENTRY_SHIP_TO)); = the X and Y coordinates inside the cell, X will move it left and right and Y will move it up and down

Explain the 4 numbers that make up the boundaries of a box or cell and what each number will change.

 

I bring this up because when you change the default paper size from A4 to letter, the left edge of all the cells is cutoff when the invoice is printed.

 

Changing paper size requires changing just 2 words in 2 files:

catalog/pdfinvoice.php (change A4 to letter), A4 is only listed in one place, so you can't mess this up.

catalog/fpdf/fpdf.php (change A4 to letter) on this line: function FPDF($orientation='P',$unit='mm',$format='letter')

DO NOT change the unit of measurement ($unit='mm') as this is already established for US letter sizes.

 

I think this contrib is one of the best on OSC and should be included in the main OSC release files. Not only is it easy to setup, but with a little more instruction, it would be easy to customize for any store. This is going to save me a ton of time at the end of the year when many of my customers start contacting me for an invoice for tax purposes. It also makes my little operation more professional than even the largest companies like FedEx and UPS.

 

Keep up the good work!

Tom

Edited by stickypod

Anyone can buy a camera... it's what you do with it that counts!

Sticky Pod

www.stickypod.com

Link to comment
Share on other sites

Hi Chris,

 

I tried your code snippet for the file save, but it did not work. I think it's because I'm not forcing a download. I'm using the PDF inline. I would like it to come up in the save dialogue box as stickypod_invoice_#### ####=order number (your idea). If you have any other suggestions, please let me know.

 

Thank you,

Tom

Anyone can buy a camera... it's what you do with it that counts!

Sticky Pod

www.stickypod.com

Link to comment
Share on other sites

Hi Guys,

 

I tried to install the PDF Customer Invoice v1.1 contribution. After following all the steps, I went into my admin but could not see the "PDF Invoices" option.

 

I then went to my database and in the "configuration_group" table the entry "PDF Invoices" is there.

 

Please Help

 

Shingi

Link to comment
Share on other sites

I tried your code snippet for the file save, but it did not work. I think it's because I'm not forcing a download. I'm using the PDF inline. I would like it to come up in the save dialogue box as stickypod_invoice_#### ####=order number (your idea). If you have any other suggestions, please let me know.

 

Hi Tom,

 

Thanks for your replies - lots of food for thought! I'll have a look at automating the A4->Letter option. It may be possible to add a correction factor to the box coordinates to automatically format correctly between paper sizes.

 

Regarding your PDF issue, this is a pain in the a**! Having Googled the issue and trawled through Adobe's forum, it seems that the "Save As" dialogue steadfastly refuses to use the fiename provided (tried on Adobe Reader 6,7 & 8) pdfinvoice.php passes the filename to fpdf which then sets the header:

 

Content-Disposition: attachment; filename='.$name

 

What happens then is down to the browser / os / pdf-plugin (usually Adobe Reader)

 

I'd love to hear of a workaround (be proved wrong!) or from anyone who's getting the intended filename to work (pls post browser / os / pdf plugin used here). I suppose a "dirty" fix would be to change the filename of pdfinvoice.php to stickpod_invoice.php and then change all links to the file (a fair bit of work I know).

 

Sorry I can't be an more help with this but doesn't appear to be a code issue but rather an implementation issue.

 

Kind regards

 

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 tried to install the PDF Customer Invoice v1.1 contribution. After following all the steps, I went into my admin but could not see the "PDF Invoices" option.

I then went to my database and in the "configuration_group" table the entry "PDF Invoices" is there.

 

Hi Shingi,

 

If you have the "PDF Invoices" entry in the db, you should find the PDF Invoices link under 'Configuration -> PDF Invoices', the last entry on the list

 

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've managed to change te column size by adding ($cell_height*$attrib_count) to the column height.

But when there are 2 products on the invoice with an models name to large for the width of the models column.

the rest of the name is inserted in the column of the second product.. (that also has en models name..)

so this doesn't really look pro... two models written is one column...

 

do you have an solution..? some kind of line count for the models column i think ..?

 

Hi Marco,

 

Have you altered your db to allow for longer product model text? The default is 12 characters. If you've increased the length of this field, you're going to get line breaks within the model cell, forcing a new cell to be rendered. To fix this, replace your output_table_heading function with the following. It seems to work for model field length upto 48 characters at size 10, Arial.

 

Hope this is what you need:

 

output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {

 $prod_attribs='';

 // set cell height

 $cell_height = 5;

 // if product name length is > 45 (arial at font size 10) , we get a line break, so start $attrib_count=1
 // adjust upwards for smaller fonts sizes; trial and error!

 $attrib_count = (strlen($order->products[$i]['name']) > 45 ) ? 1 : 0;

//get attribs and concat. Use attrib count to increase cell height for row
	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	$prod_attribs .= "\n- " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	$attrib_count++;
	}
}
$attrib_count++;

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

$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');


$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);
$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(78,$cell_height,tep_html_entity_decode($product_name_attrib_contact),1,'L');


$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(PDF_INV_CORE_FONT,'',10);

$breaks = (strlen($order->products[$i]['model']) > 12) ? (ceil(strlen($order->products[$i]['model'])%12)) : 1;

$pdf->MultiCell(25,($cell_height*$attrib_count)/$breaks,tep_html_entity_decode($order->products[$i]['model']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(118);
$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(20,($cell_height*$attrib_count),$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(138);
$pdf->MultiCell(20,($cell_height*$attrib_count),$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(158);
$pdf->MultiCell(20,($cell_height*$attrib_count),$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(178);
$pdf->MultiCell(20,($cell_height*$attrib_count),$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']),1,'C');
$Y_Table_Position += ($cell_height*$attrib_count);

//Check for product line overflow
 $item_count++;
if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){
	$pdf->AddPage();
	//Fields Name position
	$Y_Fields_Name_position = 125;
	//Table position, under Fields Name
	$Y_Table_Position = 70;
	output_table_heading($Y_Table_Position-6);
	if ($i == 20) $item_count = 1;
}
}

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

Regarding the instructions, I would just give people the basic principle. For example:

 

$pdf->SetX(50); = the left edge of a box or cell

$pdf->Text(113,77,tep_html_entity_decode(ENTRY_SHIP_TO)); = the X and Y coordinates inside the cell, X will move it left and right and Y will move it up and down

Explain the 4 numbers that make up the boundaries of a box or cell and what each number will change.

 

I bring this up because when you change the default paper size from A4 to letter, the left edge of all the cells is cutoff when the invoice is printed.

 

Hi Tom,

 

I've been giving more thought to your suggestion and I'm leaning more towards ditching having the formatting fixed within the pdfinvoice file. I think a better solution would be to rewrite the code using a basic templating system and supplying various layouts with configurable options. Although initially more work, it would mean that people wouldn't need to be exposed to the fpdf class, which is a skill in its own right. I seem to be spending more and more time helping people with fpdf layout tweaks to accommodate numerous contributions and hopefully a template system would cut down on this.

 

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

 

I've been giving more thought to your suggestion and I'm leaning more towards ditching having the formatting fixed within the pdfinvoice file. I think a better solution would be to rewrite the code using a basic templating system and supplying various layouts with configurable options. Although initially more work, it would mean that people wouldn't need to be exposed to the fpdf class, which is a skill in its own right. I seem to be spending more and more time helping people with fpdf layout tweaks to accommodate numerous contributions and hopefully a template system would cut down on this.

 

Cheers

 

Chris

Hi Chris,

 

That sounds like a lot of work for just a few changes. How about simply supplying both a Letter(US) and A4(Europe) version of the PDF invoice. That would accomodate many, if not all, users that want to use this.

 

I will PM you a copy of my pdfinvoice file so you can see the changes I made. If you want to do some test printing, just change the A4 in fpdf.php to letter. I have the update patch that puts the invoice in Admin included in the file.

 

I think this is a short and simple solution.

 

Good luck,

Tom

Anyone can buy a camera... it's what you do with it that counts!

Sticky Pod

www.stickypod.com

Link to comment
Share on other sites

Hi chris I've try'ed your solutions

but it seems not to work correctly:

 

I've I replaced the output_table_heading with your option but its still

getting messed up multiple model colums, Two model names in one column written throught each other..?

 

When I use this output_table_heading below it seems al little normaal, and I can read the text, but its still

getting one part of the model in the right column and the rest is in the column of the second product model.

Can you see what is getting wrong with this code ?

 

 

 output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {

 $prod_attribs='';

 // set cell height

 $cell_height = 5;

 // if product name length is > 45 (arial at font size 10) , we get a line break, so start $attrib_count=1
 // adjust upwards for smaller fonts sizes; trial and error!

 $attrib_count = (strlen($order->products[$i]['name']) > 45 ) ? 1 : 0;

//get attribs and concat. Use attrib count to increase cell height for row
	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	$prod_attribs .= "\n- " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	$attrib_count++;
	}
}
$attrib_count++;
$product_name_attrib_contact = $order->products[$i]['name'] . $prod_attribs;

$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');


$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);
	$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(115,$cell_height,tep_html_entity_decode($product_name_attrib_contact),1,'L');

 $pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(PDF_INV_CORE_FONT,'',3);
$breaks = (strlen($order->products[$i]['model']) > 10) ? (ceil(strlen($order->products[$i]['model'])%3)) : 1;
$pdf->MultiCell(25,($cell_height*$attrib_count)/$breaks,tep_html_entity_decode($order->products[$i]['model']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(155);

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->MultiCell(22,($cell_height*$attrib_count),$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);

$pdf->SetX(177);
$pdf->MultiCell(22,($cell_height*$attrib_count),$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$Y_Table_Position += ($cell_height*$attrib_count);

 

regards Marco

Link to comment
Share on other sites

I've I replaced the output_table_heading with your option but its still

getting messed up multiple model colums, Two model names in one column written throught each other..?

 

Hi Marco,

Can you confirm whether you've increased the "model" field length. Also, is it possible to send me a copy of a PDF invoice so I can see what's going on - it's not too clear from the obscured image.

PM me of this is OK so I can send you my e-mail address.

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

why I am getting this error when I hit the pdf file?

1054 - Unknown column 'comments' in 'field list'

 

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 from orders where orders_id = '1'

 

[TEP STOP]

 

and I am from the US so is there something I got to do in my database?

Link to comment
Share on other sites

why I am getting this error when I hit the pdf file?

1054 - Unknown column 'comments' in 'field list'

 

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 from orders where orders_id = '1'

 

[TEP STOP]

 

and I am from the US so is there something I got to do in my database?

 

Hi Tim,

 

I don't think this is an error with the contrib. All the pdfinvoice.php file does is use the built in orders object to get the invoice data, (the same way account_history_info.php gives the customer the full order details in theire account history)

 

Your SQL statement is looking for the "comments" filed in the orders table and there isn't one there (and neither should it be - it should be in orders_status_history.)

 

The most likely explanation is a change made when you added fedex, dhl or ups changes to includes/classes/order.php

 

For comparison, the original SQL from includes/classes/order.php (note no 'comments'):

 

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, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"

 

If you have a test account on your installation, have a look at an order history details page - you should be getting the same error.

 

Hope this helps

 

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