<?php

$active_sub_menu = 'hr-employment' ;
switch($employment_status){
	case 'Pending' :
		$active_menu = 'hr-letter-pending' ;
	break ;
	case 'Processing' :
		$active_menu = 'hr-letter-processing' ;
	break ;
	case 'Processing Confirmed' :
		$active_menu = 'hr-letter-processing-manager-approved' ;
	break ;
	case 'Processing Rejected' :
		$active_menu = 'hr-letter-processing-manager-rejected' ;
	break ;
	case 'Processing Interview Slot' :
		$active_menu = 'hr-letter-processing-interview-slot' ;
	break ;
	case 'Interview' :
		$active_menu = 'hr-letter-interview' ;
	break ;
	case 'Reschedule' :
		$active_menu = 'hr-letter-reschedule' ;
	break ;
	case 'Keep In View' :
		$active_menu = 'hr-letter-kiv' ;
	break ;
	case 'Offer' :
		$active_menu = 'hr-letter-offer' ;
	break ;	
	case 'Confirmation' :
		$active_menu = 'hr-letter-confirmation' ;
	break ;	
	case 'Reject' :
		$active_menu = 'hr-letter-reject' ;
	break ;	
	case 'Terminate' :
		$active_menu = 'hr-letter-terminate' ;
	break ;
}

// update database
if (isset($type) && $type == 'edit_status' && $_POST['hide'] == 1 && $_POST['hide_select_worker'] == 'Local'){

	//employment_status_change
	$employment_status_change = escapeString($_POST['employment_status_change']) ;

	if ( $employment_status_change == 'Processing' ){

		$employment_incharge_staff_id = escapeString($_POST['employment_incharge_staff_id']) ;
		if ( $employment_incharge_staff_id != '' ){
			if($mysqli->query("UPDATE staff_employment SET employment_status = '".$employment_status_change."', employment_incharge_staff_id = '".$employment_incharge_staff_id."' WHERE employment_id = '".$page."'")){
				$descrition = $_SESSION['system_name'].'(username) update status to Processing and waiting manager to confirm or reject.' ;
				$mysqli->query("INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
								('employment', 'update-status', '200', 'AF-".$page."', '".$_SESSION["system_id"]."', '".$descrition."', '".$record."', NOW())");

				if ( $row_page['employment_incharge_staff_id'] != $employment_incharge_staff_id ){
					pushToUserCron( 'staff_employment', $page, $employment_incharge_staff_id, 'Recruitment', 'New hires ( '.$row_page['employment_name'].' ) need your confirmation or rejection' ) ;
				}
			}
		}

	}elseif( $employment_status_change == 'Interview' && ($_POST['employment_interview_date'] != '' || $_POST['email_to_cand_adm'] != '' )){

		$employment_interview_date = escapeString($_POST['employment_interview_date']) ;
		$employment_email_to_cand_adm = escapeString($_POST['email_to_cand_adm']) ;

		if( $employment_interview_date !='' && $employment_email_to_cand_adm != '' ){
			$query_email = "employment_interview_email = '".$employment_email_to_cand_adm."', ";
		}

		if($mysqli->query("UPDATE staff_employment SET ".$query_email." employment_status = '".$employment_status_change."', employment_interview_date = '".$employment_interview_date."' WHERE employment_id = '".$page."'")){
			$descrition = $_SESSION['system_name'].'(username) update status to Interview and update the interview details. ' ;
			if ($query_email != '') {
				$descrition .= 'Interview emails is sent ('.TODAYDATE.')';
			}
			$mysqli->query("INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
							('employment', 'update-status', '200', 'AF-".$page."', '".$_SESSION["system_id"]."', '".$descrition."', '".$record."', NOW())");
		}

	}elseif( $employment_status_change == 'Reschedule' && ($_POST['employment_r_interview_date'] != '' || $_POST['r_email_to_cand_adm'] != '' )){

		$employment_r_interview_date = escapeString($_POST['employment_r_interview_date']) ;
		$employment_r_email_to_cand_adm = escapeString($_POST['r_email_to_cand_adm']) ;
		$employment_r_update_interview = escapeString($_POST['r_update_interview']);

		if( $employment_r_interview_date !='' && $employment_r_email_to_cand_adm !=''){
			$query_r_email = "employment_r_interview_email = '".$employment_r_email_to_cand_adm."', ";
		}

		if($employment_r_update_interview == '' ){
			if($mysqli->query("UPDATE staff_employment SET ".$query_r_email." employment_status = '".$employment_status_change."', employment_r_interview_date = '".$employment_r_interview_date."' WHERE employment_id = '".$page."'")){
				$descrition = $_SESSION['system_name'].'(username) update status to Reschedule and update the reschedule details. ' ;
				if ($query_r_email != '') {
					$descrition .= 'Reschedule emails is sent ('.TODAYDATE.')';
				}
				$mysqli->query("INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
								('employment', 'update-status', '200', 'AF-".$page."', '".$_SESSION["system_id"]."', '".$descrition."', '".$record."', NOW())");
			}
		}elseif($employment_r_update_interview !=''){

			if($mysqli->query("UPDATE staff_employment SET ".$query_r_email." employment_status = 'Interview', employment_interview_date = '".$employment_r_interview_date."', employment_r_interview_date = '0000-00-00 00:00:00', employment_r_candidate = '' WHERE employment_id = '".$page."'")){
				$descrition = $_SESSION['system_name'].'(username) update status to Interview and update the interview details. ' ;
				if ($query_r_email != '') {
					$descrition .= 'Reschedule emails is sent ('.TODAYDATE.')';
				}
				$mysqli->query("INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
								('employment', 'update-status', '200', 'AF-".$page."', '".$_SESSION["system_id"]."', '".$descrition."', '".$record."', NOW())");
			}
		}

	}else{

		$temp_employment_tier       = [] ;
		foreach ( $_POST['employment_tier'] as $kemploymenttier => $vemploymenttier ){
			$temp_employment_tier[] = escapeString($vemploymenttier) ;
		}
		$employment_tier 		    = implode(',', $temp_employment_tier) ;

		if($mysqli->query( "UPDATE staff_employment SET 
						    employment_status   = '".$employment_status_change."',
						    employment_tier     = '".$employment_tier."'
						    WHERE employment_id = '".$page."'" )){
			$descrition = $_SESSION['system_name'].'(username) update the employment status to '.$employment_status_change ;
			$mysqli->query("INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
							('employment', 'update-status', '200', 'AF-".$page."', '".$_SESSION["system_id"]."', '".$descrition."', '".$record."', NOW())");
		}
	}

	if($_POST['employment_interview_date'] != '' && $_POST['email_to_cand_adm'] != ''){

		$extra_itv_link = '';
		if ($_POST['email_itv_hod'] == 1 && $_POST['email_itv_to_hod'] != '') {
			$email_itv_to_hod = base64_encode($_POST['email_itv_to_hod']);
			$extra_itv_link .= '&hod='.$email_itv_to_hod;
		}

		if ($_POST['email_itv_attach'] == 1) {
			$email_itv_attach = base64_encode($row_page['employment_resume']);
			$extra_itv_link .= '&attach='.$email_itv_attach;
		}

		header("Location:?page_mode=sent_email&mail_type=interview".$extra_itv_link."&page=".$page);
		exit;
	}else if($_POST['employment_r_interview_date'] != '' && $_POST['r_email_to_cand_adm'] != ''){
		$extra_rsd_link = '';
		if ($_POST['email_rsd_hod'] == 1 && $_POST['email_rsd_to_hod'] != '') {
			$email_rsd_to_hod = base64_encode($_POST['email_rsd_to_hod']);
			$extra_rsd_link .= '&hod='.$email_rsd_to_hod;
		}

		if ($_POST['email_rsd_attach'] == 1) {
			$email_rsd_attach = base64_encode($row_page['employment_resume']);
			$extra_rsd_link .= '&attach='.$email_rsd_attach;
		}
		
		header("Location:?page_mode=sent_email&mail_type=reschedule".$extra_rsd_link."&page=".$page);
		exit;
	}else if( $_POST['employment_status_change'] == 'Reject' && $_POST['employment_status_change'] != $row_page['employment_status'] ){
		$extra_rsd_link = '';
		header("Location:?page_mode=sent_email&mail_type=reject".$extra_rsd_link."&page=".$page) ;
		exit;
	} 

	// refresh page
	header("Location:?page_mode=edit_status&page=".$page."&success=1&select_worker=Local") ;
	exit ;

}

// start header here
include 'requires/page_header.php' ;

if ( $hide_title == false ){
	include 'requires/page_top.php' ;
}

$user_profile = jsonEncodeDecode('decode', $row_page['employment_file']) ;

if ( $hide_title == true && $_GET['success'] == '1' ){
	echo '
	<script>
	$(document).ready(function(){
		alert("Thank you, you data has been submited.") ;
	}) ;
	</script>' ;
}
?>

<div class="warper container-fluid">  
<div class='container' style="background-color: white; border-radius: 10px;"> 
    <div class="row">
        <div class="col-md-12" style="position:inherit;">

    		<?php if ( $hide_title == false ){ ?>	<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;"><h1><?= $lang['Employment Status']?> <small><h1><?= $lang['edit']?></small></h1></div><?php } ?>

            <div class="panel panel-default">
                <div class="panel-heading"></div>
                <div class="panel-body">
                    <form method="post" class="form-horizontal" id="quotationForm" enctype="multipart/form-data" action="?page_mode=edit_status&page=<?= $page ?>&type=edit_status&select_worker=Local" novalidate="novalidate">
                        <table border="0" cellpadding="0" cellspacing="0" class="employment_table" style="max-width:960px; width:100%;padding:0; margin:0 auto;">
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Picture:</td>
                        		<td colspan="2" style="padding:5px; text-transform: uppercase;">
                        			<img src="<?= ($user_profile['file'] != '' ? $user_profile['path'].$user_profile['file'] : 'images/user_profile.png') ?>" style="width:150px;" /></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                        	<tr>
                        		<td colspan="1" style="width:120px;">Name:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= $row_page['employment_name'] ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Designation:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
                        			<?php 
                        				$mysqli_query = "SELECT a.job_position_id, b.job_position_desc FROM setting_job_position a
				                                         LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id )
				                                         WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.job_position_id = '".$row_page['employment_position']."' LIMIT 1" ; 
                                    	$mysqli_position = $mysqli->query($mysqli_query) ;
                                   	 	if ($mysqli_position->num_rows > 0){
                                   	 		while($row_position = $mysqli_position->fetch_array(MYSQLI_ASSOC)){
                                   	 			echo $row_position['job_position_desc'];
                                   	 		}
                                   	 	}
                                    ?>
                        			
                        		</td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Department:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
                        			<?php 
                        				$mysqli_query = "SELECT a.department_id, b.department_desc FROM setting_department a
                                                     LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
                                                     WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.department_id = '".$row_page['employment_department']."' LIMIT 1" ; 
                                    	$mysqli_department = $mysqli->query($mysqli_query) ;
                                   	 	if ($mysqli_department->num_rows > 0){
                                   	 		while($row_department = $mysqli_department->fetch_array(MYSQLI_ASSOC)){
                                   	 			echo $row_department['department_desc'];
                                   	 		}
                                   	 	}
                                    ?>
                        			
                        		</td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Branch:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
                        			<?php 
                        				$mysqli_query = "SELECT branch_name FROM branch WHERE deleted_at IS NULL AND branch_id = '".$row_page['employment_branch']."' LIMIT 1" ; 
                                    	$mysqli_branch = $mysqli->query($mysqli_query) ;
                                   	 	if ($mysqli_branch->num_rows > 0){
                                   	 		while($row_branch = $mysqli_branch->fetch_array(MYSQLI_ASSOC)){
                                   	 			echo $row_branch['branch_name'];
                                   	 		}
                                   	 	}
                                    ?>
                        		</td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Sex:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= $row_page['employment_sex'] ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Race:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= $row_page['employment_race'] ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Nationality:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= $row_page['employment_nationality'] ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Mobile Phone:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= $row_page['employment_mobile'] ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Status:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
                        			<select name="employment_status_change" class="employment_status_change" required="required" style="border:0px; padding:0px; margin: 0px;">
                        				<option value=""><?= $lang['select'] ?></option>
	                        			<?php foreach ( [ 'Pending', 'Processing', 'Processing Confirmed', 'Processing Rejected', 'Processing Interview Slot', 'Interview', 'Reschedule', 'Keep In View', 'Offer', 'Confirmation', 'Terminate', 'Reject' ] as $kstatus => $vstatus ){ ?>
	                        				<option value="<?= $vstatus ?>" <?= ( $row_page['employment_status'] == $vstatus ? 'selected' : '' ) ?> ><?= $vstatus ?></option>
	                        			<?php } ?>
	                        		</select>
                        		</td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                        	<?php if ( $row_page['employment_status'] == 'Offer' 		||
                        			   $row_page['employment_status'] == 'Confirmation' ||
                        			   $row_page['employment_status'] == 'Terminate'    ||
                        			   $row_page['employment_status'] == 'Reject' ){ ?>
                        		<tr>
	                        		<td colspan="1" style="width:120px;"><?= $lang['Tier'] ?>:</td>
	                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
	                        			<select name="employment_tier[]" id="user_tier" multiple class="chosen-select select2-basic-single form-control group_2" style="border:0px; padding:0px; margin: 0px;">
							        		<?php foreach( $tier_list as $k => $v ){ $tier_id = '|'.$v['tier_id'].'|' ; ?>
							        			<option value="<?= $tier_id ?>" <?= ( strpos($row_page['employment_tier'], $tier_id) !== false ? 'selected' : '' ) ?> ><?= $v['title'] ?></option>
							        		<?php } ?>
							            </select>
	                        		</td>
	                        		<td width="200px">&nbsp;</td>
	                        	</tr>
                        	<?php } ?>
                        	<tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                        		<td colspan="1" style="width:120px;">Manager:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;">
                        			<select name="employment_incharge_staff_id" class="employment_incharge_staff_id" required="required" style="border:0px; padding:0px; margin: 0px;">
                        				<option value=""><?= $lang['select'] ?></option>
	                        			<?php
	                        			$mysqli_inchargestaff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name FROM staff
				 				    									 		 WHERE deleted_at IS NULL AND ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND staff_settings LIKE '%\"checkrecruitment\":\"yes\"%'" . $user_branch_permission_sql ) ;
				 				    	if ( $mysqli_inchargestaff->num_rows > 0 ){
				 				    		while ( $row_inchargestaff = $mysqli_inchargestaff->fetch_array() ){
				 				    			echo '<option value="'.$row_inchargestaff['staff_id'].'" '.( $row_page['employment_incharge_staff_id'] == $row_inchargestaff['staff_id'] ? 'selected' : '' ).' >'.$row_inchargestaff['staff_name'].' ( '.$row_inchargestaff['staff_idno'].' )</option>' ;
				 				    		}
				 				    	}
	                        			?>
	                        		</select>
                        		</td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr><td colspan="4">&nbsp;</td></tr>


                        	<tr class="interview_content">
                        		<td colspan="1" style="width:120px;">Interview Date:</td>
                        		<td colspan="2"><input name="employment_interview_date" type="text" class="datetimepicker_with_time_employ" style="border:1px solid black" value="<?= (($row_page['employment_interview_date'] != '' && $row_page['employment_interview_date'] != '0000-00-00 00:00:00') ? date('Y-m-d H:i', strtotime($row_page['employment_interview_date'])) : '') ?>"/></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr class="interview_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="interview_content">
                        		<td colspan="3">
                        			<label style="width:100%;">
                        				<input type="checkbox" name="email_to_cand_adm" value="1" /> Send Emails to Candidate and Admin <?= ($row_page['employment_interview_email'] == '1' ? '<span style="color:red">(Interview emails had sent before)</span>' : '') ?>
                        			</label>
                        		</td>
                        	</tr>
                        	<tr class="interview_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="interview_content">
                        		<td colspan="3" style="width:120px;">
                        			<label>
                        				<input type="checkbox" name="email_itv_hod" value="1" /> Send Email To Others: <br>
                        				<input type="text" name="email_itv_to_hod" placeholder="Enter Emails Here: ( 1@email.com, 2@email.com )" />
                        			</label>
                        		</td>
                        	</tr>
                        	<tr class="interview_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="interview_content">
                        		<td colspan="3" style="width:120px;">
                        			<label><input type="checkbox" name="email_itv_attach" value="1" /> Attached Candidate's Resume</label>
                        		</td>
                        	</tr>
                        	<tr class="interview_content"><td colspan="4">&nbsp;</td></tr>


                        	<tr class="reschedule_content">
                        		<td colspan="1" style="width:120px;">Original Interview Date:</td>
                        		<td colspan="2" style="border:1px solid black; padding:5px; text-transform: uppercase;"><?= (($row_page['employment_interview_date'] != '' && $row_page['employment_interview_date'] != '0000-00-00 00:00:00') ? date('Y-m-d H:i', strtotime($row_page['employment_interview_date'])) : '') ?></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
							<tr class="reschedule_content">
                        		<td colspan="1" style="width:120px;">Rescheduled Interview Date:</td>
                        		<td colspan="2"><input name="employment_r_interview_date" type="text" class="datetimepicker_with_time_employ" style="border:1px solid black" value="<?= (($row_page['employment_r_interview_date'] != '' && $row_page['employment_r_interview_date'] != '0000-00-00 00:00:00') ? date('Y-m-d H:i', strtotime($row_page['employment_r_interview_date'])) : '') ?>" /></td>
                        		<td width="200px">&nbsp;</td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="reschedule_content">
                        		<td colspan="3" style="width:120px;"><input type="checkbox" name="r_email_to_cand_adm" value="1"/> Send Rescheduled Emails to Candidate and Admin <?= ($row_page['employment_r_interview_email'] == '1' ? '<span style="color:red">(Reschedule emails had sent before)</span>' : '') ?></td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="reschedule_content">
                        		<td colspan="3" style="width:120px;"><input type="checkbox" name="email_rsd_hod" value="1"/> Send Email To Others: <br><input type="text" name="email_rsd_to_hod" placeholder="Enter Emails Here: (1@email.com, 2@email.com)"/></td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="reschedule_content">
                        		<td colspan="3" style="width:120px;"><input type="checkbox" name="email_rsd_attach" value="1"/> Attached Candidate\'s Resume</td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
                        	<tr class="reschedule_content">
                        		<td colspan="3" style="width:120px;"><input type="checkbox" name="r_update_interview" value="1"/> Confirm and update status back to Interview</td>
                        	</tr>
                        	<tr class="reschedule_content"><td colspan="4">&nbsp;</td></tr>
                            

                            <tr><td colspan="4" style="border-bottom:1px solid #000;">&nbsp;</td></tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr>
                                <td colspan="4">
                                	<?php 
                                		if($row_page['employment_status'] != 'Terminate'){ 

                                			echo '
		                                    <button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;">'.$lang['submit'].'</button>
		                                    <input type="hidden" name="page_status" value="edit" />
		                                    <input type="hidden" name="hide" value="1">
		                                    <input type="hidden" name="hide_select_worker" value="Local">
		                                    ';
	                                	} 
                                	?>
                                </td>
                            </tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                            <tr><td colspan="4">&nbsp;</td></tr>
                        </table>
                    </form>

                    <table border="0" cellpadding="0" cellspacing="0" class="employment_table" style="max-width:960px; width:100%;padding:0; margin:0 auto;">
                    	<tr><td colspan="3"><strong>Log<strong><td></tr>
                    	<tr><td colspan="3">&nbsp;</td></tr>
                    	<tr>
                    		<td width="30px" style="border:1px solid black; padding:2px 5px;">No.</td>
                    		<td style="border:1px solid black; padding:2px 5px;">Action</td>
                    		<td width="150px" style="border:1px solid black; padding:2px 5px;">Date</td>
                    	</tr>
                    	<?php
                    		$mysqli_query = "SELECT * FROM system_log_employment WHERE log_page_name = 'AF-".$page."' ORDER BY log_date DESC LIMIT 100" ; 
                    		$mysqli_log   = $mysqli->query($mysqli_query) ;
                       	 	if ($mysqli_log->num_rows > 0){
                    			$count_row_log = $mysqli_log->num_rows ;
                       	 		while( $row_log = $mysqli_log->fetch_array(MYSQLI_ASSOC) ){
                       	 			
                       	 			echo '
                   	 				<tr>
			                    		<td style="border:1px solid black; padding:2px 5px;">'.$count_row_log.'</td>
			                    		<td style="border:1px solid black; padding:2px 5px;">'.$row_log['log_description'].'</td>
			                    		<td style="border:1px solid black; padding:2px 5px;">'.$row_log['log_date'].'</td>
			                    	</tr>' ;

                       	 			$count_row_log-- ;
                       	 		}
                       	 	}

	                    	
                    	?>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script>

$(document).ready(function(){

	var ori_status = $(".employment_status_change").val();
	if (ori_status == 'Processing Interview Slot' || ori_status == 'Interview') {
		$(".interview_content").show();
		$(".reschedule_content").hide();
	}else if(ori_status == 'Reschedule'){
		$(".interview_content").hide();
		$(".reschedule_content").show();
	}else{
		$(".interview_content").hide();
		$(".reschedule_content").hide();
	}

	$(".employment_status_change").change(function(){
		var status = $(this).val();
		if (status == 'Processing Interview Slot' || status == 'Interview') {
			$(".interview_content").show();
			$(".reschedule_content").hide();
		}else if(status == 'Reschedule'){
			$(".interview_content").hide();
			$(".reschedule_content").show();
		}else{
			$(".interview_content").hide();
			$(".reschedule_content").hide();
		}
	});
	// alert("asdas");
});

</script>