<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Admin.User.KS_UserCount" Codebehind="KS.UserCount.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Components" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="server">
	<style>
    .w50{width:50%;}
	.highcharts-legend,.highcharts-data-labels{ display:none;}
	.highcharts-background{fill-opacity: 0;}
	.m-TabTitle{position: relative;z-index:99998;}
	.CollageRightInfo{ margin-top:60px;}
	.CollageBox .PrintBox .innerPrintBox{border:0;}
	@media (max-width: 1313px){
		.CollageRightInfo {width: 100%; margin-top:80px;}
	}
    </style>
    <script src="/admin/images/Chart.js"></script>
    <script>
        function OnChange(key) {
             var schoolid=document.getElementById('ctl00_KSContent_DrpSchool').value;
               location.href = "?schooluserid=" + key+"&showType=<%=showType%>&flag=<%=flag%>&action=<%=action %>";
           
        }
    </script>
     <div class="content-area mt20">   
          <table width="100%" border="0" cellpadding="0" cellspacing="0" class="sTable"> 
            	<tr>
                	<td width="100" align="right" class="Lheight36">客户端：</td>
                    <td>
                        <span class="ml20"><a<%=KSCMS.S("showType")==""||KSCMS.S("showType")=="0"?" class='greenFont'":string.Empty %> href="KS.UserCount.aspx?showType=0&flag=<%=flag%>&schooluserid=<%=schoolUserId %>">所有客户端</a></span>
                        <span class="ml20"><a<%=KSCMS.S("showType")=="1"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&showType=1&flag=<%=flag%>&schooluserid=<%=schoolUserId %>">PC端</a></span>
                        <span class="ml20"><a<%=KSCMS.S("showType")=="2"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&showType=2&flag=<%=flag%>&schooluserid=<%=schoolUserId %>">微信端</a></span>
                        <span class="ml20"><a<%=KSCMS.S("showType")=="3"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&showType=3&flag=<%=flag%>&schooluserid=<%=schoolUserId %>">WAP端</a></span>
                        <span class="ml20"><a<%=KSCMS.S("showType")=="4"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&showType=4&flag=<%=flag%>&schooluserid=<%=schoolUserId %>">APP端</a></span>
                    </td>
                </tr>
                <tr>
                	<td width="100" align="right" class="Lheight36">选择时间段：</td>
                    <td>
                          <span class="ml20"><a<%=KSCMS.S("flag")==""||KSCMS.S("flag")=="0"||(action=="userdetail"&&flag==4)?" class='greenFont'":string.Empty %> href="?action=<%=action %>&flag=0&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">所有</a></span>
                        <span class="ml20"><a<%=KSCMS.S("flag")=="5"?" class='greenFont'":string.Empty %> href="KS.UserCount.aspx?action=<%=action %>&flag=5&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">今日</a></span>
                        <span class="ml20"><a<%=KSCMS.S("flag")=="1"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&flag=1&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">昨日</a></span>
                        <span class="ml20"><a<%=KSCMS.S("flag")=="2"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&flag=2&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">最近7日</a></span>
                        <span class="ml20"><a<%=KSCMS.S("flag")=="3"?" class='greenFont'":string.Empty %> href="?action=<%=action %>&flag=3&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">最近30日</a></span>
                        
                        <%if (string.IsNullOrEmpty(action))
                                {%>
                        <spanx class="ml20"><a<%=KSCMS.S("flag") == "4" ? " class='greenFont'" : string.Empty %> href="?action=<%=action %>&flag=4&showType=<%=showType%>&schooluserid=<%=schoolUserId %>">按时间段</a></span>
                            <%} %>
                        <%if (string.IsNullOrEmpty(action)&&KSCMS.S("flag") == "4"&&(BaseFun.CheckModulePower("school") && System.IO.Directory.Exists(Utils.GetMapPath("/admin/enterprise/")) == true)&&Utils.StrToInt(new EpConfig().GetEpConfig(19)) == 1 && Utils.StrToInt(new EpConfig().GetEpConfig(36), 0) == 1)
						  { %>
							<asp:TextBox CssClass="textbox Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" Width="150" ID="TxtBeginDate" runat="server"></asp:TextBox>
							至&nbsp;&nbsp;<asp:TextBox CssClass="textbox Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" Width="150" ID="TxtEndDate" runat="server"></asp:TextBox>
							选择机构:
                            <asp:DropDownList ID="DropDownList2" runat="server" Style="margin-right: 8px;" >
                                <asp:ListItem Value="0">全部机构</asp:ListItem>
                         </asp:DropDownList>
                            <asp:Button ID="BtnSearch" runat="server" Text="查询" CssClass="button" OnClick="BtnSearch_Click" />
						<%} %>
                    </td>
                </tr>
                    <%if (flag!=4&&(BaseFun.CheckModulePower("school") && System.IO.Directory.Exists(Utils.GetMapPath("/admin/enterprise/")) == true)&&Utils.StrToInt(new EpConfig().GetEpConfig(19)) == 1 && Utils.StrToInt(new EpConfig().GetEpConfig(36), 0) == 1)
                        { %>
                 <tr>
                	<td width="100" align="right" class="Lheight36">选择机构：</td>
                    <td>
                        <span class="ml20">
                            <asp:DropDownList ID="DrpSchool" runat="server" Style="margin-right: 8px;" onchange="OnChange(this.value);">
                                <asp:ListItem Value="0">全部机构</asp:ListItem>
                         </asp:DropDownList>
                 </span>
                </td>
                 </tr>
                <%} %>
                     <tr style="display:none;">
                	<td width="100" align="right" class="Lheight36"></td>
                    <td>
						<%if (KSCMS.S("flag") == "4")
                          { %>
                        	<div class="tips"><asp:Label ID="LabTips" runat="server"></asp:Label></div>
                        <%} %>
                    </td>
                </tr>
            </table>
      <asp:Panel ID="ListPanel" runat="server" Width="100%">
              
            <div class="myTitle clearfix" style="display:none"><asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CssClass="fr button">导出</asp:LinkButton>用户统计</div>
            <div class="CollageBox clearfix mt20">
                <div class="fl w50">
                    <table width="99%" style="margin-top: 10px" border="0" cellpadding="1" cellspacing="1" class="CTable">
                        <tr>
                            <td align="center">
                                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="650" height="400" id="OrderGeneral" align="middle">
                                    <param name="FlashVars" value="&dataXML=<graph caption='会员注册统计(单位：人)' decimalPrecision='2' formatNumberScale='0' showPercentageValues='0' showNames='1' showValues='1' showPercentageInLabel='0' pieYScale='45' pieBorderAlpha='40' pieFillAlpha='70' pieSliceDepth='15' pieRadius='100' outCnvBaseFontSize='13' baseFontSize='12'><%=InialStr() %></graph>">
                                    <param name="movie" value="../../ks_inc/part/pie3d.swf?chartWidth=650&chartHeight=400">
                                    <param name="quality" value="high">
                                    <param name="bgcolor" value="#FFFFFF">
                                    <param name="wmode" value="opaque" />
                                    <embed src="../../ks_inc/part/pie3d.swf?chartWidth=650&chartHeight=400" flashvars="&dataXML=<graph caption='用户地区统计(单位：个)' decimalPrecision='2' formatNumberScale='0' showPercentageValues='0' showNames='1' showValues='1' showPercentageInLabel='0' pieYScale='45' pieBorderAlpha='40' pieFillAlpha='70' pieSliceDepth='15' pieRadius='100' outCnvBaseFontSize='13' baseFontSize='12'><%=InialStr() %></graph>" quality="high" bgcolor="#FFFFFF" width="650" height="400" wmode="opaque" name="OrderGeneral" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
                                </object>
                            </td>
                        </tr>
                    </table>
                </div>
            	<%if ((BaseFun.CheckModulePower("school") && System.IO.Directory.Exists(Utils.GetMapPath("/admin/enterprise/")) == true) && Utils.StrToInt(new EpConfig().GetEpConfig(19)) == 1 && Utils.StrToInt(new EpConfig().GetEpConfig(36), 0) == 1)
                 { %>
            	<!--圆形图统计-->
            
                <div class="PrintBox">
                    <div class="innerPrintBox">
                        <div class="f16 Lheight md20 m-TabTitle">用户分组慨况 <span class="blackTipsBox"><i></i><font class="blackTips">（单位：个）</font></span></div>
                        <div class="clearfix">
                            <div class="CollageForm fl" data-chart="学生个数,<%=totalStudentUser %>|老师个数,<%=totalTeacherUser  %>|机构个数,<%=totalSchoolUser  %>">
                                <div id="Annular1"></div>
                            </div>
                            <ul class="CollageRightInfo fl">
                                <li class="Collagenum clearfix"><span class="fr f12"><%=totalStudentUserRate.ToString("f2") %>%</span><b class="no1"></b><div class="CollageTit">学生个数<span class="Percentage"><%=totalStudentUser%>个</span></div>
                                </li>
                                <li class="Collagenum clearfix"><span class="fr f12"><%=totalTeacherUserRate.ToString("f2")  %>%</span><b class="no6"></b><div class="CollageTit">老师个数<span class="Percentage"><%=totalTeacherUser%>个</span></div>
                                </li>
                                <li class="Collagenum clearfix"><span class="fr f12"><%=totalSchoolUserRate.ToString("f2")  %>%</span><b class="no2"></b><div class="CollageTit">机构个数<span class="Percentage"><%=totalSchoolUser%>个</span></div>
                                </li>
                            </ul>
                        </div>

                    </div>
                </div>
                <script>
                    var Highcharts, colorStyle;
                    loadHighcharts(function () {
                        Annular('Annular1', '用户分组慨况','<%=totalUser %>', function () {
            
                        })
                    }, 10)

                    function loadHighcharts(fn, num) {
                        colorStyle = num;
                        Highcharts = null;
                        var script = document.createElement('script');
                        script.src = '/admin/images/highcharts.js';
                        document.head.appendChild(script);
                        script.onload = function () {
                            this.outerHTML = null;
                            typeof fn === 'function' && fn()
                        }
                    }

                    /**
                    * 环形统计表obj:显示体表div的id，title:环形中间的标题，allnum:环形中间的数值，fn:回调的参数
                    */

                    function Annular(obj, title, allnum, fn) {

                        var currArray = new Array();
                        var dataSplit = $('#' + obj).parent('.CollageForm').attr('data-chart').split('|');
                        var dataLength = dataSplit.length;
                        for (var i = 0; i < dataLength; i++) {
                            var name = dataSplit[i].split(',')[0];
                            var data = Number(dataSplit[i].split(',')[1]);
                            currArray[i] = [name, data];
                        };
                        var chart = Highcharts.chart(obj, {
                            chart: {
                                spacing: [10, 0, 10, 0]
                            },
                            title: {
                                floating: true,
                                text: '<span class="orderAll">' + title + '</span><br><font class="orderData">' + allnum + '</font>',
                                align: "center",
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || '#999'
                                }
                            },
                            plotOptions: {
                                pie: {
                                    size: 200
                                }
                            },
                            tooltip: {
                                pointFormat: '<b>{point.percentage:.1f}%</b>'
                            },

                            series: [{
                                type: 'pie',
                                innerSize: '85%',
                                data: currArray
                            }]
                        }, function (c) {
                            // 环形图圆心
                            var centerY = c.series[0].center[1],
                                titleHeight = parseInt(c.title.styles.fontSize);
                            // 动态设置标题位置
                            c.setTitle({
                                y: centerY
                            });
                            typeof fn === 'function' && fn()
                        });

                    }
                </script>
                <%} %>
            </div>
            

            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table width="99%" border="0" cellpadding="2" cellspacing="1" class="CTable">
                        <tr align="center" class="CTitle">

                            <td width="50" align="center"><b>序号</b></td>
                            <td width="80" align="center"><b>客户端</b></td>
                            <td align="center"><b>会员总数</b></td>
                            <%if(BaseFun.CheckModulePower("school") && System.IO.Directory.Exists(Utils.GetMapPath("/admin/enterprise/")) == true&& Utils.StrToInt(new EpConfig().GetEpConfig(19)) == 1 && Utils.StrToInt(new EpConfig().GetEpConfig(36), 0) == 1)
                                { %>
                             <td align="center"><b>学生个数</b></td>
                             <td align="center"><b>老师个数</b></td>
                             <td align="center"><b>机构个数</b></td>
                            <%} %>
                            <td align="center"><b>占总会员比率</b></td>
                          
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr class="tdbg">
                        <td align="center">
                            <%#Container.ItemIndex+1%>
                        </td>
                        <td align="center">
                            <%# Utils.OrderDeviceName(Utils.StrToInt(Eval("OrderDevice"))) %>
                        </td>
                        <td align="center">
                           <a href="?action=userdetail&schooluserid=<%#schoolUserId %>&flag=<%#flag%>&showType=<%#showType %>"><%#GetUserCount(Utils.StrToInt(Eval("OrderDevice")),flag,0,schoolUserId) %></a>
                        </td>
                        <%if (BaseFun.CheckModulePower("school") && System.IO.Directory.Exists(Utils.GetMapPath("/admin/enterprise/")) == true && Utils.StrToInt(new EpConfig().GetEpConfig(19)) == 1 && Utils.StrToInt(new EpConfig().GetEpConfig(36), 0) == 1)
                            { %>
                        <td align="center">
                            <%#GetUserCount(Utils.StrToInt(Eval("OrderDevice").ToString()),flag,1,schoolUserId) %>
                        </td>
                         <td align="center">
                             <%#GetUserCount(Utils.StrToInt(Eval("OrderDevice").ToString()),flag,2,schoolUserId) %>
                        </td>
                         <td align="center">
                             <%#GetUserCount(Utils.StrToInt(Eval("OrderDevice").ToString()),flag,3,schoolUserId) %>
                        </td>
                        <%} %>
                        <td align="center">
                           <%#GetUserCountRate(Utils.StrToInt(Eval("OrderDevice")),flag,schoolUserId).ToString("f2") %>%
                        </td>
                    </tr>

                </ItemTemplate>
                <FooterTemplate>

                    <tr class="tdbg" style="display: <%# bool.Parse((Repeater1.Items.Count==0).ToString())?"":"none"%>">
                        <td class="Ctd" style="text-align: center" colspan="12">
                            <div class="empty">没有会员注册统计的数据</div>
                        </td>
                    </tr>
                </FooterTemplate>
            </asp:Repeater>
        
    </asp:Panel>


    <asp:Panel ID="Panel1" runat="server">
        <asp:Repeater ID="Repeater2" runat="server">
        <HeaderTemplate>
        <table width="100%"border="0" cellpadding="1" cellspacing="1" class="CTable">
            <tr class="CTitle">
                <td   style="text-align:center">用户昵称</td>
                <td   style="text-align:center">用户类型</td>
                <td   style="text-align:center">注册时间</td> 
            </tr>
        </HeaderTemplate>
        <ItemTemplate>
              <tr>
            <td class="Ctd" style="text-align:center"><%#Eval("username") %></td>
              <td class="Ctd" style="text-align:center"><%#Eval("groupname") %></td>
            <td class="Ctd" style="text-align:center"><%#Eval("regdate") %></td>
        </tr>
        </ItemTemplate>
        <FooterTemplate>
            <tr class="tdbg" style="display: <%# bool.Parse((Repeater2.Items.Count==0).ToString())?"":"none"%>">
                <td class="Ctd" style="text-align: center" colspan="3">
                    <div class="empty">没有会员记录</div>
                </td>
            </tr>
            </table>
        </FooterTemplate>
        </asp:Repeater>
        <KS:Page ID="Page1" runat="server" />
        <script>
            function OnChange2(key) {
                var schoolid=document.getElementById('ctl00_KSContent_DropDownList1').value;
                location.href = "?action=userdetail&schooluserid=" + key+"&showType=<%=showType%>&flag=<%=flag%>";
            
            }
        </script>
    </asp:Panel>
    
</div>
<div class="mt20 clearfix">
    <div class="activty-customer mt20">
        <asp:Panel ID="Panel2" runat="server" Width="100%">
            <div class="myTitle">
                活跃会员
            </div>
            <div class="customerList clearfix mt20" id="courseList2">
                <ul>
                    <asp:Repeater ID="Repeater3" runat="server">
                        <ItemTemplate>
                            <li>
                                <div class="customer-head fl"><img src="<%#Userface( Utils.StrToInt( Eval("userid"))) %>" onerror="this.src='/admin/images/imagespic_200_200.png'"/></div>
                                <div class="fl customerInfo">    
                                    <h4><%#Eval("UserName") %></h4>
                                    <p>活跃度：<font class="c-red"><%#Kesion.APPCode.Public.ReturnShopPrice( getliveness(Utils.StrToInt( getlogintimes( Utils.StrToInt( Eval("userid")))))) %>%</font></p>
                                    <p>上次登录：<%# getlastlogin(Utils.StrToInt(Eval("userid"))) %></p>
                                </div>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                            <div class="empty" style="display:<%# bool.Parse((Repeater3.Items.Count==0).ToString())?"":"none"%>">
                                不好意思暂无数据
                            </div> 
                        </FooterTemplate>
                    </asp:Repeater>
                </ul>
            </div>
        </asp:Panel>
    </div>
    <div class="activty-customer mt20 md20">
        <asp:Panel ID="Panel3" runat="server" Width="100%">
            <div class="myTitle">
                不活跃会员
            </div>
            <div class="customerList clearfix mt20" id="courseList3">
                <ul>
                    <asp:Repeater ID="Repeater4" runat="server">
                        <ItemTemplate>
                                <li>
                                <div class="customer-head fl"><img src="<%#Userface( Utils.StrToInt( Eval("userid"))) %>" onerror="this.src='/admin/images/imagespic_200_200.png'"/></div>
                                <div class="fl customerInfo">    
                                    <h4><%#Eval("UserName") %></h4>
                                    <p>活跃度：<font class="c-red"><%#Kesion.APPCode.Public.ReturnShopPrice( getliveness(Utils.StrToInt( getlogintimes( Utils.StrToInt( Eval("userid")))))) %>%</font></p>
                                    <p>上次登录：<%# getlastlogin(Utils.StrToInt(Eval("userid"))) %></p>
                                </div>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                                <div class="empty" style="display:<%# bool.Parse((Repeater4.Items.Count==0).ToString())?"":"none"%>">
                                不好意思暂无数据
                            </div> 
                        </FooterTemplate>
                    </asp:Repeater>
                </ul>
            </div>
        </asp:Panel>
    </div>
</div>
  
</asp:Content>
