<?php
require_once('config.php');
$error_message;
$valid = true;


$site_cd = $_REQUEST['site_cd'];
$emp_mst_att_sts = $_REQUEST['emp_mst_att_sts'];
$emp_mst_empl_id = $_REQUEST['emp_mst_empl_id'];



$sql = "UPDATE emp_mst 

		SET emp_mst_att_sts =?
		
		WHERE site_cd =?
		AND emp_mst_empl_id =?";

$params_emp_mst = array($emp_mst_att_sts,$site_cd,$emp_mst_empl_id);
$stmt_emp_mst = sqlsrv_query($conn, $sql, $params_emp_mst);

if ($stmt_emp_mst === false)
{

	$error_message = "(".$now.") Error updating table (emp_mst)";
	returnError($error_message);
	
    sqlsrv_rollback($conn);
    sqlsrv_close($conn);
}else{
	
	returnData();
	
}
sqlsrv_free_stmt($stmt_emp_mst);
	


function returnData(){
	
	$returnData = array(
	'status' => 'SUCCESS',
	'message' => 'Update Successfully');
	
	echo json_encode($returnData);
}

function returnError($error_message){
	$json = array();
	
	$returnData = array(
	'status' => 'Alert',
	'message' => $error_message,
	'data' => $json);	
	
	echo json_encode($returnData);
		
	exit();
}	


?>