Jump to content

smplejohn

Member
  • Posts

    4
  • Joined

  • Last visited

About smplejohn

smplejohn's Achievements

Junior Member

Junior Member (1/3)

0

Reputation

  1. I've been working on a script to figure out the yearly projected sales like the income forecast on the dashboard and since making it I've been having trouble getting the two numbers to match up. I feel my script is pretty encompassing and more thorough, so now I'm wondering if WHMCS' income forecast is correct. Here's the script I'm trying to use: // Total Annual Revenue $total = 0; $breakdown = array(); $stmt = $db->prepare('SELECT * FROM tblhosting WHERE domainstatus="Active" OR domainstatus="Suspended"'); $stmt->execute(); while($r = $stmt->fetch()){ $cycle = $r['billingcycle']; $amount = $r['amount']; switch($cycle){ case "Monthly": $yearly = $amount * 12; $breakdown['monthly'] = $breakdown['monthly'] + $amount; $breakdown['monthlycount'] = $breakdown['monthlycount'] + 1; break; case "Quarterly": $yearly = $amount * 4; $breakdown['quarterly'] = $breakdown['quarterly'] + $amount; $breakdown['quarterlycount'] = $breakdown['quarterlycount'] + 1; break; case "Semi-Annually": $yearly = $amount * 2; $breakdown['semiannually'] = $breakdown['semiannually'] + $amount; $breakdown['semiannuallycount'] = $breakdown['semiannuallycount'] + 1; break; case "Annually": $yearly = $amount; $breakdown['annually'] = $breakdown['annually'] + $amount; $breakdown['annuallycount'] = $breakdown['annuallycount'] + 1; break; case "Biennially": $yearly = $amount/2; $breakdown['biannually'] = $breakdown['biannually'] + $amount; $breakdown['biannuallycount'] = $breakdown['biannuallycount'] + 1; break; case "Triennially": $yearly = $amount/3; $breakdown['triannually'] = $breakdown['triannually'] + $amount; $breakdown['triannuallycount'] = $breakdown['triannuallycount'] + 1; break; default: $yearly = $amount; $breakdown['default'] = $breakdown['default'] + $amount; $breakdown['defaultcount'] = $breakdown['defaultcount'] + 1; break; } $total = $total + $yearly; } $stmt = $db->prepare('SELECT * FROM tblhostingaddons WHERE status="Active" OR status="Suspended"'); $stmt->execute(); while($r = $stmt->fetch()){ $cycle = $r['billingcycle']; $amount = $r['recurring']; switch($cycle){ case "Monthly": $yearly = $amount * 12; $breakdown['monthly'] = $breakdown['monthly'] + $amount; break; case "Quarterly": $yearly = $amount * 4; $breakdown['quarterly'] = $breakdown['quarterly'] + $amount; break; case "Semi-Annually": $yearly = $amount * 2; $breakdown['semiannually'] = $breakdown['semiannually'] + $amount; break; case "Annually": $yearly = $amount; $breakdown['annually'] = $breakdown['annually'] + $amount; break; case "Biennially": $yearly = $amount/2; $breakdown['biannually'] = $breakdown['biannually'] + $amount; break; case "Triennially": $yearly = $amount/3; $breakdown['triannually'] = $breakdown['triannually'] + $amount; break; default: $yearly = $amount; $breakdown['default'] = $breakdown['default'] + $amount; break; } $total = $total + $yearly; } $yearlyProducts = $total; $yearlyProductTotal = number_format($total,2); $total = 0; $stmt = $db->prepare('SELECT * FROM tbldomains WHERE status="Active"'); $stmt->execute(); while($r = $stmt->fetch()){ $amount = $r['recurringamount']; $cycle = $r['registrationperiod']; $yearly = $amount/$cycle; $breakdown['domains'] = $breakdown['domains'] + $amount; $breakdown['domainscount'] = $breakdown['domainscount'] + 1; $total = $total + $yearly; } $yearlyDomains = $total; $yearlyDomainTotal = number_format($total,2); $yearlyTotal = number_format($yearlyProducts + $yearlyDomains,2,".",","); echo "Monthly: $" . number_format($breakdown['monthly'],2,'.',',') . " (" . $breakdown['monthlycount'] . ")<br />"; echo "Quarterly: $" . number_format($breakdown['quarterly'],2,'.',',') . " (" . $breakdown['quarterlycount'] . ")<br />"; echo "Semi-Annually: $" . number_format($breakdown['semiannually'],2,'.',',') . " (" . $breakdown['semiannuallycount'] . ")<br />"; echo "Annually: $" . number_format($breakdown['annually'],2,'.',',') . " (" . $breakdown['annuallycount'] . ")<br />"; echo "Biennially: $" . number_format($breakdown['biannually'],2,'.',',') . " (" . $breakdown['biannuallycount'] . ")<br />"; echo "Triennially: $" . number_format($breakdown['triannually'],2,'.',',') . " (" . $breakdown['triannuallycount'] . ")<br />"; echo "One Time: $" . number_format($breakdown['default'],2,'.',',') . " (" . $breakdown['defaultcount'] . ")<br />"; echo "Domains: $" . number_format($breakdown['domains'],2,'.',',') . " (" . $breakdown['domainscount'] . ")<br />"; echo "Estimated Annual: $yearlyTotal"; exit(); And if you want to compare to WHMCS' queries you can look at the income_forecast.php file. I also have a ticket open because I believe WHMCS' file may be off. Any thoughts on what I may be missing here?
  2. Like the title says, I got tired of seeing Active and Non-Active products mixed in with each other, so this small hook reorders the dropdown into the <optgroup> tag for Active and Non-Active Products. Here's what it'll look like: And... here's the code for the hook: <?php add_hook('AdminAreaFooterOutput', 1, function($vars) { if ($vars['filename'] == 'clientsservices'){ return " <script> $(document).ready(function(){ var active; var nonactive; var i = 0; var total = $('#frm2 select[name=id] option').length; $('#frm2 select[name=id] option').each(function(){ if ($(this).attr('style').indexOf('#FFF') > 0) { active = active + $(this).context.outerHTML; } else { nonactive = nonactive + $(this).context.outerHTML; } i++; if (i == total) { $('#frm2 select[name=id]').html(\"<optgroup label='Active'>\" + active + \"</optgroup><optgroup label='Non-Active'>\" + nonactive + \"</optgroup>\"); } }); }); </script> "; } }); I created a new file under /includes/hooks/hook_betterClientProducts.php Enjoy
  3. Just like the title says, I'm trying to access the variables assigned in a module within the hook I have set up in the module folder. I can't find any documentation on that and am at a loss. Any suggestions?
  4. So, I wanted to get some feedback from everyone before I release the first version of this module I've been working on. I have multiple installs of WHMCS across brands and wanted a quick way to access all the support tickets & pending orders in one place. Thus, the "Multidashboard" was born. Here's what I have so far: You enter a string with credentials for an outside install's API. The Addon automatically pulls the current install and any outside APIs into a centralized dashboard all mixed together and sorted by date. If it's more than a day old it's marked yellow, more than 2 days is red. You can click on the link to the ticket or user on the other install and it will take you there. All departments are also pulled and merged (if named the same) so you can filter and sort by departments. Pending orders are shown in a separate tab, again all mixed by date. If you have multiple installs of WHMCS is this something you feel you could use and are there any additional features you'd like to see before I put this in the wild?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated