<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">
    <tr>
        <td class="td_bg" id="append_1"></td>
    </tr>
</table>
<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="<?= $car_no ?>">
                <label for="id_man">被保险人:</label>
                <input name="id_man" id="id_man" type="text" size="10" value="<?= $id_man ?>">
                <label for="id_phone">电话:</label>
                <input name="id_phone" id="id_phone" type="text" size="10" value="<?= $id_phone ?>">
                <label for="link_man">联系人:</label>
                <input name="link_man" id="link_man" type="text" size="10" value="<?= $link_man ?>">
                <label for="link_phone">电话:</label>
                <input name="link_phone" id="link_phone" type="text" size="10" value="<?= $link_phone ?>">
                <label for="sort_key">排序:</label>
                <select name="sort_key" id="sort_key">
                    <option value="created_at" <?= 'create_at' === $sort_key ? 'selected' : '' ?>>提单日期</option>
                </select>
                <select name="sort_value">
                    <option value="ASC" <?= 'ASC' === $sort_value ? 'selected' : ''?>>顺序</option>
                    <option value="DESC" <?= '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="<?= $start_time ?>">
                至<input type="text" size="10" name="end_time" onclick="WdatePicker()" value="<?= $end_time ?>">
                <input type="submit" class="act_btn" value="搜索">
                <input type="reset" class="act_btn" value="重置">
                <input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加">
<!--                <input type="button" class="act_btn" id="items-list" 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 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->fix->car_no ?></td>
            <td align="left" class="td_bg" nowrap><?= $item->fix->brand ? $item->fix->brand->name : '' ?></td>
            <td align="left" class="td_bg" nowrap><?= $item->fix->series ? $item->fix->series->name : '' ?></td>
            <td align="left" class="td_bg" nowrap><?= $item->fix->link_man ?></td>
            <td align="left" class="td_bg" nowrap><?= $item->fix->accident_type ?></td>
            <td align="left" class="td_bg" nowrap><?= $item->fix->finish_date ?></td>
            <td align="left" class="td_bg" nowrap><?= $type_name ?></td>
            <td align="center" class="td_bg" nowrap>
                [<a href="javascript:void(0);" onclick="edit(<?= $item->fix->id ?>,<?= $item->fix->status ?>)">详情</a>]
                [<a href="javascript:void(0);" onclick="del(<?= $item->fix->id ?>)">删除</a>]
            </td>
        </tr>
    <?php endforeach; ?>
    <tr>
        <td height="25" colspan="9" align="center" class="td_bg"><?= $page_info ?></td>
    </tr>
</table>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(id, status) {
        window.location.href = '/business-order/paint-work-info?id=' + id + '&status=' + status + '&type=2';
    }
    $('#items-list').on('click',function(){
        window.location.href = "/fix-car-item/items-list?type=<?= $type_name ?>";
    });
    var itemIdArr = [];

    function batchGetItem(){
        $.post('/fix-car-item/batch-get-item',{item_id:itemIdArr},function(data){
            refreshItem();
        },'json');
    }
    //定时更新维修订单数
    refreshItem();
    setInterval(refreshItem,10000);
    function refreshItem(){
        $.post('/fix-car-item/item',{type:3},function(data){
            $('#append_1').html(data.content);
            itemIdArr = data.data;
        },'json');
    }
</script>