<?php
use \common\libs\MyLib;
?>
<style>
    .qbox{
        margin-top:10px;
        margin-left: 10px;
    }
    .xtop{
        position: relative;
    }
    .xchide{
        background: #e4f1fa;
        width: 200px;
        height: 110px;
        margin: auto;
        left: 0;
        top: 156px;
        border:1px solid #a5d0e1;
        position: absolute;
        display: none;
        bottom: 0; right: 0;
    }

</style>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.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/common2.js"></script>
<script type="text/javascript" language="javascript">
    function info(id) {

        window.open('/car/info-track?id=' + id);
    }

    $(function(){
        //操作历史
        gotoPage('/car/ajax-history-index?car_id=<?=$id?>&page=1&t='+Math.random(),'car_history_list');
        //返回
        $('.js-back-btn').click(function(){
            window.location.href = '/car/invalid-xubao';
        });

        $('.invalid-btn').click(function(){
            var car_id = <?=$id?>;
            var invalid_id = $('#invalid_id').val();
//            var invalid_id = $('#invalid_id').val();
            if(invalid_id == 0) {
                alert('必须选择无效理由!');
                return;
            }
            if(invalid_id ==26 ||invalid_id ==27 || invalid_id ==34 ||invalid_id ==35 ||invalid_id ==36 ||invalid_id ==44){
                $('.xchide').show()
//                alert('请更新保险日期')
//                $(".baocun").click()
                return
            }
            if(confirm('是否无效这条数据?')) {

                $.post('/car/invalid-f',{car_id:car_id,invalid_id:invalid_id},function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('.xchide').hide()
                        $('#appointment-save-btn').attr('disabled',true);
                        $('.save-btn').attr('disabled',true);
                        $('.invalid-btn').attr('disabled',true);
                        next_index = next_index - 1;
                        if(next_index < 0) next_index = 0;
                    }
                },'json');
            }
        });
        $('.qux').click(function(){
            $('.xchide').hide()
        })
        $('.queding').click(function(){
            var ac1=$('.ac1').val();
            var ac2=$('.ac2').val();
//            var ac3=$('.cpys').val();
            var car_id = <?=$id?>;
            var invalid_id = $('#invalid_id').val();
            if(ac1==''|| ac2==''){
                alert('请填写保险日期')
                return false;
            }else{
                if(confirm('是否无效这条数据?')) {

                    $.post('/car/invalid-f',{car_id:car_id,invalid_id:invalid_id,ac1:ac1,ac2:ac2},function(obj){
                        alert(obj.msg);
                        if(obj.success) {
                            $('.xchide').hide()
                            $('#appointment-save-btn').attr('disabled',true);
                            $('.save-btn').attr('disabled',true);
                            $('.invalid-btn').attr('disabled',true);
                            next_index = next_index - 1;
                            if(next_index < 0) next_index = 0;
                        }
                    },'json');


                }
            }

        })



    });
</script>
<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<table>
    <tbody>
    <tr>
        <TD height="30" align="center" class=tab-on id=navcell onclick=open_up(1) name="navcell">▼保单信息</TD>
    </tr>
    </tbody>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table" id=tb1>
    <tr>
        <td width="30" align="center" class="bg_tr" nowrap>序号</td>
        <td width="60" align="center" class="bg_tr" nowrap>车牌号</td>
        <td width="50" align="center" class="bg_tr" nowrap>保险到期日</td>
        <td width="60" align="center" class="bg_tr" nowrap>电话</td>
        <td width="60" align="center" class="bg_tr" nowrap>数据下发日期</td>
        <td width="60" align="center" class="bg_tr" nowrap>无效原因</td>
        <td width="60" align="center" class="bg_tr" nowrap>业务员</td>
        <td width="60" align="center" class="bg_tr" nowrap>详情</td>

    </tr>
    <?php
    foreach($data as $index => $item) {

        ?>
        <tr>
            <td align="center" class="td_bg" nowrap ><?=$index + 1?></td>
            <td class="td_bg" nowrap><?=$item->car_no?></td>
            <td class="td_bg" nowrap><?=$item->insurer1_date?></td>
            <td class="td_bg" nowrap><?=$item->phone?></td>
            <td class="td_bg" nowrap><?=$item->xdate?></td>
            <td class="td_bg" nowrap><?=$item->invalids->name?></td>
            <td class="td_bg" nowrap><?=$item->user?$item->user->getShowName():''?></td>
<!--            找出这条订单的id-->
            <td class="td_bg" nowrap>[<a href="javascript:void(0);" onclick="info(<?=$item->car_id?>)">详情</a>]</td>

        </tr>
        <?php
    }
    ?>

</table>
<table>
    <tbody>
    <tr>
        <TD height="30" align="center" class=tab-off id=navcell onclick=open_up(4) name="navcell">▲操作记录</TD>
    </tr>
    </tbody>
</table>
<TABLE id=tb4 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
    <TR>
        <TD vAlign=top>
            <div id="car_history_list"></div>
        </TD>
    </TR>
</TABLE>
<table cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
    <tr>


        <td height="22" colspan="8" align="center" class="td_bg">

            <input id="back-btn" type="button" class="ACT_btn js-back-btn"  value=" 返回 ">
            <select name="invalid_id" id="invalid_id">
                <option value="0">请选择无效理由</option>
                <?php foreach($failure_items as $item) {?>

                    <option value="<?=$item->id?>"<?php if($item->id==25 || $item->id==37 || $item->id==40){ echo 'disabled';}?>><?=$item->name?></option>

                <?php  }?>


            </select>
            <input type=button class="ACT_btn invalid-btn" name="invalid-btn" value=" 无效数据 "/>
            <div class="xtop">
                <div class="xchide">
                    <div class="qbox">
                        商业起保日期: <input class="act_date ac1" type="text" name="insurer1_date" value="" onclick="WdatePicker()">
                    </div>

                    <div class="qbox">
                        交强起保日期: <input class="act_date ac2" type="text"  name="insurer2_date" value="" onclick="WdatePicker()">
                    </div>

<!--                    <div class="qbox">-->
<!--                        保险公司:<select name="company" class="cpys" style="width:100px;">-->
<!--                            <option value="">---请选择---</option>-->
<!--                            --><?php
//                            foreach($insurer_company2_items as $item) {
//                                echo '<option value="'.$item->name.'"';
//
//                                echo '>'.$item->name.'</option>';
//                            }
//                            ?>
<!--                        </select>-->
<!--                    </div>-->
                    <div class="qbox">
                        <button class="queding">确定</button>
                        <button class="qux">取消</button>
                    </div>
                </div>
            </div>
        </td>

    </tr>
</table>