// 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("PSOVERVIEW_DGV");
		PSOVERVIEW_DGV = DataGridView("PSOVERVIEW_DGV");
		//PSOVERVIEW_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//PSOVERVIEW_DGV.SETTING_EDITABLE = true;
	

		// Auto Compute
		// _______________________________________________________________________	
		var AUTO_CALC = JSTOOL_CUSTOMIZE.DGVCALC.APPLY(PSOVERVIEW_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
				]
			);
		*/

		/*
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_QTY_UNSERVED_ORDERS', 																	
				'`REC_PSOVERVIEW_QTY_REQUEST` - `REC_PSOVERVIEW_QTY_DELIVERY`', 
				true							
			]
		);
		*/
		/*
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_QTY_DELIVERY_TOTAL', 																	
				'`REC_PSOVERVIEW_QTY_DELIVERY` + `REC_PSOVERVIEW_QTY_DELIVERY_ON`', 
				true							
			]
		);		
		*/						
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('REC_EODPROD_QTY_BEGIN_CLONE01'))
		{
			AUTO_COMPUTE_BLOCKS.push
			(
				[
					'REC_EODPROD_QTY_BEGIN_CLONE01', 																	
					'`REC_EODPROD_QTY_BEGIN` - `REC_PSOVERVIEW_QTY_PRODUCE`', 
					true							
				]
			);
		}								
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_COST_PDATA_PPC', 																	
				'`REC_PSOVERVIEW_COST_PDATA` / (`REC_PSOVERVIEW_QTY_PRODUCE` + `REC_PSOVERVIEW_QTY_PRODUCE_ON`)', 
				true							
			]
		);										
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_SALES', 																	
				'`REC_PSOVERVIEW_PRICE` * `REC_PSOVERVIEW_QTY_DELIVERY`', 
				true							
			]
		);		
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_COST', 																	
				'`REC_PSOVERVIEW_COST_FDATA` * (`REC_PSOVERVIEW_MIX_PRODUCTION` + `REC_PSOVERVIEW_MIX_PRODUCTION_ON`)', 
				true							
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_COST_PPC', 																	
				'`REC_PSOVERVIEW_COST_FDATA` / `REC_PSOVERVIEW_QTY_YEILD`', 
				true							
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM', 																	
				'`REC_PSOVERVIEW_CALC_SALES` - `REC_PSOVERVIEW_CALC_COST`', 
				true							
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM_PPC', 																	
				'`REC_PSOVERVIEW_CALC_GM` / (`REC_PSOVERVIEW_QTY_PRODUCE` + `REC_PSOVERVIEW_QTY_PRODUCE_ON`)', 
				true							
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM_PERC', 																	
				'`REC_PSOVERVIEW_CALC_GM` / `TOTAL:REC_PSOVERVIEW_CALC_GM`', 
				true							
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM_ACT', 																	
				'`REC_PSOVERVIEW_CALC_SALES` - `REC_PSOVERVIEW_COST_PDATA`', 
				true							
			]
		);		
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM_ACT_PPC', 																	
				'`REC_PSOVERVIEW_CALC_GM_ACT` / (`REC_PSOVERVIEW_QTY_PRODUCE` + `REC_PSOVERVIEW_QTY_PRODUCE_ON`)', 
				true							
			]
		);	
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_CALC_GM_ACT_PERC', 																	
				'`REC_PSOVERVIEW_CALC_GM_ACT` / `TOTAL:REC_PSOVERVIEW_CALC_GM_ACT`', 
				true							
			]
		);	
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_PSOVERVIEW_COGS_PERC_CALC', 																	
				'`REC_PSOVERVIEW_COST_PDATA` / `REC_PSOVERVIEW_CALC_SALES`', 
				true							
			]
		);
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_DELIVERY"))
		{
			AUTO_COMPUTE_BLOCKS.push
			(
				[
					'DELIVERY', 																	
					'`REC_PSOVERVIEW_QTY_DELIVERY` - `REC_PSOVERVIEW_QTY_RETURN`', 
					true							
				]
			);			
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_UNSERVED_ORDER"))
		{
			AUTO_COMPUTE_BLOCKS.push
			(
				[
					'UNSERVED_ORDER', 																	
					'(`DELIVERY` + `REC_PSOVERVIEW_QTY_DELIVERY_ON`) - `REC_PSOVERVIEW_QTY_REQUEST`', 
					true							
				]
			);		
		}
		PSOVERVIEW_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_PSOVERVIEW_CNT_PRODUCTION');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CNT_PRODUCTION_ON');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_REQUEST');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_PRODUCE');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_PRODUCE_ON');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DELIVERY');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DELIVERY_ON');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DAMAGE');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_SNACK');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_YEILD');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_PRICE');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_COST_FDATA');
			
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_REQUEST');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_PRODUCTION');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_PRODUCTION_ON');
			AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_COGS_PERC');
		*/


		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_COST_PDATA');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_COST_FDATA');
		
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_COST_PDATA_PPC');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CNT_PRODUCTION');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CNT_PRODUCTION_ON');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_REQUEST');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_PRODUCTION');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_MIX_PRODUCTION_ON');
		
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_REQUEST');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_PRODUCE');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_PRODUCE_ON');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DELIVERY');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DELIVERY_ON');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DELIVERY_TOTAL');
		
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_SNACK');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_QTY_DAMAGE');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_SALES');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_COST');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_GM');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_GM_PPC');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_GM_ACT');
		AUTO_TOTAL_COLUMNS.push('REC_PSOVERVIEW_CALC_GM_ACT_PPC');
			
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_DELIVERY"))
		{
			AUTO_TOTAL_COLUMNS.push('DELIVERY');			
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_UNSERVED_ORDER"))
		{
			AUTO_TOTAL_COLUMNS.push('UNSERVED_ORDER');		
		}
		
		PSOVERVIEW_DGV.COLUMN.TOTAL_CREATE
		(
			AUTO_TOTAL_COLUMNS,
			'REC_PSOVERVIEW_DESCRIPTION',								
			AUTO_TOTAL_COPY_TO_ELEMENT
		);		
		
		
		// DGV OnClick Event
		// _______________________________________________________________________		
		PSOVERVIEW_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
			}
		);   


		// DGV OnChange Event
		// _______________________________________________________________________	
		PSOVERVIEW_DGV.ON_CHANGE
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Auto-Calculate tool
				// ...........................................
				// PSOVERVIEW_DGV.COLUMN.AUTO_COMPUTE_EXECUTE(ROW_INDEX);
				
				// Auto-total tool
				// ...........................................
				if(PSOVERVIEW_DGV.COLUMN.TOTAL_IS_READY())
				{
					PSOVERVIEW_DGV.COLUMN.TOTAL_REFRESH();
				}
			}
		);

		
		// DGV OnClick Event
		// _______________________________________________________________________	
		TRANS_LIST_SH_SETTINGS_DGV = DataGridView("TRANS_LIST_SH_SETTINGS_DGV");
					
		TRANS_LIST_SH_SETTINGS_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Delete Button
				if(TRANS_LIST_SH_SETTINGS_DGV.COLUMN.NAME(COL_INDEX) != "CHECK")
				{
					TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE
					(
						"CHECK", ROW_INDEX, 
						TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE("CHECK", ROW_INDEX) != true
					);
				}
			}
		);   	
		
		// DGV OnChange Event
		// _______________________________________________________________________	
		TRANS_LIST_SH_SETTINGS_DGV.ON_CHANGE
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				if(TRANS_LIST_SH_SETTINGS_DGV.COLUMN.NAME(COL_INDEX) == "CHECK")
				{
					if
					(
						TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE
						(
							"CHECK", ROW_INDEX
						)
					)
					{
						PSOVERVIEW_DGV.COLUMN.DISPLAY
						(
							TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE_NVALL("COLUMN_NAME", ROW_INDEX), "DEFAULT"
						);					
					}
					else
					{
						PSOVERVIEW_DGV.COLUMN.DISPLAY
						(
							TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE_NVALL("COLUMN_NAME", ROW_INDEX), "NONE"
						);						
					}
				}				
			}
		);
		POPULATE_SETTINGS();
		
		// 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_PSOVERVIEW_CAT_PRODUCT_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_ROW_REC_PSOVERVIEW_CAT_PRODUCT_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("PSOVERVIEW_DGV_ROW_REC_PSOVERVIEW_CAT_PRODUCT_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_PSOVERVIEW_CAT_PRODUCT_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Product");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", 0);
						$('.BSSP_SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("PSOVERVIEW_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Product");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		
		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("PSOVERVIEW_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_PSOVERVIEW_DESCRIPTION_TXT"))
		{
			var SEARCH_REC_PSOVERVIEW_DESCRIPTION_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_PSOVERVIEW_DESCRIPTION_TXT");
			SEARCH_REC_PSOVERVIEW_DESCRIPTION_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();
						}
					};
				}();
		}
		
		
		// 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
		{
			// Disable Dialogs
			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
		// _______________________________________________________________________
		GET_MAP_ARRAY = JSCUS_SQL._RECORD._PSOVERVIEW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		// if(JSVC_VAR.VAR_ISSET("PROPERTY_PARENT_ID"))
		// {
		//	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', PROPERTY_PARENT_ID);
		// }  // Parent ID Sample
		
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_CAT_PRODUCT_ID_CMB', 'PARAM_REC_PSOVERVIEW_CAT_PRODUCT_ID'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_DESCRIPTION_TXT', 'PARAM_REC_PSOVERVIEW_DESCRIPTION'
		);	
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_DATE_FROM_DTP', 'PARAM_REC_PSOVERVIEW_DATE_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_DATE_TO_DTP', 'PARAM_REC_PSOVERVIEW_DATE_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_CNT_PRODUCTION_FROM_TXT', 'PARAM_REC_PSOVERVIEW_CNT_PRODUCTION_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_CNT_PRODUCTION_TO_TXT', 'PARAM_REC_PSOVERVIEW_CNT_PRODUCTION_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_CNT_PRODUCTION_ON_FROM_TXT', 'PARAM_REC_PSOVERVIEW_CNT_PRODUCTION_ON_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_CNT_PRODUCTION_ON_TO_TXT', 'PARAM_REC_PSOVERVIEW_CNT_PRODUCTION_ON_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_REQUEST_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_REQUEST_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_REQUEST_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_REQUEST_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_PRODUCE_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_PRODUCE_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_PRODUCE_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_PRODUCE_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_PRODUCE_ON_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_PRODUCE_ON_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_PRODUCE_ON_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_PRODUCE_ON_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DELIVERY_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DELIVERY_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DELIVERY_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DELIVERY_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DELIVERY_ON_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DELIVERY_ON_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DELIVERY_ON_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DELIVERY_ON_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DAMAGE_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DAMAGE_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_DAMAGE_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_DAMAGE_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_SNACK_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_SNACK_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_SNACK_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_SNACK_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_YEILD_FROM_TXT', 'PARAM_REC_PSOVERVIEW_QTY_YEILD_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_QTY_YEILD_TO_TXT', 'PARAM_REC_PSOVERVIEW_QTY_YEILD_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_PRICE_FROM_TXT', 'PARAM_REC_PSOVERVIEW_PRICE_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_PRICE_TO_TXT', 'PARAM_REC_PSOVERVIEW_PRICE_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COST_FDATA_FROM_TXT', 'PARAM_REC_PSOVERVIEW_COST_FDATA_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COST_FDATA_TO_TXT', 'PARAM_REC_PSOVERVIEW_COST_FDATA_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COST_PDATA_FROM_TXT', 'PARAM_REC_PSOVERVIEW_COST_PDATA_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COST_PDATA_TO_TXT', 'PARAM_REC_PSOVERVIEW_COST_PDATA_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_REQUEST_FROM_TXT', 'PARAM_REC_PSOVERVIEW_MIX_REQUEST_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_REQUEST_TO_TXT', 'PARAM_REC_PSOVERVIEW_MIX_REQUEST_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_PRODUCTION_FROM_TXT', 'PARAM_REC_PSOVERVIEW_MIX_PRODUCTION_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_PRODUCTION_TO_TXT', 'PARAM_REC_PSOVERVIEW_MIX_PRODUCTION_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_PRODUCTION_ON_FROM_TXT', 'PARAM_REC_PSOVERVIEW_MIX_PRODUCTION_ON_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_MIX_PRODUCTION_ON_TO_TXT', 'PARAM_REC_PSOVERVIEW_MIX_PRODUCTION_ON_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COGS_PERC_FROM_TXT', 'PARAM_REC_PSOVERVIEW_COGS_PERC_FROM'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_COGS_PERC_TO_TXT', 'PARAM_REC_PSOVERVIEW_COGS_PERC_TO'
		);
		JSCUS_SQL._ADD_FROM
		(
			GET_MAP_ARRAY, 'SEARCH_REC_PSOVERVIEW_STATUS_CMB', 'PARAM_REC_PSOVERVIEW_STATUS'
		);
		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'
		);		
		
		var SELECTED_SEARCH_MODE = 0;
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_MODE_CMB") == true)
		{
			SELECTED_SEARCH_MODE = JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_MODE_CMB"));		
		}						
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Search Inserted / Saved Record
		// _______________________________________________________________________
		if(NEW_ITEM_ID >= 0)
		{
			GET_MAP_ARRAY = JSCUS_SQL._RECORD._PSOVERVIEW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PSOVERVIEW_ID', NEW_ITEM_ID);
			
			JSCUS_SQL._RECORD._PSOVERVIEW.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
			); 			
		}
			
			
		// REGULAR Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 0)
		{			
			JSCUS_SQL._RECORD._PSOVERVIEW.CUS_GET
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 			
       	}
		
		
		// LITE Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 1)
		{
			JSCUS_SQL._RECORD._PSOVERVIEW.CUS_GET_LITE
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 				
		}
		
		
		// ALL Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 2)
		{
			JSCUS_SQL._RECORD._PSOVERVIEW.CUS_GET_ALL
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 							
		}
		
		
		// Update Paging Cache
		// _______________________________________________________________________
		if(NEW_ITEM_ID <= 0)
		{
			PSOVERVIEW_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(PSOVERVIEW_LAST_GET_MAP_ARRAY) == false)
		{
			return;
		}
		
		// Update Paging row count
		// _______________________________________________________________________	
		PSOVERVIEW_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = 
			JSVC_NUM.VAR_NVALL(PSOVERVIEW_LAST_GET_MAP_ARRAY['PARAM_SKIP']) + 
			JSVC_NUM.VAR_NVALL(PSOVERVIEW_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);	
			
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_LIMIT_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET
			(
				PSOVERVIEW_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._PSOVERVIEW.CUS_GET
		(
			PSOVERVIEW_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(PSOVERVIEW_LAST_GET_MAP_ARRAY) == false ||
			JSOC_CMB.VAR_SELECTED_INDEX("LOAD_PAGING_CMB") < 0
		)
		{
			return;
		}
		
		// Update Paging row count
		// _______________________________________________________________________
		PSOVERVIEW_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = 
		JSVC_NUM.VAR_NVALL(PSOVERVIEW_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._PSOVERVIEW.CUS_GET
		(
			PSOVERVIEW_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(PSOVERVIEW_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("PSOVERVIEW_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);
			PSOVERVIEW_DGV.ROW.CLEAR();
			if(PSOVERVIEW_DGV.COLUMN.TOTAL_IS_READY())
			{
				PSOVERVIEW_DGV.COLUMN.TOTAL_REFRESH();
			}
			return;
		}
		HTTP_SEARCH_LOAD_PAGING_UPDATE
		(
			JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "RECORD_COUNT", 1)
		);
		
		// Populate DGV
		// _______________________________________________________________________
		PSOVERVIEW_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				KEEP_DGV_ITEMS,
				false,
				PSOVERVIEW_LAST_GET_MAP_ARRAY['PARAM_SKIP'] + 1,
				[2, 1]
		);
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
		var CURRENT_CELL_VALUE = null;
		var ROW_COUNT = PSOVERVIEW_DGV.ROW.COUNT();
		var ROW_INDEX = 0;
		

			while(ROW_COUNT > ROW_INDEX)
			{
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_DELIVERY"))
				{	
					PSOVERVIEW_DGV.CELL.VALUE_NVAL
					(
						'DELIVERY', ROW_INDEX,
						PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY', ROW_INDEX) +
						PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY_ON', ROW_INDEX)
					);
				}
				
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_REC_PSOVERVIEW_QTY_UNSERVED_ORDERS"))
				{			
					if(PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY', ROW_INDEX) > 0)
					{
						PSOVERVIEW_DGV.CELL.VALUE
						(
							'REC_PSOVERVIEW_QTY_UNSERVED_ORDERS', ROW_INDEX,
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_REQUEST', ROW_INDEX) - 
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY', ROW_INDEX) 
						);
					}
					else
					{
						PSOVERVIEW_DGV.CELL.VALUE
						(
							'REC_PSOVERVIEW_QTY_UNSERVED_ORDERS', ROW_INDEX,
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_REQUEST', ROW_INDEX) - 
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY_ON', ROW_INDEX) 
						);
					}

					// ~~~~~
				
					if(PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_UNSERVED_ORDERS', ROW_INDEX) <= 0)
					{
						PSOVERVIEW_DGV.CELL.VALUE('REC_PSOVERVIEW_QTY_UNSERVED_ORDERS', ROW_INDEX, 0); 
					}
				}
				
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_REC_PSOVERVIEW_PRODUCE_VS_DELIVERY_PENDING"))
				{
					PSOVERVIEW_DGV.CELL.VALUE
					(
						'REC_PSOVERVIEW_PRODUCE_VS_DELIVERY_PENDING', ROW_INDEX, JSVC_NUM.VAR_CFORMAT
						(
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_PRODUCE', ROW_INDEX) - 
							PSOVERVIEW_DGV.CELL.VALUE_NVAL('REC_PSOVERVIEW_QTY_DELIVERY', ROW_INDEX) 
						)
					);
				}
				
				ROW_INDEX ++;
			}
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_REC_PSOVERVIEW_QTY_UNSERVED_ORDERS"))
			{		
				PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_UNSERVED_ORDERS");
			}
			
		// For Applying CFormat
		// _______________________________________________________________________	
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_REQUEST");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_PRODUCE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_PRODUCE_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DELIVERY");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DELIVERY_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DAMAGE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_SNACK");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_YEILD");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_PRICE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COST_FDATA");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COST_PDATA");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_REQUEST");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_PRODUCTION");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_PRODUCTION_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COGS_PERC");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COGS_PERC");
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PSOVERVIEW_DGV_HEADER_DELIVERY"))
		{
			PSOVERVIEW_DGV.COLUMN.CFORMAT("DELIVERY");	
		}
		
		// Color Coding (Uncomment to use)
		// _______________________________________________________________________	
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning


		// Auto-total tool
		// _______________________________________________________________________	
		if(PSOVERVIEW_DGV.COLUMN.TOTAL_IS_READY())
		{
			PSOVERVIEW_DGV.COLUMN.TOTAL_REFRESH();
		}

		// Freeze Column
		// _______________________________________________________________________	
		console.log($('#PSOVERVIEW_DGV').hasClass('tbl-colfix'))
		if($('#PSOVERVIEW_DGV').hasClass('tbl-colfix'))
		{
			COL_FIXED_ACTIVATE();
		}
	};
	
	
	// ===============================================================
	// 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)
		{
			PSOVERVIEW_DGV.ROW.CLEAR();
			return;
		}

		// Validate Row Count
		// _______________________________________________________________________	
		if(PSOVERVIEW_DGV.ROW.COUNT() <= 0)
		{
			console.error("DataGridView has no rows to fill.");
			return;
		}
		JSVC_AV.VAR_VALIDATE_RANGE(ROW_INDEX, "ROW_INDEX", 0, PSOVERVIEW_DGV.ROW.COUNT() - 1);
		
		// Populate DGV
		// _______________________________________________________________________
		PSOVERVIEW_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1],
				ROW_INDEX
		);
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_REQUEST");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_PRODUCE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_PRODUCE_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DELIVERY");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DELIVERY_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_DAMAGE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_SNACK");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_QTY_YEILD");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_PRICE");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COST_FDATA");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COST_PDATA");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_REQUEST");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_PRODUCTION");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_MIX_PRODUCTION_ON");
		PSOVERVIEW_DGV.COLUMN.CFORMAT("REC_PSOVERVIEW_COGS_PERC");
		
	
		// For Applying DateTime Format
		// _______________________________________________________________________	
		if(PSOVERVIEW_DGV.COLUMN.IS_EXISTS("REC_PSOVERVIEW_DATE"))
		{
			PSOVERVIEW_DGV.COLUMN.DATE_FORMAT("REC_PSOVERVIEW_DATE", "MMM DD, YYYY");
		}


		// Auto-total tool
		// _______________________________________________________________________	
		if(PSOVERVIEW_DGV.COLUMN.TOTAL_IS_READY())
		{
			PSOVERVIEW_DGV.COLUMN.TOTAL_REFRESH();
		}
		
		
		// Color Coding (Uncomment to use)
		// _______________________________________________________________________	
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#dc3545"; // Danger
		//PSOVERVIEW_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#17a2b8"; // Info
	};
	
	
	// ===============================================================
	// Populate ShowHide Settings
	// ===============================================================
	function POPULATE_SETTINGS()
	{
		// Initialize
		// _______________________________________________________________________	
		var COLUMN_COUNT = PSOVERVIEW_DGV.COLUMN.COUNT();
		var COLUMN_INDEX = 0;
		var ROW_INDEX = 0;
		
		// Populate Settings
		// _______________________________________________________________________	
		while(COLUMN_COUNT > COLUMN_INDEX)
		{
			if
			(
				JSOC_STYLE.VAR_IS_VISIBLE
				(
					PSOVERVIEW_DGV.COLUMN.HEADER_ITEM(COLUMN_INDEX)
				)
			)
			{
				TRANS_LIST_SH_SETTINGS_DGV.ROW.ADD();
				ROW_INDEX = TRANS_LIST_SH_SETTINGS_DGV.ROW.COUNT() - 1;
				
				TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE("CHECK", ROW_INDEX, true);
				TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE
				(
					"COLUMN_NAME", ROW_INDEX, COLUMN_INDEX
				);
				TRANS_LIST_SH_SETTINGS_DGV.CELL.VALUE
				(
					"COLUMN_CAPTION", ROW_INDEX, 
					JSOC_ELEMENT.VAR_VALUE(PSOVERVIEW_DGV.COLUMN.HEADER_ITEM(COLUMN_INDEX))
				);
			}
			COLUMN_INDEX ++;
		}
	};
		
				
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();