Jump to content
chris23

[CONTRIBUTION] PDF Customer Invoice

Recommended Posts

When, working in a vector graphics program (Illustrator, Corel Draw, etc..) you can save, or save as, but that file will be in the latest version according to the program version (e.g. Illustator CS2). But if you want to save your file in an older version, you must use File > Export > EPS (then choose Version #)

 

Here you can save the file in an older format (e.g. Illustrator 8). I would recommend using EPS versions 8 or older. I have many EPS files, old and new, and in my testing only the older files worked.

Share this post


Link to post
Share on other sites

Hi Chris,

 

What I'm trying to achieve with the invoice is similar to the invoice produced by the batch print center. I've attached a screen shot. I don't think the batch print center uses fpdf though.

 

any ideas whether the attched would be possible with fpdf?

 

invoice_batch.jpg

 

Thanks

 

Dave

Edited by stubbsy

Share this post


Link to post
Share on other sites
any ideas whether the attched would be possible with fpdf?

 

My my Mr Stubbs, what big attributes you have :P

 

Here's some code replacement for pdfinvoice.pdf that'll do what you want:

 

FIND:

 

output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(9,6,$order->products[$i]['qty'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);

$prod_attribs='';

//get attribs and concat
	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 .= " - " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	}
}	

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

if (strlen($product_name_attrib_contact) > 40 && strlen($product_name_attrib_contact) < 50){
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode($product_name_attrib_contact),1,'L');
	}

else if (strlen($product_name_attrib_contact) > 50){
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode(substr($product_name_attrib_contact,0,60)) ." .. ",1,'L');
	}


else{
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode($product_name_attrib_contact),1,'L');
	$pdf->Ln();
	}	

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(PDF_INV_CORE_FONT,'',8);
$pdf->MultiCell(25,6,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,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(138);
$pdf->MultiCell(20,6,$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,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);
$pdf->SetX(178);
$pdf->MultiCell(20,6,$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 += 6;

//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;
}
}

 

and replace with:

 

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,'',8);
$pdf->MultiCell(25,($cell_height*$attrib_count),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;
}
}

 

There are a few comments in the replacement code should you want to change font / font size.

 

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

Hi Chris!

 

I know this has come up before, and I thought I would add my two cents.

 

I really would like to be able to have the customer PDF invoice and my admin invoice look the exact same. I was playing around with it, but it's too complicated for me to do at this point.

 

Have you put any more thought into offering the same formatted PDF on the admin side?

 

Best Regards,

Chris

Share this post


Link to post
Share on other sites

Chris,

 

you're a star! Thanks for your excellent help (as usual)

 

Cheers

 

Dave

 

My my Mr Stubbs, what big attributes you have :P

 

Here's some code replacement for pdfinvoice.pdf that'll do what you want:

 

FIND:

 

output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(9,6,$order->products[$i]['qty'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);

$prod_attribs='';

//get attribs and concat
	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 .= " - " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	}
}	

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

if (strlen($product_name_attrib_contact) > 40 && strlen($product_name_attrib_contact) < 50){
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode($product_name_attrib_contact),1,'L');
	}

else if (strlen($product_name_attrib_contact) > 50){
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode(substr($product_name_attrib_contact,0,60)) ." .. ",1,'L');
	}


else{
	$pdf->SetFont(PDF_INV_CORE_FONT,'',6);
	$pdf->MultiCell(78,6,tep_html_entity_decode($product_name_attrib_contact),1,'L');
	$pdf->Ln();
	}	

$pdf->SetFont(PDF_INV_CORE_FONT,'',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont(PDF_INV_CORE_FONT,'',8);
$pdf->MultiCell(25,6,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,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(138);
$pdf->MultiCell(20,6,$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,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);
$pdf->SetX(178);
$pdf->MultiCell(20,6,$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 += 6;

//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;
}
}

 

and replace with:

 

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,'',8);
$pdf->MultiCell(25,($cell_height*$attrib_count),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;
}
}

 

There are a few comments in the replacement code should you want to change font / font size.

 

Cheers

 

Chris

Share this post


Link to post
Share on other sites
Have you put any more thought into offering the same formatted PDF on the admin side?

 

Hi Chris,

 

Yes I have and I'm almost ready to upload an admin "howto" / contrib to the contribution area - just need to type up the instructions when I get 5!

 

I've decided to keep the client side and admin side contribs separate so people can add on the admin facility should they wish to use this version of the PDF code, rather than the original admin based PDF Invoice contribution (incidentally the existing admin version will still run happily along side this one so you can use either).

 

I've got the security in place to my satisfaction so that it will only be possible to view all invoices when pdfinvoice.php is called from within the protected admin area.

 

I'll PM you when I've uploaded.

 

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

Share this post


Link to post
Share on other sites
How can i make this. ??? It the text "GAVEKORT" there are wrong.

 

Hi Michael,

 

Is GAVEKORT Danish for Gift Voucher?

 

I don't think that this line is out of place - it looks like the following line is too high. I can't make this line out; is it Discount?

 

The code:

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;
}

 

in pdfinvoice should take each line of the order total and separate it vertically by 5 units - I can't see why these two lines shouldn't be spaced by 5 units like the others.

 

Any other users of CCGV having issues?

 

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

Yes is danish Gift Voucher The link to the modul is on the picture. I don't now what happen there.

 

You contri is nice, and i will make some chance so the picture will be 100%, i think is the paymet metod there are som probs whit.

 

Sorry my bad english.

 

Hi Michael,

 

Is GAVEKORT Danish for Gift Voucher?

 

I don't think that this line is out of place - it looks like the following line is too high. I can't make this line out; is it Discount?

 

The code:

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;
}

 

in pdfinvoice should take each line of the order total and separate it vertically by 5 units - I can't see why these two lines shouldn't be spaced by 5 units like the others.

 

Any other users of CCGV having issues?

 

Cheers

 

Chris

Share this post


Link to post
Share on other sites
You contri is nice, and i will make some chance so the picture will be 100%, i think is the paymet metod there are som probs whit.

 

Michael,

 

I think I've got the answer to your problem. Your shipping line text is very long and is forcing a line break

 

You need to increase the size of the cell containing the "totals" data

 

Edit pdfinvoice.php and FIND:

 

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;
}

 

Reduce SetX(102) to say SetX(80) and increase the 94 in $pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

 

by the same amount ie 94 + 22 = 116, so you now have

 

$pdf->MultiCell(116,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

 

 

This gives you a wider cell for the text, without an auto line break. If this is still happening reduce SetX more and increase MultiCell(x) by the same amount until your box is big enough

 

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

Share this post


Link to post
Share on other sites

Hey Chris

 

Thanks Alot, it work great :)

 

Michael,

 

I think I've got the answer to your problem. Your shipping line text is very long and is forcing a line break

 

You need to increase the size of the cell containing the "totals" data

 

Edit pdfinvoice.php and FIND:

 

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;
}

 

Reduce SetX(102) to say SetX(80) and increase the 94 in $pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

 

by the same amount ie 94 + 22 = 116, so you now have

 

$pdf->MultiCell(116,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

This gives you a wider cell for the text, without an auto line break. If this is still happening reduce SetX more and increase MultiCell(x) by the same amount until your box is big enough

 

Hope this helps,

 

Chris

Share this post


Link to post
Share on other sites

Hi

 

Just installed 1.1 and all i get is

 

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

 

i have not change any thing in the new files.

 

any one know what could be wrong.

Share this post


Link to post
Share on other sites
FPDF error: Some data has already been output, can't send PDF file

 

Hi,

 

Have a quick look at post #60

 

Please check you have absolutely no whitespace after your closing ?> tags and try again

 

HTH

 

Chris

Edited by chris23

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

Google Site Search is your friend

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

Share this post


Link to post
Share on other sites

I have installed customer invoice 1.1 plus add-on, only one problem encountered: a small jpg file (a logo for 2gether discount) cannot be displayed, instead it is displayed html as follows:

 

<img src="images/save-icon_sm.gif" alt="2gether" title="2gether"> Your

2<i>gether</i> Discount:<i> <br>10 x (xxxxx) </i> <font color=red>

 

any idea what I can do, thanks!

Share this post


Link to post
Share on other sites
I have installed customer invoice 1.1 plus add-on, only one problem encountered: a small jpg file (a logo for 2gether discount) cannot be displayed, instead it is displayed html as follows:

 

<img src="images/save-icon_sm.gif" alt="2gether" title="2gether"> Your

2<i>gether</i> Discount:<i> <br>10 x (xxxxx) </i> <font color=red>

 

any idea what I can do, thanks!

 

Hi,

 

It looks like your 2gether contribution is adding to the order totals array but is including html. The pdfinvoice.php only accounts for <b> tags.

 

A quick fix would be to strip out all html from $order->totals. You will lose your image however.

 

Edit pdfinvoice.php

 

FIND:

 

$pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

 

REPLACE with:

 

$pdf->MultiCell(94,6,strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']),0,'R');

 

Note: I've not tested this as I don't have the 2gether contrib installed (just had a quick look through the code).

 

Let me know if this strips out the html and leaves you the text.

 

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,

 

It looks like your 2gether contribution is adding to the order totals array but is including html. The pdfinvoice.php only accounts for <b> tags.

 

A quick fix would be to strip out all html from $order->totals. You will lose your image however.

 

Edit pdfinvoice.php

 

FIND:

 

$pdf->MultiCell(94,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');

 

REPLACE with:

 

$pdf->MultiCell(94,6,strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']),0,'R');

 

Note: I've not tested this as I don't have the 2gether contrib installed (just had a quick look through the code).

 

Let me know if this strips out the html and leaves you the text.

 

HTH

 

Chris

 

Hi, Chris, thanks for your help, it works as what you expected.

Share this post


Link to post
Share on other sites

Just came by to say a big THANKS!

 

I installed this module and it is working flawlessly for me. The option to see invoices from the admin side is also great.

 

I also use batch print center, so I will have left adapting both templates to look like the same. I might even try to just make PDF Customer Invoice use the same template I have on Batch Print Center, even that might mean using ezpdf class (batch print center) instead of fpdf (PDF Customer Invoice). Might be worth the time if I later renew/change my templates, so I only have to do it on one place.

 

Thx chris23! :D


MindTwist of Twisted Reality and Twisted Tienda

Share this post


Link to post
Share on other sites

Hello,

 

First of al i like te contribution (excellent job)..

 

But i was wondering 3 thinks i could not find out.

 

1. the watermark is not showing up (al the rest is OK)..

have no idea why, its enabled in admin, color is set.. but no watermark..

 

 

2. what if the show invoice on order status has multiple status options for shipping.

like status 3 for paypal shiiping OK, and status 7 for Moneyorder OK,

how can i then show the invoice on completion of the order?

 

<?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' ){
?>

 

something in this code right?

 

 

3. I'm using login with customer numbers ( http://www.oscommerce.com/community/contributions,2242 )

And i would like to see the customer number on de invoice?

 

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

to the corresponding table of the customer number in pdfinvoice.php didn't work.

 

any idea's for this?

 

for the rest i like this contribution...Thanks allot..Marcot

Share this post


Link to post
Share on other sites
2. what if the show invoice on order status has multiple status options for shipping.

like status 3 for paypal shiiping OK, and status 7 for Moneyorder OK,

how can i then show the invoice on completion of the order?

 

<?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' ){
?>

 

something in this code right?

 

Feel free to change the delivered_status to what feels you best, or to several different options (I have disabled it, and I even included a link to the PDF invoice on the email customers receive when they place an order).

 

	if ($delivered_status['orders_status_id'] == 3 || $delivered_status['orders_status_id'] == 7 || $delivered_status['orders_status_id'] == WHATEVER || DISPLAY_PDF_DELIVERED_ONLY == 'false' ){


MindTwist of Twisted Reality and Twisted Tienda

Share this post


Link to post
Share on other sites
1. the watermark is not showing up (al the rest is OK)..

have no idea why, its enabled in admin, color is set.. but no watermark..

 

Very odd. Have you entered some text for the watermark as well as enabling it? Also check that you haven't set the colour to white (#ffffff) - obvious I know but possible!

I can't see what else this could be if the rest of the pdf is generating OK

 

2. what if the show invoice on order status has multiple status options for shipping.

like status 3 for paypal shiiping OK, and status 7 for Moneyorder OK,

how can i then show the invoice on completion of the order?

 

See Aitor's post above for a fix. This contrib only accounts for the standard shipping methods on a vanilla osC install so you'll need to use Aitor's fix for other contribs that add to the normal 3.

 

3. I'm using login with customer numbers ( http://www.oscommerce.com/community/contributions,2242 )

And i would like to see the customer number on de invoice?

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

to the corresponding table of the customer number in pdfinvoice.php didn't work.

 

I suspect this contib adds another property to the orders object but unfortunately I can't download this the contribution currently as the osC downloads area is timing out.

I'll have a look when I get the code and let you know if this can be fixed.

 

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

Share this post


Link to post
Share on other sites

Thanks alot,

 

I will try the status solutions first thing tomorrow morning.

ill keep you informed.

 

The watermark has en text lets say "invoice" en the color is #f3f3f3 and is enabled...

But is not showing up.. very odd ?!

 

 

Again, thanks .. Ill try it out...

Share this post


Link to post
Share on other sites

status fix works like a charm...

great thank alot...

 

I'm still figuring out why the watermark doesn't show up ?

I've double checked the code but can not find an solution

Ive also checked throught phpmyadmin for database problems, but it enabled, color is set en text is set...(strange huh..)

 

function Watermark()
{
global $watermark_color;
$this->SetFont(PDF_INV_CORE_FONT,'B',60);
$this->SetTextColor($watermark_color[0], $watermark_color[1], $watermark_color[2]);
$ang=30;																			 
$cos=cos(deg2rad($ang));
$wwm=($this->GetStringWidth(tep_html_entity_decode(PDF_INV_WATERMARK_TEXT))*$cos);
$this->RotatedText(($this->w-$wwm)/2,$this->w,PDF_INV_WATERMARK_TEXT,$ang);
}

 

Also i noticed that when a force to not show the invoice on screen but want users to download it.

it doesnt download, with an error the file could not be found on the server. is the file saved in an directory which I should CHMOD ??

 

 

*******************************

Maybe you also have an solution for this?

I know it is not about your contribution but and totally offtopic, Butt i'm terrible stuck in the script...

in the customer number login script (see post above)

I also have made an modification for the new customers in create_account.php

 

below:

tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);
	 $customer_id = tep_db_insert_id();

add:

$customer_id_sprint=sprintf("%05d",$customer_id );
$customers_additional_customers_number = mt_rand(1,9) . $customer_id_sprint;   

tep_db_query("update " . TABLE_CUSTOMERS. " set `customers_additional_customers_number` = $customers_additional_customers_number where `customers_id` = " . $customer_id);

 

This code gives every new customer on the website an random number based on the customer id,

like customer id 345 > shows customer number 200345

or like customer 678 > shows customer number 700678

 

but now i have the problem that al the customers that where in the database,

before the time of integrating this script, do not have an number.

is there an way to give al the customers also an random number without doing this manual (>500 customers).

with any kind of script ?

********************************

 

Thanks, greetz Marcot

Share this post


Link to post
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

 

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

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

×