othellotech Posted August 28, 2007 Share Posted August 28, 2007 Similar to the WHMCS recurring income report with the following mods.... 1. it includes biennial income column and 1/2 of that amount in the annual totals 2. it correctly shows the addons rather than repeating the last server over ad over 3. it gets the amounts for the domains rather than showing 0.00 4. it ignores products you've not sold any of 5. takes up less paper by having product group headings rather than duplicating the group on each line save in your reports folder as projected_income.php <?php $reportdata["title"] = "Projected Income Summary "; $reportdata["description"] = "Recurring Income by Active Product / Income Projection by Rob for www.OthelloTech.net"; $reportdata["tableheadings"] = array("Item Name","Monthly Revenue","Quarterly Revenue","Semi-Annual Revenue","Annual Revenue","Biennial Revenue","Total Yearly Revenue"); $reportdata["tablevalues"][] = array("**[b]Products/Services[/b]"); $query = "SELECT tblproducts.*,tblproductgroups.name AS groupname FROM tblproducts INNER JOIN tblproductgroups ON tblproductgroups.id = tblproducts.gid ORDER BY name ASC"; $result=mysql_query($query); $lastgroup = ""; while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $groupname = $data["groupname"]; $productname = $data["name"]; $monthly = 0; $monthlycost = 0; $quarterly = 0; $semiannually = 0; $annually = 0; $biannually = 0; $total = 0; $query2 = "SELECT * FROM tblhosting WHERE domainstatus!='Terminated' AND billingcycle!='Free Account' AND billingcycle!='One Time' AND packageid='$id'"; $result2 = mysql_query($query2); while ($data2 = mysql_fetch_array($result2)) { $amount = $data2["amount"]; $billingcycle = $data2["billingcycle"]; if($billingcycle=="Monthly") { $monthly=$monthly+$amount; } elseif($billingcycle=="Quarterly") { $quarterly=$quarterly+$amount; } elseif($billingcycle=="Semi-Annually") { $semiannually=$semiannually+$amount; } elseif($billingcycle=="Annually") { $annually=$annually+$amount; } elseif($billingcycle=="Biennially") { $biannually=$biannually+$amount; } } $monthly=number_format($monthly,2,".",""); $quarterly=number_format($quarterly,2,".",""); $semiannually=number_format($semiannually,2,".",""); $annually=number_format($annually,2,".",""); $biannually=number_format($biannually,2,".",""); //RDG Note //Where does it get $monthlycost from ??? $servertotal=number_format( ( ($monthly*12)+($quarterly*4)+($semiannually*2)+$annually+($biannually/2) - ($monthlycost*12) ) ,2,".",""); $overalltotal=$overalltotal+$servertotal; if ($servertotal >= "0.01") { if ($lastgroup != $groupname) { $lastgroup = $groupname ; $reportdata["tablevalues"][] = array("**[i]$groupname[/i]"); } $reportdata["tablevalues"][] = array("$productname",$CONFIG["CurrencySymbol"]."$monthly",$CONFIG["CurrencySymbol"]."$quarterly",$CONFIG["CurrencySymbol"]."$semiannually",$CONFIG["CurrencySymbol"]."$annually",$CONFIG["CurrencySymbol"]."$biannually",$CONFIG["CurrencySymbol"]."$servertotal"); } } $reportdata["tablevalues"][] = array("**[b]Products Addons[/b]"); $query = "SELECT DISTINCT name FROM tblhostingaddons WHERE status!='Terminated' AND billingcycle!='One Time' AND billingcycle!='Free'"; $result = mysql_query($query); while($data = mysql_fetch_array($result)) { $name = $data["name"]; $monthly = 0; $quarterly = 0; $semiannually = 0; $annually = 0; $biannually = 0; $annualtotal = 0; $query2 = "SELECT * FROM tblhostingaddons WHERE name='".$name."' AND status!='Terminated' AND billingcycle!='One Time' AND billingcycle!='Free'"; $result2 = mysql_query($query2); while($data2 = mysql_fetch_array($result2)) { $amount = $data2["recurring"]; $billingcycle = $data2["billingcycle"]; if($billingcycle=="Monthly") { $monthly=$monthly+$amount; } elseif($billingcycle=="Quarterly") { $quarterly=$quarterly+$amount; } elseif($billingcycle=="Semi-Annually") { $semiannually=$semiannually+$amount; } elseif($billingcycle=="Annually") { $annually=$annually+$amount; } elseif($billingcycle=="Biennially") { $biannually=$biannually+$amount; } } $monthly=number_format($monthly,2,".",""); $quarterly=number_format($quarterly,2,".",""); $semiannually=number_format($semiannually,2,".",""); $annually=number_format($annually,2,".",""); $biannually=number_format($biannually,2,".",""); $servertotal=number_format( ( ($monthly*12)+($quarterly*4)+($semiannually*2)+$annually+($biannually/2) ) ,2,".",""); $overalltotal=$overalltotal+$servertotal; if ($servertotal >= "0.01") { $reportdata["tablevalues"][] = array("$name",$CONFIG["CurrencySymbol"]."$monthly",$CONFIG["CurrencySymbol"]."$quarterly",$CONFIG["CurrencySymbol"]."$semiannually",$CONFIG["CurrencySymbol"]."$annually",$CONFIG["CurrencySymbol"]."$biannually",$CONFIG["CurrencySymbol"]."$servertotal"); } } $reportdata["tablevalues"][] = array("**[b]Domains[/b]"); $annually = 0; $query = "SELECT * FROM tbldomains WHERE status!='Expired'"; $result=mysql_query($query); while($data = mysql_fetch_array($result)) { $amount = $data["recurringamount"]; $registrationperiod = $data["registrationperiod"]; if ($registrationperiod < 1) { $registrationperiod=1; } $annually=$annually+($amount/$registrationperiod); } $annually=number_format($annually,2,".",""); $servertotal=number_format($annually,2,".",""); $overalltotal=$overalltotal+$servertotal; $reportdata["tablevalues"][] = array("Domains","-","-","-",$CONFIG["CurrencySymbol"]."$annually","-",$CONFIG["CurrencySymbol"]."$servertotal"); $overalltotal=number_format($overalltotal,2,".",""); $data["footertext"]="[b]Total Income:[/b] ".$CONFIG["CurrencySymbol"].$overalltotal; ?> 0 Quote Link to comment Share on other sites More sharing options...
Santo Posted August 28, 2007 Share Posted August 28, 2007 Perfect! thank you for a job well done. It will come in handy this report. Cheers, 0 Quote Link to comment Share on other sites More sharing options...
PPH Posted August 28, 2007 Share Posted August 28, 2007 Thanks for the report contrib 0 Quote Link to comment Share on other sites More sharing options...
lainard Posted August 28, 2007 Share Posted August 28, 2007 Nice contrib Thanks alot 0 Quote Link to comment Share on other sites More sharing options...
Dominic Posted August 28, 2007 Share Posted August 28, 2007 Very nice, thanks 0 Quote Link to comment Share on other sites More sharing options...
DavidJ Posted September 30, 2007 Share Posted September 30, 2007 Very nice, thank you for the report I must admit I came into the thread thinking it was some sort of 'projection' system that would calculate some averages & 'guess' how much you would be making by such-and-such a date. But this is fairly nice, it's cool to have more details like on this report 0 Quote Link to comment Share on other sites More sharing options...
raaqi Posted October 8, 2007 Share Posted October 8, 2007 nice report. thanks! 0 Quote Link to comment Share on other sites More sharing options...
G Swanepoel Posted October 23, 2007 Share Posted October 23, 2007 Hi Guys, I posted a topic two weeks ago but no reply. Maybe you can help. I need a simple report. Well easy for you but impossible for me. All I want is the following query :SELECT * FROM `tblinvoices` WHERE `tax` <> 0 AND `status` = 'paid': with totals on 'subtotal' 'total' and 'tax' all in a nice report. Please note that I am a newby with no experience in php. Any help will me apreciated. Thanks Swannie 0 Quote Link to comment Share on other sites More sharing options...
G Swanepoel Posted October 23, 2007 Share Posted October 23, 2007 WOW do I feel like an IDIOT. The report I wanted help with is already in the report section under a different name. Changed it slightly and it works fine. I know now why no one replied....... One thing though, is it possible to give my accountant access to the reports without giving him access to the rest of WHMCS? Swannie 0 Quote Link to comment Share on other sites More sharing options...
Tech Entrance Posted November 11, 2007 Share Posted November 11, 2007 WOW do I feel like an IDIOT. The report I wanted help with is already in the report section under a different name. Changed it slightly and it works fine. I know now why no one replied....... One thing though, is it possible to give my accountant access to the reports without giving him access to the rest of WHMCS? Swannie Export the report in MS access file (CSV) or print it and hand it to him :wink: 0 Quote Link to comment Share on other sites More sharing options...
amnesia Posted January 28, 2008 Share Posted January 28, 2008 can you create one more row at the bottom of this report to total the income and then break it down (monthly, quarterly, ect.)?? I would do it myself, but have no idea how. 0 Quote Link to comment Share on other sites More sharing options...
tqhosting Posted January 20, 2010 Share Posted January 20, 2010 Hi, I've tried to modify this report, unfortunately I'm not familiar enough with the code to be able to do it successfully. This report is pretty much what we're looking for, but I would like it to display ONLY the product groups, not each individual product and only the product group's revenue total for each billing cycle (not just yearly total but broken down by each billing cycle). I've attempted to take out this line:$productname = $data["name"]; but it still displays each line item just without the name. Is this possible? I'm sure it is, I'm just too stupid to figure it out 0 Quote Link to comment Share on other sites More sharing options...
tqhosting Posted January 22, 2010 Share Posted January 22, 2010 (edited) OK, I've gotten it to sort by Product Group. I found an error in the way it calculated monthly totals. it added several hundred over what it should actually be, so I corrected that, and I also noticed the "Biennially" functions were all mis-spelled as "Biannually" so that field wasn't calculating at all. Here is the updated code for that: <?php $reportdata["title"] = "Product Group Income "; $reportdata["description"] = "Modified by KT"; $reportdata["tableheadings"] = array("Product Group","Monthly","Quarterly","Semi-Annual","Annual","Biennial","Total Yearly Income"); $query = "SELECT tblproducts.*,tblproductgroups.name AS groupname FROM tblproducts INNER JOIN tblproductgroups ON tblproductgroups.id = tblproducts.gid ORDER BY groupname ASC"; $result=mysql_query($query); $lastgroup = ""; $result=mysql_query($query); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $groupname = $data["groupname"]; $productname = $data["name"]; $monthly = 0; $quarterly = 0; $semiannually = 0; $annually = 0; $biennially = 0; $total = 0; $query2 = "SELECT * FROM tblhosting WHERE (domainstatus='Active' OR domainstatus='Suspended') AND billingcycle!='Free Account' AND billingcycle!='One Time' AND packageid='$id'"; $result2=mysql_query($query2); while($data = mysql_fetch_array($result2)){ $amount = $data["amount"]; $billingcycle = $data["billingcycle"]; if($billingcycle=="Monthly"){ $monthly=$monthly+$amount; }elseif($billingcycle=="Quarterly"){ $quarterly=$quarterly+$amount; }elseif($billingcycle=="Semi-Annually"){ $semiannually=$semiannually+$amount; }elseif($billingcycle=="Annually"){ $annually=$annually+$amount; }elseif($billingcycle=="Biennially"){ $biennially=$biennially+$amount; } } $monthly=number_format($monthly,2,".",""); $quarterly=number_format($quarterly,2,".",""); $semiannually=number_format($semiannually,2,".",""); $annually=number_format($annually,2,".",""); $biennially=number_format($biennially,2,".",""); //RDG Note //Where does it get $monthlycost from ??? $servertotal=number_format( ( ($monthly*12)+($quarterly*4)+($semiannually*2)+$annually+($biennially/2) - ($monthlycost*12) ) ,2,".",""); $overalltotal=$overalltotal+$servertotal; if ($servertotal >= "0.01") { if ($lastgroup != $groupname) { $lastgroup = $groupname ; $reportdata["tablevalues"][] = array("**$groupname"); } $reportdata["tablevalues"][] = array("$productname",$CONFIG["CurrencySymbol"]."$monthly",$CONFIG["CurrencySymbol"]."$quarterly",$CONFIG["CurrencySymbol"]."$semiannually",$CONFIG["CurrencySymbol"]."$annually",$CONFIG["CurrencySymbol"]."$biennially",$CONFIG["CurrencySymbol"]."$servertotal"); } } $reportdata["tablevalues"][] = array("**Products Addons"); $query = "SELECT DISTINCT name FROM tblhostingaddons WHERE status!='Terminated' AND billingcycle!='One Time' AND billingcycle!='Free'"; $result = mysql_query($query); while($data = mysql_fetch_array($result)) { $name = $data["name"]; $monthly = 0; $quarterly = 0; $semiannually = 0; $annually = 0; $biennially = 0; $annualtotal = 0; $query2 = "SELECT * FROM tblhostingaddons WHERE name='".$name."' AND status!='Terminated' AND billingcycle!='One Time' AND billingcycle!='Free'"; $result2 = mysql_query($query2); while($data2 = mysql_fetch_array($result2)) { $amount = $data2["recurring"]; $billingcycle = $data2["billingcycle"]; if($billingcycle=="Monthly") { $monthly=$monthly+$amount; } elseif($billingcycle=="Quarterly") { $quarterly=$quarterly+$amount; } elseif($billingcycle=="Semi-Annually") { $semiannually=$semiannually+$amount; } elseif($billingcycle=="Annually") { $annually=$annually+$amount; } elseif($billingcycle=="Biennially") { $biennially=$biennially+$amount; } } $monthly=number_format($monthly,2,".",""); $quarterly=number_format($quarterly,2,".",""); $semiannually=number_format($semiannually,2,".",""); $annually=number_format($annually,2,".",""); $biennially=number_format($biennially,2,".",""); $servertotal=number_format( ( ($monthly*12)+($quarterly*4)+($semiannually*2)+$annually+($biennially/2) ) ,2,".",""); $overalltotal=$overalltotal+$servertotal; if ($servertotal >= "0.01") { $reportdata["tablevalues"][] = array("$name",$CONFIG["CurrencySymbol"]."$monthly",$CONFIG["CurrencySymbol"]."$quarterly",$CONFIG["CurrencySymbol"]."$semiannually",$CONFIG["CurrencySymbol"]."$annually",$CONFIG["CurrencySymbol"]."$biennially",$CONFIG["CurrencySymbol"]."$servertotal"); } } $reportdata["tablevalues"][] = array("**Domains"); $annually = 0; $query = "SELECT * FROM tbldomains WHERE status!='Expired'"; $result=mysql_query($query); while($data = mysql_fetch_array($result)) { $amount = $data["recurringamount"]; $registrationperiod = $data["registrationperiod"]; if ($registrationperiod < 1) { $registrationperiod=1; } $annually=$annually+($amount/$registrationperiod); } $annually=number_format($annually,2,".",""); $servertotal=number_format($annually,2,".",""); $overalltotal=$overalltotal+$servertotal; $reportdata["tablevalues"][] = array("Domains","-","-","-",$CONFIG["CurrencySymbol"]."$annually","-",$CONFIG["CurrencySymbol"]."$servertotal"); $overalltotal=number_format($overalltotal,2,".",""); $data["footertext"]="Total Income: ".$CONFIG["CurrencySymbol"].$overalltotal; ?> The only thing I would like to see now is a total of each group column: Eg: Product Group Monthly service $9.00 service $9.00 Totals $18.00 can someone help with this? Edited January 22, 2010 by tqhosting 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted January 23, 2010 Author Share Posted January 23, 2010 I also noticed the "Biennially" functions were all mis-spelled as "Biannually" field *name* is irrelevant as long as its constant, i could have called it "arthur" if i'd wanted 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted January 26, 2010 Share Posted January 26, 2010 Does it support multiple currencies? 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted January 26, 2010 Author Share Posted January 26, 2010 Does it support multiple currencies? multi-ccy didnt exist when i created this (and other) reports, and isnt something we use, so no but feel free to improve it as necessary 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.