<?php

// Check Array Input
PHPCUS_PARAM::CUS_DOES_NOT_SUPPORT_ARRAY();

if
(
		PHPRC_HTTP_PARAM::REF_ISSET_IN_ARRAY
		(
				[
						'PARAM_SYS_STATUS_ID',
						'PARAM_SYS_STATUS_DESCRIPTION',
						'PARAM_SYS_STATUS_DESCRIPTION_2',
						'PARAM_SYS_STATUS_DESCRIPTION_3',
						'PARAM_SYS_STATUS_STATUS',
						
						'PARAM_ORDER_FIELD',
						'PARAM_ORDER_TYPE',
						'PARAM_SKIP',
						'PARAM_LIMIT'
				], True
				)
		)
{
	Try
	{
		// Read params
		// ------------------------------------------------------------------
		
		$PARAM_SYS_STATUS_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_SYS_STATUS_ID');
		$PARAM_SYS_STATUS_DESCRIPTION = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_SYS_STATUS_DESCRIPTION');
		$PARAM_SYS_STATUS_DESCRIPTION_2 = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_SYS_STATUS_DESCRIPTION_2');
		$PARAM_SYS_STATUS_DESCRIPTION_3 = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_SYS_STATUS_DESCRIPTION_3');
		$PARAM_SYS_STATUS_STATUS = PHPCUS_PARAM::CUS_READ_INT('PARAM_SYS_STATUS_STATUS');
		
		$PARAM_ORDER_FIELD = PHPCUS_PARAM::CUS_READ_SORT_FIELD
		(
				'PARAM_ORDER_FIELD',
				[
						'SYS_STATUS_ID',
						'SYS_STATUS_DESCRIPTION',
						'SYS_STATUS_DESCRIPTION_2',
						'SYS_STATUS_DESCRIPTION_3',
						'SYS_STATUS_STATUS'
				]
		);
		
		$PARAM_ORDER_TYPE = PHPCUS_PARAM::CUS_READ_SORT_TYPE('PARAM_ORDER_TYPE');
		$PARAM_SKIP	= PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_SKIP');
		$PARAM_LIMIT = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_LIMIT');
		
		// ------------------------------------------------------------------
		
		
		// Execute Stored Procedure
		$DATA_SET = PHPCUS_SYSTEM_STATUS::CUS_GET
		(
				$PARAM_SYS_STATUS_ID,
				$PARAM_SYS_STATUS_DESCRIPTION,
				$PARAM_SYS_STATUS_DESCRIPTION_2,
				$PARAM_SYS_STATUS_DESCRIPTION_3,
				$PARAM_SYS_STATUS_STATUS,
				
				$PARAM_ORDER_FIELD,
				$PARAM_ORDER_TYPE,
				$PARAM_SKIP,
				$PARAM_LIMIT
		);
		
		// Return JSON response
		if(empty($DATA_SET) === False)
		{
			PHPCUS_PARAM::CUS_JSON_SUCCESS($DATA_SET);
		}
		else
		{
			PHPCUS_PARAM::CUS_JSON_SUCCESS('');
		}
		
	}
	Catch(Exception $ERR)
	{
		PHPVC_LOG::VAR_REPORT_ERROR($ERR, 0);
		PHPCUS_PARAM::CUS_JSON_ERROR($ERR->getMessage());
	}
}
else
{
	PHPCUS_PARAM::CUS_JSON_ERROR('Missing parameters');
}

?>