TeleMagic Posted August 16, 2013 Share Posted August 16, 2013 Hi Guys I am wondering if it is possible to display the balance of a VOIP account on an external system in the client area. So I would have ie Account Credit Balance: $0.00 USD Due Invoices Balance: $14.30 USD Voip Account Balance: $12.95 USD The voip accounts are created by WHMCS using a module I am writing and the table that stores the balance has the customerid from WHMCS in it so from a database perspective it would simply be a case of running a query to find out the balance of that customer, Im just not sure how and if it is possible to change the template to display this is client area? Regards 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 16, 2013 Share Posted August 16, 2013 (edited) Well it's really easy. On your external system you have to store the key (client ID) too. Then on your custom page you can run the query below. I'm assuming that voip balance variable is stored on an external dababase so ConnectToExternalDB() should return the connection string to your external database. $result = mysql_query("SELECT voipbalance FROM externalsystem WHERE id=".$ca->getUserID(),ConnectToExternalDB()); Edited August 16, 2013 by Kian 0 Quote Link to comment Share on other sites More sharing options...
TeleMagic Posted August 16, 2013 Author Share Posted August 16, 2013 I already store the client id in the external system. So I can just put that code in the template for client area and display like that? How would I configure the external connection? Regards 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 17, 2013 Share Posted August 17, 2013 Yes. If you need to display this value in a standard page of WHMCS (obfuscated) the only option you have is to add your script directly inside the tpl file between {php}{/php} tags or include an external file with {include_php file='yourscript.php'}. The cleanest way is to use the include and pass VoIP Balance variable to a Smarty variable. In this way you can refer to this value with something like {$voipbalance} instead of using {php}echo $voipbalance;{/php} in the tpl. 0 Quote Link to comment Share on other sites More sharing options...
TeleMagic Posted August 28, 2013 Author Share Posted August 28, 2013 How would I convert my PHP variable into a smarty variable? Ie if I included a php which did the database connection, and did a $result = mysql_query("mysuery"); How would I then convert the value of $result into a smarty variable $voipbalance? Regards 0 Quote Link to comment Share on other sites More sharing options...
TeleMagic Posted August 28, 2013 Author Share Posted August 28, 2013 Also how do I get the clientdetails.id into the php file called from the template? I use the $clientsdetails['id'] to store in the external system. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 28, 2013 Share Posted August 28, 2013 Quick example: $result = mysql_query("SELECT firstname FROM tblclients WHERE id=".$ca->getUserID()); $data = mysql_fetch_array($result); $clientname = $data[0]; $ca->assign('clientname', $clientname); 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.