<?
session_start();
ob_start();
?>
<html>
<head>
<script language="JavaScript"> 
function onInsert()
{ 
		if(form1.txtzoneid.value =="")
		{
			alert("You not fill zone!");
			form1.txtzoneid.focus();
			return false;
		}
		else
		{
			return true; 
		}	 
} 

function onUpdate() 
{ 
		if(form2.txtzoneid2.value =="")
		{
			alert("You not fill zone!");
			form2.txtzoneid2.focus();
			return false;
		}
		else
		{
			return true;
		} 
} 
</script> 
<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;
}
.styleblacklargered {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color:#FF0000;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	color: #FFFFFF;
	text-decoration: none;
}
a:hover {
	color: #FF3300;
	text-decoration: none;
}
a:active {
	color: #FFFFFF;
	text-decoration: none;
}
.style1 {color: #FF0000}
.style2 {font-weight: bold}
.style3 {color: #FF0000; font-weight: bold; }
-->
</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="464" height="705" valign="top" bgcolor="#CCCCCC"><?
if($_POST[submit])
{
	$inszoneid = trim($_POST["txtzoneid"]);
	$insdesc = trim($_POST["txtdesc"]);
	require_once("zone_function.inc.php");
	InsertZone($inszoneid,$insdesc);
	$tlog = "Add Fishing Zone ".$inszoneid;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);
}
if($_POST[submit2])
{
	$edtzoneid = $_POST["hdzoneid"];
	$edtnewzoneid = trim($_POST["txtzoneid2"]);
	$edtdesc = trim($_POST["txtdesc2"]);
	require_once("zone_function.inc.php");
	EditZone($edtzoneid,$edtnewzoneid,$edtdesc);
	$tlog = "Edit Fishing Zone ".$edtzoneid." To ".$edtnewzoneid;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);
}
if($_POST[submit3])
{
	$delzoneid = $_POST["hdzoneid2"];
	require_once("zone_function.inc.php");
	DeleteZone($delzoneid);
	$tlog = "Delete Fishing Zone ".$delzoneid;
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);
}

?>  
<br>
	   <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
        <tr>
            <td width="32%" bgcolor="#000000" class="stylewhitesmall"><div align="center"><span class="stylewhitesmall">Fishing area</span></div></td>
          <td width="31%" bgcolor="#000000" class="stylewhitesmall"><div align="center">Description</div></td>
          <td width="17%" bgcolor="#000000" class="stylewhitesmall"><div align="center"><span class="stylewhitesmall">Edit</span></div></td>
          <td width="20%" bgcolor="#000000" class="stylewhitesmall"><div align="center"><span class="stylewhitesmall">Delete</span></div></td>
	   </tr>
        
          <div align="center">
            <?
	  include "connect.inc.php";
	  $sqlgetzone = "select zone,description from fishingzone order by zone";
	  
	  $qrygetzone = mysql_query($sqlgetzone);
	  $numgetzone = mysql_num_rows($qrygetzone);
	   for($i=1;$i<=$numgetzone;$i++)
		{
			$resgetzone = mysql_fetch_array($qrygetzone);
			$dbzone = $resgetzone["zone"];
			$dbdesc = $resgetzone["description"];
			$encodezone = base64_encode($dbzone);
			?>
			
            <tr align="center" class="stylewhitesmall">
            
			  <td bgcolor="#006666" class="stylewhitesmall"><? echo $dbzone; ?></td>
              <td align="left" bgcolor="#006666" class="stylewhitesmall"><? echo $dbdesc; ?></td>
                <td bgcolor="#006666">
                <div align="center"><a href="fishingzone.php?edtzone=<? echo $encodezone; ?>"><img src="images/document_edit.png" width="20" height="20" border="0"></a></div></td>
                  <td bgcolor="#006666"><div align="center"><a href="fishingzone.php?delzone=<? echo $encodezone; ?>"><img src="images/close.png" width="20" height="20" border="0"></a></div></td>
            

		    </tr>
		    <?
        }
      ?>
          </div>
        
        <tr>
          <td colspan="4" bgcolor="#000000"><div align="right">
          <span class="stylewhitesmall">
          
          <a href="fishingzone.php"><img src="images/add.png" width="24" height="24" border="0"></a></span><span class="styleblack">&nbsp;&nbsp;&nbsp; </span></div>
          </td>
        </tr>
      </table>
	  <p align="center" class="styleblacklarge">&nbsp;</p>
      <p align="center" class="styleblacklarge">&nbsp;</p>
      <p align="center" class="stylegreen">&nbsp;</p>
      <p align="center" class="styleblack">&nbsp;</p></td>
      <td width="554" valign="top" bgcolor="#CCCCCC"><?
	  if(!isset($_GET["edtzone"]) && !isset($_GET["delzone"]))
	  {
	  ?><br>
        <form action="fishingzone.php" method="post" name="form1" id="form1" onSubmit="return onInsert();">
          <table width="70%" height="122" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td height="19" colspan="2" background="images/index_01.gif"><div align="center"><span class="stylewhite">Insert Fishing area </span> </div>
                  <div align="right"></div></td>
            </tr>
            <tr>
              <td height="14" colspan="2" bgcolor="#ADCE4C" class="style1"><label>                </label></td>
            </tr>
            <tr>
              <td width="26%" height="25" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Fishing Area </span>&nbsp; </div></td>
              <td width="74%" height="25" bgcolor="#ADCE4C"><input name="txtzoneid" type="text" class="styleblack" id="txtzoneid" size="30" maxlength="30" /></td>
            </tr>
            <tr>
              <td height="25" valign="top" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Description </span>&nbsp; </div></td>
              <td height="25" bgcolor="#ADCE4C"><label>
                <textarea name="txtdesc" cols="30" rows="5" class="styleblack" id="txtdesc"></textarea>
              </label></td>
            </tr>
            <tr>
              <td height="34" colspan="2" bgcolor="#ADCE4C"><label>
                  <div align="center">
                    <input name="submit" type="submit" class="styleblack" id="submit" value="Insert" />
                    <input name="Reset" type="reset" class="styleblack" id="button" value="Cancel">
                  </div>
                </label></td>
            </tr>
            <tr>
              <td height="19" colspan="2" bgcolor="#6B716F"><div align="right"></div></td>
            </tr>
          </table>
        </form>
        <?
		}
		elseif(isset($_GET["edtzone"]))
		{
		$edtzoneid = base64_decode($_GET["edtzone"]);
		$sqlgetdesc = "select description from fishingzone where zone = '$edtzoneid'";
		$qrygetdesc = mysql_query($sqlgetdesc);
		$resgetdesc = mysql_fetch_array($qrygetdesc);
		$describ = $resgetdesc["description"];
        ?>
        <br>   
        <form action="fishingzone.php" method="post" name="form2" id="form2" onSubmit="return onUpdate()">
          <table width="70%" height="122" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td height="19" colspan="2" background="images/index_01.gif"><div align="center"><span class="stylewhite">Edit Fishing area </span> </div>
                  <div align="right"></div></td>
            </tr>
            <tr>
              <td height="14" colspan="2" bgcolor="#ADCE4C" class="style1"><label>
  &nbsp;</label></td></tr>
            <tr>
              <td width="31%" height="25" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Fishing Area</span> &nbsp; </div></td>
              <td width="69%" height="25" bgcolor="#ADCE4C"><input name="txtzoneid2" type="text" class="styleblack" id="txtzoneid2" value="<? echo $edtzoneid; ?>" size="30" maxlength="30" />
              <input name="hdzoneid" type="hidden" id="hdzoneid" value="<? echo $edtzoneid; ?>"></td>
            </tr>
            <tr>
              <td height="25" valign="top" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Description </span>&nbsp; </div></td>
              <td height="25" bgcolor="#ADCE4C"><label>
              <textarea name="txtdesc2" cols="30" rows="5" class="styleblack" id="txtdesc2"><? echo $describ; ?> </textarea>
              </label></td>
            </tr>
            <tr>
              <td height="34" colspan="2" bgcolor="#ADCE4C"><label>
                <div align="center">
                    <input name="submit2" type="submit" class="styleblack" id="submit2" value="Update" />
                    <input name="button2" type="button" class="styleblack" id="button2" value="Cancel" onClick="window.location='fishingzone.php';">
                </div>
                </label></td>
            </tr>
            <tr>
              <td height="19" colspan="2" bgcolor="#6B716F"><div align="right"></div></td>
            </tr>
          </table>
        </form>
        <?
		}
		if(isset($_GET["delzone"]))
		{
		$delzoneid = base64_decode($_GET["delzone"]);
		?>
        <br>
        <form action="fishingzone.php" method="post" name="form3" id="form3">
          <table width="90%" height="86" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="100%" height="19" background="images/index_01.gif"><div align="center"><span class="stylewhite">Delete Fishing area </span> </div>
                  <div align="right"></div></td>
            </tr>
            <tr>
              <td height="25" bgcolor="#ADCE4C" class="style1"><label>
                  <br><div align="center" class="stylewhite">
                <input name="hdzoneid2" type="hidden" id="hdzoneid2" value="<? echo $delzoneid; ?>">
                &nbsp; Are you sure to delete fishinng area '<span class="styleblacklargered"><? echo $delzoneid; ?></span>'?</div></td>
            </tr>


            <tr>
              <td height="34" bgcolor="#ADCE4C"><label>
                  <div align="center">
                    <input name="submit3" type="submit" class="styleblack" id="submit3" value="Confirm" />
                    <input name="button3" type="button" class="styleblack" id="button3" value="Cancel" onClick="window.location='fishingzone.php';">
                </div>
                </label></td>
            </tr>
            <tr>
              <td height="19" bgcolor="#6B716F"><div align="right"></div></td>
            </tr>
          </table>
        </form>
        <?
        }
		?></td>
  </tr>
	<tr>
	  <td colspan="2" bgcolor="#006666">&nbsp;</td>
  </tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>