Modules:checkout - PDF invoice

Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Wed, 2008-12-17 17:01

Thank you alecmyers.

Quote:
Well, since this is Gallery, and it's written in php, it's "just" a simple matter of programming it to do what you want. But there's no trivial modification to the code that will do this, no.

I understand, yes, I guess there must be storaged some data in the data base and transfered to...etc...not that easy as I thought....

Quote:
I also think it's a mistake to trust Gallery with regulatory and compliance-type issues. What are you going to do when your host accidentally wipes your database two days before your filing is due? Gallery's great for taking orders, but it doesn't have the backup facilities, access control, journaling, logging, auditing or reliability for 'official' purposes, so my solution would be to print out each invoice and number them by hand - then keep the copies in a file. I definitely wouldn't trust Gallery to keep official records.

Yes, I see. So, numbering by hand is okay then: I would send the pdf invoices by e-mail (first generally without printing) manually to the customer after generating them by pressing the Donwload PDF Invoice button (and one copy - you are right - storage in a directory on hard disk). The only information before storing and sending to be inserted (which is missing on an "official" invoice) would be then the invoice number (may be then also a signature) which I could add manually. So, to not to have to do this by an pdf editor, could I add the number before generating the pdf or is there another good work flow?

Quote:
It's complicated. You'll have to work through the code and understand how the locations are set, when you've done that it will be obvious. Also study the fpdf docs (google for 'fpdf') for the API for that library.
Quote:

How can I limit the width of the thumbs displayed in the invoice (like it is done in the e-mail)

You'll need to write code to work out the dimensions of the image that you want to print based on its aspect ratio and the space you have allocated for it. Also the position on the page of the top-left corner. You pass the position and size information to $pdf->Image(...) - again, looking at the fpdf docs will make this clear.

Ah well, so it is not done that easily unfortunately (for me), the way it could be done with css (as I assumed) as I have also seen now on the German fpdf.de. So I wll leave it like it is, it should work also.

To get the space on the footer needed for some information placed in the pdf file, I have just changed $itemsPerPage = 7; to $itemsPerPage = 6;. That is ok now.

Quote:
Quote:

how can I text display one time, e.g. on the first page only and not on each of the pages?

Just write the text only on the first page. I don't see the difficulty.

Is there perhaps a possibility to easily add text with its needed space displayed once on the first page only, between the customer's address and the first image?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-12-17 17:43
Quote:
I guess there must be storaged some data in the data base and transfered to...etc..

Well, yes, but you'd have to arrange the storage, program the number, program to recover the number, etc. Then what happens if there's a mistake and you need to change the number? Anything's possible but you'd have to do all the programming to make it happen.

Quote:
is there another good work flow?

It sounds very awkward to me any way around, if the customer's copy needs to have this number on it. But there's no rule that says what we *want* to be easy is actually going to be easy - this module isn't designed to have the feature that you want, so ... there's nothing I can say. You'll just have to manage as best as you can!

Quote:
the way it could be done with css (as I assumed)

Alas, no, there's nothing like a stylesheet - remember this is a pdf that we're creating, by moving a virtual cursor around the page and writing text and placing images, just like we used to do in the old days with on-screen bitmap graphic displays, in the dark days before html, websites and browsers were invented. I've made things like the column widths, the number of items per page, all variables that you can adjust but that's about as far as I went. Another option would be to rewrite the module, I wonder if it would be possible to use a smarty template for the pdf file - but that's something for the distant future, if the module ever gets rewritten.

Quote:
To get the space on the footer needed for some information placed in the pdf file, I have just changed $itemsPerPage = 7; to $itemsPerPage = 6;. That is ok now

That's good

Quote:
Is there perhaps a possibility to easily add text with its needed space displayed once on the first page only

If you look at the way the delivery address is displayed, it's only printed on the first page - see where it says

if ($pdf->PageNo() == 1) {
.
.
.
}

So you can use the same idea to put text only on the first page header.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Wed, 2008-12-17 22:48
Quote:
Quote:

I guess there must be storaged some data in the data base and transfered to...etc..

Well, yes, but you'd have to arrange the storage, program the number, program to recover the number, etc. Then what happens if there's a mistake and you need to change the number? Anything's possible but you'd have to do all the programming to make it happen.

I see, not easily done and absolutely out of my abilities...

Quote:
Quote:

is there another good work flow?

It sounds very awkward to me any way around, if the customer's copy needs to have this number on it. But there's no rule that says what we *want* to be easy is actually going to be easy - this module isn't designed to have the feature that you want, so ... there's nothing I can say. You'll just have to manage as best as you can!

Ok, so the best way I can see at the moment, is to just add a number to the PDFout.inc and increment it manually. By the way, how do you handle the purchase, how is your work flow (if I may ask this, very interesting to learn how others do it)?

Quote:
the way it could be done with css (as I assumed)

Alas, no, there's nothing like a stylesheet - remember this is a pdf that we're creating, by moving a virtual cursor around the page and writing text and placing images, just like we used to do in the old days with on-screen bitmap graphic displays, in the dark days before html, websites and browsers were invented. I've made things like the column widths, the number of items per page, all variables that you can adjust but that's about as far as I went. Another option would be to rewrite the module, I wonder if it would be possible to use a smarty template for the pdf file - but that's something for the distant future, if the module ever gets rewritten.

May be in Gallery3...4...(I am curios about it)...at the moment there seems to be all in the file, the pdf I would need, I think, a bit awkward, but it works as it seems...and the e-mail checkout works fine, also...

Quote:
If you look at the way the delivery address is displayed, it's only printed on the first page - see where it says

if ($pdf->PageNo() == 1) {
.
.
.
}

So you can use the same idea to put text only on the first page header.

Yes, I had tried it in a similar way and the same one, but the problem always was, that the space didn't become bigger, so there was some overlapping. But the way I have it now, the space should be enough.

Many thanks for your very fast support, always.

 
magicrob

Joined: 2009-01-07
Posts: 6
Posted: Wed, 2009-01-07 09:24

Is there somewhere that explains how to customise the PDF being produced? Specifically what these do:

$lineHeight = 3.5;
$leftLine = 10;
$rightLine = 200;
$leftMargin = 10;
$rightMargin = 10;
$firstItemY = 105;
$itemYinc = 25;
$thumbWidth = 30;
$thumbHeight = 23;
$itemsPerPage = 7;
$col1X = 15;
$col2X = 50;
$col2Width = 35;
$col3X = 90;
$col3Width = 35;
$col4X = 130;
$col4Width = 100;
$col5XRight = 160;
$col5Width = 100;
$col6XRight = 190;
$col6Width = 100;
$commentY = 267;

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-01-07 09:33

HI magicrob

There's nowhere specifically that explains how to customise the PDF. As mentioned earlier in this thread, the original checkoutpdfinvoice module was a quick lash-up of some private code for my own use, which I was later happy to share on an as-is basis.

Most of the variables you list are (should be) self-explanatory: X and Y obviously the X and Y offsets or coords. of various things, measured in mm, sometimes from the left or top of the page (if I remember right).

I can't believe you need to ask what something like $itemsPerPage could possibly be, or $thumbHeight !

If in doubt, adjust the value to something outrageous and see what changes.

 
magicrob

Joined: 2009-01-07
Posts: 6
Posted: Wed, 2009-01-07 09:41

Well, i just copied the entire block... Some are obvious :)

You answered the biggest question I had, which related to the scale. That's basically all I needed to work it out :)

Cheers.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-01-07 09:49
Quote:
You answered the biggest question I had, which related to the scale.

See http://www.fpdf.org/ which might help when looking at the code.
Also http://www.setasign.de/products/pdf-php-solutions/fpdi/

in particular http://www.fpdf.org/en/doc/fpdf.htm - default unit mm.

 
shridhar.govindaiah

Joined: 2009-02-13
Posts: 1
Posted: Fri, 2009-02-13 07:00

Hi All,
Hope all of you doing great.
I am using HTML2FPDF to create PDF files. Its working fine and PDF file is also creating.
My Question is,
the content which i am writing to PDF file is crossing 2 pages and I have header and footer for
those pages. The problem which I am facing is the text which is coming in the second page is overlapping
header Logo.
Please somebody help to avoid this overlapping and text should print after Logo in every page.

Thanks in Advance.
Hope I get fast reply :-)

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Wed, 2010-03-10 11:57

1. Is there a modification of this module to have an invoice serial number?
Our requirements looks to be the same as in Germany.
2. Is there a modification of this module to digitally sign the invoice?
The law requires that the invoice must be signed.
The signature does not have necessarily be a qualified signature (when you buy certificate from a certified local company). Signature can be generated by the seller itself using openssl for example.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-03-10 12:16
anonimlt wrote:
1. Is there a modification of this module to have an invoice serial number?

No

Quote:
Our requirements looks to be the same as in Germany.

checkoutpdf wasn't designed to comply with German law.

Quote:
2. Is there a modification of this module to digitally sign the invoice?

No

Quote:
The law requires that the invoice must be signed.

Not the law in the country for which the module was written. Everyone else can take their chances.

Quote:
The signature does not have necessarily be a qualified signature (when you buy certificate from a certified local company). Signature can be generated by the seller itself using openssl for example.

Both of these features would require extensive modifications to the checkout and/or checkoutpdf modules.

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Wed, 2010-03-10 13:06

Thanks for comments. I would like add a unique serial number feature to the invoice. in pseudo code it looks like this:
start_mysql_transaction;
SerNr=GetPluginParameter(...'NextSerialNo');
//create invoice
SetPluginParameter(...'NextSerialNo', SerNr+1);
commit_mysql_transaction;
How could I start/commit mysql transaction from the framework point of view?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-03-10 14:09

That's a terrible way to do it.

The correct way is to add a new GalleryMap that maps a transactionId to a transaction number, so each transaction is linked to its number. Then in the G2 API there's a method http://gallery.menalto.com/apidoc/GalleryCore/Storage/GalleryStorageExtras.html#methodcreateSequence to create a new sequence, which is the correct way in the G2 framework to have a unique incrementing sequence. To get the next number in sequence use http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryStorage.html#methodgetUniqueId on that sequence.

You absolutely definitely don't want to be worrying about mysql transactions and commits, that would break the framework totally.

This is not easy stuff. From your other questions that you've asked I don't think you have the knowledge of G2 API to achieve this. I would begin with some easy, unrelated, projects to create some new modules for yourself and learn how G2 functions internally first before trying this.