<?
header("Content-Type: application/vnd.ms-excel"); 
header('Content-Disposition: attachment; filename="speciesanualdata.xls"');
?>

<html>
<head>
<title>Fish landing data management system</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="autocomplete.css" type="text/css" media="screen">
<style type="text/css">
<!--
#wrapper {
		border: 1px solid black;
		background-color: #E0E0EF;
		color:#FFFFFF;
		padding:10px;
        height:800px;
        width:1024px;
		text-align:center;
    }
.stylewhite {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.stylewhitesmall {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
}
.stylegreen {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #00661F;
}
.styleblack {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
.styleblacklarge {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color: #000000;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	color: #FFFFFF;
	text-decoration: none;
}
a:hover {
	color: #FF0000;
	text-decoration: none;
}
a:active {
	color: #FFFFFF;
	text-decoration: none;
}
.style1 {color: #FF0000}
.styletextbox {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color:#000000; }
-->
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (Untitled-1) -->
<span class="styleblack">
<? 
	  $subgear = $_GET["lstgear"];
	  $chkYear = $_GET["chkYear"];
	  $cyear = explode(",",$chkYear);
?>
<br>
</span>
<table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF" class="stylewhite">
  <tr bordercolor="#FFFFFF">
    <td colspan="14" bordercolor="#000000" bgcolor="#FFFFFF" class="styleblack"><span class="styleblack">Species anual yearly report</span></td>
  </tr>
  <tr bordercolor="#FFFFFF">
    <td colspan="14" bordercolor="#000000" bgcolor="#FFFFFF" class="styleblack"><span class="styleblack">Species/Local name:
      <?php
		  	require_once("sp_function.inc.php");
			$rptSpid =$_GET[lstsp];
			require_once("sp_function.inc.php");
			$rptSp = getspname($rptSpid); 
			echo $rptSp;
			?>
    </span></td>
  </tr>
  <tr bordercolor="#FFFFFF">
    <td colspan="14" bordercolor="#000000" bgcolor="#FFFFFF" class="styleblack"><span class="styleblack">Fishing Gear :
      <?
		  require_once("NewReport.inc.php");
		  echo getGearName($subgear); 
		  ?>
    </span></td>
  </tr>
  <?
		include "connect.inc.php";
		$sqlgetzone = "SELECT distinct fishoperation.zoneid FROM catch";
		$sqlgetzone = $sqlgetzone." INNER JOIN fishspecies ON catch.spid = fishspecies.spid";
		$sqlgetzone = $sqlgetzone." INNER JOIN fishoperation ON fishoperation.Optid = catch.Optid";
		$sqlgetzone = $sqlgetzone." INNER JOIN ship ON fishoperation.VesselId = ship.ShipName";
		$sqlgetzone = $sqlgetzone." INNER JOIN shiptype ON ship.fishsector = shiptype.shptid";
		$sqlgetzone = $sqlgetzone." INNER JOIN fishingsector ON shiptype.sid = fishingsector.sid";
		$sqlgetzone = $sqlgetzone." INNER JOIN gearandmethod ON ship.GearType = gearandmethod.fgid";
		$sqlgetzone = $sqlgetzone." WHERE ship.GearType=$subgear";
       //echo $sqlgetzone;
		$qrygetzone = mysql_query($sqlgetzone);
		$numgetzone = mysql_num_rows($qrygetzone);
		if($numgetzone == 0)
		{
		?>
  <tr bordercolor="#FFFFFF">
    <td colspan="14" bordercolor="#000000" bgcolor="#FFFFFF" class="styleblack"><span class="styleblack">No data</span></td>
  </tr>
  <?
		}
		else
		{
		for($j=1;$j<=$numgetzone;$j++)
		{
			$resgetzone = mysql_fetch_array($qrygetzone);
			$rptZone = $resgetzone["zoneid"];
			
		  ?>
  <tr bordercolor="#FFFFFF">
    <td colspan="14" bordercolor="#000000" bgcolor="#FFFFFF" class="styleblack"><span class="styleblack">Fishing Area: <? echo $rptZone; ?></span></td>
  </tr>
  <tr bgcolor="#000000" class="stylewhitesmall">
    <td width="16%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Year</div></td>
    <td width="6%" bgcolor="#CCCCCC" class="styleblack"><div align="center"><span class="stylewhitesmallk">Jan<br>
    </span></div></td>
    <td width="5%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Feb<br>
    </div></td>
    <td width="8%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Mar<br>
    </div></td>
    <td width="5%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Apr<br>
    </div></td>
    <td width="7%" bgcolor="#CCCCCC" class="styleblack"><div align="center">May<br>
    </div></td>
    <td width="6%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Jun<br>
    </div></td>
    <td width="6%" bgcolor="#CCCCCC" class="styleblack"><div align="center">July<br>
    </div></td>
    <td width="7%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Aug<br>
    </div></td>
    <td width="7%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Sep<br>
    </div></td>
    <td width="6%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Oct<br>
    </div></td>
    <td width="7%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Nov<br>
    </div></td>
    <td width="5%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Dec<br>
    </div></td>
    <td width="9%" bgcolor="#CCCCCC" class="styleblack"><div align="center">Total</div></td>
  </tr>
  <?
       
		$ttjan = 0;
		$ttfeb = 0;
		$ttmar = 0;
		$ttapr = 0;
		$ttmay = 0;
		$ttjun = 0;
		$ttjul = 0;
		$ttaug = 0;
		$ttsep = 0;
		$ttoct = 0;
		$ttnov = 0;
		$ttdec = 0;
		$tts = 0;
		$numyear = count($cyear);
		for($i=0;$i<count($cyear);$i++) 
		 { 
	
         	if($chkYear[$i] != "") 
        	{ 
			$rptyear = $cyear[$i];
			
			require_once("NewReport.inc.php");
			$catchJan = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid ,1);
			$ttjan = $ttjan+$catchJan;
			
			require_once("NewReport.inc.php");
			$catchFeb = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,2);
			$ttfeb = $ttfeb+$catchFeb;
			require_once("NewReport.inc.php"); 
			$catchMar = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,3);
			$ttmar = $ttmar+$catchMar; 
			require_once("NewReport.inc.php"); 
			$catchApr = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,4);
			$ttapr = $ttapr+$catchApr; 
			require_once("NewReport.inc.php"); 
			$catchMay = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,5);
			$ttmay = $ttmay+$catchMay; 
			require_once("NewReport.inc.php"); 
			$catchJun = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,6);
			$ttjun = $ttjun+$catchJun; 
			require_once("NewReport.inc.php"); 
			$catchJul = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,7);
			$ttjul = $ttjul+$catchJul; 
			require_once("NewReport.inc.php"); 
			$catchAug = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,8);
			$ttaug = $ttaug+$catchAug;
			require_once("NewReport.inc.php"); 
			$catchSep = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,9);
			$ttsep = $ttsep+$catchSep; 
			require_once("NewReport.inc.php"); 
			$catchOct = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,10);
			$ttoct = $ttoct+$catchOct; 
			require_once("NewReport.inc.php"); 
			$catchNov = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,11);
			$ttnov = $ttnov+$catchNov; 
			require_once("NewReport.inc.php"); 
			$catchDec = getCatchDataSp($rptyear,$subgear,$rptZone,$rptSpid,12);
			$ttdec = $ttdec+$catchDec; 
			$tty = $catchJan+$catchFeb+$catchMar+$catchApr+$catchMay+$catchJun+$catchJul+$catchAug+$catchSep+$catchOct+$catchNov+$catchDec;
			$tts = $tts+$tty;
			
		?>
  <tr class="styleblack">
    <td align="center" bgcolor="#FFFFFF"><? echo $rptyear; ?> </td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchJan; ?> </td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchFeb; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchMar; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchApr; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchMay; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchJun; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchJul; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchAug; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchSep; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchOct; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchNov; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $catchDec; ?></td>
    <td align="center" bgcolor="#FFFFFF" class="styleblack"><? echo number_format($tty,2,'.',''); ?></td>
  </tr>
  <?
		}
		}
		?>
  <tr class="styleblack">
    <td align="center" bgcolor="#FFFFFF">Total </td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttjan,2,'.',''); ?> </td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttfeb,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttmar,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttapr,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttmay,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttjun,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttjul,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttaug,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttsep,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttoct,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttnov,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo number_format($ttdec,2,'.',''); ?></td>
    <td align="center" bgcolor="#FFFFFF" class="styleblack"><? echo number_format($tts,2,'.',''); ?></td>
  </tr>
  <tr bgcolor="#A8C47A" class="styleblack">
    <td colspan="14" align="center" bgcolor="#FFFFFF"><div align="right"></div>
        <div align="right"></div></td>
  </tr>
  <?
		
		}
		?>
</table>
<p class="styleblack">
  <?
				
        	} 
    	 
	  ?>
</p>
<!-- End ImageReady Slices -->
</body>
</html>