<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.utilities.CscCalendar,com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*,com.csc.library.formula.*,java.text.*"%>
<%@page import="com.csc.library.utilities.CscTime,com.csc.library.report.ReportUDF"%>
<jsp:useBean id="SM1007" class="com.csc.library.system.Task" scope="page" />
<%!
public  String getHHMMSS(String HHMM){
	
	String[] temp = HHMM.split("\\.");
	String reStr = "00:00:00";
	if(temp.length ==2){
		 reStr = ((temp[0].length()<=1)?"0"+temp[0]:temp[0])+":"+temp[1]+":00";
	} 
	return reStr;
}
%>
<%
	SM1007.setChannel(request, response);
	HelpEntry screen = (HelpEntry) SM1007.process("HelpEntry", "SM1007");
	String subordinate = screen.getUProfile().get("subordinateall"); 
	CheckNull chk=new CheckNull();
	ThaiUtilities thaicode = new ThaiUtilities(); 
	String empid1= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empid1")));  
	String empid2= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empid2")));  
	String startDate= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__date1")));  
	String endDate= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__date2")));  
	String startTime= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__time1"),"0.00"));  
	String endTime= thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__time2"),"0.00"));  
	String module = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__module_name"),"ALL"));  
	String screenName = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__screen")));
	String whereCuz=""; 
	if(!empid1.equals("") && !empid2.equals("")){
		whereCuz += " and user_code  in (select usernameid from muser where empid >= '"+empid1+"' and empid <= '"+empid2+"') ";
	}
	if(!startDate.equals("")){
		whereCuz += " and (login_date >= '"+new CscCalendar(startDate).getYYYYMMDD()+"' ";
		if(!endTime.equals("0.00")){
			whereCuz += " and login_date <= '"+new CscCalendar(endDate).getYYYYMMDD()+"'";
		}
		whereCuz += ") ";
		whereCuz +=" and (login_time >= '"+getHHMMSS(startTime)+"' ";
		if(!endTime.equals("0.00")){
			whereCuz += "and login_time <= '"+getHHMMSS(endTime)+"')";
		}else{
			whereCuz += ")";
		}
	} 
	if(!module.equals("ALL")){
		whereCuz += " and module_name = '"+module+"'";
	}
//out.print("whereCuz : "+whereCuz);
	screen.getInquiry().setFilter("LOGIN_STATUS = 'P' "+whereCuz); 
/*
	String orderBy= chk.chkNullString(request.getParameter("__orderBy"),"asc");  
	if(orderBy.indexOf("desc")>-1){
		screen.getInquiry().setOrderBy("bu2,employeeid desc");
	}else{
		screen.getInquiry().setOrderBy("bu2,employeeid asc");
	}  
	*/
	screen.referLangOn(); 
	//screen.getInquiry().refresh(); 
	screen.process();
	screen.totalRec=screen.getInquiry().recCount();   
	// out.print("whereCuz : "+screen.inq.getFilter() +" end");
	
	ThaiUtilities thai=new ThaiUtilities(); 
%> 

<html>
<head>
<title></title>
 

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/bootstrap.css" rel="stylesheet"  type="text/css">
<link href="../CSS/bootstrap_csc_backend.css" rel="stylesheet"  type="text/css">
<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
<script type='text/javascript' src="../JS/bootstrap.js"></script>
<script type='text/javascript' src='../JS/SCREEN.js'></script>
<script language='javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>
<script type='text/javascript' src='../JS/DATEINPUT.js'></script>
<script type='text/javascript' src='../JS/VIEWCALENDAR.js'></script>
<script language="javascript">getTitleName();</script>  
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//--> 
  
function setSubmit(){
	//setFilter();
	with(document.cscform){ 
		submit();
	}
} 

/*function goHelp(helpName,inputName) {
	var helpReturn="";
	var fcon=__fixCon.value;
	if (inputName=="__empid1" ) {
	 	helpReturn="__empid1:employeeid,MEMPLOYEE@FULLNAME";
	} 
	if (inputName=="__empid2" ) {
	 	helpReturn="__empid2:employeeid,MEMPLOYEE@FULLNAME";
	} 
	linkHelp_Return(helpName,helpReturn);
}*/

function goHelp(helpName,inputName){
	with(document.cscform){
		var helpReturn="";
		var fcon=__fixCon.value;
        
	if (inputName=="__empid1" ) {
	 	helpReturn="__empid1:employeeid,MEMPLOYEE@FULLNAME";
	} 
	if (inputName=="__empid2" ) {
	 	helpReturn="__empid2:employeeid,MEMPLOYEE@FULLNAME";
	} 

		if(fcon=="")
	     	linkHelp_Return(helpName,helpReturn);
	    else
	     	helpPageCon(helpName,helpReturn,fcon);
	}
	
}
  
</script>

</head>

<body leftmargin="0" topmargin="0" onLoad="MM_preloadImages('../IMAGES/BUTTON/SEARCH.gif')">
<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
<script language="javascript">initToolTips();</script>
<form name="cscform" method="post" action="SM1007.jsp">


<!----------BEGIN CSC INITIAL ZONE ------------------------>

<%=screen.InitialVariable()%>

<!----------END CSC INITIAL ZONE -------------------------->

	<input type="hidden" name="__screen" value="SM1007">
	<input type="hidden" name="__cmd" value="">
	<input type="hidden" name="__help" value="">
	<input type="hidden" name="__goPage" value="">
<!-- 	<input type="hidden" name="__orderBy" value="<%=chk.chkNullString(request.getParameter("__orderBy"),"asc")%>"> -->
	<input type="hidden" name="__helpReturn" value="">
	<input type="hidden" name="__helpName" value="">
	<input type="hidden" name="__pageCall" value="">
	<input type="hidden" name="__fixCon" value=""> 
	<input type="hidden" name="__calendar">
	<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
	<input type="hidden" name="__subordinate" value="<%=screen.getUProfile().get("subordinateall")%>"> 
  	<script language="javascript">getInputFormatDate();</script> 
	<br>
  	<table height="" align="center" cellpadding="1" cellspacing="0"  border="0" class="largest">
    <tr>
      <td  height="20" class="header" colspan="4">SM1007, <%=screen.getUProfile().get("lang").equalsIgnoreCase("THA") ? "ประวัติการเข้าใช้งาน" : "List Of Online User" %>&nbsp;</td>
  	</tr>
	<tr>
      <td class="blankspace" colspan="4">&nbsp;</td>
    </tr>
	<!-- Search Zone -->
    <tr>
      <td colspan="4">&nbsp;<strong><%=screen.getUProfile().get("lang").equalsIgnoreCase("THA") ? "กำหนดเงื่อนไขการค้นหา" : "Condition For Search" %></strong></td>
    </tr> 
	<tr> 
			<td   style="padding-left:10px" width="15%"><%=screen.getUProfile().get("lang").equalsIgnoreCase("THA") ? "วันที่ / เวลา" : "Date / Time" %>  </td>
			<td  colspan='3' width="85%"> 
						<input type="text" name="__date1" size="10" maxlength="10" value="<%=new CscCalendar(startDate).getDDMMYYYY()%>" onclick="" onchange="" onmouseover="toolTip('วันที่บันทึกเวลา(DDMMYYYY)')" onmouseout="toolTip()" onkeypress="chkIntegerOfDate(this.value);" onkeyup="formatDate(this);" dir="" onblur="chkInputDate(this);" onfocus="this.select();" class="" alt="วันที่บันทึกเวลา"/>
							<a onmouseover="MM_swapImage('calendar1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="#"><img border="0" align="absmiddle" alt="Calendar" onclick="viewCal('__date1')" name="calendar1" src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif"/></a>
							<input type="text" onmouseout="toolTip()" onmouseover="toolTip('HHMM')" onblur="chkTime(this)" onkeypress="chkInteger(event)" onfocus="this.select()" value="<%=startTime%>" maxlength="5" size="4" name="__time1">
							 - 
							 <input type="text" name="__date2" size="10" maxlength="10" value="<%=new CscCalendar(endDate).getDDMMYYYY()%>" onclick="" onchange="" onmouseover="toolTip('วันที่บันทึกเวลา(DDMMYYYY)')" onmouseout="toolTip()" onkeypress="chkIntegerOfDate(this.value);" onkeyup="formatDate(this);" dir="" onblur="chkInputDate(this);" onfocus="this.select();" class="" alt="วันที่บันทึกเวลา"/>
							<a onmouseover="MM_swapImage('calendar1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="#"><img border="0" align="absmiddle" alt="Calendar" onclick="viewCal('__date2')" name="calendar1" src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif"/></a>
							<input type="text" onmouseout="toolTip()" onmouseover="toolTip('HHMM')" onblur="chkTime(this)" onkeypress="chkInteger(event)" onfocus="this.select()" value="<%=endTime%>" maxlength="5" size="4" name="__time2">
			</td>
	</tr>
	<tr>
		<td  style="padding-left:10px"><%=screen.getUProfile().get("lang").equalsIgnoreCase("THA") ? "รหัสพนักงาน" : "Employee id" %></td>
		<td colspan="3"> 
			<input type="text" name="__empid1" size="10" maxlength="15" value="" onkeypress="chkSpecialStr(event);" onblur="trimValue(this);" onfocus="this.select();" alt="รหัสพนักงาน" onmouseover="toolTip('รหัสพนักงาน')" onmouseout="toolTip()"  value="<%=empid1%>"/>&nbsp;<a href="javascript:goHelp('MEMPLOYEEHELP','__empid1');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__empid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__empid_image" width="20" height="20" border="0" align="absmiddle"  ></a>
			-
			<input type="text" name="__empid2" size="10" maxlength="15" value="" onkeypress="chkSpecialStr(event);" onblur="trimValue(this);" onfocus="this.select();" alt="รหัสพนักงาน" onmouseover="toolTip('รหัสพนักงาน')" onmouseout="toolTip()"   value="<%=empid2%>" />&nbsp;<a href="javascript:goHelp('MEMPLOYEEHELP','__empid2');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__empid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__empid_image" width="20" height="20" border="0" align="absmiddle"  ></a>
		</td>
	</tr>
	<tr>
		<td   style="padding-left:10px">Module</td>
		<td colspan="2"> 
			<!-- <select name="__module" id="module"  style="width:100px">
				<option value="">All</option>
				<option value="TA" <%if(module.equals("TA")) out.print(" selected ");%>>Time Attendance</option>
				<option value="PERSONAL" <%if(module.equals("PERSONAL")) out.print(" selected ");%>>Personal</option>
				<option value="COMPANY" <%if(module.equals("COMPANY")) out.print(" selected ");%>>Company</option>
				<option value="WOR" <%if(module.equals("WOR")) out.print(" selected ");%>>Workflow</option>
				<option value="WELFARE" <%if(module.equals("WELFARE")) out.print(" selected ");%>>Welfare</option>
				<option value="SET" <%if(module.equals("SET")) out.print(" selected ");%>>Setting</option>
				<option value="RECRUIT" <%if(module.equals("RECRUIT")) out.print(" selected ");%>>Recruit</option>
				<option value="TRAINING" <%if(module.equals("TRAINING")) out.print(" selected ");%>>Trianing</option>
				<option value="EMPVIEW" <%if(module.equals("EMPVIEW")) out.print(" selected ");%>>Empview</option>
				<option value="APPRAISAL" <%if(module.equals("APPRAISAL")) out.print(" selected ");%>>Appraisal</option>
				<option value="ER" <%if(module.equals("ER")) out.print(" selected ");%>>ER</option>
				<option value="PAYROLL" <%if(module.equals("PAYROLL")) out.print(" selected ");%>>Payroll</option>
				<option value="MYNOTE" <%if(module.equals("MYNOTE")) out.print(" selected ");%>>Mynote</option>
			</select> -->
			<%=screen.getInput("module_name")%>
		</td>
		<td class="blankspace">
			<button type="button" class="btn btn-primary width100" swlang code="SW013168" onClick="search();">SEARCH</button>
		</td>
	</tr>
	<tr>
      <td class="blankspace" colspan="4"></td>
    </tr>  	
	<!-- Search Zone -->

	<!-- Data View Zone -->
	<tr>
      <td  colspan="4"><div align="right">&lt; <%=screen.getPageTag()%> &gt;</div></td>
    </tr>   	 
	<tr>
		<td colspan="4">
			<table height="" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333" class="maxsize tablewithborder">
				<tr>						
					<td class="row3" align="center" width="">No.</td> 
					<td class="row3" align="center" width="">UserName</td> 
					<td class="row3" align="center" width="">ชื่อ</td> 
					<td class="row3" align="center" width="">Client</td> 
					<td class="row3" align="center" width="">Node</td> 
					<td class="row3" align="center" width="">Login Time</td> 
				<!-- 	<td class="row3" align="center" width="">Module</td>  -->
					<td class="row3" align="center" width="">รหัสหน้าจอ</td> 
				</tr> 
<%
int i = 1;  
if(!screenName.equals("")){
while(screen.nextRec()){ 
%>
				<tr>
					<td align="center">&nbsp;<%=i++%>&nbsp;</td>
					<td>&nbsp;<%=screen.getString("user_code")%>&nbsp;</td>
					<td>&nbsp;<%=screen.getString("memployee","fullname")%>&nbsp;</td>
					<td>&nbsp;<%=screen.getString("remote_ip")%>&nbsp;</td>
					<td>&nbsp;<%=screen.getString("server_name")%>&nbsp;</td>
					<td>&nbsp;<%=screen.getString("login_date")+"   "+screen.getString("login_time")%>&nbsp;</td>
					<!-- <td>&nbsp;<%=screen.getString("module_name")%>&nbsp;</td> -->
					<td>&nbsp;<%=screen.getString("current_page")%>&nbsp;</td>
				</tr>
<% 
}
}
%>
  			</table>		
		</td>
	</tr>
	<!-- Data View Zone -->

	<!-- Button Zone -->
<!-- 	<tr>
      <td class="blankspace" colspan="4" align="center"><a href="javascript:linkPrint();"><img src="../IMAGES/BUTTON/PRINT.gif" alt="Print" width="73" height="23" border="0" align="absmiddle"></a></td>
    </tr> -->
	<!-- Button Zone -->
	<tr>
      <td class="blankspace" colspan="4"></td>
    </tr>
	<tr>
      <td class="header" colspan="4"></td>
    </tr>
  </table>
</form>
</body>
</html>