Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] PDF Customer Invoice


chris23

Recommended Posts

I change it and now I have this :

 

Parse error: parse error in c:\program files\easyphp1-8\www\catalog\includes\classes\order.php on line 64

 

 

God I'm having a bad day!

 

'orders_date_facture' => $order['orders_date_facture']),

 

needs to be

 

'orders_date_facture' => $order['orders_date_facture'],

 

no ) should be there!!!!!!!

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

God I'm having a bad day!

 

'orders_date_facture' => $order['orders_date_facture']),

 

needs to be

 

'orders_date_facture' => $order['orders_date_facture'],

 

no ) should be there!!!!!!!

 

Nice job chris :thumbsup: :)

 

Three other things and all will be ok :lol: :

 

- How to cut the hour in invoice date?

 

- I don't want to see "2007-07-30" but "30.07.2007". How to do that?

 

- You can see that we can see only the first letter of the customer country "F". How to see all the name of the country?

 

 

Merci beaucoup chris :rolleyes:

Link to comment
Share on other sites

This seems like a very nice contribution. I've installed it and tested it out and I have a few questions:

 

Which file or files do I edit to alter the font, font size, color, image name or other details of the Invoice?

 

Also, how do I change the address format for the billing address and shipping address that are listed on the Invoice and Packing Slip?

 

Thanks!

Link to comment
Share on other sites

This seems like a very nice contribution. I've installed it and tested it out and I have a few questions:

 

Which file or files do I edit to alter the font, font size, color, image name or other details of the Invoice?

 

Also, how do I change the address format for the billing address and shipping address that are listed on the Invoice and Packing Slip?

 

Thanks!

 

Well, I figured out one of the problems and how to fix it:

 

$pdf->MultiCell(70, 3.3, tep_address_format(2, $order->customer, '', '', "\n"),0,'L');

 

The 'address_format' here needs to be set to 2 instead of 1.

 

The different format styles are stored in the ADDRESS_FORMATS table in the database. For shipping in the US, format 2 is the ideal format for invoice and packing slip addresses.

Edited by waverider75
Link to comment
Share on other sites

$pdf->MultiCell(70, 3.3, tep_address_format(2, $order->customer, '', '', "\n"),0,'L');

 

The 'address_format' here needs to be set to 2 instead of 1.

 

The different format styles are stored in the ADDRESS_FORMATS table in the database. For shipping in the US, format 2 is the ideal format for invoice and packing slip addresses.

 

Hi Chris,

 

You're right here. The original PDF Invoice code on which this contrib is based has a few things "hardcoded" rather than using osC's built in properties.

 

I'd already picked this one up and is in the next version which I will upload soon (has some other features too)

 

If you want the address format to be automatically linked to your store location

 

Change (for both the invoice and delivery entries)

 

$pdf->MultiCell(70, 3.3, tep_address_format(2, $order->customer, '', '', "\n"),0,'L');

 

to

 

$pdf->MultiCell(70, 3.3, tep_address_format($order->customer['format_id'], $order->customer, '', '', "\n"),0,'L');

 

To answer your earlier post, all the options you want to change are found in admin - configuration - PDF Invoices. This is the biggest change from the orig contribution; you don't have to hack any files to configure! :thumbsup:

 

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

- How to cut the hour in invoice date?

- I don't want to see "2007-07-30" but "30.07.2007". How to do that?

 

Jean,

 

Looks like you changed from $date to $order->info['orders_date_facture'] as I suggested.

 

This returns a MySQL datetime.

 

To convert to something readable, use either osC's tep_date_long() or tep_date_short() function:

 

eg

 

$this->MultiCell(100,6, PRINT_INVOICE_TITLE . $order->info['orders_numero_facture'] . "\n" . tep_date_long($order->info['orders_date_facture']) ,0,'L');

 

NOTE: the site wide format of tep_date_long is taken from

 

catalog/includes/languages/yourlanguage/yourlanguage.php

 

define('DATE_FORMAT_SHORT', '%d/%m/%Y');  // this is used for strftime()
define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()

 

So if tep_date_long() is not displaying as you want, you need to change these values.

 

You can see that we can see only the first letter of the customer country "F". How to see all the name of the country?

 

Not guilty! This is an osC issue - there's a fix for it already in readme.txt under "Q & As"

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 a lot chris ;)

 

I have other question :

 

How to change footer : "Thank you for your purchase"

 

How to cut owner name?

 

In payment method, accent appears like this : è . Whats to do?

 

In admin/configuration, I only can change the logo but not text color... why?

 

:thumbsup:

Link to comment
Share on other sites

How to change footer : "Thank you for your purchase"

How to cut owner name?

In admin/configuration, I only can change the logo but not text color... why?

 

Jean,

 

How many options do you have in under admin -> configuration -> PDF Invoices?

 

If it's only "Choose logo", you have a buggy MySQL version - see the end of installation.txt for the fix

 

In payment method, accent appears like this : è . Whats to do?

 

Wrap the output containing accented characters in html_entity_decode(), e.g line 223:

 

Repeat this for any $order->info which is likely to contain accented characters - you French and your accents .. ;) !

 

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

$temp = html_entity_decode(substr ($order->info['payment_method'] , 0, 23));

 

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

Jean,

 

How many options do you have in under admin -> configuration -> PDF Invoices?

 

If it's only "Choose logo", you have a buggy MySQL version - see the end of installation.txt for the fix

 

In payment method, accent appears like this : è . Whats to do?

 

Wrap the output containing accented characters in html_entity_decode(), e.g line 223:

 

Repeat this for any $order->info which is likely to contain accented characters - you French and your accents .. ;) !

 

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

$temp = html_entity_decode(substr ($order->info['payment_method'] , 0, 23));

 

Regards,

 

Chris

 

It's ok :thumbsup: ;)

 

-Now I want to modifiy text "Qty" to "Qté"

 

qty.jpg

 

How to do that?

 

-I want also to cut owner name because text is in double :

 

double.jpg

 

 

-How to cut the 3 columns "Price (ex)", "Price (inc)" and "Total (ex)" and save only column "Total (ttc)"?

 

ttc.jpg

 

-How to add a TD to add text like this :

 

tva.jpg

 

 

Thank you very much and sorry for this boring quesions :blush:

Link to comment
Share on other sites

-Now I want to modifiy text "Qty" to "Qté"

 

Line 317 of pdfinvoice.php. Change Qty. I'm going to change this to be included in the language file.

 

-I want also to cut owner name because text is in double :

 

edit pdfinvoice.php and comment out:

 

// Company name
$this->SetX(0);
$this->SetY(12);
$this->SetFont(PDF_INV_CORE_FONT,'B',12);
$this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]);
$this->Ln(0);
$this->Cell(149);
$this->MultiCell(50, 3.5, STORE_NAME,0,'L');

 

 

-How to cut the 3 columns "Price (ex)", "Price (inc)" and "Total (ex)" and save only column "Total (ttc)"?

 

You're going to have to comment out big blocks of code from pdfinvoice.php

 

To get rid of the headers, comment out:

$pdf->SetX(118);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(138);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_INCLUDING_TAX,1,0,'C',1);
$pdf->SetX(158);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(178);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_INCLUDING_TAX,1,0,'C',1);

 

Then set the value of SetX in the next line to 118

 

and for the data:

 

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

 

Then set the value of SetX in the next line to 118

NOT TESTED SO BACKUP YOUR pdfinvoice.php FIRST!

 

- How to add a TD to add text like this :

 

Can you not put this tax information in the tax information box in config? Much easier than adding another table row!

 

BTW. If you want the rest of your invoice in French, you can write your own catalog/includes/languages/francais/pdfinvoice.php, translating the contents of the English one. You could even upload it as a contribution :-"

 

Cheers

 

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

Link to comment
Share on other sites

Hi Endre,

 

This is the the bit that's got me stumped - the code in pdfinvoice.php creates a standard order object using the order number passed to it.

 

The same code is used in account_history_info.php (from where it was taken!)

 

If account_history_info.php is accessing the data, so should pdfinvoice.php

 

Do you know if you (or a contrib) have made any amendments to catalog/includes/classes/order.php?

 

Chris

 

Hi Chris

I have at least two other contributions added to catalog/includes/classes/order.php.

One is a CC mod for UK debit cards, and have also the gift wrap module installed.

 

I also have a SSL certificate on my website, could that cause the problem?

 

Cheers

Endre

Link to comment
Share on other sites

I have at least two other contributions added to catalog/includes/classes/order.php.

 

Endre,

 

Provided there's nothing confidential security-wise in your catalog/classes/order.php PM me for my email address so you can send this file over for me to compare to a vanilla order.php. I feel it must be something in here ...

 

I also have a SSL certificate on my website, could that cause the problem?

 

Not likely - the script will automatically switch ssl - non-ssl and my test server has an SSL cert and the pdf script works fine.

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

BTW. If you want the rest of your invoice in French, you can write your own catalog/includes/languages/francais/pdfinvoice.php, translating the contents of the English one. You could even upload it as a contribution :-"

 

Cheers

 

Chris

 

Ok I will add a contribution but I don't see where to change "Invoice" which is in the line.

 

 

Can you not put this tax information in the tax information box in config? Much easier than adding another table row!

 

I can but I prefer below the TOTAL. Is it really difficult?

Link to comment
Share on other sites

Ok I will add a contribution but I don't see where to change "Invoice" which is in the line.

in catalog/includes/languages/english/pdfinvoice.php

define('PRINT_INVOICE_HEADING', 'Invoice');

 

It would be great if you could do a French translation, even if you just want to PM it to me for me to add to the next full upload.

 

I can but I prefer below the TOTAL. Is it really difficult?

 

OK, from pdfinvoice remove:

 

// VAT / Tax number (if enabled)
if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$this->SetX(0);
$this->SetY(53);
$this->SetFont(PDF_INV_CORE_FONT,'B',10);
$this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]);
$this->Ln(0);
$this->Cell(88);
$this->MultiCell(100, 6, PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
  }

 

 

BEFORE:

 

// set PDF metadata

 

ADD

 

if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$pdf->SetX(102);
$pdf->SetY($Y_Table_Position + 5);
  $pdf->SetFont(PDF_INV_CORE_FONT,'B',10);
$pdf->MultiCell(94,6,PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
}

 

Then in admin, type yout TVA text in the vat text box, leaving the number blank

 

That should do

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

in catalog/includes/languages/english/pdfinvoice.php

define('PRINT_INVOICE_HEADING', 'Invoice');

 

I try to do that in catalog/includes/languages/french/pdfinvoice.php

 

code4.jpg

 

And the result doesn't change :

 

line.jpg

Link to comment
Share on other sites

OK, from pdfinvoice remove:

 

// VAT / Tax number (if enabled)
if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$this->SetX(0);
$this->SetY(53);
$this->SetFont(PDF_INV_CORE_FONT,'B',10);
$this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]);
$this->Ln(0);
$this->Cell(88);
$this->MultiCell(100, 6, PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
  }

BEFORE:

 

// set PDF metadata

 

ADD

 

if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$pdf->SetX(102);
$pdf->SetY($Y_Table_Position + 5);
  $pdf->SetFont(PDF_INV_CORE_FONT,'B',10);
$pdf->MultiCell(94,6,PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
}

 

Then in admin, type yout TVA text in the vat text box, leaving the number blank

 

That should do

 

RESULT :

 

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in c:\program files\easyphp1-8\www\catalog\pdfinvoice.php on line 208

Link to comment
Share on other sites

I try to do that in catalog/includes/languages/french/pdfinvoice.php

 

code4.jpg

 

And the result doesn't change :

 

Jean,

 

I've just found another hardcoded "Invoice" in pdfinvoice.pdf:

 

Look for:

 

$pdf->Text(22,61.5,'Invoice');

 

and replace with

 

$pdf->Text(22,61.5,PRINT_INVOICE_HEADING);

 

I think that's all the hardcoded text from the original contibution removed now .....

 

Merci pour les traductions :thumbsup:

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

Looks like you haven't commented out the final } in this block:

 

// VAT / Tax number (if enabled)
if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$this->SetX(0);
$this->SetY(53);
$this->SetFont(PDF_INV_CORE_FONT,'B',10);
$this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]);
$this->Ln(0);
$this->Cell(88);
$this->MultiCell(100, 6, PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
  }

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

Looks like you haven't commented out the final } in this block:

 

// VAT / Tax number (if enabled)
if (DISPLAY_PDF_TAX_NUMBER == 'true'){
$this->SetX(0);
$this->SetY(53);
$this->SetFont(PDF_INV_CORE_FONT,'B',10);
$this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]);
$this->Ln(0);
$this->Cell(88);
$this->MultiCell(100, 6, PDF_TAX_NAME . " " . PDF_TAX_NUMBER,0,'R');
  }

 

Bad position :

 

tvasup.jpg

Link to comment
Share on other sites

Bad position :

 

Flip:

$pdf->SetX(102);
$pdf->SetY($Y_Table_Position + 5);

 

 

to

 

 

$pdf->SetY($Y_Table_Position + 5);
$pdf->SetX(102);

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

Flip:

$pdf->SetX(102);
$pdf->SetY($Y_Table_Position + 5);

to

$pdf->SetY($Y_Table_Position + 5);
$pdf->SetX(102);

 

Ok nice :thumbsup: Thank you very much chris

 

And do you think it's possible to send this pdf on my email when status=shipped? :huh:

Link to comment
Share on other sites

And do you think it's possible to send this pdf on my email when status=shipped? :huh:

 

That's a big project for another day! The osCommerce mail function doesn't support the sending of attachments natively.

 

You'd need to install a contribution based on phpmailer (if there is one), that supports the handling of attachments.

 

Then the pdfinvoice.php would need to be modified to save the invoice in a temporary location so it could be attached.

 

Then admin/orders.php would need extra coding to call the pdfinvoice and then make use of the modified mail function to attach and send.

 

Hope I haven't put you off :'(

 

 

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

Link to comment
Share on other sites

That's a big project for another day! The osCommerce mail function doesn't support the sending of attachments natively.

 

You'd need to install a contribution based on phpmailer (if there is one), that supports the handling of attachments.

 

Then the pdfinvoice.php would need to be modified to save the invoice in a temporary location so it could be attached.

 

Then admin/orders.php would need extra coding to call the pdfinvoice and then make use of the modified mail function to attach and send.

 

Hope I haven't put you off :'(

Chris

 

Ok.

 

So in your opinion, what is the solution to get the invoice because I need to save them on my computer.

 

Thanks :)

Link to comment
Share on other sites

Ok.

 

So in your opinion, what is the solution to get the invoice because I need to save them on my computer.

 

Thanks :)

 

Is it possible to see the pdf invoice from my admin? (For information I can't use the contrib PDF invoice)

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