<?php

// Check nonce

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


if
(
    PHPRC_HTTP_PARAM::REF_ISSET_IN_ARRAY
    (
        [
            'PARAM_SYS_GENDER_ID',
            'PARAM_SYS_GENDER_CODE',
            'PARAM_SYS_GENDER_DESCRIPTION',
            'PARAM_SYS_GENDER_STATUS',
            
            'PARAM_ORDER_FIELD',
            'PARAM_ORDER_TYPE',
            'PARAM_SKIP',
            'PARAM_LIMIT'
        ], True
        )
    )
{
    Try
    {
        // Read params
        // ------------------------------------------------------------------
        $PARAM_SYS_GENDER_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_SYS_GENDER_ID');
        $PARAM_SYS_GENDER_CODE = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_SYS_GENDER_CODE');
        $PARAM_SYS_GENDER_DESCRIPTION = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_SYS_GENDER_DESCRIPTION');
        $PARAM_SYS_GENDER_STATUS = PHPCUS_PARAM::CUS_READ_INT('PARAM_SYS_GENDER_STATUS');
        
        $PARAM_ORDER_FIELD = PHPCUS_PARAM::CUS_READ_SORT_FIELD
        (
            'PARAM_ORDER_FIELD',
            [
                'SYS_GENDER_ID',
                'SYS_GENDER_CODE',
                'SYS_GENDER_DESCRIPTION',
                'SYS_GENDER_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');
        
        // ------------------------------------------------------------------
        
        
        // Populate Map Array
        // ...........................................
        $GET_MAP_ARRAY = PHPCUS_SYSTEM_GENDER::CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
        
        $GET_MAP_ARRAY['PARAM_SYS_GENDER_ID'] = $PARAM_SYS_GENDER_ID;
        $GET_MAP_ARRAY['PARAM_SYS_GENDER_CODE'] = $PARAM_SYS_GENDER_CODE;
        $GET_MAP_ARRAY['PARAM_SYS_GENDER_DESCRIPTION'] = $PARAM_SYS_GENDER_DESCRIPTION;
        $GET_MAP_ARRAY['PARAM_SYS_GENDER_STATUS'] = $PARAM_SYS_GENDER_STATUS;
        
        $GET_MAP_ARRAY["PARAM_ORDER_FIELD"] = $PARAM_ORDER_FIELD;
        $GET_MAP_ARRAY["PARAM_ORDER_TYPE"] = $PARAM_ORDER_TYPE;
        $GET_MAP_ARRAY["PARAM_SKIP"] = $PARAM_SKIP;
        $GET_MAP_ARRAY["PARAM_LIMIT"] = $PARAM_LIMIT;
        
        
        // Execute Stored Procedure
        // ...........................................
        $DATA_SET = PHPCUS_SYSTEM_GENDER::CUS_GET_MA($GET_MAP_ARRAY);
        
        
        // 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');
}

?>