<?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="refreshList();">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form role="form" id="search" class="form-inline" onsubmit="return search();">
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="username">车主</label>
                    <input type="text" id="car_man" name="car_man" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label for="phone">电话</label>
                    <input type="text" id="phone" name="phone" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label for="car_no">车牌</label>
                    <input type="text" id="car_no" name="car_no" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label for="car_model">车型</label>
                    <input type="text" id="car_model" name="car_model" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="datepicker1">初登日期</label>
                    <div class="input-group" id="datepicker1">
                        <input type="text" class="form-control date" id="register_date" name="register_date" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label for="datepicker2">保险日期</label>
                    <div class="input-group" id="datepicker2">
                        <input type="text" class="form-control date" id="insurer_date" name="insurer_date" autocomplete="off" />
                    </div>
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label for="caller">被保险人</label>
                    <input type="text" id="id_man" name="id_man" class="form-control">
                </div>
                <button type="submit" class="btn btn-primary">搜索</button>
            </form>
            <div class="row" style="margin-top:20px;">
                <div class="col-md-12">
                    <table id="listTable">
                        <thead class="bg-warning">
                        <tr>
                            <th data-field="id">ID</th>
                            <th data-field="car_man">车主</th>
                            <th data-field="car_no">车牌号</th>
                            <th data-field="engine_no">发动机号</th>
                            <th data-field="car_frame_no">车架号</th>
                            <th data-field="register_date">初登日期</th>
                            <th data-field="insurer1_date">保险日期</th>
                            <th data-field="location_txt">位置</th>
                            <th data-field="show_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>
    function opFormatter(value, row, index) {
        var opStr = [];
        opStr.push('<a href="javascript:void(0);" onclick="info(' + row.id + ')">');
        opStr.push('<i class="fa fa-plus" title="详情">&nbsp;详情</i>');
        opStr.push('</a>');

        return opStr.join(' ');
    }

    function info(id) {
        layer_show('客户信息','/car/info-track?id=' + id);
    }

    function refreshList() {
        $('#listTable').bootstrapTable('refresh');
    }

    function search() {
        $('#listTable').bootstrapTable('destroy');
        $('#listTable').bootstrapTable({
            url: "/car/search-json",
            pagination: true,
            sidePagination: 'server',
            queryParams: function(params) {
                $('#search').find(':input:not(input[type=button],input[type=submit],button)').each(function(index,item){
                    params[$(item).attr('name')] = $(item).val();
                });
                return params;
            }
        });
        return false;
    }

    $(function() {
        search();
        $('.date').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            autoclose: true
        });
    });
</script>
<?php $this->endBlock(); ?>