// 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_RESERVE_DGV = DataGridView("POS_RESERVE_DGV");
		PRODUCT_BRANCH_DGV = DataGridView("PRODUCT_BRANCH_DGV");
		//POS_RESERVE_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//POS_RESERVE_DGV.SETTING_EDITABLE = true;
		
		POS_RESERVE_DGV.COLUMN.TOTAL_CREATE
		(
			[
				"PRODUCT_01",
				"PRODUCT_02",
				"PRODUCT_03",
				"PRODUCT_04",
				"PRODUCT_05",
				"PRODUCT_06"
			],
			"REC_CLIENT_NAME"
		);

		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Requires Authentication
		// _______________________________________________________________________	
		//PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_GROUP_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_POSRESERVE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(), "Select Branch");
			JSCUS_SQL._ACCOUNT._GROUP.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function()
				{
					JSOC_CMB.VAR_SELECTED_INDEX("REC_POSRESERVE_ACC_GROUP_ID_CMB", 0);
					
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_ACC_GROUP_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_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_POSRESERVE_ACC_GROUP_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB");
						//JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Group");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSRESERVE_ACC_GROUP_ID_CMB"), true);

						// if(JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID) != 2)
						// {
						// 	document.getElementById("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB").setAttribute('disabled', true);
						// 	JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
						// }
						// else
							JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB", 0);
						$('#SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB').select2();
					}

					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_GROUP_ID_CMB2") == true)
					{
						JSOC_CMB.VAR_CLEAR("REC_POSRESERVE_ACC_GROUP_ID_CMB2");
						JSOC_ELEMENT.VAR_INNER_HTML("REC_POSRESERVE_ACC_GROUP_ID_CMB2", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSRESERVE_ACC_GROUP_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("REC_POSRESERVE_ACC_GROUP_ID_CMB2", 0);
					}			
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_RESERVE_MODAL");
					}
					
					// Forward populate complete event.
					// $('#REC_POSRESERVE_ACC_GROUP_ID_CMB').select2({
					// 	dropdownParent: $('#POS_RESERVE_MODAL')
					// });
					HTTP_POPULATE_RESULT();		
				},
				"REC_POSRESERVE_ACC_GROUP_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_GROUP_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB");
			//JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Group");
			// 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_POSRESERVE_ACC_GROUP_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('#SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB').select2();
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_REC_CLIENT_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_POSRESERVE_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_REC_CLIENT_STATUS', 2);
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_CLIENT_FIRSTNAME');
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC');
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', '100');
			
			JSCUS_SQL._RECORD._CLIENT.CUS_GET
			(
				GET_MAP_ARRAY,
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					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;
					}

					var JSON_COUNT = JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT");
					var CTR = 0;
					var COUNTER = 1;
					var TOTAL_SALES = 0;

					while(CTR < JSON_COUNT)
					{
						JSOC_CMB.VAR_ADD
						(
							"REC_POSRESERVE_REC_CLIENT_ID_CMB",
							JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_ID", COUNTER),
							JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_FIRSTNAME", COUNTER) + " " + JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_LASTNAME", COUNTER)
						);


						CTR++;
						COUNTER++;
					}

					// JSOC_CMB.VAR_ADD_FROM_JSON
					// (
					// 	'REC_POSRESERVE_REC_CLIENT_ID_CMB',
					// 	JSON_OBJECT,
					// 	'REC_CLIENT_ID',
					// 	'REC_CLIENT_LASTNAME', 
					// 	true,
					// 	false
					// )

					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_POSRESERVE_REC_CLIENT_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_REC_CLIENT_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_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_POSRESERVE_REC_CLIENT_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Client");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSRESERVE_REC_CLIENT_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB", 0);
						$('#SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB').select2();
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_RESERVE_MODAL");
					}
					
					// Forward populate complete event.
					// $('#REC_POSRESERVE_REC_CLIENT_ID_CMB').select2({
					// 	dropdownParent: $('#POS_RESERVE_MODAL')
					// });
					HTTP_POPULATE_RESULT();		
				},
				true
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_REC_CLIENT_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_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_REC_CLIENT_STATUS', 2);

			JSCUS_SQL._RECORD._CLIENT.CUS_GET
			(
				GET_MAP_ARRAY,
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					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;
					}

					var JSON_COUNT = JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT");
					var CTR = 0;
					var COUNTER = 1;
					var TOTAL_SALES = 0;

					while(CTR < JSON_COUNT)
					{
						JSOC_CMB.VAR_ADD
						(
							"SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB",
							JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_ID", COUNTER),
							JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_FIRSTNAME", COUNTER) + " " + JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_LASTNAME", COUNTER)
						);


						CTR++;
						COUNTER++;
					}


					// JSOC_CMB.VAR_ADD_FROM_JSON
					// (
					// 	'SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB',
					// 	JSON_OBJECT,
					// 	'REC_CLIENT_ID',
					// 	'REC_CLIENT_LASTNAME',
					// 	true,
					// 	false
					// )

					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('#SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB').select2();
					HTTP_POPULATE_RESULT();	
				},
				true
			);

			/*JSCUS_SQL._RECORD._CLIENT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function()
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);*/
		}
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_ACCOUNT_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_POSRESERVE_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_POSRESERVE_ACC_ACCOUNT_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_ACC_ACCOUNT_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("POS_RESERVE_DGV_ROW_REC_POSRESERVE_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_POSRESERVE_ACC_ACCOUNT_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Member");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_POSRESERVE_ACC_ACCOUNT_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB", 0);
						$('#SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB').html($('#SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB option').sort(function (a, b) {
						    return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
						}));
						$('.BSSP_SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_RESERVE_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_POSRESERVE_ACC_ACCOUNT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_ACCOUNT_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_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_POSRESERVE_ACC_ACCOUNT_ID_CMB", 0);
					
					// Forward populate complete event.
					$('#SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB').html($('#SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB option').sort(function (a, b) {
						    return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
						}));
					$('.BSSP_SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}

		// Status		
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_POSRESERVE_STATUS_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "0","Any Status");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "1","Pending");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "2","Approved");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "999","Delivered");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "3","Cancelled");
			JSOC_CMB.VAR_ADD("SEARCH_REC_POSRESERVE_STATUS_CMB", "4","Collected");
			JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_STATUS_CMB", "1");
		}			
		
		
		// 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)
	{
		// Actual Function
		// _______________________________________________________________________
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		if(JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_DATE_CMB)) == 1)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DATE_RECORDED_FROM', JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_DATE_RECORDED_FROM_DTP"), "YYYY-MM-DD") + " 00:00:00.000000");
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DATE_RECORDED_TO', JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_DATE_RECORDED_TO_DTP"), "YYYY-MM-DD") + " 23:59:59.999999");
		}
		else
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DATE_EXPECTED_FROM', JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_DATE_RECORDED_FROM_DTP"), "YYYY-MM-DD") + " 00:00:00.000000");
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DATE_EXPECTED_TO', JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_DATE_RECORDED_TO_DTP"), "YYYY-MM-DD") + " 23:59:59.999999");
		}
		
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ACC_GROUP_ID', JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_ACC_GROUP_ID_CMB")));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ACC_ACCOUNT_ID', JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB")));

		if(JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_STATUS_CMB")) == 999)
		{
			STATUS_CHK = 1;
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_STATUS', 2);
		}
		else if(JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_STATUS_CMB")) == 2)
		{
			STATUS_CHK = 2
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_STATUS', 2);
		}
		else
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_STATUS', JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_STATUS_CMB")));

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_SKIP', SKIP);
		

		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_GET_ALL
		(
			GET_MAP_ARRAY,
			HTTP_SEARCH_CALLBACK,
			true
		); 		
	};
	
	function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
	{
		// Disable Dialogs
		// _______________________________________________________________________
		CUS_SEND_DIALOG_TRY_DISMISS();

		if (SKIP == 0)
			POS_RESERVE_DGV.ROW.CLEAR();
		
		// 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)
		{
			if (SKIP == 0)
				POS_RESERVE_DGV.ROW.CLEAR();
			return;
		}

		// Populate DGV
		// _______________________________________________________________________
		var JSON_COUNT = JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT");
		var COUNTER = 1;
		while(COUNTER <= JSON_COUNT)
		{
			if
			(
				STATUS_CHK == 0 ||
				(STATUS_CHK == 1 && JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_DECIMAL_B", COUNTER)) == 1) ||
				(STATUS_CHK == 2 && JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_DECIMAL_B", COUNTER)) == 0)
			)
			{
				var R_INDEX = 1; var IS_INSERTED = 0;
				while(POS_RESERVE_DGV.ROW.COUNT() >= R_INDEX)
				{
					if
					(
						JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ID", R_INDEX-1)) ==
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_REC_CLIENT_ID", COUNTER))
					)
					{
						IS_INSERTED = 1;
						if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_01", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_01", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						else if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID2
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_02", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_02", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						else if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID3
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_03", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_03", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						else if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID4
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_04", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_04", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						else if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID5
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_05", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_05", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						else if
						(
							JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
							STATIC_PROD_ID6
						)
						{
							POS_RESERVE_DGV.CELL.VALUE("PRODUCT_06", R_INDEX-1, JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("PRODUCT_06", R_INDEX-1)) + JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER)));
						}
						break;
					}
					R_INDEX++;
				}

				if(IS_INSERTED == 0)
				{
					var RINDEX = POS_RESERVE_DGV.ROW.COUNT();
					POS_RESERVE_DGV.ROW.INSERT_AT(RINDEX);
					POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ID", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_REC_CLIENT_ID", COUNTER));
					if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_01", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
					else if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID2
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_02", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
					else if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID3
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_03", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
					else if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID4
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_04", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
					else if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID5
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_05", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
					else if
					(
						JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID", COUNTER)) ==
						STATIC_PROD_ID6
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("PRODUCT_06", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", COUNTER));
					}
				}
			}
			
			COUNTER++;
		}

		if (JSON_COUNT == 1000)
		{
			SKIP = SKIP + 1000;
			HTTP_SEARCH();
		}
		else
		{
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_01");
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_02");
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_03");
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_04");
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_05");
			POS_RESERVE_DGV.COLUMN.CFORMAT("PRODUCT_06");

			POS_RESERVE_DGV.COLUMN.TOTAL_REFRESH();

			DGV_INDEX = 0;
			HTTP_CLIENT();
		}
	};

	function HTTP_CLIENT()
	{
		// Actual Function
		// _______________________________________________________________________
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CLIENT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_CLIENT_ID', JSVC_NUM.VAR_NVAL(POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ID", DGV_INDEX)));

		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._CLIENT.CUS_GET
		(
			GET_MAP_ARRAY,
			HTTP_CLIENT_CALLBACK,
			true
		); 		
	};

	function HTTP_CLIENT_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
	{
		// Disable Dialogs
		// _______________________________________________________________________
		CUS_SEND_DIALOG_TRY_DISMISS();
		
		// Validate
		// _______________________________________________________________________
		if(IS_SUCCESS === false)
		{
			console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
			DGV_INDEX++;
			if(POS_RESERVE_DGV.ROW.COUNT() - 1 > DGV_INDEX)
				HTTP_CLIENT();
			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);
			DGV_INDEX++;
			if(POS_RESERVE_DGV.ROW.COUNT() - 1 > DGV_INDEX)
				HTTP_CLIENT();
			return;
		}
		
		// JSON Empty (Clears the DataGrodView)
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
		{
			//POS_RESERVE_DGV.ROW.CLEAR();
			DGV_INDEX++;
			if(POS_RESERVE_DGV.ROW.COUNT() - 1 > DGV_INDEX)
				HTTP_CLIENT();
			return;
		}

		// Populate DGV
		// _______________________________________________________________________

		POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_CONTACT", DGV_INDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_CONTACT", 1));
		POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ADDRESS", DGV_INDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_ADDRESS", 1));
		POS_RESERVE_DGV.CELL.VALUE
		(
			"REC_CLIENT_NAME",
			DGV_INDEX,
			JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_FIRSTNAME", 1) + " " +
			JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CLIENT_LASTNAME", 1)
		);

		DGV_INDEX++;
		if(POS_RESERVE_DGV.ROW.COUNT() - 1 > DGV_INDEX)
				HTTP_CLIENT();
	};
	
	
	FORM_INITIALIZE();
	FORM_LOAD();