<?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 (NOLOCK) where  
		column_name IN ('ast_mst_asset_no',
						'ast_mst_asset_group',
						'ast_mst_asset_shortdesc',
						'ast_mst_asset_longdesc',
						'ast_mst_asset_grpcode',
						'ast_mst_perm_id',
						'ast_det_cus_code',
						'ast_mst_asset_type',
						'ast_mst_asset_code',
						'mst_war_work_area',
						'ast_mst_asset_locn',
						'ast_mst_ast_lvl',
						'ast_mst_asset_status',
						'ast_mst_cri_factor',
						'ast_mst_cost_center',
						'ast_mst_create_by',
						'ast_det_warranty_date',
						'ast_det_from_date',
						'ast_det_to_date',
						'ast_det_serial') 
		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();
		
}
	

 
?>