<?php

include("../include/session.php");
if(!$session->logged_in){
	header("Location: ../main.php");
}else{
//	include("../include/db.php");
	include "../header.php";
	$d = date("d");
	$m = date("m");
	$y = date("Y");

	$empFName = mysql_real_escape_string($_POST['firstName']);
	$empLName = mysql_real_escape_string($_POST['empLName']);
	$empAge = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
	$empSex = mysql_real_escape_string($_POST['empSex']);
	$empCountry = mysql_real_escape_string($_POST['empCountry']);
	$empIdNo = mysql_real_escape_string($_POST['empIdNo']);
	$empPost = mysql_real_escape_string($_POST['empPost']);
	$empContact = mysql_real_escape_string($_POST['empContact']);




	$query = "INSERT INTO nam_employees (empFName, empLName, empContact, empAge, empSex, empCountry, empIdNo, empPost) VALUES ('".$empFName."','".$empLName."', '".$empContact."', '".$empAge."','".$empSex."','".$empCountry."', '".$empIdNo."', '".$empPost."')";
	execsql($query);


	//second part



	$query = "SELECT * FROM nam_employees WHERE empFName ='".$empFName."' AND empLName = '".$empLName."'";
	$result = execsql($query);
	if(!$result) {
		die('Could not query: ' . mysql_error());
	}

	$num = mysql_num_rows($result);
	mysql_close();

	?>

	<?php

	require_once('classes/tc_calendar.php');
	?>

<form method="post" action="updateEmployee.php"><?php
$i = 0;

while($i < $num) {
	$f1 = mysql_result($result, $i,"empId");
	$f2 = mysql_result($result, $i,"empFName");
	$f3 = mysql_result($result, $i,"empLName");
	$f4 = mysql_result($result, $i,"empAge");
	$f5 = mysql_result($result, $i,"empSex");
	$f6 = mysql_result($result, $i,"empCountry");
	$f7 = mysql_result($result, $i,"empIdNo");
	$f8 = mysql_result($result, $i, "empPost");
	$f9 = mysql_result($result, $i, "empContact");


	?>
<link href="calendar.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../include/calendar.js"></script>
<table>
	<tr>
		<td>Id Number:</td>
		<td><input name="empId" value="<?php echo $f1; ?>" /></td>
		<td>First Name:</td>
		<td><input name="empFName" value="<?php echo $f2; ?>" /></td>
	</tr>
	<tr>
		<td>Last name:</td>
		<td><input name="empLName" value="<?php echo $f3; ?>" /></td>
		<td>Contact Number:</td>
		<td><input name="empContact" value="<?php echo $f9; ?>" /></td>
	</tr>
	<tr>
		<td>Age:</td>
		<td><input name="empAge" value="<?php echo $f4; ?>" /></td>
		<td>Sex:</td>
		<td><input name="empSex" value="<?php echo $f5; ?>" /></td>
	</tr>
	<tr>
		<td>Citizen?:</td>
		<td><input name="empCountry" value="<?php echo $f6; ?>" /></td>
		<td>Omang No:</td>
		<td><input name="empIdNo" value="<?php echo $f7; ?>" /></td>
	</tr>
	<tr>
		<td>Postal Address:</td>
		<td><input name="empPost" value="<?php echo $f8; ?>" /></td>
		<td colspan="2">&nbsp;</td>
	</tr>
	<tr>
		<td>Employment Date:</td>
		<td colspan="3"><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$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>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>

	<tr>
		<td id="row1">Married?:</td>
		<td><select name="empMStatus">
		<option value="Unknown">Unknown</option>
			<option value="Single">Single</option>
			<option value="Married">Married</option>
			<option value="Divorced">Divorced</option>
		</select></td>
		<td>Passport:</td>
		<td><input name="empPass" value="" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>Residential Address:</td>
		<td><input name="empRes" value="" /></td>
		<td>Bank Name:</td>
		<td><select name="empBank">
			<option value="">Choose One</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>
	</tr>
	<tr>
		<td>Account number:</td>
		<td><input name="empAccNo" value="" /></td>
		<td>Branch Number:</td>
		<td><input name="empBranch" value="" /></td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>Dependants:</td>
		<td><input name="empDepend" value="" /></td>
		<td>Position:</td>
		<td><select name="empPos">
			<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="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 colspan="2">&nbsp;</td>
	</tr>
	<tr>
		<td>Emergency Contact:</td>
		<td><input name="emergName" value="" /></td>
		<td>Contacts Relation to Employee:</td>
		<td><input name="emergRelation" value="" /></td>
	</tr>
	<tr>
		<td>Contacts Number:</td>
		<td><input name="emergNo" value="" /></td>
		<td colspan="2">&nbsp;</td>
	</tr>

	<tr>
		<td>Shoe size:</td>
		<td><select name="empShoe">
			<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>
		</select></td>
		<td>Overall Size:</td>
		<td><select name="empOverall">
			<option value="42">42</option>
			<option value="44">44</option>
			<option value="46">46</option>
			<option value="48">48</option>
			<option value="50">50</option>
			<option value="52">52</option>
		</select></td>
	</tr>
	<tr>
		<td>Hourly Rate:</td>
		<td><input name="empRate" value="" /></td>
		<td colspan="2">&nbsp;</td>
	</tr>
</table>
<input type="submit" name="submitok" value="   Add Employee   " /></form>
		<?php
		$i++;
}
include "../footer.html";
}
?>

