<?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="car_no">保险类型</label>
                    <select name="insurer_type" class="form-control">
                        <option value=0>全部</option>
                        <option value=1>商业</option>
                        <option value=2>交强</option>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">保单号</label>
                    <input type="text" id="insurer_no" name="insurer_no" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">车牌</label>
                    <input type="text" id="car_no" name="car_no" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">工号</label>
                    <input type="text" id="username" name="username" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="datepicker1">出单日期</label>
                    <div class="input-group input-daterange" id="datepicker1">
                        <input type="text" class="input-sm form-control" id="begin_date" name="begin_date" value="" autocomplete="off" />
                        <span class="input-group-addon">-</span>
                        <input type="text" class="input-sm form-control" id="end_date" name="end_date" value="" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="datepicker1">回单日期</label>
                    <div class="input-group input-daterange" id="datepicker1">
                        <input type="text" class="input-sm form-control" id="r_begin_date" name="r_begin_date" value="" autocomplete="off" />
                        <span class="input-group-addon">-</span>
                        <input type="text" class="input-sm form-control" id="r_end_date" name="r_end_date" value="" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">联系电话</label>
                    <input type="text" id="phone" name="phone" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">保险公司</label>
                    <select name="company_id" class="form-control">
                        <option value="0">全部</option>
                        <?php
                        foreach($company_items as $item) {
                            echo '<option value="'.$item->id.'">'.$item->name.'</option>';
                        }
                        ?>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="engine_no">级别</label>
                    <select name="group_id" class="form-control">
                        <option value="0">全部</option>
                        <?php
                        foreach($group_items as $item) {
                            echo '<option value="'.$item->id.'">'.$item->name.'</option>';
                        }
                        ?>
                    </select>
                </div>
                <button type="submit" class="btn btn-primary mb-8">搜索</button>
            </form>
            <div class="row">
                <div class="col-sm-12">
                    <table id="listTable">
                        <thead>
                        <tr>
                            <th data-field="state" data-checkbox="true"></th>
                            <th width="50" data-field="id">ID</th>
                            <th data-field="car_no">车牌</th>
                            <th data-field="company_name">保险公司</th>
                            <th data-field="username">工号</th>
                            <th data-field="group_name">级别</th>
                            <th data-field="insurer_no">保单号</th>
                            <th data-field="submit_date">提单日期</th>
                            <th data-field="print_date">出单日期</th>
                            <th data-field="insurer_type">保险类型</th>
                            <th data-field="total">商业总保费</th>
                            <th data-field="total_clear">商业净保费</th>
                            <th data-field="total_rate">手续费比例</th>
                            <th data-field="budian_rate">补点比例</th>
                            <th data-field="total_real">应得金额</th>
                            <th data-field="total_clear_real">实得金额</th>
                            <th data-field="r_total">回款金额</th>
                            <th data-field="bu_dian">补点金额</th>
                            <th data-field="r_bu_dian">回款补点</th>
                            <th data-field="total1_dis">减免金额</th>
                            <th data-field="liwu">礼品礼券</th>
                            <th data-field="gongzi">工资</th>
                            <th data-field="lirun">利润</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>
    var o = {};
    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: "/finance/receipt-lirun-json",
            pagination: true,
            sidePagination: 'server',
            multipleSelectRow: true,
            queryParams: function(params) {
                o['offset'] = params['offset'];
                o['limit'] = params['limit'];
                return o;
            },
            responseHandler: function (res) {
                var totals = res.rows.pop();
                var html = '<tfoot><tr><td colspan="22" class="">';
                $.each(totals,function (i,d) {
                    html += '<div class="layui-show-md-inline-block m-r-lg m-l-lg">' +
                        '<span>'+ d[0] +'：</span>' +
                        '<span class="font-bold">'+ d[1] +'</span>' +
                        '</div>'
                });
                html += '</td></tr></tfoot>';
                $('#listTable').find('tfoot').remove();
                $('#listTable').append(html);
                return res;
            }
        });
        return false;
    }

    $(function() {
        search();
        $('.input-daterange').datepicker({
            keyboardNavigation: false,
            forceParse: false,
            autoclose: true
        });
    });
</script>
<?php $this->endBlock(); ?>
