<?php
/*
	// Perform Login
    $SHORTCODE_STATUS = PHPCUS_SHORTCODE::CUS_QUICK_LOGIN();
	
	// Check nonce
	if($SHORTCODE_STATUS == false)
    {
		PHPCUS_PARAM::CUS_REQUIRES_NONCE();
	}
	
	// Check array size
	PHPCUS_PARAM::CUS_DOES_NOT_SUPPORT_ARRAY();
	
	// Check already authenticated
	PHPCUS_PARAM::CUS_REQUIRES_AUTHENTICATION();

	// Check access rights
	PHPCUS_PARAM::CUS_HAS_PERMISSION(PHPCUS_SYSTEM::AUTHORITY_VIEW_EDIT, 'record_attendance');
	
	if
	(
			PHPRC_HTTP_PARAM::REF_ISSET_IN_ARRAY
			(
					[
							'PARAM_CAT_ENTRANCE_ID',
							'PARAM_REC_USER_UNIQUE_CODE', 
							'PARAM_REC_ATTENDANCE_DEVICE_KEY'
							// , 'PARAM_REC_ATTENDANCE_ID_FILE'
					], True
			)
	)
	{
		Try
		{
			// Read params
			// ------------------------------------------------------------------
		    $PARAM_CAT_ENTRANCE_ID = PHPCUS_PARAM::CUS_READ_BIGINT('PARAM_CAT_ENTRANCE_ID');
		    $PARAM_REC_USER_UNIQUE_CODE = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_REC_USER_UNIQUE_CODE');
			$PARAM_REC_ATTENDANCE_DEVICE_KEY = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_REC_ATTENDANCE_DEVICE_KEY');
			
				
			// Prepare PDO Handler
			// ------------------------------------------------------------------	
			$SAVE_MAP_ARRAY = [];
			$PDO_HANDLE = PHPRC_PDO_MYSQL::REF_CONNECT();
			PHPRC_PDO_MYSQL::REF_TRANSACTION_BEGIN($PDO_HANDLE);
			
		
			// Execute Stored Procedure
			// ------------------------------------------------------------------
			Try
			{
					$SAVE_MAP_ARRAY = PHPCUS_RECORD_ATTENDANCE_CUSTOM::CUS_PREPARE_MAPPED_ARRAY_FOR_PASS();
					
					$SAVE_MAP_ARRAY['PARAM_CAT_ENTRANCE_ID'] = $PARAM_CAT_ENTRANCE_ID;
					$SAVE_MAP_ARRAY['PARAM_REC_USER_UNIQUE_CODE'] = $PARAM_REC_USER_UNIQUE_CODE;
                    $SAVE_MAP_ARRAY['PARAM_REC_ATTENDANCE_DEVICE_KEY'] = $PARAM_REC_ATTENDANCE_DEVICE_KEY;

					$DATA_SET = PHPCUS_RECORD_ATTENDANCE_CUSTOM::CUS_PASS_MA
					(
							$SAVE_MAP_ARRAY,
							true,
							$PDO_HANDLE
					);
					
					
					// Send Attendance SMS
					if(empty($DATA_SET) == false && count($DATA_SET) > 0 && empty($DATA_SET[0]) == false)
					{
					    $HTTP_PARAM =
					    'PARAM_REC_CLIENT_USERNAME[]=' . urlencode(PHPSET::$MOBILE_USERNAME) . '&' .
					    'PARAM_REC_CLIENT_PASSWORD[]=' . urlencode(PHPSET::$MOBILE_PASSWORD) . '&' .
					    'PARAM_REC_SMS_PHONE[]=' . urlencode($DATA_SET[0]['REC_USER_NOTIFY_PHONE']) . '&' .
					    'PARAM_REC_SMS_STUDENT[]=' . urlencode($DATA_SET[0]['REC_USER_LAST_NAME'] . ', ' . $DATA_SET[0]['REC_USER_FIRST_NAME'] . ' ' . $DATA_SET[0]['REC_USER_MIDDLE_NAME'] . ' ' . $DATA_SET[0]['REC_USER_SUFFIX']) . '&' .
					    'PARAM_REC_SMS_DATETIME[]=' . urlencode($DATA_SET[0]['SERVER_TIME']) . '&' .
					    'PARAM_REC_SMS_IS_IN[]=' . urlencode($DATA_SET[0]['REC_ATTENDANCE_IS_IN']) . '&' .
					    'PARAM_REC_SMS_IS_OUT[]=' . urlencode($DATA_SET[0]['REC_ATTENDANCE_IS_OUT']) . '&' .
					    'PARAM_REC_SMS_ENTRANCE[]=' . urlencode($DATA_SET[0]['REC_ATTENDANCE_ENTRANCE']);
					    
					    PHPRC_HTTP::REF_REQUEST(PHPSET::$MOBILE_ATTENDANCE_URL, $HTTP_PARAM);
					}
			}
			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();
						
			
			
			// Return JSON response
			// ------------------------------------------------------------------
			PHPCUS_PARAM::CUS_JSON_SUCCESS($DATA_SET);
			
		}
		Catch(Exception $ERR)
		{
			PHPCUS_PARAM::CUS_JSON_ERROR($ERR);
		}
	}
	else
	{
		PHPCUS_PARAM::CUS_JSON_ERROR('Missing parameters');
	}
*/

	PHPCUS_PARAM::CUS_JSON_ERROR('For development only');	
	
?>