示例#1
0
function render_yearSelectionFrm($intYear)
{
    if (getAnimationState() == "1") {
        $animateYes = "checked";
        $animateNo = "";
    } else {
        $animateYes = "";
        $animateNo = "checked";
    }
    // Function to connect to the DB
    $link = connectToDB();
    //Retrieve the years
    $strSQL = "SELECT DISTINCT YEAR(OrderDate) As Year FROM FC_Orders ORDER BY 1";
    $result = mysql_query($strSQL) or die(mysql_error());
    //Render them in drop down box
    $strYears = "";
    if ($result) {
        while ($ors = mysql_fetch_array($result)) {
            if ($intYear == $ors['Year']) {
                $checked = "checked";
            } else {
                $checked = "";
            }
            $strYears .= "<input type='radio' name='year' value='" . $ors['Year'] . "' " . $checked . "><span class='text'>" . $ors['Year'] . "</span>";
        }
    }
    mysql_close($link);
    $htmldata = <<<HTMLINFO

<!-- Code to render the form for year selection and animation selection -->
<tr>
\t<td width="33">\t\t
\t</td>
\t<td height="1" colspan="2" bgColor="#FFFFFF">
\t</td>
\t<td width="37">\t\t
\t</td>
</tr>

<form name="frmYr" action="Default.php" method="post" id="frmYr">
<tr height="30">
\t<td width="33">\t\t
\t</td>
\t<td height="22" colspan="2" align="center" bgColor="#EEEEEE" valign="middle">
\t<nobr>
\t<span class="textbolddark">Select Year: </span>
{$strYears}
\t<span class="textbolddark"><span class='text'>&nbsp;&nbsp;&nbsp;</span>Animate Charts: </span>

    <input type="radio" name="animate" value="1" {$animateYes}><span class="text">Yes</span>
\t<input type="radio" name="animate" value="0" {$animateNo}><span class="text">No</span>

    <span class='text'>&nbsp;&nbsp;</span>
\t<input type="submit" class="button" value="Go" id="submit" 1 name="submit" 1>
\t
\t</nobr>\t
\t</td>
\t<td width="37">\t\t
\t</td>
</tr>
</form>\t

<tr>
\t<td width="33">\t\t
\t</td>
\t<td height="1" colspan="2" bgColor="#FFFFFF">
\t</td>
\t<td width="37">\t\t
\t</td>
</tr>

<tr>
\t<td width="33">\t\t
\t</td>
\t<td height="1" colspan="2" bgColor="#EEEEEE">
\t</td>
\t<td width="37">\t\t
\t</td>
</tr>
<!-- End code to render form -->

HTMLINFO;
    return $htmldata;
}
if (!isset($_GET['year']) || $_GET['year'] == "") {
    $intYear = 1996;
} else {
    $intYear = $_GET['year'];
}
//Render page headers
echo render_pageHeader();
//Render the main table open
echo render_pageTableOpen();
?>
<table width='875' align='center' cellspacing='0' cellpadding='0'>
	<tr>
	<td align='center'>
	<?php 
//Generate the XML data for the main pie chart.
$strXML = "<chart caption='Sales By Country for " . $intYear . "' palette='" . getPalette() . "' animation='" . getAnimationState() . "' formatNumberScale='0' numberPrefix='\$' labeldisplay='ROTATE' slantLabels='1' seriesNameInToolTip='0' sNumberSuffix=' pcs.' showValues='0' plotSpacePercent='0'>";
$strXML .= getSalesByCountryXML($intYear, -1, true, false);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
echo renderChart("FusionCharts/MSColumn3DLineDY.swf", "", $strXML, "NewChart", 850, 300, false, false);
?>
	</td>
	</tr>
</table>

<?php 
//Separator line
echo drawSepLine();
?>
	
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the sales data for customers in a country for the given year
//To this page, we're provided country and year
$intYear = $_GET['year'];
$country = $_GET['country'];
//XML Data container
$strXML = "<chart caption='" . $country . " - Customer wise Sales Figure for " . $intYear . "' xAxisName='Customer' palette='1' animation='" . getAnimationState() . "' formatNumberScale='0' numberPrefix='\$' labeldisplay='ROTATE' slantLabels='1' seriesNameInToolTip='0' sNumberSuffix=' pcs.' showValues='0' showBorder='1' showLegend='0'>";
//Add the data
$strXML .= getSalesByCountryCustomerXML($intYear, $country, true);
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='13' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the inventory by product data for a given category.
$strCat = $_GET['category'];
//XML Data container
$strXML = "<chart caption='" . $strCat . " - Inventory by Products' PYAxisName='Cost of Inventory' SYAxisName='Units in Inventory' xAxisName='Products' palette='" . getPalette() . "' animation='" . getAnimationState() . "' showValues='0' formatNumberScale='0' numberPrefix='\$' labelDisplay='STAGGER' seriesNameInToolTip='0'>";
//Add the data
$strXML .= getInventoryByProdXML($strCat, true);
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
?>
);"><OPTION value='5'>5<OPTION value='10'>10<OPTION value='20'>20<OPTION value='30'>30</SELECT>&nbsp;&nbsp;Expensive Products</span>
</FORM>
</CENTER>
<?php 
//Separator line
echo drawSepLine();
?>
	


<table width='875' align='center' cellspacing='0' cellpadding='0'>
	<tr>
	<td align='center'>
	<?php 
$strXML = "<chart caption='" . $intYear . " - Top 5 Cities By Sales ' palette='" . getPalette() . "' animation='" . getAnimationState() . "' formatNumberScale='0' numberPrefix='\$' seriesNameInToolTip='0' sNumberSuffix=' pcs.' showValues='0' plotSpacePercent='0' labelDisplay='STAGGER'>";
$strXML .= getSalesByCityXML($intYear, 5, false);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
echo renderChart("FusionCharts/Column3D.swf", "", $strXML, "TopCities", 700, 250, false, true);
?>
	</td>
	</tr>
</table>

<?php 
//Separator line
echo drawSepLine();
?>
	
//If year has not been provided, we default to 1996
if (!isset($_GET['year']) || $_GET['year'] == "") {
    $intYear = 1996;
} else {
    $intYear = $_GET['year'];
}
//Render page headers
echo render_pageHeader();
//Render the main table open
echo render_pageTableOpen();
?>
<table width='875' align='center' cellspacing='0' cellpadding='0'>
	<tr>
	<td align='center'>
	<?php 
$strXML = "<chart caption='Sales By Category for " . $intYear . "' palette='" . getPalette() . "' animation='" . getAnimationState() . "' formatNumberScale='0' PYAXisName='Revenue' SYAxisName='Units Sold' numberPrefix='\$' labeldisplay='STAGGER' seriesNameInToolTip='0' showValues='0' plotSpacePercent='0'>";
$strXML .= getYrlySalesByCatXML($intYear, true, false);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
echo renderChart("FusionCharts/MSColumn3DLineDY.swf", "", $strXML, "CatCum", 850, 300, false, false);
?>
	</td>
	</tr>
</table>

<?php 
//Separator line
echo drawSepLine();
?>
	
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the sales by product data for a given category for a given year
$intYear = $_GET['year'];
$intCatId = $_GET['catId'];
//XML Data container
$strXML = "<chart caption='" . getCategoryName($intCatId) . " - Product wise sales in " . $intYear . "' PYAXisName='Revenue' SYAxisName='Units Sold' xAxisName='Products' palette='" . getPalette() . "' animation='" . getAnimationState() . "' showValues='0' formatNumberScale='0' numberPrefix='\$' labelDisplay='STAGGER' seriesNameInToolTip='0'>";
//Add the data
$strXML .= getSalesByProdCatXML($intYear, $intCatId, true);
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This page outputs the sales by category XML data for the the specified year.
//Request the year for which we've to show data.
//If year has not been provided, we default to 1996
if (!isset($_GET['year']) || $_GET['year'] == "") {
    $intYear = 1996;
} else {
    $intYear = $_GET['year'];
}
$strXML = "<chart caption='Category wise Sales for " . $intYear . "' subcaption='(Click on a column to see monthly sales for that category in the chart below this)' XAxisName='Month' palette='" . getPalette() . "' animation='" . getAnimationState() . "' formatNumberScale='0' numberPrefix='\$' showValues='0' numDivLines='4' legendPosition='BOTTOM'>";
$strXML .= getCumulativeSalesByCatXML($intYear, true);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' color='" . getCaptionFontColor() . "' size='15' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Write the XML data to output stream - WITHOUT ANY HTML Tag.
header('Content-type: text/xml');
echo $strXML;
	}
	</SCRIPT>
	<LINK REL='stylesheet' HREF='Style.css' />
</HEAD>
<BODY topmargin='0' leftmargin='0' bottomMargin='0' rightMargin='0' bgColor='#EEEEEE'>
<?php 
//Render page headers
echo render_pageHeader();
//Render the main table open
echo render_pageTableOpen();
?>
<table width='875' align='center' cellspacing='0' cellpadding='0'>
	<tr>
	<td align='center'>
	<?php 
$strXML = "<chart caption='Inventory by Product Categories' subcaption='(Click on a category to see product-wise details)' PYAxisName='Cost of Inventory' SYAxisName='Units in Inventory' xAxisName='Product Category' palette='" . getPalette() . "' animation='" . getAnimationState() . "' showValues='0' formatNumberScale='0' numberPrefix='\$' labelDisplay='STAGGER' seriesNameInToolTip='0'>";
$strXML .= getInventoryByCatXML(true, false);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
echo renderChart("FusionCharts/MSColumn3DLineDY.swf", "", $strXML, "ByCategory", 800, 300, false, false);
?>
	</td>
	</tr>
</table>

<?php 
//Separator line
echo drawSepLine();
?>
	
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the top n employees  and their sales quantity for a given year.
//To this page, we're provided year and count
$intYear = $_GET['year'];
$count = $_GET['count'];
//XML Data container
$strXML = "<chart caption='Top 5 Employees for " . $intYear . "' palette='" . getPalette() . "' animation='" . getAnimationState() . "' subCaption='(Click to slice out or right click to choose rotation mode)' YAxisName='Sales Achieved' YAxisName='Quantity' showValues='0' numberPrefix='\$' formatNumberScale='0' showPercentInToolTip='0'>";
$strXML .= getSalePerEmpXML($intYear, $count, false, false, true);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the number of orders the employee processes yearly data as XML.
//To this page, we're provided employeed Id.
$eId = $_GET['id'];
//XML Data container
$strXML = "<chart caption='Number of Orders - " . getEmployeeName($eId) . "' xAxisName='Year' palette='" . getPalette() . "' animation='" . getAnimationState() . "' >";
//Get the data for employee for 3 years - 1994,95,96
$strXML .= "<set label='1994' value='" . getNumOrders($eId, 1994) . "' />";
$strXML .= "<set label='1995' value='" . getNumOrders($eId, 1995) . "' />";
$strXML .= "<set label='1996' value='" . getNumOrders($eId, 1996) . "' />";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
function getNumOrders($eId, $intYear)
{
    // Function to connect to the DB
    $link = connectToDB();
    //Retrieve the data
    $strSQL = "SELECT Count(OrderID) As Total FROM FC_Orders WHERE YEAR(OrderDate)=" . $intYear . " and EmployeeID=" . $eId;
    $result = mysql_query($strSQL) or die(mysql_error());
    if ($result) {
        if (mysql_num_rows($result) > 0) {
            $ors = mysql_fetch_array($result);
            $getNumOrders = $ors['Total'];
        } else {
            $getNumOrders = 0;
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the top n customers  and their purchase quantity for a given year.
//To this page, we're provided year and count
$intYear = $_GET['year'];
$count = $_GET['count'];
//XML Data container
//We do a conditional label formatting
//If number of items to show on chart is less than 10, we wrap them
//else we show as rotated
if ($count > 10) {
    $labelFormatting = " labelDisplay='ROTATE' slantLabels='1' ";
} else {
    $labelFormatting = " labelDisplay='WRAP' ";
}
$strXML = "<chart caption='Top " . $count . " Customers for " . $intYear . "' palette='" . getPalette() . "' animation='" . getAnimationState() . "' PYAxisName='Amount' SYAxisName='Quantity' showValues='0' numberPrefix='\$' sNumberSuffix=' pcs.' seriesNameInToolTip='0' formatNumberScale='0' " . $labelFormatting . ">";
$strXML .= getTopCustomersXML($intYear, $count, true);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;
<?php

include "Includes/Connection_inc.php";
include "Includes/Functions.php";
include "DataGen.php";
//This method writes the top n expensive items and its sales quantity for a given year.
//To this page, we're provided year and count
$intYear = $_GET['year'];
$count = $_GET['count'];
//We do a conditional label formatting
//If number of items to show on chart is less than 10, we wrap them
//else we show as rotated
if ($count > 10) {
    $labelFormatting = " labelDisplay='ROTATE' slantLabels='1' ";
} else {
    $labelFormatting = " labelDisplay='WRAP' ";
}
//XML Data container
$strXML = "<chart caption='Sale of " . $count . " Most Expensive Products for " . $intYear . "' PYAxisName='Unit Price' SYAxisName='Units Sold for the year' palette='" . getPalette() . "' animation='" . getAnimationState() . "' formatNumberScale='0' numberPrefix='\$' seriesNameInToolTip='0' sNumberSuffix=' pcs.' showValues='0' plotSpacePercent='0' " . $labelFormatting . ">";
$strXML .= getExpensiveProdXML($intYear, $count, true);
//Add some styles to increase caption font size
$strXML .= "<styles><definition><style type='font' name='CaptionFont' size='15' color='" . getCaptionFontColor() . "' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
$strXML .= "</chart>";
//Output it
header('Content-type: text/xml');
echo $strXML;