<?php

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

$sql="select * from cf_label where  
		column_name IN ('wko_mst_originator',			'wko_mst_phone',			'wko_mst_assetno',			'wko_mst_descs',
						'wko_mst_asset_group_code',		'wko_mst_asset_location',	'wko_mst_asset_level',		'wko_mst_chg_costcenter',
						'wko_mst_wo_no',				'wko_mst_orig_priority',	'wko_mst_plan_priority',	'wko_mst_org_date',
						'wko_mst_due_date',				'wko_mst_flt_code',			'wko_mst_status',			'wko_det_assign_to',
						'wko_det_lab_cost',				'wko_det_con_cost',			'wko_det_mtl_cost',			'wko_det_work_type',
						'wko_det_caccount',				'wko_det_maccount',			'wko_det_ack_name',			'wko_det_ack_id',
						'wko_det_ack_contact',			'wko_det_ack_date',			'wko_det_safety',			'wko_det_work_grp',
						'wko_det_numeric2',				'wko_det_numeric3',			'wko_det_work_grp',			'wko_det_cause_code',
						'wko_det_act_code',				'wko_det_corr_action' ,		'wko_det_note1',			'wko_ls4_pr_no',	
						'wko_ls4_supplier',				'wko_ls4_chg_costcenter',	'wko_ls4_descr',			'wko_ls4_svc_uom',	
						'wko_ls4_est_cost',				'wko_ls4_qty_needed',		'pur_ls1_desc',				'pur_ls1_supplier',	
						'pur_ls1_tax_code',				'pur_ls1_chg_costcenter',	'pur_ls1_chg_account',		'pur_ls1_ord_uom',	
						'pur_ls1_ord_qty',				'wko_ls3_pr_lineno',		'wko_ls3_rec_supplier',		'wko_ls3_chg_costcenter',	
						'wko_ls3_descr',				'wko_ls3_mtl_uom',			'wko_ls3_item_cost',		'wko_ls3_qty_needed',
						'wko_ls2_mr_lineno',			'mtr_mst_assetno',			'mtr_mst_requester',		'wko_ls2_mr_no',
						'wko_ls2_stockno',				'wko_ls2_chg_costcenter',	'wko_ls2_stk_locn',			'wko_ls2_desc',
						'wko_ls2_mtl_uom',				'wko_ls2_item_cost',		'mtr_ls1_stockno',			'mtr_ls1_stk_locn',
						'mtr_ls1_desc',					'mtr_ls1_chg_costcenter',	'mtr_ls1_chg_account',		'mtr_ls1_mtl_uom',
						'mtr_ls1_item_cost',			'wko_ls8_empl_id',			'wko_ls8_craft',			'wko_ls8_hours_type',	
						'wko_ls8_hrs',					'wko_ls8_multiplier',		'wko_ls8_rate',				'wko_ls8_act_cost',
						'wko_det_supv_id') 
		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();
		
}
	

 
?>