<?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_man">车主</label>
                    <input type="text" name="car_man" id="car_man" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="phone">电话</label>
                    <input type="text" name="phone" id="phone" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="car_no">车牌</label>
                    <input type="text" name="car_no" id="car_no" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="id_man">被保险人</label>
                    <input type="text" name="id_man" id="id_man" class="form-control">
                </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="car_id">ID</th>
                            <th data-field="pdate">预约日期</th>
                            <th data-field="ptime">预约时间</th>
                            <th data-field="car_no">车牌号</th>
                            <th data-field="car_man">车主</th>
                            <th data-field="register_date">初登日期</th>
                            <th data-field="insurer1_date">商业起保日期</th>
                            <th data-field="insurer2_date">交强起保日期</th>
                            <th data-field="remark">预约备注</th>
                            <th data-field="user_name">业务员</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>
    var o = {};
    function opFormatter(value, row, index) {
        var opStr = [];
        opStr.push('<a href="javascript:void(0);" onclick="view(' + row.car_id + ')">');
        opStr.push('<i class="fa fa-file-o" title="详情"></i>');
        opStr.push('</a>');

        return opStr.join(' ');
    }

    function view(car_id) {
        location.href = '/car/info?id=' + car_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: "/appointment/today-json",
            pagination: true,
            sidePagination: 'server',
            multipleSelectRow: true,
            queryParams: function(params) {
                o['limit'] = params['limit'];
                o['offset'] = params['offset'];
                return o;
            }
        });
        return false;
    }

    $(function() {
        search();

    });
</script>
<?php $this->endBlock(); ?>