<?
session_start();
ob_start();
?>
<html>
<head>

<title>Fish landing data management system</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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}
.style37 {color: #FFFFFF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (Untitled-1) -->
<table width="1024" height="799" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#F3F3F3" id="Table_01">
<tr>
		<td height="50" colspan="2" bgcolor="#ADCE4C" class="stylewhite">&nbsp;Fish Landing Data Management System</td>
  </tr>
	<tr class="stylewhitesmall">
	  <td height="20" colspan="2" bgcolor="#006666"><span class="styleblack">&nbsp;</span><a href="main.php">Home</a><span class="style1">&nbsp;</span> |&nbsp;<a href="usr.php">User</a> |<span class="style1"> <a href="fishingzone.php">Fishing Zone|</a> <a href="district.php">District</a> </span>|<a href="samplingport.php"> Sampling Port </a>| <a href="fgmethod.php">Fishing Gear and Method</a> | <a href="vessel.php">Fishing Vessel</a> | <a href="species.php">Fish Species</a> | <a href="fishoperation.php">Fishing Operation</a> | <a href="biology.php">Biology Data</a> | <a href="report.php">Report</a> |<span class="style1"> <a href="logout.php">Logout</a></span></td>
  </tr>
	<tr>
	  <td width="203" height="705" valign="top" bgcolor="#CCCCCC"><table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
          <tr>
            <td bgcolor="#000000"><div align="center"><span class="stylewhite">
            Report</span></div></td>
          </tr>
          <div align="center"> <span class="stylegreen">
            <?
	  include "connect.inc.php";
	  $sqlgetyear = "select distinct year(SamplingDate) as dyear from fishoperation order by dyear";
	  //echo $sqlgetship;
	  $qrygetyear = mysql_query($sqlgetyear);
	  $numgetyear = mysql_num_rows($qrygetyear);
	   for($i=1;$i<=$numgetyear;$i++)
		{
			$resgetyear = mysql_fetch_array($qrygetyear);
			$dbyear= $resgetyear["dyear"];
			$s = $_GET["s"];
			?>
            </span>
              <tr class="styleblack">
                <td align="center" bgcolor="#006666" class="stylewhitesmall"><a href="spcompositionfg.php?y=<? echo $dbyear; ?>&s=<? echo $_GET["s"]; ?>">
                  <? 
				echo $dbyear;
				require_once("fishing_function.inc.php");
				echo " (".getNumYear($dbyear)." operations) ";
				
				?>
                  </a><br>                </td>
              </tr>
              <span class="stylegreen">
              <?
        }
      ?>
            </span></div>
	      <tr>
            <td bgcolor="#000000"><div align="right"><span class="styleblack">&nbsp;&nbsp; </span></div></td>
          </tr>
        </table>	    
	 </td>
      <td width="815" valign="top" bgcolor="#CCCCCC" class="styleblack">
	 
	    <br>
	    <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF" class="stylewhite">
          <tr bordercolor="#FFFFFF">
		  <?
		  if($_GET["s"] == 1)
		  {
		  	$stype = "Commercial";
		  }
		  else
		  {
		  	$stype = "Small Scale";
		  }
		  ?>
            <td bgcolor="#006666" class="stylewhitesmall"><span class="stylewhite">Species composition by fishing gear <? echo $_GET["y"]; ?> [<? echo $stype; ?>]</span></td>
          </tr>
        </table>
	    <?
	  if(isset($_GET["y"]))
	  {
	   include "connect.inc.php";
		  $yy = $_GET["y"];
		  $ss = $_GET["s"];
		
       $sqlgetgear = "select distinct(ShipGearId) as fgid,fishinggear,fishmethod from catch inner join fishoperation on catch.Optid=fishoperation.Optid inner join gearandmethod on gearandmethod.fgid = fishoperation.ShipGearId where year(SamplingDate) = '$yy' AND Sector = $ss";
	   //echo  $sqlgetgear; 
	   $qrygetgear = mysql_query($sqlgetgear);
	   $numgetgear = mysql_num_rows($qrygetgear);
	   for($d=1;$d<=$numgetgear;$d++)
	   {
	   	$resgetgear = mysql_fetch_array($qrygetgear);
		$dbgearid = $resgetgear["fgid"];
		$dbgear = $resgetgear["fishinggear"];
			$dbmethod = $resgetgear["fishmethod"];
			  if($dbmethod != "")
				{
					$gear2 =  $dbgear."(".$dbmethod.")"; 
				}
				else
				{
					$gear2 = $dbgear;
				}
        ?>
	    <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
        <tr bgcolor="#000000" class="styleblack">
          <td colspan="14" class="stylewhitesmall">Fishing gear: <? echo $gear2; ?></td>
          </tr>
        <?
        $sqlgetvessel = "select distinct VesselId from fishoperation where year(SamplingDate) = '$yy' AND Sector = $ss and ShipGearId = $dbgearid";
		//echo $sqlgetvessel;
		  $qrygetvessel = mysql_query($sqlgetvessel);
		  $numgetvessel = mysql_num_rows($qrygetvessel);
        for($i=1;$i<=$numgetvessel;$i++)
		{
			$resgetvessel = mysql_fetch_array($qrygetvessel);
			$dbvesselid = $resgetvessel["VesselId"];

		?>
        <tr>
        <td width="18%" bgcolor="#000000" class="stylewhitesmall"><? echo "Vessel: ".$dbvesselid; ?></td>
        
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Jan<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Feb<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Mar<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Apr<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">May<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Jun<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">July<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Aug<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Sep<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Oct<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Nov<br>
    kg.</div></td>
          <td bgcolor="#000000" class="stylewhitesmall"><div align="center">Dec<br>
    kg.</div></td>
          <td width="11%" bgcolor="#000000" class="stylewhitesmall"><div align="center">Total<br>kg.</div>            </td>
          </tr>
        <?
       $sqlgetsp = "select distinct(catch.Spid) as spid,scientific  from catch inner join fishoperation on catch.Optid = fishoperation.Optid inner join fishspecies on catch.Spid = fishspecies.spid where year(SamplingDate) = '$yy' and VesselId = '$dbvesselid' AND Sector = $ss and ShipGearId = $dbgearid";
			//echo $sqlgetsp;
			$qrygetsp = mysql_query($sqlgetsp);
			$numgetsp = mysql_num_rows($qrygetsp);
			$sumjan = 0;
			$sumfeb = 0;
			$summar = 0;
			$sumapr = 0;
			$summay = 0;
			$sumjun = 0;
			$sumjul = 0;
			$sumaug = 0;
			$sumsep = 0;
			$sumoct = 0;
			$sumnov = 0;
			$sumdec = 0;
			$totalyear = 0;
			$summonth = 0;
			for($j=1;$j<=$numgetsp;$j++)
			{
			$resgetsp = mysql_fetch_array($qrygetsp);
			$dbspid = $resgetsp["spid"];
			$dbspname =  $resgetsp["scientific"];
			require_once("spcopositionfg.inc.php");
			$ttcjan = getcomposition($ss,$yy,1,$dbgearid,$dbvesselid,$dbspid);
			$sumjan = $sumjan+$ttcjan;
			require_once("spcopositionfg.inc.php");
			$ttcfeb = getcomposition($ss,$yy,2,$dbgearid,$dbvesselid,$dbspid);
			$sumfeb = $sumfeb+$ttcfeb;
			require_once("spcopositionfg.inc.php");
			$ttcmar = getcomposition($ss,$yy,3,$dbgearid,$dbvesselid,$dbspid);
			$summar = $summar+$ttcmar;
			require_once("spcopositionfg.inc.php");
			$ttcapr = getcomposition($ss,$yy,4,$dbgearid,$dbvesselid,$dbspid);
			$sumapr = $sumapr+$ttcapr;
			require_once("spcopositionfg.inc.php");
			$ttcmay = getcomposition($ss,$yy,5,$dbgearid,$dbvesselid,$dbspid);
			$summay = $summay+$ttcmay;
			require_once("spcopositionfg.inc.php");
			$ttcjun = getcomposition($ss,$yy,6,$dbgearid,$dbvesselid,$dbspid);
			$sumjun = $sumjun+$ttcjun;
			require_once("spcopositionfg.inc.php");
			$ttcjul = getcomposition($ss,$yy,7,$dbgearid,$dbvesselid,$dbspid);
			$sumjul = $sumjul+$ttcjul;
			require_once("spcopositionfg.inc.php");
			$ttcaug = getcomposition($ss,$yy,8,$dbgearid,$dbvesselid,$dbspid);
			$sumaug = $sumaug+$ttcaug;
			require_once("spcopositionfg.inc.php");
			$ttcsep = getcomposition($ss,$yy,9,$dbgearid,$dbvesselid,$dbspid);
			$sumsep = $sumsep+$ttcsep;
			require_once("spcopositionfg.inc.php");
			$ttcoct = getcomposition($ss,$yy,10,$dbgearid,$dbvesselid,$dbspid);
			$sumoct = $sumoct+$ttcoct;
			require_once("spcopositionfg.inc.php");
			$ttcnov = getcomposition($ss,$yy,11,$dbgearid,$dbvesselid,$dbspid);
			$sumnov = $sumnov+$ttcnov;
			require_once("spcopositionfg.inc.php");
			$ttcdec = getcomposition($ss,$yy,12,$dbgearid,$dbvesselid,$dbspid);
			$sumdec = $sumdec+$ttcdec;
			$allyear = $ttcjan+$ttcfeb+$ttcmar+$ttcapr+$ttcmay+$ttcjun+$ttcjul+$ttcaug+$ttcsep+$ttcoct+$ttcnov+$ttcdec;
		?>
       <tr>
        <td align="left" bgcolor="#ADCE4C" class="styleblack"><div align="left"><? echo $dbspname; ?>&nbsp;</div>
          <div align="left"></div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcjan; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcfeb; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcmar; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcapr; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcmay; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcjun; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcjul; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcaug; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcsep; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcoct; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcnov; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $ttcdec; ?>&nbsp;</div></td>
        <td bgcolor="#ADCE4C" class="styleblack"><div align="center"><? echo $allyear; ?>&nbsp;</div></td>
        </tr>
        <?
		}
		require_once("spcopositionfg.inc.php");
		$ttyjan = getcompositionyear($ss,$yy,1,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyfeb = getcompositionyear($ss,$yy,2,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttymar = getcompositionyear($ss,$yy,3,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyapr = getcompositionyear($ss,$yy,4,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttymay = getcompositionyear($ss,$yy,5,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyjun = getcompositionyear($ss,$yy,6,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyjul = getcompositionyear($ss,$yy,7,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyaug = getcompositionyear($ss,$yy,8,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttysep = getcompositionyear($ss,$yy,9,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttyoct = getcompositionyear($ss,$yy,10,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttynov = getcompositionyear($ss,$yy,11,$dbgearid,$dbvesselid);
		require_once("spcopositionfg.inc.php");
		$ttydec = getcompositionyear($ss,$yy,12,$dbgearid,$dbvesselid);
		       
		?>
         <tr>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center">sub total</div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyjan; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyfeb; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttymar; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyapr; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttymay; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyjun; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyjul; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyaug; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttysep; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttyoct; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttynov; ?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? echo $ttydec;?></div></td>
        <td bgcolor="#006666" class="stylewhitesmall"><div align="center"><? 
		require_once("spcopositionfg.inc.php"); 
		echo getcompositionnomonth($ss,$yy,$dbgearid,$dbvesselid); 
		?></div></td>
        </tr>
        <?
		}
         }
		 require_once("spcopositionfg.inc.php");
		$sumjan = getcompositionyearnovessel($ss,$yy,1);
		require_once("spcopositionfg.inc.php");
		$sumfeb = getcompositionyearnovessel($ss,$yy,2);
		require_once("spcopositionfg.inc.php");
		$summar = getcompositionyearnovessel($ss,$yy,3);
		require_once("spcopositionfg.inc.php");
		$sumapr = getcompositionyearnovessel($ss,$yy,4);
		require_once("spcopositionfg.inc.php");
		$summay = getcompositionyearnovessel($ss,$yy,5);
		require_once("spcopositionfg.inc.php");
		$sumjun = getcompositionyearnovessel($ss,$yy,6);
		require_once("spcopositionfg.inc.php");
		$sumjul = getcompositionyearnovessel($ss,$yy,7);
		require_once("spcopositionfg.inc.php");
		$sumaug = getcompositionyearnovessel($ss,$yy,8);
		require_once("spcopositionfg.inc.php");
		$sumsep = getcompositionyearnovessel($ss,$yy,9);
		require_once("spcopositionfg.inc.php");
		$sumoct = getcompositionyearnovessel($ss,$yy,10);
		require_once("spcopositionfg.inc.php");
		$sumnov = getcompositionyearnovessel($ss,$yy,11);
		require_once("spcopositionfg.inc.php");
		$sumdec = getcompositionyearnovessel($ss,$yy,12);
		 ?>
		 <tr>
        <td bgcolor="#6B716F"><div align="center"><span class="style37">total</span></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumjan; ?> </div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumfeb; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $summar; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumapr; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $summay; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumjun; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumjul; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumaug; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumsep; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumoct; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumnov; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? echo $sumdec; ?></div></td>
        <td bgcolor="#6B716F" class="styleblack"><div align="center"><? 
		require_once("spcopositionfg.inc.php");
		echo getcompositionys($ss,$yy); 
		?></div></td>
        </tr>
     
		</table>
        <?
	   } 
	 
      else
			  {
			  ?>
      <table width="70%" height="47" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="4" align="right" bgcolor="#6B716F">&nbsp;</td>
        </tr>
        <tr>
          <td height="5" align="right" bgcolor="#ADCE4C" class="styleblack"><div align="center">
              <p>&nbsp;</p>
            <p>Select Year</p>
            <p>&nbsp;</p>
          </div></td>
        </tr>
        <tr>
          <td height="9" align="right" bgcolor="#6B716F">&nbsp;</td>
        </tr>
      </table>
      <?
			  }
			  ?>
	 </td>
  </tr>
	<tr>
	  <td colspan="2" bgcolor="#006666"><div align="right"><span class="styleblack">@SEAFDEC 2012</span></div></td>
  </tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>