ouldfella Posted July 3, 2017 Share Posted July 3, 2017 hi i added this code : {php} use WHMCS\Database\Capsule; foreach (Capsule::table('tblinvoiceitems')->get() as $icosinvoiceitems) { echo $icosinvoiceitems->description; } {/php} and i had this error cosed by using Capsule Parse error: syntax error, unexpected 'use' (T_USE) in /var/www/html/manager/templates_c/72d89e63f9b687d11411376dbdde1aa26bc02b1d_0.file.viewinvoice.tpl.php on line 53 i nedd to interogate the table 0 Quote Link to comment Share on other sites More sharing options...
ouldfella Posted July 3, 2017 Author Share Posted July 3, 2017 i changed the code to select all items : $result = mysql_query("SELECT * FROM tblinvoiceitems where invoiceid='77';"); $data = mysql_fetch_array($result); var_dump($data ); but there is one item, it must find two 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 3, 2017 Share Posted July 3, 2017 you shouldn't really be using {php} tags these days, it's better to use a hook and pass the array back to the template. what exactly are you trying to do with this code? there is already an $invoiceitems array in the viewinvoice page, so i'm not sure why you need to query the database for the same information ?? 0 Quote Link to comment Share on other sites More sharing options...
ouldfella Posted July 4, 2017 Author Share Posted July 4, 2017 thank you for yor reply, finaly what i want is to costumize the invoice in actual invoice the description of the product is like this : 2 x Pack Starter (03/07/2017 - 02/08/2017) @ 1000.00/chaque * 2 : indicate the quantity so i want to create a new column with header is Quantity and i will put the values in there and i need to delete the dates interval (03/07/2017 - 02/08/2017) for the moment just i am trying to how to get the data from the table tblinvoiceitems 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 4, 2017 Share Posted July 4, 2017 thank you for yor reply, finaly what i want is to costumize the invoicein actual invoice the description of the product is like this : 2 x Pack Starter (03/07/2017 - 02/08/2017) @ 1000.00/chaque * if you're seeing "2 x " etc in the description, that means you have Group Similar Line Items enabled in General Settings. Tick to enable automatically grouping identical line items into a quantity x description format. if it was unticked, you'd see multiple copies of the same line item shown in the invoice - the existing $invoiceitems arrays adjusts the description value based on the value of the above checkbox. 2 : indicate the quantityso i want to create a new column with header is Quantity and i will put the values in there it's worth noting that there isn't a "Quantity" column stored in this database table - so you'd have to get that value another way. and i need to delete the dates interval (03/07/2017 - 02/08/2017)for the moment just i am trying to how to get the data from the table tblinvoiceitems if you just wanted an action hook to query the tblinvoiceitems table, for the current invoice, then you could use this... <?php # Invoice Items Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function invoice_items_hook($vars) { $invoiceitems = Capsule::table('tblinvoiceitems') ->where('invoiceid', $vars['invoiceid']) ->get(); if (count($invoiceitems)) { $encodedata = json_encode($invoiceitems); $decodedata = json_decode($encodedata, true); return array("invoiceitems2" => $decodedata); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_items_hook"); that would give you a new Smarty array, $invoiceitems2, that you can use in the viewinvoice template... if "Group Similar" is disabled, the two arrays should be very similar (any differences aren't relevant to your needs); if enabled, $invoiceitems2 will show individual line items whereas $invoiceitems will group them. you could do what you want to do without any SQL queries or hooks, e.g just using Smarty/PHP (using no {php} tags!) - certainly the above hook doesn't give you any useful information that doesn't already exist in $invoiceitems... though you could get the qty with a more complex database query... and the date removal could be done using Smarty or PHP. unfortunately, I don't think i'm going to be able to help you much with this... the problem being that i've very recently done something very similar for a couple of paying clients, and so I can't charge for the customisation one day, and give it away the next.... nor could I just ignore your reply... I might be able to give you clues, but no specific code... apologies for that. 0 Quote Link to comment Share on other sites More sharing options...
ouldfella Posted July 6, 2017 Author Share Posted July 6, 2017 thank you very much for your help. 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.