	/** 
	 * =======================================================================================================
	 * Perform SQL GET request to the table RECORD_STOCK_CARD. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY String() Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 *
	 * @param SQL_KEEP_PARAMETER_TO_CACHE bool (Optional) If TRUE save to cache, for easier paging request.
	 * =======================================================================================================
	 */
	JSCUS_SQL._RECORD._STOCK_CARD.CUS_SUM_BY_PROD = function
	(
		VAR_PARAMETER_ARRAY,
		CALLBACK_ADDRESS,
		
		SQL_KEEP_PARAMETER_TO_CACHE
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_PARAMETER_ARRAY, 'VAR_PARAMETER_ARRAY', 'ARRAY');
		
		// Handle Optionals
		// _______________________________________________________________________		
		SQL_KEEP_PARAMETER_TO_CACHE = JSVC_VAR.VAR_OPTIONAL(SQL_KEEP_PARAMETER_TO_CACHE, false);
		
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";			
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_CAT_PRODUCT_ID', VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_CAT_PRODUCT_ID"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_DATE_TRANSACTION_FROM', VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION_FROM"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_DATE_TRANSACTION_TO', VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION_TO"]);

		// Copy Parameter To Cache
		// _______________________________________________________________________
		if(SQL_KEEP_PARAMETER_TO_CACHE == true)
		{
			JSCUS_SQL._RECORD._STOCK_CARD.PROPERTY_CACHED_QUERY = VAR_PARAMETER_ARRAY;
		}
							
		// Send SQL Request
		// _______________________________________________________________________					
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			JSCUS_CACHE.SERVER_URL + '/Record/stock_card/sum_by_prod',
			'',
			PARAM_SET
		);	
	};

	
	/** 
	 * =======================================================================================================
	 * Populate SP-GET request request parameters with default value.
	 * =======================================================================================================
	 */
	JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_SUM_BY_PROD = function()
	{
		// Initialize
		var RESULT_MAPARRAY = [];

		// Populate default fields
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_CAT_PRODUCT_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION_FROM"] = FLAG_DATETIME_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION_TO"] = FLAG_DATETIME_NULL;					

		// Return prepared MapArray
		return RESULT_MAPARRAY;
	};
	
	
		
	/** 
	 * =======================================================================================================
	 * Perform SQL SAVE request to the table RECORD_STOCK_CARD. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 * @param FORWARDED_RESPONSE_STRING(String[]) Used internally. Ignore this parameter when calling this function.
	 * =======================================================================================================
	 */
	JSCUS_SQL._RECORD._STOCK_CARD.CUS_BACKDATE = function
	(
		VAR_PARAMETER_ARRAY,
		CALLBACK_ADDRESS,
		FORWARDED_RESPONSE_STRING
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_PARAMETER_ARRAY, 'VAR_PARAMETER_ARRAY', 'ARRAY');
		
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";	
		var ARRAY_INDEX = 0;
		var RAW_VAR_PARAMETER_ARRAY = JSVC_ARR.VAR_CLONE(VAR_PARAMETER_ARRAY);
		
		if(JSVC_VAR.VAR_IS_ARRAY(VAR_PARAMETER_ARRAY[0]) == true)
		{
			// Check limits per request 
			if(VAR_PARAMETER_ARRAY.length > CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				throw "HTTP request is too large for single request. Limit : " + CUSTOM_SITE_ARRAY_REQUEST_LIMIT;
			}
			
			// Populate Array Items
			while(VAR_PARAMETER_ARRAY.length > 0 && ARRAY_INDEX < CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_ID[]', VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_ID"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_CAT_PRODUCT_ID[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_CAT_PRODUCT_ID"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_QUANTITY[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_QUANTITY"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_REMARKS[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_REMARKS"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_DATE_TRANSACTION[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_DATE_TRANSACTION"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_STATUS[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_STATUS"]);
				if(JSVC_VAR.VAR_ISSET(VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_ID_FILE"]))
				{
					PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_ID_FILE[]',  VAR_PARAMETER_ARRAY[0]["PARAM_REC_STOCKCARD_ID_FILE"]);
				}
				if(ARRAY_INDEX == 0)
				{
					PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REQUEST_UNIQUE_VALUE',  VAR_PARAMETER_ARRAY[0]["PARAM_REQUEST_UNIQUE_VALUE"]);
				}
				VAR_PARAMETER_ARRAY.shift();
				ARRAY_INDEX ++;
			}					
		}
		else
		{
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_ID[]', VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_ID"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_CAT_PRODUCT_ID[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_CAT_PRODUCT_ID"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_QUANTITY[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_QUANTITY"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_REMARKS[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_REMARKS"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_DATE_TRANSACTION[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_STATUS[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_STATUS"]);
			if(JSVC_VAR.VAR_ISSET(VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_ID_FILE"]))
			{
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REC_STOCKCARD_ID_FILE[]',  VAR_PARAMETER_ARRAY["PARAM_REC_STOCKCARD_ID_FILE"]);
			}
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_REQUEST_UNIQUE_VALUE',  VAR_PARAMETER_ARRAY["PARAM_REQUEST_UNIQUE_VALUE"]);
		}

		// Send SQL Request [Splitted multi-request]
		// _______________________________________________________________________	
		if(VAR_PARAMETER_ARRAY.length > 0)
		{	
			CUS_SEND_REQUEST
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Merge RESPONSE_STRING
					// ...........................................
					if(JSVC_VAR.VAR_IS_ARRAY(FORWARDED_RESPONSE_STRING))
					{
						FORWARDED_RESPONSE_STRING.push(RESPONSE_STRING);
					}
					else if(JSVC_STR.VAR_IS_BLANK(FORWARDED_RESPONSE_STRING))
					{
						FORWARDED_RESPONSE_STRING = RESPONSE_STRING;
					}
					else
					{
						FORWARDED_RESPONSE_STRING = [FORWARDED_RESPONSE_STRING, RESPONSE_STRING];
					}
					
					// Validate
					// ...........................................
					if(IS_SUCCESS === false)
					{
						CALLBACK_ADDRESS(IS_SUCCESS, RESPONSE_STRING, RAW_VAR_PARAMETER_ARRAY);
						return;
					}
					
					// Validate JSON Response
					// ...........................................
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						CALLBACK_ADDRESS(IS_SUCCESS, RESPONSE_STRING, RAW_VAR_PARAMETER_ARRAY);
						return;
					}		
					
					// To next request
					// ...........................................	
					JSCUS_SQL._RECORD._STOCK_CARD.CUS_BACKDATE
					(
						VAR_PARAMETER_ARRAY,
						CALLBACK_ADDRESS,
						FORWARDED_RESPONSE_STRING
					);
				},
				JSCUS_CACHE.SERVER_URL + '/Record/stock_card/backdate',
				JSCUS_CACHE.SERVER_URL + '/System/nonce/get',
				PARAM_SET
			);		
		}
		
		// Send SQL Request [One-time request]
		// _______________________________________________________________________
		else
		{
			CUS_SEND_REQUEST
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Merge RESPONSE_STRING
					// ...........................................
					if(JSVC_VAR.VAR_IS_ARRAY(FORWARDED_RESPONSE_STRING))
					{
						FORWARDED_RESPONSE_STRING.push(RESPONSE_STRING);
					}
					else if(JSVC_STR.VAR_IS_BLANK(FORWARDED_RESPONSE_STRING))
					{
						FORWARDED_RESPONSE_STRING = RESPONSE_STRING;
					}
					else
					{
						FORWARDED_RESPONSE_STRING = [FORWARDED_RESPONSE_STRING, RESPONSE_STRING];
					}
					
					// Validate
					// ...........................................
					if(IS_SUCCESS === false)
					{
						CALLBACK_ADDRESS(IS_SUCCESS, RESPONSE_STRING, RAW_VAR_PARAMETER_ARRAY);
						return;
					}
					
					// Validate JSON Response
					// ...........................................
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						CALLBACK_ADDRESS(IS_SUCCESS, RESPONSE_STRING, RAW_VAR_PARAMETER_ARRAY);
						return;
					}		
					
					// Execute callback
					// ...........................................
					CALLBACK_ADDRESS(IS_SUCCESS, FORWARDED_RESPONSE_STRING);
				},
				JSCUS_CACHE.SERVER_URL + '/Record/stock_card/backdate',
				JSCUS_CACHE.SERVER_URL + '/System/nonce/get',
				PARAM_SET
			);	
		}
	};
	
	
	
	/** 
	 * =======================================================================================================
	 * Populate SP-GET request request parameters with default value.
	 * =======================================================================================================
	 */
	JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_BACKDATE = function()
	{
		// Initialize
		var RESULT_MAPARRAY = [];

		// Populate default fields
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_CAT_PRODUCT_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_QUANTITY"] = FLAG_DECIMAL_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_REMARKS"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_DATE_TRANSACTION"] = FLAG_DATETIME_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_STATUS"] = FLAG_TINYINT_NULL;
		RESULT_MAPARRAY["PARAM_REC_STOCKCARD_ID_FILE"] = null;
		RESULT_MAPARRAY["PARAM_REQUEST_UNIQUE_VALUE"] = '';
		
		// Return prepared MapArray
		return RESULT_MAPARRAY;
	};