Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/08/2019 in all areas

  1. 1 point
    I need a few query scripts created that connect using a specified database user. The scripts should perform actions similar to some of the reports built into WHMCS however, only output a single number. 1. Active Clients - should output active clients at the time of executing the script 2. Active Client WITH Active Services - should output the count of active clients that also have active services 3. Daily Revenue - should get current dollar amount of income of the day
  2. 1 point
    the problem with the first hook is that you're checking the status of $client, but never defining what $client is - so that if statement is never valid and hence the link is not added. <?php #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (!is_null($client)) { $primaryNavbar->addChild('UnBlock IP') ->setUri('index.php?m=unblockip') ->setOrder(70); } }); the above will add a menu link to a client's menu when they are logged in - if they are not logged in, the link will not be added.
  3. 1 point
    We do the same on one of our installs, and it's a matter of edits to the menu system via hooks, mostly. When setting it up, we loaded the pages as they are now and looked for all references to these, and worked our way through the templates to see where they were referenced. Don't forget the email templates, since some have a footer with a helpdesk link in them. Here's the KB one we use (change the obvious in the URL part): <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $newURL = 'https://mydomain.com/desk/index.php?/Knowledgebase/List'; if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->getChild('Knowledgebase') ->setURI($newURL); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->getChild('Knowledgebase') ->setURI($newURL); } }); add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { $newURL = 'https://mydomain.com/desk/index.php?/Knowledgebase/List'; if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support') ->getChild('Knowledgebase') ->setURI($newURL); } }); We also created a Kayako database user with read only perms, and wrote a widget that will call that db and show ticket counts within the WHMCS admin dashboard. Didn't do that for customers, though.
  4. 1 point
    Hello, After sign up for the WHMCS license reseller program, you will have access to the WHMCS reseller module which allow to sell WHMCS license within your WHMCS installation.
  5. 1 point
    it looks like it - there's the usual 4 year old feature request for it. 🙄 https://requests.whmcs.com/topic/api-call-to-create-todo-item
  6. 1 point
    Hi Michael, I thought it might be helpful if I mentioned two further things for clarification... firstly, the WHMCS Exchange Rate updates basically work by pulling the daily ECB (European Central Bank) XML feed - that feed is a list of 30+ currencies and gives the daily equivalent value of 1 Euro in those currencies - so it's not loading 30 different currencies and all the exchange rates between each of them, just the Euro exchange rate with each and then it can easily calculate the others from those values. <Cube><Cube time="2018-12-21"><Cube currency="USD" rate="1.1414"/><Cube currency="JPY" rate="126.98"/><Cube currency="BGN" rate="1.9558"/><Cube currency="CZK" rate="25.855"/><Cube currency="DKK" rate="7.4670"/><Cube currency="GBP" rate="0.90215"/><Cube currency="HUF" rate="321.97"/><Cube currency="PLN" rate="4.2851"/><Cube currency="RON" rate="4.6389"/><Cube currency="SEK" rate="10.2733"/><Cube currency="CHF" rate="1.1312"/><Cube currency="ISK" rate="134.10"/><Cube currency="NOK" rate="9.9428"/><Cube currency="HRK" rate="7.4216"/><Cube currency="RUB" rate="78.2103"/><Cube currency="TRY" rate="6.0546"/><Cube currency="AUD" rate="1.6081"/><Cube currency="BRL" rate="4.4099"/><Cube currency="CAD" rate="1.5459"/><Cube currency="CNY" rate="7.8825"/><Cube currency="HKD" rate="8.9368"/><Cube currency="IDR" rate="16696.34"/><Cube currency="ILS" rate="4.3045"/><Cube currency="INR" rate="80.0400"/><Cube currency="KRW" rate="1282.71"/><Cube currency="MXN" rate="22.7547"/><Cube currency="MYR" rate="4.7608"/><Cube currency="NZD" rate="1.6925"/><Cube currency="PHP" rate="60.546"/><Cube currency="SGD" rate="1.5641"/><Cube currency="THB" rate="37.267"/><Cube currency="ZAR" rate="16.4753"/></Cube></Cube> as an example, today on the ECB list, 1 EUR = 0.90215 GBP - however, on my dev, my default currency is GBP, so WHMCS does the calculation of 1/0.90215 to give me the GBP->EUR exchange rate of 1.10846 so if I wanted to calculate the exchange rate between two non-default currencies, in my case that could be USD->HRK with a default currency of GBP, I know that the GBP->USD rate is 1.2652 today, so USD->GBP would therefore be 0.79039 .... GBP->HRK is still 8.22657, so if we multiply one by the other (0.79039*8.22657), we get a USD->HRK exchange rate of 6.50219 I can double-check this by setting USD as my default currency and updating the exchange rates again... secondly, when it comes to the hook, you basically need to know two things: what is the client's currency what is the secondary currency exchange rate that you want to return for the client's currency. so 1️⃣ can be taken care of by adding the code below to your hook function... $clientcurrency = $vars['clientsdetails']['currency']; that gives you a new variable, $clientcurrency, than you can use in your conditions. i'm assuming for 2️⃣ that it's always going to be HRK - though it wouldn't really matter if it wasn't, it would just make the hook code a little longer... as an early Christmas present from me, here's a replacement hook that should work for you - you'll have to change the IF statements to match your own currency conditions though... 🎁 <?php # Get Croatian Currency Exchange Rate # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function hook_currency_exchange_rates($vars) { $clientcurrency = $vars['clientsdetails']['currency']; if ($clientcurrency == "1") { // GBP $exchangerate = Capsule::table('tblcurrencies')->where('code','HRK')->value('rate'); return array("exchangerate" => $exchangerate); } elseif ($clientcurrency == "13") { // USD $usdrate = Capsule::table('tblcurrencies')->where('code','USD')->value('rate'); $hrkrate = Capsule::table('tblcurrencies')->where('code','HRK')->value('rate'); $exchangerate = number_format(((1/$usdrate) * $hrkrate), 5); return array("exchangerate" => $exchangerate); } elseif ($clientcurrency == "14") { // EUR $eurrate = Capsule::table('tblcurrencies')->where('code','EUR')->value('rate'); $hrkrate = Capsule::table('tblcurrencies')->where('code','HRK')->value('rate'); $exchangerate = number_format(((1/$eurrate) * $hrkrate), 5); return array("exchangerate" => $exchangerate); } elseif ($clientcurrency == "15") { // HRK // do nothing - it is the secondary currency! } } add_hook("ClientAreaPageViewInvoice", 1, "hook_currency_exchange_rates"); ?> I should add that if I were writing this for a client, and if the second currency was always going to be HRK, I could cut this hook right down to it's bare bones (e.g remove all but one of these if statements) and it would be half the size... but as you said that you're not a programmer, and because I don't know exactly which currencies you have and which currency would be secondary for each of those currencies, i've tried to keep it simple and documented. so in my dev, 1=GBP; 13=USD; 14=EUR and 15=HRK, and so what this hook will do is for GBP clients, return the HRK exchange rate (because GBP is the default currency, that's just a basic query to the database); for USD & EUR clients, it will calculate and return their HRK exchange rate; for HRK clients, assuming that Croatian invoice rules means that you only need to show HRK prices for non-HRK currencies, it does nothing... you don't really need it in the code, but I left it in in case you need to do something else for HRK clients. in the template, you can also change your Smarty code from... {if $clientsdetails.currency eq "2"} ({math equation="x * y" x=$item.amount->toNumeric() y=$exchangerate format="%.2f"} HRK){/if} to... {if $exchangerate} ({math equation="x * y" x=$item.amount->toNumeric() y=$exchangerate format="%.2f"} HRK){/if} because now the logic of how to react to client currencies is in the hook and it is the hook that decides if and when the $exchangerate variable is returned to the template... so using the above hook as is, if the client used HRK, then $exchange rate would not be returned to the template and that Smarty if statement would be false... if they were USD customers, $exchange rate will be returned with the correct rate and the if statement true. as I said in the other thread, using the above method, you're going to run into a potential issue with paid invoices using today's exchange rate rather than the rate on the date of purchase - that's fixable in the hook, but could get quite involved coding wise, so I may return to that in the New Year when the batteries are fully recharged... even with unpaid invoices, that's still an issue - but a harder one to fix. hopefully the hook will give you the basis of a quieter seasonal break than you otherwise would have had... enjoy Christmas/New Year - I know that I intend to! 🎄
×

Important Information

By using this site, you agree to our Terms of Use & Guidelines