Jump to content

Report: Product Summary v0.1


othellotech

Recommended Posts

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";

?>

Link to comment
Share on other sites

  • 3 weeks later...
  • 5 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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