Synister Posted May 31, 2021 Share Posted May 31, 2021 Is there a way to include the Service Username on the invoice? This would help clients who have multiple services know which one they are renewing. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 31, 2021 Share Posted May 31, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
Synister Posted May 31, 2021 Author Share Posted May 31, 2021 (edited) 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, Edited May 31, 2021 by Synister 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 31, 2021 Share Posted May 31, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
Synister Posted May 31, 2021 Author Share Posted May 31, 2021 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. Â 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2021 Share Posted June 1, 2021 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>'; } } 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. 0 Quote Link to comment Share on other sites More sharing options...
Synister Posted June 2, 2021 Author Share Posted June 2, 2021 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>'; } } 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 2, 2021 Share Posted June 2, 2021 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* 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. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.