<?
session_start();
ob_start();
?>
<html>
<head>
<script language="JavaScript"> 
function onInsert()
{ 
		if(form1.txttotalcatch.value =="")
		{
			alert("You not fill total catch!");
			form1.txttotalcatch.focus();
			return false;
		}
		else
		{
			return true; 
		}	 
} 
function onInsert2()
{ 
		if(form2.searchField.value =="")
		{
			alert("You not fill species!");
			form2.searchField.focus();
			return false;
		}
		if(form2.txtweight.value =="")
		{
			alert("You not fill weight!");
			form2.txtweight.focus();
			return false;
		}
		else
		{
			return true; 
		}	 
} 
function onInsert3()
{ 
		if(form3.searchField.value =="")
		{
			alert("You not fill species!");
			form3.searchField.focus();
			return false;
		}
		if(form3.txtweight2.value =="")
		{
			alert("You not fill weight!");
			form3.txtweight2.focus();
			return false;
		}
		else
		{
			return true; 
		}	 
} 
</script>
<title>Fish landing data management system</title>
<script type="text/javascript" src="calendarDateInput.js">

/***********************************************
* Jason's Date Input Calendar- By Jason Moon http://calendar.moonscript.com/dateinput.cfm
* Script featured on and available at http://www.dynamicdrive.com
* Keep this notice intact for use.
***********************************************/

</script>
<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}
.styletextbox {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color:#000000; }
.style37 {color: #FFFFFF}
.styleblacklargered {font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color:#FF0000;
}
.style26 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10; }
.style39 {font-size: 12px; color: #000000; font-family: Arial, Helvetica, sans-serif;}
-->
</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> | <a href="usr.php">User</a> |<span class="style1"> <a href="fishingzone.php">Fishing Area |</a> <a href="district.php">State/Province </a></span>|<a href="samplingport.php"> Landing Site </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="catchdata.php">Catch Data </a> | <a href="biology.php">Biology Data</a> | <a href="report.php"> </a><a href="report.php">Report</a> |<span class="style1"> <a href="logout.php">Logout</a></span></td>
  </tr>
	<tr>
	  <td width="410" height="705" valign="top" bgcolor="#CCCCCC"><p align="center">
	    <?
		if($_POST[submit1])
	{
	include "usr_function.php"; //for Check null
	$insoptid = base64_decode($_GET["optid"]);
	$insspid = $_GET["spid"];
	$instl = chknull($_POST["txttl"]);
	$insbl = chknull($_POST["txtbl"]);
	$insfl = chknull($_POST["txtfl"]);
	$inssl = chknull($_POST["txtsl"]);
	$insbw = chknull($_POST["txtbw"]);
	$inssex = chknull($_POST["lstsex"]);
	$insstage = chknull($_POST["lststage"]);
	$insgw = chknull($_POST["txtgw"]);
	require_once("biology_function.inc.php");
	$inssid = getsid($insoptid,$insspid);
	require_once("biology_function.inc.php");
	InsertBiology($insoptid,$insspid,$inssid,$instl,$insbl,$insfl,$inssl,$insbw,$inssex,$insstage,$insgw);
	$tlog = "Add Biology Operation ".$insoptid." spid=".$insspid ;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);	
	}
if($_POST[submit2])
{
	if (!file_exists("biology/"))
		{
		mkdir("biology/");
		}
		$moveto = "biology/".$_FILES["fileCSV"]["name"];
		move_uploaded_file($_FILES["fileCSV"]["tmp_name"],$moveto); // Copy/Upload CSV  
		$objCSV = fopen($moveto, "r+"); 
		include "usr_function.php"; //for Check null
		$insoptid = base64_decode($_GET["optid"]);
		$insspid = $_GET["spid"];
		if (($_FILES["fileCSV"]["type"] == "application/vnd.ms-excel"))
		 {
			$i=0;
			while (($objArr = fgetcsv($objCSV, 2048, ",")) != FALSE) {
				if($objArr[0] !="")
				{
				if($i>0)
				{
				$obj0 = chknull($objArr[0]);
				$obj1 = chknull($objArr[1]);
				$obj2 = chknull($objArr[2]);
				$obj3 = chknull($objArr[3]);
				$obj4 = chknull($objArr[4]);
				$obj5 = chknull($objArr[5]);
				$obj6 = chknull($objArr[6]);
				$obj7 = chknull($objArr[7]);
				require_once("biology_function.inc.php");
				$inssid = getsid($insoptid,$insspid);
			  	require_once("biology_function.inc.php");
		  		InsertBiology($insoptid,$spid,$inssid,$obj0,$obj1,$obj2,$obj3,$obj4,$obj5,$obj6,$obj7);
			
					}
				}
			$i++;
			}
		}
		else
		{
			require_once("usr_function.php");
			ErrMsg("Error: Only .CSV File type ".$_FILES['fileCSV']['type']);
			 //die("Sorry, mime type not allowed");
		}
	$tlog = "Add Biology Operation ".$insoptid;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);
	
}
if($_POST[del])
{
		 $insoptid = base64_decode($_GET["optid"]);
		 $insspid = $_GET["spid"];
		 for($i=0;$i<count($_POST["chkDel"]);$i++) 
		 { 
		 	$hdcruiseid = base64_decode($_GET[crid]);
         	if($_POST["chkDel"][$i] != "") 
        	{ 
				require_once("biology_function.inc.php");
				deleteBiology($insoptid, $insspid,$_POST["chkDel"][$i]);
        	} 
    	 }
}
if($_POST[submit4])
{  

	include "usr_function.php"; //for Check null
	$insoptid = base64_decode($_GET["optid"]);
	$insspid = $_GET["spid"];
	$inssid = $_POST["hdsid4"];
	$instl = chknull($_POST["txttl2"]);
	$insbl = chknull($_POST["txtbl2"]);
	$insfl = chknull($_POST["txtfl2"]);
	$inssl = chknull($_POST["txtsl2"]);
	$insbw = chknull($_POST["txtbw2"]);
	$inssex = chknull($_POST["lstsex2"]);
	$insstage = chknull($_POST["lststage2"]);
	$insgw = chknull($_POST["txtgw2"]);
	require_once("biology_function.inc.php");
	EditBiology($insoptid,$insspid,$inssid,$instl,$insbl,$insfl,$inssl,$insbw,$inssex,$insstage,$insgw);
	$tlog = "Edit Biology Operation ".$optid." spid=".$insspid ;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);	
}
?>
	    <br />
          <?
	 if(isset($_GET["optid"]))
	{
		include "connect.inc.php";
		$decodeid = base64_decode($_GET["optid"]);
	  ?>     
          <table width="95%" height="114" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
            <tr>
              <td height="19" colspan="2" bgcolor="#000000"><div align="center"><span class="stylewhite">Fishing Operation</span><span class="styleblack">
                <?
				  $sqlgetoperation = "select VesselId,LandingPort,DepartureDate,ArrivalDate,Duration,FishingTime,BottomDepth,FishingGearDepth,HualPerTrip,TotalCatch,Recorder,fishinggear,portname,province,fishoperation.zoneid,fishsector,fishingdulation,sector from  fishoperation inner join ship on fishoperation.VesselId = ship.ShipName left join gearandmethod on ship.GearType =  gearandmethod.fgid  inner join fishingport on fishingport.portid = fishoperation.LandingPort left join district on  fishingport.province = district.disid inner join shiptype on ship.fishsector = shiptype.shptid inner join fishingsector on shiptype.sid = fishingsector.sid where Optid = '$decodeid'";
	//echo  $sqlgetoperation;
	  $qrygetoperation = mysql_query($sqlgetoperation) or die(mysql_error());
	  $numgetoperation = mysql_fetch_array($qrygetoperation);
	  $dbsector = $numgetoperation["Sector"];
	  $dbvessel =  $numgetoperation["VesselId"];
	  $dbgearid =  $numgetoperation["ShipGearId"];
	  $dbgearname = $numgetoperation["fishinggear"];
	  $dbgearmethod = $numgetoperation["fishmethod"];
	  $dbfishingzone =  $numgetoperation["zoneid"];
	  $dbdistrict = $numgetoperation["District"];
	  $dbdisname = $numgetoperation["disname"];
	  $dbportid2 = $numgetoperation["LandingPort"];
	  $dbportname2 = $numgetoperation["portname"];
	  $dbportprovince2 = $numgetoperation["province"];
	  $dbsamplingdate = $numgetoperation["SamplingDate"];
	  $dbdeparturedate = $numgetoperation["DepartureDate"];
	  $dbarrivaldate = $numgetoperation["ArrivalDate"];
	  $dbduration = $numgetoperation["Duration"];
	  $dbfishingtime = $numgetoperation["FishingTime"];
	  $dbbottomdepth = $numgetoperation["BottomDepth"];
	  $dbfishingdepth = $numgetoperation["FishingGearDepth"];
	  $dbhual = $numgetoperation["HualPerTrip"];
	  $dbtotalcatch = $numgetoperation["TotalCatch"];
	  $dbrecorder = $numgetoperation["Recorder"];
	  $dbddate = $numgetoperation["DepartureDate"];
	  $dbtotalcatchpri = $numgetoperation["catchprimary"];
	  $dbfishsector = $numgetoperation["sector"];
	  $dbfishdulation = $numgetoperation["fishingdulation"];
				  ?>
              </span></div>
                  <div align="right"></div></td>
            </tr>
            <tr>
              <td width="46%" height="12" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right" class="stylewhitesmall">Vessel Name&nbsp; </div></td>
              <td width="54%" height="12" bgcolor="#990000" class="stylewhitesmall"><?php  echo $dbvessel; ?></td>
            </tr>
            <tr>
              <td height="6" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Fishing area &nbsp; </div></td>
              <td bgcolor="#990000" class="stylewhitesmall"><? echo $dbfishingzone; ?></td>
            </tr>
            <tr>
              <td height="3" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Fishing Gear&nbsp; </div></td>
              <td bgcolor="#990000" class="stylewhitesmall"><? echo $dbgearname; ?></td>
            </tr>
            <tr>
              <td height="4" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Fishing Sector</div></td>
              <td bgcolor="#990000" class="stylewhitesmall"><? echo $dbfishsector; ?></td>
            </tr>
            <tr>
              <td height="3" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Landing port&nbsp; </div></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbportname2; ?></td>
            </tr>
            <tr>
              <td height="7" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Departure date&nbsp; </div></td>
              <td height="1" bgcolor="#990000" class="stylewhitesmall"><? echo $dbdeparturedate; ?></td>
            </tr>
            <tr>
              <td height="7" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Arrival date&nbsp; </div></td>
              <td height="1" bgcolor="#990000" class="stylewhitesmall"><? echo $dbarrivaldate; ?>             </td>
            </tr>
            <tr>
              <td height="1" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Dulation (Days)&nbsp; </div></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbduration; ?> </td>
            </tr>
            <tr>
              <td height="2" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Fishing time&nbsp; </div></td>
              <td height="2" bgcolor="#990000" class="stylewhitesmall"><?  echo $dbfishingtime; ?></td>
            </tr>
            <tr>
              <td height="3" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Bottom depth&nbsp; </div></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbbottomdepth; ?></td>
            </tr>
            <tr>
              <td height="2" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Fishing gear depth&nbsp; </div></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbfishingdepth; ?></td>
            </tr>
            <tr>
              <td height="1" valign="top" bgcolor="#006666" class="stylewhitesmall"><p align="right">No. of haul per trip&nbsp; </p></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbhual; ?></td>
            </tr>
            <tr>
              <td height="1" align="right" valign="middle" bgcolor="#006666" class="stylewhitesmall">&nbsp;
                Fishing Duration(hours)&nbsp; </td>
              <td height="1" bgcolor="#990000" class="stylewhitesmall"><? echo $dbfishdulation; ?></td>
            </tr>
            <tr>
              <td height="7" valign="top" bgcolor="#006666" class="stylewhitesmall"><div align="right">Recorder&nbsp; </div></td>
              <td height="0" bgcolor="#990000" class="stylewhitesmall"><? echo $dbrecorder; ?></td>
            </tr>
            <tr>
              <td height="19" colspan="2" bgcolor="#000000"><div align="right"></div></td>
            </tr>
        </table>
          <br />
        <table width="95%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
            <tr>
              <td colspan="3" bgcolor="#000000"><div align="center"> <span class="stylewhite">Catch Data For '<? echo $dbvessel; ?>'</span></div></td>
            </tr>
            <tr class="stylewhitesmall">
              <td width="31%" bgcolor="#000000" class="stylewhitesmall"><div align="center">Vessel Name</div></td>
              <td width="47%" bgcolor="#000000"><div align="center">Departure Date</div>                <div align="center"></div></td>
              <td width="22%" bgcolor="#000000"><div align="center">select</div></td>
            </tr>
            <div align="center"> <span class="stylegreen">
              <?
	  include "connect.inc.php";
	  $sqlgetyear2 = "select Optid,VesselId,ArrivalDate from fishoperation where VesselId =  '$dbvessel' order by ArrivalDate ";
	  //echo  $sqlgetyear2;
	  $qrygetyear2 = mysql_query($sqlgetyear2);
	  $numgetyear2 = mysql_num_rows($qrygetyear2);
	   for($j=1;$j<=$numgetyear2;$j++)
		{
			$resgetyear2 = mysql_fetch_array($qrygetyear2);
			$dboptid2 = $resgetyear2["Optid"];
			$dbddate2= $resgetyear2["ArrivalDate"];
			$dbvessel2= $resgetyear2["VesselId"];
			$encodeoptid2 = base64_encode($dboptid2);
			$encodevessel = base64_encode($dbvessel2);
			if($dbarrivaldate == $dbddate2)
			{
				$colcolors = "#990000";
			}
			else
			{
				$colcolors = "#006666";
			}
			?>
              </span>
                <tr>
                  <td align="center" bgcolor="<? echo $colcolors; ?>" class="stylewhitesmall"><? echo $dbvessel2; ?></td>
                  <td align="center" bgcolor="<? echo $colcolors; ?>" class="stylewhitesmall"><? echo $dbddate2; ?></td>
                  <td align="center" bgcolor="<? echo $colcolors; ?>" class="stylewhitesmall"><a href="biology.php?optid=<? echo $encodeoptid2; ?>&d=<? echo $dbddate2; ?>"><img src="images/monthForward_normal.gif" width="20" height="20" border="0" /></a></td>
                </tr>
                <span class="stylegreen">
                <?
        }
      ?>
              </span></div>
            <tr>
              <td colspan="3" bgcolor="#000000"><div align="right"><a href="catchdata.php"></a></div></td>
            </tr>
        </table>
         
        <?
	}
	else
	{
	?>
        <table width="95%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
          <tr>
            <td colspan="3" bgcolor="#000000"><div align="center"><span class="stylewhite"> Catch Data</span></div></td>
          </tr>
          <tr class="stylewhitesmall">
            <td width="27%" bgcolor="#000000" class="stylewhitesmall"><div align="center">Vessel Name</div></td>
            <td width="53%" bgcolor="#000000"><div align="center">No. of operation</div></td>
            <td width="20%" bgcolor="#000000"><div align="center">Add Biology</div></td>
          </tr>
          <div align="center"> <span class="stylegreen">
            <?
	  include "connect.inc.php";
	  $sqlgetyear = "select VesselId,min(ArrivalDate) as mindate,count(Optid) AS countopt from fishoperation group by VesselId order by ArrivalDate";
	  //echo  $sqlgetyear;
	  $qrygetyear = mysql_query($sqlgetyear);
	  $numgetyear = mysql_num_rows($qrygetyear);
	   for($i=1;$i<=$numgetyear;$i++)
		{
			$resgetyear = mysql_fetch_array($qrygetyear);
			
			$dbcountoptid = $resgetyear["countopt"];
			$dbddate= $resgetyear["mindate"];
			$dbvessel = $resgetyear["VesselId"];
			$sqlgetopt = "select Optid from fishoperation where VesselId='$dbvessel' and ArrivalDate='$dbddate'";
			$qrygetopt = mysql_query($sqlgetopt);
			$resgetopt = mysql_fetch_array($qrygetopt);
			$dboptid = $resgetopt["Optid"];
			$encodeoptid = base64_encode($dboptid);
			
			?>
            </span>
              <tr>
                <td align="center" bgcolor="#006666" class="stylewhitesmall"><? echo $dbvessel; ?></td>
                <td align="center" bgcolor="#006666" class="stylewhitesmall"><? echo $dbcountoptid; ?></td>
                <td align="center" bgcolor="#006666" class="styleblack"><a href="biology.php?optid=<? echo $encodeoptid; ?>&d=<? echo $dbddate; ?>"><img src="images/monthForward_down.gif" width="20" height="20" border="0" /></a></td>
            </tr>
              <span class="stylegreen">
              <?
        }
      ?>
            </span></div>
          <tr>
            <td colspan="3" bgcolor="#000000"><div align="right"><a href="catchdata.php"></a>&nbsp; </div></td>
          </tr>
        </table>
        <?
		}
		?>
        <p align="center"></p>
      <p align="center">&nbsp; </p>        <p align="center">&nbsp;</p></td>
      <td width="608" valign="top" bgcolor="#CCCCCC"><?
	  if(isset($_GET[optid]))
	  {
	  $decodeid = base64_decode($_GET["optid"]);
	  ?>
        <br><table width="95%" height="35" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="100%" height="9" background="images/index_01.gif"><div align="center"><span class="stylewhite">Biology Data</span></div>
                  <div align="right"></div></td>
            </tr>
            <?
		   include "connect.inc.php";
	  $sqlgetcatch = "select distinct(catch.spid),fishspecies.scientific from catch inner join fishspecies on catch.spid = fishspecies.spid where Optid='$decodeid'";
	  //echo $sqlgetcatch;
	  $qrygetcatch = mysql_query($sqlgetcatch);
	  $numgetcatch = mysql_num_rows($qrygetcatch);
	  
		  ?>

            <tr>
              <td height="7" bgcolor="#ADCE4C" class="style1"><label> </label>
                  <div align="left"> <br>
                      <?
					  if(!isset($_GET["spid"]))
					  {
					  ?>
                      <table width="62%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
                        <tr bgcolor="#000000" class="styleblack">
                          <td width="18%" class="stylewhitesmall"><div align="center">No</div></td>
                          <td width="53%" class="stylewhitesmall"><div align="left">Species</div></td>
                          <td width="29%" class="stylewhitesmall"><div align="center">Add Biology Data</div></td>
                        </tr>
                        <?
               for($j=1;$j<=$numgetcatch;$j++)
				{
    				$resgetcatch = mysql_fetch_array($qrygetcatch);
					$dbspid = $resgetcatch["spid"];
					$dbspname = $resgetcatch["scientific"];
					$dbweight = $resgetcatch["Weight"];
				?>
                        <tr class="styleblack">
                          <td bgcolor="#006666" class="styleblack"><div align="center"><span class="style37"><? echo $j; ?></span></div></td>
                          <td bgcolor="#006666" class="styleblack"><span class="style37"><? echo $dbspname; ?></span></td>
                          <td bgcolor="#006666" class="styleblack"><div align="center"><a href="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $dbspid; ?>&spname=<? echo $dbspname; ?>&d=<? echo $_GET["d"]; ?>"><img src="images/add.png" width="24" height="24" border="0"></a></div></td>
                        </tr>
                        <?
			  }
			  ?>
                        <tr class="styleblack">
                          <td height="17" colspan="3" bgcolor="#000000" class="stylewhitesmall">&nbsp;</td>
                        </tr>
                      </table>
                <br>
                      
                      <?
					  }
					  else
					  {
					  ?>
                      <form name="form3" method="post" action="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>; ?>">
                        <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
                          <tr bgcolor="#000000" class="styleblack">
                            <td colspan="11" bgcolor="#6B716F" class="stylewhitesmall"><div align="center"> Biology Data</div>
                                <div align="left"></div></td>
                          </tr>
                          <?
						$showoptid = base64_decode($_GET["optid"]);
						$showspid = $_GET["spid"];
						include "connect.inc.php";
						$sqlgetbio = "select * from biology left join stage on biology.stageid = stage.stageid where Optid=$showoptid and spid=$showspid";
						//echo $sqlgetbio;
						$qrygetbio = mysql_query($sqlgetbio);
						$numgetbio = mysql_num_rows($qrygetbio);
						?>
                          <tr class="styleblack">
                            <td width="5%" class="stylegreen"><div align="center">No.<br>
                            </div></td>
                            <td width="8%" class="stylegreen"><div align="center">TL(mm)</div></td>
                            <td width="11%" class="stylegreen"><div align="center">BL(mm)</div></td>
                            <td width="11%" class="stylegreen"><div align="center">FL(mm)</div></td>
                            <td width="11%" class="stylegreen"><div align="center">SL(mm)</div></td>
                            <td width="11%" class="stylegreen"><div align="center">BW(g)</div></td>
                            <td width="6%" class="stylegreen"><div align="center">SEX</div></td>
                            <td width="11%" class="stylegreen"><div align="center">Stage</div></td>
                            <td width="10%" class="stylegreen"><div align="center">GW(g)</div></td>
                            <td width="8%" class="stylegreen"><div align="center">Edit</div></td>
                            <td width="8%" class="stylegreen"><div align="center">Delete</div></td>
                          </tr>
                          <?
						for($b=1;$b<=$numgetbio;$b++)
						{
						$resgetbio = mysql_fetch_array($qrygetbio);
						$dbsno =  $resgetbio["sid"];
						$dbtl = $resgetbio["tl"];
						$dbbl = $resgetbio["bl"];
						$dbfl = $resgetbio["fl"];
						$dbsl = $resgetbio["sl"];
						$dbbw = $resgetbio["bw"];
						$dbsex = $resgetbio["sex"];
						$dbstage = $resgetbio["stageid"];
						$dbstagename = $resgetbio["stagename"];
						$dbgw = $resgetbio["gw"];
						?>
                       
                          <tr align="center" class="styleblack">
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbsno; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbtl; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbbl; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbfl; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbsl; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbbw; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbsex; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbstage."-".$dbstagename; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><? echo $dbgw; ?></td>
                            <td height="17" bgcolor="#ADCE4C" class="styleblack"><span class="style26">
                            <a href="biology.php?edtid=<? echo $dbsno; ?>&optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>"><img src="images/document_edit.png" width="20" height="20" border="0" /></a></span></td>
                            <td bgcolor="#ADCE4C" class="styleblack"><a href="biology.php?edtid=<? echo $dbsno; ?>&optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>"><span class="style26">
                              <input type="radio" name="chkDel[]" value="<?=$dbsno;?>" />
                            </span></a></td>
                          </tr>
                          <?
						}
						?>
                          <tr class="styleblack">
                            <td height="17" colspan="11" bgcolor="#6B716F" class="stylewhitesmall"><div align="right">
                              <input name="del" type="submit" class="styleblack" id="del" value="Delete">
                            </div></td>
                          </tr>
                        </table>
                    </form>
                    <?
                      if(!isset($_GET["import"]))
                      {
					  if(isset($_GET["edtid"]))
						{
						$showoptid2 = base64_decode($_GET["optid"]);
						$showspid2 = $_GET["spid"];
						$showsid2 = $_GET["edtid"];
						include "connect.inc.php";
						$sqlgetbio2 = "select * from biology left join stage on biology.stageid = stage.stageid where Optid=$showoptid2 and spid=$showspid2 and sid = $showsid2";
						//echo $sqlgetbio;
						$qrygetbio2 = mysql_query($sqlgetbio2);
						$numgetbio2 = mysql_num_rows($qrygetbio2);
						$resgetbio2 = mysql_fetch_array($qrygetbio2);
						$dbtl2 = $resgetbio2["tl"];
						$dbbl2 = $resgetbio2["bl"];
						$dbfl2 = $resgetbio2["fl"];
						$dbsl2 = $resgetbio2["sl"];
						$dbbw2 = $resgetbio2["bw"];
						$dbsex2 = $resgetbio2["sex"];
						$dbstage2 = $resgetbio2["stageid"];
						$dbstagename2 = $resgetbio2["stagename"];
						$dbgw2 = $resgetbio2["gw"];
						?>
							<form action="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>" method="post" name="form4" id="form4">
                              <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
                                <tr bgcolor="#000000" class="styleblack">
                                  <td colspan="9" bgcolor="#6B716F" class="stylewhitesmall"><div align="center" class="stylewhitesmall">Edit Biology Data (<span class="stylegreen"><? echo $_GET["spname"]; ?></span>)
                                          <input type="hidden" name="hdsid4" id="hdsid4" value="<? echo $showsid2; ?>">
                                    </div>
                                      <div align="left"></div></td>
                                </tr>
                                <tr class="styleblack">
                                  <td width="13%" class="stylegreen"><div align="center">TL(mm)</div></td>
                                  <td width="13%" class="stylegreen"><div align="center">BL(mm)</div></td>
                                  <td width="13%" class="stylegreen"><div align="center">FL(mm)</div></td>
                                  <td width="13%" class="stylegreen"><div align="center">SL(mm)</div></td>
                                  <td width="13%" class="stylegreen"><div align="center">BW(g)</div></td>
                                  <td width="7%" class="stylegreen"><div align="center">SEX</div></td>
                                  <td width="15%" class="stylegreen"><div align="center">Stage</div></td>
                                  <td width="6%" class="stylegreen"><div align="center">GW(g)</div></td>
                                  <td width="7%" class="stylegreen"><div align="center">Submit</div></td>
                                </tr>
                                <tr class="styleblack">
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="txttl2" type="text" class="styleblack" id="txttl" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbtl2; ?>" size="8" maxlength="8">
                                  </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="txtbl2" type="text" class="styleblack" id="txtbl2" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbbl2; ?>" size="8" maxlength="8">
                                  </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                    <input name="txtfl2" type="text" class="styleblack" id="txtfl22" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbfl2; ?>" size="8" maxlength="8">
</div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="txtsl2" type="text" class="styleblack" id="txtsl2" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbsl2; ?>" size="8" maxlength="8">
                                  </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="txtbw2" type="text" class="styleblack" id="txtbw2" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbbw2; ?>" size="8" maxlength="8">
                                  </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><label> </label>
                                      <div align="center">
                                        <select name="lstsex" class="styleblack" id="lstsex">
                                         
										  <?
										  if($dbsex2 == "M")
										  {
										  ?>
                                          <option value="M">Male</option>
                                          <option value="F">Female</option>
										    <option value=""></option>
										  <?
										  }										
										  else
										  {
										  ?>
										  <option value="F">Female</option>
										  <option value="M">Male</option>
										    <option value=""></option>
										  <?
										  }
										  ?>
										 
                                        </select>
                                    </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center"><span class="styletextbox">
                                      <select name="lststage2" class="styleblack" id="select2">
                                        <?php
							  echo "<option value='$dbstage2'>$dbstage2-$dbstagename2</option>";
							  echo "<option value=''></option>";
		include "connect.inc.php";
	  $sqlgetstage = "SELECT stageid,stagename FROM stage order by stageid";
	  //echo $sqlgetship;
	  $qrygetstage = mysql_query($sqlgetstage);
	  $numgetstage = mysql_num_rows($qrygetstage);
	   for($s=1;$s<=$numgetstage;$s++)
		{
			$resgetstage = mysql_fetch_array($qrygetstage);
			$dbstageid = $resgetstage["stageid"];
			$dbstagename = $resgetstage["stagename"];
				echo "<option value='$dbstageid'>$dbstageid-$dbstagename</option>";
			  }
			  ?>
                                  </select>
                                  </span></div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="txtgw2" type="text" class="styleblack" id="txtgw2" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" value="<? echo $dbgw2; ?>" size="8" maxlength="8">
                                  </div></td>
                                  <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                                      <input name="submit4" type="submit" class="styleblack" id="submit4" value="Edit">
                                  </div></td>
                                </tr>
                                <tr class="styleblack">
                                  <td height="17" colspan="9" bgcolor="#6B716F" class="stylewhitesmall"><div align="right"><a href="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>&import=1">Import</a></div></td>
                                </tr>
                              </table>
				    </form>
							<?
						}
						else
						{
					  ?>
                    <br>
					
                    <form name="form1" method="post" action="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>">
                      <table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
                        <tr bgcolor="#000000" class="styleblack">
                          <td colspan="9" bgcolor="#6B716F" class="stylewhitesmall"><div align="center" class="stylewhitesmall">Add Biology Data (<span class="stylewhitesmall"><? echo $_GET["spname"]; ?></span>)
                            <input type="hidden" name="hdspid" id="hiddenField2" value="<? echo $_GET["spid"]; ?>">
                          </div>
                          <div align="left"></div></td>
                        </tr>
                        <tr class="styleblack">
                          <td width="13%" class="stylegreen"><div align="center">TL(mm)</div></td>
                          <td width="13%" class="stylegreen"><div align="center">BL(mm)</div></td>
                          <td width="13%" class="stylegreen"><div align="center">FL(mm)</div></td>
                          <td width="13%" class="stylegreen"><div align="center">SL(mm)</div></td>
                          <td width="13%" class="stylegreen"><div align="center">BW(g)</div></td>
                          <td width="7%" class="stylegreen"><div align="center">SEX</div></td>
                          <td width="15%" class="stylegreen"><div align="center">Stage</div></td>
                          <td width="6%" class="stylegreen"><div align="center">GW(g)</div></td>
                          <td width="7%" class="stylegreen"><div align="center">Submit</div></td>
                        </tr>
                        <tr class="styleblack">
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txttl" type="text" class="styleblack" id="txtbottomdepth" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txtbl" type="text" class="styleblack" id="txtbl" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txtfl" type="text" class="styleblack" id="txtfl" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txtsl" type="text" class="styleblack" id="txtsl" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txtbw" type="text" class="styleblack" id="txtbw" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><label>
                              <div align="center">
                                <select name="lstsex" class="styleblack" id="lstsex">
                                  <option value=""></option>
                                  <option value="M">Male</option>
                                  <option value="F">Female</option>
                                </select>
                              </div>
                            </label></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center"><span class="styletextbox">
                          <select name="lststage" class="styleblack" id="lststage">
                              <?php
							  echo "<option value=''></option>";
		include "connect.inc.php";
	  $sqlgetstage = "SELECT stageid,stagename FROM stage order by stageid";
	  //echo $sqlgetship;
	  $qrygetstage = mysql_query($sqlgetstage);
	  $numgetstage = mysql_num_rows($qrygetstage);
	   for($s=1;$s<=$numgetstage;$s++)
		{
			$resgetstage = mysql_fetch_array($qrygetstage);
			$dbstageid = $resgetstage["stageid"];
			$dbstagename = $resgetstage["stagename"];
				echo "<option value='$dbstageid'>$dbstageid-$dbstagename</option>";
			  }
			  ?>
                          </select>
                          </span></div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="txtgw" type="text" class="styleblack" id="txtgw" onKeyPress="if (event.keyCode&lt;46||event.keyCode&gt;57) event.returnValue=false" size="8" maxlength="8">
                          </div></td>
                          <td height="17" bgcolor="#ADCE4C" class="stylewhitesmall"><div align="center">
                              <input name="submit1" type="submit" class="styleblack" id="submit1" value="Submit">
                          </div></td>
                        </tr>
                        <tr class="styleblack">
                          <td height="17" colspan="9" bgcolor="#6B716F" class="stylewhitesmall"><div align="right"><a href="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>&d=<? echo $_GET["d"]; ?>&import=1">Import</a></div></td>
                        </tr>
                      </table>
                    </form>
                    <?
					  }
					  }
					  elseif(isset($_GET["import"]))
					  {
					  	?>                    
                    <br>
                    <form action="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $_GET["spname"]; ?>" method="post" enctype="multipart/form-data" name="form2">
                      <table width="60%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
                        <tr bgcolor="#000000" class="styleblack">
                          <td colspan="2" bgcolor="#6B716F" class="stylewhitesmall"><div align="center">Import  Biology Data</div>
                              <div align="left"></div></td>
                        </tr>
                        <tr class="styleblack">
                          <td width="23%" class="stylegreen"><div align="right">Species&nbsp;&nbsp; </div></td>
                          <td width="77%" class="stylegreen"><? echo $_GET["spname"]; ?>
                          <input type="hidden" name="hdspid2" id="hiddenField" value="<? echo $_GET["spid"]; ?>"></td>
                        </tr>
                        <tr class="styleblack">
                          <td height="8" bgcolor="#ADCE4C" class="stylegreen"><div align="right">Import File&nbsp;&nbsp; </div></td>
                          <td height="8" bgcolor="#ADCE4C" class="stylewhitesmall"><label>
                            <input name="fileCSV" type="file" class="styleblack" id="fileCSV">
                          </label></td>
                        </tr>
                        <tr class="styleblack">
                          <td height="9" colspan="2" bgcolor="#ADCE4C" class="stylegreen"><div align="center">
                            <input name="submit2" type="submit" class="styleblack" id="submit2" value="Submit">
                          </div></td>
                        </tr>
                        <tr class="styleblack">
                          <td height="17" colspan="2" bgcolor="#6B716F" class="stylewhitesmall"><div align="right"><a href="biology.php?optid=<? echo $_GET["optid"]; ?>&y=<? echo $_GET["y"]; ?>&spid=<? echo $_GET["spid"]; ?>&spname=<? echo $dbspname; ?>">Back</a></div></td>
                        </tr>
                      </table>
                    </form>
                    <?
					  }
						
					  }
					  ?>
                    
                </div></td>
            </tr>

            <tr>
              <td height="19" bgcolor="#6B716F"><div align="right"></div></td>
            </tr>
          </table>
      <?
	  }
	  else
	  {
	?>
	  <br><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 Fishing Operation </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>