<!DOCTYPE html>

<%@ page import = "com.eg.IniFile"%>
<%@ page import = "com.egurkha.util.StringUtils"%>

<%@ include file="EgTrackerA.jsp" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);

	if(!EgInstallInfo.isAggregationSupported())
	{
		Vector errors = new Vector();
		errors.addElement(_mapping.getTextDescription("admin.error.Admin Home"));
		errors.addElement("EgAdminOperations.jsp");
		errors.addElement(_mapping.getTextDescription("admin.error.Possible Reason"));
		errors.addElement(_mapping.getTextDescription("admin.error.Your license does not allow you to use this feature")+".");
		errors.addElement(_mapping.getTextDescription("admin.error.Please contact") + " <a href='mailTo:license@eginnovations.com' target='_parent' class='dash_link'><b>license@eginnovations.com</b></a> " + _mapping.getTextDescription("admin.error.for more details")+".");
		session.putValue("vec_Errors", errors);
%>
	<jsp:forward page="EgErrors.jsp" />
<%
	}
	String queryString  = request.getQueryString();
	String avg_desc = _mapping.getTextDescription("admin.common.avg");
	String avg_sum_desc = _mapping.getTextDescription("admin.common.avg_sum");
	String min_desc = _mapping.getTextDescription("admin.common.min");
	String max_desc = _mapping.getTextDescription("admin.common.max");
	String sum_desc = _mapping.getTextDescription("admin.common.sum");
	String fn_desc = _mapping.getTextDescription("admin.common.Function");
	String name_desc = _mapping.getTextDescription("admin.common.Name");
	String desc_desc = _mapping.getTextDescription("admin.common.Description");

	String current_testfor = request.getParameter("testfor");
	current_testfor = StringUtils.isNull(current_testfor) ? "managedtests":current_testfor.trim();
%>

<html>
<head>
	<meta charset="utf-8">

	<egui:skin ui="admin"/>
	<style>
		.threshold_table{
			table-layout: fixed !important;
		}

		.threshold_table td{
			word-wrap: break-word !important;
			white-space: normal !important;
			padding:2px 5px 2px 5px !important;
		}

		.gridSkin .threshold_tdcls div.x-grid-cell-inner{
		
			padding:0px !important;
		}
	</style>
	<script type="text/javascript" src="../extjs/ext-all.js"></script>

	<!-- Fancy Scroll-->
	<script src="/final/jquery/jquery.js"></script>
	<script src="/final/styles/jscrollpane/jquery.jscrollpane.js" ></script>
	<script src="/final/styles/jscrollpane/jquery.mousewheel.js" ></script>
	<script src="/final/styles/jscrollpane/mwheelIntent.js" ></script>
	<script src="/final/scripts/utilities/EncodeDecodeParams.js"></script>
	<link rel="stylesheet" href="/final/styles/jscrollpane/jquery.jscrollpane.css"/>

	<script language="JavaScript1.2" src="/final/scripts/eg_DateUtil.js"></script>
	<script language="JavaScript1.2">
		var csrfToken = '<%=strCsrfToken%>';
		var titleGrid1 = '<egui:intnl text="admin.title.Measures with thresholds"/>';
		var titleGrid2 = '<egui:intnl text="admin.title.Measures without thresholds (Click on the individual measure to configure their thresholds)"/>';
		var alarmPolText = '<egui:intnl text="admin.threshold.Alarm Policy"/>';
		var btnText = '<egui:intnl text="admin.common.Finish"/>';
		var btnText1 = '<egui:intnl text="admin.common.Back"/>';
		var btnText2 = '<egui:intnl text="admin.common.Update"/>';
		var minThreshText = '<egui:intnl text="admin.threshold.Minimum Threshold"/>';
		var maxThreshText = '<egui:intnl text="admin.threshold.Maximum Threshold"/>';
		var minRegExpText = '<egui:intnl text="admin.threshold.Alphabets or special characters are not allowed"/>';
		var minThreshTipText = '*&nbsp;'+'<egui:intnl text="admin.threshold.Specify minimum threshold values (Critical, Major, and Minor) in ascending order"/>';
		var maxThreshTipText = '*&nbsp;'+'<egui:intnl text="admin.thresholds.Specify maximum threshold values (Critical, Major, and Minor) in descending order"/>';

		var pageTitle = '<egui:intnl text="admin.title.USER DEFINED AGGREGATE TEST DETAILS"/>';
		var pageTitle1 = '<egui:intnl text="admin.title.DEFAULT THRESHOLDS"/>';
		var pageTitle2 = '<egui:intnl text="admin.title.CONFIGURE THRESHOLDS"/>';
		var pageDescc = '<egui:intnl description="aggAddTest.jsp"/>';
		var pageDesc1 = '<egui:intnl description="EgDefaultThresholds.jsp"/>';
		var pageDesc2 = '<egui:intnl description="EgConfigureThresholds.jsp"/>';
		var current_testfor = "<%=current_testfor%>";
		var showBackButton = "false";
		var queryString = "<%=queryString%>";
		var operation = '<%=request.getParameter("operation")%>';
		var s_test = "";
		var s_aggTest = '<%=request.getParameter("aggtest")%>';
		var measures_exist = new Array();

		var pageLabel = '<egui:intnl text="admin.title.admin.Aggregate Test"/>';
		var create_alert = '<egui:intnl text="Please select a measure to create aggregate test"/>'+'.';
		var modify_alert = '<egui:intnl text="Please select a measure to modify aggregate test"/>'+'.';
		var delete_alert = '<egui:intnl text="Please select a measure to exclude from aggregate test"/>'+'.';
		var append_alert = '<egui:intnl text="Please select a measure to append to aggregate test"/>'+'.';
		var measure_desc_alert1 = '<egui:intnl text="Aggregate measure name"/>';
		var measure_desc_alert2 = '<egui:intnl text="already exists"/>';

		var report_by_desc = '<egui:intnl text="admin.aggregate.Report by descriptors"/>';
		var s_name = '<egui:intnl text="admin.common.Name"/>';
		var description = '<egui:intnl text="admin.common.Description"/>';
		var descPageTitle = '<egui:intnl text="admin.common.Aggregate Functions"/>';
		var back_button = '<egui:intnl text="admin.common.Back"/>';
		var yes = '<egui:intnl text="admin.common.Yes"/>';
		var no = '<egui:intnl text="admin.common.No"/>';

		var avgLabel = '<egui:intnl text="admin.aggregate.Average"/>';
		var avgDesc = '<egui:intnl text="admin.aggregate.Average of all measures"/>';
		var avgSumLabel = '<egui:intnl text="admin.aggregate.Average sum"/>';
		var avgSumDesc = '<egui:intnl text="admin.aggregate.Averages the number of measures for the test frequency and sums with the other component"/>';
		var maxLabel = '<egui:intnl text="admin.aggregate.Maximum"/>';
		var maxDesc = '<egui:intnl text="admin.aggregate.Maximum of all measures"/>';
		var minLabel = '<egui:intnl text="admin.aggregate.Minimum"/>';
		var minDesc = '<egui:intnl text="admin.aggregate.Minimum of all measures"/>';
		var sumLabel = '<egui:intnl text="admin.aggregate.Sum"/>';
		var sumDesc = '<egui:intnl text="admin.aggregate.Sum of all measures"/>';
		var conLabel = '<egui:intnl text="admin.aggregate.Condition"/>';
		var conDesc = '<egui:intnl text="admin.aggregate.Metrics calculation is based on single condition"/>';
		var multi_conLabel = '<egui:intnl text="admin.aggregate.Multi-Condition"/>';
		var mulConDesc = '<egui:intnl text="admin.aggregate.Metrics calculation is based on multiple conditions"/>';

		var confirmation_1 = '<egui:intnl text="admin.ic.Excluding all measures will remove this test totally from the eG system"/>'+". "+'\n<egui:intnl text="admin.ic.Are you sure you want to delete"/>';
		var confirmation_2 = '<egui:intnl text="admin.ic.This will remove existing values from the test table"/>'+". "+'\n<egui:intnl text="admin.ic.Are you sure you want to proceed"/>?';

		var message_1 = '<egui:intnl text="admin.ic.Test name can not be blank"/>';
		var message_2 = '<egui:intnl text="admin.ic.Test name is not allowed in DBL(Chinese,Korean,Japanese)"/>';
		var message_3 = '<egui:intnl text="admin.common.Measure description filed can not be blank"/>';
		var message_4 = '<egui:intnl text="admin.common.Measure description is allowed only in English"/>';
		var message_5 = '<egui:intnl text="admin.common.Measure description should not contain"/>'+' '+'.'+' (<egui:intnl text="admin.common.dot"/>)';

		var message_6 = '<egui:intnl text="admin.common.Target operation should be valid for the measure name"/>';
		var message_7 = '<egui:intnl text="admin.common.Target value is invalid for the measure name"/>';
		var message_8 = '<egui:intnl text="admin.common.Measurement unit should be Number or % for the measure name"/>';
		var message_9 = '<egui:intnl text="admin.common.Measurement unit should be Number if the multi-condition function is chosen"/>';
		var message_11 = '<egui:intnl text="admin.common.Target violation by descriptors is invalid for the measure name"/>';
		var message_13 = '<egui:intnl text="admin.common.Target components should be in descending order for the measure name"/>';
		var message_14 = '<egui:intnl text="admin.common.Target values cannot have negative values for the measure name"/>';
		var message_15 = '<egui:intnl text="admin.common.Target components cannot have negative values for the measure name"/>';
		var message_16 = '<egui:intnl text="admin.common.No target values have been set for the measure name"/>';
		var message_17 = '<egui:intnl text="admin.common.No target components have been set for the measure name"/>';
		var message_18 = '<egui:intnl text="admin.common.Target value cannot be a negative number for the measure"/>';
		var message_19 = '<egui:intnl text="admin.common.Special characters are not allowed in aggregate test display name"/>';
		var message_20 = '<egui:intnl text="admin.common.Special characters are not allowed in aggregate measure name"/>';

		var trgt_value_invalid = '<egui:intnl text="admin.common.Target value is invalid for the measure name"/>';
		var possible_reason_could_be = '<egui:intnl text="admin.common.Possible reasons could be"/>';
		var set_with_negative_value = '<egui:intnl text="admin.common.Target value is set with a negative value"/>';
		var six_digits = '<egui:intnl text="admin.common.The integer part contains more than six digits"/>';
		var four_digits = '<egui:intnl text="admin.common.The fractional part contains more than four digits"/>';
		var should_not_contain = '<egui:intnl text="admin.common.should not contain negative value"/>';

		var set_with_negative_value = '<egui:intnl text="admin.common.Target value is set with a negative value"/>';
		var critial_trgt_value_invalid = '<egui:intnl text="admin.common.Critical target value is invalid for the measure name"/>';
		var major_trgt_value_invalid = '<egui:intnl text="admin.common.Major target value is invalid for the measure name"/>';
		var minor_trgt_value_invalid = '<egui:intnl text="admin.common.Minor target value is invalid for the measure name"/>';

		var critial_trgt_comps_invalid = '<egui:intnl text="admin.common.Critical target components value is invalid for the measure name"/>';
		var major_trgt_comps_invalid = '<egui:intnl text="admin.common.Major target components value is invalid for the measure name"/>';
		var minor_trgt_comps_invalid = '<egui:intnl text="admin.common.Minor target components value is invalid for the measure name"/>';
		var critial_trgt_comps_100 = '<egui:intnl text="admin.common.Critical target component value should not exceed 100 for the measure name"/>';
		var major_trgt_comps_100 = '<egui:intnl text="admin.common.Major target component value should not exceed 100 for the measure name"/>';
		var minor_trgt_comps_100 = '<egui:intnl text="admin.common.Minor target component value should not exceed 100 for the measure name"/>';

		var trgt_message_1 = '<egui:intnl text="admin.common.Please specify the critical target values for the measure name"/>';
		var trgt_message_2 = '<egui:intnl text="admin.common.Please specify the critical target components value for the measure name"/>';

		var trgt_message_3 = '<egui:intnl text="admin.common.Please specify the major target values for the measure name"/>';
		var trgt_message_4 = '<egui:intnl text="admin.common.Please specify the major target components value for the measure name"/>';

		var trgt_message_5 = '<egui:intnl text="admin.common.Please specify the minor target values for the measure name"/>';
		var trgt_message_6 = '<egui:intnl text="admin.common.Please specify the minor target components value for the measure name"/>';

		var invalid_chars_found_trgt_val = '<egui:intnl text="admin.common.Invalid character is found in target values for the measure name"/>';
		var invalid_chars_found_trgt_comps = '<egui:intnl text="admin.common.Invalid character is found in target components value for the measure name"/>';

		var addConfirmationMsg='<egui:intnl text="admin.common.You are trying to include measures"/>';
		var modifyConfirmationMsg='<egui:intnl text="admin.common.You are trying to update measures"/>';
		var deleteConfirmationMsg='<egui:intnl text="admin.common.You are trying to exclude measures"/>';
		var appendConfirmationMsg='<egui:intnl text="admin.common.You are trying to include measures"/>';
		var proceedMsg='<egui:intnl text="admin.common.Do you want to proceed"/>';

		var target_operation_lab = '<egui:intnl text="admin.common.Target Operation"/>';
		var target_values_lab = '<egui:intnl text="admin.common.Target Values"/>';
		var target_components_lab = '<egui:intnl text="admin.common.Target Components"/>';
		var measurement_unit_lab = '<egui:intnl text="admin.common.Measurement Unit"/>';
		var trgt_violation_lab = '<egui:intnl text="admin.common.Target Violation By Descriptors"/>';

		var staticMinCriticalErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Critical - Static minimum threshold"/>';
		var staticMaxCriticalErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Critical - Static maximum threshold"/>';
		var staticMinMajorErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Major - Static minimum threshold"/>';
		var staticMaxMajorErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Major - Static maximum threshold"/>';
		var staticMinMinorErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Minor - Static minimum threshold"/>';
		var staticMaxMinorErrMsg1 = '<egui:intnl text="admin.threshold.Invalid threshold entry : Minor - Static maximum threshold"/>';
		var errMsg1 = '<egui:intnl text="admin.threshold.Possible reasons could be"/>';
		var errMsg2 = '<egui:intnl text="admin.threshold.Threshold is set with a negative value"/>';
		var errMsg3 = '<egui:intnl text="admin.threshold.The integer part contains more than 10 digits"/>';
		var errMsg4 = '<egui:intnl text="admin.threshold.The fractional part contains more than 4 digits"/>';
		var errMsg5 = '<egui:intnl text="admin.threshold.Static minimum threshold"/> <egui:intnl text="admin.threshold.for"/>';
		var errMsg6 = '<egui:intnl text="admin.threshold.should not contain negative values"/>';
		var errMsg7 = '<egui:intnl text="admin.threshold.Static minimum threshold values representing Critical/Major/Minor should be in ascending order"/>';
		var errMsg8 = '<egui:intnl text="admin.threshold.Automatic minimum threshold values representing Critical/Major/Minor should be in ascending order"/>';
		var errMsg9 = '<egui:intnl text="admin.threshold.Static maximum threshold values representing Critical/Major/Minor should be in descending order"/>';
		var errMsg10 = '<egui:intnl text="admin.threshold.Automatic maximum threshold values representing Critical/Major/Minor should be in descending order"/>';
		var errMsg11 = '<egui:intnl text="admin.threshold.Static maximum threshold"/> <egui:intnl text="admin.threshold.for"/>';
		var deleteConfirmMsg = '<egui:intnl text="admin.threshold.Are you sure you want to delete specific thresholds for this descriptor"/>?';
		var successMsg1 = '<egui:intnl text="admin.threshold.Threshold updated successfully"/>'+'.';
		var pct_agg_function_valid_msg= '<egui:intnl text="admin.threshold.Percent aggregate function is applicable only when three or more measures are selected"/>';
		var you_cannot_set = '<egui:intnl text="admin.threshold.You cannot set the same aggregate measure name for both numerator and denominator to calculate the value for aggregate measure"/>';

		var measureText = '<egui:intnl text="admin.threshold.Measure"/>';
		var thresholdText = '<egui:intnl text="admin.threshold.Threshold"/>';
		var criticalText = '<egui:intnl text="admin.threshold.Critical"/>';
		var majorText = '<egui:intnl text="admin.threshold.Major"/>';
		var minorText = '<egui:intnl text="admin.threshold.Minor"/>';
		var maxminText = '<egui:intnl text="admin.threshold.Min/Max"/>';
		var staticText = '<egui:intnl text="admin.threshold.Static"/>';
		var autoText = '<egui:intnl text="admin.threshold.Automatic"/>';
		var descText = '<egui:intnl text="admin.threshold.Description"/>';
		var polText = '<egui:intnl text="admin.threshold.Policy"/>';
		var allMeasureText = '<egui:intnl text="admin.threshold.Apply to other measures"/>';
		var autoCriText = '<egui:intnl text="admin.threshold.Critical (% Tolerance)"/>';
		var autoMajorText = '<egui:intnl text="admin.threshold.Major (% Tolerance)"/>';
		var autoMinorText = '<egui:intnl text="admin.threshold.Minor (% Tolerance)"/>';
		var display_internal_name_mapping = null;
		var superMeasureMap = null;
		var pctMeasureNamesArray = null;

		var probsErrorMessage = '<egui:intnl text="admin.error.Problem encountered while loading the user interface"/>';
		var requestTimeOut = '<egui:intnl text="admin.error.Response timed out"/>';
		var errorTitle = '<egui:intnl text="admin.user.Error"/>';
	</script>

	<!-- Application folder -->
	<script type="text/javascript" src="AggregateTests/app/app.js"></script>

	<script language="javascript" src="/final/admin/eg_scripts/common.js"></script>
	<script language="JavaScript1.2" src="/final/admin/eg_scripts/validate.js"></script>

	<script language="javascript">
		Ext.onReady(function(){
			Ext.Ajax.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};
			Ext.data.Connection.prototype.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};
			Ext.data.ScriptTagProxy.prototype.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};

			Ext.Ajax.on('requestexception', function (conn, response, options) {
				var errorStr = response.responseText;
				if (errorStr != undefined && errorStr != 'undefined' && errorStr.indexOf("customerror") != -1)
				{
					if (errorStr.indexOf("user-session-invalid") != -1)
					{
						callWindow(1);
					}
					else if (errorStr.indexOf("user-deleted") != -1)
					{
						callWindow(2);
					}
					else if (errorStr.indexOf("user-timedout") != -1)
					{
						callWindow(3);
					}
				}
				else
				{
					if (response.status == 302 || (response.timedout != undefined && response.timedout == true))
					{
						Ext.Msg.show({
							title : errorTitle,
							msg : requestTimeOut,
							buttons : Ext.Msg.OK,
							icon : 'iconError'
						});
					}
					else
					{
						console.log(response.responseText);
						Ext.Msg.show({
							title : errorTitle,
							msg : probsErrorMessage,
							buttons : Ext.Msg.OK,
							icon : 'iconError'
						});
					}
				}
			});
		});
	</script>

</head>

<body>
<div id="loadmask" class="x-mask-msg x-layer x-mask-msg-default" style="z-index: 19001;left:45%;top:35%;">
	<div class="x-mask-loading" style="position:relative">
		Loading...
	</div>
</div>
</body>
</html>

<%
	session.setAttribute("adminLastAccessedURL","/final/admin/aggAddTest.jsp?"+request.getQueryString());
%>



