simplydigital Posted September 7, 2016 Share Posted September 7, 2016 Hi I need to add the service username to PDF invoice, I believe this can be done via a hook, but a bit beyond me. I have re-sellers that have several clients, and at the moment when an invoice is created and sent, it does not include any reference to which one of their clients the invoice is for. Thanks Steven 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 7, 2016 Share Posted September 7, 2016 (edited) Hi Steven, I need to add the service username to PDF invoice, I believe this can be done via a hook, but a bit beyond me.I have re-sellers that have several clients, and at the moment when an invoice is created and sent, it does not include any reference to which one of their clients the invoice is for. for something like this, it's easier to modify the invoicepdf.tpl template and add the required code in there. so at the top of the file, you need to enable Capsule so that you can query the database... <?php use Illuminate\Database\Capsule\Manager as Capsule; and then in the # Invoice Items block of code, you can change... foreach ($invoiceitems as $item) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br /></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } to... foreach ($invoiceitems as $item) { $serviceusername = Capsule::table('tblhosting') ->where('userid',$userid) ->where('id',$item['relid']) ->pluck('username'); if ($serviceusername) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />'. Lang::trans('serverusername'). ': ' . $serviceusername .'<br /></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>'; } } i'm not sure how you wanted to output the username, so for those product(s) that have a service username, it should now be displayed in the invoice for each applicable product below the description of the product. note - if you're going to use this on WHMCS v7, modify the code by changing 'pluck' to 'value'. Edited September 7, 2016 by brian! 1 Quote Link to comment Share on other sites More sharing options...
simplydigital Posted September 7, 2016 Author Share Posted September 7, 2016 Thank you so much, worked brilliant 0 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.