// 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;

		
		// 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");
			// 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
					// if(JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID) != 2)
					// {
					// 	document.getElementById("REC_POSRESERVE_ACC_GROUP_ID_CMB").setAttribute('disabled', true);
					// 	JSOC_CMB.VAR_SELECTED_VALUE("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("REC_POSRESERVE_ACC_GROUP_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					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
			);

			/*JSCUS_SQL._RECORD._CLIENT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function()
				{
					// 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);
						$('.BSSP_SEARCH_REC_POSRESERVE_REC_CLIENT_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_REC_CLIENT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_POSRESERVE_REC_CLIENT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);*/
		}
		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");
		}			
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("REC_POSRESERVE_STATUS_CMB");
			JSOC_CMB.VAR_ADD("REC_POSRESERVE_STATUS_CMB", "1","Pending");
			//JSOC_CMB.VAR_ADD("REC_POSRESERVE_STATUS_CMB", "2","Active");
			// JSOC_CMB.VAR_ADD("REC_POSRESERVE_STATUS_CMB", "3","Closed");
			// JSOC_CMB.VAR_ADD("REC_POSRESERVE_STATUS_CMB", "4","Completed");
			JSOC_CMB.VAR_SELECTED_VALUE("REC_POSRESERVE_STATUS_CMB", "1");
		}
		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("POS_RESERVE_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		/*if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_CODE_TXT"))
		{
			var SEARCH_REC_POSRESERVE_CODE_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_POSRESERVE_CODE_TXT");
			SEARCH_REC_POSRESERVE_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
		// _______________________________________________________________________
		GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		//  if(JSVC_VAR.VAR_ISSET("PROPERTY_PARENT_ID"))
		// {
		//	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', PROPERTY_PARENT_ID);
		// }  // Parent ID Sample
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_REC_CLIENT_ID', JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_REC_CLIENT_ID_CMB")));
		}
		
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_CODE_TXT") == true &&
			JSVC_STR.VAR_IS_BLANK( JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_CODE_TXT")) == false
		)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_CODE', JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_CODE_TXT"));
		}
		
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_REFERENCE_CODE_TXT") == true &&
			JSVC_STR.VAR_IS_BLANK( JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_REFERENCE_CODE_TXT")) == false
		)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_REFERENCE_CODE', JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_REFERENCE_CODE_TXT"));
		}

		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");
		}
		
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_AMOUNT_FROM_TXT") == true &&
			JSOC_STYLE.VAR_IS_VISIBLE('SEARCH_REC_POSRESERVE_AMOUNT_FROM_TXT') == true
		)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_AMOUNT_FROM', JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_AMOUNT_FROM_TXT")));
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_AMOUNT_TO_TXT") == true &&
			JSOC_STYLE.VAR_IS_VISIBLE('SEARCH_REC_POSRESERVE_AMOUNT_TO_TXT') == true
		)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_AMOUNT_TO', JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_AMOUNT_TO_TXT")));
		}			
		
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_REMARKS_TXT") == true &&
			JSVC_STR.VAR_IS_BLANK( JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_REMARKS_TXT")) == false
		)
		{
			//JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_REMARKS', JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_REMARKS_TXT"));
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_CODE', JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_POSRESERVE_REMARKS_TXT"));
		}
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_ACC_ACCOUNT_ID_CMB") == true)
		{
			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(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_POSRESERVE_STATUS_CMB") == true)
		// {
		// 	if(JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_POSRESERVE_STATUS_CMB")) == 999)
		// 	{
		// 		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DECIMAL_B_FROM', 1);
		// 		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DECIMAL_B_TO', 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)
		// 	{
		// 		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DECIMAL_B_FROM', 0);
		// 		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_DECIMAL_B_TO', 0);
		// 		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_REC_POSRESERVE_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_POSRESERVE_STATUS', 1);

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_ORDER_BY_CMB") == true)
		{
			var SELECTED_VAL = JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_ORDER_BY_CMB");
			if(JSVC_STR.VAR_CONTAINS_RIGHT(SELECTED_VAL, '_ASC'))
			{
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', JSVC_STR.VAR_DRIGHT(SELECTED_VAL, 4));
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC');		
			}
			else
			{
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', SELECTED_VAL);
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC');
			}
		}	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_LIMIT_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_LIMIT_CMB"));		
		}			
		
		var SELECTED_SEARCH_MODE = 0;
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_MODE_CMB") == true)
		{
			SELECTED_SEARCH_MODE = JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_MODE_CMB"));		
		}				
		
		
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// REGULAR Search Mode
		// _______________________________________________________________________
		if(SELECTED_SEARCH_MODE == 0)
		{			
			if(NEW_ITEM_ID < 0)
			{
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET
				(
					GET_MAP_ARRAY,
					HTTP_SEARCH_CALLBACK,
					true
				); 		
				POS_RESERVE_LAST_GET_MAP_ARRAY = GET_MAP_ARRAY;
				POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP']) + JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);			
			}
			else
			{		
				GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ID', NEW_ITEM_ID);
				
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET
				(
					GET_MAP_ARRAY,
					function(IS_SUCCESS, RESPONSE_STRING)
					{
						// Update Existing Row
						if(EDITED_ROW_INDEX >= 0)
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, EDITED_ROW_INDEX);
						}
						
						// Add new item
						else
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, 0);
						}
					},
					true
				); 		
			}
       	}
		
		
		// LITE Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 1)
		{
			if(NEW_ITEM_ID < 0)
			{
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_LITE
				(
					GET_MAP_ARRAY,
					HTTP_SEARCH_CALLBACK,
					true
				); 		
				POS_RESERVE_LAST_GET_MAP_ARRAY = GET_MAP_ARRAY;
				POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP']) + JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);		
			}
			else
			{		
				GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ID', NEW_ITEM_ID);
				
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_LITE
				(
					GET_MAP_ARRAY,
					function(IS_SUCCESS, RESPONSE_STRING)
					{
						// Update Existing Row
						if(EDITED_ROW_INDEX >= 0)
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, EDITED_ROW_INDEX);
						}
						
						// Add new item
						else
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, 0);
						}
					},
					true
				); 		
			}			
		}
		
		
		// ALL Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 2)
		{
			if(NEW_ITEM_ID < 0)
			{
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_ALL
				(
					GET_MAP_ARRAY,
					HTTP_SEARCH_CALLBACK,
					true
				); 		
				POS_RESERVE_LAST_GET_MAP_ARRAY = GET_MAP_ARRAY;
				POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP'] = JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_SKIP']) + JSVC_NUM.VAR_NVALL(POS_RESERVE_LAST_GET_MAP_ARRAY['PARAM_LIMIT']);		
			}
			else
			{		
				GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
				JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ID', NEW_ITEM_ID);
				
				JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_ALL
				(
					GET_MAP_ARRAY,
					function(IS_SUCCESS, RESPONSE_STRING)
					{
						// Update Existing Row
						if(EDITED_ROW_INDEX >= 0)
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, EDITED_ROW_INDEX);
						}
						
						// Add new item
						else
						{
							HTTP_SEARCH_LIMITED_ROWS_CALLBACK(IS_SUCCESS, RESPONSE_STRING, 0);
						}
					},
					true
				); 		
			}					
		}
	};
	
	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_SEARCH_LOAD_MORE()
	{
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_LIMIT_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_LIMIT_CMB"));		
		}	
		
		// REGULAR Search Mode
		// _______________________________________________________________________
		if(SELECTED_SEARCH_MODE == 0)
		{			
			JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_ALL
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 		
		}

		
		// LITE Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 1)
		{			
			JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_LITE
			(
				GET_MAP_ARRAY,
				HTTP_SEARCH_CALLBACK,
				true
			); 		
		}

		
		// ALL Search Mode
		// _______________________________________________________________________
		else if(SELECTED_SEARCH_MODE == 2)
		{			
			JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET_ALL
			(
				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_RESERVE_DGV.ROW.CLEAR();
			return;
		}

		// Populate DGV
		// _______________________________________________________________________
		POS_RESERVE_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1]
		);
		
		
		// For Applying CFormat
		// _______________________________________________________________________	
		POS_RESERVE_DGV.COLUMN.CFORMAT("REC_POSRESERVE_AMOUNT");
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
		var ROW_INDEX = 0;

		var STATUS;
		var MODE;
		var IS_DELIVERED;

		while(POS_RESERVE_DGV.ROW.COUNT() > ROW_INDEX)
		{
			STATUS = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_STATUS", ROW_INDEX + 1);
			IS_DELIVERED = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_DECIMAL_B", ROW_INDEX + 1);
			MODE = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LONG_A", ROW_INDEX + 1)

			if (STATUS == 1)
				POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Pending');
			else if (STATUS == 2 && IS_DELIVERED == 1)
				POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Delivered');
			else if (STATUS == 2)
				POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Approved');
			else if (STATUS == 3)
				POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Cancelled');
			else
				POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Collected');

			POS_RESERVE_DGV.CELL.VALUE
			(
				'REC_CLIENT_NAME',
				ROW_INDEX,
				POS_RESERVE_DGV.CELL.VALUE('REC_CLIENT_FIRSTNAME', ROW_INDEX) +
				' ' +
				POS_RESERVE_DGV.CELL.VALUE('REC_CLIENT_LASTNAME', ROW_INDEX)
			);

			HTTP_GET_RESERVED_ITEMS
			(
				JSVC_NUM.VAR_NVALL(POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_ID', ROW_INDEX)),
				ROW_INDEX,
				function(IS_SUCCESS, ROW_INDEX, RESPONSE_STRING)
				{
					if(IS_SUCCESS == true)
					{
						POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_ITEMS', ROW_INDEX, RESPONSE_STRING);
					}
				}
			);

			ROW_INDEX ++;
		}
	
	
		// DateTime Format
		// _______________________________________________________________________	
		if(POS_RESERVE_DGV.COLUMN.IS_EXISTS("REC_POSRESERVE_DATE_RECORDED"))
		{
			WEBTABLE_DATE = null;
			ROW_INDEX = 0;
			while(POS_RESERVE_DGV.ROW.COUNT() > ROW_INDEX)
			{
				// Read Current Value
				// ...........................................
				 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
					 (
							POS_RESERVE_DGV.CELL.VALUE
							(
									"REC_POSRESERVE_DATE_RECORDED", 
									ROW_INDEX
							)
					 );
				
				// Apply CFormat, and DateFormat
				// ...........................................
				if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
				{
					POS_RESERVE_DGV.CELL.VALUE
					(
							"REC_POSRESERVE_DATE_RECORDED", ROW_INDEX, 
							JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MM/DD/YY hh:mm TT")
					);

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

					POS_RESERVE_DGV.CELL.VALUE
					(
							"REC_POSRESERVE_DATE_EXPECTED_RAW", ROW_INDEX, 
							JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "YYYY-MM-DD HH:mm:ss") + '.999999'
					);				
				}			
				
				// Color Coding (Uncomment to use)
				// ...........................................	
				//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
				//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
				//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
				//POS_RESERVE_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_RESERVE_DGV.ROW.CLEAR();
			return;
		}

		// Validate Row Count
		// _______________________________________________________________________	
		if(POS_RESERVE_DGV.ROW.COUNT() <= 0)
		{
			console.error("DataGridView has no rows to fill.");
			return;
		}
		JSVC_AV.VAR_VALIDATE_RANGE(ROW_INDEX, "ROW_INDEX", 0, POS_RESERVE_DGV.ROW.COUNT() - 1);
		
		// Populate DGV
		// _______________________________________________________________________
		POS_RESERVE_DGV.POPULATE_FROM_QUERY
		(
				JSON_OBJECT, 
				'',
				false,
				false,
				1,
				[2, 1],
				ROW_INDEX
		);
		
		var STATUS = JSVC_NUM.VAR_NVALL(POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS', ROW_INDEX));
		var IS_DELIVERED = JSVC_NUM.VAR_NVALL(POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_DECIMAL_B', ROW_INDEX));

		if (STATUS == 1)
			POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Pending');
		else if (STATUS == 2 && IS_DELIVERED == 1)
			POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Delivered');
		else if (STATUS == 2)
			POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Approved');
		else if (STATUS == 3)
			POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Cancelled');
		else
			POS_RESERVE_DGV.CELL.VALUE('REC_POSRESERVE_STATUS_DESCRIPTION', ROW_INDEX, 'Collected');

		POS_RESERVE_DGV.CELL.VALUE
		(
			'REC_CLIENT_NAME',
			ROW_INDEX,
			POS_RESERVE_DGV.CELL.VALUE('REC_CLIENT_FIRSTNAME', ROW_INDEX) +
			' ' +
			POS_RESERVE_DGV.CELL.VALUE('REC_CLIENT_LASTNAME', ROW_INDEX)
		);
		
		// For Applying CFormat
		// _______________________________________________________________________	
		POS_RESERVE_DGV.COLUMN.CFORMAT("REC_POSRESERVE_AMOUNT");
		
		
		// Initialize
		// _______________________________________________________________________	
		var WEBTABLE_DATE = null;
	
	
		// DateTime Format
		// _______________________________________________________________________	
		if(POS_RESERVE_DGV.COLUMN.IS_EXISTS("REC_POSRESERVE_DATE_RECORDED"))
		{
			WEBTABLE_DATE = null;
			// Read Current Value
			// ...........................................
			 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				 (
						POS_RESERVE_DGV.CELL.VALUE
						(
								"REC_POSRESERVE_DATE_RECORDED", 
								ROW_INDEX
						)
				 );
			
			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				POS_RESERVE_DGV.CELL.VALUE
				(
						"REC_POSRESERVE_DATE_RECORDED", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			
			
			// Color Coding (Uncomment to use)
			// ...........................................	
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}
		if(POS_RESERVE_DGV.COLUMN.IS_EXISTS("REC_POSRESERVE_DATE_EXPECTED"))
		{
			WEBTABLE_DATE = null;
			// Read Current Value
			// ...........................................
			 WEBTABLE_DATE = JSVC_DATE.VAR_TO_DATE
				 (
						POS_RESERVE_DGV.CELL.VALUE
						(
								"REC_POSRESERVE_DATE_EXPECTED", 
								ROW_INDEX
						)
				 );
			
			// Apply CFormat, and DateFormat
			// ...........................................
			if(JSVC_VAR.VAR_ISSET(WEBTABLE_DATE))
			{
				POS_RESERVE_DGV.CELL.VALUE
				(
						"REC_POSRESERVE_DATE_EXPECTED", ROW_INDEX, 
						JSVC_DATE.VAR_FORMAT(WEBTABLE_DATE, "MMM DD, YYYY")
				);				
			}			
			
			// Color Coding (Uncomment to use)
			// ...........................................	
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//POS_RESERVE_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
		}

		if(IS_APPROVE == 1)
		{
			var CALLBACK_HANDLER = 
				function(IS_SUCCESS)
				{
					// Abort on failure
					if(IS_SUCCESS == false)
					{
						return;
					}
				
					// Show record saved messageBox
					JSVC_INFO.VAR_RECORD_SAVED('');
					SAMPLE_QUICK_SAVE2();
				}
			HTTP_SAVE_JO(CALLBACK_HANDLER);
		}
	};
	
	function HTTP_SEARCH_PRODUCT()
	{
		JSOC_CMB.VAR_CLEAR("REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB");
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSRESERVE_ACC_GROUP_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSRESERVE_ACC_GROUP_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_ACC_GROUP_ID_CMB)) < 0
			)
		)
		{
			return;
		}
		
		var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_ACC_GROUP_ID_CMB") == true)
		{
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_ACC_GROUP_ID', JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("REC_POSRESERVE_ACC_GROUP_ID_CMB")));
		}
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_CAT_PRICEMDL_ID', 1);

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'CAT_PRODUCT_DESCRIPTION');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC');

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

				JSOC_CMB.VAR_ADD_FROM_JSON
				(
					'REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB',
					JSON_OBJECT,
					'CAT_PRODUCT_ID',
					'CAT_PRODUCT_DESCRIPTION', 
					true,
					false
				)

				$('#REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB').select2({
					dropdownParent: $('#POS_RESERVE_MODAL')
				});
			},
			true
		); 
	}

	function HTTP_ADD_PRODUCT()
	{
		if(JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB)) <= 0)
		{
		 	return;
		}

		//check if product already added in dgv
		var ROW_INDEX = 0;
		var IS_INSERTED = false;

		// while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		// {
		// 	if(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", ROW_INDEX)) == JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB)))
		// 	{
		// 		IS_INSERTED = true;
		// 		break;
		// 	}

		// 	ROW_INDEX++;
		// }

		if(IS_INSERTED == false)
		{
			var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_CAT_PRODUCT_ID', JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB)));
			JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_ACC_GROUP_ID', JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_ACC_GROUP_ID_CMB)));
			

			var RESPONSE_HANDLER = 
				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)
					// _______________________________________________________________________
					var RINDEX = PRODUCT_BRANCH_DGV.ROW.COUNT();
					PRODUCT_BRANCH_DGV.ROW.INSERT_AT(RINDEX);
					PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", RINDEX, 0);
					PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", RINDEX, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB)));
					PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", RINDEX, JSOC_CMB.VAR_SELECTED_TEXT(REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB));
					PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", RINDEX, 1);
					PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_STATUS", RINDEX, 1);
					
					if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
					{
						PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", RINDEX, 0);
						PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", RINDEX, '');
					}
					else
					{
						PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODBRANCH_AMOUNT_PRICE", 1))));
						PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", RINDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", 1));
					}
				};

			JSOC_DIALOG.VAR_LOADING_SPINNER(true);
			JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_GET
			(
				GET_MAP_ARRAY,
				RESPONSE_HANDLER,
				true
			);
		}
		else
		{
			PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", ROW_INDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", ROW_INDEX)) + 1);
		}
	}

	function HTTP_GET_RESERVED_ITEMS(POSRESERVE_ID, ROW_INDEX, CALLBACK_METHOD)
	{
		var HTML = '';

		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_LIST_REC_POSRESERVE_ID', POSRESERVE_ID); 

		var RESPONSE_HANDLER = 			
			function(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)
				{
					CALLBACK_METHOD(false);
				}

				var INDEX = 1;
				var JSON_COUNT = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT"));

				while(JSON_COUNT >= INDEX)
				{
					HTML += JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_QTY", INDEX)) + " X " + JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", INDEX) + " Price:" + JSVC_NUM.VAR_CFORMAT(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_LIST_PRICE_BASE", INDEX)) + "<br>";

					INDEX++;
				}

				CALLBACK_METHOD(true, ROW_INDEX, HTML);
			};

		
		JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);	
	}
				
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();