Author Topic: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME  (Read 724 times)

Offline Mimmi

  • Full Member
  • ***
  • Posts: 32
    • View Profile
NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« on: 26/January/2011, 12:54:52 PM »
Using nBill 2.0, haven't had time to upgrade to 2.1.1.

I would like to change my custom e-mailtemplate so that the following text appear in the mail:

"You can see all of your invoices online by logging in at %s (your username is %s). If you no longer wish to receive your invoices by e-mail, simply log in and click on `My Profile` in the `My Account` area to set your preferences."

(now this is the text: You can see all of your invoices online by logging in at %s. If you no longer wish to receive your invoices by e-mail, simply log in and click on `My Profile` in the `My Account` area to set your preferences)

I have to change the code in invoice_email_custom_attach.php from:
Code: [Select]
<p><?php echo sprintf(NBILL_EM_NEW_INVOICE_PAR_2nbf_cms::$interop->live_site); ?></p>
to something like

Code: [Select]
<p><?php echo sprintf(NBILL_EM_NEW_INVOICE_PAR_2_USERNAMEnbf_cms::$interop->live_site$username); ?></p>
But that doesn't make the username appear. I guess I have to do something more with the code, but what?

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,952
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #1 on: 26/January/2011, 01:09:46 PM »
I'm afraid the username is not currently loaded at the time the invoice template is executed, so if you want to pick up the username, you would have to write some code to look it up in the database yourself. The username is stored on the contact record, so you would need to look up the primary_contact_id on the jos_nbill_entity table using the entity_id from the jos_nbill_document table as the key.

Offline Mimmi

  • Full Member
  • ***
  • Posts: 32
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #2 on: 26/January/2011, 01:31:55 PM »
I'm afraid the username is not currently loaded at the time the invoice template is executed, so if you want to pick up the username, you would have to write some code to look it up in the database yourself. The username is stored on the contact record, so you would need to look up the primary_contact_id on the jos_nbill_entity table using the entity_id from the jos_nbill_document table as the key.

Thank you for your quick reply. This is odd because I just received an e-mail from "Joomla i Norge" that has this, and they can't remember changing a lot of code to achieve this.
« Last Edit: 26/January/2011, 01:44:05 PM by Mimmi »

Offline Mimmi

  • Full Member
  • ***
  • Posts: 32
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #3 on: 26/January/2011, 07:25:41 PM »
This is very strange. I double-checked with Joomla-i-Norge and they are certain they are only using the normal files, no alterations.

Is there a difference in behavior if the e-mail is created by clicking the envelope in administrator/index.php?option=com_nbill&action=invoices or if it is auto-created?

Offline Mimmi

  • Full Member
  • ***
  • Posts: 32
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #4 on: 26/January/2011, 07:55:16 PM »
It seems to me that n.richard in User Name in email templates requested the same thing as I do.
http://www.nbill.co.uk/forum/index.php/topic,1671.0.html

Maybe I just asked the question wrong? Anyway, I don't have the skills to neither find $document_id variables nor the looking the username up in the database, so I guess I'm just lost!  :-[ I guessed it was a standard simple feature since the NBILL_EM_NEW_INVOICE_PAR_2_USERNAME is in the language file and Joomla-i-Norge use it. But if it's not I'll survive  :)

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,952
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #5 on: 28/January/2011, 11:24:14 AM »
At present, it will show the username only if you are NOT using an HTML email template (ie. when you are just using a plain text email). I will see if I can easily accommodate including the username on HTML emails as well (needs a bit of jiggery-pokery in the core to make the username available to the template).

Offline Mimmi

  • Full Member
  • ***
  • Posts: 32
    • View Profile
Re: NBILL_EM_NEW_INVOICE_PAR_2_USERNAME
« Reply #6 on: 28/January/2011, 12:50:37 PM »
At present, it will show the username only if you are NOT using an HTML email template (ie. when you are just using a plain text email). I will see if I can easily accommodate including the username on HTML emails as well (needs a bit of jiggery-pokery in the core to make the username available to the template).

Thank you! I love it when it's an easy explanation! :-D No worries, I just use the plain text :-)