<?php
include('../include/session.php');

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 


$emp_id = $_POST['emp_id_text'];

$table_name = $_SESSION['db_prefix']."_permissions";
$view_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'HR-wages' ";
$view_result = mySQL_query($view_query);
$view_num = mysql_num_rows($view_result);
if ($view_num!=0) {
	$view='yes';
}
else {
$view='no';
}	

$table_name = $_SESSION['db_prefix']."_employee";
$saved_employee_query = "SELECT * FROM $table_name WHERE emp_id = '".$emp_id."' ";
$saved_employee_result = mySQL_query($saved_employee_query);
$saved_employee_num = mysql_num_rows($saved_employee_result);

$id_number_saved = mysql_result($saved_employee_result, 0, 'id_number');
$emp_first_name_saved = mysql_result($saved_employee_result, 0, 'emp_first_name');
$emp_last_name_saved = mysql_result($saved_employee_result, 0, 'emp_last_name');
$birth_date_saved = mysql_result($saved_employee_result, 0, 'birth_date');
$gender_saved = mysql_result($saved_employee_result, 0, 'gender');
$bag_box_saved = mysql_result($saved_employee_result, 0, 'bag_box');
$box_no_saved = mysql_result($saved_employee_result, 0, 'box_no');
$postal_place_saved = mysql_result($saved_employee_result, 0, 'postal_place');
$phys_address_saved = mysql_result($saved_employee_result, 0, 'phys_address');
$phys_place_saved = mysql_result($saved_employee_result, 0, 'phys_place');
$emergency_name_saved = mysql_result($saved_employee_result, 0, 'emergency_name');
$emergency_phone_saved = mysql_result($saved_employee_result, 0, 'emergency_phone');
$position_saved = mysql_result($saved_employee_result, 0, 'position');
$pay_period_saved = mysql_result($saved_employee_result, 0, 'pay_period');
$rate_saved = mysql_result($saved_employee_result, 0, 'rate');
$bank_saved = mysql_result($saved_employee_result, 0, 'bank');
$bank_branch_saved = mysql_result($saved_employee_result, 0, 'bank_branch');
$bank_account_saved = mysql_result($saved_employee_result, 0, 'bank_account');
$clothing_size_saved = mysql_result($saved_employee_result, 0, 'clothing_size');
$shoe_size_saved = mysql_result($saved_employee_result, 0, 'shoe_size');
$cell_saved = mysql_result($saved_employee_result, 0, 'cell');
$phone_saved = mysql_result($saved_employee_result, 0, 'phone');
$email_saved = mysql_result($saved_employee_result, 0, 'email');
$country_saved = mysql_result($saved_employee_result, 0, 'country');
$marital_status_saved = mysql_result($saved_employee_result, 0, 'marital_status');
$department_saved = mysql_result($saved_employee_result, 0, 'department');
$position = mysql_result($saved_employee_result, 0, 'position');
$employ_date_saved = mysql_result($saved_employee_result, 0, 'employ_date');
$end_employ_date_saved = mysql_result($saved_employee_result, 0, 'end_employ_date');
$premature_end_date_saved = mysql_result($saved_employee_result, 0, 'premature_end_date');
//$citizen = mysql_result($saved_employee_result, 0, '');
//$nationality = mysql_result($saved_employee_result, 0, '');
$notes_saved = mysql_result($saved_employee_result, 0, 'notes');
$pay_unit_saved = mysql_result($saved_employee_result, 0, 'pay_unit');
$leave_days_saved = mysql_result($saved_employee_result, 0, 'leave_days');
$time_keeping_saved = mysql_result($saved_employee_result, 0, 'time_keeping');
$time_zone_saved = mysql_result($saved_employee_result, 0, 'time_zone');

$nationality_saved = mysql_result($saved_employee_result, 0, 'nationality');
$expatriate_saved = mysql_result($saved_employee_result, 0, 'expatriate');
$permit_number_saved = mysql_result($saved_employee_result, 0, 'permit_number');
$permit_date_saved = mysql_result($saved_employee_result, 0, 'permit_date');


$id_number = $_POST['id_number_text'];
$emp_first_name = $_POST['first_name_text'];
$emp_last_name = $_POST['last_name_text'];
$birth_date = $_POST['birth_date'];
$gender = $_POST['gender_select'];
$bag_box = $_POST['bag_box_select'];
$box_no = $_POST['box_no_text'];
$postal_place = $_POST['post_place_select'];
$phys_address = $_POST['phys_address_text'];
$phys_place = $_POST['phys_place_select'];
$emergency_name = $_POST['emergency_contact_text'];
$emergency_phone = $_POST['emergency_cell_text'];
$position = $_POST['position_select'];
$pay_period = $_POST['pay_period_select'];
if ($view=='yes') {
$rate = $_POST['rate_text'];
}
else {
	$rate = $rate_saved;
}
$bank = $_POST['bank_select'];
$bank_branch = $_POST['branch_select'];
$bank_account = $_POST['acc_number_text'];
$clothing_size = $_POST['clothing_size_select'];
$shoe_size = $_POST['shoe_size_select'];
$cell = $_POST['cell_text'];
$phone = $_POST['phone_text'];
$email = $_POST['email_text'];
$country = $_POST['country_select'];
$marital_status = $_POST['marital_status_select'];
$department = $_POST['department_select'];
$position = $_POST['position_select'];
$employ_date = $_POST['employ_date'];
$end_employ_date = $_POST['end_employ_date'];
$premature_end_date = $_POST['premature_end_date'];
//$citizen = $_POST['_text'];
//$nationality = $_POST['_text'];
$notes = $_POST['notes_text'];
$pay_unit = $_POST['pay_unit_select'];
$leave_days = $_POST['leave_days_select'];
$time_keeping = $_POST['time_keeping_select'];
$time_zone = $_POST['time_zone'];

$nationality = $_POST['nationality_select'];
$expatriate = $_POST['expatriate_select'];
$permit_number = $_POST['permit_number_text'];
$permit_date = $_POST['permit_date'];

$table_name = $_SESSION['db_prefix']."_employee";
$employee_query = "UPDATE $table_name SET emp_first_name = '".$emp_first_name."', emp_last_name = '".$emp_last_name."', gender = '".$gender."', id_number = '".$id_number."', birth_date = '".$birth_date."', marital_status = '".$marital_status."', bag_box = '".$bag_box."', box_no = '".$box_no."', postal_place = '".$postal_place."', phys_address = '".$phys_address."', phys_place = '".$phys_place."', country = '".$country."', phone = '".$phone."', cell = '".$cell."', email = '".$email."', emergency_name = '".$emergency_name."', emergency_phone = '".$emergency_phone."', employ_date = '".$employ_date."', end_employ_date = '".$end_employ_date."', premature_end_date = '".$premature_end_date."', position = '".$position."', department = '".$department."', pay_period = '".$pay_period."', rate = '".$rate."', leave_days = '".$leave_days."', time_keeping = '".$time_keeping."', time_zone = '".$time_zone."', pay_unit = '".$pay_unit."', clothing_size = '".$clothing_size."', shoe_size = '".$shoe_size."', bank = '".$bank."', bank_branch = '".$bank_branch."', bank_account = '".$bank_account."', notes = '".$notes."', nationality = '".$nationality."', expatriate = '".$expatriate."', permit_number = '".$permit_number."', permit_date = '".$permit_date."' WHERE emp_id = '".$emp_id."' ";
execsql($employee_query);



$table_name = $_SESSION['db_prefix']."_tracking_hr";

if ($id_number_saved!=$id_number) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$id_number_saved."','".$id_number."','Id number' )";
		//echo '<br>id_number'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($emp_first_name_saved!=$emp_first_name) {
		$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$emp_first_name_saved."','".$emp_first_name."','First name' )";
		//echo '<br>emp_first_name'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($emp_last_name_saved!=$emp_last_name) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$emp_last_name_saved."','".$emp_last_name."','Last name' )";
		//echo '<br>emp_last_name'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($birth_date_saved!=$birth_date) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$birth_date_saved."','".$birth_date."','Dob' )";
		//echo '<br>birth_date'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($gender_saved!=$gender) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$gender_saved."','".$gender."','Gender' )";
		//echo '<br>gender'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($bag_box_saved!=$bag_box) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$bag_box_saved."','".$bag_box."','Postal address' )";
		//echo '<br>bag_box'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($box_no_saved!=$box_no) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$box_no_saved."','".$box_no."','Postal address' )";
		//echo '<br>box_no'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($postal_place_saved!=$postal_place) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$postal_place_saved."','".$postal_place."','Postal place' )";
		//echo '<br>postal_place'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($phys_address_saved!=$phys_address) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$phys_address_saved."','".$phys_address."','Residential address' )";
		//echo '<br>phys_address'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($phys_place_saved!=$phys_place) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$phys_place_saved."','".$phys_place."','Residential place' )";
		//echo '<br>phys_place'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($emergency_name_saved!=$emergency_name) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$emergency_name_saved."','".$emergency_name."','Emergency contact' )";
		//echo '<br>emergency_name'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($emergency_phone_saved!=$emergency_phone) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$emergency_phone_saved."','".$emergency_phone."','Emergency phone' )";
		//echo '<br>emergency_phone'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($position_saved!=$position) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$position_saved."','".$position."','Position' )";
		//echo '<br>position'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($pay_period_saved!=$pay_period) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$pay_period_saved."','".$pay_period."','Pay period' )";
		//echo '<br>pay_period'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($rate_saved!=$rate) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$rate_saved."','".$rate."','Rate/salary' )";
		//echo '<br>rate'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($bank_saved!=$bank) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$bank_saved."','".$bank."','Bank' )";
		//echo '<br>bank'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($bank_branch_saved!=$bank_branch) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$bank_branch_saved."','".$bank_branch."','Bank branch' )";
		//echo '<br>bank_branch'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($bank_account_saved!=$bank_account) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$bank_account_saved."','".$bank_account."','Bank account' )";
		//echo '<br>bank_account'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($clothing_size_saved!=$clothing_size) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$clothing_size_saved."','".$clothing_size."','Clothing size' )";
		//echo '<br>clothing_size'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($shoe_size_saved!=$shoe_size) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$shoe_size_saved."','".$shoe_size."','Shoe size' )";
		//echo '<br>shoe_size'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($cell_saved!=$cell) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$cell_saved."','".$cell."','Cell' )";
		//echo '<br>cell'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($phone_saved!=$phone) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$phone_saved."','".$phone."','Phone' )";
		//echo '<br>phone'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($email_saved!=$email) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$email_saved."','".$email."','Email' )";
	//	echo '<br>email'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($country_saved!=$country) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$country_saved."','".$country."','Country' )";
		//echo '<br>country'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($marital_status_saved!=$marital_status) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$marital_status_saved."','".$marital_status."','Marital status' )";
		//echo '<br>marital_status'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($department_saved!=$department) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$department_saved."','".$department."','Department' )";
		//echo '<br>department'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($position_saved!=$position) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$position_saved."','".$position."','Position' )";
		//echo '<br>position'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($employ_date_saved!=$employ_date) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$employ_date_saved."','".$employ_date."','Employment date' )";
		//echo '<br>employ_date'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($end_employ_date_saved!=$end_employ_date) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$end_employ_date_saved."','".$end_employ_date."','End employment date' )";
		//echo '<br>end_employ_date'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($premature_end_date_saved!=$premature_end_date) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$end_employ_date_saved."','".$end_employ_date."','Premature end employment date' )";
		//echo '<br>end_employ_date'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($notes_saved!=$notes) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$notes_saved."','".$notes."','Notes' )";
		//echo '<br>notes'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($pay_unit_saved!=$pay_unit) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$pay_unit_saved."','".$pay_unit."','Pay unit' )";
		//echo '<br>pay_unit'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($leave_days_saved!=$leave_days) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$leave_days_saved."','".$leave_days."','Leave days' )";
		//echo '<br>leave_days'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}


if ($time_keeping_saved!=$time_keeping) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$time_keeping_saved."','".$time_keeping."','Time keeping' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($time_zone_saved!=$time_zone) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$time_zone_saved."','".$time_zone."','Time zone' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}


if ($nationality_saved!=$nationality) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$nationality_saved."','".$nationality."','Nationality' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($expatriate_saved!=$expatriate) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$expatriate_saved."','".$expatriate."','Expatriate' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($permit_number_saved!=$permit_number) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$permit_number_saved."','".$permit_number."','Permit number' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}

if ($permit_date_saved!=$permit_date) {
	    $trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '21', '".$emp_id."' ,'".$permit_date_saved."','".$permit_date."','Permit exp date' )";
		//echo '<br>time_keeping'.$trackingQuery;
			$trackingResult = mySQL_query($trackingQuery);
}


if (isset($_POST['save_close_button']) )
	   { ?>
       <script>
	 		 window.location="../hr_module/hr_main.php?date=0";
		</script>
        <?php		 
	   }
	   
	if (isset($_POST['save_button']) )
	   {  ?>
       <script>
	          window.location="employee_details_edit.php?emp_id=<?php echo $emp_id?>"
	   </script>
        <?php		 
	   }
	   ?>

