<?php
include("../include/session.php");
if(!$session->isRadstoneReceptionUser() && !$session->isAdmin()){
	header("Location: ../HR/employeeMenu.php");
}else{
	require_once('classes/tc_calendar.php');
	include("../header.php");
//	include("../include/db.php");
	?>
<script language="javascript" src="../include/calendar.js"></script>
<link href="calendar.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../include/calendar.js"></script>
<script type="text/javascript">
<!-------

//----->
</script>


<form method="post" action="modifyFoundEmployee.php"><?php
$inputId = mysql_real_escape_string($_GET['empId']);


$query = "SELECT * FROM nam_employees WHERE empId ='".$inputId."'";


$result = execsql($query);
if(!$result) {
	die('Could not query: ' . mysql_error());
}

$num = mysql_num_rows($result);
mysql_close();
if($num > 0){
	echo "<h3>Modify Employee</h3><br />";
	$i = 0;
	while ($i < $num) {
		$f1=mysql_result($result,$i,"empFName");
		$f2=mysql_result($result,$i,"empLName");
		$f3=mysql_result($result,$i,"empContact");
		$f4=mysql_result($result,$i,"empAge");
		$f5=mysql_result($result,$i,"emergName");
		$f6=mysql_result($result,$i,"emergNo");
		$f7=mysql_result($result,$i,"emergRelation");
		$f8=mysql_result($result,$i,"empBank");
		$f10=mysql_result($result, $i, "empId");
		//			$f11=mysql_result($result, $i, "pob");
		$f12=mysql_result($result, $i, "empSex");
		$f13=mysql_result($result, $i, "empMStatus");
		$f14=mysql_result($result, $i, "empIdNo");
//		$f15=mysql_result($result, $i, "empPass");
		$f17=mysql_result($result, $i, "empCountry");
		$f18=mysql_result($result, $i, "empPost");
//		$f19=mysql_result($result, $i, "empRes");
		$f20=mysql_result($result, $i, "empAccNo");
		$f21=mysql_result($result, $i, "empBranch");
		$f22=mysql_result($result, $i, "empDepend");
		$f23=mysql_result($result, $i, "empPos");
		$f27=mysql_result($result, $i, "empSection");
		$f24=mysql_result($result, $i, "empDateEmp");
		$f25=mysql_result($result, $i, "empShoe");
		$f26=mysql_result($result, $i, "empOverall");
		$f28=mysql_result($result, $i, "empEmployDate");
		$f29=mysql_result($result, $i, "empRate");
		$f30=mysql_result($result, $i, "firstWarning");
		$f31=mysql_result($result, $i, "writtenWarning");
		$f32=mysql_result($result, $i, "finalWarning");
		$f33=mysql_result($result, $i, "performance");
		
//		$dateOfBirth = date("d-m-Y", strtotime($f4));
		$da = date("d", strtotime($f4));
		$ma = date("m", strtotime($f4));
		$ya = date("Y", strtotime($f4));
//		echo $da . $ma . $ya;

		$de = date("d", strtotime($f24));
		$me = date("m", strtotime($f24));
		$ye = date("Y", strtotime($f24));
		
//		echo $de . $me. $ye;
		?>
		
<table>
	<tr>
		<td id="row1">ID Number:</td>
		<td><input name="empId" readonly="readonly"
			value="<?php echo $f10; ?>" /></td>
		<td id="row1">Name:</td>
		<td><input name="empFName" value="<?php echo $f1; ?>" /></td>
	</tr>
	<tr>
		<td>Last Name:</td>
		<td><input name="empLName" value="<?php echo $f2; ?>" /></td>

		<td>Contact Number:</td>
		<td><input name="empContact" value="<?php echo $f3; ?>" /></td>
	</tr>

	<tr>
		<td>Date of Birth:</td>
		<td><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($da, $ma, $ya);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(1920, 2030);
	 // $myCalendar->dateAllow('2008-05-13', '2010-03-01', false);
		//$myCalendar->setHeight(350);
		//$myCalendar->autoSubmit(true, "form1");
		$myCalendar->writeScript();

		?></td>

		<td>National Id Number:</td>
		<td><input name="empIdNo" value="<?php echo $f14; ?>" /></td>
	</tr>

	<tr>
		<td>Sex:</td>
		<td>
		<select name="empSex">
			<option value="<?php echo $f12?>"><?php echo $f12?></option>
			<option value="Male">Male</option>
			<option value="Female">Female</option>
			</select>
<!--		<input name="empSex" value="<?php echo $f12; ?>" />-->
		</td>
		<td>Martial Status:</td>
		<td><select name="empMStatus">
			<option value="<?php echo $f13?>"><?php echo $f13?></option>
			<option value="Single">Single</option>
			<option value="Married">Married</option>
			<option value="Divorced">Divorced</option>
		</select>
		
<!--		<input name="empMStatus" value="<?php echo $f13; ?>" />-->
		</td>
	</tr>
	<tr>

		<td>Citizen:</td>
		<td>
		<select name="empCountry">
			<option value="<?php echo $f17?>"><?php echo $f17?></option>
			<option value="No">No</option>
			<option value="Yes">Yes</option>
			</select>
<!--		<input name="empCountry" value="<?php echo $f17; ?>" />-->
		</td>
	</tr>

	<tr>
		<td>Postal Address:</td>
		<td><input name="empPost" value="<?php echo $f18; ?>" /></td>

	</tr>
	<tr>
		<td>Dependants:</td>
		<td><input name="empDepend" value="<?php echo $f22; ?>" /></td>
		<td colspan="2">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>Bank Name:</td>
		<td><select name="empBank">
		  <option value="<?php echo $f8?>">
		    <?php echo $f8?>
	      </option>
		  <option value="FNB">FNB</option>
		  <option value="Barclays">Barclays</option>
		  <option value="Baroda">Baroda</option>
		  <option value="Standard Chartered">Standard Chartered</option>
		  <option value="Stanbic">Stanbic Bank</option>
      </select></td>
		<td>Account number:</td>
		<td><input name="empAccNo" value="<?php echo $f20; ?>" /></td>
	</tr>
	<tr>
		<td>Branch Number:</td>
		<td><input name="empBranch" value="<?php echo $f21; ?>" /></td>
		<td colspan="2">&nbsp;</td>
	</tr>
	<tr>

		<td>Position:</td>
		<td><select name="empPos">
			<option value="<?php echo $f23?>"><?php echo $f23?></option>
			<option value="Unskilled Labourer">Unskilled Labourer</option>
			<option value="Semi-skilled Labourer">Semi-skilled Labourer</option>
			<option value="Skilled Labourer">Skilled Labourer</option>
			<option value="Operator">Operator</option>
			<option value="Driver">Driver</option>
			<option value="Supervisor">Supervisor</option>
			<option value="Other">Other</option>
		</select></td>
	</tr>
	<tr>
		<td>Section:</td>
		<td><select name="empSection">
			<option value="<?php echo $f27?>"><?php echo $f27?></option>
			<option value="Office Staff">A: Office Staff</option>
			<option value="Workshop/Stones">B: Workshop / Stones</option>
			<option value="Aggregate/Mixing">C: Agrregate / Mixing</option>
			<option value="Extruding/Curing">D: Extruding / Curing</option>
			<option value="Depalleting/Palletting">E: Depalleting / Palletting</option>
		</select></td>
		<td>Date Employed:</td>
		<td><?php
		$myCalendar = new tc_calendar("date2", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($de, $me, $ye);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(1980, 2030);
	 // $myCalendar->dateAllow('2008-05-13', '2010-03-01', false);
		//$myCalendar->setHeight(350);
		//$myCalendar->autoSubmit(true, "form1");
		$myCalendar->writeScript();

		?></td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>Emergency Contact:</td>
		<td><input name="emergName" value="<?php echo $f5; ?>" /></td>
		<td>Emergency Contacts Relation to Employee:</td>
		<td><input name="emergRelation" value="<?php echo $f7; ?>" /></td>
	</tr>

	<tr>
		<td>Emergency Contacts Number:</td>
		<td><input name="emergNo" value="<?php echo $f6; ?>" /></td>
		<td>Employement :</td>
		<td><?php echo $employed; ?></td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>Shoe size:</td>
		<td><select name="empShoe">
			<option value="<?php echo $f25?>"><?php echo $f25?></option>
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
			<option value="5">5</option>
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
		</select></td>
		<td>Overall Size:</td>
		<td><select name="empOverall">
			<option value="26">26</option>
			<option value="28">28</option>
			<option value="30">30</option>
			<option value="32">32</option>
			<option value="34">34</option>
			<option value="36">36</option>
			<option value="38">38</option>
			<option value="40">40</option>
			<option value="42">42</option>
			<option value="44">44</option>
			<option value="44">46</option>
			<option value="44">48</option>
		</select></td>
	</tr>
	<tr>
		<td>End of Employment Date:</td>
		<td><?php
		$myCalendar = new tc_calendar("date3", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		//$myCalendar->setDate(19, 6, 2009);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2000, 2030);
	 // $myCalendar->dateAllow('2008-05-13', '2010-03-01', false);
		//$myCalendar->setHeight(350);
		//$myCalendar->autoSubmit(true, "form1");
		$myCalendar->writeScript();

		?></td>
		<td>Rate:</td>
		<td><input name="empRate" value="<?php echo  $f29; ?>" /></td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>HAS RECEIVED FIRST WARNING:</td>
		<td><select name="firstWarning">
			<option value="<?php echo $f30?>"><?php echo $f30?></option>
			<option value="NO">NO</option>
			<option value="YES">YES</option>
		</select>
		
		
		<td>HAS RECEIVED WRITTEN WARNING:</td>
		<td><select name="writtenWarning">
			<option value="<?php echo $f31?>"><?php echo $f31?></option>
			<option value="NO">NO</option>
			<option value="YES">YES</option>
		</select></td>
	</tr>


	<tr>
		<td>HAS RECEIVED FINAL WARNING:</td>
		<td><select name="finalWarning">
			<option value="<?php echo $f32?>"><?php echo $f32?></option>
			<option value="NO">NO</option>
			<option value="YES">YES</option>
		</select></td><td>Performance Note</td><td><textarea name="performance" cols="20" rows="6"><?php echo $f33?></textarea>
	</tr>
	<tr>
<!--		<td><a href="javascript: hi();">Click here</a> to remove this employee</td>-->
		<td><a href="manipulate/removeEmp.php?id=<?php echo $f10?>">Click here</a> to remove this employee</td>
		
	</tr>


</table>
		<?php
		$i++;
	}
	?>
  <input type="submit" name="submitok" value="Save and New" />
	<input type="submit" name="submitok" value="Save and Close" /></form>
	<?php 
}else {
	echo "Sorry, information regarding that person is no longer available"; }

	include("../footer.html");
}