<?
function getcomposition($s,$y,$m,$d,$v,$sp)
{
  $sqlgetcatch = "select scientific,catch.spid,sum(Weight) as estotalcatch from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' AND district =$d and VesselId = '$v' and catch.spid = '$sp'  and SortNo = 1 and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $resgetcatch = mysql_fetch_array($qrygetcatch);
	  $ttcatch = $resgetcatch["estotalcatch"];
	  
  $sqlgetcatch2 = "select scientific,catch.spid,sum(Weight*raisingfact) as estotalcatch2 from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' AND district =$d and VesselId = '$v' and catch.spid = '$sp'  and SortNo = 2 and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch2;
	  $qrygetcatch2 = mysql_query($sqlgetcatch2);
	 
	  $resgetcatch2 = mysql_fetch_array($qrygetcatch2);
	  $ttcatch2 = $resgetcatch2["estotalcatch2"];
	  $spcomposition =  $ttcatch+ $ttcatch2;
	  return  $spcomposition;
}

function getcompositionyear($s,$y,$m,$d,$v)
{
  $sqlgetcatch = "select sum(Weight) as estotalcatch from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' AND district =$d and VesselId = '$v' and SortNo = 1 and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $resgetcatch = mysql_fetch_array($qrygetcatch);
	  $ttcatch = $resgetcatch["estotalcatch"];
	  
  $sqlgetcatch2 = "select sum(Weight*raisingfact) as estotalcatch2 from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' AND district =$d and VesselId = '$v' and SortNo = 2  and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch2;
	  $qrygetcatch2 = mysql_query($sqlgetcatch2);
	 
	  $resgetcatch2 = mysql_fetch_array($qrygetcatch2);
	  $ttcatch2 = $resgetcatch2["estotalcatch2"];
	  $spcomposition =  $ttcatch+ $ttcatch2;
	  return  $spcomposition;
}
function getcompositionyearnovessel($s,$y,$m)
{
  $sqlgetcatch = "select sum(Weight) as estotalcatch from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' and SortNo = 1 and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $resgetcatch = mysql_fetch_array($qrygetcatch);
	  $ttcatch = $resgetcatch["estotalcatch"];
	  
  $sqlgetcatch2 = "select sum(Weight*raisingfact) as estotalcatch2 from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y' AND month( SamplingDate )='$m' and SortNo = 2  and Sector = $s GROUP BY month(SamplingDate)";
	//echo $sqlgetcatch2;
	  $qrygetcatch2 = mysql_query($sqlgetcatch2);
	 
	  $resgetcatch2 = mysql_fetch_array($qrygetcatch2);
	  $ttcatch2 = $resgetcatch2["estotalcatch2"];
	  $spcomposition =  $ttcatch+ $ttcatch2;
	  return  $spcomposition;
}
function getcompositionnomonth($s,$y,$d,$v)
{
  $sqlgetcatch = "select sum(Weight) as estotalcatch from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y'  AND district =$d and VesselId = '$v' and SortNo = 1 and Sector = $s";
	//echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $resgetcatch = mysql_fetch_array($qrygetcatch);
	  $ttcatch = $resgetcatch["estotalcatch"];
	  
  $sqlgetcatch2 = "select sum(Weight*raisingfact) as estotalcatch2 from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y'  AND district =$d and VesselId = '$v' and SortNo = 2  and Sector = $s";
	//echo $sqlgetcatch2;
	  $qrygetcatch2 = mysql_query($sqlgetcatch2);
	 
	  $resgetcatch2 = mysql_fetch_array($qrygetcatch2);
	  $ttcatch2 = $resgetcatch2["estotalcatch2"];
	  $spcomposition =  $ttcatch+ $ttcatch2;
	  return  $spcomposition;
}
function getcompositionys($s,$y)
{
  $sqlgetcatch = "select sum(Weight) as estotalcatch from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y'  and SortNo = 1 and Sector = $s ";
	//echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $resgetcatch = mysql_fetch_array($qrygetcatch);
	  $ttcatch = $resgetcatch["estotalcatch"];
	  
  $sqlgetcatch2 = "select sum(Weight*raisingfact) as estotalcatch2 from catch inner join fishspecies on catch.spid = fishspecies.spid inner join fishoperation on catch.Optid = fishoperation.Optid where year( SamplingDate )='$y'  and SortNo = 2  and Sector = $s";
	//echo $sqlgetcatch2;
	  $qrygetcatch2 = mysql_query($sqlgetcatch2);
	 
	  $resgetcatch2 = mysql_fetch_array($qrygetcatch2);
	  $ttcatch2 = $resgetcatch2["estotalcatch2"];
	  $spcomposition =  $ttcatch+ $ttcatch2;
	  return  $spcomposition;
}
?>