// 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
		// _______________________________________________________________________	
		JSTOOL_CUSTOMIZE.DGVREORDER.APPLY("INVENTORY_DGV");
		INVENTORY_DGV = DataGridView("INVENTORY_DGV");
		//INVENTORY_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//INVENTORY_DGV.SETTING_EDITABLE = true;
	

		// Auto Compute
		// _______________________________________________________________________	
		var AUTO_CALC = JSTOOL_CUSTOMIZE.DGVCALC.APPLY(INVENTORY_DGV);
		var AUTO_COMPUTE_BLOCKS = AUTO_CALC[0];
			
		/*
			// Sample Code
			AUTO_COMPUTE_BLOCKS.push
			(
				[
					'COLUMN_A', 					// Target Column
					'`COLUMN_1` + `COLUMN_2`',		// Math
					true							// Apply CFormat
				]
			);
		*/
		// INVENTORY_DGV.COLUMN.AUTO_COMPUTE_CREATE(AUTO_COMPUTE_BLOCKS);
		
		
		// Auto Total
		// _______________________________________________________________________	
		var AUTO_TOTAL_COLUMNS = AUTO_CALC[1];
		var AUTO_TOTAL_COPY_TO_ELEMENT = AUTO_CALC[2];
		
		/*
			AUTO_TOTAL_COLUMNS.push('COLUMN_A');					// Column to Auto Total
			AUTO_TOTAL_COPY_TO_ELEMENT.push(["COL_ID", "ELEM_ID"]);	// Source Column, Element ID where total is copied to
			
			AUTO_TOTAL_COLUMNS.push('REC_INVENTORY_QUANTITY');
		*/
		/*
		INVENTORY_DGV.COLUMN.TOTAL_CREATE
		(
			AUTO_TOTAL_COLUMNS,
			'REC_INVENTORY_ID',									// Column, where you want to display the caption `Total:`.
			AUTO_TOTAL_COPY_TO_ELEMENT
		);		
		*/
		
		
		INVENTORY_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Reset Data
				// ...........................................
				var RESET_DIALOG = function()
				{
					PROPERTY_REC_INVENTORY_ID = INVENTORY_DGV.CELL.VALUE('REC_INVENTORY_ID', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;			
					
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_INVENTORY_CAT_PRODUCT_ID_TXT", 
						INVENTORY_DGV.CELL.VALUE('REC_INVENTORY_CAT_PRODUCT_ID', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_INVENTORY_CAT_PRODUCT_DESCRIPTION_TXT", 
						INVENTORY_DGV.CELL.VALUE('CAT_PRODUCT_DESCRIPTION', ROW_INDEX)
					);	

					JSOC_CMB.VAR_SELECTED_VALUE
					(
						"POSITIVE_STOCKFLOW_CMB", 0
					);
					JSOC_CMB.VAR_SELECTED_INDEX
					(
						"NEGATIVE_STOCKFLOW_CMB", 0
					);

					JSOC_ELEMENT.VAR_VALUE
					(
						"BAG_QUANTITY_TXT", 0
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"CONTENT_QUANTITY_TXT", 0
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_INVENTORY_QUANTITY_TXT", 0
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"UOM_TXT", 
						INVENTORY_DGV.CELL.VALUE('CAT_UOM_DESCRIPTION', ROW_INDEX)
					);		
					JSOC_ELEMENT.VAR_VALUE
					(
						"BACKDATE_DTP", 'NULL'
					);	
					JSOC_ELEMENT.VAR_VALUE
					(
						"REMARKS_TXT", 
						""
					);	

					$('.BSSP_POSITIVE_STOCKFLOW_CMB').selectpicker('refresh');
					$('.BSSP_NEGATIVE_STOCKFLOW_CMB').selectpicker('refresh');

					POSITIVE_STOCKFLOW_CMB.onchange();
					HTTP_RELOAD_QTY
					(
						function()
						{
							JSOC_ELEMENT.VAR_VALUE
							(
								"PRICE_TXT", JSOC_ELEMENT.VAR_VALUE_NVAL("PRICE_ON_DATABASE_TXT")
							);
							CONTENT_QUANTITY_TXT.onchange();
							
							EDIT_HANDLER.REF_IS_MODIFIED = true;
							JSOC_DIALOG.VAR_MODAL("INVENTORY_MODAL", true);								
						}, false
					);
				};

				
				// Link to Child Table
				// ...........................................
				if(INVENTORY_DGV.COLUMN.NAME(COL_INDEX) == "PLUS_CMD")
				{
					RESET_DIALOG();	
					JSOC_ELEMENT.VAR_INNER_HTML('MODAL_TITLE_BTAG', 'Stock-In');
					JSOC_STYLE.VAR_DISPLAY("POSITIVE_STOCKFLOW_CMB_DLG_BLOCK", "DEFAULT");
					JSOC_STYLE.VAR_DISPLAY("NEGATIVE_STOCKFLOW_CMB_DLG_BLOCK", "NONE");
					PROPERTY_MODE_ID = 1;
				}
				else if(INVENTORY_DGV.COLUMN.NAME(COL_INDEX) == "MINUS_CMD")
				{
					RESET_DIALOG();
					JSOC_ELEMENT.VAR_INNER_HTML('MODAL_TITLE_BTAG', 'Stock-Out');
					JSOC_STYLE.VAR_DISPLAY("POSITIVE_STOCKFLOW_CMB_DLG_BLOCK", "NONE");
					JSOC_STYLE.VAR_DISPLAY("NEGATIVE_STOCKFLOW_CMB_DLG_BLOCK", "DEFAULT");
					PROPERTY_MODE_ID = 2;
				}
				else if(INVENTORY_DGV.COLUMN.NAME(COL_INDEX) == "ADJUST_CMD")
				{
					RESET_DIALOG();
					JSOC_ELEMENT.VAR_INNER_HTML('MODAL_TITLE_BTAG', 'Inventory Audit');
					JSOC_STYLE.VAR_DISPLAY("POSITIVE_STOCKFLOW_CMB_DLG_BLOCK", "NONE");
					JSOC_STYLE.VAR_DISPLAY("NEGATIVE_STOCKFLOW_CMB_DLG_BLOCK", "NONE");
					PROPERTY_MODE_ID = 3;
				}
			}
		);   

		
		// 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("POSITIVE_STOCKFLOW_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			// ...........................................
			JSOC_CMB.VAR_ADD("POSITIVE_STOCKFLOW_CMB", FLAG_BIGINT_NULL.toString(), "-");
			
			// To use custom populate
			// ...........................................
			var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_IS_IN', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_STATUS', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			
			JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("POSITIVE_STOCKFLOW_CMB", 0);
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVENTORY_MODAL") == true)
					{
						// INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("INVENTORY_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_POSITIVE_STOCKFLOW_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"POSITIVE_STOCKFLOW_CMB",
				true, 2, GET_MAP_ARRAY 
			);
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("NEGATIVE_STOCKFLOW_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			// ...........................................
			JSOC_CMB.VAR_ADD("NEGATIVE_STOCKFLOW_CMB", FLAG_BIGINT_NULL.toString(), "-");
			
			// To use custom populate
			// ...........................................
			var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_IS_IN', JSCUS_SQL._SYSTEM._STATUS.STATUS_INACTIVE);	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_STATUS', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			
			JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("NEGATIVE_STOCKFLOW_CMB", 0);
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVENTORY_MODAL") == true)
					{
						// INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("INVENTORY_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_NEGATIVE_STOCKFLOW_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"NEGATIVE_STOCKFLOW_CMB",
				true, 2, GET_MAP_ARRAY 
			);
		}		

		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVENTORY_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("INVENTORY_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_INVENTORY_ID_TXT"))
		{
			var SEARCH_REC_INVENTORY_ID_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_INVENTORY_ID_TXT");
			SEARCH_REC_INVENTORY_ID_TXT.onkeydown = 
				function() 
				{ 
					return function(e) 
					{
						if
						(
							(
								e.which == 13 || 
								e.keyCode == 13 || 
								e.key === "Enter"
							) &&
							JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_CMD")
						)
						{
							HTTP_SEARCH();
						}
					};
				}();
		}
		
		
		// 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
		{
			// Disable Dialogs
			if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
			{
				HTTP_SEARCH();
			}
		}
	};

	
	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_SEARCH()
	{
		// Actual Function
		// _______________________________________________________________________
		GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVENTORY_CUSTOM.CUS_PREPARE_MAPPED_ARRAY_FOR_RELATED();	

		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_CAT_UOM_ID_CMB', 'PARAM_CAT_PRODUCT_CAT_UOM_ID'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_BARCODE_TXT', 'PARAM_CAT_PRODUCT_BARCODE'
		);	
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_ITEMCODE_TXT', 'PARAM_CAT_PRODUCT_ITEMCODE'
		);	
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_DESCRIPTION_TXT', 'PARAM_CAT_PRODUCT_DESCRIPTION'
		);	
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_HAS_RECIPE_CMB', 'PARAM_CAT_PRODUCT_HAS_RECIPE'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_ING_PRICE_FROM_TXT', 'PARAM_CAT_PRODUCT_ING_PRICE_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_ING_PRICE_TO_TXT', 'PARAM_CAT_PRODUCT_ING_PRICE_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_ING_NET_CONTENT_FROM_TXT', 'PARAM_CAT_PRODUCT_ING_NET_CONTENT_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_ING_NET_CONTENT_TO_TXT', 'PARAM_CAT_PRODUCT_ING_NET_CONTENT_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_MIXTURE_QTY_FROM_TXT', 'PARAM_CAT_PRODUCT_MIXTURE_QTY_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_MIXTURE_QTY_TO_TXT', 'PARAM_CAT_PRODUCT_MIXTURE_QTY_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_STATUS_CMB', 'PARAM_CAT_PRODUCT_STATUS'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_CAT_PRODUCT_SYSTEM_GENERATED_TXT', 'PARAM_CAT_PRODUCT_SYSTEM_GENERATED'
		);
		
		
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_ORDER_BY_CMB', 'PARAM_ORDER_FIELD'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_LIMIT_CMB', 'PARAM_LIMIT'
		);						
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
			
			
		// REGULAR Search Mode
		// _______________________________________________________________________
		JSCUS_SQL._RECORD._INVENTORY_CUSTOM.CUS_RELATED
		(
			GET_MAP_ARRAY,
			HTTP_SEARCH_CALLBACK,
			true
		); 			

		
		// Update Paging Cache
		// _______________________________________________________________________
		INVENTORY_LAST_GET_MAP_ARRAY = GET_MAP_ARRAY;
	};
	
	
	// ===============================================================
	// Request Search - PART.A1
	// ===============================================================
	function HTTP_SEARCH_LOAD_MORE()
	{
		// Abort if no GET cache is found
		// _______________________________________________________________________		
		if(JSVC_VAR.VAR_ISSET(INVENTORY_LAST_GET_MAP_ARRAY) == false)
		{
			return;
		}
		
		// Update Paging row count
		// _______________________________________________________________________	
		INVENTORY_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = 
			JSVC_NUM.VAR_NVALL(INVENTORY_LAST_GET_MAP_ARRAY['PARAM_SKIP']) + 
			JSVC_NUM.VAR_NVALL(INVENTORY_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);	
			
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_LIMIT_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET
			(
				INVENTORY_LAST_GET_MAP_ARRAY,
				'PARAM_LIMIT', 
				JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_LIMIT_CMB")
			);		
		}
		
		
		// REGULAR Search Mode
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._INVENTORY_CUSTOM.CUS_RELATED
		(
			INVENTORY_LAST_GET_MAP_ARRAY,
			function (IS_SUCCESS, RESPONSE_STRING)
			{
				HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING, true);
			},
			true
		);
	}
	
	
	// ===============================================================
	// Request Search - PART.A2
	// ===============================================================
	function HTTP_SEARCH_LOAD_PAGE()
	{
		// Abort if no GET cache is found
		// _______________________________________________________________________		
		if
		(
			JSVC_VAR.VAR_ISSET(INVENTORY_LAST_GET_MAP_ARRAY) == false ||
			JSOC_CMB.VAR_SELECTED_INDEX("LOAD_PAGING_CMB") < 0
		)
		{
			return;
		}
		
		// Update Paging row count
		// _______________________________________________________________________
		INVENTORY_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = 
		JSVC_NUM.VAR_NVALL(INVENTORY_LAST_GET_MAP_ARRAY['PARAM_LIMIT']) *
		JSOC_CMB.VAR_SELECTED_INDEX("LOAD_PAGING_CMB");	
		
		// REGULAR Search Mode
		// _______________________________________________________________________
		LOAD_PAGING_IGNORE_NEXT_REQUEST = true;
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._INVENTORY_CUSTOM.CUS_RELATED
		(
			INVENTORY_LAST_GET_MAP_ARRAY,
			function (IS_SUCCESS, RESPONSE_STRING)
			{
				HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING, false);
			},
			true
		);
	}
	function HTTP_SEARCH_LOAD_PAGING_UPDATE(ROW_COUNT)
	{
		// Abort if no paging function enabled
		// _______________________________________________________________________
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("LOAD_PAGING_CMB") == false || LOAD_PAGING_IGNORE_NEXT_REQUEST == true)
		{
			LOAD_PAGING_IGNORE_NEXT_REQUEST = false;
			return;
		}
		
		// Initialize
		// _______________________________________________________________________
		var PAGING_INDEX = 0;
		var PAGING_COUNT = 
			ROW_COUNT / JSVC_NUM.VAR_NVALL(INVENTORY_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);
		PAGING_COUNT = Math.trunc(PAGING_COUNT) + 1;
		JSOC_CMB.VAR_CLEAR("LOAD_PAGING_CMB");
		
		// Populate Paging
		// _______________________________________________________________________
		while(PAGING_COUNT > PAGING_INDEX)
		{
			JSOC_CMB.VAR_ADD
			(
				"LOAD_PAGING_CMB", 
				(PAGING_INDEX + 1).toString(), 
				(PAGING_INDEX + 1).toString()
			);
			PAGING_INDEX ++;
		}
	}
	
	
	// ===============================================================
	// Request Search - PART.B
	// ===============================================================
	function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING, KEEP_DGV_ITEMS = false)
	{
		// 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
		// _______________________________________________________________________	
		if(LOAD_PAGING_IGNORE_NEXT_REQUEST == true)
		{
			JSOC_ELEMENT.VAR_GET("INVENTORY_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
		}
		
		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			HTTP_SEARCH_LOAD_PAGING_UPDATE(0);
			INVENTORY_DGV.ROW.CLEAR();
			if(INVENTORY_DGV.COLUMN.TOTAL_IS_READY())
			{
				INVENTORY_DGV.COLUMN.TOTAL_REFRESH();
			}
			return;
		}
		HTTP_SEARCH_LOAD_PAGING_UPDATE
		(
			JSVC_NUM.VAR_NVALL
			(
				JSRC_JSON.REF_READ(JSON_OBJECT, "RECORD_COUNT", 1)
			)
		);
		
		// Populate DGV
		// _______________________________________________________________________
		INVENTORY_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				KEEP_DGV_ITEMS,
				false,
				INVENTORY_LAST_GET_MAP_ARRAY['PARAM_SKIP'] + 1,
				[2, 1]
		);
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		INVENTORY_DGV.COLUMN.CFORMAT("REC_INVENTORY_QUANTITY");
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
		var CURRENT_CELL_VALUE = null;
		var ROW_INDEX = 0;
	
	
		// DateTime Format
		// _______________________________________________________________________	
		
		
		// Color Coding (Uncomment to use)
		// _______________________________________________________________________	
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning


		// Auto-total tool
		// _______________________________________________________________________	
		if(INVENTORY_DGV.COLUMN.TOTAL_IS_READY())
		{
			INVENTORY_DGV.COLUMN.TOTAL_REFRESH();
		}
	};
	
	
	// ===============================================================
	// 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)
		{
			INVENTORY_DGV.ROW.CLEAR();
			return;
		}

		// Validate Row Count
		// _______________________________________________________________________	
		if(INVENTORY_DGV.ROW.COUNT() <= 0)
		{
			console.error("DataGridView has no rows to fill.");
			return;
		}
		JSVC_AV.VAR_VALIDATE_RANGE(ROW_INDEX, "ROW_INDEX", 0, INVENTORY_DGV.ROW.COUNT() - 1);
		
		// Populate DGV
		// _______________________________________________________________________
		INVENTORY_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1],
				ROW_INDEX
		);
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		INVENTORY_DGV.COLUMN.CFORMAT("REC_INVENTORY_QUANTITY");
		
	
		// For Applying DateTime Format
		// _______________________________________________________________________	


		// Auto-total tool
		// _______________________________________________________________________	
		if(INVENTORY_DGV.COLUMN.TOTAL_IS_READY())
		{
			INVENTORY_DGV.COLUMN.TOTAL_REFRESH();
		}
		
		
		// Color Coding (Uncomment to use)
		// _______________________________________________________________________	
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#dc3545"; // Danger
		//INVENTORY_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#17a2b8"; // Info
	};
	
				
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();