<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ page import="net.sz600.organize.*" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ include file="/sessionInfo.jsp"%>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<script language="javascript">
 function checkMonth(oFormName, sV, sUrl) {
 	oFormName.chkDate.value = sV;
 	oFormName.action = sUrl;
 	oFormName.target = "_self";
 	oFormName.submit();
 }
</script>
<script language="javascript">
  function VisitDetail(key) {
    var type= "";
    var url = "../../newcustomer/visit/detail.jsp?OPERATOR=detail&type=0&KEY=" + key;
    window.showModalDialog(url,window,"status=no;dialogWidth=780px;dialogHeight=550px");  
  }
  function VisitDetail2(key) {
    var type= "";
    var url = "../../newcustomer/info/detail.jsp?OPERATOR=detail&type=0&KEY=" + key;
    window.showModalDialog(url,window,"status=no;dialogWidth=780px;dialogHeight=550px");  
  }  
</script>
</head>
<%
    
	  String sSearchId = SzConvert.strWriteData(request.getParameter("txtSearchId"));
		String sSearchName = SzConvert.strWriteData(request.getParameter("txtSearchName"));
	  String sSearchDepart = SzConvert.strWriteData(request.getParameter("txtSearchDepart"));
	  //查询时间段
	  String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
	  String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));  
	    
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String selectDay = SzConvert.toSpaceStr(request.getParameter("selectDay"));
    

    
    String chkDate = SzConvert.toZeroStr(request.getParameter("chkDate"));
    Date fDate = null;
    Date lDate = null;
    if (chkDate.equals("1")) {
    	fDate = SzDateHelp.getFirstDatePrioMonth(SzDateHelp.stringToDate(sSearchBegin));
    	sSearchBegin = SzDateHelp.dateToYMD(fDate);
    	lDate = SzDateHelp.getLastDateMonth(fDate);
    	sSearchEnd = SzDateHelp.dateToYMD(lDate);
   	} else if (chkDate.equals("2")) {   	
   		fDate = SzDateHelp.getFirstDateNextMonth(SzDateHelp.stringToDate(sSearchBegin));
			sSearchBegin = SzDateHelp.dateToYMD(fDate);
			lDate = SzDateHelp.getLastDateMonth(fDate);
			sSearchEnd = SzDateHelp.dateToYMD(lDate);   	  	
   	} else if (chkDate.equals("0") || sSearchBegin.equals("") || sSearchEnd.equals("")) {
   		//本周
   		fDate = SzDateHelp.getFirstDateMonth();
   		sSearchBegin = SzDateHelp.dateToYMD(SzDateHelp.getFirstDateMonth());
   		lDate = SzDateHelp.getLastDateMonth();
   		sSearchEnd = SzDateHelp.dateToYMD(SzDateHelp.getLastDateMonth());
   	} else {
   		fDate = SzDateHelp.stringToDate(sSearchBegin);
   		lDate = SzDateHelp.stringToDate(sSearchEnd);
   	}
    
    String sTable_type = "";

		SzLogControl logControl = new SzLogControl();  
		int iSearchId = SzConvert.toInt(sSearchId);
		if (iSearchId == 0) {
			iSearchId = iDLID_SESSION;
		}
		
		HashMap mapLoginCount = logControl.statLoginCount(iSearchId, sSearchBegin, sSearchEnd);
		HashMap mapLoginTime = logControl.statLastLoginTime(iSearchId, sSearchBegin, sSearchEnd);

		int i = 0;
		int j = 0;
%>
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="chkDate" value="-1">
  <tr>
    <td>
			<input type="button" value="本月" class="btnClass" name="prioWeek" OnClick="javascript:checkMonth(formBar, '0', 'stat.jsp');">
	 		<input type="button" value="上月" class="btnClass" name="prioWeek" OnClick="javascript:checkMonth(formBar, '1', 'stat.jsp');">
      <input type="button" value="下月" class="btnClass" name="nextWeek" OnClick="javascript:checkMonth(formBar, '2', 'stat.jsp');">

      开始<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>" readonly>
      结束<input type="text" name="txtSearchEnd" class="txtClassSearch" value="<%=sSearchEnd%>" readonly>
     <% if (isBarManager_SESSION) { %>
     <input type="hidden" name="txtSearchId" class="txtClassSearch" value="<%=iSearchId%>">
     按人员查<input type="text" name="txtSearchName" class="txtClassSearch" value="<%=sSearchName%>" OnDblClick="javascript:OpenWin12('formBar.txtSearchId','formBar.txtSearchName','all');">
     <input class="btnClass" type="button" name="btnSearchNameOk" value="确定" OnClick="javascript:FormSubmit(formBar,'stat.jsp');">
     <% } %>
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="chkDate" value="-1">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>"> 
  <input type="hidden" name="txtSearchId" value="<%=iSearchId%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">       
  <tr class="trClassTitle">
    <td width="80">日期</td>
		<td>普通登陆次数/最后登陆时间</td>
		<td>微信登陆次数/最后登陆时间</td>
		<td>微信签到次数/最后签到时间</td>		
  </tr>
<%
	  String value_str[] = null;
		String strDate = "";
		Date date = fDate;
		Date nextDate = null;
		int k = 0;
		String strCond = "";
		int iSize = 0;
		
		String sLogin = "";
		String sLoginWeixin = "";
		String sSigninWeixin = "";
		
		while (true) {
			strDate = SzDateHelp.dateToYMD(date);
			sLogin = "";
			sLoginWeixin = "";
			sSigninWeixin = "";
			sLogin = logControl.getLoginInfo(mapLoginCount, mapLoginTime, "登陆", strDate);
			sLoginWeixin = logControl.getLoginInfo(mapLoginCount, mapLoginTime, "微信登陆", strDate);
			sSigninWeixin = logControl.getLoginInfo(mapLoginCount, mapLoginTime, "微信签到", strDate);		
			%>
			<tr>
				<td align="left" ><%=SzDateHelp.dateToString(date, "yyyy-MM-dd")%> <%=SzDateHelp.getWeekName(date) %></td>
				<td align="center"><%=sLogin %></td>
				<td align="center"><%=sLoginWeixin %></td>
				<td align="center"><%=sSigninWeixin %></td>
			</tr>								
			<%					  
			date = SzDateHelp.dayAfter(date,1);		
			if (date.after(lDate)) {
				break;
			}
		} //for (k = 0; k<7; k++ )			
  	String temp = "";
%>		

  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="chkDate" value="-1">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">   
  <input type="hidden" name="txtSearchId" value="<%=iSearchId%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">   
  <tr>
    <td align="right">

    </td>
  </tr>
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="chkDate" value="-1">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">   
  <input type="hidden" name="txtSearchId" value="<%=iSearchId%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">       
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  function OpenWin(objName,type) {
    var url = "../../share/organize/name_single_win.jsp";
    url = url + "?objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
    //window.open(url,"","status=no;Width=580px;Height=350px");
  }
</script>
<%
    //map = null;
%>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame2());
%>
