<?php
set_time_limit(999999);
$year=$_GET['year'];
if(!$year)$year=(int)date("Y");
if(!$_REQUEST['no'])$_REQUEST['no']=30;

if($year==date(Y)){
	$mmm=(int)date("m")-1;
}
else $mmm=12;
$category=$_GET['category'];
if(!$category){
	$r=mysql_fetch_array(mysql_query("select id from ecmproductcategories where deleted='0' order by name asc limit 1"));
	$category=$r['id'];
}
if(!$_REQUEST['show'])$_REQUEST['show']="sales";
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Charts: Top Products </h2></td></tr></table><br />
<ul class="tablist" style="width:1024px;">
<li>
	<a class="current" href="#">Basic Search</a>
</li>		
</ul>
<form action="index.php" method="get">
<input type="hidden" name="module" value="EcmCharts" />
<input type="hidden" name="action" value="index4" />
<input type="hidden" name="x" id="x" value="0" />
<input type="hidden" name="y" id="y" value="0" />
<table style="border-top: 0px none; margin-bottom: 4px;width:1024px;" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
	<tr>			
		<td class="dataLabel" width="10%" nowrap="nowrap">Year</td>
		<td class="dataField" width="30%" nowrap="nowrap">
			<select name="year" id="year">
			<?
			$ey=(int)date("Y");
			$sy=2009;
			for($i=$sy;$i<=$ey;$i++){
				echo '<option value="'.$i.'"';
				if($i==$year)echo ' selected';
				echo '>'.$i.'</option>';
			}
			?>
		    </select>		</td>
		<td class="dataLabel" width="10%" nowrap="nowrap">Show</td>
		<td class="dataField" width="30%" nowrap="nowrap">
			<select name="show">
			<option value="sales" <? if($_REQUEST['show']=="sales")echo "selected";?>>Sales</option>
			<option value="quantity" <? if($_REQUEST['show']=="quantity")echo "selected";?>>Pcs</option>
			<option value="margin" <? if($_REQUEST['show']=="margin")echo "selected";?>>% Margin </option>
			<option value="pln_margin" <? if($_REQUEST['show']=="pln_margin")echo "selected";?>>PLN Margin</option>
			</select></td>
		<td class="dataLabel" width="10%" nowrap="nowrap">Number of products</td>
		<td class="dataField" width="30%" nowrap="nowrap">
			<select name="no">
			<option value="10" <? if($_REQUEST['no']==10)echo "selected";?>>10</option>
			<option value="20" <? if($_REQUEST['no']==20)echo "selected";?>>20</option>
			<option value="30" <? if($_REQUEST['no']==30)echo "selected";?>>30 </option>
			<option value="50" <? if($_REQUEST['no']==50)echo "selected";?>>50</option>
			</select></td>
	  </tr>
</tbody>
</table>

<input class="button" name="submit" value="Search" type="submit">
<input class="button" name="clear" value="Clear" type="button" onclick="location.href='index.php?module=EcmCharts&action=index4';">
<input class="button" name="popup" value="Open in popup" type="button" onclick="window.open('index.php?module=EcmCharts&action=OpenPopup&file=4&width='+screen.width+'&height='+screen.height+'&to_pdf=1','popup','menubar=0,fullscreen=yes,resizable=0,width='+screen.width+',height='+screen.height);">
</form><br />
<?php

include_once('include/ECM/open_flash_chart/ofc-library/open_flash_chart_object.php');
$_SESSION['EcmCharts_4_year']=$year;
$_SESSION['EcmCharts_4_category']=$category;
$_SESSION['EcmCharts_4_show']=$_REQUEST['show'];
$_SESSION['EcmCharts_4_mmm']=$mmm;
$_SESSION['EcmCharts_4_no']=$_REQUEST['no'];

open_flash_chart_object(1024,552,'modules/EcmCharts/4.php',true,'include/ECM/open_flash_chart/');
?>