<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<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" src="/js/common.js"></script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="searchForm" method="GET">
        <tr>
            <td class="td_bg">
                <label for="car_no">车牌号:</label>
                <input id="car_no" name="car_no" type="text" size="10" value="<?= isset($car_no) ? $car_no :''?>">
                <label for="id_man">被保险人:</label>
                <input name="id_man" id="id_man" type="text" size="10" value="<?= isset($id_man) ? $id_man : '' ?>">
                <label for="id_phone">电话:</label>
                <input name="id_phone" id="id_phone" type="text" size="10" value="<?= isset($id_phone) ? $id_phone : '' ?>">
                <label for="link_man">联系人:</label>
                <input name="link_man" id="link_man" type="text" size="10" value="<?= isset($link_man) ? $link_man : '' ?>">
                <label for="link_phone">电话:</label>
                <input name="link_phone" id="link_phone" type="text" size="10" value="<?= isset($link_phone) ? $link_phone : '' ?>">
                <label for="status">状态:</label>
                <select name="status" id="status">
                    <option value="-1" <?= isset($status) ? ('-1' === $status ? 'selected' : '') : '' ?>>全部</option>
                    <option value="0" <?= isset($status) ? ('0' === $status ? 'selected' : '') : '' ?>>业务提单</option>
                    <option value="1" <?= isset($status) ? ('1' === $status ? 'selected' : '') : '' ?>>提单审核</option>
                    <option value="2" <?= isset($status) ? ('2' === $status ? 'selected' : '') : '' ?>>司机接车</option>
                    <option value="3" <?= isset($status) ? ('3' === $status ? 'selected' : '') : '' ?>>前台审核</option>
                    <option value="4" <?= isset($status) ? ('4' === $status ? 'selected' : '') : '' ?>>查勘定损</option>
                    <option value="5" <?= isset($status) ? ('5' === $status ? 'selected' : '') : '' ?>>前台派工</option>
                    <option value="6" <?= isset($status) ? ('6' === $status ? 'selected' : '') : '' ?>>车间维修中</option>
                    <option value="11" <?= isset($status) ? ('11' === $status ? 'selected' : '') : '' ?>>机电</option>
                    <option value="14" <?= isset($status) ? ('14' === $status ? 'selected' : '') : '' ?>>总检</option>
                    <option value="17" <?= isset($status) ? ('17' === $status ? 'selected' : '') : 'selected' ?>>出厂</option>
                </select>
                <label for="sort_key">排序:</label>
                <select name="sort_key" id="sort_key">
                    <option value="created_at" <?= isset($sort_key) ? ('create_at' === $sort_key ? 'selected' : '') : '' ?>>提单日期</option>
                </select>
                <select name="sort_value">
                    <option value="ASC" <?= isset($sort_value) ? ('ASC' === $sort_value ? 'selected' : '') : ''?>>顺序</option>
                    <option value="DESC" <?= isset($sort_value) ? ('DESC' === $sort_value ? 'selected' : '') : '' ?>>倒序</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="td_bg">
                <label for="start_time">提单日期:</label>
                从<input type="text" size="10" id="start_time" name="start_time" onclick="WdatePicker()" value="<?= isset($start_time) ? $start_time : '' ?>">
                至<input type="text" size="10" name="end_time" onclick="WdatePicker()" value="<?= isset($end_time) ? $end_time : '' ?>">
                <input type="submit" class="act_btn" value="搜索">
                <input type="reset" class="act_btn" value="重置">
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td>
        <td align="center" align="center" class="bg_tr">车牌号</td>
        <td align="center" align="center" class="bg_tr">品牌</td>
        <td align="center" align="center" class="bg_tr">车型</td>
        <td align="center" align="center" class="bg_tr">联系人</td>
        <td align="center" align="center" class="bg_tr">事故类型</td>
        <td align="center" align="center" class="bg_tr">出厂时间</td>
        <td align="center" align="center" class="bg_tr">状态</td>
        <td width="30" align="center" class="bg_tr">操作</td>
    </tr>
    <?php if(!empty($items)): ?>
        <?php foreach ($items as $index => $item): ?>
            <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->car_no ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->brand ? $item->brand->name : '' ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->series ? $item->series->name : '' ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->link_man ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->accident_type ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->finish_date ?></td>
                <td align="left" class="td_bg" nowrap><?= $item->getStatus() ?></td>
                <td align="center" class="td_bg" nowrap>
                    [<a href="javascript:void(0);" onclick="edit(<?= $item->id ?>,<?= $item->status ?>)">详情</a>]
                    [<a href="javascript:void(0);" onclick="del(<?= $item->id ?>)">删除</a>]
                </td>
            </tr>
        <?php endforeach; ?>
    <?php endif; ?>
    <tr>
        <td height="25" colspan="9" align="center" class="td_bg"><?= isset($page_info) ? $page_info : '' ?></td>
    </tr>
</table>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(id, status) {
        window.location.href = '/leave-factory/info?id=' + id + '&status=' + status + '&type=2';
    }
</script>