	// ===============================================================
	// 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);
		
		
		// Load Line
		// _______________________________________________________________________
		var PO_ORDER_LIST_CALLBACK = function(IS_SUCCESS, RESPONSE_STRING)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
			
			// Validate
			// ...........................................
			if(IS_SUCCESS === false)
			{
				console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
				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);
				return;
			}
			
			// Back to DGV Top
			// ...........................................
			JSOC_ELEMENT.VAR_GET("PO_ORDER_LIST_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
			
			
			// JSON Empty (Clears the DataGrodView)
			// ...........................................
			if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
			{
				PO_ORDER_LIST_DGV.ROW.CLEAR();
				if(PO_ORDER_LIST_DGV.COLUMN.TOTAL_IS_READY())
				{
					PO_ORDER_LIST_DGV.COLUMN.TOTAL_REFRESH();
				}
				return;
			}
			
			// Populate DGV
			// ...........................................
			PO_ORDER_LIST_DGV.POPULATE_FROM_QUERY
			(
					JSON_OBJECT, 
					'',
					false,
					false,
					1,
					[2, 1]
			);
			LINE_UPDATE_STATUS();
			
			// Auto-total tool
			// ...........................................
			if(PO_ORDER_LIST_DGV.COLUMN.TOTAL_IS_READY())
			{
				PO_ORDER_LIST_DGV.COLUMN.TOTAL_REFRESH();
			}
			
			// Make callback if given
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(CALLBACK_FUNCTION))
			{
				CALLBACK_FUNCTION();
			}
		};

		
		// 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'
				);
				*/
				
				
				// Actual Function
				// ...........................................
				STATUS_BUTTON_ENABLED(true);
				STATUS_BUTTON_MANAGE();
				
				GET_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PORDER_LIST_REC_PORDER_ID', PROPERTY_REC_PORDER_ID);
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_GET
				(
					GET_MAP_ARRAY,
					PO_ORDER_LIST_CALLBACK,
					true
				); 	
			},
			
			TARGET_MODAL, 
			FLAG_TINYINT_NULL, 
			PROPERTY_REC_PORDER_ID
			//, GET_MAP_ARRAY
		);
		
		
		// Clear Changes due to loading
		// _______________________________________________________________________
		HTTP_SHOW_MODAL(true);
		
	};


	// ===============================================================
	// 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;
			}
				
			// Load new item into the DataGridView
			// ...........................................
			// Retrieve Inserted ID
			PROPERTY_REC_PORDER_ID = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "INSERTED_ID", "1");
			
			// Lift edit and Exit EditMode
			// ...........................................
			LINE_UPDATE_STATUS();
			HTTP_SAVE_LINE(CALLBACK_METHOD, 0);							
		};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};
	

	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE_LINE(CALLBACK_METHOD, RESUME_INDEX)
	{
		//console.log(CALLBACK_METHOD);
		// Save item [Prepare]
		// _______________________________________________________________________
		var REQUEST_PARAM_BUNDLE_MAP_ARRAY = [];
		var SAVE_MAP_ARRAY = [];
		var ROW_COUNT = PO_ORDER_LIST_DGV.ROW.COUNT();
		var ROW_INDEX = RESUME_INDEX;
		
		while(ROW_COUNT > ROW_INDEX && REQUEST_PARAM_BUNDLE_MAP_ARRAY.length <= 30)
		{		
			// Populate Data
			// ...........................................	
			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_ID", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_ID", ROW_INDEX));				
			
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_REC_PORDER_ID", PROPERTY_REC_PORDER_ID);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_CAT_PRODUCT_ID", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_CAT_PRODUCT_ID", ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_QUANTITY", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_QUANTITY", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_QUANTITY_NET", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_QUANTITY_NET", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_QUANTITY_TOTAL", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_QUANTITY_TOTAL", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_PRICE_PPACK", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_PRICE_PPACK", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_PRICE_TOTAL", PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_PRICE_TOTAL", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_STATUS",  PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_STATUS", ROW_INDEX));
			
			REQUEST_PARAM_BUNDLE_MAP_ARRAY.push(SAVE_MAP_ARRAY);
			ROW_INDEX ++;
		}
		
		
		// On Completion Callback
		// _______________________________________________________________________
		var HTTP_SAVE_COMPLETION = function()
		{
			// Lift edit and Exit EditMode
			// ...........................................
			EDIT_HANDLER.REF_IS_MODIFIED = false;
			EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;	
			STATUS_BUTTON_ENABLED(true);
			STATUS_BUTTON_MANAGE();		
			
			// On Completion
			// ...........................................
			CALLBACK_METHOD(true);		
		};
		
		
		// Abort Save if no items on the line, then proceed to returns
		// _______________________________________________________________________
		if(REQUEST_PARAM_BUNDLE_MAP_ARRAY.length <= 0)
		{
			HTTP_SAVE_COMPLETION();
			return;
		}
		
		
		// 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
			// ...........................................
			var JSON_COUNT = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "JSON_COUNT");
			var CURRENT_REC_INVOICELIST_ID = 0;
			var CURRENT_REC_TRANSLIST_CAT_PRODUCT_ID = 0;
			var CURRENT_REC_INVOICELIST_STATUS = 0;
			var CURRENT_ROW_INDEX = 0;
					
			while(JSON_COUNT > 0)
			{
				// Initialize Loop
				CURRENT_REC_INVOICELIST_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", JSON_COUNT);
				CURRENT_REC_TRANSLIST_CAT_PRODUCT_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PORDER_LIST_CAT_PRODUCT_ID", JSON_COUNT);
				CURRENT_ROW_INDEX = PO_ORDER_LIST_DGV.COLUMN.FIND("REC_PORDER_LIST_CAT_PRODUCT_ID", CURRENT_REC_TRANSLIST_CAT_PRODUCT_ID);
				CURRENT_REC_INVOICELIST_STATUS = JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_STATUS", JSON_COUNT);
				
				// Abort if unable to locate the saved column
				if(CURRENT_ROW_INDEX  < 0)
				{
					JSON_COUNT --;
					continue;
				}
				
				// Remove Line
				if(CURRENT_REC_INVOICELIST_STATUS == 99)
				{
					PO_ORDER_LIST_DGV.ROW.REMOVE_AT(CURRENT_ROW_INDEX, true);	
					JSON_COUNT --;
					continue;
				}
				
				// Update Value
				PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_ID", CURRENT_ROW_INDEX, CURRENT_REC_INVOICELIST_ID);
						
				// To next loop
				JSON_COUNT --;
			}


			// Loop unfinished save
			// ...........................................
			if(ROW_COUNT > ROW_INDEX)
			{
				HTTP_SAVE_LINE(CALLBACK_METHOD, RESUME_INDEX);
				return;
			}
			else
			{
				HTTP_SAVE_COMPLETION();
			}										
		};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_SAVE 
		(
			REQUEST_PARAM_BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};
	