


	function HTTP_LOAD_RES_LINE(CALLBACK_FUNCTION)
	{
		PRODUCT_BRANCH_DGV.ROW.CLEAR();

		var ROW_INDEX = 0;
		while(RES_LINE_HOLDER_DGV.ROW.COUNT() > ROW_INDEX)
		{
			if
			(
				(JSVC_NUM.VAR_NVALL(RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_REC_POSRESERVE_ID", ROW_INDEX)) ==
				PROPERTY_REC_POSRESERVE_ID) &&
				(JSVC_NUM.VAR_NVALL(RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", ROW_INDEX)) ==
				PROPERTY_LS_ID) &&
				(JSVC_NUM.VAR_NVALL(RES_LINE_HOLDER_DGV.CELL.VALUE("REC_IS_DELETED", ROW_INDEX)) == 0)
			)
			{
				var RINDEX = PRODUCT_BRANCH_DGV.ROW.COUNT();
				PRODUCT_BRANCH_DGV.ROW.INSERT_AT(RINDEX);
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_LS_ID", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_STATUS", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_STATUS", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", RINDEX, RES_LINE_HOLDER_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", ROW_INDEX));
				PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_INDEX", RINDEX, ROW_INDEX);
				

				PRODUCT_BRANCH_DGV.COLUMN.CFORMAT("REC_POSRESERVE_LIST_QTY");
				PRODUCT_BRANCH_DGV.COLUMN.CFORMAT("REC_POSRESERVE_LIST_PRICE_BASE");
			}
			
			ROW_INDEX++;
		}
	}

	function HTTP_LOAD_JO_LINE(CALLBACK_FUNCTION)
	{
		JOB_ORDER_TASK_DELIVER_DGV.ROW.CLEAR();
		JOB_ORDER_TASK_RETURN_DGV.ROW.CLEAR();

		var TOTAL_SALES = 0;
		var ROW_INDEX =  0;
		
		while(JO_LINE_HOLDER_DGV.ROW.COUNT() > ROW_INDEX)
		{
			if
			(
				(JSVC_NUM.VAR_NVALL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_LONG_A", ROW_INDEX)) ==
				PROPERTY_REC_JORDER_ID) &&
				(JSVC_NUM.VAR_NVALL(JO_LINE_HOLDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", ROW_INDEX)) ==
				PROPERTY_LS_ID) &&
				(JSVC_NUM.VAR_NVALL(JO_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", ROW_INDEX)) ==
				PROPERTY_LS_ID2)
			)
			{
				if(JSVC_NUM.VAR_NVALL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_A", ROW_INDEX)) == 1)
				{
					var RINDEX = JOB_ORDER_TASK_DELIVER_DGV.ROW.COUNT();
					JOB_ORDER_TASK_DELIVER_DGV.ROW.INSERT_AT(RINDEX);
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_ID", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_ID", ROW_INDEX));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", ROW_INDEX));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", ROW_INDEX));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", ROW_INDEX))));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", ROW_INDEX))));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX1", RINDEX, ROW_INDEX);
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_AMT_TARGET", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_AMT_TARGET", ROW_INDEX))));
				}
				else
				{
					var RINDEX = JOB_ORDER_TASK_RETURN_DGV.ROW.COUNT();
					JOB_ORDER_TASK_RETURN_DGV.ROW.INSERT_AT(RINDEX);
					JOB_ORDER_TASK_RETURN_DGV.CELL.VALUE("REC_JORDER_TASK_ID", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_ID", ROW_INDEX));
					JOB_ORDER_TASK_RETURN_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", ROW_INDEX));
					JOB_ORDER_TASK_RETURN_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", RINDEX, JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", ROW_INDEX));
					JOB_ORDER_TASK_RETURN_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", ROW_INDEX))));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL2", RINDEX, JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", ROW_INDEX))));
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX2", RINDEX, ROW_INDEX);
				}
			}
			
			ROW_INDEX++;
		}
	}

	function HTTP_RES_GROSS_CALL(CALLBACK_METHOD)
	{
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSRESERVE_REC_CLIENT_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSRESERVE_REC_CLIENT_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Client is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSRESERVE_REC_CLIENT_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSRESERVE_REC_CLIENT_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}

		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		// GROSS CALL
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._GROSS_CALL.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_REC_CLIENT_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_DATE", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_REMARKS", JSOC_ELEMENT.VAR_VALUE('REC_POSRESERVE_REMARKS_TXT'));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_STATUS", 2);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_ID_FILE", '');

		if(getValue('GROSS_CTR_HOLDER') === null)
			createItem('GROSS_CTR_HOLDER', 1);

		var CTR;

		if(getValue('GROSS_CTR') === null)
			CTR = 1;
		else
			CTR = JSVC_NUM.VAR_NVALL(getValue('GROSS_CTR')) + 1;

		createItem('GROSS_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		createItem('GROSS_CTR', CTR);

		UNPRO_GROSSCALL += 1;
		JSOC_ELEMENT.VAR_VALUE("GROSS_CALL_LBL", "Unproductive Call : " + UNPRO_GROSSCALL);

		CUS_SEND_DIALOG_TRY_DISMISS();

		NTBSYNC();

		EDIT_HANDLER.REF_IS_MODIFIED = false;
		EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;
			
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('POS_RESERVE_NEW_MODAL') == true)
			JSOC_DIALOG.VAR_MODAL('POS_RESERVE_NEW_MODAL', false);
		
		CALLBACK_METHOD(true);	
	}

	function HTTP_RES_SAVE(CALLBACK_METHOD)
	{
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSRESERVE_REC_CLIENT_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSRESERVE_REC_CLIENT_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Client is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSRESERVE_REC_CLIENT_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSRESERVE_REC_CLIENT_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if
		(
			PRODUCT_BRANCH_DGV.ROW.COUNT() <= 0
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'You must add atleast One (1) product.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		
		// Validate Duplicates
		// _______________________________________________________________________
		var EXCEPTION_ROW_INDEX = -1;
		if(PROPERTY_REC_POSRESERVE_ID >= 0)
		{
			EXCEPTION_ROW_INDEX = PROPERTY_EDIT_ROW_INDEX;
		}
		
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		// RESERVATION
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_ID", PROPERTY_REC_POSRESERVE_ID);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_REC_CLIENT_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_REFERENCE_CODE", JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_REFERENCE_CODE_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_DATE_EXPECTED", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_DATE_EXPECTED_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_REMARKS", JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_REMARKS_TXT));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LONG_A", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_LONG_A_CMB))); // Mode of Payment 2-Cash, 3-Credit
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LONG_B", 0);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_DECIMAL_A", 0);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_DECIMAL_B", 0);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_VARCHAR_A", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_VARCHAR_B", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_ID_FILE", '');

		if(IS_APPROVE == 0)
		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_STATUS", 1);
		else
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_STATUS", 2);

		if(getValue('RES_CTR_HOLDER') === null)
		{
			createItem('RES_SAVE_HOLDER', 1);
			createItem('RES_CTR_HOLDER', 1);
		}

		var CTR;
		if(PROPERTY_LS_ID > 0)
		{
			CTR = PROPERTY_LS_ID;
			createItem('RES_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		}
		else
		{
			if(getValue('RES_CTR') === null)
				CTR = 1;
			else
				CTR = JSVC_NUM.VAR_NVALL(getValue('RES_CTR')) + 1;

			createItem('RES_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			createItem('RES_CTR', CTR);
		}
		CUS_SEND_DIALOG_TRY_DISMISS();
		NTBSYNC();

		// RESERVATION LINE
		HTTP_RES_SAVE_LINE(CALLBACK_METHOD, CTR);
	}

	function HTTP_RES_SAVE_LINE(CALLBACK_METHOD, PARENT_ID_HOLDER)
	{
		// LUKAL STURIDZ
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		TOTAL_AMOUNT = 0;

		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];
		var ROW_INDEX = 0;
		while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		{
			TOTAL_AMOUNT += (JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", ROW_INDEX)) * JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", ROW_INDEX)))

			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_ID", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_ID',ROW_INDEX)));			
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_REC_POSRESERVE_ID", 0);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_CAT_DISCOUNT_ID", 1); //DEFAULT WALA PA MUNA DISCOUNT
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_PRICE_EXPECT",
				JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',ROW_INDEX)) *
				JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX))
				);	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_PRICE_BASE", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',ROW_INDEX)));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_QTY", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_STATUS", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_STATUS',ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_ID_FILE", '');
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			ROW_INDEX++;
		}
		
		var CTR = 0;
		var ARRAY_INDEX = 0;

		while(BUNDLE_MAP_ARRAY.length > ARRAY_INDEX)
		{
			createItem(PARENT_ID_HOLDER + 'RES_LINE_BUNDLE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
			CTR++;
			ARRAY_INDEX++;
		}

		//SAVE ONLY
		if(IS_APPROVE == 0)
		{
			if(PROPERTY_REC_POSRESERVE_ID > 0 || PROPERTY_LS_ID > 0)
			{
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ID", PROPERTY_EDIT_ROW_INDEX, PROPERTY_REC_POSRESERVE_ID);
				POS_RESERVE_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", PROPERTY_EDIT_ROW_INDEX, PARENT_ID_HOLDER);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ACC_GROUP_ID", PROPERTY_EDIT_ROW_INDEX, JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
				POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ID", PROPERTY_EDIT_ROW_INDEX, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
				POS_RESERVE_DGV.CELL.VALUE("ACC_GROUP_DESCRIPTION", PROPERTY_EDIT_ROW_INDEX, JSCUS_SQL._ACCOUNT._LOGIN.ACC_GROUP_DESCRIPTION);

				//USE CUS_HOLDER
				var ROW_INDEX = 1;
				var CTR = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "JSON_COUNT"));
				while(ROW_INDEX <= CTR)
				{
					if
					(
						JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)) ==
						JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ID", ROW_INDEX))
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_FIRSTNAME", PROPERTY_EDIT_ROW_INDEX, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_LASTNAME", PROPERTY_EDIT_ROW_INDEX, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_NAME", PROPERTY_EDIT_ROW_INDEX, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX) + ' ' + JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ADDRESS", PROPERTY_EDIT_ROW_INDEX, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ADDRESS", ROW_INDEX));
						break;
					}
					ROW_INDEX++;
				}

				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_RECORDED", PROPERTY_EDIT_ROW_INDEX, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "MMM DD, YYYY hh:mm tt"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_RECORDED_RAW", PROPERTY_EDIT_ROW_INDEX, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_EXPECTED", PROPERTY_EDIT_ROW_INDEX, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_REMARKS", PROPERTY_EDIT_ROW_INDEX, JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_REMARKS_TXT));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ACC_ACCOUNT_ID", PROPERTY_EDIT_ROW_INDEX, JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_LONG_A", PROPERTY_EDIT_ROW_INDEX, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_LONG_A_CMB))); // Mode of Payment 2-Cash, 3-Credit
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_STATUS", PROPERTY_EDIT_ROW_INDEX, 1);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_STATUS_DESCRIPTION", PROPERTY_EDIT_ROW_INDEX, 'Pending');

				//dpt lalagyan mo dn ls id yung holder
				ROW_INDEX = 0;
				while(RES_LINE_HOLDER_DGV.ROW.COUNT() > ROW_INDEX)
				{
					if
					(
						(JSVC_NUM.VAR_NVALL(RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_REC_POSRESERVE_ID", ROW_INDEX)) ==
						PROPERTY_REC_POSRESERVE_ID) &&
						(JSVC_NUM.VAR_NVALL(RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", ROW_INDEX)) ==
						PROPERTY_LS_ID)
					)
					{
						RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", ROW_INDEX, PARENT_ID_HOLDER);
					}
					ROW_INDEX++;
				}

				ROW_INDEX = 0;
				while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
				{
					if
					(
						(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", ROW_INDEX)) > 0) ||
						(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_LS_ID", ROW_INDEX)) > 0)
					)
					{
						//UPDATE HOLDER QTY AND PRICE
						RES_LINE_HOLDER_DGV.CELL.VALUE
						(
							"REC_POSRESERVE_LIST_QTY",
							JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_INDEX", ROW_INDEX)),
							JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", ROW_INDEX))
						);
						RES_LINE_HOLDER_DGV.CELL.VALUE
						(
							"REC_POSRESERVE_LIST_PRICE_BASE",
							JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_INDEX", ROW_INDEX)),
							JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", ROW_INDEX))
						);
					}

					if
					(
						(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", ROW_INDEX)) == 0) &&
						(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE("REC_LS_ID", ROW_INDEX)) == 0)
					)
					{
						var RINDEX = RES_LINE_HOLDER_DGV.ROW.COUNT();
						RES_LINE_HOLDER_DGV.ROW.INSERT_AT(RINDEX);
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", RINDEX, 0);
						RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", RINDEX, PARENT_ID_HOLDER);
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_REC_POSRESERVE_ID", RINDEX, PROPERTY_REC_POSRESERVE_ID);
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',ROW_INDEX)));
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION',ROW_INDEX));
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',ROW_INDEX)));
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_STATUS", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_STATUS',ROW_INDEX)));
						RES_LINE_HOLDER_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION',ROW_INDEX));
						RES_LINE_HOLDER_DGV.CELL.VALUE("REC_IS_DELETED", RINDEX, 0);
					}
					ROW_INDEX++;
				}
			}
			else
			{
				POS_RESERVE_DGV.ROW.INSERT_AT(0);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ID", 0, 0);
				POS_RESERVE_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", 0, PARENT_ID_HOLDER);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ACC_GROUP_ID", 0, JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
				POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ID", 0, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
				POS_RESERVE_DGV.CELL.VALUE("ACC_GROUP_DESCRIPTION", 0, JSCUS_SQL._ACCOUNT._LOGIN.ACC_GROUP_DESCRIPTION);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_CODE", 0, 'Offline Rec - ' + PARENT_ID_HOLDER); //auto generate ng system pano kaya ito?

				//USE CUS_HOLDER
				var ROW_INDEX = 1;
				var CTR = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "JSON_COUNT"));
				while(ROW_INDEX <= CTR)
				{
					if
					(
						JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)) ==
						JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ID", ROW_INDEX))
					)
					{
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_FIRSTNAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_LASTNAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_NAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX) + ' ' + JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
						POS_RESERVE_DGV.CELL.VALUE("REC_CLIENT_ADDRESS", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ADDRESS", ROW_INDEX));
						break;
					}
					ROW_INDEX++;
				}

				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_REFERENCE_CODE", 0, '');
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_RECORDED", 0, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "MMM DD, YYYY hh:mm tt"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_RECORDED_RAW", 0, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_DATE_EXPECTED", 0, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_AMOUNT", 0, 0); //
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_REMARKS", 0, JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_REMARKS_TXT));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_ACC_ACCOUNT_ID", 0, JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID));
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_STATUS", 0, 1);
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_STATUS_DESCRIPTION", 0, 'Pending');
				POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_LONG_A", 0, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_LONG_A_CMB))); // Mode of Payment 2-Cash, 3-Credit


				//ADD DIN SA HOLDER
				ROW_INDEX = 0;
				while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
				{
					var RINDEX = RES_LINE_HOLDER_DGV.ROW.COUNT();
					RES_LINE_HOLDER_DGV.ROW.INSERT_AT(RINDEX);
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_ID", RINDEX, 0);
					RES_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", RINDEX, PARENT_ID_HOLDER);
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_REC_POSRESERVE_ID", RINDEX, PROPERTY_REC_POSRESERVE_ID);
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',ROW_INDEX)));
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION',ROW_INDEX));
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_QTY", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_PRICE_BASE", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',ROW_INDEX)));
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_POSRESERVE_LIST_STATUS", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_STATUS',ROW_INDEX)));
					RES_LINE_HOLDER_DGV.CELL.VALUE("CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION',ROW_INDEX));
					RES_LINE_HOLDER_DGV.CELL.VALUE("REC_IS_DELETED", RINDEX, 0);

					ROW_INDEX++;
				}
			}
			CUS_SEND_DIALOG_TRY_DISMISS();

			// Lift edit and Exit EditMode
			EDIT_HANDLER.REF_IS_MODIFIED = false;
			EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;	

			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('POS_RESERVE_NEW_MODAL') == true)
				JSOC_DIALOG.VAR_MODAL('POS_RESERVE_NEW_MODAL', false);
			
			//SWAP_EDIT_MODE(false);
			CALLBACK_METHOD(true);
		}
		else
		{
			CUS_SEND_DIALOG_TRY_DISMISS();
			if(PROPERTY_EDIT_ROW_INDEX > -1)
				POS_RESERVE_DGV.ROW.DISPLAY(PROPERTY_EDIT_ROW_INDEX, "none");

			HTTP_RES_SAVE_JO(CALLBACK_METHOD, PARENT_ID_HOLDER);
		}
	}

	function HTTP_RES_SAVE_JO(CALLBACK_METHOD, PARENT_ID_HOLDER)
	{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_REC_CLIENT_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_REFERENCE_NUMBER", ''); // AUTO GENERATE KASI
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_DESCRIPTION", JSCUS_SQL._ACCOUNT._LOGIN.ACC_GROUP_DESCRIPTION);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_AMOUNT", TOTAL_AMOUNT);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_REMARKS", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_REMARKS_ASSIGN", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_USER_ASSIGN", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID)); // Hub ID
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_FOR_COMPLETION", 1);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_LONG_A", 0); // Reservation ID (Extra reference) //UPDATE LANG PAG MAG SYNC NA
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_LONG_B", 0); // Reserve column for cashier. If paid change value to 1
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_DECIMAL_A", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_LONG_A_CMB))); // Reserve column for mode of payment
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_DECIMAL_B", 0); // Reserve for Sales ID
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_VARCHAR_A", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_VARCHAR_B", '');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_DATETIME_A", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss"));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_DATETIME_B", '1000-01-01 01:00:00.000000');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_STATUS", IS_JO_STATUS);
		
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_DATE", JSVC_DATE.VAR_NOW());
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ID_FILE", '');

		createItem(PARENT_ID_HOLDER + 'RES_JO_SAVE_MAP_ARRAY', JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		CUS_SEND_DIALOG_TRY_DISMISS();

		// RESERVATION LINE
		HTTP_RES_SAVE_JO_LINE(CALLBACK_METHOD, PARENT_ID_HOLDER);
	}

	function HTTP_RES_SAVE_JO_LINE(CALLBACK_METHOD, PARENT_ID_HOLDER)
	{
		// LUKAL STURIDZ
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Create Deliver Line
		var ROW_INDEX = 0;
		while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		{
		 	SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_LONG_A", 0); // Parent ID
		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_LONG_B", 0); // Line ID (Maybe usefull in future)
		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DESCRIPTION", PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION', ROW_INDEX));
		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_REMARKS", 'To be delivered');
		 	JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_TARGET", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_ACTUAL", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_AMT_TARGET", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_AMT_ACTUAL", 0);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DECIMAL_A", 1); // 1 for delivery
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DECIMAL_B", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID', ROW_INDEX))); // PRODUCT ID
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_VARCHAR_A", PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION', ROW_INDEX)); //UOM
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_VARCHAR_B", ''); 
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DATETIME_A", '1000-01-01 01:00:00.000000');
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DATETIME_B", '1000-01-01 01:00:00.000000');
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_STATUS", 2); // 2 - default.
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID_FILE", '');

			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

		 	ROW_INDEX++;
		}

		// Create Return Line
		ROW_INDEX = 0;
		while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		{
			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_LONG_A", 0); // Parent ID
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_LONG_B", 0); // Line ID (Maybe usefull in future)
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DESCRIPTION", PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION', ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_REMARKS", 'To be delivered');
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_TARGET", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_ACTUAL", 0);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_AMT_TARGET", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_AMT_ACTUAL", 0);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DECIMAL_A", 2); // 1 for return
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DECIMAL_B", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID', ROW_INDEX))); // PRODUCT ID
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_VARCHAR_A", PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODUCT_CAT_UOM_ID_DESCRIPTION', ROW_INDEX)); //UOM
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_VARCHAR_B", ''); 
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DATETIME_A", '1000-01-01 01:00:00.000000');
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_DATETIME_B", '1000-01-01 01:00:00.000000');
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_STATUS", 2); // 2 - default.
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID_FILE", '');

			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			ROW_INDEX++;
		}

		var CTR = 0;
		var ARRAY_INDEX = 0;

		while(BUNDLE_MAP_ARRAY.length > ARRAY_INDEX)
		{
			createItem(PARENT_ID_HOLDER + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
			CTR++;
			ARRAY_INDEX++;
		}

		//ADD SA JO DGV
		JOB_ORDER_DGV.ROW.INSERT_AT(0);
		JOB_ORDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", 0, 0);
		JOB_ORDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", 0, PARENT_ID_HOLDER);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_ID", 0, 0);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_ACC_GROUP_ID", 0, JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ACC_GROUP_ID));
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_REC_CLIENT_ID", 0, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)));
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_ACC_GROUP_ID_DESCRIPTION", 0, JSCUS_SQL._ACCOUNT._LOGIN.ACC_GROUP_DESCRIPTION);

		if(PROPERTY_EDIT_ROW_INDEX > -1)
			JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_REFERENCE_NUMBER", 0, POS_RESERVE_DGV.CELL.VALUE("REC_POSRESERVE_CODE", PROPERTY_EDIT_ROW_INDEX));
		else
			JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_REFERENCE_NUMBER", 0, 'Offline Rec - ' + PARENT_ID_HOLDER);

		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_DESCRIPTION", 0, JSCUS_SQL._ACCOUNT._LOGIN.ACC_GROUP_DESCRIPTION);

		//USE CUS_HOLDER
		var ROW_INDEX = 1;
		var CTR = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "JSON_COUNT"));
		while(ROW_INDEX <= CTR)
		{
			if
			(
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_REC_CLIENT_ID_CMB)) ==
				JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ID", ROW_INDEX))
			)
			{
				JOB_ORDER_DGV.CELL.VALUE("REC_CLIENT_FIRSTNAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX));
				JOB_ORDER_DGV.CELL.VALUE("REC_CLIENT_LASTNAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
				JOB_ORDER_DGV.CELL.VALUE("REC_CLIENT_NAME", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_FIRSTNAME", ROW_INDEX) + ' ' + JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_LASTNAME", ROW_INDEX));
				JOB_ORDER_DGV.CELL.VALUE("REC_CLIENT_ADDRESS", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_ADDRESS", ROW_INDEX));
				JOB_ORDER_DGV.CELL.VALUE("REC_CLIENT_CONTACT", 0, JSRC_JSON.REF_READ(CUS_HOLDER, "REC_CLIENT_CONTACT", ROW_INDEX));
				break;
			}
			ROW_INDEX++;
		}

		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_AMOUNT", 0, TOTAL_AMOUNT);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_DATE_COMPLETE", 0, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "MMM DD, YYYY hh:mm tt"));
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_FOR_COMPLETION", 0, 1);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_STATUS", 0, 2);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_STATUS_TEXT", 0, 'Approve');
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_LONG_A", 0, 0);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_LONG_B", 0, 0);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_DECIMAL_A", 0, JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSRESERVE_LONG_A_CMB))); // Reserve column for mode of payment


		//JO LINE HOLDER
		var RINDEX = JO_LINE_HOLDER_DGV.ROW.COUNT();
		ROW_INDEX = 0;
		while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		{
			JO_LINE_HOLDER_DGV.ROW.INSERT_AT(RINDEX);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_ID", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_LONG_A", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", RINDEX, PARENT_ID_HOLDER);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION',ROW_INDEX));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_A", RINDEX, 1); // Delivery
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_AMT_TARGET", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',ROW_INDEX)));
			

			RINDEX++;
			
			JO_LINE_HOLDER_DGV.ROW.INSERT_AT(RINDEX);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_ID", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_LONG_A", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("RES_LOCAL_STORAGE_ID", RINDEX, PARENT_ID_HOLDER);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_B", RINDEX, JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DESCRIPTION", RINDEX, PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID_DESCRIPTION',ROW_INDEX));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_TARGET", RINDEX, JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", RINDEX, 0);
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_DECIMAL_A", RINDEX, 2); // Return

			ROW_INDEX++;
			RINDEX++;
		}
		CUS_SEND_DIALOG_TRY_DISMISS();

		EDIT_HANDLER.REF_IS_MODIFIED = false;
		EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('POS_RESERVE_NEW_MODAL') == true)
		{
			JSOC_DIALOG.VAR_MODAL('POS_RESERVE_NEW_MODAL', false);
		}

		if(IS_PROCESSING == 1)
			JOB_ORDER_DGV.CELL.ELEMENT(1, 0).onclick();
		else
			//SWAP_EDIT_MODE(false);
			CALLBACK_METHOD(true);
	}

	function HTTP_JO_SAVE(CALLBACK_METHOD)
	{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ID", PROPERTY_REC_JORDER_ID);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_STATUS", IS_JO_STATUS);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_GROSSCALL_DATE", JSVC_DATE.VAR_NOW());
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ID_FILE", '');

		var ROW_INDEX = 0;
		var TOTAL = 0;
		while(JOB_ORDER_TASK_DELIVER_DGV.ROW.COUNT() > ROW_INDEX)
		{
			TOTAL += (JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)) * JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_AMT_TARGET', ROW_INDEX)));
			ROW_INDEX++;
		}
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_AMOUNT", TOTAL);
		JOB_ORDER_DGV.CELL.VALUE("REC_JORDER_AMOUNT", PROPERTY_EDIT_ROW_INDEX, TOTAL);

		var IS_OFFLINE;
		if(PROPERTY_REC_JORDER_ID > 0)
		{
			IS_OFFLINE = false;
			var CTR;

			if(getValue('RES_CTR_HOLDER') === null)
			{
				createItem('JO_SAVE_HOLDER', 1);
				createItem('JO_CTR_HOLDER', 1);
			}

			if(PROPERTY_LS_ID > 0)
			{
				CTR = PROPERTY_LS_ID;
				createItem('JO_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			}
			else
			{
				if(getValue('JO_CTR') === null)
				{
					CTR = 1;
				}
				else
					CTR = JSVC_NUM.VAR_NVALL(getValue('JO_CTR')) + 1;

				createItem('JO_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
				createItem('JO_CTR', CTR);
			}
		}
		else
		{
			IS_OFFLINE = true;
			var CTR = PROPERTY_LS_ID2;
			createItem(CTR + 'JO_SAVE_MAP_ARRAYX', JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		}
		
		CUS_SEND_DIALOG_TRY_DISMISS();
		NTBSYNC();

		HTTP_JO_SAVE_LINE(CALLBACK_METHOD, CTR, IS_OFFLINE);
	}

	function HTTP_JO_SAVE_LINE(CALLBACK_METHOD, PARENT_ID_HOLDER, IS_OFFLINE)
	{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];
		var IS_REB = false;
		REB_STOCKIN_QTY = 0;
		REB_STOCKIN_QTY2 = 0;
		TOTAL_OUT = 0;

		// Create Deliver Line
		var ROW_INDEX = 0;
		var BUNDLE_CTR = 0;
		while(JOB_ORDER_TASK_DELIVER_DGV.ROW.COUNT() > ROW_INDEX)
		{
			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID",JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_ID', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_ACTUAL", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID_FILE", '');

			// Compute new inventory for 5 Gallons
			if(STATIC_PROD_ID == JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DECIMAL_B', ROW_INDEX)))
				TOTAL_OUT += JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX));
			
			// Compute new inventory for all items
			DEDUCT_QUANTITY
			(
				JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DECIMAL_B', ROW_INDEX)).toString(), 
				JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)
			);
			
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			if(IS_OFFLINE == true)
			{
				var SAVE_MAP_ARRAY2 = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(PARENT_ID_HOLDER + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + BUNDLE_CTR));
				SAVE_MAP_ARRAY2['PARAM_REC_JORDER_TASK_QTY_ACTUAL'] = JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX));
				createItem(PARENT_ID_HOLDER + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + BUNDLE_CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY2));
				BUNDLE_CTR++;
			}

			ROW_INDEX++;
		}

		// Create Return Line
		ROW_INDEX = 0;
		while(JOB_ORDER_TASK_RETURN_DGV.ROW.COUNT() > ROW_INDEX)
		{
			if
			(
				JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX)) > 0 &&
				JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DECIMAL_B', ROW_INDEX)) == STATIC_PROD_ID
			)
			{
				IS_REB = true;
				REB_STOCKIN_QTY += JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX));
			}

			if
			(
				JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX)) > 0 &&
				JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DECIMAL_B', ROW_INDEX)) == STATIC_PROD_ID2
			)
			{
				IS_REB = true;
				REB_STOCKIN_QTY2 += JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX));
			}

			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_RETURN_DGV.CELL.VALUE('REC_JORDER_TASK_ID', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_QTY_ACTUAL", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX)));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_TASK_ID_FILE", '');
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			if(IS_OFFLINE == true)
			{
				var SAVE_MAP_ARRAY2 = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(PARENT_ID_HOLDER + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + BUNDLE_CTR));
				SAVE_MAP_ARRAY2['PARAM_REC_JORDER_TASK_QTY_ACTUAL'] = JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX));
				createItem(PARENT_ID_HOLDER + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + BUNDLE_CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY2));
				BUNDLE_CTR++;
			}

			ROW_INDEX++;
		}

		var CTR = 0;
		var ARRAY_INDEX = 0;

		if(IS_OFFLINE == false)
		{		
			while(BUNDLE_MAP_ARRAY.length > ARRAY_INDEX)
			{
				createItem(PARENT_ID_HOLDER + 'JO_LINE_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
				
				ARRAY_INDEX++;
				CTR++;
			}
		}

		//JO DGV
		if(IS_OFFLINE == false)
			JOB_ORDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", PROPERTY_EDIT_ROW_INDEX, PARENT_ID_HOLDER);

		//JO LINE HOLDER
		ROW_INDEX = 0;
		while(JOB_ORDER_TASK_DELIVER_DGV.ROW.COUNT() > ROW_INDEX)
		{
			if(IS_OFFLINE == false)
			{
				JO_LINE_HOLDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX1", ROW_INDEX)), PARENT_ID_HOLDER);
				JO_LINE_HOLDER_DGV.CELL.VALUE("JO_LOCAL_STORAGE_ID", JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX2", ROW_INDEX)), PARENT_ID_HOLDER);
			}

			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX1", ROW_INDEX)), JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", ROW_INDEX)));
			JO_LINE_HOLDER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL", JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_INDEX2", ROW_INDEX)), JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE("REC_JORDER_TASK_QTY_ACTUAL2", ROW_INDEX)));

			ROW_INDEX++;
		}
		
		CUS_SEND_DIALOG_TRY_DISMISS();

		if(IS_JO_STATUS == 4)
		{
			JOB_ORDER_DGV.ROW.DISPLAY(PROPERTY_EDIT_ROW_INDEX, "none");
			JO_DELIVERED_RECEIPT = '';

			//FORMAT RECEIPT
			JO_DELIVERED_RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: center;">Williams Water</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td></td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Customer '+JSOC_ELEMENT.VAR_VALUE("REC_JORDER_REC_CLIENT_LBL")+'</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Agent: '+JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_NAME+'</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Date: '+JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss")+'</td></tr>';
			JO_DELIVERED_RECEIPT += '</table>';

			JO_DELIVERED_RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			JO_DELIVERED_RECEIPT += '<tr><th style="text-align: left;">Item</th> <th style="text-align: right;">Qty</th> <th style="text-align: right;">Price</th> <th style="text-align: right;">Sub-Total</th></tr>';

			ROW_INDEX = 0;
			while(JOB_ORDER_TASK_DELIVER_DGV.ROW.COUNT() > ROW_INDEX)
			{
				JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">'+JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DESCRIPTION', ROW_INDEX)+'</td></tr>';
				JO_DELIVERED_RECEIPT += '<tr><td></td>';
				JO_DELIVERED_RECEIPT += '<td style="text-align: right;">'+JSVC_NUM.VAR_NVALL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX))+'</td>';
				JO_DELIVERED_RECEIPT += '<td style="text-align: right;">'+JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_AMT_TARGET', ROW_INDEX)+'</td>';

				var Sub = 0;
				Sub = JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)) *
					JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_AMT_TARGET', ROW_INDEX));

				JO_DELIVERED_RECEIPT += '<td style="text-align: right;">'+JSVC_NUM.VAR_CFORMAT(Sub)+'</td></tr>';

				ROW_INDEX++;
			}

			JO_DELIVERED_RECEIPT += '<tr><td></td><td></td><td></td>';
			JO_DELIVERED_RECEIPT += '<td style="text-align: right;">Total : '+JSOC_ELEMENT.VAR_VALUE("TOTAL_AMOUNT")+'</td></tr>';
			JO_DELIVERED_RECEIPT += '</table>';

			JO_DELIVERED_RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Williams Water Call Center Hotline</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Call: 0919-068-2765 or 0917-170-9327</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: left;">Text: 0908-812-2138</td></tr>';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: center;">!!! THANK YOU !!!</td></tr></table>';

			JO_DELIVERED_RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: center;">.</td></tr></table>';
			JO_DELIVERED_RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			JO_DELIVERED_RECEIPT += '<tr><td style="text-align: center;">.</td></tr></table>';

			//if(IS_REB == true)
			//{
			//	HTTP_JO_CUSTOMER_INV_SAVE_TO_LOCAL_STORAGE(CALLBACK_METHOD, PARENT_ID_HOLDER, IS_OFFLINE);
			//}
			//else
			//{
				HTTP_JO_REB_STOCKIN(CALLBACK_METHOD, PARENT_ID_HOLDER, IS_OFFLINE);
			//}			
		}
		else
		{
			// Lift edit and Exit EditMode
			EDIT_HANDLER.REF_IS_MODIFIED = false;
			EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;	

			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('JOB_ORDER_MODAL') == true)
				JSOC_DIALOG.VAR_MODAL('JOB_ORDER_MODAL', false);
			
			//SWAP_EDIT_MODE(false);
			CALLBACK_METHOD(true);
		}
	}
	

	function HTTP_JO_REB_STOCKIN
	(
		CALLBACK_METHOD, PARENT_ID_HOLDER, IS_OFFLINE
	)
	{
		// Show loading dialog
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);


		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];
		var CURRENT_ITEM_ID = 0;
		var CURRENT_REB_DIFFERENCE = 0;
		var ROW_INDEX = 0;

		while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
		{
			// Get Item ID
			CURRENT_ITEM_ID = JSVC_NUM.VAR_NVALL
			(
				JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_DECIMAL_B', ROW_INDEX)
			);
			
			// Returned Empty Bottles
			if
			(
				CURRENT_ITEM_ID == STATIC_PROD_RET_ID ||
				CURRENT_ITEM_ID == STATIC_PROD_RET_ID2
			)
			{
				// Add to Truck
				// ...........................................
				SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
	
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STORAGE_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(SEARCH_CAT_STORAGE_ID_CMB)));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_PRODUCT_ID", CURRENT_ITEM_ID);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID", 14);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_QUANTITY", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX)));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_REMARKS", "");
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_STATUS", 2);
	
				BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

				// Check Difference
				// ...........................................
				CURRENT_REB_DIFFERENCE = 
				JSVC_NUM.VAR_NVAL
				(
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)
				) - 
				JSVC_NUM.VAR_NVAL
				(
					JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL2', ROW_INDEX)
				);
				
				if(CURRENT_REB_DIFFERENCE !== 0)
				{
					HTTP_JO_CUSTOMER_INV_SAVE_TO_LOCAL_STORAGE(CURRENT_ITEM_ID, CURRENT_REB_DIFFERENCE);
				}
			}
			
			// JO Sold Items
			else
			{
				// Deduct from Truck
				// ...........................................
				SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
	
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STORAGE_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(SEARCH_CAT_STORAGE_ID_CMB)));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_PRODUCT_ID", CURRENT_ITEM_ID);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID", 53);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_QUANTITY", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_REMARKS", "");
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_STATUS", 2);
	
				BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
				
				
				// Add to store
				// ...........................................
				SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
	
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STORAGE_ID", JSVC_NUM.VAR_NVALL(PROPERTY_REC_STORAGE_ID));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_PRODUCT_ID", CURRENT_ITEM_ID);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_CAT_STOCKFLOW_ID", 54);
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_QUANTITY", JSVC_NUM.VAR_NVAL(JOB_ORDER_TASK_DELIVER_DGV.CELL.VALUE('REC_JORDER_TASK_QTY_ACTUAL', ROW_INDEX)));
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_REMARKS", "");
				JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_STOCKCARD_STATUS", 2);
	
				BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);					
			}

			
			// To next loop
			// ...........................................
		 	ROW_INDEX++;
		}
		
		
		// Save to local storage
		// _______________________________________________________________________
		var CTR = 0;
		var ARRAY_INDEX = 0;

		while(BUNDLE_MAP_ARRAY.length > ARRAY_INDEX)
		{
			if(IS_OFFLINE == false)
			{
				createItem(PARENT_ID_HOLDER + 'JO_REB_STOCKIN_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
			}
			else
			{
				createItem(PARENT_ID_HOLDER + 'JO_REB_STOCKIN_SAVE_MAP_ARRAYX' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
			}
			
			ARRAY_INDEX++;
			CTR++;
		}
		
		
		// Post process actions
		// _______________________________________________________________________
		TOTAL_INVENTORY -= TOTAL_OUT;
		JSOC_ELEMENT.VAR_VALUE("LOCAL_INV_LBL", "Inventory : " + TOTAL_INVENTORY);
		CUS_SEND_DIALOG_TRY_DISMISS();	


		// Lift edit and Exit EditMode
		// _______________________________________________________________________
		EDIT_HANDLER.REF_IS_MODIFIED = false;
		EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;


		// Lift edit and Exit EditMode
		// _______________________________________________________________________
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('JOB_ORDER_MODAL') == true)
		{
			JSOC_DIALOG.VAR_MODAL('JOB_ORDER_MODAL', false);
		}
		
		
		//SWAP_EDIT_MODE(false);
		// _______________________________________________________________________
		CALLBACK_METHOD(true);
	}
	
	
	function HTTP_JO_CUSTOMER_INV_SAVE_TO_LOCAL_STORAGE(PRODUCT_ID, PRODUCT_QUANTITY)
	{
		// Populate Mapped Array
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JOB_ORDER_DGV.CELL.VALUE('REC_JORDER_ACC_GROUP_ID', PROPERTY_EDIT_ROW_INDEX)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_REC_CLIENT_ID", JSVC_NUM.VAR_NVALL(JOB_ORDER_DGV.CELL.VALUE('REC_JORDER_REC_CLIENT_ID', PROPERTY_EDIT_ROW_INDEX)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_CAT_PRODUCT_ID", PRODUCT_ID); // SET DEFAULT PRODUCT IN DB AND USE IT ID?
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_QUANTITY", PRODUCT_QUANTITY);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_STATUS", 2);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_CUSTOMER_INV_ID_FILE", '');
		
		// Save to Local storage
		// _______________________________________________________________________
		if(IS_OFFLINE == false)
		{		
			createItem
			(
				PARENT_ID_HOLDER + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAY', 
				JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY)
			);
		}
		else
		{
			createItem
			(
				PARENT_ID_HOLDER + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAYX', 
				JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY)
			);		
		}
	};

	function HTTP_JO_CANCEL_RESERVATION(CALLBACK_METHOD)
	{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		var SAVE_MAP_ARRAY = [];

		if(PROPERTY_LS_ID2 > 0) // RES
		{
			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('RES_SAVE_MAP_ARRAY' + PROPERTY_LS_ID2));
			SAVE_MAP_ARRAY['PARAM_REC_POSRESERVE_STATUS'] = 3;
			createItem('RES_SAVE_MAP_ARRAY' + PROPERTY_LS_ID2, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		}
		else
		{
			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_ID", PROPERTY_PARENT_ID);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_STATUS", 3);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_ID_FILE", '');

			if(getValue('JO_CAN_RES_CTR_HOLDER') === null)
			{
				createItem('JO_CAN_RES_SAVE_HOLDER', 1);
				createItem('JO_CAN_RES_CTR_HOLDER', 1);
			}

			if(getValue('JO_CAN_RES_CTR') === null)
				CTR = 1;
			else
				CTR = JSVC_NUM.VAR_NVALL(getValue('JO_CAN_RES_CTR')) + 1;

			createItem('JO_CAN_RES_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			createItem('JO_CAN_RES_CTR', CTR);
		}

		CUS_SEND_DIALOG_TRY_DISMISS();
		HTTP_JO_CANCEL_JO(CALLBACK_METHOD);
	}

	function HTTP_JO_CANCEL_JO(CALLBACK_METHOD)
	{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		var SAVE_MAP_ARRAY = [];

		if(PROPERTY_LS_ID2 > 0) // RES
		{
			if(getValue(PROPERTY_LS_ID2 + 'JO_SAVE_MAP_ARRAYX') !== null)
			{
				SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(PROPERTY_LS_ID2 + 'JO_SAVE_MAP_ARRAYX'));
				SAVE_MAP_ARRAY['PARAM_REC_JORDER_STATUS'] = 3;
				createItem(PROPERTY_LS_ID2 + 'JO_SAVE_MAP_ARRAYX', JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			}
			else
			{
				SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(PROPERTY_LS_ID2 + 'RES_JO_SAVE_MAP_ARRAY'));
				SAVE_MAP_ARRAY['PARAM_REC_JORDER_STATUS'] = 3;
				createItem(PROPERTY_LS_ID2 + 'RES_JO_SAVE_MAP_ARRAY', JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			}

		}
		else if(PROPERTY_LS_ID > 0) // JO
		{
			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('JO_SAVE_MAP_ARRAY' + PROPERTY_LS_ID));
			SAVE_MAP_ARRAY['PARAM_REC_JORDER_STATUS'] = 3;
			createItem('JO_SAVE_MAP_ARRAY' + PROPERTY_LS_ID, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
		}
		else
		{
			SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ID", PROPERTY_REC_JORDER_ID);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_STATUS", 3);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_JORDER_ID_FILE", '');

			if(getValue('JO_CAN_JO_CTR_HOLDER') === null)
			{
				createItem('JO_CAN_JO_SAVE_HOLDER', 1);
				createItem('JO_CAN_JO_CTR_HOLDER', 1);
			}

			if(getValue('JO_CAN_JO_CTR') === null)
				CTR = 1;
			else
				CTR = JSVC_NUM.VAR_NVALL(getValue('JO_CAN_JO_CTR')) + 1;

			createItem('JO_CAN_JO_SAVE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(SAVE_MAP_ARRAY));
			createItem('JO_CAN_JO_CTR', CTR);
		}

		CUS_SEND_DIALOG_TRY_DISMISS();
		NTBSYNC();

		JOB_ORDER_DGV.ROW.DISPLAY(PROPERTY_EDIT_ROW_INDEX, "none");

		// Lift edit and Exit EditMode
		EDIT_HANDLER.REF_IS_MODIFIED = false;
		EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;	

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('JOB_ORDER_MODAL') == true)
			JSOC_DIALOG.VAR_MODAL('JOB_ORDER_MODAL', false);
		
		//SWAP_EDIT_MODE(false);
		CALLBACK_METHOD(true);
	}

	function HTTP_RESERVATION_LINE_DELETE(ROW_INDEX, LS_ID, DELETED_INDEX)
	{
		if(ROW_INDEX >= 0)
		{
			if(getValue('DEL_RESLINE_CTR_HOLDER') === null)
			createItem('DEL_RESLINE_CTR_HOLDER', 1);

			var CTR;

			if(getValue('DEL_RESLINE_CTR') === null)
				CTR = 1;
			else
				CTR = JSVC_NUM.VAR_NVALL(getValue('DEL_RESLINE_CTR')) + 1;

			createItem('DEL_RESLINE_ID' + CTR, PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_ID', ROW_INDEX));
			createItem('DEL_RESLINE_CTR', CTR);
		}
		
		PRODUCT_BRANCH_DGV.ROW.REMOVE_AT(DELETED_INDEX);

		if(LS_ID > 0)
		{
			JSOC_DIALOG.VAR_LOADING_SPINNER(true);

			var SAVE_MAP_ARRAY = [];
			var BUNDLE_MAP_ARRAY = [];
			var R_INDEX = 0;
			while(PRODUCT_BRANCH_DGV.ROW.COUNT() > R_INDEX)
			{
				if(JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_LS_ID', R_INDEX)) > 0)
				{
					SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_ID", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_ID',R_INDEX)));			
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_REC_POSRESERVE_ID", 0);
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_CAT_DISCOUNT_ID", 1); //DEFAULT WALA PA MUNA DISCOUNT
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_CAT_PRODUCT_ID',R_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_PRICE_EXPECT",
						JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',R_INDEX)) *
						JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',R_INDEX))
						);	
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_PRICE_BASE", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_PRICE_BASE',R_INDEX)));	
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_QTY", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_QTY',R_INDEX)));	
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_STATUS", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('REC_POSRESERVE_LIST_STATUS',R_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSRESERVE_LIST_ID_FILE", '');
					BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
				}

				R_INDEX++;
			}
			
			var CTR = 0;
			var ARRAY_INDEX = 0;

			while(BUNDLE_MAP_ARRAY.length > ARRAY_INDEX)
			{
				createItem(LS_ID + 'RES_LINE_BUNDLE_MAP_ARRAY' + CTR, JSVC_MAP_ARRAY.VAR_TO_STRING(BUNDLE_MAP_ARRAY[ARRAY_INDEX]));
				CTR++;
				ARRAY_INDEX++;
			}

			localStorage.removeItem(LS_ID + 'RES_LINE_BUNDLE_MAP_ARRAY' + CTR);
			CUS_SEND_DIALOG_TRY_DISMISS();
		}

		NTBSYNC();
	}

	