<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<style>
    label.control-label {
        width: 70px;
    }

    .form-inline .form-control {
        width: 180px;
    }
</style>
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>车辆信息</h5>
        </div>
        <div class="ibox-content">
            <table class="table table-bordered">
                <tr>
                    <th class="bg-warning">车牌号</th>
                    <td><?=$car_info->car_no?></td>
                    <th class="bg-warning" nowrap>初登日期</th>
                    <td><?=$car_info->register_date?></td>
                    <th class="bg-warning" nowrap>座位数</th>
                    <td><?=$car_info->seats?></td>
                    <th class="bg-warning" nowrap>新车购置价</th>
                    <td><?=$car_info->purchase_price?></td>
                </tr>
                <tr>
                    <th class="bg-warning">车型</th>
                    <td><?=$car_info->factory_model?></td>
                    <th class="bg-warning" nowrap>发动机号</th>
                    <td><?=$car_info->engine_no?></td>
                    <th class="bg-warning" nowrap>车架号</th>
                    <td><?=$car_info->car_frame_no?></td>
                    <th class="bg-warning" nowrap>车辆使用性质</th>
                    <td><?=$car_info->carUse?$car_info->carUse->name:''?></td>
                </tr>
                <tr>
                    <th class="bg-warning">车主</th>
                    <td><?=$car_info->car_man?></td>
                    <th class="bg-warning">证件类型</th>
                    <td><?=$car_info->car_man_type?></td>
                    <th class="bg-warning">证件号码</th>
                    <td><?=$car_info->car_man_number?></td>
                    <th class="bg-warning">联系电话</th>
                    <td><?=$car_info->car_man_phone?></td>
                </tr>
                <tr>
                    <th class="bg-warning" nowrap>商业起保日期</th>
                    <td><?=$car_info->insurer1_date?></td>
                    <th class="bg-warning" nowrap>交强起保日期</th>
                    <td><?=$car_info->insurer2_date?></td>
                    <th class="bg-warning">保险公司</th>
                    <td><?=$car_info->company?></td>
                    <th class="bg-warning"></th>
                    <td></td>
                </tr>
            </table>
        </div>
    </div>
    <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="$('#appointmentTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <table id="appointmentTable">
                <thead>
                <tr>
                    <th data-field="pdate">预约日期</th>
                    <th data-field="ptime">预约时间</th>
                    <th data-field="remark">预约备注</th>
                    <th data-field="user">业务员</th>
                    <th data-field="updated_at">操作时间</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    <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="$('#orderTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <table id="orderTable">
                <thead>
                <tr>
                    <th data-field="id">ID</th>
                    <th data-field="id_man">被保险人</th>
                    <th data-field="insurer1_begin_date">商业起保日期</th>
                    <th data-field="insurer2_begin_date">交强起保日期</th>
                    <th data-field="print_date">出单日期</th>
                    <th data-field="total_all">共计签单</th>
                    <th data-field="username">业务员</th>
                    <th data-field="status">状态</th>
                    <th data-formatter="orderFormatter">操作</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    <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="$('#giftTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <table id="giftTable">
                <thead>
                <tr>
                    <th width="50" data-field="id">ID</th>
                    <th data-field="code">礼券编号</th>
                    <th data-field="name">礼品</th>
                    <th data-field="car_no">车牌号</th>
                    <th data-field="car_frame_no">车架号</th>
                    <th data-field="input_date">发放日期</th>
                    <th data-field="end_date">有效期日期</th>
                    <th data-field="submit_user">提单人</th>
                    <th data-field="use_date">使用日期1</th>
                    <th data-field="status">状态</th>
                    <th data-field="username">操作员</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    <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="$('#logTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <table id="logTable">
                <thead>
                <tr>
                    <th data-field="op_man">操作者</th>
                    <th data-field="op_time">操作时间</th>
                    <th data-field="remark">操作内容</th>
                </tr>
                </thead>
            </table>
        </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 type="text/javascript" language="javascript">
    var o = {};
    function orderFormatter(value, row, index) {
        var opStr = [];
        opStr.push('<a href="javascript:void(0);" onclick="viewOrder(' + row.id + ')">');
        opStr.push('<i class="fa fa-file-o" title="详情"></i>');
        opStr.push('</a>');

        return opStr.join(' ');
    }
    function viewOrder(id) {
        window.open('/insurer/info?id=' + id);
    }
    function searchGifts() {
        $('#giftTable').bootstrapTable('destroy');
        $('#giftTable').bootstrapTable({
            url: "/gift/ticket-use-json",
            pagination: true,
            sidePagination: 'server',
            queryParams: function(params) {
                o['car_id'] = '<?=$car_info->id?>';
                o['limit'] = params['limit'];
                o['offset'] = params['offset'];
                return o;
            }
        });
        return false;
    }
    function searchOrders() {
        $('#orderTable').bootstrapTable('destroy');
        $('#orderTable').bootstrapTable({
            url: "/car/order-history-json",
            pagination: true,
            sidePagination: 'server',
            multipleSelectRow: true,
            queryParams: function(params) {
                o['car_id'] = '<?=$car_info->id?>';
                o['limit'] = params['limit'];
                o['offset'] = params['offset'];
                return o;
            }
        });
    }
    function searchOps() {
        $('#logTable').bootstrapTable('destroy');
        $('#logTable').bootstrapTable({
            url: "/car/history-json",
            pagination: true,
            sidePagination: 'server',
            multipleSelectRow: true,
            queryParams: function(params) {
                o['car_id'] = '<?=$car_info->id?>';
                o['limit'] = params['limit'];
                o['offset'] = params['offset'];
                return o;
            }
        });
    }
    function searchAppointments() {
        $('#appointmentTable').bootstrapTable('destroy');
        $('#appointmentTable').bootstrapTable({
            url: "/appointment/history-json",
            pagination: true,
            sidePagination: 'server',
            multipleSelectRow: true,
            queryParams: function(params) {
                o['car_id'] = '<?=$car_info->id?>';
                o['limit'] = params['limit'];
                o['offset'] = params['offset'];
                return o;
            }
        });
    }
    $(function () {
        searchAppointments();
        searchOps();
        searchOrders();
        searchGifts();
    });
</script>
<?php $this->endBlock('footer_js'); ?>