<%@ Page Language="c#" Inherits="WebApp.NewsStat" CodeBehind="NewsStat.aspx.cs" EnableEventValidation="false" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>子站新闻发布量查询</title>
    <meta name="description" content="overview &amp; stats" />
    <!--#include file = "../assets/head.htm" -->
    <style type="text/css">
        .radio input[type="radio"] {
            position: static;
            margin: 0;
        }
    </style>

</head>
<body class="no-skin">
    <form id="frmNewsStat" method="post" runat="server">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try { ace.settings.check('breadcrumbs', 'fixed') } catch (e) { }
                </script>

                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        主页
                    </li>
                    <li>站点运行监控</li>
                    <li class="active">站点发文统计</li>
                </ul>
                <!-- /.breadcrumb -->

                <!-- /section:basics/content.searchbox -->
            </div>
            <!-- /section:basics/content.breadcrumbs -->

            <div class="page-content">
                <!-- PAGE CONTENT BEGINS -->
                <h3 class="header smaller lighter blue">
				发文统计 & 数据分析
				    <small><i class="ace-icon fa fa-angle-double-right"></i>&emsp;最新统计时间：<%= BindUpdateTime() %></small>
				    <asp:Button ID="btnUpdate" runat="server" Text="重新统计所有站点的数据" CausesValidation="False" OnClientClick="javascript:queryform();return true;" OnClick="btnUpdate_Click" CssClass="btn btn-xs btn-primary" ></asp:Button>
				</h3>
				
                <%--<div class="row">
                    <div class="col-xs-12">

                            <div class="col-sm-5">
                                <div class="form-group">
                                    <div class="radio pull-left">
                                        <label>
                                            <asp:RadioButton ID="rbStat1" Checked="True" runat="server" GroupName="Stat" CssClass="ace"></asp:RadioButton>
                                            <span class="lbl">从最新时间开始继续统计</span>
                                        </label>
                                        <label>
                                            <asp:RadioButton ID="rbStat2" runat="server" GroupName="Stat" CssClass="ace"></asp:RadioButton>
                                            <span class="lbl">重新统计所有站点的数据</span>
                                        </label>
                                    </div>
                                </div>                            
                            </div>
                            <div class="col-sm-2">
                                
                            </div>
                    </div>
                </div>--%>
                
                <div class="row form-horizontal">
                    <div class="col-xs-12">
                        <div class="col-sm-5">
                            <p>
                                <label class="control-label bolder blue">站点列表：</label>
                                <asp:Button ID="btnSelSchools" runat="server" Text="选择站点" CssClass="btn btn-sm btn-primary"></asp:Button>
                            </p>
                            <asp:ListBox ID="schoolList" runat="server" Width="100%" Rows="8" Height="216px"></asp:ListBox>
                            <input id="updated" type="hidden" value="false" name="Hidden1" runat="server" />
                            <input id="d_name" type="hidden" name="Hidden1" runat="server" />
                            <input id="d_value" type="hidden" name="Hidden2" runat="server" />
                        </div>
                        <div class="col-sm-7">
                            <div class="form-group">
                                <label class="control-label bolder blue col-sm-2">报表类型：</label>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="rbMonth" Checked="True" runat="server" GroupName="query" onclick="showTime(1)" CssClass="ace"></asp:RadioButton>
                                        <span class="lbl">月报</span>
                                    </label>
                                </div>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="rbyear" runat="server" GroupName="query" onclick="showTime(2)" CssClass="ace"></asp:RadioButton>
                                        <span class="lbl">年报</span>
                                    </label>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="control-label bolder blue col-sm-2" title="创建首个子站点的时间">开始时间：</label>&emsp;
                                <asp:DropDownList ID="ddlYearFrom" runat="server"></asp:DropDownList>&nbsp;年&nbsp;
                                <select id="ddlMonthFrom" runat="server">
                                  <option selected="selected">1</option>
                                  <option>2</option>
                                  <option>3</option>
                                  <option>4</option>
                                  <option>5</option>
                                  <option>6</option>
                                  <option>7</option>
                                  <option>8</option>
                                  <option>9</option>
                                  <option>10</option>
                                  <option>11</option>
                                  <option>12</option>
                                </select>
                                <div style="display: inline; width: 70px; height: 15px" id="month1" runat="server">
                                    月
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label bolder blue col-sm-2">结束时间：</label>&emsp;
                                <asp:DropDownList ID="ddlYearTo" runat="server"></asp:DropDownList>&nbsp;年&nbsp;
                                <select id="ddlMonthTo" runat="server">
                                  <option selected="selected">1</option>
                                  <option>2</option>
                                  <option>3</option>
                                  <option>4</option>
                                  <option>5</option>
                                  <option>6</option>
                                  <option>7</option>
                                  <option>8</option>
                                  <option>9</option>
                                  <option>10</option>
                                  <option>11</option>
                                  <option>12</option>
                                </select>
                                <div style="display: inline; width: 70px; height: 15px" id="month2" runat="server">
                                    月
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label bolder blue col-sm-2">显示方式：</label>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="showTable" Checked="True" runat="server" GroupName="Show" CssClass="ace"></asp:RadioButton>
                                        <span class="lbl">二维表显示</span>
                                    </label>
                                </div>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="showGrap" runat="server" GroupName="Show" CssClass="ace"></asp:RadioButton>
                                        <span class="lbl">图表显示</span>
                                    </label>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="control-label bolder blue col-sm-2">查询方式：</label>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="orderBySchool" Checked="True" runat="server" GroupName="order" class="ace"></asp:RadioButton>
                                        <span class="lbl">按站点查询</span>
                                    </label>
                                </div>
                                <div class="radio pull-left">
                                    <label>
                                        <asp:RadioButton ID="orderByMonth" runat="server" GroupName="order" CssClass="ace"></asp:RadioButton>
                                        <span class="lbl">按时间查询</span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4">
                                    &emsp;
                                    <asp:Button ID="btnQuery" runat="server" Text="生成分析报表" OnClientClick="javascript:queryform();return true;" OnClick="btnQuery_Click" CssClass="btn btn-xs btn-primary"></asp:Button>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                </div>

                <div class="row form-horizontal">
                    <div class="col-xs-12">
                        <div class="hr hr-16 hr-dotted"></div>
                        
                                <asp:Panel ID="pnl1" runat="server" Visible="False">
                                    <div class="timeline-items">
                                        <div class="timeline-container">
                                                <asp:Repeater ID="Repeater1" runat="server">
                                                    <SeparatorTemplate>
                                                        <div class="hr hr22 hr-dotted"></div>
                                                    </SeparatorTemplate>
                                                    <ItemTemplate>
                                                        <div class="timeline-label">
													        <span class="label label-success arrowed-in-right label-lg">
														        <b>
                                                                    <asp:Label ID="lblSchoolName" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.schoolName") %>'>
                                                                    </asp:Label>
                                                                </b>
													        </span>
												        </div>
                                                        
                                                        <div class="timeline-item clearfix">
                                                        
                                                        <div class="widget-box transparent">
                                                                    <asp:DataGrid ID="Datagrid1" runat="server" AutoGenerateColumns="False" class="table table-striped table-bordered" 
                                                                        DataKeyField="pkID" DataSource='<%# GetNewsStat(DataBinder.Eval(Container,"DataItem.applyID").ToString()) %>'>
                                                                        <Columns>
                                                                            <asp:BoundColumn DataField="pkID" HeaderText="ID"></asp:BoundColumn>
                                                                            <asp:BoundColumn DataField="applyID" HeaderText="站点ID"></asp:BoundColumn>
                                                                            <asp:TemplateColumn HeaderText="统计时间">
                                                                                <ItemTemplate>
                                                                                    <asp:Label ID="lbl1" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>'
                                                                                        Visible='<%# visibleMonth %>'>
                                                                                    </asp:Label>
                                                                                    <asp:Label ID="lbl2" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>'
                                                                                        Visible='<%# visibleYear %>'>
                                                                                    </asp:Label>
                                                                                </ItemTemplate>
                                                                            </asp:TemplateColumn>
                                                                            <asp:BoundColumn DataField="newsCount" HeaderText="新闻条数"></asp:BoundColumn>
                                                                        </Columns>
                                                                    </asp:DataGrid>
                                                        </div>
                                                        </div>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </div>
                                    </div>
                                </asp:Panel>
                            
                                <asp:Panel ID="pnl2" runat="server" Visible="False">
                                    <div class="timeline-items">
                                        <div class="timeline-container">
												
                                                <asp:Repeater ID="Repeater2" runat="server">
                                                    <SeparatorTemplate>
                                                        <div class="hr hr22 hr-dotted"></div>
                                                    </SeparatorTemplate>
                                                    <ItemTemplate>

                                                        <div class="timeline-label">
													        <span class="label label-success arrowed-in-right label-lg">
														        <b>
														        <asp:Label ID="lbl3" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.schoolName") %>'>
                                                                </asp:Label>
                                                                </b>
													        </span>
												        </div>
                                                        
                                                        <div class="timeline-item clearfix">
                                                        
                                                        <div class="widget-box transparent">

                                                        <asp:DataList ID="DataList1" runat="server" class="table table-striped table-bordered" DataSource='<%# GetNewsStat(DataBinder.Eval(Container,"DataItem.applyID").ToString()) %>'>
                                                            <ItemTemplate>
                                                                
															        <h5 class="widget-title smaller">
															            <i class="ace-icon fa fa-clock-o bigger-110 blue"></i>
																            <asp:Label ID="Label1" runat="server" Text='<%# GetStatTime(DataBinder.Eval(Container, "DataItem.statTime").ToString()) %>'>
                                                                            </asp:Label>
															        </h5>
															        
															        <div class="widget-body">
																        <div class="widget-main">
																        
																            <div class="progress pos-rel" data-percent='<%# Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount")) %>'>
								                                                <div class="progress-bar" style='width: <%# (int)(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount"))/2) %>%;'></div>
							                                                </div>
							                                                
																	    </div>
																	</div>
															    
                                                            </ItemTemplate>
                                                        </asp:DataList>
                                                        
                                                        </div>
                                                        </div>
                                                        
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                                
                                        </div>
                                    </div>
                                           
                                </asp:Panel>
                            
                                <asp:Panel ID="pnl3" runat="server" Visible="False">
                                    <div class="timeline-items">
                                        <div class="timeline-container">
                                                <asp:Repeater ID="Repeater3" runat="server">
                                                    <SeparatorTemplate>
                                                        <div class="hr hr22 hr-dotted"></div>
                                                    </SeparatorTemplate>
                                                    <ItemTemplate>
                                                        <div class="timeline-label">
													        <span class="label label-success arrowed-in-right label-lg">
														        <b>
                                                                    <asp:Label ID="Label2" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>' runat="server" Visible='<%# visibleMonth %>'>
                                                                    </asp:Label>
                                                                    <asp:Label ID="Label7" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>' Visible='<%# visibleYear %>'>
                                                                    </asp:Label>
                                                                </b>
													        </span>
												        </div>
                                                        
                                                        <div class="timeline-item clearfix">
                                                        
                                                        <div class="widget-box transparent">
                                                                    <asp:DataGrid ID="Datagrid2" runat="server" DataSource='<%# GetNewsStatByMonth(DataBinder.Eval(Container,"DataItem.statTime").ToString()) %>'
                                                                        DataKeyField="pkID" AutoGenerateColumns="False" class="table table-striped table-bordered" >
                                                                        <Columns>
                                                                            <asp:BoundColumn DataField="pkID" HeaderText="ID"></asp:BoundColumn>
                                                                            <asp:BoundColumn DataField="applyID" HeaderText="站点ID"></asp:BoundColumn>
                                                                            <asp:BoundColumn DataField="schoolName" HeaderText="站点名称"></asp:BoundColumn>
                                                                            <asp:BoundColumn DataField="statTime" HeaderText="统计时间" DataFormatString="{0:yyyy}"></asp:BoundColumn>
                                                                            <asp:BoundColumn DataField="newsCount" HeaderText="新闻条数"></asp:BoundColumn>
                                                                        </Columns>
                                                                    </asp:DataGrid>
                                                                    <asp:Label ID="lblInfo" runat="server" Text='<%# StatInfo %>'>
                                                                    </asp:Label>
                                                                </div>
                                                        </div>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </div>
                                    </div>
                                </asp:Panel>
                            
                                <asp:Panel ID="pnl4" runat="server" Visible="False">
                                    <div class="timeline-items">
                                        <div class="timeline-container">
                                                <asp:Repeater ID="Repeater4" runat="server">
                                                    <SeparatorTemplate>
                                                        <div class="hr hr22 hr-dotted"></div>
                                                    </SeparatorTemplate>
                                                    <ItemTemplate>
                                                    
                                                        <div class="timeline-label">
													        <span class="label label-success arrowed-in-right label-lg">
														        <b>
                                                                <asp:Label ID="Label3" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>'
                                                                    Visible='<%# visibleMonth %>'>
                                                                </asp:Label>
                                                                <asp:Label ID="Label6" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>'
                                                                    Visible='<%# visibleYear %>'>
                                                                </asp:Label>
                                                                </b>
													        </span>
												        </div>
                                                        
                                                        <div class="timeline-item clearfix">
                                                        
                                                        <div class="widget-box transparent">
                                                        
                                                            <asp:DataList ID="Datalist2" runat="server" class="table table-striped table-bordered" DataSource='<%# GetNewsStatByMonth(DataBinder.Eval(Container,"DataItem.statTime").ToString()) %>'>
                                                                <ItemTemplate>
                                                                    <h5 class="widget-title smaller">
															            <i class="ace-icon fa fa-globe bigger-110 blue"></i>
															            <asp:Label ID="Label5" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.schoolName") %>'></asp:Label>
															        </h5>
															        
															        <div class="widget-body">
																        <div class="widget-main">
																            <div class="progress pos-rel" data-percent='<%# Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount")) %>'>
								                                                <div class="progress-bar" style='width: <%# (int)(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount"))/2) %>%;'></div>
							                                                </div>
																        </div>
																	</div>
																	
                                                                </ItemTemplate>
                                                            </asp:DataList>
                                                            <asp:Label ID="lblRecordInfo" runat="server" Text='<%# StatInfo %>'>
                                                            </asp:Label>
                                                        
                                                        </div>
                                                        </div>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                        </div>
                                    </div>
                                </asp:Panel>
                           
                    </div>
                </div>
            </div>
        </div>
        
    </form>
    <!--#include file = "../assets/foot.htm" -->
     <script type="text/javascript">

         jQuery(function ($) {
             //改用弹出层，因为201409发布的最新chrome开始不支持showModalDialog()
             $("#btnSelSchools").click(function () {
                 return true;
             }).fancybox({
                 autoSize: false,
                 'type': 'iframe',
                 'width': 600,
                 'height': 450,
                 'hideOnOverlayClick': false,
                 'href': 'selectSchools.aspx'
             });
         })
    </script>
    <script language="javascript">
        //function selectSchools()
        //{	
        //	var arr = showModalDialog("selectSchools.aspx", window, "dialogWidth:500px;dialogHeight:326px;help:no;scroll:no;resizable:yes;status:no");
        //	if(arr!=null)
        //	  location.href="NewsStat.aspx";
        //}
        function DelAll() {
            var selectTo = document.frmNewsStat.schoolList;
            var nLen = selectTo.length;
            if (nLen < 1) return;
            for (var loop = nLen; loop >= 0; loop--) {
                selectTo.options[loop] = null;
            }
        }
        function checkform(text, value) {
            var selectFrom = document.frmNewsStat.schoolList;
            selectFrom.add(new Option(text, value));
        }
        function queryform() {
            var sel = document.frmNewsStat.schoolList;
            var nLen = sel.length;
            var str1 = "";
            var str2 = "";
            for (var i = 0; i < nLen; i++) {
                if (i > 0)
                { str2 += ","; str1 += ","; }
                str2 += sel.options[i].value;
                str1 += sel.options[i].text;
            }
            document.frmNewsStat.d_name.value = str1;
            document.frmNewsStat.d_value.value = str2;
            //alert(str1+str2);
            return true;
        }
        //年报和月报切换。
        function showTime(type) {
            if (type == 1) {
                document.all("ddlMonthFrom").style.visibility = "visible";
                document.all("ddlMonthTo").style.visibility = "visible";
                document.all("month1").style.visibility = "visible";
                document.all("month2").style.visibility = "visible";
            }
            else if (type == 2) {
                document.all("ddlMonthFrom").style.visibility = "hidden";
                document.all("ddlMonthTo").style.visibility = "hidden";
                document.all("month1").style.visibility = "hidden";
                document.all("month2").style.visibility = "hidden";
            }
        }
    </script>
</body>
</html>
