othellotech Posted September 3, 2007 Share Posted September 3, 2007 Summary counts of products sold (and live) by group ... <?php $reportdata["title"] = "Products Summary "; $reportdata["description"] = "Summary of Products Sold by Rob for www.OthelloTech.net"; $reportdata["tableheadings"] = array("Product Name","Monthly Count","Quarterly Count","Semi-Annual Count","Annual Count","Biennial Count","Total"); $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 = ""; $overalltotal = 0; while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $groupname = $data["groupname"]; $productname = $data["name"]; $monthly_count = 0; $quarterly_count = 0; $semiannually_count = 0; $annually_count = 0; $biannually_count = 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)) { $billingcycle = $data2["billingcycle"]; if($billingcycle=="Monthly") { $monthly_count=$monthly_count+1; } elseif($billingcycle=="Quarterly") { $quarterly_count=$quarterly_count+1; } elseif($billingcycle=="Semi-Annually") { $semiannually_count=$semiannually_count+1; } elseif($billingcycle=="Annually") { $annually_count=$annually_count+1; } elseif($billingcycle=="Biennially") { $biannually_count=$biannually_count+1; } } $total=( $monthly_count+$quarterly_count+$semiannually_count+$annually_count+$biannually_count ); if ($total >= "1") { if ($lastgroup != $groupname) { $lastgroup = $groupname ; $reportdata["tablevalues"][] = array("**[i]$groupname[/i]"); } $reportdata["tablevalues"][] = array("$productname","$monthly_count","$quarterly_count","$semiannually_count","$annually_count","$biannually_count","$total"); $overalltotal=$overalltotal+$total; } } $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_count = 0; $quarterly_count = 0; $semiannually_count = 0; $annually_count = 0; $biannually_count = 0; $total = 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)) { $billingcycle = $data2["billingcycle"]; if($billingcycle=="Monthly") { $monthly_count=$monthly_count+1; } elseif($billingcycle=="Quarterly") { $quarterly_count=$quarterly_count+1; } elseif($billingcycle=="Semi-Annually") { $semiannually_count=$semiannually_count+1; } elseif($billingcycle=="Annually") { $annually_count=$annually_count+1; } elseif($billingcycle=="Biennially") { $biannually_count=$biannually_count+1; } } $total=( $monthly_count+$quarterly_count+$semiannually_count+$annually_count+$biannually_count ); if ($total >= "1") { $reportdata["tablevalues"][] = array("$name","$monthly_count","$quarterly_count","$semiannually_count","$annually_count","$biannually_count","$total"); $overalltotal=$overalltotal+$total; } } $reportdata["tablevalues"][] = array("**[b]Domains[/b]"); $monthly_count = 0; $quarterly_count = 0; $semiannually_count = 0; $annually_count = 0; $biannually_count = 0; $query = "SELECT * FROM tbldomains WHERE status!='Expired'"; $result=mysql_query($query); while($data = mysql_fetch_array($result)) { $registrationperiod = $data["registrationperiod"]; $annually_count=$annually_count+1; } $total=( $monthly_count+$quarterly_count+$semiannually_count+$annually_count+$biannually_count ); $reportdata["tablevalues"][] = array("Domains","-","-","-","$annually_count","-","$total"); $overalltotal=$overalltotal+$total; $data["footertext"]="[b]Total Items:[/b] "."$overalltotal"; ?> 0 Quote Link to comment Share on other sites More sharing options...
Tech Entrance Posted September 18, 2007 Share Posted September 18, 2007 Nice work dude 0 Quote Link to comment Share on other sites More sharing options...
Beekingo Posted June 12, 2013 Share Posted June 12, 2013 Nice one, a great upgrade it would be a column with the total $ income generated by that product. 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.