<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                        	<div class="btn-group" style="margin-bottom:20px;">
                                <a href="#payment/todayBugGoodsRank/number" class="btn btn-success">数量</a>
                                <a href="#payment/todayBugGoodsRank/money" class="btn btn-success">总价</a>
                            </div>
                            
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#payment/todayBugGoodsRank" id="totalForm">

                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>开始时间: </label>
                                                <input type="text" class="form-control datetimepicker" value="<?php if($stime) echo $stime;?>" placeholder="开始时间" name="payment_stime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>结束时间: </label>
                                                <input type="text" class="form-control datetimepicker" value="<?php if($etime) echo $etime;?>" placeholder="结束时间" name="payment_etime" />
                                        </div>
                                        <span class="gap"></span>

                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                            
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        

        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>购买商品排行榜</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table id="goodsTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>商品ID</th>
                                                <th>商品名称</th>
                                                <th>购买数量</th>
                                                <th>商品单价($)</th>
                                                <th>商品总价($)</th>
                                                <th>商品渠道</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/highcharts.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jquery.validate-1.15.0.min.js"></script>

<script>
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

	$(function () {
		
	    //查询
	    //jquery data table 初始化
	    var goodsTable = $("#goodsTable").DataTable({
	        "paging": false,
	        "select": true,
	        "processing": true,
	        "serverSide": true,
	        "language": {
	            'lengthMenu': '每页显示 _MENU_ 记录',
	            'zeroRecords': '没有数据',
	            'info': ' 第_PAGE_ 页/ _PAGES_页，共 _TOTAL_ 条',
	            'infoEmpty': '没有符合条件的记录',
	            'search': '查找',
	            'infoFiltered': '(从  _MAX_ 条记录中过滤)',
	            'paginate': { "first":  "首页 ", "last": "末页", "next": "下一页","previous": "上一页"}
	        },
	        "ajax": {
	            url: rootPath + "payment/totalData",
	            type:"post",
	            //增加参数查询参数
	            data:function(data){
	                data.payment_stime = $('input[name="payment_stime"]').val();
                	data.payment_etime = $('input[name="payment_etime"]').val();
                	data.sort = '<?php echo $sort; ?>';
	            }
	        },
	        "lengthChange": false,
	        "searching": false,
	        "ordering": false,
	        "info": false,
	        "autoWidth": false,
	        "columns": [
	            {"data": "index"},
	            {"data": "gid"},
	            {"data": "gname"},
	            {"data": "num"},
	            {"data": "gprice", render:function (data) {
	                return "$"+data;
	            }},
	            {"data": "money", render:function (data) {
	                return "$"+data;
	            }},
	            {"data": "channel"}
	        ]
	    });
	
	    //当点击search按钮时按条件重新加载数据
	    $("#searchBtn").click(function(){
	        if($("#totalForm").valid()) {
	            goodsTable.ajax.reload();
	        }
	    });
	
	
	});
</script>
