News:

Looking for documentation? Take a look on our wiki

Main Menu

Override of confirmation mails

Started by sscheidegger, February 29, 2012, 18:05:33 PM

Previous topic - Next topic

neo314

#30
Quote from: randomdev on December 20, 2012, 02:31:03 AM
If you want to change it I believe the filename is in controllers/invoice.php line 88 (I haven't tested this)

$path .= 'vminvoice_'.$invoiceNumber.'.pdf';

Thanks. I found that, but it would be nice if it were configurable so the changes would survive updates. Also, it doesn't matter if I can't get the PDF to look half way decent, so I just made it not attach a pdf to the email at all for now.

randomdev

I could get the pdf in the emails looking ok, but I am having problems with the BE pdf one however (tiny logo and lots of spacing).

The store owner wanted to use this to print out and attach to the parcels (the print view is even worse and looks like it has no formatting/css?)

Milbo

Quote from: neo314 on December 20, 2012, 00:33:19 AM
I don't think it is purely cosmetic either. The Email that I get from the purchase is something I can override, and even without doing an override, it is not coming from the same source as the attached PDF file.
It cannot be the same, of course the email is different than an invoice. But exactly the same is the price list. We just use always the same file for it.

But the pdf of the email and the pdf created in the Backend are exactly the same except two small things. The header and the footer of the pdf is not exactly the same. This is the reason for the different size of logos.
One time we use /index.php?option=com_virtuemart&view=invoice&layout=invoice&format=pdf&tmpl=component&virtuemart_order_id=xxx&order_number=1234&order_pass=yyy

This is using then "/libraries/joomla/document/pdf/pdf.php". But the pdf of the email is created in the controller and we change the headers there. Reinhold meant at begin that he is eager to solve it, but then also said, uih shit, that looks hard. I spent already 4-5 hours to get it running. So we are happy if someone has an idea, how we can overwrite the header and footer and how we can have always the same thing. yes. Adding of new fonts is already in vm2.1.

Quote from: neo314 on December 20, 2012, 00:33:19 AM
The email has clean formatting with order information at the top and the Bill To/ Ship To list the information cleanly with out the array's keys spit out.

The pdf attached to the email and the pdf shown in the back end, may share a source file, but template overrides appear in the BE pdf and not in the email attachment pdf, and on mine, the head of the two files is different along with added information (Order Status Table) included in the email attachment (See attached images).
You start it from BE, so it checks first for overwrites in the BE. If you updated, then you have old folders in BE. There is no view invoices anylonger in the BE, delete it.

Quote from: neo314 on December 20, 2012, 00:33:19 AM
I need to at least be able to stop the email attachment from going out (just the email, no attachment).

Standard. Since 2.0.10 or so you can define the orderstatus which should be used to send the pdf, just unselect all and it should work for you.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

neo314

Thanks Milbo,

That is helpful. I do not have an views/invoice folder in the BE administrator/components/com_virtuemart. Must have already deleted it when I upgraded.

QuoteStandard. Since 2.0.10 or so you can define the orderstatus which should be used to send the pdf, just unselect all and it should work for you.

You can't actually unselect it in 2.0.14, hence the work around in the thread I linked to. I think it is a little confusing as well. The BE prompt is "Default Order Status to send an invoice" which to my mind could as easily be the email. I think of the email as an invoice and I get email only invoices all the time. It might be better to have the prompt say "Default Order Status to send a pdf invoice"

Thanks again.

reinhold

Quote from: Milbo on December 20, 2012, 12:35:21 PM
But the pdf of the email and the pdf created in the Backend are exactly the same except two small things. The header and the footer of the pdf is not exactly the same. This is the reason for the different size of logos.

Actually, the pdf invoice sent via mail and the one available in the BE are created even from different templates (invoice.php for the BE invoice, mail_html.php for the automatically sent pdf invoice!), so unless you override both to create identical output, the two types of invoice will be different!

Another problem is that the automatic pdf invoice (and the mail contents) does NOT seem to use content plugins. Since I'm using {article Allgemeine Geschäftsbedingungen}{title} {text}{/article} in the legal information, my invoices and order confirmations sent by mail do not show the terms & conditions, so I might even be in violation of the appropriate laws!

Basically, the templates used are:


  • notification mail body: mail_html.php (NO content plugins)
  • pdf invoice in the "order" list in the BE (click on the pdf icon): invoice.php (language override from FE, content plugins work)
  • print invoice in the "order" list in the BE (click on the print icon): invoice.php (NO header/footer, language override from FE, content plugins work)
  • auto-generated pdf invoice mail body (change the order status to confirmed): mail_html.php (NO content plugins, language override from BE)
  • auto-generated pdf invoice mail attachment (change the order status to confirmed): mail_html.php (NO content plugins, language override from BE)


The biggest issues I have with this are:

  • The two PDF invoices use different templates
  • The auto-generated pdf invoice (and the mail) do NOT use content plugins
  • Different language overrides (FE/BE overrides are used)
  • PDFs are NOT stored on disk, but are re-created every time, which might again collide with the law that invoices must be created in a way that they may not be tampered with after creation. So depending on which lawyer you ask, once you sent out a PDF invoice, you might be in violation of the law if you later modify the templates and use the downloaded invoice from the BE for your own accounting.

The vision that I have is that virtuemart should

  • Have a generic setting for company letters (proper header/footer HTML in the config)
  • Provide a generic function to create company-styled documents. AFAICS, this should not be done by using Joomla's content PDF creation, but needs its own TCPDF-derived class, which needs to be heavily tweaked (look e.g. at the Phoca PDF for Virtuemart 1 plugin, which was able to generate nicely styled PDF invoices and delivery notes. The headers/footers there were custom HTML cells with fixed position.).
  • There should be only one codepath to create the pdf invoices (from the invoice template, so the mail body might look completely different, which is okay, since it's not an invoice in any way).
  • That pdf invoice-creation uses the company-styled document generation and stores the documents on disk, with a trigger to e.g. call a signature function for electronic signatures)
  • That pdf document from disk is then either attached to the mail or sent to the administrator's browser in the BE

Such a generic approach also has the advantage that it opens the path to serial-letter creation with company-styled prints from the VM BE. Also, it would implementing delivery notes or reminders for payment much easier.

Cheers,
Reinhold

neo314

I think your premise that the PDF attached to the email and the email use the same template is incorrect. See my earlier post (with pictures)

reinhold

Quote from: neo314 on December 20, 2012, 20:23:45 PM
I think your premise that the PDF attached to the email and the email use the same template is incorrect.

They are using the same template, but with different variables, so the if checks in the template yield slightly different output.

Also, previously, the pdf attached to the mail didn't correctly employ the template overrides. I hope this is fixed now in the latest version (I think Milbo included the fix in 2.0.15e).

neo314

Quote from: reinhold on December 20, 2012, 20:44:00 PM
Quote from: neo314 on December 20, 2012, 20:23:45 PM
I think your premise that the PDF attached to the email and the email use the same template is incorrect.

They are using the same template, but with different variables, so the if checks in the template yield slightly different output.

Also, previously, the pdf attached to the mail didn't correctly employ the template overrides. I hope this is fixed now in the latest version (I think Milbo included the fix in 2.0.15e).

Unfortunately I can't upgrade to 2.0.15x yet as two VM plugins I need broke under 20.15... b I think. How is it they use different variables. Can you elaborate on that. I concur with the approach you propose. I do think this should be a high priority for VM development and core would be best, but a plugin would help.

reinhold

Quote from: reinhold on December 20, 2012, 20:44:00 PM
They are using the same template, but with different variables, so the if checks in the template yield slightly different output.

Oops, sorry, I messed up something:

The two pdf generated use the same "invoice" template, but they are still very different. I'm attaching sample files (both the pdf files created by Virtuemart and the html files, which I converted to PDF in Firefox) for debugging, where I inserted a <h1> displaying each include file of the view as they are processed... I also added a sample translated string
<h2><?php echo JText::_('TESTTRANSLATION'); ?></h2> where the translation in the frontend/backend files shows whether the FE or the BE is responsible for the translation. And you can see that in the automatically generated and sent PDF invoices no content plugins are run.
{article Allgemeine Geschäftsbedingungen}{title} {text}{/article}


Quote from: neo314 on December 20, 2012, 23:09:32 PM
How is it they use different variables. Can you elaborate on that.

E.g. the mail sent to the shopper and to the vendor look quite different, but they are generated by the same "mail_html.php" view. If you look at that file, you'll see checks like
if ($this->recipient == 'shopper') {



[attachment cleanup by admin]

enserk

Hallo,

can anyone tell me what file the pdf invoice uses for the shipping address? I have a fixed shipping address and not the standard one; I have already changed it in the confirmation mail and the online order status but won't find the file for the pdf invoice!
Thanks in advance!