<?php

// get these values from your DB.
require_once('config.php');
require_once('f_get_emp_ls5.php');
$error_message;
$valid = true;

//Asset Code:



$sql="select * from cf_label where  
		column_name IN ('ast_ls1_stock_no',
						'ast_ls1_varchar1',
						'ast_ls1_desc',
						'ast_ls1_ttl_oh',
						'ast_ls1_qty_needed') 
		and language_cd = 'DEFAULT' order by customize_label";


$stmt_asset_list = sqlsrv_query( $conn, $sql);

if( !$stmt_asset_list ) {
	 $error_message = "Error selecting table (cf_label)";
	 returnError($error_message);
	 die( print_r( sqlsrv_errors(), true));
	 
}

$json = array();

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



if( $stmt_asset_list) {
		 sqlsrv_commit( $conn );
		 sqlsrv_close( $conn);	
		 returnData($json);	
	} else {
		 sqlsrv_rollback( $conn );
		 $error_message = "Transaction rolled back.<br />";
		 returnError($error_message);
	} 



function returnData($json){	
	
	$returnData = array('status' => 'SUCCESS','message' => '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);
	exit();
		
}
	

 
?>