<?php

	// Perform Login
	$CURRENT_MODULE_KEY = 'record_psactual';
    $SHORTCODE_STATUS = PHPCUS_SHORTCODE::CUS_QUICK_LOGIN();
	
	// Check nonce
	if($SHORTCODE_STATUS == false)
    {
		PHPCUS_PARAM::CUS_REQUIRES_NONCE();
	}
	
	// Check array size
	PHPCUS_PARAM::CUS_ARRAY_TOO_LARGE();
	
	// Check already authenticated
	PHPCUS_PARAM::CUS_REQUIRES_AUTHENTICATION();

	// Check access rights
	PHPCUS_PARAM::CUS_HAS_PERMISSION(PHPCUS_SYSTEM::AUTHORITY_VIEW_EDIT, $CURRENT_MODULE_KEY);
	
	if
	(
			PHPRC_HTTP_PARAM::REF_ISSET_IN_ARRAY
			(
					[
							'PARAM_REC_PSACTUAL_ID',
							'PARAM_REC_PSACTUAL_ACC_GROUP_ID', 
							'PARAM_REC_PSACTUAL_CAT_PRODUCT_ID', 
							'PARAM_REC_PSACTUAL_QTY_D01', 
							'PARAM_REC_PSACTUAL_QTY_D02', 
							'PARAM_REC_PSACTUAL_QTY_D03', 
							'PARAM_REC_PSACTUAL_QTY_D04', 
							'PARAM_REC_PSACTUAL_QTY_D05', 
							'PARAM_REC_PSACTUAL_QTY_D06', 
							'PARAM_REC_PSACTUAL_QTY_D07', 
							'PARAM_REC_PSACTUAL_QTY_D08', 
							'PARAM_REC_PSACTUAL_QTY_D09', 
							'PARAM_REC_PSACTUAL_QTY_D10', 
							'PARAM_REC_PSACTUAL_QTY_D11', 
							'PARAM_REC_PSACTUAL_QTY_D12', 
							'PARAM_REC_PSACTUAL_QTY_D13', 
							'PARAM_REC_PSACTUAL_QTY_D14', 
							'PARAM_REC_PSACTUAL_QTY_D15', 
							'PARAM_REC_PSACTUAL_QTY_D16', 
							'PARAM_REC_PSACTUAL_QTY_D17', 
							'PARAM_REC_PSACTUAL_QTY_D18', 
							'PARAM_REC_PSACTUAL_QTY_D19', 
							'PARAM_REC_PSACTUAL_QTY_D20', 
							'PARAM_REC_PSACTUAL_QTY_D21', 
							'PARAM_REC_PSACTUAL_QTY_D22', 
							'PARAM_REC_PSACTUAL_QTY_D23', 
							'PARAM_REC_PSACTUAL_QTY_D24', 
							'PARAM_REC_PSACTUAL_QTY_D25', 
							'PARAM_REC_PSACTUAL_QTY_D26', 
							'PARAM_REC_PSACTUAL_QTY_D27', 
							'PARAM_REC_PSACTUAL_QTY_D28', 
							'PARAM_REC_PSACTUAL_QTY_D29', 
							'PARAM_REC_PSACTUAL_QTY_D30', 
							'PARAM_REC_PSACTUAL_QTY_D31', 
							'PARAM_REC_PSACTUAL_QTY_TOTAL', 
							'PARAM_REC_PSACTUAL_DATE', 
							'PARAM_REC_PSACTUAL_REMARKS', 
							'PARAM_REC_PSACTUAL_STATUS'
							// , 'PARAM_REC_PSACTUAL_ID_FILE'
					], True
			)
	)
	{
		Try
		{
			// Read params
			// ------------------------------------------------------------------
			$PARAM_REC_PSACTUAL_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_REC_PSACTUAL_ID', true);
			$PARAM_REC_PSACTUAL_ACC_GROUP_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_REC_PSACTUAL_ACC_GROUP_ID', true);
			$PARAM_REC_PSACTUAL_CAT_PRODUCT_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_REC_PSACTUAL_CAT_PRODUCT_ID', true);
			$PARAM_REC_PSACTUAL_QTY_D01 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D01', true);
			$PARAM_REC_PSACTUAL_QTY_D02 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D02', true);
			$PARAM_REC_PSACTUAL_QTY_D03 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D03', true);
			$PARAM_REC_PSACTUAL_QTY_D04 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D04', true);
			$PARAM_REC_PSACTUAL_QTY_D05 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D05', true);
			$PARAM_REC_PSACTUAL_QTY_D06 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D06', true);
			$PARAM_REC_PSACTUAL_QTY_D07 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D07', true);
			$PARAM_REC_PSACTUAL_QTY_D08 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D08', true);
			$PARAM_REC_PSACTUAL_QTY_D09 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D09', true);
			$PARAM_REC_PSACTUAL_QTY_D10 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D10', true);
			$PARAM_REC_PSACTUAL_QTY_D11 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D11', true);
			$PARAM_REC_PSACTUAL_QTY_D12 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D12', true);
			$PARAM_REC_PSACTUAL_QTY_D13 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D13', true);
			$PARAM_REC_PSACTUAL_QTY_D14 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D14', true);
			$PARAM_REC_PSACTUAL_QTY_D15 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D15', true);
			$PARAM_REC_PSACTUAL_QTY_D16 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D16', true);
			$PARAM_REC_PSACTUAL_QTY_D17 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D17', true);
			$PARAM_REC_PSACTUAL_QTY_D18 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D18', true);
			$PARAM_REC_PSACTUAL_QTY_D19 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D19', true);
			$PARAM_REC_PSACTUAL_QTY_D20 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D20', true);
			$PARAM_REC_PSACTUAL_QTY_D21 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D21', true);
			$PARAM_REC_PSACTUAL_QTY_D22 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D22', true);
			$PARAM_REC_PSACTUAL_QTY_D23 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D23', true);
			$PARAM_REC_PSACTUAL_QTY_D24 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D24', true);
			$PARAM_REC_PSACTUAL_QTY_D25 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D25', true);
			$PARAM_REC_PSACTUAL_QTY_D26 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D26', true);
			$PARAM_REC_PSACTUAL_QTY_D27 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D27', true);
			$PARAM_REC_PSACTUAL_QTY_D28 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D28', true);
			$PARAM_REC_PSACTUAL_QTY_D29 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D29', true);
			$PARAM_REC_PSACTUAL_QTY_D30 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D30', true);
			$PARAM_REC_PSACTUAL_QTY_D31 = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_D31', true);
			$PARAM_REC_PSACTUAL_QTY_TOTAL = PHPCUS_PARAM::CUS_READ_DECIMAL('PARAM_REC_PSACTUAL_QTY_TOTAL', true);
			$PARAM_REC_PSACTUAL_DATE = PHPCUS_PARAM::CUS_READ_DATETIME('PARAM_REC_PSACTUAL_DATE', true);
			$PARAM_REC_PSACTUAL_REMARKS = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_REC_PSACTUAL_REMARKS', true);
			$PARAM_REC_PSACTUAL_STATUS = PHPCUS_PARAM::CUS_READ_INT('PARAM_REC_PSACTUAL_STATUS', true);
			
			//$PARAM_REC_PSACTUAL_ID_FILE = PHPCUS_PARAM::CUS_READ_FILES('PARAM_REC_PSACTUAL_ID_FILE');
			$PARAM_ARRAY_COUNT = count($PARAM_REC_PSACTUAL_ID);
			
				
			// Validate if array has same size
			// ------------------------------------------------------------------
			PHPCUS_PARAM::CUS_ARRAY_SIZE_MISMATCH
			(
					[
							$PARAM_REC_PSACTUAL_ID,
							$PARAM_REC_PSACTUAL_ACC_GROUP_ID, 
							$PARAM_REC_PSACTUAL_CAT_PRODUCT_ID, 
							$PARAM_REC_PSACTUAL_QTY_D01, 
							$PARAM_REC_PSACTUAL_QTY_D02, 
							$PARAM_REC_PSACTUAL_QTY_D03, 
							$PARAM_REC_PSACTUAL_QTY_D04, 
							$PARAM_REC_PSACTUAL_QTY_D05, 
							$PARAM_REC_PSACTUAL_QTY_D06, 
							$PARAM_REC_PSACTUAL_QTY_D07, 
							$PARAM_REC_PSACTUAL_QTY_D08, 
							$PARAM_REC_PSACTUAL_QTY_D09, 
							$PARAM_REC_PSACTUAL_QTY_D10, 
							$PARAM_REC_PSACTUAL_QTY_D11, 
							$PARAM_REC_PSACTUAL_QTY_D12, 
							$PARAM_REC_PSACTUAL_QTY_D13, 
							$PARAM_REC_PSACTUAL_QTY_D14, 
							$PARAM_REC_PSACTUAL_QTY_D15, 
							$PARAM_REC_PSACTUAL_QTY_D16, 
							$PARAM_REC_PSACTUAL_QTY_D17, 
							$PARAM_REC_PSACTUAL_QTY_D18, 
							$PARAM_REC_PSACTUAL_QTY_D19, 
							$PARAM_REC_PSACTUAL_QTY_D20, 
							$PARAM_REC_PSACTUAL_QTY_D21, 
							$PARAM_REC_PSACTUAL_QTY_D22, 
							$PARAM_REC_PSACTUAL_QTY_D23, 
							$PARAM_REC_PSACTUAL_QTY_D24, 
							$PARAM_REC_PSACTUAL_QTY_D25, 
							$PARAM_REC_PSACTUAL_QTY_D26, 
							$PARAM_REC_PSACTUAL_QTY_D27, 
							$PARAM_REC_PSACTUAL_QTY_D28, 
							$PARAM_REC_PSACTUAL_QTY_D29, 
							$PARAM_REC_PSACTUAL_QTY_D30, 
							$PARAM_REC_PSACTUAL_QTY_D31, 
							$PARAM_REC_PSACTUAL_QTY_TOTAL, 
							$PARAM_REC_PSACTUAL_DATE, 
							$PARAM_REC_PSACTUAL_REMARKS, 
							$PARAM_REC_PSACTUAL_STATUS
							// ,$PARAM_REC_PSACTUAL_ID_FILE['name']
					]
			);
			
			
			// Abort if already processed
			// ------------------------------------------------------------------
			$PARAM_REQUEST_UNIQUE_VALUE = null;
			if(PHPRC_HTTP_PARAM::REF_ISSET('PARAM_REQUEST_UNIQUE_VALUE'))
			{
				$PARAM_REQUEST_UNIQUE_VALUE = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_REQUEST_UNIQUE_VALUE', false);
			}
			else
			{
				// Dismiss Session
				PHPVC_SESSION::VAR_STOP();
			}
			
			if(PHPVC_STR::VAR_IS_BLANK($PARAM_REQUEST_UNIQUE_VALUE) == false)
			{
				$ARR_INDEX = array_search($CURRENT_MODULE_KEY, PHPCUS_Account_Login_Session::$SESSION_REQUEST_KEY); 
				if
				(
					$ARR_INDEX !== false &&
					PHPCUS_Account_Login_Session::$SESSION_REQUEST_LAST_VALUE[$ARR_INDEX] == $PARAM_REQUEST_UNIQUE_VALUE
				)
				{
					PHPCUS_PARAM::CUS_JSON_ERROR('Given Request is already processed.');
				}
			}
		
		
			// Prepare PDO Handler
			// ------------------------------------------------------------------
			$FULL_DATA_SET = [];
			$ARRAY_CTR = 0;
			
			$SAVE_MAP_ARRAY = [];
			$PDO_HANDLE = PHPRC_PDO_MYSQL::REF_CONNECT();
			PHPRC_PDO_MYSQL::REF_TRANSACTION_BEGIN($PDO_HANDLE);
			
		
			// Execute Stored Procedure
			// ------------------------------------------------------------------
			Try
			{
				while($ARRAY_CTR < $PARAM_ARRAY_COUNT)
				{
					$SAVE_MAP_ARRAY = PHPCUS_RECORD_PSACTUAL::CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
					
					$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_ID'] = $PARAM_REC_PSACTUAL_ID[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_ACC_GROUP_ID'] = $PARAM_REC_PSACTUAL_ACC_GROUP_ID[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_CAT_PRODUCT_ID'] = $PARAM_REC_PSACTUAL_CAT_PRODUCT_ID[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D01'] = $PARAM_REC_PSACTUAL_QTY_D01[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D02'] = $PARAM_REC_PSACTUAL_QTY_D02[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D03'] = $PARAM_REC_PSACTUAL_QTY_D03[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D04'] = $PARAM_REC_PSACTUAL_QTY_D04[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D05'] = $PARAM_REC_PSACTUAL_QTY_D05[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D06'] = $PARAM_REC_PSACTUAL_QTY_D06[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D07'] = $PARAM_REC_PSACTUAL_QTY_D07[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D08'] = $PARAM_REC_PSACTUAL_QTY_D08[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D09'] = $PARAM_REC_PSACTUAL_QTY_D09[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D10'] = $PARAM_REC_PSACTUAL_QTY_D10[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D11'] = $PARAM_REC_PSACTUAL_QTY_D11[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D12'] = $PARAM_REC_PSACTUAL_QTY_D12[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D13'] = $PARAM_REC_PSACTUAL_QTY_D13[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D14'] = $PARAM_REC_PSACTUAL_QTY_D14[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D15'] = $PARAM_REC_PSACTUAL_QTY_D15[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D16'] = $PARAM_REC_PSACTUAL_QTY_D16[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D17'] = $PARAM_REC_PSACTUAL_QTY_D17[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D18'] = $PARAM_REC_PSACTUAL_QTY_D18[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D19'] = $PARAM_REC_PSACTUAL_QTY_D19[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D20'] = $PARAM_REC_PSACTUAL_QTY_D20[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D21'] = $PARAM_REC_PSACTUAL_QTY_D21[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D22'] = $PARAM_REC_PSACTUAL_QTY_D22[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D23'] = $PARAM_REC_PSACTUAL_QTY_D23[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D24'] = $PARAM_REC_PSACTUAL_QTY_D24[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D25'] = $PARAM_REC_PSACTUAL_QTY_D25[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D26'] = $PARAM_REC_PSACTUAL_QTY_D26[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D27'] = $PARAM_REC_PSACTUAL_QTY_D27[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D28'] = $PARAM_REC_PSACTUAL_QTY_D28[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D29'] = $PARAM_REC_PSACTUAL_QTY_D29[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D30'] = $PARAM_REC_PSACTUAL_QTY_D30[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_D31'] = $PARAM_REC_PSACTUAL_QTY_D31[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_QTY_TOTAL'] = $PARAM_REC_PSACTUAL_QTY_TOTAL[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_DATE'] = $PARAM_REC_PSACTUAL_DATE[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_REMARKS'] = $PARAM_REC_PSACTUAL_REMARKS[$ARRAY_CTR];
$SAVE_MAP_ARRAY['PARAM_REC_PSACTUAL_STATUS'] = $PARAM_REC_PSACTUAL_STATUS[$ARRAY_CTR];
							
					$DATA_SET = PHPCUS_RECORD_PSACTUAL::CUS_SAVE_MA
					(
							$SAVE_MAP_ARRAY,
							true,
							$PDO_HANDLE
					);
			
					/*
					if
					(
						isset($PARAM_REC_PSACTUAL_ID_FILE['name'][$ARRAY_CTR]) && 
						empty($DATA_SET) == false && 
						isset($DATA_SET[0]['INSERTED_ID'])
					)
					{		
						$FILE_PATH = PHPRC_UPLOAD::REF_SUGGEST_PATH
						(
							PHPSET::$ROOT . '/Upload/priv/Record/psactual/', 
							$DATA_SET[0]['INSERTED_ID'],
							$PARAM_REC_PSACTUAL_ID_FILE['name'][$ARRAY_CTR]
						);
						PHPRC_UPLOAD::REF_UPLOAD_TRANSACTION_MOVEFILE
						(
							$PARAM_REC_PSACTUAL_ID_FILE['tmp_name'][$ARRAY_CTR],
							$FILE_PATH,
							true
						);
					}
					*/
					
					$FULL_DATA_SET = PHPRC_PDO_MYSQL_ARRAY::REF_MERGE($FULL_DATA_SET, $DATA_SET);
					$ARRAY_CTR ++;
				}
					
			}
			Catch(Exception $PDO_ERR)
			{
				PHPRC_PDO_MYSQL::REF_TRANSACTION_ROLLBACK($PDO_HANDLE);
				//PHPRC_UPLOAD::REF_UPLOAD_TRANSACTION_ROLLBACK();
				PHPCUS_PARAM::CUS_JSON_ERROR($PDO_ERR);
			}
			PHPRC_PDO_MYSQL::REF_TRANSACTION_COMMIT($PDO_HANDLE);
			//PHPRC_UPLOAD::REF_UPLOAD_TRANSACTION_COMMIT();
					
					
			// Update processed request key
			// ------------------------------------------------------------------
			if(PHPVC_STR::VAR_IS_BLANK($PARAM_REQUEST_UNIQUE_VALUE) == false)
			{
				$ARR_INDEX = array_search($CURRENT_MODULE_KEY, PHPCUS_Account_Login_Session::$SESSION_REQUEST_KEY);
				if($ARR_INDEX !== false)
				{
					PHPCUS_Account_Login_Session::$SESSION_REQUEST_LAST_VALUE[$ARR_INDEX] = $PARAM_REQUEST_UNIQUE_VALUE;
				}
				else
				{
					array_push(PHPCUS_Account_Login_Session::$SESSION_REQUEST_KEY, $CURRENT_MODULE_KEY);
					array_push(PHPCUS_Account_Login_Session::$SESSION_REQUEST_LAST_VALUE, $PARAM_REQUEST_UNIQUE_VALUE);
				}
				PHPCUS_Account_Login_Session::CUS_SESSION_SAVE_THEN_CLOSE();
			}			
			
			
			// Return JSON response
			// ------------------------------------------------------------------
			PHPCUS_PARAM::CUS_JSON_SUCCESS($FULL_DATA_SET);
			
		}
		Catch(Exception $ERR)
		{
			PHPCUS_PARAM::CUS_JSON_ERROR($ERR);
		}
	}
	else
	{
		PHPCUS_PARAM::CUS_JSON_ERROR('Missing parameters');
	}

?>