	// ===============================================================
	// Load Parent Information Flags
	// ===============================================================	
	function HTTP_PARENT_LOAD()
	{
	};
	

	// ===============================================================
	// EditHandler Flags
	// ===============================================================	
	
	function HTTP_LOAD(CALLBACK_FUNCTION)
	{
		// Escape if new item
		// _______________________________________________________________________
		if(JSRC_FLAG.IS_NULL_BIGINT(PROPERTY_REC_PORDER_ID, 1, 1))
		{
			return;
		}
		
		
		// Initialize
		// _______________________________________________________________________
		var TARGET_MODAL = "PO_ORDER_MODAL";
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PORDER_ID', PROPERTY_REC_PORDER_ID);
		
		
		// Sample Only
		// _______________________________________________________________________
		var SECONDARY_OPTION = function()
		{
			// GET_MAP_ARRAY = JSCUS_SQL._RECORD._SECONDARY_OPTIONH.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_SECONDARY_OPTION', PROPERTY_SECONDARY_OPTION);
		
			JSCUS_SQL._RECORD._SECONDARY_OPTION.CUS_GET_THEN_POPULATE_FORM
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Dismiss Modal
					// ...........................................
					CUS_SEND_DIALOG_TRY_DISMISS();
					
					// Abort Action, close dialog
					// ...........................................
					if(IS_SUCCESS == false)
					{
						console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
						JSOC_DIALOG.VAR_MODAL(TARGET_MODAL, false);
						return;	
					}
					
					// Validate JSON Response
					// ...........................................
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
						JSOC_DIALOG.VAR_MODAL(TARGET_MODAL, false);
						return;
					}
					
					// JSON Empty (Run Secondary Option Here)
					// ...........................................
					if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
					{
						console.error("REQUEST ERROR: \nData not found.");
						JSOC_DIALOG.VAR_MODAL(TARGET_MODAL, false);
						return;
					}
					
					// Assign Parent ID as Foreign field drop-down
					// ...........................................
					PROPERTY_REC_PORDER_ID = -1;
					JSOC_CMB.VAR_CLEAR(SECONDARY_OPTION_CMB);
					JSOC_CMB.VAR_ADD
					(
						SECONDARY_OPTION_CMB,
						JSRC_JSON.REF_READ(JSON_OBJECT, "SECONDARY_OPTION_ID", "1"), 
						JSRC_JSON.REF_READ(JSON_OBJECT, "SECONDARY_OPTION_DESCRIPTION", "1")
					);
					JSOC_CMB.VAR_SELECTED_INDEX(SECONDARY_OPTION_CMB, 0);
						
					// Make callback if given
					// ...........................................
					if(JSVC_VAR.VAR_ISSET(CALLBACK_FUNCTION))
					{
						CALLBACK_FUNCTION();
					}	
				},
				TARGET_MODAL, 
				FLAG_TINYINT_NULL, 
				PROPERTY_REC_PORDER_ID			
				//, GET_MAP_ARRAY
			);
		};

		
		// Load DB data of item
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER.CUS_GET_THEN_POPULATE_FORM
		(
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				// Abort Action, close dialog
				// ...........................................
				if(IS_SUCCESS == false)
				{
					CUS_SEND_DIALOG_TRY_DISMISS();
					console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
					JSOC_DIALOG.VAR_MODAL(TARGET_MODAL, false);
					return;	
				}
				
				// Validate JSON Response
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					CUS_SEND_DIALOG_TRY_DISMISS();
					console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
					JSOC_DIALOG.VAR_MODAL(TARGET_MODAL, false);
					return;
				}
				
				// JSON Empty (Run Secondary Option Here)
				// ...........................................
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					// SECONDARY_OPTION();
					throw "Unable to load data";
					return;
				}
				else
				{
					CUS_SEND_DIALOG_TRY_DISMISS();
				}
				
				/*
				JSOC_IMAGE.VAR_SRC_WITH_PROGRESS
				(
					'QR_IMAGE_IMG', 
					'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAI=', 
					JSCUS_CACHE.SERVER_URL + '/System/image/qrcode?PARAM_QRCODE=' + JSOC_ELEMENT.VAR_VALUE("REC_PORDER_ID") + '&PARAM_SIZE=10', 
					JSCUS_CACHE.SERVER_URL + '/res/lib/dlg/noimage.png'
				);
				*/
				
				// Make callback if given
				// ...........................................
				if(JSVC_VAR.VAR_ISSET(CALLBACK_FUNCTION))
				{
					CALLBACK_FUNCTION();
				}
			},
			
			TARGET_MODAL, 
			FLAG_TINYINT_NULL, 
			PROPERTY_REC_PORDER_ID
			//, GET_MAP_ARRAY
		);
		
		
		// Clear Changes due to loading
		// _______________________________________________________________________
		
		
	};


	// ===============================================================
	// Trims empty spaces and perform convertion for numeric fields.
	// ===============================================================
	function FIX_INPUT()
	{
		// Fix String Fields
		// ...........................................
		JSOC_INPUT_TEXT.CTL_TRIM(REC_PORDER_CODE_TXT);
		
		
		// Fix Numeric Fields (if field type is not number.)
		// ...........................................


		// Fix Password Fields
		// ...........................................
	};

		
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE(CALLBACK_METHOD)
	{

		// Sanitize User Inputs
		// _______________________________________________________________________
		FIX_INPUT();
	
	
		// Check Edit Status
		// _______________________________________________________________________
		if(EDIT_HANDLER.REF_IS_MODIFIED == false)
		{
			JSVC_INFO.VAR_NOTHING_TO_SAVE(function(){CALLBACK_METHOD(false);})	
			return;		
		}


		// Validate Null [String Input]
		// _______________________________________________________________________
		
		
		// Validate Zero [Numeric Input]
		// _______________________________________________________________________
	
	
		// Validate Negative [Numeric Input]
		// _______________________________________________________________________
		
		
		// Validate Range [Numeric Input]
		// _______________________________________________________________________	


		// Foreign key check
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(REC_PORDER_CAT_COMPANY_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_PORDER_CAT_COMPANY_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_PORDER_CAT_COMPANY_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Supplier is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_PORDER_CAT_COMPANY_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_PORDER_CAT_COMPANY_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		

		// Validate Duplicates
		// _______________________________________________________________________
		var EXCEPTION_ROW_INDEX = -1;
		if(PROPERTY_REC_PORDER_ID >= 0)
		{
			EXCEPTION_ROW_INDEX = PROPERTY_EDIT_ROW_INDEX;
		}
			

		
		
		// Password Items (if available)
		// _______________________________________________________________________
		
		
		// CheckBox Items (if available)
		// _______________________________________________________________________

	
		// File is required
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_PORDER_ID_FILE_FP") &&
			PARAM_REC_PORDER_ID_FILE_FP.files.length <= 0
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_MISSING_INPUT("Upload File", false), 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					PARAM_REC_PORDER_ID_FILE_FP.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					CALLBACK_METHOD(false);
				}
			);		
			return;	
		}
		
	
		// File is too large (Sample Code : 3mb)
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_PORDER_ID_FILE_FP") &&
			PARAM_REC_PORDER_ID_FILE_FP.files[0].size > 1024 * 1024 * 3
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Selected file is too large. File size is restricted to 3mb or below',
				'Information',
				'OK', 'ERROR',
				function()
				{
					CALLBACK_METHOD(false);
				}
			);	
		   PARAM_REC_PORDER_ID_FILE_FP.value = "";
		   return;
		};
		
		 

		
		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', PROPERTY_PARENT_ID);		// Parent ID Sample
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', INPUT_FILE_ELEMENT_FP);		// File Upload Sample
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_ID", PROPERTY_REC_PORDER_ID);				
		
			
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_CAT_COMPANY_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_PORDER_CAT_COMPANY_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_CODE", JSOC_ELEMENT.VAR_VALUE(REC_PORDER_CODE_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_INVOICE_CODE", JSOC_ELEMENT.VAR_VALUE(REC_PORDER_INVOICE_CODE_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_REMARKS", JSOC_ELEMENT.VAR_VALUE(REC_PORDER_REMARKS_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_DATE_EXPECT", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_PORDER_DATE_EXPECT_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_DATE_DELIVERY", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_PORDER_DATE_DELIVERY_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_STATUS", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_PORDER_STATUS_CMB)));
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_PORDER_ID_FILE_FP"))
		{
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_ID_FILE", PARAM_REC_PORDER_ID_FILE_FP);
		}
		
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
			
			// Handle Error
			// ...........................................
			if(IS_SUCCESS === false)
			{
				METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
				return;
			}
			
			// Catch JSON Error
			// ...........................................
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
				return;			
			}

			// Load Response
			// ...........................................
			var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
			if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
			{
				METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
				return;
			}
				
			// Update Changes to DataGridView
			// ...........................................
			if(PROPERTY_REC_PORDER_ID > 0)
			{
				HTTP_SEARCH(PROPERTY_REC_PORDER_ID, PROPERTY_EDIT_ROW_INDEX);
			}
			
			// Load new item into the DataGridView
			// ...........................................
			else
			{
				// Retrieve Inserted ID
				PROPERTY_REC_PORDER_ID = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "INSERTED_ID", "1");
				
				// Add new line
				PO_ORDER_DGV.ROW.INSERT_AT(0);
				HTTP_SEARCH(PROPERTY_REC_PORDER_ID, 0);
			}	

			// Lift edit and Exit EditMode
			// ...........................................
			EDIT_HANDLER.REF_IS_MODIFIED = false;
			EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
			if
			(
				JSOC_ELEMENT.VAR_ELEMENT_EXISTS('PO_ORDER_MODAL') == true
			)
			{
				JSOC_DIALOG.VAR_MODAL('PO_ORDER_MODAL', false);
			}
			
			//SWAP_EDIT_MODE(false);
			CALLBACK_METHOD(true);											
		};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};
	
	
	// ===============================================================
	// Request Delete
	// ===============================================================
	function HTTP_DELETE(CALLBACK_METHOD, ROW_INDEX)
	{
		// Escape if Disabled
		// _______________________________________________________________________
		if(JSVC_VAR.VAR_ISSET(DELETE_BBI) && DELETE_BBI.Enabled == false)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Initialize
		// _______________________________________________________________________
		var DELETE_ITEM_DESCRIPTION = PO_ORDER_DGV.CELL.VALUE('REC_PORDER_CODE', ROW_INDEX);
		
		
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = function
		(
			IS_SUCCESS, 
			HTTP_RESPONSE
		)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
				
				
			// Handle Error
			// ...........................................
			if(IS_SUCCESS === false)
			{
				METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);
				return;
			}
			
			// Catch JSON Error
			// ...........................................
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
				return;			
			}
			
			
			// Read Response
			// ...........................................
			else
			{
				// Load Response
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
					return;
				}
				
				// Post Delete Action
				else
				{
					PO_ORDER_DGV.ROW.REMOVE_AT(ROW_INDEX);
					PO_ORDER_DGV.COLUMN.ROW_COUNT_PRINT('ROW_COUNT');
					JSVC_INFO.VAR_RECORD_DELETED
					(
						DELETE_ITEM_DESCRIPTION, 
						function()
						{
							CALLBACK_METHOD(true);
						}
					);		
				}
			}
		};
		
		
		// Request User Verification for Delete
		// _______________________________________________________________________
		JSVC_INFO.VAR_VERIFY_DELETE
		(
			DELETE_ITEM_DESCRIPTION,
			function(VERIFY_RESULT) 
			{
				// Abort if rejected by user.
				// ...........................................
				if(VERIFY_RESULT != JSOC_DIALOG.MSGBOX_YES)
				{

					CALLBACK_METHOD(false);
					return;
				}
				
				
				//Delete Item
				// ...........................................
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._PO_ORDER.CUS_DELETE
				(
					PO_ORDER_DGV.CELL.VALUE('REC_PORDER_ID', ROW_INDEX),
					RESPONSE_HANDLER
				)
			}
		);
	};
	
	
	// ===============================================================
	// Request Void
	// ===============================================================
	function HTTP_VOID(CALLBACK_METHOD, ROW_INDEX)
	{
		
		// Escape if Disabled
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(PO_ORDER_DGV.CELL.ELEMENT('REC_PORDER_STATUS', ROW_INDEX)) && 
			PO_ORDER_DGV.CELL.ELEMENT('REC_PORDER_STATUS', ROW_INDEX).Enabled == false
		)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Abort if already Voided (Status = 3)
		// _______________________________________________________________________
		if(PO_ORDER_DGV.CELL.VALUE('REC_PORDER_STATUS', ROW_INDEX) == 3)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'This item is already Voided', 
				'Information',
				'OK', 'INFO',
				null
			);		
			return;
		}		
		
		// Notify User to Void	
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_MESSAGE_BOX
		(
			'Do you want to void the selected item?', 
			'Information',
			'YESNO', 'QUESTION',
			function(VERIFY_RESULT)
			{
				if(VERIFY_RESULT == JSOC_DIALOG.MSGBOX_YES)
				{
					PROPERTY_REC_VOUCHER_ID = PO_ORDER_DGV.CELL.VALUE('6966', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;
					HTTP_LOAD
					(
						function()
						{
							JSOC_CMB.VAR_SELECTED_VALUE(REC_PORDER_STATUS_CMB, 3);
							JSOC_DIALOG.VAR_MODAL("PO_ORDER_MODAL", true);
							EDIT_HANDLER.REF_IS_MODIFIED = true;				
						}
					);
				}
			}
		);
		
	};