Jump to content

Invoice Editing


Synister

Recommended Posts

9 minutes ago, Synister said:

Is there a way to include the Service Username on the invoice?

not from settings.

10 minutes ago, Synister said:

This would help clients who have multiple services know which one they are renewing.

where are you wanting to see this - the html invoice, the PDF invoice, the email... or all of the above ??

with the first two, you could use a hook or edit the PDF template to get the username from the database (when relevant); whereas if it needs to be everywhere, then you're probably looking at a invoicing hook to modify the appropriate line item(s) before it gets sent to the user.

Link to comment
Share on other sites

10 minutes ago, brian! said:

not from settings.

where are you wanting to see this - the html invoice, the PDF invoice, the email... or all of the above ??

with the first two, you could use a hook or edit the PDF template to get the username from the database (when relevant); whereas if it needs to be everywhere, then you're probably looking at a invoicing hook to modify the appropriate line item(s) before it gets sent to the user.

Im wanting it in the HTML invoice and PDF Invoice.

Either the Service username or Service ID. Service ID would probably be better and more secure since it  does not show any part of the login info.

Kind of like in the attached image,

Screenshot 2021-05-31 095731.png

Edited by Synister
Link to comment
Share on other sites

32 minutes ago, Synister said:

Either the Service username or Service ID. Service ID would probably be better and more secure since it  does not show any part of the login info.

well the good news if you want service ID is that there would be no db querying involved - it would already be available to the template... so it would be ClientAreaPageViewInvoice hook for the html template, and it would check to see if $item['type']="hosting" and if it is, then the service ID value would be $item['relid']... so from your screenshot, you would add your new output (language string for Service ID and the relid value) before the first break return of the line item description.

it should be exactly the same principle in the PDF template too.

Link to comment
Share on other sites

7 hours ago, brian! said:

well the good news if you want service ID is that there would be no db querying involved - it would already be available to the template... so it would be ClientAreaPageViewInvoice hook for the html template, and it would check to see if $item['type']="hosting" and if it is, then the service ID value would be $item['relid']... so from your screenshot, you would add your new output (language string for Service ID and the relid value) before the first break return of the line item description.

it should be exactly the same principle in the PDF template too.

I'm completely clueless on how to do this.

 

Link to comment
Share on other sites

14 hours ago, Synister said:

I'm completely clueless on how to do this.

well the complicating part is you wanting to add the new content in the middle of the output - it's doable though and just requires manipulating the array.

if I take the PDF as an example, and i'll use Six, but 21 should be exactly the same... if you wanted to add the service ID to the end of the output (simpler!), then you would just change (in invoicepdf.tpl)...

foreach ($invoiceitems as $item) {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br />Service ID: ' . $item['relid'] . '</td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
}

to...

foreach ($invoiceitems as $item) {
if ($item['type'] == "Hosting") {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br />Service ID: ' . $item['relid'] . '</td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
} else {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br /></td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
}
}

273Z7dk.png

something similar could be done with a hook to adjust the HTML invoice - you could even link it to go to the relevant service page.

btw, I assumed there was a language string for "Service ID", but there doesn't seem to be one - you could make them as Language Overrides if you wanted to, or just hardcode it as I have above.

Link to comment
Share on other sites

8 hours ago, brian! said:

well the complicating part is you wanting to add the new content in the middle of the output - it's doable though and just requires manipulating the array.

if I take the PDF as an example, and i'll use Six, but 21 should be exactly the same... if you wanted to add the service ID to the end of the output (simpler!), then you would just change (in invoicepdf.tpl)...


foreach ($invoiceitems as $item) {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br />Service ID: ' . $item['relid'] . '</td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
}

to...


foreach ($invoiceitems as $item) {
if ($item['type'] == "Hosting") {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br />Service ID: ' . $item['relid'] . '</td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
} else {
    $tblhtml .= '
    <tr bgcolor="#fff">
        <td align="left">' . nl2br($item['description']) . '<br /></td>
        <td align="center">' . $item['amount'] . '</td>
    </tr>';
}
}

273Z7dk.png

something similar could be done with a hook to adjust the HTML invoice - you could even link it to go to the relevant service page.

btw, I assumed there was a language string for "Service ID", but there doesn't seem to be one - you could make them as Language Overrides if you wanted to, or just hardcode it as I have above.

How would I add the Service ID to the Invoice Created and Credit Card Invoice Created Templates?

Link to comment
Share on other sites

9 hours ago, Synister said:

How would I add the Service ID to the Invoice Created and Credit Card Invoice Created Templates?

*sighs and hits head against a brick wall* smiley-bangheadonwall-yellow.gif

when I asked you on Monday where you wanted to do this, there was a good reason for doing so - namely, the answer you gave determined the best solution.

so if you had said only PDF, then you just modify the invoicePDF template; if only the HTML template, you use a CAPVI hook; if everywhere, then you would use a hook to modify the relevant line items before they're sent to the client and that removes the need to modify any client area or email templates.

*sighs again* 🙄

the array structure is the same in the email template as it is in the client area, so in the email template, you could replace...

{$invoice_html_contents}

with...

{foreach from=$invoice_items item=data}
{$data.description}{if $data.type eq "Hosting"}<br />Service ID: {$data.relid}{/if}: {$data.amount}
{/foreach}

it probably wouldn't look as neat as the contents string, but you could put the foreach output in a table to make it cleaner if you wanted to... you'd also have to add the subtotal/credit/tax/total summaries etc.

the invoicing hook would really be the way to go, but that's not one for me to write.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated