<html>
<head>
<title>Log_Query</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--<base href="$$BASE_URL$$" />-->

<link href="css/trend-style-new.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="javascripts/localization.js"></script>
<script language="JavaScript" src="javascripts/trend-ui-new.js"></script>
<script language="JavaScript" src="javascripts/OLH_Mapping.js"></script>
<script language="JavaScript" src="javascripts/TmCube_Common.js"></script>
<script language="JavaScript" src="javascripts/TmCube_Tree.js"></script>
<script language="JavaScript" src="cgiDispatcher.exe?Page=administration/SystemDateTime.htm">
<!-- //src="cgiDispatcher.exe?Page=administration/SystemDateTime.htm" return 4 values: vSvrDate, vSvrDateFormat, vSvrTime, vSvrTimeFormat, vSvrTwoDigitYearMax. //-->
</script>

<script language="JavaScript" type="text/JavaScript">
function setCommonOption(strDateFrom, strDateTo, strReason, strSortBy, strSortOrder, strNumPerPage)
{
    document.fmMain.txtDateFrom.value = strDateFrom;
	document.fmMain.txtDateTo.value = strDateTo;
	document.fmMain.optReason.value = strReason;
    document.fmMain.optSort.value = strSortBy;
    document.fmMain.optSortType.value = strSortOrder;
    document.fmMain.txtNumPerPage.value =  strNumPerPage;
}
function setNoneETOption(strAccount, strSite, strFileName, strKeyword)
{
   
    document.fmMain.txtSite.value = strSite;
    document.fmMain.txtAccount.value = strAccount;
    document.fmMain.txtKeyword.value = strKeyword;
    document.fmMain.txtFileName.value = strFileName;
      //  Target Page initialize to 1
    document.fmMain.txtTargetPage.value = 1;
	if (document.fmMain.txtAccount.value != "ANYONE")
    {
        var valueArray = new Array;
        jsSeparateStringWithLen(document.fmMain.txtAccount.value, valueArray);
        
        var vList = document.getElementById("lstSelectedAccount");
        vList.innerHTML = "";
        for(var i=0; i<valueArray.length; i++)
        {
            setUIAddItemWithValue("\n", valueArray[i], vList);
        }
        setOption2Selected(document.getElementById("lstSelectedAccount"));
    }
}
function setETOption(strIP,strSourceType,strEventType,strDescription,strETUsername)
{
    document.fmMain.txtIpAddress.value = strIP;
    document.fmMain.txtSourceType.value = strSourceType;
    document.fmMain.txtEventType.value = strEventType;
    document.fmMain.txtDescription.value = strDescription;
	document.fmMain.txtTargetPage.value = 1;
	if(strETUsername!="")
	 {
	     var valueArray = new Array;
        jsSeparateStringWithLen(strETUsername, valueArray);
        
        var vList = document.getElementById("lstUserSelected");
        vList.innerHTML = "";
        for(var i=0; i<valueArray.length; i++)
        {
            setUIAddItemWithValue("\n", valueArray[i], vList);
        }
        setOption2Selected(document.getElementById("lstUserSelected"));
	 }
}
var vQueryPage = "$$QUERY_PAGE$$";
function jsQuery()
{
    document.fmMain.Page.value = vQueryPage;
    parent.document.fmMain.btnSearch.disabled = true;
    document.fmMain.target = "_self";
    jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsPrint() 
{
    if (document.getElementById("cmdPrint").disabled)return;
	document.fmMain.Page.value = "$$PRINT_PAGE$$";
    if (document.fmMain.txtAccount.value != "ANYONE")
    {
        var valueArray = new Array;
        jsSeparateStringWithLen(document.fmMain.txtAccount.value, valueArray);
        
        var vList = document.getElementById("lstSelectedAccount");
        vList.innerHTML = "";
        for(var i=0; i<valueArray.length; i++)
        {
            setUIAddItemWithValue("\n", valueArray[i], vList);
        }
        setOption2Selected(document.getElementById("lstSelectedAccount"));
    }
    document.fmMain.target = "_blank";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsExport()
{
    if (document.getElementById("cmdExport").disabled)return;
	document.fmMain.Page.value = "$$EXPORT_PAGE$$";
    document.fmMain.target = "_self";
    if (document.fmMain.txtAccount.value != "ANYONE")
    {
        var valueArray = new Array;
        jsSeparateStringWithLen(document.fmMain.txtAccount.value, valueArray);
        
        var vList = document.getElementById("lstSelectedAccount");
        vList.innerHTML = "";
        for(var i=0; i<valueArray.length; i++)
        {
            setUIAddItemWithValue("\n", valueArray[i], vList);
        }
        setOption2Selected(document.getElementById("lstSelectedAccount"));
    }
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function  firstLetterCapitalize(str) {
	if(str == null) return;
	if(str == "") return;
	var words = str.split(" ");
	if(words.length > 1) {
		var result = "";
		for(var i=0; i<words.length; i++) {
			result += words[i].substring(0,1).toUpperCase() + words[i].substring(1, words[i].length) + " ";
		}
		return result.substring(0,result.length-1);
	} else {
		return str.substring(0,1).toUpperCase() + str.substring(1, str.length);
	}	
}

function jsInitPage()
{
    var vReason     = "";
    var vSort        = 0;
    var vSortType    = 0;
    var vNumPerPage  = 15;
    var vTargetPage  = 0;
    var vViolator    = 0;
    var vRecCount    = 0;
    var vPageCount   = 0;
    var vCurrentPage = 0;

   	if (document.fmMain.txtDateFrom.value	!= "") { vDateFrom	= new Date(document.fmMain.txtDateFrom.value); }
	if (document.fmMain.txtDateTo.value		!= "") { vDateTo	= new Date(document.fmMain.txtDateTo.value); }
	if (document.fmMain.optReason.value		!= "")
     {
          vReason	= document.fmMain.optReason.value;
		  vReason   = firstLetterCapitalize(vReason);
          document.getElementById("searchreason").innerHTML= vReason+" Logs from ";
     }
	if (document.fmMain.optSort.value		!= "") { vSort        = document.fmMain.optSort.value; }
	if (document.fmMain.optSortType.value	!= "") { vSortType    = document.fmMain.optSortType.value; }
	if (document.fmMain.txtNumPerPage.value	!= "") { vNumPerPage  = document.fmMain.txtNumPerPage.value; }
	if (document.fmMain.txtTargetPage.value	!= "") { vTargetPage  = document.fmMain.txtTargetPage.value; }
	if (document.fmMain.txtRecCount.value	!= "") { vRecCount    = document.fmMain.txtRecCount.value; }
	if (document.fmMain.txtPageCount.value	!= "") { vPageCount   = document.fmMain.txtPageCount.value; }
	if (document.fmMain.txtCurrentPage.value	!= "") { vCurrentPage = document.fmMain.txtCurrentPage.value; }
    if (document.fmMain.optViolator.value    != "") { vViolator    = document.fmMain.optViolator.value;} 

    if (document.fmMain.txtRecCount.value != "") {
	    if(document.fmMain.txtRecCount.value > 0) {
	        var tmpRecCount = document.fmMain.txtRecCount.value;
	        var tmpNumPerPage = document.fmMain.txtNumPerPage.value;
	        var vTotalPage = (tmpRecCount%tmpNumPerPage>0)?(parseInt(tmpRecCount/tmpNumPerPage)+1):(tmpRecCount/tmpNumPerPage);
	        document.getElementById("labTotalPage").innerText = vTotalPage;
	        document.getElementById("labTotalPage2").innerText = vTotalPage;
	     }
	    else{
	        document.getElementById("labTotalPage").innerText = 0;
	        document.getElementById("labTotalPage2").innerText = 0;
	    }
	}
   
   if (vCurrentPage != "" && vNumPerPage != "" && vRecCount != "") {
		var iRecCount = parseInt(vRecCount);
		if (iRecCount > 0) {
			var iBeginRec = parseInt(vNumPerPage) * (parseInt(vCurrentPage) - 1) + 1;
			var iEndRec   = parseInt(vNumPerPage) * (parseInt(vCurrentPage));
			if (iBeginRec > iRecCount) {iBeginRec = iRecCount;}
			if (iEndRec > iRecCount) {iEndRec = iRecCount;}
			document.getElementById("labRecordRange").innerText = iBeginRec.toString() + "-" + iEndRec.toString();
			document.getElementById("labRecordRange2").innerText = iBeginRec.toString() + "-" + iEndRec.toString();
            document.getElementById("labTotalRec").innerText = iRecCount.toString();
            document.getElementById("labTotalRec2").innerText = iRecCount.toString();

            document.fmMain.txtPageNum.value = document.fmMain.txtCurrentPage.value;
		    document.getElementById("txtPageNum2").value = document.fmMain.txtCurrentPage.value;
		}
        else
        {
            document.getElementById("ResultBar3").style.display = "none";
            setUIFunctionLink(false,"cmdPrint");
  	        setUIFunctionLink(false,"cmdPrint2");
  	        setUIFunctionLink(false,"cmdExport");
  	        setUIFunctionLink(false,"cmdExport2");
            
        }
	}
   if (document.fmMain.txtDateFrom.value != "") {
		document.getElementById("txtBeginTime").innerHTML = "$$QUERY_BEGIN_TIME$$";
		document.getElementById("txtEndTime").innerHTML = "$$QUERY_END_TIME$$";
   }
   if (document.fmMain.optSort.value != "") {
		if (objSort = document.getElementById(document.fmMain.optSort.value))
	    	document.getElementById(document.fmMain.optSort.value).innerHTML += parseInt(document.fmMain.optSortType.value) ? "<img src=\"images/arrow_down.gif\"/>" : "<img src=\"images/arrow_up.gif\"/>";
	}
  parent.document.fmMain.btnSearch.disabled = false;
  var bQueryFailed = "$$LOG_QUERY_FAILED$$";
  if(bQueryFailed=="true")
    alert(STR_WARN_LOGQUERY_FAILED);
}

function jsPage(nPage,vId) {
	// add some checking
    document.fmMain.Page.value = vQueryPage;
    document.fmMain.target = "_self";
	if (document.getElementById("ResultBar2").disabled)
		return;
	var nPageCount   = parseInt(document.fmMain.txtPageCount.value);
	var nCurrentPage = parseInt(document.fmMain.txtCurrentPage.value);
	if (nPage == "_NEXT_")			nPage = nCurrentPage + 1;
	else if (nPage == "_PREV_")		nPage = nCurrentPage - 1;
	else if (nPage == "_FIRST_")	nPage = 1;
	else if (nPage == "_LAST_")		nPage = nPageCount;
	
	if (nPage < 1) nPage = 1;
	else if (nPage > nPageCount) nPage = nPageCount;
	else if (nPage == nCurrentPage) return;
	else if (!checkNumberRange(nPage,nPageCount,1,STR_ERR_INVALID_LOG_PAGE_NUM))
	{
		document.getElementById(vId).focus();
		document.getElementById(vId).select();
		return;
	}
	var vPageCount = document.fmMain.txtPageCount.value;	
	document.fmMain.txtTargetPage.value = nPage;
	if (document.fmMain.txtAccount.value != "ANYONE")
    {
        var valueArray = new Array;
        jsSeparateStringWithLen(document.fmMain.txtAccount.value, valueArray);
        
        var vList = document.getElementById("lstSelectedAccount");
        vList.innerHTML = "";
        for(var i=0; i<valueArray.length; i++)
        {
            setUIAddItemWithValue("\n", valueArray[i], vList);
        }
        setOption2Selected(document.getElementById("lstSelectedAccount"));
    }
	setOption2Selected(document.getElementById("lstUserSelected"));
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsToggleSort(txtField) 
{
    setOption2Selected(document.getElementById("lstSelectedAccount"));
	document.fmMain.Page.value = vQueryPage;
    document.fmMain.target = "_self";
	var intOrder = 0;
	
	if (txtField == document.fmMain.optSort.value) {
		if (document.fmMain.optSortType.value != "")
		intOrder = (parseInt(document.fmMain.optSortType.value)+ 1) % 2;
	}
	//jsCombineDateTime();
	document.fmMain.optSort.value = txtField;
	document.fmMain.optSortType.value = intOrder;
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsKeyPressEvent(e,vId,nValue)
{
    var key = window.event ? e.keyCode : e.which;
    if(key == 13)
        jsPage(nValue,vId);
}
//-->
</script>
<body style="margin-left: 0px;margin-top: 0px;OVERFLOW-Y:HIDDEN" onLoad="jsInitPage();"> 

<form id="fmMain" name="fmMain" action="$$REQUERY_ACTION$$" method="POST">
<!--Hidden Field-->
    <input type="hidden" name="Page" value="$$PAGE_ID$$">
    <input type="hidden" name="txtDateFrom"     value="$$BEGIN_TIME$$"/>
    <input type="hidden" name="txtDateTo"       value="$$END_TIME$$"/>
    <input type="hidden" name="optReason"      value="$$REASON$$"/>
    <input type="hidden" name="optViolator"     value="$$VIOLATOR$$">
	<input type="hidden" name="optSort"         value="$$SORT_BY$$"/>
	<input type="hidden" name="optSortType"     value="$$SORT_ORDER$$"/>
	<input type="hidden" name="txtTargetPage"   value="$$TARGET_PAGE$$"/>
	<input type="hidden" name="txtNumPerPage"   value="$$REC_PER_PAGE$$"/>
	<input type="hidden" name="txtRecCount"         value="$$REC_COUNT$$"/>
	<input type="hidden" name="txtPageCount"        value="$$PAGE_COUNT$$"/>
	<input type="hidden" name="txtCurrentPage"      value="$$CURRENT_PAGE$$"/>
    <input type="hidden" name="txtSite" value="$$SITE$$">
    <input type="hidden" name="txtAccount" value="$$ACCOUNT$$">
    <input type="hidden" name="txtKeyword" value="$$KEYWORD$$">
    <input type="hidden" name="txtFileName" value="$$FILENAME$$">
	<input type="hidden" name="txtIpAddress" value="$$IP_ADDRESS$$">
	<input type="hidden" name="txtEventType" value="$$EVENT_TYPE$$">
	<input type="hidden" name="txtDescription" value="$$DESCRIPTION$$">
	<input type="hidden" name="txtSourceType" value="$$SOURCE_TYPE$$">
    <select id="lstSelectedAccount" name="lstSelectedAccount" multiple style="display:none">
    $$QUERY_USER$$
	</select>
	<select id="lstUserSelected" name="lstUserSelected" multiple style="display:none">
    $$EVENT_TRACKING_USER$$
	</select>

<!--/Hidden Field-->
<!--/Page Title-->
<table style="height:auto;" width="100%" border="0" cellspacing="0" cellpadding="0">
<!--Page Description--><!--/Page Description-->
<!--Page Content-->
	<tr id="ResultBar1"><td class="tableheader" style="BORDER-TOP: #999999 2px solid;"><font id="searchreason"></font> <font id="txtBeginTime"></font>&nbsp;to&nbsp;<font id="txtEndTime"></font></td></tr>
		<tr id="ResultBar2" ><td class="data2">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr><td><a id="cmdPrint" href="javascript:jsPrint();" class="databutton"><img id="cmdPrint_img" src="images/icon_print.gif"
                class="vAlignMid">Print</a>
					<a id="cmdExport" href="javascript:jsExport();" class="databutton"><img id="cmdExport_img" src="images/icon_deliver.gif"
                    class="vAlignMid">Export</images></a></td>
					<td align="right"><table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap><font id="labRecordRange" name="labRecordRange">0</font> of <font id="labTotalRec" name="labTotalRec">0</font></td><td>&nbsp;logs</td>
						<td><img src="images/pagination-beginning.gif" style="cursor:pointer" onClick="jsPage('_FIRST_');" class="vAlignMid"></td>
						<td><img src="images/pagination-previous.gif" style="cursor:pointer" onClick="jsPage('_PREV_');" class="vAlignMid"></td>
						<td>Page</td>
						<td><input type="text" class="text" id="txtPageNum" name="txtPageNum" size="5" maxlength="5" onKeyPress="jsKeyPressEvent(event,this.id,this.value);"/></td>
						<td>of&nbsp;</td>
						<td><font id="labTotalPage" name="labTotalPage">0</font></td>
						<td><img src="images/pagination-next.gif" style="cursor:pointer" onClick="jsPage('_NEXT_');" class="vAlignMid"></td>
						<td><img src="images/pagination-end.gif" style="cursor:pointer" onClick="jsPage('_LAST_');" class="vAlignMid"></td><td>&nbsp;|&nbsp;</td>
						<td><input type=button class="text" value="Go" onClick="jsPage(this.form.txtPageNum.value,'txtPageNum');"></td></tr></table></td></tr>
				</table></td></tr>
			<!--||TABLE DATA||-->
			
		<tr id="ResultBar3"><td style="padding:0">
            $$PAGE_CONTENT$$
		</td></tr>
		<tr id="ResultBar4"><td class="data2c">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr><td><a id="cmdPrint2" href="javascript:jsPrint();" class="databutton"><img id="cmdPrint2_img" src="images/icon_print.gif"
                class="vAlignMid">Print</a>
					<a id="cmdExport2" href="javascript:jsExport();" class="databutton"><img id="cmdExport2_img" src="images/icon_deliver.gif"
                    class="vAlignMid">Export</images></a></td>
					<td align="right"><table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap><font id="labRecordRange2" name="labRecordRange2">0</font> of <font id="labTotalRec2" name="labTotalRec2">0</font></td><td>&nbsp;logs</td>
						<td><img src="images/pagination-beginning.gif" style="cursor:pointer" onClick="jsPage('_FIRST_');" class="vAlignMid"></td>
						<td><img src="images/pagination-previous.gif" style="cursor:pointer" onClick="jsPage('_PREV_');" class="vAlignMid"></td>
						<td>Page</td>
						<td><input type="text" class="text" id="txtPageNum2" name="txtPageNum2" size="5" maxlength="5" onKeyPress="jsKeyPressEvent(event,this.id,this.value);"/></td>
						<td>of&nbsp;</td>
						<td><font id="labTotalPage2" name="labTotalPage2">0</font></td>
						<td><img src="images/pagination-next.gif" style="cursor:pointer" onClick="jsPage('_NEXT_');" class="vAlignMid"></td>
						<td><img src="images/pagination-end.gif" style="cursor:pointer" onClick="jsPage('_LAST_');" class="vAlignMid"></td><td>&nbsp;|&nbsp;</td>
						<td><input type=button class="text" value="Go" onClick="jsPage(document.getElementById('txtPageNum2').value,'txtPageNum2');"></td></tr></table></td></tr>
				</table></td></tr>
<!--/Page Content-->
</table>
</form>
<iframe id="ifmDownload" name="ifmDownload" style="display:none" src="html/UntitledFrame-1.htm"></iframe>


</body>
</html>
