// NOTE: [This JS must loaded as last item]

	// ===============================================================
	// Initialize Form
	// ===============================================================
	function FORM_LOAD()
	{
		// Initialize
		// _______________________________________________________________________	
		var DGV_ELEMENT_CHILD = null;
		var DGV_ELEMENT_CHILD_INDEX = 0;

		// Load DataGridVuew
		// _______________________________________________________________________	
		INVAUDIT_DGV = DataGridView("INVAUDIT_DGV");
		INVENTORY_AUDIT_LINE_DGV = DataGridView("INVENTORY_AUDIT_LINE_DGV");
		//INVAUDIT_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//INVAUDIT_DGV.SETTING_EDITABLE = true;

		INVAUDIT_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{	
				// If dialog supported
				// ...........................................
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVAUDIT_MODAL") == true)
				{
					// Clear Modal
					if(JSVC_VAR.VAR_ISSET(INPUT_INSTANCE))
					{
						JSOC_WINDOW.VAR_INPUT_INSTANCE_RESTORE(INPUT_INSTANCE);
					}

					// Display Modal
					PROPERTY_REC_INVAUDIT_ID = INVAUDIT_DGV.CELL.VALUE('REC_INVAUDIT_ID', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;

					//JSOC_ELEMENT.VAR_VALUE("REC_INVAUDIT_ACC_GROUP_ID_LBL", ": " + INVAUDIT_DGV.CELL.VALUE("REC_INVAUDIT_ACC_GROUP_ID_DESCRIPTION", PROPERTY_EDIT_ROW_INDEX));
					//JSOC_ELEMENT.VAR_VALUE("REC_INVAUDIT_CAT_STORAGE_LBL", ": " + INVAUDIT_DGV.CELL.VALUE("REC_INVAUDIT_CAT_STORAGE_ID_DESCRIPTION", PROPERTY_EDIT_ROW_INDEX));

					EDIT_HANDLER.REF_IS_MODIFIED = false;
					JSOC_DIALOG.VAR_MODAL("INVAUDIT_MODAL", true);

					HTTP_LOAD();
					return;
				}
			}
		);



		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		// Requires Authentication
		// _______________________________________________________________________	
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			

		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_INVAUDIT_ACC_GROUP_ID_CMB") == true)
		{
		 	// Set Default Item, if used in DataGridView
		 	JSOC_CMB.VAR_ADD("REC_INVAUDIT_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");

		 	// To use custom populate
		 	JSCUS_SQL._ACCOUNT._GROUP.CUS_GET_THEN_POPULATE_COMBOBOX
		 	(
		 		function(IS_SUCCESS, RESPONSE_STRING)
		 		{
					if(IS_SUCCESS)
					{
						JSON_ACCOUNT_GROUP = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
					}
			
		 			// Set Default index
		 			JSOC_CMB.VAR_SELECTED_INDEX("REC_INVAUDIT_ACC_GROUP_ID_CMB", 0);

		 			// Clone to DGV Cell if ComboBox Exists
		 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVAUDIT_DGV_ROW_REC_INVAUDIT_ACC_GROUP_ID") == true)
		 			{
		 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("INVAUDIT_DGV_ROW_REC_INVAUDIT_ACC_GROUP_ID");
		 				DGV_ELEMENT_CHILD_INDEX = 0;

		 				while(DGV_ELEMENT_CHILD.length > DGV_ELEMENT_CHILD_INDEX)
		 				{
		 					if
		 					(
								DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].tagName == "SELECT" &&
		 						JSVC_STR.VAR_IS_BLANK(DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].id.toString())
		 					)
		 					{
		 						JSOC_ELEMENT.VAR_INNER_HTML
		 						(
		 							DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX], 
		 							JSOC_ELEMENT.VAR_INNER_HTML("REC_INVAUDIT_ACC_GROUP_ID_CMB")
		 						);
		 					}	

		 					DGV_ELEMENT_CHILD_INDEX ++;
		 				}
		 			}

		 			// Copy items to edit control
		 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_INVAUDIT_ACC_GROUP_ID_CMB") == true)
		 			{
		 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_INVAUDIT_ACC_GROUP_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_INVAUDIT_ACC_GROUP_ID_CMB"), true);
		 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_INVAUDIT_ACC_GROUP_ID_CMB", 0);
		 			}				

		 			// Update Modal Settings
		 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVAUDIT_MODAL") == true)
		 			{
		 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("INVAUDIT_MODAL");
		 			}

		 			// Forward populate complete event.
		 			HTTP_POPULATE_RESULT();		
		 		},
		 		"REC_INVAUDIT_ACC_GROUP_ID_CMB",
		 		true, 2
		 	);
		}


		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		

		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVAUDIT_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("INVAUDIT_MODAL");
		}

		
		// Load Parent Data (if Exists)
		// _______________________________________________________________________	
		HTTP_PARENT_LOAD();


		// Pre-Load Items (uncomment if no foreign key pre-fetch)
		// _______________________________________________________________________	
		if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
		{
			HTTP_SEARCH();
		}

		// Disable Dialogs
		// _______________________________________________________________________	
		CUS_SEND_DIALOG_TRY_DISMISS();
	}


	// ===============================================================
	// Populate Foreign Keys
	// ===============================================================
	function HTTP_POPULATE_RESULT(IS_SUCCESS, HTTP_RESPONSE)
	{
		// Disable Dialogs
		CUS_SEND_DIALOG_TRY_DISMISS();

		// Handle Error
		if(IS_SUCCESS === false)
		{
			alert("Unable to populate lists.");
		}
		else
		{
			if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
			{
			 	HTTP_SEARCH();
			}
		}
	}


	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_SEARCH(NEW_ITEM_ID, EDITED_ROW_INDEX)
	{
		// Optional Value
		NEW_ITEM_ID = JSVC_VAR.VAR_OPTIONAL(NEW_ITEM_ID, -1);
		EDITED_ROW_INDEX = JSVC_VAR.VAR_OPTIONAL(EDITED_ROW_INDEX, -1);

		// Parameter Validate
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(NEW_ITEM_ID, 'NEW_ITEM_ID', 'NUMERIC');
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(EDITED_ROW_INDEX, 'EDITED_ROW_INDEX', 'NUMERIC');

		// Actual Function
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVAUDIT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_REC_INVAUDIT_DATE_AUDIT_FROM', 
			JSVC_DATE.VAR_FORMAT
			(
				JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_INVAUDIT_DATE_AUDIT_FROM_DTP"), "YYYY-MM-DD"
			) + " 00:00:00"
		);
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_REC_INVAUDIT_DATE_AUDIT_TO', 
			JSVC_DATE.VAR_FORMAT
			(
				JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_INVAUDIT_DATE_AUDIT_TO_DTP"), "YYYY-MM-DD"
			) + " 23:59:59"
		);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVAUDIT_ACC_GROUP_ID', JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE('SEARCH_REC_INVAUDIT_ACC_GROUP_ID_CMB')));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVAUDIT_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_INVAUDIT_ID');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC');

		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		if(NEW_ITEM_ID < 0)
		{
			JSCUS_SQL._RECORD._INVAUDIT.CUS_GET
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 		
		}
		else
		{		
			GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVAUDIT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVAUDIT_ID', NEW_ITEM_ID);

			JSCUS_SQL._RECORD._INVAUDIT.CUS_GET
			(
				GET_MAP_ARRAY,
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Update Existing Row
					if(EDITED_ROW_INDEX >= 0)
					{
						HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, EDITED_ROW_INDEX);
					}

					// Add new item
					else
					{
						HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, 0);
					}
				},
				true
			); 		
		}
	}

	
	// ===============================================================
	// Request Search - PART.B
	// ===============================================================
	function HTTP_SEARCH_CALLBACK(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;
		}

		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			INVAUDIT_DGV.ROW.CLEAR();
			return;
		}

		// Populate DGV
		// _______________________________________________________________________
		INVAUDIT_DGV.POPULATE_FROM_QUERY
		(
			JSON_OBJECT, 
			'',
			false,
			false,
			1,
			[2, 1]
		);
		

		// For Applying CFormat
		// _______________________________________________________________________	

		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
		var ROW_INDEX = 0;


		// DateTime Format
		// _______________________________________________________________________	

		if(INVAUDIT_DGV.COLUMN.IS_EXISTS("REC_INVAUDIT_DATE_AUDIT"))
		{
			WEBTABLE_DATE = null;
			ROW_INDEX = 0;

			while(INVAUDIT_DGV.ROW.COUNT() > ROW_INDEX)
			{
				// Read Current Value
				// ...........................................
				WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
					(
						INVAUDIT_DGV.CELL.VALUE
						(
							"REC_INVAUDIT_DATE_AUDIT", 
							ROW_INDEX
						)
					);

				// Apply CFormat, and DateFormat
				// ...........................................
				if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
				{
					INVAUDIT_DGV.CELL.VALUE
					(
						"REC_INVAUDIT_DATE_AUDIT", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY hh:mm TT")
					);				
				}			

				// Color Coding (Uncomment to use)
				// ...........................................	
				//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
				//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
				//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
				//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning

				// To next loop
				// ...........................................	
				ROW_INDEX ++;
			}			
		}
	}

	
	// ===============================================================
	// Request Search - PART.C
	// ===============================================================
	function HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, ROW_INDEX)
	{

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

		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			INVAUDIT_DGV.ROW.CLEAR();
			return;
		}

		// Validate Row Count
		// _______________________________________________________________________	
		if(INVAUDIT_DGV.ROW.COUNT() <= 0)
		{
			console.error("DataGridView has no rows to fill.");
			return;
		}

		JSVC_AV.VAR_VALIDATE_RANGE(ROW_INDEX, "ROW_INDEX", 0, INVAUDIT_DGV.ROW.COUNT() - 1);

		// Populate DGV
		// _______________________________________________________________________
		INVAUDIT_DGV.POPULATE_FROM_QUERY
		(
			JSON_OBJECT, 
			'',
			false,
			false,
			1,
			[2, 1],
			ROW_INDEX
		);

		// For Applying CFormat
		// _______________________________________________________________________	

		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;

	
		// DateTime Format
		// _______________________________________________________________________	
		if(INVAUDIT_DGV.COLUMN.IS_EXISTS("REC_INVAUDIT_DATE_AUDIT"))
		{
			WEBTABLE_DATE = null;

			// Read Current Value
			// ...........................................
			WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				(
					INVAUDIT_DGV.CELL.VALUE
					(
						"REC_INVAUDIT_DATE_AUDIT", 
						ROW_INDEX
					)
				);

			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				INVAUDIT_DGV.CELL.VALUE
				(
					"REC_INVAUDIT_DATE_AUDIT", ROW_INDEX, 
					JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			

			// Color Coding (Uncomment to use)
			// ...........................................	
			//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//INVAUDIT_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}
	}

	function HTTP_STORAGE_LOCATION()
	{
		
	} 

	function HTTP_STORAGE() 
	{
		// Get Storage ID
		var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._STORAGE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

/*
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STORAGE_ACC_GROUP_ID', JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STORAGE_IS_STORE', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STORAGE_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'CAT_STORAGE_ID');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', 1);
*/

		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_CAT_STORAGE_ACC_GROUP_ID', 
			JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVAUDIT_ACC_GROUP_ID_CMB))
		);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STORAGE_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'CAT_STORAGE_DESCRIPTION');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', 1000);
		
		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;
						}
						else
						{
							// PROPERTY_REC_STORAGE_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_STORAGE_ID", 1);
							JSOC_CMB.VAR_ADD_FROM_JSON
							(
									"CAT_STORAGE_CMB", 
									HTTP_RESPONSE, 
									
									'CAT_STORAGE_ID', 
									'CAT_STORAGE_DESCRIPTION', 
									
									false, false
							);		
									
							// ~~~~~
							
							if(JSVC_NUM.VAR_NVALL(PROPERTY_REC_STORAGE_ID) > 0)
							{
								JSOC_ELEMENT.VAR_VALUE
								(
									'CAT_STORAGE_LBL', 
									JSOC_CMB.VAR_TEXT
									(
										'CAT_STORAGE_CMB', 
										JSOC_CMB.VAR_INDEX_OF_VALUE
										(
											'CAT_STORAGE_CMB',
											PROPERTY_REC_STORAGE_ID
										)
									)
								);	
							}

							CAT_STORAGE_CMB.onchange();
						}
					}
				};

		JSCUS_SQL._CATEGORY._STORAGE.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
	};


	function HTTP_BRANCH_PRODUCTS(GROUP_ID, STORAGE_ID) 
	{
		// Get Branch Products
		var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_ACC_GROUP_ID', GROUP_ID);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_CAT_PRICEMDL_ID', 1);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_STATUS', 2);

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'CAT_PRODUCT_DESCRIPTION');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC');

		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;
						}
						else
						{
							var INDEX = 1;
							PROPERTY_REC_BRANCH_PRODUCTS = [];
							
							while(JSON_OBJECT.JSON_COUNT >= INDEX)
							{
								// if
								// (
								// 	JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_IS_INVENTORY_ONLY", INDEX)) == 2 && 
								// 	JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_AMOUNT_PRICE", INDEX)) >= 0
								// )
								// {
								// 	PROPERTY_REC_BRANCH_PRODUCTS.push(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_ID", INDEX));
								// }

								// if(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_AMOUNT_PRICE", INDEX)) > 0)
								// {
								 	PROPERTY_REC_BRANCH_PRODUCTS.push(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_ID", INDEX));
								// }
								
								INDEX++;
							}
						}

						HTTP_NEW_LOAD
						(
							GROUP_ID, 
							STORAGE_ID,
							function(){}
						);
					}
				};

		JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
	};


	function HTTP_CALCULATE_DISCREPANCY(INPUT_ID)
	{
		var INDEX = INPUT_ID.replace("INVENTORY_AUDIT_LINE_DGV_REC_INVAUDIT_LINE_QUANTITY_ACTUAL_ELEMENT_", "");
		
		var ACTUAL_QTY = JSOC_ELEMENT.VAR_VALUE(INPUT_ID);
		var SYSTEM_QTY = INVENTORY_AUDIT_LINE_DGV.CELL.VALUE("REC_INVAUDIT_LINE_QUANTITY_SYSTEM", JSVC_NUM.VAR_NVALL(INDEX));
		var DISCREPANCY = 0;

		if(JSVC_STR.VAR_IS_BLANK(ACTUAL_QTY) == true)
			DISCREPANCY = SYSTEM_QTY;
		else
			DISCREPANCY = JSVC_NUM.VAR_NVAL(ACTUAL_QTY) - JSVC_NUM.VAR_NVAL(SYSTEM_QTY);
		
		INVENTORY_AUDIT_LINE_DGV.CELL.VALUE("DISCREPANCY", JSVC_NUM.VAR_NVALL(INDEX), DISCREPANCY);
	};

	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();