<?php
use \common\libs\MyLib;
?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>拼图前端框架跨屏响应式模板</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/js/pintuer/pintuer.css">
    <script src="/js/pintuer/jquery.js"></script>
    <script src="/js/pintuer/pintuer.js"></script>
    <script src="/js/pintuer/respond.js"></script>
</head>
<body>
<div class="container-layout padding-top">
    <div class="panel active">
        <div class="panel-body">
            <form id="searchForm" method="post" class="form-inline">
                <div class="input-block">
                    <div class="form-group">
                        <div class="label">
                            <label for="car_man">
                                车主:</label>
                        </div>
                        <div class="field">
                            <input type="text" class="input" id="car_man" name="car_man" value="<?=$car_man?>" size="20" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="label">
                            <label for="phone">
                                电话:</label>
                        </div>
                        <div class="field">
                            <input type="text" class="input" id="phone" name="phone" value="<?=$phone?>" size="20" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="label">
                            <label for="car_no">
                                车牌:</label>
                        </div>
                        <div class="field">
                            <input type="text" class="input" id="car_no" name="car_no" <?=$car_no?> size="20" />
                        </div>
                    </div>
                    <div class="form-button">
                        <button class="button" type="button" id="search-btn">
                            搜索</button>
                    </div>
                </div>
                <div class="input-block">
                    <div class="form-group">
                        <div class="label">
                            <label for="car_man">
                                排序:</label>
                        </div>
                        <div class="field">
                            <select class="input" name="sort_key">
                                <option value="appointment_t.pdate" <?=$sort_key=='appointment_t.pdate'?'selected':''?>>按预约时间</option>
                                <option value="car_t.register_date" <?=$sort_key=='car_t.register_date'?'selected':''?>>按初登时间</option>
                                <option value="car_t.insurer1_date" <?=$sort_key=='car_t.insurer1_date'?'selected':''?>>按商业保险时间</option>
                                <option value="car_t.insurer2_date" <?=$sort_key=='car_t.insurer2_date'?'selected':''?>>按商业保险时间</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="field">
                            <select class="input" name="sort_value">
                                <option value="ASC" <?=$sort_value=='ASC'?'selected':''?>>顺序</option>
                                <option value="DESC" <?=$sort_value=='DESC'?'selected':''?>>倒序</option>
                            </select>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="table-responsive margin-top">
        <table class="table table-condensed table-hover table-bordered table-striped">
            <tr>
                <th width="50" align="center" nowrap>序号</th>
                <th width="100" align="center" nowrap>预约日期</th>
                <th width="100" align="center" nowrap>预约时间</th>
                <th width="70" align="center" nowrap>车牌号</th>
                <th width="70" align="center" nowrap>车主</th>
                <th width="70" align="center" nowrap>初登日期</th>
                <th width="100" align="center" nowrap>商业起保日期</th>
                <th width="100" align="center" nowrap>交强起保日期</th>
                <th width="200" align="center" nowrap>预约备注</th>
                <th width="70" align="center" nowrap>业务员</th>
                <th width="50" align="center" nowrap>操作</th>
            </tr>
            <?php
            foreach($items as $index => $item) {
                $start_index = ($page-1) * 20 + $index;
                $car_info = $item->car;
                ?>
                <tr>
                    <td align="center" nowrap ><?=$start_index+1?></td>
                    <td align="center" nowrap><?=$item->pdate?></td>
                    <td align="center" nowrap><?=$item->ptime?></td>
                    <td nowrap><?=$car_info->car_no?></td>
                    <td nowrap title="<?=$car_info->car_man?>"><?=MyLib::substr_cut($car_info->car_man,9)?></td>
                    <td nowrap><?=$car_info->register_date?></td>
                    <td nowrap><?=$car_info->insurer1_date?></td>
                    <td nowrap><?=$car_info->insurer2_date?></td>
                    <td ><?=MyLib::substr_cut($item->remark,40)?></td>
                    <td nowrap><?=$item->user?$item->user->getShowName():''?></td>
                    <td align="center" nowrap>
                        <button class="button border-blue button-little icon-file" onclick="info(<?=$item->car_id?>,<?=$start_index?>)">详情</button>
                    </td>
                </tr>
                <?php
            }
            ?>
        </table>
        <p class="text-center">
            <?=$page_info?>
        </p>
    </div>
</div>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    //详情
    function info(id,index) {
        var params = $('#searchForm').serialize();
        window.location.href = '/car/info-renewal?id=' + id + '&type=<?=$type?>' + '&next_index=' + index + '&back_params=' + encodeURIComponent(params);
    }

    $(function(){
        $("#search-btn").click(function(){
            $('#page').val(1);
            var params = $('#searchForm').serialize();
            window.location.href = "/renewal/today?" + params;
        });
    });
</script>
</body>
</html>