<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>工作量统计</h5>
            <div class="ibox-tools">
                <a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form role="form" id="searchFrm" class="form-inline" onsubmit="return search();">
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="datepicker1">提单日期</label>
                    <div class="input-group" id="datepicker1">
                        <input type="text" class="input-sm form-control" id="date_begin" name="date_begin" value="" autocomplete="off" />
                        <span class="input-group-addon">到</span>
                        <input type="text" class="input-sm form-control" id="date_end" name="date_end" value="" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="datepicker2">正本日期</label>
                    <div class="input-group" id="datepicker2">
                        <input type="text" class="input-sm form-control" id="date2_begin" name="date2_begin" value="" autocomplete="off" />
                        <span class="input-group-addon">到</span>
                        <input type="text" class="input-sm form-control" id="date2_end" name="date2_end" value="" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="username">工号</label>
                    <input type="text" id="username" name="username" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="group_id">级别</label>
                    <select name="group_id" id="group_id" class="form-control">
                        <option value="0">全部</option>
                        <?php
                        foreach($group_items as $item) {
                            echo '<option value="'.$item->id.'"';
                            if($item->id == $group_id)
                                echo ' selected ';
                            echo '>'.$item->name.'</option>';
                        }
                        ?>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="company_id">保险公司</label>
                    <select name="company_id" id="company_id" class="form-control">
                        <option value="0">全部</option>
                        <?php
                        foreach($company_items as $item) {
                            echo '<option value="'.$item->id.'"';
                            if($item->id == $company_id)
                                echo ' selected ';
                            echo '">'.$item->name.'</option>';
                        }
                        ?>
                    </select>
                </div>
                <button type="submit" class="btn btn-primary mb-8">搜索</button>
            </form>
            <div class="row">
                <div class="col-md-12">
                    <table id="listTable">
                        <thead>
                        <tr>
                            <th data-field="username">工号</th>
                            <th data-field="truename">真实姓名</th>
                            <th data-field="total_7">提车总数</th>
                            <th data-field="total_1">提单总数</th>
                            <th data-field="total_2">商业总净保费</th>
                            <th data-field="total_3">交强总净保费</th>
                            <th data-field="total_4">商业已收净保费</th>
                            <th data-field="total_5">交强已收净保费</th>
                            <th data-field="total_6">总签单净保费</th>
                            <th data-formatter="opFormatter">操作</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/assets/js/plugins/layer/laydate/laydate.js"></script>
<script>
    var o = {};
    function opFormatter(value, row, index) {
        var opStr = [];
        if(row.op == 1) {
            opStr.push('<a href="javascript:void(0);" onclick="view(' + row.id + ')">');
            opStr.push('<i class="fa fa-file-o" title="查看"></i>');
            opStr.push('</a>');
        }

        return opStr.join(' ');
    }
    function view(id) {
        var title = '查看详情';
        layer_show(title, '/statistics/work-info?user_id=' + id);
    }
    function refreshList() {
        $('#listTable').bootstrapTable('refresh');
    }

    function search() {
        o = {};
        var params = $("#searchFrm").serializeArray();
        $.each(params, function(index) {
            o[this['name']] = this['value'];
        });
        $('#listTable').bootstrapTable('destroy');
        $('#listTable').bootstrapTable({
            url: "/statistics/work-json",
            pagination: true,
            sidePagination: 'server',
            queryParams: function(params) {
                o['offset'] = params['offset'];
                o['limit'] = params['limit'];
                return o;
            }
        });
        return false;
    }

    $(function() {
        search();
        laydate({
            elem:'#date_begin',
            format: 'YYYY-MM-DD'
        });
        laydate({
            elem:'#date2_begin',
            format: 'YYYY-MM-DD'
        });
        laydate({
            elem:'#date_end',
            format: 'YYYY-MM-DD'
        });
        laydate({
            elem:'#date2_end',
            format: 'YYYY-MM-DD',
            istime: true
        });
    });
</script>
<?php $this->endBlock(); ?>