<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <base href="{base}application/views/" />
        <base target="mainFrame" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <!--   <link rel="stylesheet" type="text/css" href="css/ztreestyle.css" >!--> 
        <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
        <script type="text/javascript" src="js/jquery.ztree.core-3.5.js"></script>
        <SCRIPT type="text/javascript" >
            var base = "{base}";
       
        </SCRIPT>
        <script>

            function subForm(){
                
                var year_option = $("#year_option").val();
                var month_option  = $("#month_option").val();
                var day  = $("#day_option").val();
                window.location.href = base+'manage/hits/click_info/'+year_option+"/"+month_option+"/"+day;  
                
                return true;
            }
            
            function selectd_month_option($month){
                var month = $month-1;
                document.getElementById("month_option").options[month].selected = true;
            }
            function selectd_year_option($year){
                var year = $year-1;
                document.getElementById("year_option").options[year].selected = true;
            }
            function selectd_day_option($day){
                var day = $day-1;
                document.getElementById("day_option").options[day].selected = true;
            }
        </script>
        <style type="text/css">  
            table {  
                border: 1px solid #B1CDE3;  
                padding:0;   
                margin:0 auto;  
                border-collapse: collapse;  
            }  

            td {  
                border: 1px solid #B1CDE3;  
                background: #fff;  
                font-size:12px;  
                padding: 3px 3px 3px 8px;  
                color: #4f6b72;  
            }  
        </style>  
    </HEAD>

    <BODY>
      <div style="display:none"> <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1253235349'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s5.cnzz.com/z_stat.php%3Fid%3D1253235349%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script></div>
        <form action="{base}/manage/hits/click_info" id="month_form" name ="month_form" method="post">

            <center><p> <h3>点击率详情<h3> </p></center>

                            <table width="800px" height="300px" border="1">
                                <tr>
                                    <td>
                                        频道
                                    </td>
                                    <td colspan="4">
                                        请选择年份

                                        <select id="year_option" name="year_option"  > 

                                            <option value="2014">2014</option>  
                                            <option value="2015">2015</option>                                          
                                        </select>
                                        <script>
                                            selectd_year_option('{year}');
                                        </script>
                                        -
                                        请选择月份

                                        <select id="month_option" name="month_option"  > 
                                            <option value="1" >1月份</option>  
                                            <option value="2" >2月份</option>  
                                            <option value="3" >3月份</option>  
                                            <option value="4" >4月份</option>  
                                            <option value="5" >5月份</option>
                                            <option value="6" >6月份</option>
                                            <option value="7" >7月份</option>
                                            <option value="8" >8月份</option>
                                            <option value="9" >9月份</option>
                                            <option value="10" >10月份</option>
                                            <option value="11" >11月份</option>
                                            <option value="12" >12月份</option>
                                        </select>
                                        <script>
                                            selectd_month_option('{month}');
                                        </script>
                                        -
                                        请选择日
                                        <select id="day_option" name="day_option"  > 
                                            <option value="1" >1</option>  
                                            <option value="2" >2</option>  
                                            <option value="3" >3</option>  
                                            <option value="4" >4</option>  
                                            <option value="5" >5</option>
                                            <option value="6" >6</option>
                                            <option value="7" >7</option>
                                            <option value="8" >8</option>
                                            <option value="9" >9</option>
                                            <option value="10" >10</option>
                                            <option value="11" >11</option>  
                                            <option value="12" >12</option>  
                                            <option value="13" >13</option>  
                                            <option value="14" >14</option>  
                                            <option value="15" >15</option>
                                            <option value="16" >16</option>
                                            <option value="17" >17</option>
                                            <option value="18" >18</option>
                                            <option value="19" >19</option>
                                            <option value="20" >20</option>
                                            <option value="21" >21</option>  
                                            <option value="22" >22</option>  
                                            <option value="23" >23</option>  
                                            <option value="24" >24</option>  
                                            <option value="25" >25</option>
                                            <option value="26" >26</option>
                                            <option value="27" >27</option>
                                            <option value="28" >28</option>
                                            <option value="29" >29</option>
                                            <option value="30" >30</option>
                                            <option value="31" >31</option>
                                        </select>
                                        <script>
                                            selectd_day_option('{day}');
                                        </script>
                                    </td>

                                    <td>
                                        <input type="button" value="提交" onclick="subForm()">
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td >年点击数</td>
                                    <td >月点击数</td>
                                    <td >周点击数</td>
                                    <td >日点击数</td>
                                </tr>
                                <?php
                                $date = date("m", time());
                                $dateyear = date("Y", time());
                                $sql = "select * from cms_section";
                                $lists = $this->db->query($sql)->result();
                                foreach ($lists as $list) {
                                    ?>
                                    <tr>
                                        <td>
                                            <?php
                                            echo $list->name;
                                            ?>
                                        </td>
                                        <td >
                                            <?php
                                            if ($year == $dateyear) {
                                                $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE YEAR(DATE)=" . $year . " AND menu_id =" . $list->id . ";";
                                                $hitss1 = $this->db->query($sql)->row();

                                                echo $hitss1->s_click;
                                            } else {

                                                $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE YEAR(DATE)=" . $year . " AND menu_id =" . $list->id . ";";
                                                $hitss1 = $this->db->query($sql)->row();

                                                echo $hitss1->s_click;
                                            }
                                            ?>
                                        </td>

                                        </td>
                                        <td >
                                            <?php
                                            if ($month == 0) {
                                                $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE MONTH(DATE)=MONTH(NOW()) AND YEAR(DATE)=" . $year . " AND menu_id =" . $list->id . ";";
                                                $hitss = $this->db->query($sql)->row();
                                                echo $hitss->s_click;
                                            } else {
                                                $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE MONTH(DATE)=" . $month . " AND YEAR(DATE)=" . $year . "  AND menu_id =" . $list->id . ";";
                                                $hitss = $this->db->query($sql)->row();

                                                echo $hitss->s_click;
                                            }
                                            ?>
                                        </td>
                                        <td >
                                            <?php
                                            if ($month == $date && $year == $dateyear) {
                                                $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE week(DATE)=week(NOW()) AND menu_id =" . $list->id . ";";
                                                $hitss1 = $this->db->query($sql)->row();

                                                echo $hitss1->s_click;
                                            }
                                            ?>

                                        </td>
                                        <td>
                                            <?php
                                            if ($month == $date && $year == $dateyear) {

                                                if ($day != 0) {
                                                    $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE DAY(DATE)=" . $day . " AND MONTH(DATE)=" . $month . "   AND menu_id =" . $list->id . ";";
                                                    $hitss1 = $this->db->query($sql)->row();           
                                                    echo $hitss1->s_click;
                                                } else {
                                                    $sql = "SELECT *,SUM(click)as s_click FROM hits WHERE DAY(DATE)=" . $day . " AND MONTH(DATE)=" . $month . " menu_id =" . $list->id . ";";
                                                    $hitss1 = $this->db->query($sql)->row();
                                                    echo $hitss1->s_click;
                                                }
                                            }
                                            ?>
                                        </td>

                                    </tr>
<?php } ?>
                            </table>
                            </form>
                            </BODY>
                            </HTML>
