// 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
		// _______________________________________________________________________	
		POS_SALE_DGV = DataGridView("POS_SALE_DGV");
		POS_SALE_LIST_DGV = DataGridView("POS_SALE_LIST_DGV");
		//POS_SALE_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//POS_SALE_DGV.SETTING_EDITABLE = true;
		POS_SALE_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Print Button
				// ...........................................
				if(POS_SALE_DGV.COLUMN.NAME(COL_INDEX) == "REPRINT_CMD")
				{
					//REPRINT RECEIPT
					PROPERTY_REC_POSSALE_ID = POS_SALE_DGV.CELL.VALUE('REC_POSSALE_ID', ROW_INDEX);
					HTTP_REPRINT_SALE(PROPERTY_REC_POSSALE_ID);
					return;
				}
						
	
				// If dialog supported
				// ...........................................
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
				{
					// Clear Modal
					if(JSVC_VAR.VAR_ISSET(INPUT_INSTANCE))
					{
						JSOC_WINDOW.VAR_INPUT_INSTANCE_RESTORE(INPUT_INSTANCE);
					}
						
					// Display Modal
					PROPERTY_REC_POSSALE_ID = POS_SALE_DGV.CELL.VALUE('REC_POSSALE_ID', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;

					JSOC_ELEMENT.VAR_VALUE('POS_SALE_CUSTOMER_NAME', POS_SALE_DGV.CELL.VALUE('REC_CLIENT_FIRSTNAME', ROW_INDEX));
					JSOC_ELEMENT.VAR_VALUE('POS_SALE_CUSTOMER_ADDRESS', POS_SALE_DGV.CELL.VALUE('REC_CLIENT_MIDDLENAME', ROW_INDEX));
					JSOC_ELEMENT.VAR_VALUE('POS_SALE_CUSTOMER_TIN', '');

					JSOC_ELEMENT.VAR_VALUE('POS_SALE_CODE_TXT', POS_SALE_DGV.CELL.VALUE('REC_POSSALE_CODE', ROW_INDEX));
					
					EDIT_HANDLER.REF_IS_MODIFIED = false;
					JSOC_DIALOG.VAR_MODAL("POS_SALE_MODAL", true);
					HTTP_LOAD();
					return;
				}

			}
		);   

		
		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Requires Authentication
		// _______________________________________________________________________	
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			


		
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_ACC_GROUP_ID_CMB") == true)
		// {
		// 	// Set Default Item, if used in DataGridView
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._GROUP.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._ACCOUNT._GROUP.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("REC_POSSALE_ACC_GROUP_ID_CMB", 0);
					
		// 			// Clone to DGV Cell if ComboBox Exists
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_DGV_ROW_REC_POSSALE_ACC_GROUP_ID") == true)
		// 			{
		// 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_SALE_DGV_ROW_REC_POSSALE_ACC_GROUP_ID");
		// 				DGV_ELEMENT_CHILD_INDEX = 0;
		// 				while(DGV_ELEMENT_CHILD.length > DGV_ELEMENT_CHILD_INDEX)
		// 				{
		// 					if
		// 					(
		// 						DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].tagName == "SELECT" &&
		// 						JSVC_STR.VAR_IS_BLANK(DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].id.toString())
		// 					)
		// 					{
		// 						JSOC_ELEMENT.VAR_INNER_HTML
		// 						(
		// 							DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX], 
		// 							JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_ACC_GROUP_ID_CMB")
		// 						);
		// 					}	
		// 					DGV_ELEMENT_CHILD_INDEX ++;
		// 				}
		// 			}
					
		// 			// Copy items to edit control
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB") == true)
		// 			{
		// 				JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB");
		// 				JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Branch");
		// 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_ACC_GROUP_ID_CMB"), true);
		// 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB", 0);
		// 				$('.BSSP_SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB').selectpicker('refresh');
		// 			}				
					
		// 			// Update Modal Settings
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		// 			{
		// 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		// 			}
					
		// 			// Forward populate complete event.
		// 			$('.BSSP_REC_POSSALE_ACC_GROUP_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();		
		// 		},
		// 		"REC_POSSALE_ACC_GROUP_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		// if
		// (
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB") == true &&
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_ACC_GROUP_ID_CMB") == false
		// )
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Branch");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._GROUP.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._ACCOUNT._GROUP.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB", 0);
					
		// 			// Forward populate complete event.		
		// 			$('.BSSP_SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();
		// 		},		
		// 		"SEARCH_REC_POSSALE_ACC_GROUP_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_POSDEVICE_ID_CMB") == true)
		// {
		// 	// Set Default Item, if used in DataGridView
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_REC_POSDEVICE_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POSDEVICE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._POSDEVICE.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("REC_POSSALE_REC_POSDEVICE_ID_CMB", 0);
					
		// 			// Clone to DGV Cell if ComboBox Exists
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_POSDEVICE_ID") == true)
		// 			{
		// 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_POSDEVICE_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_POSSALE_REC_POSDEVICE_ID_CMB")
		// 						);
		// 					}	
		// 					DGV_ELEMENT_CHILD_INDEX ++;
		// 				}
		// 			}
					
		// 			// Copy items to edit control
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB") == true)
		// 			{
		// 				JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB");
		// 				JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Posdevice");
		// 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_REC_POSDEVICE_ID_CMB"), true);
		// 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB", 0);
		// 				$('.BSSP_SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB').selectpicker('refresh');
		// 			}				
					
		// 			// Update Modal Settings
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		// 			{
		// 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		// 			}
					
		// 			// Forward populate complete event.
		// 			$('.BSSP_REC_POSSALE_REC_POSDEVICE_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();		
		// 		},
		// 		"REC_POSSALE_REC_POSDEVICE_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		// if
		// (
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB") == true &&
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_POSDEVICE_ID_CMB") == false
		// )
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Posdevice");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POSDEVICE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._POSDEVICE.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB", 0);
					
		// 			// Forward populate complete event.		
		// 			$('.BSSP_SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();
		// 		},		
		// 		"SEARCH_REC_POSSALE_REC_POSDEVICE_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_CLIENT_ID_CMB") == true)
		// {
		// 	// Set Default Item, if used in DataGridView
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_REC_CLIENT_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CLIENT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._CLIENT.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("REC_POSSALE_REC_CLIENT_ID_CMB", 0);
					
		// 			// Clone to DGV Cell if ComboBox Exists
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_CLIENT_ID") == true)
		// 			{
		// 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_CLIENT_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_POSSALE_REC_CLIENT_ID_CMB")
		// 						);
		// 					}	
		// 					DGV_ELEMENT_CHILD_INDEX ++;
		// 				}
		// 			}
					
		// 			// Copy items to edit control
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB") == true)
		// 			{
		// 				JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB");
		// 				JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Client");
		// 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_REC_CLIENT_ID_CMB"), true);
		// 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB", 0);
		// 				$('.BSSP_SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB').selectpicker('refresh');
		// 			}				
					
		// 			// Update Modal Settings
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		// 			{
		// 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		// 			}
					
		// 			// Forward populate complete event.
		// 			$('.BSSP_REC_POSSALE_REC_CLIENT_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();		
		// 		},
		// 		"REC_POSSALE_REC_CLIENT_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		// if
		// (
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB") == true &&
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_CLIENT_ID_CMB") == false
		// )
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Client");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CLIENT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._CLIENT.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB", 0);
					
		// 			// Forward populate complete event.		
		// 			$('.BSSP_SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();
		// 		},		
		// 		"SEARCH_REC_POSSALE_REC_CLIENT_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_LOYALTY_ID_CMB") == true)
		// {
		// 	// Set Default Item, if used in DataGridView
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_REC_LOYALTY_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._LOYALTY.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._LOYALTY.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("REC_POSSALE_REC_LOYALTY_ID_CMB", 0);
					
		// 			// Clone to DGV Cell if ComboBox Exists
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_LOYALTY_ID") == true)
		// 			{
		// 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_SALE_DGV_ROW_REC_POSSALE_REC_LOYALTY_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_POSSALE_REC_LOYALTY_ID_CMB")
		// 						);
		// 					}	
		// 					DGV_ELEMENT_CHILD_INDEX ++;
		// 				}
		// 			}
					
		// 			// Copy items to edit control
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB") == true)
		// 			{
		// 				JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB");
		// 				JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Loyalty");
		// 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_REC_LOYALTY_ID_CMB"), true);
		// 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB", 0);
		// 				$('.BSSP_SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB').selectpicker('refresh');
		// 			}				
					
		// 			// Update Modal Settings
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		// 			{
		// 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		// 			}
					
		// 			// Forward populate complete event.
		// 			$('.BSSP_REC_POSSALE_REC_LOYALTY_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();		
		// 		},
		// 		"REC_POSSALE_REC_LOYALTY_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		// if
		// (
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB") == true &&
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_REC_LOYALTY_ID_CMB") == false
		// )
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Loyalty");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._LOYALTY.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._RECORD._LOYALTY.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB", 0);
					
		// 			// Forward populate complete event.		
		// 			$('.BSSP_SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();
		// 		},		
		// 		"SEARCH_REC_POSSALE_REC_LOYALTY_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_ACC_ACCOUNT_ID_CMB") == true)
		// {
		// 	// Set Default Item, if used in DataGridView
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_ACC_ACCOUNT_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._ACCOUNT._MEMBER.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("REC_POSSALE_ACC_ACCOUNT_ID_CMB", 0);
					
		// 			// Clone to DGV Cell if ComboBox Exists
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_DGV_ROW_REC_POSSALE_ACC_ACCOUNT_ID") == true)
		// 			{
		// 				DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_SALE_DGV_ROW_REC_POSSALE_ACC_ACCOUNT_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_POSSALE_ACC_ACCOUNT_ID_CMB")
		// 						);
		// 					}	
		// 					DGV_ELEMENT_CHILD_INDEX ++;
		// 				}
		// 			}
					
		// 			// Copy items to edit control
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB") == true)
		// 			{
		// 				JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB");
		// 				JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Member");
		// 				JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSSALE_ACC_ACCOUNT_ID_CMB"), true);
		// 				JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB", 0);
		// 				$('.BSSP_SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
		// 			}				
					
		// 			// Update Modal Settings
		// 			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		// 			{
		// 				INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		// 			}
					
		// 			// Forward populate complete event.
		// 			$('.BSSP_REC_POSSALE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();		
		// 		},
		// 		"REC_POSSALE_ACC_ACCOUNT_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		// if
		// (
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB") == true &&
		// 	JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_ACC_ACCOUNT_ID_CMB") == false
		// )
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Member");
		// 	// To use custom populate
		// 	// var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		// 	// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
		// 	JSCUS_SQL._ACCOUNT._MEMBER.CUS_GET_THEN_POPULATE_COMBOBOX
		// 	(
		// 		function()
		// 		{
		// 			// Set Default index
		// 			JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB", 0);
					
		// 			// Forward populate complete event.		
		// 			$('.BSSP_SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
		// 			HTTP_POPULATE_RESULT();
		// 		},		
		// 		"SEARCH_REC_POSSALE_ACC_ACCOUNT_ID_CMB",
		// 		true, 2
		// 		// , GET_MAP_ARRAY 
		// 	);
		// }
		
		// Status		
		// _______________________________________________________________________	
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_STATUS_CMB") == true)
		// {
		// 	JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSSALE_STATUS_CMB");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_STATUS_CMB", "0","Any Status");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_STATUS_CMB", "1","Inactive");
		// 	JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_STATUS_CMB", "2","Active");
		// 	// JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_STATUS_CMB", "3","Closed");
		// 	// JSOC_CMB.VAR_ADD("SEARCH_REC_POSSALE_STATUS_CMB", "4","Completed");
		// 	JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSSALE_STATUS_CMB", "2");
		// }			
		
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSSALE_STATUS_CMB") == true)
		// {
		// 	JSOC_CMB.VAR_CLEAR("REC_POSSALE_STATUS_CMB");
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_STATUS_CMB", "1","Inactive");
		// 	JSOC_CMB.VAR_ADD("REC_POSSALE_STATUS_CMB", "2","Active");
		// 	// JSOC_CMB.VAR_ADD("REC_POSSALE_STATUS_CMB", "3","Closed");
		// 	// JSOC_CMB.VAR_ADD("REC_POSSALE_STATUS_CMB", "4","Completed");
		// 	JSOC_CMB.VAR_SELECTED_VALUE("REC_POSSALE_STATUS_CMB", "2");
		// }
		
		
		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_SALE_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_SALE_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		// if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSSALE_CODE_TXT"))
		// {
		// 	var SEARCH_REC_POSSALE_CODE_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_POSSALE_CODE_TXT");
		// 	SEARCH_REC_POSSALE_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
		{
			PRELOAD_POS_SHIFT
			(
				function(IS_SUCCESS, RESPONSE)
				{
					if(IS_SUCCESS)
					{
						HTTP_SEARCH();

						if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("DEVICE_ID_LBL")) {
							JSOC_ELEMENT.VAR_VALUE('DEVICE_ID_LBL', JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID);
						}
					}
				}
			);
		}
	}

	
	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_SEARCH(NEW_ITEM_ID, EDITED_ROW_INDEX)
	{
		// Optional Value
		//NEW_ITEM_ID = JSVC_VAR.VAR_OPTIONAL(NEW_ITEM_ID, -1);
		//EDITED_ROW_INDEX = JSVC_VAR.VAR_OPTIONAL(EDITED_ROW_INDEX, -1);
		
		// Parameter Validate
		//JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(NEW_ITEM_ID, 'NEW_ITEM_ID', 'NUMERIC');
		//JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(EDITED_ROW_INDEX, 'EDITED_ROW_INDEX', 'NUMERIC');
		
		
		// Actual Function
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SALE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_ACC_GROUP_ID', JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID)); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_REC_POSDEVICE_ID', JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID)); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_ACC_ACCOUNT_ID', JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID)); 

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_DATE_TRANSACT_FROM', JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD") + " 00:00:00.000000"); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_DATE_TRANSACT_TO', JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD") + " 23:59:59.999999"); 

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_POSSALE_ID'); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC'); 
			
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		JSCUS_SQL._RECORD._POS_SALE.CUS_GET
		(
			GET_MAP_ARRAY,
			HTTP_SEARCH_CALLBACK,
			true
		);       		
	}
	
	
	// ===============================================================
	// Request Search - PART.B
	// ===============================================================
	function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
	{
		// Disable Dialogs
		// _______________________________________________________________________
		CUS_SEND_DIALOG_TRY_DISMISS();
		
		// Validate
		// _______________________________________________________________________
		if(IS_SUCCESS === false)
		{
			console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// Validate JSON Response
		// _______________________________________________________________________
		var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
		if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
		{
			console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			POS_SALE_DGV.ROW.CLEAR();

			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'No transactions found',
				'Information',
				'OK', 'ERROR',
				function() {}
			);

			JSOC_ELEMENT.VAR_VALUE('transaction_count', 0);
			return;
		}

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

		JSOC_ELEMENT.VAR_VALUE('transaction_count', POS_SALE_DGV.ROW.COUNT());
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_NET");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_DISCOUNT");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATABLE");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATEXEMPT");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_NONVAT");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_ZERORATED");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATOTHER");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VAT");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VAT_LESS");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_POINT");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_RTN_SUBTOTAL");
		// POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_PAID");
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
		var ROW_INDEX = 0;
	
	
		// DateTime Format
		// _______________________________________________________________________	
		if(POS_SALE_DGV.COLUMN.IS_EXISTS("REC_POSSALE_TOTAL_NET"))
		{
			WEBTABLE_DATE = null;
			ROW_INDEX = 0;

			while(POS_SALE_DGV.ROW.COUNT() > ROW_INDEX)
			{
				// Apply CFormat, and DateFormat
				// ...........................................
				POS_SALE_DGV.CELL.VALUE
				(
					"REC_POSSALE_TOTAL_NET", ROW_INDEX, 
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_VATABLE", ROW_INDEX)) +
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_VATEXEMPT", ROW_INDEX)) +
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_NONVAT", ROW_INDEX)) +
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_ZERORATED", ROW_INDEX)) +
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_VATOTHER", ROW_INDEX)) +
				    JSVC_NUM.VAR_NVAL(POS_SALE_DGV.CELL.VALUE("REC_POSSALE_TOTAL_VAT", ROW_INDEX))
				);
										
										
				// Color Coding (Uncomment to use)
				// ...........................................	
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
				
				// To next loop
				// ...........................................	
				ROW_INDEX ++;
			}			
			POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_NET");
			//JSOC_ELEMENT.VAR_VALUE('REC_POSSALE_TOTAL_NET_LBL', JSVC_NUM.VAR_CFORMAT(POS_SALE_DGV.COLUMN.SUM("REC_POSSALE_TOTAL_NET")));
		}

		if(POS_SALE_DGV.COLUMN.IS_EXISTS("REC_POSSALE_DATE_TRANSACT"))
		{
			WEBTABLE_DATE = null;
			ROW_INDEX = 0;
			while(POS_SALE_DGV.ROW.COUNT() > ROW_INDEX)
			{
				// Read Current Value
				// ...........................................
				 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
					 (
							POS_SALE_DGV.CELL.VALUE
							(
									"REC_POSSALE_DATE_TRANSACT", 
									ROW_INDEX
							)
					 );
				
				// Apply CFormat, and DateFormat
				// ...........................................
				if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
				{
					POS_SALE_DGV.CELL.VALUE
					(
							"REC_POSSALE_DATE_TRANSACT", ROW_INDEX, 
							JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY hh:mm:ss TT")
					);				
				}			
				
				// Color Coding (Uncomment to use)
				// ...........................................	
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
				//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
				
				// To next loop
				// ...........................................	
				ROW_INDEX ++;
			}			
		}

	}
	
	
	// ===============================================================
	// Request Search - PART.C
	// ===============================================================
	function HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, ROW_INDEX)
	{
		// Disable Dialogs
		// _______________________________________________________________________
		CUS_SEND_DIALOG_TRY_DISMISS();
		
		// Validate
		// _______________________________________________________________________
		if(IS_SUCCESS === false)
		{
			console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// Validate JSON Response
		// _______________________________________________________________________
		var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
		if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
		{
			console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			POS_SALE_DGV.ROW.CLEAR();
			return;
		}

		// Validate Row Count
		// _______________________________________________________________________	
		if(POS_SALE_DGV.ROW.COUNT() <= 0)
		{
			console.error("DataGridView has no rows to fill.");
			return;
		}
		JSVC_AV.VAR_VALIDATE_RANGE(ROW_INDEX, "ROW_INDEX", 0, POS_SALE_DGV.ROW.COUNT() - 1);
		
		// Populate DGV
		// _______________________________________________________________________
		POS_SALE_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1],
				ROW_INDEX
		);
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_SUBTOTAL");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_DISCOUNT");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATABLE");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATEXEMPT");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_NONVAT");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_ZERORATED");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VATOTHER");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VAT");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_VAT_LESS");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_POINT");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_RTN_SUBTOTAL");
		POS_SALE_DGV.COLUMN.CFORMAT("REC_POSSALE_TOTAL_PAID");
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
	
	
		// DateTime Format
		// _______________________________________________________________________	
		if(POS_SALE_DGV.COLUMN.IS_EXISTS("REC_POSSALE_DATE_PAID"))
		{
			WEBTABLE_DATE = null;
			// Read Current Value
			// ...........................................
			 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				 (
						POS_SALE_DGV.CELL.VALUE
						(
								"REC_POSSALE_DATE_PAID", 
								ROW_INDEX
						)
				 );
			
			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				POS_SALE_DGV.CELL.VALUE
				(
						"REC_POSSALE_DATE_PAID", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			
			
			// Color Coding (Uncomment to use)
			// ...........................................	
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}
		if(POS_SALE_DGV.COLUMN.IS_EXISTS("REC_POSSALE_DATE_DUE"))
		{
			WEBTABLE_DATE = null;
			// Read Current Value
			// ...........................................
			 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				 (
						POS_SALE_DGV.CELL.VALUE
						(
								"REC_POSSALE_DATE_DUE", 
								ROW_INDEX
						)
				 );
			
			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				POS_SALE_DGV.CELL.VALUE
				(
						"REC_POSSALE_DATE_DUE", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			
			
			// Color Coding (Uncomment to use)
			// ...........................................	
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}
		if(POS_SALE_DGV.COLUMN.IS_EXISTS("REC_POSSALE_DATE_TRANSACT"))
		{
			WEBTABLE_DATE = null;
			// Read Current Value
			// ...........................................
			 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				 (
						POS_SALE_DGV.CELL.VALUE
						(
								"REC_POSSALE_DATE_TRANSACT", 
								ROW_INDEX
						)
				 );
			
			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				POS_SALE_DGV.CELL.VALUE
				(
						"REC_POSSALE_DATE_TRANSACT", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			
			
			// Color Coding (Uncomment to use)
			// ...........................................	
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//POS_SALE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}

	}	

	function HTTP_REPRINT_SALE(POS_SALE_ID)
	{
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SALE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_ID', POS_SALE_ID); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_STATUS', 4); 


		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = 			
			function(IS_SUCCESS, HTTP_RESPONSE)
			{
				// Disable Dialogs
				// ...........................................
				CUS_SEND_DIALOG_TRY_DISMISS();
				
				// Handle Error
				// ...........................................
				if(IS_SUCCESS === false)
				{
					METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
					return;
				}
				
				// Catch JSON Error
				// ...........................................
				else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
				{
					METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
					return;			
				}
					
				// Read Response
				// ...........................................
				else
				{
					// Load Response
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}
					// Post Save Action
					else
					{
						var TOTAL_DUE = 0;

						var RECEIPT = '';
						var RECEIPT_TOTAL = '';

						//prepare RECEIPT
						RECEIPT += '<table border="0" style="width: 100%; font-size: 10px; border-collapse: collapse;">';
							RECEIPT += '<tr><td style="text-align: center;">'+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSDEVICE_DESCRIPTION", 1)+'</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">'+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSDEVICE_ADDRESS", 1)+'</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">'+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSDEVICE_CONTACT", 1)+'</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">VAT Reg TIN: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSDEVICE_TIN", 1)+'</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;"><hr style="border: 1px dashed black;"></td></tr>';
						RECEIPT += '</table>';

						RECEIPT += '<table border="0" style="width: 100%; font-size: 10px; border-collapse: collapse;">';
							RECEIPT += '<tr><td style="text-align: right;">'+ JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_CODE", 1)+'</td></tr>';
							RECEIPT += '<tr><td>DATE: '+JSVC_DATE.VAR_FORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_DATE_TRANSACT", 1), "MM-DD-YYYY HH:mm:ss TT")+'</td></tr>';
							RECEIPT += '<tr><td>CASHIER: '+JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_ACCOUNT_NAME", 1)+'</td></tr>';
							RECEIPT += '<tr><td>CUSTOMER: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_LASTNAME", 1)+'</td></tr>';
							RECEIPT += '<tr><td>TIN: </td></tr>';
							RECEIPT += '<tr><td>ADDRESS: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_MIDDLENAME", 1)+'</td></tr>';
						RECEIPT += '</table>';

						RECEIPT += '<br>';

						RECEIPT += '<table border="0" style="width: 100%; font-size: 11px; border-collapse: collapse;">';
							RECEIPT += '<tr>';
								RECEIPT += '<td>ITEM</td>';
								RECEIPT += '<td style="text-align: right;">QTY</td>';
								RECEIPT += '<td style="text-align: right;">PRICE</td>';
								RECEIPT += '<td style="text-align: right;">SUB-TOTAL</td>';
							RECEIPT += '</tr>';
							RECEIPT += '<tr><td colspan="4"><hr style="border: 1px dashed black;"></td></tr>';
						RECEIPT += '</table>';

						//for totals

						RECEIPT_TOTAL += '<tr><td>SUB-TOTAL</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_SUBTOTAL", 1)))+'</td></tr>';

							if(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_DISCOUNT", 1)) > 0) {
								RECEIPT += '<tr><td style="padding-left: 10px;">LESS DISCOUNT</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_SUBTOTAL", 1)))+'</td></tr>';
							}

						TOTAL_DUE += 
							(
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_VAT", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_NONVAT", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_VATABLE", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_VATEXEMPT", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_VATOTHER", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_VAT_LESS", 1)) +
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_TOTAL_ZERORATED", 1))
							);

						RECEIPT_TOTAL += '<tr><td></td><td style="text-align: right;"><hr style="border: 1px dashed black;"></td></tr>';
						RECEIPT_TOTAL += '<tr><td>AMOUNT DUE</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(TOTAL_DUE)+'</td></tr>';

						HTTP_REPRINT_SALE_LIST(POS_SALE_ID, RECEIPT, RECEIPT_TOTAL);
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._POS_SALE.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}

	function HTTP_REPRINT_SALE_LIST(POS_SALE_ID, RECEIPT, RECEIPT_TOTAL)
	{
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SALE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_LIST_REC_POSSALE_ID', POS_SALE_ID); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_LIST_STATUS', 2); 


		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = 			
			function(IS_SUCCESS, HTTP_RESPONSE)
			{
				// Disable Dialogs
				// ...........................................
				CUS_SEND_DIALOG_TRY_DISMISS();
				
				// Handle Error
				// ...........................................
				if(IS_SUCCESS === false)
				{
					METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
					return;
				}
				
				// Catch JSON Error
				// ...........................................
				else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
				{
					METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
					return;			
				}
					
				// Read Response
				// ...........................................
				else
				{
					// Load Response
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}
					
					else
					{
						// JSON Empty (Clears the DataGrodView)
						// _______________________________________________________________________
						if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
						{
							JSOC_DIALOG.VAR_MESSAGE_BOX
							(
								'Transaction not found',
								'Information',
								'OK', 'ERROR',
								function() {}
							);
							
							return;
						}

						//prepare RECEIPT
						RECEIPT += '<table border="0" style="width: 100%; font-size: 11px; border-collapse: collapse;">';

							var INDEX = 1;
							var TOTAL_ITEMS = 0;

							while(JSON_OBJECT.JSON_COUNT >= INDEX)
							{
								RECEIPT += '<tr>';
									RECEIPT += '<td style="vertical-align: top;"><small>'+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_LIST_CAT_PRODUCT_ID_DESCRIPTION", INDEX)+'</small></td>';
								RECEIPT += '</tr>';
								RECEIPT += '<tr>';
									RECEIPT += '<td colspan="3" style="vertical-align: top;"><small>'+JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_LIST_QUANTITY", INDEX)))+' '+JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_UOM_CODE", INDEX)+' X '+JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_LIST_AMOUNT_PRICE", INDEX)))+'</small></td>';
									RECEIPT += '<td style="text-align: right; vertical-align: top;"><small>'+JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_LIST_TOPAY_SUBTOTAL", INDEX)))+'</small></td>';
								RECEIPT += '</tr>';

								TOTAL_ITEMS += JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSSALE_LIST_QUANTITY", INDEX));

								INDEX++;
							}

						RECEIPT += '</table>';

						RECEIPT += '<hr style="border: 1px dashed black;">';

						HTTP_REPRINT_SALE_PAYMENT(POS_SALE_ID, TOTAL_ITEMS, RECEIPT, RECEIPT_TOTAL);
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._POS_SALE_LIST.CUS_GET_ALL
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}

	function HTTP_REPRINT_SALE_PAYMENT(POS_SALE_ID, TOTAL_ITEMS, RECEIPT, RECEIPT_TOTAL)
	{
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_PAYMENT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSPAY_REC_POSSALE_ID', POS_SALE_ID); 
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSPAY_STATUS', 2); 
		//JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_POSPAY_ID'); 
		//JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC'); 


		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = 			
			function(IS_SUCCESS, HTTP_RESPONSE)
			{
				// Disable Dialogs
				// ...........................................
				CUS_SEND_DIALOG_TRY_DISMISS();
				
				// Handle Error
				// ...........................................
				if(IS_SUCCESS === false)
				{
					METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
					return;
				}
				
				// Catch JSON Error
				// ...........................................
				else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
				{
					METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
					return;			
				}
					
				// Read Response
				// ...........................................
				else
				{
					// Load Response
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}
					
					else
					{
						//prepare RECEIPT
						RECEIPT += '<table border="0" style="width: 100%; font-size: 10px; border-collapse: collapse;">';
							RECEIPT += '<thead>';
								RECEIPT += RECEIPT_TOTAL;

						var INDEX = 1;
						var TOTAL_ITEMS = 0;
						var AMOUNT_CHANGE = 0;
						var CHARGED = false;

						while(JSON_OBJECT.JSON_COUNT >= INDEX)
						{
							//not charge to account
							if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) !== 5) 
							{
								if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) == 1) {
									RECEIPT += '<tr><td style="padding-left: 10px;">CASH</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_AMOUNT_PAID", INDEX))+'</td></tr>';
								}
										
								if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) == 2) {
									RECEIPT += '<tr><td style="padding-left: 10px;">C/D: ****-****-****-'+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_NUMBER", INDEX)+'</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_AMOUNT_PAID", INDEX))+'</td></tr>';
								}

								if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) == 3) {
									RECEIPT += '<tr><td style="padding-left: 10px;">CHECK: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_NUMBER", INDEX)+'</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_AMOUNT_PAID", INDEX))+'</td></tr>';
								}

								if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) == 6) {
									RECEIPT += '<tr><td style="padding-left: 10px;">LOYALTY CARD: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_NUMBER", INDEX)+'</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_AMOUNT_PAID", INDEX))+'</td></tr>';
								}

								if(JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CAT_PAYTYPE_ID", INDEX)) == 7) {
									RECEIPT += '<tr><td style="padding-left: 10px;">GIFT CERT./VOUCHER: '+JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_NUMBER", INDEX)+'</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_AMOUNT_PAID", INDEX))+'</td></tr>';
								}
							}

							// if charged to account
							else {
								CHARGED = true;
							}

							AMOUNT_CHANGE = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSPAY_CHANGE", 1));

							INDEX++;
						}

							RECEIPT += '<tr><td></td><td style="text-align: right;"><hr style="border: 1px dashed black;"></td></tr>';
							RECEIPT += '<tr><td>CHANGE</td><td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(AMOUNT_CHANGE)+'</td></tr>';
							

						// if charged to account
						if(CHARGED == true) 
						{
							RECEIPT += '<tr><td> </td><td> </td></tr>';
							RECEIPT += '<tr><td> </td><td> </td></tr>';
							RECEIPT += '<tr><td>ITEMS:</td><td style="text-align: right;">'+JSOC_ELEMENT.VAR_CFORMAT(TOTAL_ITEMS)+'</td></tr>';
							RECEIPT += '<tr><td> </td><td> </td></tr>';
							RECEIPT += '<tr><td colspan="2" style="text-align: center;">_______________________________</td></tr>';
							RECEIPT += '<tr><td colspan="2" style="text-align: center;"><small>SIGNATURE OVER PRINTED NAME</small></td></tr>';
							RECEIPT += '<tr><td colspan="2" style="text-align: center;">RECEIVED THE ABOVE GOODS COMPLETE AND IN GOOD CONDITION</td></tr>';
						}

							RECEIPT += '</thead>';
						RECEIPT += '</table>'

						RECEIPT += '<br>';

						RECEIPT += '<hr style="border: 1px dashed black;">';

						RECEIPT += '<table border="0" style="width: 100%; font-size: 10px; border-collapse: collapse;">';
							RECEIPT += '<tr><td style="text-align: center;">POS SOFTWARE PROVIDER</td></tr>';
							RECEIPT += '<tr><td> </td></tr>';
							RECEIPT += '<tr><td> </td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">DSA SOFTWARE SOLUTIONS</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">Diamond Township Bldg., Cotabato City</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">Contact No.: 09661452163 / 064-557-4005</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">TIN: 278-081-323</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">ACCR. No.: 1072780813232016010482</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">ACCR. DATE: 12/06/2019</td></tr>';
							RECEIPT += '<tr><td style="text-align: center;">PERMIT No.: '+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_PERMIT_NUMBER+'</td></tr>';
						RECEIPT += '</table>';

						if(CHARGED == false)
						{
							RECEIPT += '<br>';

							RECEIPT += '<table border="0" style="width: 100%; font-size: 10px; border-collapse: collapse;">';
								RECEIPT += '<tr><td style="text-align: center;">This invoice/RECEIPT shall be valid for five years from the date of permit to use.</td></tr>';
								RECEIPT += '<tr><td></td></tr>';
								RECEIPT += '<tr><td></td></tr>';
								RECEIPT += '<tr><td style="text-align: center;">*THIS IS A REPRINTED RECEIPT*</td></tr>';
								RECEIPT += '<tr><td style="text-align: center;">***THANK YOU! COME AGAIN!***</td></tr>';
							RECEIPT += '</table>';
						}

						Android.CALL('PRINT', '<html><body>' + RECEIPT + '</body></html>');
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._POS_PAYMENT.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}
				
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();