<?php
require_once('config.php');

$error_message;
$valid = true;

$site_cd = $_REQUEST['site_cd'];
$mst_RowID = $_REQUEST['mst_RowID'];


$sql= "	select wko_det.wko_det_rating1 ,
		wko_det.wko_det_rating2,
		wko_det.wko_det_rating3,
		wko_det_ack_name,
		wko_det_ack_contact,
		wko_det_ack_id		
		
		from wko_det 
		WHERE  		wko_det.site_cd = '".$site_cd."' 
		AND 		wko_det.mst_RowID = '".$mst_RowID."'";
		
$stmt = sqlsrv_query( $conn, $sql);

if( !$stmt ) {
     $error_message = "Error selecting table (Asset Group Code)";
	 returnError($error_message);
     die( print_r( sqlsrv_errors(), true));
	 
}

$json = array();

do {
     while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {		
		$json[] = $row;	
	
     }
} while ( sqlsrv_next_result($stmt) );


if ($valid) {

	//echo $sql;
	returnData($json);	
	
}

function returnData($json){
	//echo $json;
	$returnData = array(												
	'status' => 'SUCCESS',
	'message' => 'Completed Successfully',	
	'data'=>$json);
	
	echo json_encode($returnData);
}

function returnError($error_message){
	$json = array();
	
	$returnData = array(
	'status' => 'ERROR',
	'message' => $error_message,
	'data' => $json);
	
	echo json_encode($returnData);
		
}
	sqlsrv_free_stmt( $stmt);
	sqlsrv_close( $conn);

?>