<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="Kesion.Weixin" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
	DataRow dr = null;

	public static int pagesize = 20;
	public float DayRate = 0;
	public float WeekRate = 0;
	public float MonthRate = 0;
	public int TodayDayCount = 0;
	public int TodayWeekCount = 0;
	public int TodayMonthCount = 0;
	public int YesDayCount = 0;
	public int YesWeekCount = 0;
	public int YesMonthCount = 0;
	public string ThisDayRate = "---";
	public string ThisWeekRate = "---";
	public string ThisMonthRate = "---";
	public string ToDayTitle = string.Empty;
	public string MonthTitle = string.Empty;
	public string WeekTitle = string.Empty;
	protected void Page_Load(object sender, EventArgs e)
	{
		TodayDayCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(day,[Subscribe_Time],getdate())=0 and schoolID="+new TemporaryVar().UserID+""));
		TodayWeekCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(week,[Subscribe_Time],getdate())=0 and schoolID=" + new TemporaryVar().UserID + ""));
		TodayMonthCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(month,[Subscribe_Time],getdate())=0 and schoolID=" + new TemporaryVar().UserID + ""));
		YesDayCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(day,[Subscribe_Time],getdate())-1=0 and schoolID=" + new TemporaryVar().UserID + ""));
		YesWeekCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(week,[Subscribe_Time],getdate())-1=0 and schoolID=" + new TemporaryVar().UserID + ""));
		YesMonthCount = Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(month,[Subscribe_Time],getdate())-1=0 and schoolID=" + new TemporaryVar().UserID + ""));
		DayRate = Utils.StrToFloat(Utils.StrToFloat((TodayDayCount - YesDayCount)) / Utils.StrToFloat(YesDayCount)) * 100 / 100;
		WeekRate = Utils.StrToFloat(Utils.StrToFloat((TodayWeekCount - YesWeekCount)) / Utils.StrToFloat(YesWeekCount)) * 100 / 100;
		MonthRate = Utils.StrToFloat(Utils.StrToFloat((TodayMonthCount - YesMonthCount)) / Utils.StrToFloat(YesMonthCount)) * 100 / 100;
		if (DayRate < 0)
		{
			ToDayTitle = "<i class=\"icon_down\" title=\"下降\"></i>";
			string[] ttt = (Utils.StrToFloat(DayRate).ToString("f2")).Split('-');
			ThisDayRate = ttt[1];
		}
		else if (DayRate == 0)
		{
			ToDayTitle = "&nbsp;&nbsp;&nbsp;";
			ThisDayRate = "--";
		}
		else
		{
			ToDayTitle = "<i class=\"icon_up\" title=\"上升\"></i>";
			ThisDayRate = Utils.StrToFloat(DayRate).ToString("f2");
		}
		if (WeekRate < 0)
		{
			WeekTitle = "<i class=\"icon_down\" title=\"下降\"></i>";
			string[] ttt = (Utils.StrToFloat(WeekRate).ToString("f2")).Split('-');
			ThisWeekRate = ttt[1];
		}
		else if (WeekRate == 0)
		{
			WeekTitle = "&nbsp;&nbsp;&nbsp;";
			ThisWeekRate = "--";
		}
		else
		{
			WeekTitle = "<i class=\"icon_up\" title=\"上升\"></i>";
			ThisWeekRate = Utils.StrToFloat(WeekRate).ToString("f2");
		}
		if (MonthRate < 0)
		{
			MonthTitle = "<i class=\"icon_down\" title=\"下降\"></i>";
			string[] ttt = (Utils.StrToFloat(MonthRate).ToString("f2")).Split('-');
			ThisMonthRate = ttt[1];
		}
		else if (MonthRate == 0)
		{
			MonthTitle = "&nbsp;&nbsp;&nbsp;";
			ThisMonthRate = "--";
		}
		else
		{
			MonthTitle = "<i class=\"icon_up\" title=\"上升\"></i>";
			ThisMonthRate = Utils.StrToFloat(MonthRate).ToString("f2");
		}
		string DoMethod = BasicField.GetParam("do");
		if (string.IsNullOrEmpty(DoMethod))
		{
			DoMethod = KSCMS.S("action");
		}
		switch (DoMethod)
		{
			case "":

				break;
		}
	}

	

</script>
<%
	if (!isLoadPage) return;
%>
 <link href="/SysImg/teacher/css/newswx.css" rel="stylesheet" />
 <div class="t_tybox">
  <div class="tytitle"><h4>微信公众号统计</h4></div>
  <form name="myForm" method="post" action="<%=BasicField.GetUserUrl("wx/wx_Count") %>" id="myForm">
  <div class="console_body">   
   <asp:Panel ID="Panel1" runat="server">

       <div>
	       <div class="top_count">

			   <div class="count_left">
				   <a href="<%=BasicField.GetUserUrl("wx/wx_Sendmsg","adddate-"+DateTime.Now.ToShortDateString()) %>">
					   <span class="tap_inner o1">
							<i class="icon_index_tap"></i>
							<em class="number"><%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinMsg where datediff(day,[AddTime],getdate())=0 and MsgType!='event' and tousername='"+ks_weixin.WeiXinOpenID(1)+"'")) %></em>
							<strong class="title">新消息</strong>
					   </span>
				   </a>
				   <a href="<%=BasicField.GetUserUrl("wx/wx_Userlist","adddate-"+DateTime.Now.ToShortDateString()) %>">
					   <span class="tap_inner no_extra o2">
							<i class="icon_index_tap"></i>
							<em class="number"><%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(day,[Subscribe_Time],getdate())=0 and schoolID="+new TemporaryVar().UserID+"")) %></em>
							<strong class="title">新增人数</strong>
					   </span>
				   </a>
			       <div class="clear"></div>
			   </div>
			   <div class="count_right">
				   <a href="<%=BasicField.GetUserUrl("wx/wx_Userlist") %>">
					   <span class="tap_inner o3">
							<i class="icon_index_tap"></i>
							<em class="number"><%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where schoolID="+new TemporaryVar().UserID+"")) %></em>
							<strong class="title">总用户数</strong>
					   </span>
				   </a>
			   </div>
			   <div class="clear"></div>
           </div>
           <div class="bottom_count">
               <div class="bottom_count_item">
                   <div  class="count_item_title">
                     <span><i class="count_icon icon1"></i>新关注人数</span>
                    
                   </div>
                   <div class="count_item_con">
				       <div class="count_item_con_left"><span class="ui_trendgrid_number"><strong><%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinOpenuser where datediff(day,[Subscribe_Time],getdate())=0 and schoolID="+new TemporaryVar().UserID+"")) %></strong></span></div>
                       <div class="count_item_con_right">
						   <dd>日 <%= ToDayTitle%><%=ThisDayRate %></dd>
						   <dd>周 <%=WeekTitle %><%=ThisWeekRate %> </dd>
						   <dd style="border-bottom: none;">月 <%=MonthTitle %><%=ThisMonthRate %> </dd>
					   </div>
                   </div>
               </div>
               <div class="bottom_count_item two">
                 <div class="count_item_title"><span><i class="count_icon icon2"></i>素材管理</span></div>
                   <div class="midel">
                       <a href="<%=BasicField.GetUserUrl("wx/wx_Picmsg") %>">总素材数（<%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinPigmsg where userID="+new TemporaryVar().UserID+"")) %>）</a>
                   </div>
                   <div class="down">
                       <a href="<%=BasicField.GetUserUrl("wx/wx_Picmsg","adddate-"+DateTime.Now.ToShortDateString()) %>">今日新增素材数（<%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinPigmsg where datediff(day,[AddTime],getdate())=0 ")) %>）</a>
                   </div>
               </div>
               <div class="bottom_count_item">
                   <div class="count_item_title">
                       <span><i class="count_icon icon3"></i>关键字管理</span>
                   </div>
                   <div class="midel">
                        <a href="<%=BasicField.GetUserUrl("wx/wx_Keyword") %>">总关键字数（<%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinKeyWord where userID="+new TemporaryVar().UserID+"")) %>）</a>
                   </div>
                   <div class="down">
                      <a href="<%=BasicField.GetUserUrl("wx/wx_Keyword","adddate-"+DateTime.Now.ToShortDateString()) %>">今日新增关键字数（<%=Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_WeixinKeyWord where datediff(day,[AddTime],getdate())=0 and userID="+new TemporaryVar().UserID+"")) %>）</a>
                   </div>
               </div>
			   <div class="clear"></div>
           </div>
            <div class="fans_count">
			 <table width="96%" class="CTable count_table" align="center" border="0" cellpadding="0" cellspacing="0" >
						<tr class="CTitle">
						  <td>微信头像</td>
						  <td>昵称（备注名）</td>
						  <td>性别</td>
						  <td>关注时间</td>
						  <td>城市</td>
						
						</tr>       
			<%
				int CurrPage = new BasicField().GetCurrPage;
				string sqlParam = "ks_weixinopenuser where datediff(day,[Subscribe_Time],getdate())=0 and schoolID=" + new TemporaryVar().UserID + "";
            int recordcount, pagecount;
			using (DataTable dt = DataFactory.GetPage("*", sqlParam, "id", "order by subscribe_time desc", CurrPage, pagesize, out recordcount, out pagecount))
			{
				if (dt.Rows.Count > 0)
				{
					foreach (DataRow dr in dt.Rows)
					{ 
		KSCMS.W("<tr><td align=\"center\"> <img src=\""+ dr["headimgurl"].ToString()+"\" height=\"40\" width=\"50\"></td>"+
					"<td align=\"center\" style=\"color: #999;\">"+dr["nickname"].ToString()+(Convert.ToString(dr["Remark"].ToString())==string.Empty?"":"<font color='red'>("+dr["Remark"].ToString()+")</font>") +"</td>"+
					 "<td align=\"center\" style=\"color: #999;\">"+(dr["sex"].ToString()=="1"?"男":"女")+"</td>"+
					 "<td align=\"center\" style=\"color: #999;\">"+dr["subscribe_time"].ToString()+"</td>"+
					 "<td align=\"center\" style=\"color: #999;\">"+dr["city"].ToString()+"</td></tr>");
					}
				}else
				{
					KSCMS.W(" <tr width=\"100%\" ><td colspan=\"9\"><div class=\"empty\">今日暂无新增的粉丝信息</div></td></tr>");
				}
			}
	   
	    %>

				  </table>
           </div>
       </div>
       <div class="fy_box">
   <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, CurrPage, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
       </div>
       <div class="clear"></div>
   </asp:Panel>
   
  </div>
  </form>
 </div>
