// NOTE: [This JS must loaded as last item]
var PROPERTY_REC_CHLDCOLLECT_ID = 0;
var PROPERTY_CURRENT_POSDEVICE_ID = 2;
var PROPERTY_CURRENT_POSDEVICE_ACCOUNT_GROUP_ID = 6;

	// ===============================================================
	// Initialize Form
	// ===============================================================
	function FORM_LOAD()
	{
		// Initialize
		// _______________________________________________________________________	
		var DGV_ELEMENT_CHILD = null;
		var DGV_ELEMENT_CHILD_INDEX = 0;
		
		
		// Load DataGridVuew
		// _______________________________________________________________________	
		EOD_ZREADING_DGV = DataGridView("EOD_ZREADING_DGV");
		//EOD_ZREADING_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//EOD_ZREADING_DGV.SETTING_EDITABLE = true;
		EOD_ZREADING_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Payment Collection Button
				// ...........................................
				if(EOD_ZREADING_DGV.COLUMN.NAME(COL_INDEX) == "PAY_BBI")
				{
					// Clear collection modal
					JSOC_ELEMENT.VAR_VALUE("REC_CHLDCOLLECT_REC_POSDEVICE_ID_TXT", PROPERTY_CURRENT_POSDEVICE_ID);
					JSOC_ELEMENT.VAR_VALUE("REC_CHLDCOLLECT_ACC_LINKSVR_ID_TXT", EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_ID', ROW_INDEX));
					JSOC_ELEMENT.VAR_VALUE("REC_CHLDCOLLECT_LINKSVR_ACC_GROUP_ID_TXT", EOD_ZREADING_DGV.CELL.VALUE('ACC_GROUP_ID', ROW_INDEX));
					JSOC_ELEMENT.VAR_VALUE("REC_CHLDCOLLECT_DESCRIPTION_TXT", EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_DESCRIPTION', ROW_INDEX));	
					JSOC_ELEMENT.VAR_VALUE("REC_CHLDCOLLECT_LINKSVR_DATE_DTP", EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_DATE', ROW_INDEX));
					
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_CHLDCOLLECT_AMOUNT_TXT", 
						JSVC_NUM.VAR_NVAL(EOD_ZREADING_DGV.CELL.VALUE('REC_POSSALE_PAID', ROW_INDEX)) -
						JSVC_NUM.VAR_NVAL(EOD_ZREADING_DGV.CELL.VALUE('REC_CHLDCOLLECT_AMOUNT', ROW_INDEX))
					);
					
					
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_BANK_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_BANK', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_CARD_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_CARD', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_CASH_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_CASH', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_CHECK_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_CHECK', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_LOYALTY_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_LOYALTY', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_VOUCHER_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_VOUCHER', ROW_INDEX)
					);
					JSOC_ELEMENT.VAR_VALUE
					(
						"REC_EODREP_ZREAD_PAID_OTHER_TXT", 
						EOD_ZREADING_DGV.CELL.VALUE('REC_EODREP_ZREAD_PAID_OTHER', ROW_INDEX)
					);
			

					// Display Modal
					PROPERTY_REC_CHLDCOLLECT_ID = 0;
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;
					
					EDIT_HANDLER.REF_IS_MODIFIED = false;
					JSOC_DIALOG.VAR_MODAL("CHILD_COLLECTION_MODAL", true);
					return;
				}		
			}
		);   

		
		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Requires Authentication
		// _______________________________________________________________________	
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			
		JSCUS_SQL._RECORD._POSDEVICE.CUS_ME(HTTP_POPULATE_RESULT);

		
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_EODREP_ZREAD_REC_EODREP_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_EODREP_ZREAD_REC_EODREP_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._EOD_CSREP.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._RECORD._EOD_CSREP.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function()
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_EODREP_ZREAD_REC_EODREP_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("EOD_ZREADING_DGV_ROW_REC_EODREP_ZREAD_REC_EODREP_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("EOD_ZREADING_DGV_ROW_REC_EODREP_ZREAD_REC_EODREP_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_EODREP_ZREAD_REC_EODREP_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Eod_Csrep");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_EODREP_ZREAD_REC_EODREP_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB", 0);
						$('.BSSP_SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("EOD_ZREADING_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("EOD_ZREADING_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_EODREP_ZREAD_REC_EODREP_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_EODREP_ZREAD_REC_EODREP_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_EODREP_ZREAD_REC_EODREP_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Eod_Csrep");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._EOD_CSREP.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._RECORD._EOD_CSREP.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function()
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_EODREP_ZREAD_REC_EODREP_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		// Status		
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_EODREP_ZREAD_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_EODREP_ZREAD_STATUS_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "0","Any Status");
			JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "1","Inactive");
			JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "2","Active");
			// JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "3","Closed");
			// JSOC_CMB.VAR_ADD("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "4","Completed");
			JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_EODREP_ZREAD_STATUS_CMB", "2");
		}			
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_EODREP_ZREAD_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("REC_EODREP_ZREAD_STATUS_CMB");
			JSOC_CMB.VAR_ADD("REC_EODREP_ZREAD_STATUS_CMB", "1","Inactive");
			JSOC_CMB.VAR_ADD("REC_EODREP_ZREAD_STATUS_CMB", "2","Active");
			// JSOC_CMB.VAR_ADD("REC_EODREP_ZREAD_STATUS_CMB", "3","Closed");
			// JSOC_CMB.VAR_ADD("REC_EODREP_ZREAD_STATUS_CMB", "4","Completed");
			JSOC_CMB.VAR_SELECTED_VALUE("REC_EODREP_ZREAD_STATUS_CMB", "2");
		}
		
		
		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("EOD_ZREADING_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("EOD_ZREADING_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_EODREP_ZREAD_CODE_TXT"))
		{
			var SEARCH_REC_EODREP_ZREAD_CODE_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_EODREP_ZREAD_CODE_TXT");
			SEARCH_REC_EODREP_ZREAD_CODE_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
		{
			// Load device info
			if(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID > 0)
			{
				PROPERTY_CURRENT_POSDEVICE_ID = JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID;
				PROPERTY_CURRENT_POSDEVICE_ACCOUNT_GROUP_ID = JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID;						
			}

			// Disable Dialogs
			if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
			{
				HTTP_SEARCH();
			}
		}
	}

	
	// ===============================================================
	// Request Search - PART.1
	// ===============================================================
	function HTTP_SEARCH()
	{
		// Actual Function
		GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._LINKSVR.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_ACC_GROUP_ID', JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_AUTH_LEVEL', 1);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_IS_SELF', 1);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_STATUS', 2);
		
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);	
		JSCUS_SQL._ACCOUNT._LINKSVR.CUS_GET
		(
			GET_MAP_ARRAY,
			HTTP_SEARCH_CALLBACK,
			true
		); 
	};
	
	
	// ===============================================================
	// Request Search - PART.2
	// ===============================================================
	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)
		{
			EOD_ZREADING_DGV.ROW.CLEAR();
			return;
		}

		// Populate DGV
		// _______________________________________________________________________
		EOD_ZREADING_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1]
		);
		
		
		// Initialize
		// _______________________________________________________________________	
		HTTP_SEARCH_GROUP(0);
	};

	
	// =================================================================================

	
	function HTTP_SEARCH_GROUP(ROW_INDEX)
	{
		// Abort if exceeds the row count
		// ...........................................
		if(EOD_ZREADING_DGV.ROW.COUNT() <= ROW_INDEX)
		{
			CUS_SEND_DIALOG_TRY_DISMISS();
			return;
		}
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		// Actual Function
		// ...........................................
		GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._GROUP.CUS_PREPARE_MAPPED_ARRAY_FOR_LINKSVR();	
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_ID', 
			EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_ID', ROW_INDEX)
		);

		// Send Request
		// ...........................................
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);	
		JSCUS_SQL._ACCOUNT._GROUP.CUS_LINKSVR_GET
		(
			GET_MAP_ARRAY,
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				HTTP_SEARCH_GROUP_CALLBACK(IS_SUCCESS, RESPONSE_STRING, ROW_INDEX);
			},
			true
		); 		
	};
	
	
	/**
	 * Report populate : PART 3.B
	 */
	function HTTP_SEARCH_GROUP_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);
			CUS_SEND_DIALOG_TRY_DISMISS();
			return;
		}
		
			
		// Validate JSON Response
		// _______________________________________________________________________
		var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
		var JSON_INDEX = 1;
		if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
		{
			console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
			CUS_SEND_DIALOG_TRY_DISMISS();
			return;
		}		

		
		// Get original cache
		// _______________________________________________________________________
		var JSON_COUNT = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT"));
		var TEMP_ACC_LINKSVR_ID = EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_ID', ROW_INDEX);
		var TEMP_ACC_LINKSVR_DESCRIPTION = EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_DESCRIPTION', ROW_INDEX);
		var SUPORTED_BRANCH_ID = EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_BRANCH_ID', ROW_INDEX);
		var PROCESSED_LINES = 0;
		
		// Populate Branch
		// _______________________________________________________________________
		while(JSON_COUNT >= JSON_INDEX)
		{
			// Check if branch is supported
			// ...........................................
			if
			(
				JSVC_STR.VAR_CONTAINS
				(
					SUPORTED_BRANCH_ID,
					'[' + JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_GROUP_ID", JSON_INDEX) + ']'
				) == false
			)
			{
				JSON_INDEX ++;
				continue;
			}
			
			// Add new line for multiple branch server
			// ...........................................
			if(PROCESSED_LINES > 0)
			{
				EOD_ZREADING_DGV.ROW.ADD(ROW_INDEX + PROCESSED_LINES);
				EOD_ZREADING_DGV.CELL.VALUE
				(
					'ACC_LINKSVR_ID', ROW_INDEX + PROCESSED_LINES, 
					TEMP_ACC_LINKSVR_ID
				);
			}
			
			// Update Branch ID
			// ...........................................
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'ACC_GROUP_ID', ROW_INDEX + PROCESSED_LINES, 
				JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_GROUP_ID", JSON_INDEX)
			);
			
			// Update Server description
			// ...........................................
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'ACC_LINKSVR_DESCRIPTION', ROW_INDEX + PROCESSED_LINES, 
				JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_GROUP_DESCRIPTION", JSON_INDEX)
			);
			
			PROCESSED_LINES ++;
			JSON_INDEX ++;
		}		
		
		
		// To next row
		// _______________________________________________________________________
		ROW_INDEX = ROW_INDEX + (JSON_INDEX - 1);
		if(EOD_ZREADING_DGV.ROW.COUNT() > ROW_INDEX)
		{
			HTTP_SEARCH_GROUP(ROW_INDEX);
			return;
		}
		else
		{
			EOD_ZREADING_DGV.ROW.REFRESH_ROW_COUNT();
		}
	};	
	
	
	// =================================================================================
	
	
	/**
	 * Report populate : PART 3.A
	 */
	function HTTP_SEARCH_ZREADING_ESTIMATE(ROW_INDEX)
	{
		// Abort if exceeds the row count
		// ...........................................
		if(EOD_ZREADING_DGV.ROW.COUNT() <= ROW_INDEX)
		{
			HTTP_SEARCH_COLLECTION()
			return;
		}
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		// Initialize
		// ...........................................
		var FILTER_DATE = JSVC_DATE.VAR_FORMAT
		(
			JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
			'YYYY-MM-DD'
		);
		
		// Actual Function
		// ...........................................
		GET_MAP_ARRAY = JSCUS_SQL._RECORD._EOD_ZREADING.CUS_PREPARE_MAPPED_ARRAY_FOR_LINKSVR();	
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_ACC_LINKSVR_ID', 
			EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_ID', ROW_INDEX)
		);
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_REC_EODREP_ACC_GROUP_ID', 
			EOD_ZREADING_DGV.CELL.VALUE('ACC_GROUP_ID', ROW_INDEX)
		);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_EODREP_ZREAD_DATE_FROM', FILTER_DATE + ' 00:00:00.000000');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_EODREP_ZREAD_DATE_TO', FILTER_DATE + ' 23:59:59.999999');
				
		// Send Request
		// ...........................................
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);	
		JSCUS_SQL._RECORD._EOD_ZREADING.CUS_LINKSVR_ESTIMATE
		(
			GET_MAP_ARRAY,
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				HTTP_SEARCH_ZREADING_ESTIMATE_CALLBACK(IS_SUCCESS, RESPONSE_STRING, ROW_INDEX);
			},
			true
		); 		
	};	
	
	
	/**
	 * Report populate : PART 3.B
	 */
	function HTTP_SEARCH_ZREADING_ESTIMATE_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);
			CUS_SEND_DIALOG_TRY_DISMISS();
			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);
			CUS_SEND_DIALOG_TRY_DISMISS();
			return;
		}
		
	
		// Populate default value
		// _______________________________________________________________________
		EOD_ZREADING_DGV.CELL.VALUE
		(
			'REC_POSSALE_TOPAY', ROW_INDEX, '0.00'
		);
		EOD_ZREADING_DGV.CELL.VALUE
		(
			'REC_POSSALE_PAID', ROW_INDEX, '0.00'
		);		
		EOD_ZREADING_DGV.CELL.VALUE
		(
			'REC_CHLDCOLLECT_AMOUNT',  ROW_INDEX, '0.00'
		);
		EOD_ZREADING_DGV.CELL.VALUE
		(
			'REC_EODREP_ZREAD_DATE', ROW_INDEX, 
			JSVC_DATE.VAR_FORMAT
			(
				JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
				'MMM DD, YYYY'
			) + ' 12:00 AM'
		);	
		EOD_ZREADING_DGV.CELL.VALUE
		(
			'STATUS', ROW_INDEX, 'No Data'
		);	
		EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, '-');
			
		
		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT")) <= 0)
		{
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_TOPAY', ROW_INDEX, '0.00'
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_PAID', ROW_INDEX, '0.00'
			);		
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_CHLDCOLLECT_AMOUNT',  ROW_INDEX, '0.00'
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_DATE', ROW_INDEX, 
				JSVC_DATE.VAR_FORMAT
				(
					JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
					'MMM DD, YYYY'
				) + ' 12:00 AM'
			);	
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'STATUS', ROW_INDEX, 'No Data'
			);	
			EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, '-');
			EOD_ZREADING_DGV.ROW.ELEMENT(ROW_INDEX).style.color = "#5a5c69";
		
			HTTP_SEARCH_ZREADING_ESTIMATE(ROW_INDEX + 1);
			return;
		}
		
		
		// Compute Total
		// _______________________________________________________________________		
		var JSON_COUNT = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT"));
		var JSON_INDEX = 1;
		var CURRENT_TOPAY = 0;	
		var CURRENT_PAID = 0;
		var CURRENT_DATE = null;
		
		var CURRENT_BANK = 0;
		var CURRENT_CARD = 0;
		var CURRENT_CASH = 0;
		var CURRENT_CHECK = 0;
		var CURRENT_LOYALTY = 0;
		var CURRENT_VOUCHER = 0;
		var CURRENT_OTHER = 0;
		
		
		// DATA MODE : 1 [Z-READING]
		// _______________________________________________________________________	
		if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "DATA_MODE", 1)) == 1)
		{
			// Compute Sum
			while(JSON_COUNT >= JSON_INDEX)
			{
				// Get Date
				// ...........................................
				if(JSVC_VAR.VAR_ISSET(CURRENT_DATE) == false)
				{
					CURRENT_DATE = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_DATE", JSON_INDEX);
				}
				
				// Compute total sales
				// ...........................................
				CURRENT_TOPAY = CURRENT_TOPAY + JSVC_NUM.VAR_NVALL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_SALE_SUBTOTAL", JSON_INDEX)
				) -
				(
					JSVC_NUM.VAR_NVALL
					(
						JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_SALE_DISCOUNT", JSON_INDEX)
					) +
					JSVC_NUM.VAR_NVALL
					(
						JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_SALE_RETURN", JSON_INDEX)
					)
				);
				
				// Compute total paid
				// ...........................................
				CURRENT_BANK += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_BANK", JSON_INDEX)
				);
				CURRENT_CARD += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_CARD", JSON_INDEX)
				);
				CURRENT_CASH += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_CASH", JSON_INDEX)
				) ;
				CURRENT_CHECK += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_CHECK", JSON_INDEX)
				);
				CURRENT_LOYALTY += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_LOYALTY", JSON_INDEX)
				);
				CURRENT_VOUCHER += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_VOUCHER", JSON_INDEX)
				);
				CURRENT_OTHER += JSVC_NUM.VAR_NVAL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EODREP_ZREAD_PAID_OTHER", JSON_INDEX)
				);
		
				CURRENT_PAID += 
					CURRENT_BANK +
					CURRENT_CASH +
	 				CURRENT_CARD +			
	 				CURRENT_CHECK +	
					CURRENT_LOYALTY +	
					CURRENT_VOUCHER +	
					CURRENT_OTHER;
				
				// Next loop
				// ...........................................
				JSON_INDEX ++;
			}
			
			// ~~~~~
			
			// Apply Value
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_TOPAY',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_TOPAY)
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_PAID',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_PAID)
			);
			
			// ~~~~~
			
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_BANK',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_BANK)
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_CARD',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_CARD)
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_CASH',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_CASH)
			);			
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_CHECK',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_CHECK)
			);	
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_LOYALTY',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_LOYALTY)
			);	
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_OTHER',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_VOUCHER)
			);	
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_PAID_VOUCHER',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_OTHER)
			);	
																				
			// ~~~~~
			
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_DATE', ROW_INDEX, 
				JSVC_DATE.VAR_FORMAT
				(
					JSVC_DATE.VAR_TO_DATE(CURRENT_DATE), 
					'MMM DD, YYYY hh:mm TT'
				)
			);	
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'STATUS', ROW_INDEX,
				'Z-Reading'
			);				
			EOD_ZREADING_DGV.ROW.ELEMENT(ROW_INDEX).style.color = "#17a2b8";			
		}
		
		
		// DATA MODE : 2 [Estimate]
		// _______________________________________________________________________	
		else
		{
			// Compute Sum
			while(JSON_COUNT >= JSON_INDEX)
			{
				// Compute total sales
				// ...........................................
				CURRENT_TOPAY = CURRENT_TOPAY + JSVC_NUM.VAR_NVALL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_TOPAY_COMPUTE", JSON_INDEX)
				);
				
				// Compute total paid
				// ...........................................
				CURRENT_PAID = CURRENT_PAID + JSVC_NUM.VAR_NVALL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_PAID_COMPUTE", JSON_INDEX)
				);
				
				// Next loop
				// ...........................................
				JSON_INDEX ++;
			}
					
			// ~~~~~
			
			// Apply Value
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_TOPAY',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_TOPAY)
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_POSSALE_PAID',
				ROW_INDEX,
				JSVC_NUM.VAR_CFORMAT(CURRENT_PAID)
			);
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'REC_EODREP_ZREAD_DATE', ROW_INDEX, 
				JSVC_DATE.VAR_FORMAT
				(
					JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
					'MMM DD, YYYY'
				) + ' 11:59 PM'
			);			
			EOD_ZREADING_DGV.CELL.VALUE
			(
				'STATUS', ROW_INDEX,
				'Estimate Only'
			);	
			EOD_ZREADING_DGV.ROW.ELEMENT(ROW_INDEX).style.color = "#dc3545";
		}
		

		// Next Request
		// _______________________________________________________________________	
		EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, 'Not Paid');
		EOD_ZREADING_DGV.CELL.ELEMENT('PAY_BBI',  ROW_INDEX).disabled = false;
		HTTP_SEARCH_ZREADING_ESTIMATE(ROW_INDEX + 1);
	};
	
	
	
	// ===============================================================
	// Request Search - PART.1
	// ===============================================================
	function HTTP_SEARCH_COLLECTION()
	{
		// Populate Data
		// _______________________________________________________________________
		GET_MAP_ARRAY = JSCUS_SQL._RECORD._CHILD_COLLECTION.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_CHLDCOLLECT_ACC_GROUP_ID', PROPERTY_CURRENT_POSDEVICE_ACCOUNT_GROUP_ID);
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_REC_CHLDCOLLECT_LINKSVR_DATE_FROM', 
			JSVC_DATE.VAR_FORMAT
			(
				JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
				'YYYY-MM-DD'
			) + " 00:00:00.000000"
		);
		JSVC_MAP_ARRAY.VAR_SET
		(
			GET_MAP_ARRAY, 'PARAM_REC_CHLDCOLLECT_LINKSVR_DATE_TO', 
			JSVC_DATE.VAR_FORMAT
			(
				JSOC_ELEMENT.VAR_VALUE('SEARCH_REC_EODREP_ZREAD_DATE_DTP'), 
				'YYYY-MM-DD'
			) + " 23:59:59.999999"
		);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_CHLDCOLLECT_ACC_LINKSVR_ID');
		
		// Get payment collection
		// _______________________________________________________________________
		JSCUS_SQL._RECORD._CHILD_COLLECTION.CUS_GET
		(
			GET_MAP_ARRAY,
			HTTP_SEARCH_COLLECTION_CALLBACK,
			true
		); 
	};
	
	
	// ===============================================================
	// Request Search - PART.2A
	// ===============================================================
	function HTTP_SEARCH_COLLECTION_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)
		{
			return;
		}


		// Populate DGV
		// _______________________________________________________________________
		var ACC_LINKSVR_BRANCH_ID = [];
		var ACC_LINKSVR_BRANCH_AMOUNT = [];
		var ACC_LINKSVR_ID = 0;
		var JSON_COUNT = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT"));
		var JSON_INDEX = 1;
		
		while(JSON_COUNT >= JSON_INDEX)
		{
			// Next Client Server
			// ...........................................
			if
			(
				ACC_LINKSVR_ID != JSVC_NUM.VAR_NVALL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHLDCOLLECT_ACC_LINKSVR_ID", JSON_INDEX)
				)
			)
			{
				// Populate collected data
				if(ACC_LINKSVR_ID > 0)
				{
					HTTP_SEARCH_COLLECTION_POPULATE(ACC_LINKSVR_ID, ACC_LINKSVR_BRANCH_ID, ACC_LINKSVR_BRANCH_AMOUNT);
				}
				
				// Clear Data
				ACC_LINKSVR_ID = JSVC_NUM.VAR_NVALL
				(
					JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHLDCOLLECT_ACC_LINKSVR_ID", JSON_INDEX)
				);
				ACC_LINKSVR_BRANCH_ID = [];
				ACC_LINKSVR_BRANCH_AMOUNT = [];				
			}
			
			
			// Check if current branch is already added in cache
			// ...........................................
			var BRANCH_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHLDCOLLECT_LINKSVR_ACC_GROUP_ID", JSON_INDEX);
			var ARRAY_INDEX = ACC_LINKSVR_BRANCH_ID.indexOf(BRANCH_ID);
			if(ARRAY_INDEX < 0)
			{
				ACC_LINKSVR_BRANCH_ID.push(BRANCH_ID);
				ACC_LINKSVR_BRANCH_AMOUNT.push(0);
				ARRAY_INDEX = ACC_LINKSVR_BRANCH_ID.length - 1;
			}
			
			
			// Sum Data
			// ...........................................
			ACC_LINKSVR_BRANCH_AMOUNT[ARRAY_INDEX] += JSVC_NUM.VAR_NVAL
			(
				JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHLDCOLLECT_AMOUNT", JSON_INDEX)
			);
			
			
			// To next loop
			// ...........................................
			JSON_INDEX ++;
		}
		
		
		// Process Last Cache
		// _______________________________________________________________________
		HTTP_SEARCH_COLLECTION_POPULATE
		(
			ACC_LINKSVR_ID, ACC_LINKSVR_BRANCH_ID, ACC_LINKSVR_BRANCH_AMOUNT
		);
	};
	

	// ===============================================================
	// Request Search - PART.2B
	// ===============================================================	
	function HTTP_SEARCH_COLLECTION_POPULATE(ACC_LINKSVR_ID, ACC_LINKSVR_BRANCH_ID, ACC_LINKSVR_BRANCH_AMOUNT)
	{
		// Initialize
		var ROW_COUNT = EOD_ZREADING_DGV.ROW.COUNT();
		var ROW_INDEX = 0;
		var BRANCH_INDEX = 0;
		
		// Populate DGV
		while(ROW_COUNT > ROW_INDEX)
		{
			// Skip if not the selected child server
			// _______________________________________________________________________
			if
			(
				JSVC_NUM.VAR_NVALL(EOD_ZREADING_DGV.CELL.VALUE('ACC_LINKSVR_ID',  ROW_INDEX)) != 
				ACC_LINKSVR_ID
			)
			{
				ROW_INDEX ++;
				continue;
			}
			
			
			// Locate current branch
			// _______________________________________________________________________
			BRANCH_INDEX = ACC_LINKSVR_BRANCH_ID.indexOf
			(
				EOD_ZREADING_DGV.CELL.VALUE('ACC_GROUP_ID',  ROW_INDEX)
			);
			
			
			// Populate Data
			// _______________________________________________________________________
			if(BRANCH_INDEX >= 0)
			{
				// Assign Value
				// ...........................................
				EOD_ZREADING_DGV.CELL.VALUE
				(
					'REC_CHLDCOLLECT_AMOUNT',  ROW_INDEX, 
					JSVC_NUM.VAR_CFORMAT(ACC_LINKSVR_BRANCH_AMOUNT[BRANCH_INDEX])
				);
				
				// Check if fully paid
				// ...........................................
				if
				(
					ACC_LINKSVR_BRANCH_AMOUNT[BRANCH_INDEX] >= JSVC_NUM.VAR_NVAL
					(
						EOD_ZREADING_DGV.CELL.VALUE('REC_POSSALE_PAID',  ROW_INDEX)
					)
				)
				{
					EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, 'Collected');
					EOD_ZREADING_DGV.CELL.ELEMENT('PAY_BBI',  ROW_INDEX).disabled = true;
					EOD_ZREADING_DGV.ROW.ELEMENT(ROW_INDEX).style.color = '#28a745';
				}
				
				// Partial
				// ...........................................
				else
				{
					EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, 'Partially Paid');
					EOD_ZREADING_DGV.CELL.ELEMENT('PAY_BBI',  ROW_INDEX).disabled = false;
				}
			}
			
			
			// Given Branch does not exists in the collection
			// _______________________________________________________________________
			else if(EOD_ZREADING_DGV.CELL.VALUE('REC_POSSALE_PAID',  ROW_INDEX) <= 0)
			{
				EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, '-');
				EOD_ZREADING_DGV.CELL.ELEMENT('PAY_BBI',  ROW_INDEX).disabled = true;
			}
			
			else
			{
				EOD_ZREADING_DGV.CELL.VALUE('PAYMENT_STATUS',  ROW_INDEX, 'Not Paid');
				EOD_ZREADING_DGV.CELL.ELEMENT('PAY_BBI',  ROW_INDEX).disabled = false;
			}
			
			
			ROW_INDEX ++;
		}
	}
	
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();