<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">
<div class="content_wrapper">
    <div id="msg-tip"></div>

    <style>
        .change {
            background: lightgoldenrodyellow;
        }
        .td-nowrap {
            white-space: nowrap;
        }
    </style>

    <div class="container-fluid">
        <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">
                                    <form class="form-inline" role="form" method="post" action="#" >
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>开始时间</label>
                                            <input type="text" class="form-control datetimepicker" value="" placeholder="开始时间" name="stime" />
                                        </div
                                        <span class="gap"></span>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>结束时间</label>
                                            <input type="text" class="form-control datetimepicker" value="" placeholder="结束时间" name="etime" />
                                        </div>
                                        <span class="gap"></span>
                                        <button type="button" class="btn btn-primary" id="searchBtn">查询</button>
                                        <a href="<?php echo site_url().'/statistics/basicReportExport'?>" target="_blank" class="btn btn-default pull-right" >导出报表</a>
                                    </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="reportTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>日期</th>
                                                <th>新增注册用户</th>
                                                <th>新增设备数</th>
                                                <th>设备次留</th>
                                                <th>登录用户数</th>
                                                <th>登录设备数</th>
                                                <th>最高在线数</th>
                                                <th>充值用户</th>
                                                <th>充值金额</th>
                                                <th>ARPU</th>
                                                <th>首充用户</th>
                                                <th>安装数(<span style="color:blue">双击编辑</span>)</th>
                                            </tr>
                                            </thead>
                                            <tbody id="reportBody">

                                            </tbody>
                                        </table>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>


<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>
<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/js/common.js?version=1"></script>
<script src="<?php echo base_url();?>public/js/statistics/basicReport.js?version=7"></script>
<script type="text/javascript">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    //如果双击安装数
    $('#reportBody').on('dblclick','.install',function () {
        var _this = $(this),//保存td
            msgTip = $('#msg-tip'),
            tdText = _this.text();
        if(!_this.is('.input')){
            _this.addClass('input').html('<input type="text" value="'+ tdText +'" />').find('input').focus().blur(function() {
                var thisid = $(this).parent().next().text();
                var thisvalue = $(this).val();
                var _input = $(this); //保存input对象

                if (tdText == thisvalue) {
                    _input.parent().removeClass('input').html(tdText || 0);
                    return;
                }
                //ajax将修改后的数据提交到后台
                $.ajax({
                    type: 'POST',
                    url: rootPath + 'statistics/editBasicAjax',
                    dataType: 'json',
                    data: {
                        "id": thisid,
                        "install": thisvalue
                    },
                    success: function (data) {
                        if (data.ret == 0) {
                            _this.removeClass('text-red');
                            _input.parent().removeClass('input').html(thisvalue || 0);
                        } else {
                            msgTip.messager().error(data.msg);
                            _this.addClass('text-red');
                        }
                    },
                    error: function () {
                        msgTip.messager().error('网络错误，请刷新后重试');
                    }
                });
            });
        }
    });


</script>