<!--Notice: (c)2013 This page is part of the management program for Tlhomeso Timbers, Gaborone, 
and developed by Customized Software (Pty) Ltd, Gaborone, Botswana. 
Customized Software holds the copyright on the source code on this and all other pages in the 
management program. For more info contact Customized Software on email: info@bwcustomized.com-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include ("../navigation/header.php");
$page_name = "HR-edit";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");


?>
<!--style sheets-->
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />


<!--jscript-->
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/lower_case.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/upper_case.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script>  






</head>
<?php
$table_name = $_SESSION['db_prefix']."_list_department";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
$table_name = $_SESSION['db_prefix']."_list_positions";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}


$table_name = $_SESSION['db_prefix']."_list_places";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId3[$b] = mysql_result($position_result, $b, "item_name");
		$arrName3[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}

$table_name = $_SESSION['db_prefix']."_list_country";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId4 = array ();
	$arrName4 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId4[$b] = mysql_result($position_result, $b, "item_name");
		$arrName4[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}	
	
$table_name = $_SESSION['db_prefix']."_list_banks";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId5 = array ();
	$arrName5 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId5[$b] = mysql_result($position_result, $b, "item_name");
		$arrName5[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_branch";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId6 = array ();
	$arrName6 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId6[$b] = mysql_result($position_result, $b, "item_name");
		$arrName6[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}

$emp_id = $_GET['emp_id'];
  	
if ($emp_id!='0') {
$table_name2 = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT * FROM $table_name2 WHERE emp_id ='".$emp_id."' ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);	

$a0 = mysql_result($employee_result, 0, "emp_first_name");
$a1 = mysql_result($employee_result, 0, "emp_last_name");
$a2 = mysql_result($employee_result, 0, "id_number");
$a3 = mysql_result($employee_result, 0, "birth_date");
$a4 = mysql_result($employee_result, 0, "employ_date");
$a5 = mysql_result($employee_result, 0, "emp_no");
$a6 = mysql_result($employee_result, 0, "gender");
$a7 = mysql_result($employee_result, 0, "bag_box");
$a8 = mysql_result($employee_result, 0, "box_no");
$a9 = mysql_result($employee_result, 0, "postal_place");
$a10 = mysql_result($employee_result, 0, "phys_address");
$a11 = mysql_result($employee_result, 0, "phys_place");
$a12 = mysql_result($employee_result, 0, "emergency_name");
$a13 = mysql_result($employee_result, 0, "emergency_phone");
$a14 = mysql_result($employee_result, 0, "position");
$a15 = mysql_result($employee_result, 0, "pay_period");
$a16 = mysql_result($employee_result, 0, "rate");
$a17 = mysql_result($employee_result, 0, "end_employ_date");
$a18 = mysql_result($employee_result, 0, "bank");
$a19 = mysql_result($employee_result, 0, "bank_branch");
$a20 = mysql_result($employee_result, 0, "bank_account");
$a21 = mysql_result($employee_result, 0, "clothing_size");
$a22 = mysql_result($employee_result, 0, "shoe_size");
$a23 = mysql_result($employee_result, 0, "cell");
$a24 = mysql_result($employee_result, 0, "phone");
$a25 = mysql_result($employee_result, 0, "email");
$a26 = mysql_result($employee_result, 0, "country");
$a27 = mysql_result($employee_result, 0, "marital_status");
$a28 = mysql_result($employee_result, 0, "department");
$a29 = mysql_result($employee_result, 0, "position");
$a30 = mysql_result($employee_result, 0, "employ_date");
$a31 = mysql_result($employee_result, 0, "end_employ_date");
$a31 = "";
$a32 = "";
$a33 = "";
$a34 = mysql_result($employee_result, 0, "citizen");
$a35 = mysql_result($employee_result, 0, "nationality");
$a36 = mysql_result($employee_result, 0, "notes");
$a37 = mysql_result($employee_result, 0, "pay_unit");
$a38 = mysql_result($employee_result, 0, "leave_days");
$a39 = mysql_result($employee_result, 0, "time_keeping");


require_once('../include/tc_calendar.php');
echo '<br>'.date("Y-m-d", strtotime($a3));

$birth_date = strtotime($a3);
$d1 = date("d", $birth_date ) ;
$m1 = date("m", $birth_date ) ;
$y1 = date("Y", $birth_date ) ;


$employ_date = strtotime($a4);
$d2 = date("d", $employ_date ) ;
$m2 = date("m", $employ_date ) ;
$y2 = date("Y", $employ_date ) ;

$end_employ_date = strtotime($a17);
$d3 = date("d", $end_employ_date ) ;
$m3 = date("m", $end_employ_date ) ;
$y3 = date("Y", $end_employ_date ) ;
}	
?>

<body>

<div class="main_frame">
 <div class="page_head_frame">
    <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="330"><label class="label_page_head">Edit  </label><label class="label_page_head_2"> <?php echo $a0." ".$a1 ?></label></td>
            <td width="350"><!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("employee_select","req","Please select an employee.");
</script></td>
            </tr>
        </table>
      </div>

<form action="employee_details_edit_save.php" method="POST">
<div class="page_middle_frame">
<div class="page_inside_frame">
<div align="left">Personal details</div>
  <table width="640" id="table_details_display">
    <tr>
      <td height="25">Employee no:</td>
      <td><b><?php echo $a5 ?></b></td>
      <td>id number:</td>
      <td><input name="id_number_text" type="text" class="text100" id="id_number_text" value="<?php echo $a2 ?>" onkeyup="ToUpper(this)" onfocus = "this.select();"/></td>
      </tr>
    <tr>
      <td width="157" height="25">First name:</td>
      <td width="177"><input name="first_name_text" type="text" class="text100" id="first_name_text" value="<?php echo $a0 ?>" onfocus = "this.select();" onBlur="capitalize(this)"/></td>
      <td width="116">Last name:</td>
      <td width="170"><input name="last_name_text" type="text" class="text100" id="last_name_text" value="<?php echo $a1 ?>" onBlur="capitalize(this)" onfocus = "this.select();"/></td>
      </tr>
    <tr>
      <td height="25">Date of birth:</td>
      <td colspan="3"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("birth_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d1, $m1, $y1);
		$myCalendar->setYearInterval(1950, 2010);
		//output the calendar
		$myCalendar->writeScript();
?></td>
      </tr>
    <tr>
      <td height="25">Gender:</td>
      <td><span class="wizard">
        <select name="gender_select" class="select120" id="gender_select">
          <option value="female">female</option>
          <option value="male">male</option>
          <option value="<?php echo $a6 ?>" selected="selected"><?php echo $a6 ?></option>
        </select>
      </span></td>
      <td>Marital status:</td>
      <td><span class="wizard">
        <select name="marital_status_select" class="select120" id="marital_status_select">
          <option value="single">single</option>
          <option value="married">married</option>
          <option value="divorced">divorded</option>
          <option value="seperated">seperated</option>
          <option value="<?php echo $a27 ?>" selected="selected"><?php echo $a27 ?></option>
          </select>
      </span></td>
      </tr>
  </table>
</div>
</td>
</tr>
<tr>
<td>
<div class="page_inside_frame">
<div align="left">Contact details</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="127" height="25">Postal address:</td>
      <td width="62"><select name="bag_box_select" class="select80" id="bag_box_select">
        <option value="PO Box">PO Box</option>
        <option value="P Bag">P Bag</option>
        <option value="<?php echo $a7 ?>" selected="selected"><?php echo $a7 ?></option>
      </select></td>
      <td width="63"><input name="box_no_text" type="text" class="text100" id="box_no_text" value="<?php echo $a8 ?>"/></td>
      <td width="113">Postal place:</td>
      <td width="138"><select name="post_place_select" class="select120"  >
        <option value="<?php echo $a9 ?>" selected="selected"><?php echo $a9 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
      </select></td>
      <td width="89">Country:</td>
      <td width="134"><select name="country_select" class="select120"  >
        <option value="<?php echo $a26 ?>" selected="selected"><?php echo $a26 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId4); $j++) {
    		echo "<option value=" . "\"" . $arrId4[$j] . "\"" . ">" . $arrName4[$j] . "</option>";
	}
?>
      </select></td>
    </tr>
    <tr>
      <td height="25">Physical address:</td>
      <td colspan="2"><b>
        <input name="phys_address_text" type="text" class="text100" id="phys_address_text" value="<?php echo $a10 ?>" onfocus = "this.select();" onBlur="capitalize(this)"/></td>
      <td>Place:</td>
      <td><select name="phys_place_select" class="select120"  >
        <option value="<?php echo $a11 ?>" selected="selected"><?php echo $a11 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
      </select></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="25">Phone:</td>
      <td colspan="2"><input name="phone_text" type="text" class="text100" id="phone_text" value="<?php echo $a24 ?>" onkeypress="return numbersonly(this, event)" onfocus = "this.select();"/></td>
      <td>Cell:</td>
      <td><input name="cell_text" type="text" class="text100" id="cell_text" value="<?php echo $a23 ?>" onfocus = "this.select();" onkeypress="return numbersonly(this, event)"/></td>
      <td>e-mail:</td>
      <td><input name="email_text" type="text" class="text100" id="email_text" value="<?php echo $a25 ?>" onkeyup="ToLower(this)" onfocus = "this.select();"/></td>
    </tr>
    <tr>
      <td height="25">Emergency contact:</td>
      <td colspan="2"><input name="emergency_contact_text" type="text" class="text100" id="emergency_contact_text" value="<?php echo $a12 ?>" onfocus = "this.select();"onBlur="capitalize(this)"/></td>
      <td>Emergency cell:</td>
      <td><input name="emergency_cell_text" type="text" class="text100" id="emergency_cell_text" value="<?php echo $a13 ?>" onkeypress="return numbersonly(this, event)"onfocus = "this.select();"/></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>

</td>
</tr>
<tr>
<td>
<div class="page_inside_frame">
<div align="left">Employment details</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="94" height="25">Employment date:</td>
      <td colspan="3"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("employ_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d2, $m2, $y2);
		$myCalendar->setYearInterval(1990, 2020);
		//output the calendar
		$myCalendar->writeScript();
?>
        <input type="hidden" name="emp_id_text" id="emp_id_text" value="<?php echo $emp_id ?>" /></td>
      <td>Leave days:</td>
      <td><select name="leave_days_select" class="select80" id="leave_days_select">
        <option value="1">1</option>
        <option value="1.5">1.5</option>
        <option value="2">2</option>
        <option value="2.5">2.5</option>
        <option value="<?php echo $a38 ?>" selected="selected"><?php echo $a38 ?></option>
      </select></td>
      </tr>
    <tr>
      <td height="25">Position:</td>
      <td width="127"><select name="position_select" class="select120"  >
        <option value="<?php echo $a29 ?>" selected="selected"><?php echo $a29 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
        </select></td>
      <td width="94">Department:</td>
      <td width="127"><select name="department_select" class="select120"  >
        <option value="<?php echo $a28 ?>" selected="selected"><?php echo $a28 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
        </select></td>
      <td width="66">Time keeping:</td>
      <td width="104"><select name="time_keeping_select" class="select80" id="time_keeping_select">
        <option value="yes">yes</option>
        <option value="no">no</option>
        <option value="<?php echo $a39 ?>" selected="selected"><?php echo $a39 ?></option>
        </select></td>
    </tr>
    <tr>
      <td height="25">Pay period:</td>
      <td><select name="pay_period_select" class="select80" id="pay_period_select">
        <option value="month">month</option>
        <option value="hour">hour</option>
        <option value="<?php echo $a15 ?>" selected="selected"><?php echo $a15 ?></option>
        </select></td>
      <td>Rate:</td>
      <td><input name="rate_text" type="text" class="text100" id="rate_text" value="<?php echo $a16 ?>" onKeyPress="return isNumberKey(event)" onchange=" this.value = this.value.replace (/(\...).*/, '$1')"/></td>
      <td>Pay unit:</td>
      <td><select name="pay_unit_select" class="select80" id="pay_unit_select">
        <option value="month">month</option>
        <option value="hour">hour</option>
        <option value="<?php echo $a37 ?>" selected="selected"><?php echo $a37 ?></option>
        </select></td>
    </tr>
    <tr>
      <td height="25">End contract:</td>
      <td colspan="3"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("end_employ_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d3, $m3, $y3);
		$myCalendar->setYearInterval(2012, 2030);
		//output the calendar
		$myCalendar->writeScript();
?></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>

<div class="page_inside_frame">
<div align="left">Miscelaneous</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="97" height="25">Bank:</td>
      <td width="177"><select name="bank_select" class="select120"  >
        <option value="<?php echo $a18 ?>" selected="selected"><?php echo $a18 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId5); $j++) {
    		echo "<option value=" . "\"" . $arrId5[$j] . "\"" . ">" . $arrName5[$j] . "</option>";
	}
?>
      </select></td>
      <td width="74">Branch:</td>
      <td width="157"><select name="branch_select" class="select120"  >
        <option value="<?php echo $a19 ?>" selected="selected"><?php echo $a19 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId6); $j++) {
    		echo "<option value=" . "\"" . $arrId6[$j] . "\"" . ">" . $arrName6[$j] . "</option>";
	}
?>
      </select></td>
      <td width="111">&nbsp;</td>
      </tr>
    <tr>
      <td height="25">Acc.number:</td>
      <td><input name="acc_number_text" type="text" class="text100" id="acc_number_text" value="<?php echo $a20 ?>" onkeyup="ToUpper(this)" onfocus = "this.select();"/></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <td height="25">Clothing size:</td>
      <td><select name="clothing_size_select" class="select80" id="clothing_size_select">
        <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="46">46</option>
        <option value="48">48</option>
        <option value="<?php echo $a21 ?>" selected="selected"><?php echo $a21 ?></option>
      </select></td>
      <td>Shoe size:</td>
      <td><select name="shoe_size_select" class="select80" id="shoe_size_select">
        <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="<?php echo $a22 ?>" selected="selected"><?php echo $a22 ?></option>
      </select></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <td height="25">Notes</td>
      <td colspan="4"><textarea name="notes_text" id="notes_text" cols="70" rows="3"><?php echo $a36 ?></textarea></td>
      </tr>
  </table>
</div>
<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="emp_id_text" id="emp_id_text" value="<?php echo $emp_id ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../hr_module/hr_main.php?date=0');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>

</div>
</form>  
</div>
</body>
<?php 
}

else {
$_SESSION['denied_return'] = "hr_module/employee_list.php";	
include ("../navigation/hr_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }

?>
<?php include ('../navigation/side_bar.php'); ?>
</html>