Modules:checkout - PDF invoice

pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Thu, 2008-11-06 18:18

First of all:

Superb module "Checkout"!!

A question regarding the PDF-invoice:

Wouldn't it be smart to include the PDF-invoice i the e-mails sent to the customer after payment?
Especially if you're using the download option you perhaps don't really want to send the invoice by e-mail..

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-11-06 23:28

Patrick,

There's no reason why not - it's just that in my case, I don't sell downloaded images, so I've never needed to email the invoice. If anyone wants to adapt the module to include the option to email the pdf, I can assist them.

 
pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Fri, 2008-11-07 09:42

A simple, but really nice feature would be a checkbox "publish in e-mails" to enable another "button" for reading the pdf-invoice in all e-mails.
Another angle (perhaps the simpliest of them) is just to make the same PDF-button the admin sees available to the customer, when he´s looking at his order status.

If you don't see this as a standard feature I'd be more than happy to get your help in modifying the code for including the link..

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-11-07 11:05
Quote:
Another angle (perhaps the simpliest of them) is just to make the same PDF-button the admin sees available to the customer, when he´s looking at his order status.

It's straightforward to do that - I'll dig the details out later on.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-11-09 15:20

Edit CheckoutPDFInvoiceStatusPlugin.class, and remove the if ($form['formName'] == 'AdminOrder') {...} clause from around line 48.

 
pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Sun, 2008-11-09 17:10

Thanks alecmyers..
Works like a treat - except...
When the customer clicks the PDF-invoice button he'll get a "Security Violation, The action you attempted is not permitted." error

Perhaps a Gallery-feature rather than a plugin feature, since he's not logged in when opening the order status page from the e-mail link.

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-11-09 17:20

Good point. Actually there is a security issue involved. You can remove the check-for-admin-status by deleting lines 50-54 of PDFOut.inc, the ones that read

	/* Make sure user is adminstrator */
	$ret = GalleryCoreApi::assertUserIsSiteAdministrator();
	if ($ret) {
	    return $ret;
	}

However, that means that anyone at all can download invoices for any and all orders, including customer details. Which is probably not good. To secure it you could add in the two security tags to the url (verify1 and verify2) like on the link to the order status page, and test for them in PDFOut.inc, instead. You'll find example code in the checkout/OrderStatus.inc, lines 96ff.

 
pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Sun, 2008-11-09 17:29

Sounds like a good idea :)

Thanks a lot for your involvment here alecmyers.
I'll have somebody take a look at your suggestions later on.
(myself are restricted to colourcodes and cut/paste when it comes to programming of any kind)

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-11-09 18:03

This should do the trick. In addition to the two changes above:

Replace from line 51 of CheckoutPDFInvoiceStatusPlugin.class as follows:

  /**
     * @see CheckoutStatusPageInterface_1_0:handleRequest()
     */
    function handleRequest(&$form) {
	if (isset($form['checkoutpdfinvoice']['downloadPDF'])) {

	    /* Get the transaction to find the security codes */
	    list ($ret, $transaction) = GalleryCoreApi::loadEntitiesById($form['checkoutpdfinvoice']['transactionId']);
	    if ($ret) {
	        return array ($ret, null);
	    }
	    if (!isset($transaction)) {
	        return array(GalleryCoreApi::error(ERROR_MISSING_OBJECT), null);
	    }
	    if ($transaction->getClassName() != 'GalleryCheckoutTransaction') {
	        return array(GalleryCoreApi::error(ERROR_MISSING_OBJECT), null);
	    }
    	    $results['redirect']['view'] = 'checkoutpdfinvoice.PDFOut';
	    $results['redirect']['transactionId'] = $form['checkoutpdfinvoice']['transactionId'];
	    $results['redirect']['verify1'] = $transaction->getDate();
	    $results['redirect']['verify2'] = $transaction->getSecurity();
	    $results['status'] = '';
	    $results['error'] = '';
	    return array(null, $results);
	}
	return array (null, null);
    }

Add at line 82 (83?) of PDFOut.inc:

        /* Perform security check */
	$verify1 = GalleryUtilities::getRequestVariables('verify1');
	$verify2 = GalleryUtilities::getRequestVariables('verify2');
	if ($verify1 != $transaction->getDate() || $verify2 != $transaction->getSecurity()) {
	    return GalleryCoreApi::error(ERROR_MISSING_OBJECT);
	}
 
pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Sun, 2008-11-09 19:58

Dindn't really work for me - the order status page turned out blank instead..
But I'll make somebody have a look at it directly in the system later on
(or if your module gets updated with the functinality in the future, whichever hapens fist)

Thanks a lot anyway - for support out of the ordinary :)

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-11-09 20:15
Quote:
the order status page turned out blank instead..

Probably a typo then - turn on debugging to 'buffered' in your config.php

 
pahvi
pahvi's picture

Joined: 2004-10-20
Posts: 31
Posted: Sun, 2008-11-09 21:16

The error code I get is:

Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /.../gallery/modules/checkoutpdfinvoice/classes/CheckoutPDFInvoiceStatusPlugin.class on line 80

Means nothing to ME, but line 80 is the last in the file "?>" right after the code I just inserted.

/patrick

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-11-09 21:34

here's one I prepared earlier.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Wed, 2008-11-26 20:06

Thank you alecmyers,

Great module checkout, very well done, thanks for sharing it.

(coming from http://gallery.menalto.com/node/83565) I copied the unzipped CheckoutPDFInvoiceStatusPlugin.zip to /modules/checkoutpdfinvoice/classes, buy as a customer, press the download-PDF-format-invoice button, it gives me this message:

Security Violation
The action you attempted is not permitted.

Back to the Gallery

When I go to “Orders”, then click an id, then press the download-PDF-format-invoice button it goes smoothly.

What might have gone wrong?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-11-26 20:31

I'm not sure... I'm just uploading (right now) the changes to this module (made in response to this thread) to the repository, so if you update the module tomorrow then you'll have the new code. Let me know then if you have any problems.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Thu, 2008-11-27 21:56

Thank you,

I can`t find any update of the Checkout PDF Invoice anywhere, in my repository displays 0.1.0 when I click to update plugins, which is the version I already should have and I can`t see any option, any link to download or update then, if I see it right. So, how, where do I find the update?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-11-28 09:44

The repository update process was stopped, so the new code wasn't made available. It should be now.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-01 12:10

Sorry, I can't still find any other Checkout PDF Invoice than 0.1.0 and I can't find the download-PDF-format-invoice button in 0.1.0. if the version's number should have been stayed the same.

As I see the po files are missing in the new versions, aren't they available anymore?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-12-01 14:22

It's still version 0.1.0 - unchanged. Code release number is 1701.

There are no po files and never have been - there's no customer-facing text to translate. If you're modifying the module to allow customers to be able to download their own pdf invoices and you want the text in the status page to be translated (or you want the text on the order admin page to appear in your own language) then you'll have to generate your own po files and translate them. Just for clarity for anyone else following this thread I'll point out that there's no way the Gallery tranlation system can't translate the pdf invoice itself.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-01 15:23

So then I must have misunderstood you completely:

Quote:
I'm just uploading (right now) the changes to this module (made in response to this thread) to the repository

I understood by this you have meant you are working on to build in this button. So, it is not like that, and then I would like to try to use the file CheckoutPDFInvoiceStatusPlugin.zip, but I obtain the message posted above. May be you have any idea how to solve the problem.

With po files I mean the files used in the most of the checkout modules, e.g. checkoutpaypal, checkoutdownload and so on: there are any po files in any of the downloaded po folders after my new installation of 4.2. The repository list doesn't show new updates (which might contain these po files). Are there older versions containing these po files available of these modules? I think in 4.1 there have been these files or am I wrong?

Sorry for the circumstances.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-12-01 15:38

@po files: No po files or mo files have ever been removed from any of the checkout- modules, they're all included in the repository. When you upgrade a module (not just checkout) you can choose which language packs to install.

For reference: po files are only needed if you want to change the translations. It's the .mo files (in <module>/locale/<language_code>/LC_MESSAGES/...) that are required for language support, and they get copied to your g2data/locale/.... directory when the module is installed.

The changes to checkoutdownload include the "improved" security check, but not making the button available for customers to download their own pdf's - that's not included. You still need to make this change:

Quote:
Edit CheckoutPDFInvoiceStatusPlugin.class, and remove the if ($form['formName'] == 'AdminOrder') {...} clause from around line 48.

From memory, I think that's all you need to do, but try it and see.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-01 22:55
Quote:
@po files: No po files or mo files have ever been removed from any of the checkout- modules, they're all included in the repository. When you upgrade a module (not just checkout) you can choose which language packs to install.

Yes, I had known and done it, but I can't find any po file which has been downloaded (though checked the right check boxes / options) and when I try to upgrade now, try to download any po file, try to download any other language in the repository list displays something like "No packages chosen", so I don't know how to download any po file. When the po files are downloaded, are they downloaded to /gallery/modules/checkout/po (and respectively to the other checkout modules folders)? These folders contain any po file though I have tried to download them by checking the boxes of the right packages, if I am right.

I have seen the po files of the version 4.1 and the other related checkout modules have been downloaded to /gallery/modules/checkout/po (and respectively to the other checkout modules folders). Has that changed, so were do I find now the po files of 4.2?

Quote:
For reference: po files are only needed if you want to change the translations.

Yes, I would like to display German language, that's why I would like to have the po files.

Quote:
The changes to checkoutdownload include the "improved" security check, but not making the button available for customers to download their own pdf's - that's not included. You still need to make this change:
Quote:

Edit CheckoutPDFInvoiceStatusPlugin.class, and remove the if ($form['formName'] == 'AdminOrder') {...} clause from around line 48.

Yes, I have read it in your posting you have done a few days ago and so I did what you wrote there, but I get this Security Violation message posted above.

Would be glad about any idea.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-12-01 23:12

There's no change to the location of any po files.

If the german po file isn't included in the distribution, you have to create one. this page explains how:
http://codex.gallery2.org/Gallery2:Localization

I'll follow my own instructions about the downoad button tomorrow, and see if I missed anything!

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-01 23:51

Many thanks for your kind help, the link and checking.

Quote:
If the german po file isn't included in the distribution, you have to create one.

All po files I would need are included, so the distribution contains all the po files I would need, but can't be downloaded obviously, at least by myself. So, can I use the po files from the previous version 4.1 or has there changed anything?

What might be the reason why the po files are not downloaded when downloading, upgrading the checkout modules though chosen the options accordingly?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-12-02 08:55
Quote:
So, can I use the po files from the previous version 4.1 or has there changed anything?

You can use them, but they don't have the right text in them so some things won't be translated.

Quote:
What might be the reason why the po files are not downloaded when downloading

I don't know... I've never really understood the Gallery language download system.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Tue, 2008-12-02 14:43

Thanks alecmyers for supporting.

Quote:
I don't know... I've never really understood the Gallery language download system.

So, when you new install a 4.2 all the po files are copied / downloaded to the right po folders of the checkout modules, e.g. to /gallery/modules/checkout/po and so on? The only files being downloaded to each of my po folders of the checkout modules are (a further time running the repository list shows what you can see on the screenshot of my second last posting here): GNUmakefile and strings.raw

Is there another place the po files can be download from directly?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-12-02 15:08

The po files and the mo files are downloaded with the rest of the module files, on a module-by-module basis. So the checkout language files are downloaded with checkout, the checkoutemail language files with checkoutemail, etc. There are currently no language files for checkoutpdfinvoice.

When a module is first installed, or updated, then the the mo files are copied from the modules/<module-name>/locale/.... directories to the g2data/locale/... directories, depending on which languages are active, as far as I know.

You can download *all* versions of *all* of the gallery files directly from the svn server:

for contributed modules: http://gallery-contrib.svn.sourceforge.net/viewvc/gallery-contrib/trunk/gallery2/modules/
for core modules: http://gallery.svn.sourceforge.net/viewvc/gallery/trunk/gallery2/modules/

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Tue, 2008-12-02 16:48
Quote:
The po files and the mo files are downloaded with the rest of the module files, on a module-by-module basis. So the checkout language files are downloaded with checkout, the checkoutemail language files with checkoutemail, etc.

Well, this doesn't happen on my system, obviously.

Quote:
There are currently no language files for checkoutpdfinvoice.

Yes, I had understood this.

Quote:
When a module is first installed, or updated, then the the mo files are copied from the modules/<module-name>/locale/.... directories to the g2data/locale/...

This doesn't happen on my system also, obviously.

So, the checkout po files all keep staying in their po folders in which they should have been downloaded automatically when installing or upgrading. This means, unless it doesn't happen in my Gallery, the best would be I download the missing files from here, http://gallery-contrib.svn.sourceforge.net/viewvc/gallery-contrib/trunk/gallery2/modules/checkout/po/ and copy them to my checkout po folder(s)?

And accordingly with the mo files to the locale folders of the checkout folders? They are renamed in Gallery when automatically copied to the directories to the g2data/locale/, if I am right.

I deleted in the ACP checkout 4.2, the checkout folder is deleted, then installed a new 4.2. The po folder is empty then, any file in it now, the locale folder, also. I copied the missing files to these folders from the svn server. When running the repo list the status of checkout can't be read as a message shows after (screenshot).

May be I should download all the files of the checkout modules from the svn server and upload them and then install in the ACP then, instead of downloading via ACP.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-12-02 17:11
Quote:
So, the checkout po files all keep staying in their po folders in which they should have been downloaded automatically when installing or upgrading.

I don't know what you mean by "staying in their po folders" - the po files should *always* be in the po/ directory - they never move from there.

Quote:
And accordingly with the mo files to the locale folders of the checkout folders? They are renamed in Gallery when automatically copied to the directories to the g2data/locale/, if I am right.

No, the mo file is renamed when the po file is compiled, and copied to the <module_name>/locale/... folder by the compilation script. This is done by the module author/contributor (i.e. me) before the module is uploaded to the repository. As you see in this directory and below:
http://gallery-contrib.svn.sourceforge.net/viewvc/gallery-contrib/trunk/gallery2/modules/checkout/locale/...

On installation, the .mo files are copied from there to the g2data/locale/... directories.

The .po files are irrelevant unless you plan to *rewrite* the translations. To create a new translation, you must build a new .po file, translate it, then compile it with the script.

I don't know why your po directory is empty. As far as I'm aware, all the po and mo files should download with the module when you install it, if you have the languages selected.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Tue, 2008-12-02 20:57

Many thanks for your help.

Quote:
I don't know what you mean by "staying in their po folders"...

I mean: once the po files (e.g. after downloading them by clicking the download link in the repo to the po folders) are in this folder, they will never be (re)moved (like it is done e.g. with the mo files, if I understand you right), they will remain there. I asked this about the po files, because my po folders are / were empty, and I was wondering when I learned that mo files are removed, if the same might happen to the po files, I didn't know first, whether the files have been downloaded to this folder and may be removed / moved then or whether they were not be downloaded. Now I mean to know they were never been downloaded.

Quote:
On installation, the .mo files are copied from there to the g2data/locale/... directories.

So, then I have to upload the mo files I downloaded from the svn server to the g2data/locale/ folders (but in which ones) or to the locale folder of the checkout modules (but I guess there is no possibility to let them remove automatically to the right g2data/locale/ folders)?

Quote:
The .po files are irrelevant unless you plan to *rewrite* the translations.

Yes, I had understood that, I plan to rewrite / translate (some of) the English po files (not existing in German language) for the front end, to change some translations of the German po files to fit my needs.

Quote:
To create a new translation, you must build a new .po file, translate it, then compile it with the script.

So I can't take an existing po file and modify it? I have to create a new one even if I want to modify some / a few sentences?

Quote:
I don't know why your po directory is empty. As far as I'm aware, all the po and mo files should download with the module when you install it, if you have the languages selected.

Yes, I have / had always have all the languages selected. Tried a few times.

Many thanks for your efforts.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-12-02 23:42
Quote:
when I learned that mo files are removed

They're not removed ... they're just copied.

Quote:
So I can't take an existing po file and modify it?

yes you can - just edit it as you wish, compile, change it to the correct name, and put the .mo file in the g2data/locale/... directory, according to language.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Wed, 2008-12-03 01:03
Quote:
just edit it as you wish, compile, change it to the correct name, and put the .mo file in the g2data/locale/... directory, according to language.

How do I compile? E.g. when I modify the file de.po in the po folder, may be some sentences to be changed, then I save the file...and which name have I change to the correct name? And the mo file in /modules/checkout/locale/de/LC_MESSAGES I will have to copy to /g2data_fotografiee/locale/de/LC_MESSAGES then? Is that right?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-12-03 01:39

For instructions on how to change localizations, you have to follow the instructions on this page (the same link as I posted for you before)
http://codex.gallery2.org/Gallery2:Localization

Then copy the .mo file to the g2data/locale/... directory.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-08 21:56
Quote:
For instructions on how to change localizations, you have to follow the instructions on this page (the same link as I posted for you before)
http://codex.gallery2.org/Gallery2:Localization

Yes, I had read this, but it was to complicated for me to understand. As I found out then, working on the po files / compiling is very easy with the right program.

So, if I have understood right, I can download all checkout modules from the svn server (and there are exactly the same files which I would download with a “usual” installation in the repo list, is this right?), then upload to the modules folder and - then go on the usual way - with the installation in “Plugins”? And there will be any difference to the way installing it automatically in the repo (besides there will be any missing files in my checkout folders)?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-12-08 22:02

Yes, if you download from the svn server, that should give you the same set of files as downloading via the get-more-plugins.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Thu, 2008-12-11 20:26
Quote:
Thanks.

Quote:
I'll follow my own instructions about the downoad button tomorrow, and see if I missed anything!

May I ask, what you did find out (thanks for it)?

And how can I prevent the po, respectively the mo files I modified from overwriting in the easiest way when updating in the future? To put them in a local folder doesn't work, if I see right.

Hi alecmyers,

I am very pleased about your help.

Do you think you could see an opportunity to let me know, whether your test regarding the download button went well? I would appreciate it very much. I always receive a "Security Violation" on different systems.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-12-11 21:15

OK, so I downloaded a fresh install of checkoutpdfinvoice. I removed the

 if ($form['formName'] == 'AdminOrder') { ...} 

clause from CheckoutPDFInvoiceStatusPlugin.class to get the button to appear on the customer-facing status page, and removed also removed the

	/* Make sure user is adminstrator */
	$ret = GalleryCoreApi::assertUserIsSiteAdministrator();
	if ($ret) {
	    return $ret;
	}

section from PDFOut.inc ...

... and it seems to work ok for me.

Make sure that's what you've done and let me know.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Thu, 2008-12-11 22:11

Thank you very much for testing and your efforts, alecmyers,

It works.

Don't know, what I could have missed before. May be it is CheckoutPDFInvoiceStatusPlugin.zip which caused a problem...

Quote:
OK, so I downloaded a fresh install of checkoutpdfdownload

Do you mean checkoutpdfinvoice? Or is there a connection to checkoutpdfdownload?

if ($form['formName'] == 'AdminOrder') { ...}

I don't know completely yet, what you mean by this: when I remove

if ($form['formName'] == 'AdminOrder') {
	    return array(null,'modules/checkoutpdfinvoice/templates/StatusPagePDFInvoice.tpl','modules_checkoutpdfinvoice')

it brings me a blanket page.

Removing this works:

if ($form['formName'] == 'AdminOrder')

But I guess, this is not what you mean.

Quote:
However, that means that anyone at all can download invoices for any and all orders, including customer details

Could now everyone see / get access to each invoice?

Once again, many thanks.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-12-11 22:16
Quote:
Do you mean checkoutpdfinvoice?

yes - sorry, my typo.

Quote:
I don't know completely yet, what you mean by this: when I remove

I mean remove the if ($form['formName'] == 'AdminOrder') { and the closing } to make it unconditional, but leave the return statement in the middle.

Quote:
Could now everyone see / get access to each invoice?

Only if they can guess the two security fields in the url (which they can't).

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Thu, 2008-12-11 22:49

Do I understand right, the red characters must be removed from this excerpt:

    /**
     * @see CheckoutStatusPageInterface_1_0::loadTemplate()
     */
    function loadTemplate(&$template, &$form) {
    
if ($form['formName'] == 'AdminOrder') {
	    return array(null,'modules/checkoutpdfinvoice/templates/StatusPagePDFInvoice.tpl','modules_checkoutpdfinvoice');
	}
	
	return array (null, null, null);
    }

    /**
     * @see CheckoutStatusPageInterface_1_0:handleRequest()
     */


So this remains:


    /**
     * @see CheckoutStatusPageInterface_1_0::loadTemplate()
     */
    function loadTemplate(&$template, &$form) {
    
        
	    return array(null,'modules/checkoutpdfinvoice/templates/StatusPagePDFInvoice.tpl','modules_checkoutpdfinvoice');
	
	return array (null, null, null);
    }

    /**
     * @see CheckoutStatusPageInterface_1_0:handleRequest()
     */

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-12-11 23:29

yeah, that would work.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Thu, 2008-12-11 23:53

Thank you, I am very happy to have the download option running now with your help.

How can I prevent the po, respectively the mo files I modified from overwriting in the easiest way when updating in the future? To put them in a folder named local - as it be can done with e.g. PDFOut.inc and CheckoutPDFInvoiceStatusPlugin.class - doesn't work, if I see right.

The e-mails sent by checkout to the admin and customer have the prefix: wwwrun. E.g.

. And the (only and simplest) way to replace this prefix e.g. with my real address or any other characters is to insert them in the "Email address to send order status notifications from" field?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-12-12 00:11
Quote:
How can I prevent the po, respectively the mo files I modified from overwriting

I don't think there's an obvious way - the local/ trick won't work - that's only for template files. you could change the file permissions to read only, I suppose, depending on how your webserver is set up.

Quote:
. And the (only and simplest) way to replace this prefix e.g. with my real address or any other characters is to insert them in the "Email address to send order status notifications from" field?

That's what it's for.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Fri, 2008-12-12 00:37

Very well, thanks for your support, all is running fine at the moment.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-15 20:58

I would like to edit the checkout pdf invoice the way I can use it with my logo (so delete the Fuzzy...lettering etc.), data etc. Could I please have a clue how I can do it? Especially the spacings between margin and content I would like to make fit my needs.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-12-15 21:13

Editing the background pdf is easy (and given the silly logo I put in, to be expected.) Just use something like Adobe Illustrator (you can download a free 30-day trial from the Adobe website) or any one of a number of pdf editors (I'm sure someone can recommend a FOSS one, if you prefer). Save the new version with the same file-name.

The spacings/margins etc of the actual content - well, here's an admission: I didn't write the module expecting it to be of much use to others, or to be put under much scrutiny - so it's not particularly well written, more sort of 'hacked together'. Having said that, there's nothing complicatd there, most of the margins, font-sizes etc are set as variables which you can adjust. The file you want to edit is PDFOut.inc. If you have any specific questions ("what does this bit do?") feel free to ask them here and I'll do my best to answer.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Mon, 2008-12-15 21:35

Thank you very much.

Quote:
I'm sure someone can recommend a FOSS one, if you prefer

Yes, I would be pleased about it. I could imagine that Illustrator is not so easily to use and so a little more simple program would be better to use for me.

Quote:
If you have any specific questions ("what does this bit do?") feel free to ask them here and I'll do my best to answer.

I will do that after starting editing, thank you, I appreciate it very much.

 
Hänsel

Joined: 2008-11-16
Posts: 39
Posted: Tue, 2008-12-16 00:48

It goes quite well thanks to your explanation...

Could you tell me, how I can insert here "Bestellnummer:": e.g.:

Bestellnummer: 232

And here "Seite 1 von 3 Seite(n)"

And in the footer, at the end of each page the actual page number and the amount of pages: e.g. "Seite 1 von 3 Seite(n)" (means: page 1 of 3 page(s))

The German date format works fine.

    function writeHeader($transaction,&$pdf) {
	global $gallery;
	$lineHeight = 3.5;
	/* put the date */
	$pdf->Text(140, 55, strftime('%A, %e. %B %Y',$transaction->getDate())); 
	/* order reference  */
	$pdf->Text(156,73,$transaction->getId());
	/* order placed by  */
	$placedBy = PDFOutView::fString($transaction->getFirstName().' '.$transaction->getLastName());
	$pdf->Text(156,80,$placedBy);
	/* page  */
	$pdf->Text(156,87,$pdf->PageNo() . " / {nb}");
	/* addressee */

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

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-12-16 08:04
Quote:
Could you tell me, how I can insert here "Bestellnummer:": e.g.:

You could put it in the master pdf (like I have, where it says "order reference") or you could put

$pdf->Text(156,73,'Bestellnummer: ' . $transaction->getId());
Quote:
And here "Seite 1 von 3 Seite(n)"

try

$pdf->Text(156,87,'Seite ' . $pdf->PageNo() . " von {nb} Seite(n)");
Quote:
And in the footer, at the end of each page

You'd need to create a footer function, like the header function, and call it once for each page.

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.

 
Hänsel

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

Thank you for your support, all of your instructions worked immediately...besides:

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

If I write the text on the first (which is the one and only) page in the pdf file, it displays on each page. And the position of the text to be written and displayed once in PDFout.inc I haven’t found yet. I would like have placed some text below the address, the header once.

Still some few questions to bother...

There’s one of the most important points I have disregarded unfortunately: I must have for the internal revenue office an invoice number in each single invoice (and e-mail would be good, also) incremented by one (without leaving out one of these incremented invoice numbers), perhaps near the order number. E.g.
first customer no. 1,
second customer no. 2,
second customer’s second order no. 3
and so on.

Can this (hopefully) be done in an easy way?

How can I make in the pdf invoice the space between the first image and the top margin and the space between the last image and the bottom margin bigger?

How can I limit the width of the thumbs displayed in the invoice (like it is done in the e-mail), so that a panorama image has the same width like e.g. an image with the aspect ratio 2:3? I think it can be done here, but...

if (method_exists($thumb, 'fetchPath')) {
		    list ($ret, $path) = $thumb->fetchPath();
		    if (!$ret and $path) {
			$printWidth = $thumbHeight * $thumb->getWidth() / $thumb->getHeight();
			$pdf->Image($path,$col1X+($thumbWidth-$printWidth)/2,$curY-$thumbHeight/2,0,$thumbHeight,'JPEG');
		    }
 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-12-17 09:46
Quote:
I must have for the internal revenue office an invoice number in each single invoice... Can this (hopefully) be done in an easy way?

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

Quote:
How can I make in the pdf invoice the space between the first image and the top margin and the space between the last image and the bottom margin bigger?

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.