	// ===============================================================
	// 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_INVOICE_ID, 1, 1))
		{
			return;
		}
		
		
		// Initialize
		// _______________________________________________________________________
		var TARGET_MODAL = "INVOICE_MODAL";
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICE_ID', PROPERTY_REC_INVOICE_ID);
		
		
		// Load Line
		// _______________________________________________________________________
		var INVOICE_LINE_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("INVOICE_LINE_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
			
			
			// JSON Empty (Clears the DataGrodView)
			// ...........................................
			if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
			{
				INVOICE_LINE_DGV.ROW.CLEAR();
				if(INVOICE_LINE_DGV.COLUMN.TOTAL_IS_READY())
				{
					INVOICE_LINE_DGV.COLUMN.TOTAL_REFRESH();
				}
			}
			
			// Populate DGV
			// ...........................................
			else
			{
				INVOICE_LINE_DGV.POPULATE_FROM_QUERY
				(
						JSON_OBJECT, 
						'',
						false,
						false,
						1,
						[2, 1]
				);
				
				// Auto-total tool
				if(INVOICE_LINE_DGV.COLUMN.TOTAL_IS_READY())
				{
					INVOICE_LINE_DGV.COLUMN.TOTAL_REFRESH();
				}	
			}
			STATUS_BUTTON_MANAGE();
			
			
			// Actual Function
			// ...........................................
			GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE_RETURN.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICERTN_REC_INVOICE_ID', PROPERTY_REC_INVOICE_ID);
			JSOC_DIALOG.VAR_LOADING_SPINNER(true);
			JSCUS_SQL._RECORD._INVOICE_RETURN.CUS_GET
			(
				GET_MAP_ARRAY,
				INVOICE_RETURN_CALLBACK,
				true
			); 		
		};
		

		// Load Return
		// _______________________________________________________________________
		var INVOICE_RETURN_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("INVOICE_RTN_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
			
			
			// JSON Empty (Clears the DataGrodView)
			// ...........................................
			if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
			{
				INVOICE_RTN_DGV.ROW.CLEAR();
				if(INVOICE_RTN_DGV.COLUMN.TOTAL_IS_READY())
				{
					INVOICE_RTN_DGV.COLUMN.TOTAL_REFRESH();
				}
				return;
			}
			
			// Populate DGV
			// ...........................................
			INVOICE_RTN_DGV.POPULATE_FROM_QUERY
			(
					JSON_OBJECT, 
					'',
					false,
					false,
					1,
					[2, 1]
			);
			
			
			// Auto-total tool
			// ...........................................
			if(INVOICE_RTN_DGV.COLUMN.TOTAL_IS_READY())
			{
				INVOICE_RTN_DGV.COLUMN.TOTAL_REFRESH();
			}
			STATUS_BUTTON_MANAGE();
			
			
			// 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._INVOICE.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();
				}
				
				if(JSOC_CMB.VAR_SELECTED_VALUE_NVAL(REC_INVOICE_ACC_GROUP_ID_CMB) != 100)
				{
					REC_INVOICE_NAME_TXT.readOnly = true;
				}
				else
				{
					REC_INVOICE_NAME_TXT.readOnly = false;
				}
			
				/*
				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_INVOICE_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._INVOICE_LINE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICELIST_REC_INVOICE_ID', PROPERTY_REC_INVOICE_ID);
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._INVOICE_LINE.CUS_GET
				(
					GET_MAP_ARRAY,
					INVOICE_LINE_CALLBACK,
					true
				); 			
			},
			
			TARGET_MODAL, 
			FLAG_TINYINT_NULL, 
			PROPERTY_REC_INVOICE_ID
			//, GET_MAP_ARRAY
		);
		
		
		// Clear Changes due to loading
		// _______________________________________________________________________
		
		
	};


	// ===============================================================
	// Trims empty spaces and perform convertion for numeric fields.
	// ===============================================================
	function FIX_INPUT()
	{
		// Fix String Fields
		// ...........................................
		
		
		// Fix Numeric Fields (if field type is not number.)
		// ...........................................
		if(JSOC_ELEMENT.VAR_TYPE_IS(REC_INVOICE_DISCOUNT_OTHER_TXT, 'input', 'number'))
		{
			JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_DISCOUNT_OTHER_TXT);
		}
		else
		{
			JSOC_INPUT_TEXT.CTL_CFORMAT(REC_INVOICE_DISCOUNT_OTHER_TXT);
		}			
		if(JSOC_ELEMENT.VAR_TYPE_IS(REC_INVOICE_AMOUNT_DUE_TXT, 'input', 'number'))
		{
			JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_AMOUNT_DUE_TXT);
		}
		else
		{
			JSOC_INPUT_TEXT.CTL_CFORMAT(REC_INVOICE_AMOUNT_DUE_TXT);
		}			
		if(JSOC_ELEMENT.VAR_TYPE_IS(REC_INVOICE_AMOUNT_PAID_TXT, 'input', 'number'))
		{
			JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_AMOUNT_PAID_TXT);
		}
		else
		{
			JSOC_INPUT_TEXT.CTL_CFORMAT(REC_INVOICE_AMOUNT_PAID_TXT);
		}			


		// 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]
		// _______________________________________________________________________
		if(JSOC_INPUT_TEXT.CTL_VALIDATE(REC_INVOICE_NAME_TXT, "Name", null, 1, 150) == false)
		{
			REC_INVOICE_NAME_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
			REC_INVOICE_NAME_TXT.focus();
			return false;
		}

		// Validate Negative [Numeric Input]
		// _______________________________________________________________________
		var ROW_COUNT = INVOICE_LINE_DGV.ROW.COUNT();
		var ROW_INDEX = 0;
		
		while(ROW_COUNT > ROW_INDEX)
		{
			if(INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_PRICE", ROW_INDEX) < 0)
			{
				JSOC_DIALOG.VAR_MESSAGE_BOX
				(
					'Field Product pricing cannot be negative. Given : ' + 
					INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_PRICE", ROW_INDEX), 
					'Information', 'OK', 'WARNING',
					function(MESSAGE_RESPONSE)
					{
						CALLBACK_METHOD(false);
					}
				);	
				return;			
			}

			if(INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_QUANTITY", ROW_INDEX) < 0)
			{
				JSOC_DIALOG.VAR_MESSAGE_BOX
				(
					'Field Product quantity cannot be negative. Given : ' + 
					INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_QUANTITY", ROW_INDEX), 
					'Information', 'OK', 'WARNING',
					function(MESSAGE_RESPONSE)
					{
						CALLBACK_METHOD(false);
					}
				);	
				return;			
			}

			if(INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_DISCOUNT", ROW_INDEX) < 0)
			{
				JSOC_DIALOG.VAR_MESSAGE_BOX
				(
					'Field Product discount cannot be negative. Given : ' + 
					INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_DISCOUNT", ROW_INDEX), 
					'Information', 'OK', 'WARNING',
					function(MESSAGE_RESPONSE)
					{
						CALLBACK_METHOD(false);
					}
				);	
				return;			
			}
									
			ROW_INDEX ++;
		}
	
	
		// Validate Negative [Numeric Input]
		// _______________________________________________________________________
		if(JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_DISCOUNT_OTHER_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Other Discounts cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_INVOICE_DISCOUNT_OTHER_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_INVOICE_DISCOUNT_OTHER_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		/*
		if(JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_AMOUNT_DUE_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Amount Due cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_INVOICE_AMOUNT_DUE_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_INVOICE_AMOUNT_DUE_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		*/
		if(JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_AMOUNT_RETURN_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Amount Return cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_INVOICE_AMOUNT_RETURN_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_INVOICE_AMOUNT_RETURN_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		/*
		if(JSOC_INPUT_TEXT.CTL_NVAL(REC_INVOICE_AMOUNT_PAID_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Amount Paid cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_INVOICE_AMOUNT_PAID_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_INVOICE_AMOUNT_PAID_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		*/

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

		// Validate Duplicates
		// _______________________________________________________________________
		var EXCEPTION_ROW_INDEX = -1;
		if(PROPERTY_REC_INVOICE_ID >= 0)
		{
			EXCEPTION_ROW_INDEX = PROPERTY_EDIT_ROW_INDEX;
		}
			
		
		// Save item [Parent Data]
		// _______________________________________________________________________		
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_ID", PROPERTY_REC_INVOICE_ID);				
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_REFERENCE", JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_REFERENCE_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVOICE_ACC_GROUP_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_NAME", JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_NAME_TXT));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_DISCOUNT_OTHER", JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_DISCOUNT_OTHER_TXT)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_AMOUNT_DUE", JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_AMOUNT_DUE_TXT)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_AMOUNT_RETURN", JSOC_ELEMENT.VAR_VALUE_NVAL(REC_INVOICE_AMOUNT_RETURN_TXT));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_AMOUNT_ADJUSTMENT", JSOC_ELEMENT.VAR_VALUE_NVAL(REC_INVOICE_AMOUNT_ADJUSTMENT_TXT));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_AMOUNT_PAID", JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_AMOUNT_PAID_TXT)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_REMARKS", JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_REMARKS_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_REC_EMPLOYEE_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVOICE_REC_EMPLOYEE_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_DATE_DELIVERY", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_DATE_DELIVERY_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_DATE_DUE", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_INVOICE_DATE_DUE_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICE_STATUS", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVOICE_STATUS_CMB)));

		// 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);		
		};

		// 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
			// ...........................................
			PROPERTY_REC_INVOICE_ID = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1"));
			
			// Skip LIne Save if Changing a Status
			// ...........................................
			if(JSOC_ELEMENT.VAR_ENABLED(SAVE_BBI) == true)
			{
				HTTP_SAVE_LINE(CALLBACK_METHOD, 0);
			}
			else
			{
				HTTP_SAVE_COMPLETION();
			}							
		};

			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._INVOICE.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};
	
	
	
	
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE_LINE(CALLBACK_METHOD, RESUME_INDEX)
	{
		// Save item [Prepare]
		// _______________________________________________________________________
		var REQUEST_PARAM_BUNDLE_MAP_ARRAY = [];
		var SAVE_MAP_ARRAY = [];
		var ROW_COUNT = INVOICE_LINE_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._INVOICE_LINE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
			
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_ID", INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_ID", ROW_INDEX));				
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_REC_INVOICE_ID", PROPERTY_REC_INVOICE_ID);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_CAT_PRODUCT_ID", INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_CAT_PRODUCT_ID", ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_PRICE", INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_PRICE", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_QUANTITY", INVOICE_LINE_DGV.CELL.VALUE_NVAL("REC_INVOICELIST_QUANTITY", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_DISCOUNT", INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_DISCOUNT", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICELIST_STATUS", INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_STATUS", ROW_INDEX));
			
			REQUEST_PARAM_BUNDLE_MAP_ARRAY.push(SAVE_MAP_ARRAY);
			ROW_INDEX ++;
		}
		
		
		// On Completion Callback
		// _______________________________________________________________________
		var HTTP_SAVE_COMPLETION = function()
		{
			HTTP_SAVE_RETURN(CALLBACK_METHOD, 0);			
		};
		
		
		// Abort Save if no items on the line, then proceed to returns
		// _______________________________________________________________________
		if
		(
			REQUEST_PARAM_BUNDLE_MAP_ARRAY.length <= 0 || 
			JSOC_CMB.VAR_SELECTED_VALUE_NVAL('REC_INVOICE_STATUS_CMB') >= 2
		)
		{
			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_INVOICELIST_CAT_PRODUCT_ID", JSON_COUNT);
				CURRENT_ROW_INDEX = INVOICE_LINE_DGV.COLUMN.FIND("REC_INVOICELIST_CAT_PRODUCT_ID", CURRENT_REC_TRANSLIST_CAT_PRODUCT_ID);
				CURRENT_REC_INVOICELIST_STATUS = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICELIST_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 == 199)
				{
					DGV_ROWS.REMOVE_AT(CURRENT_ROW_INDEX, true);	
					JSON_COUNT --;
					continue;
				}
				
				// Update Value
				INVOICE_LINE_DGV.CELL.VALUE("REC_INVOICELIST_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, ROW_INDEX);
				return;
			}
			else
			{
				HTTP_SAVE_COMPLETION();
			}										
		};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._INVOICE_LINE.CUS_SAVE 
		(
			REQUEST_PARAM_BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};
	
	
	function HTTP_SAVE_RETURN(CALLBACK_METHOD, RESUME_INDEX)
	{	
		// Save item [Prepare]
		// _______________________________________________________________________
		var REQUEST_PARAM_BUNDLE_MAP_ARRAY = [];
		var SAVE_MAP_ARRAY = [];
		var ROW_COUNT = INVOICE_RTN_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._INVOICE_RETURN.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
			
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_ID", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_ID", ROW_INDEX));				
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_REC_INVOICE_ID", PROPERTY_REC_INVOICE_ID);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_CAT_PRODUCT_ID", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_CAT_PRODUCT_ID", ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_PRICE", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_PRICE", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_QUANTITY", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_QUANTITY", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_DISCOUNT", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_DISCOUNT", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_TO_INVENTORY", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_TO_INVENTORY", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_INVOICERTN_STATUS", INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_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 return, then execute clearning and callback
		// _______________________________________________________________________
		if
		(
			REQUEST_PARAM_BUNDLE_MAP_ARRAY.length <= 0 || 
			JSOC_CMB.VAR_SELECTED_VALUE_NVAL('REC_INVOICE_STATUS_CMB') >= 3
		)
		{
			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_INVOICERTN_ID = 0;
			var CURRENT_REC_INVOICERTN_CAT_PRODUCT_ID = 0;
			var CURRENT_REC_INVOICERTN_STATUS = 0;
			var CURRENT_ROW_INDEX = 0;
					
			while(JSON_COUNT > 0)
			{
				// Initialize Loop
				CURRENT_REC_INVOICERTN_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", JSON_COUNT);
				CURRENT_REC_INVOICERTN_CAT_PRODUCT_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICERTN_CAT_PRODUCT_ID", JSON_COUNT);
				CURRENT_ROW_INDEX = INVOICE_RTN_DGV.COLUMN.FIND("REC_INVOICERTN_CAT_PRODUCT_ID", CURRENT_REC_INVOICERTN_CAT_PRODUCT_ID);
				CURRENT_REC_INVOICERTN_STATUS = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICERTN_STATUS", JSON_COUNT);
				
				// Abort if unable to locate the saved column
				if(CURRENT_ROW_INDEX  < 0)
				{
					JSON_COUNT --;
					continue;
				}
				
				// Remove Line
				if(CURRENT_REC_INVOICERTN_STATUS == 199)
				{
					INVOICE_RTN_DGV.ROW.REMOVE_AT(CURRENT_ROW_INDEX, true);	
					JSON_COUNT --;
					continue;
				}
				
				// Update Value
				INVOICE_RTN_DGV.CELL.VALUE("REC_INVOICERTN_ID", CURRENT_ROW_INDEX, CURRENT_REC_INVOICERTN_ID);
						
				// To next loop
				JSON_COUNT --;
			}


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