<?php
use \common\libs\MyLib;
use \common\models\PriceT;

$my = $this->context->my;
?>
<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<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>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
                <tr>
                    <td height="120" valign="top" class="td_bg">
                        <!--预约信息-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-on id=navcell onclick=open_up(1) name="navcell">▼非车险信息</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb1 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">

                            <TR>
                                <TD vAlign=top>
                                    <form id="myform">

                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">被保险人姓名</td>
                                                <td height="25" class="td_bg"><?=$info->insurant_name?></td>
                                                <td width="100" height="25" class="bg_tr">证件号</td>
                                                <td height="25" class="td_bg"><?=$info->insurant_number?></td>
                                                <td width="100" height="25" class="bg_tr">电话</td>
                                                <td height="25" class="td_bg"><?=$info->insurant_phone?><?php if($info->insurant_phone1): ?>,<?=$info->insurant_phone1?><?php endif;?></td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">投保人姓名</td>
                                                <td height="25" class="td_bg"><?=$info->policy_holder_name?></td>
                                                <td width="100" height="25" class="bg_tr">证件号</td>
                                                <td height="25" class="td_bg"><?=$info->policy_holder_number?></td>
                                                <td width="100" height="25" class="bg_tr">电话</td>
                                                <td height="25" class="td_bg"><?=$info->policy_holder_phone?><?php if($info->policy_holder_phone1): ?>,<?=$info->policy_holder_phone1?><?php endif;?></td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">受益人姓名</td>
                                                <td height="25" class="td_bg"><?=$info->beneficiary_name?></td>
                                                <td width="100" height="25" class="bg_tr">证件号</td>
                                                <td height="25" class="td_bg"><?=$info->beneficiary_number?></td>
                                                <td width="100" height="25" class="bg_tr">电话</td>
                                                <td height="25" class="td_bg"><?=$info->beneficiary_phone?><?php if($info->beneficiary_phone1): ?>,<?=$info->beneficiary_phone1?><?php endif;?></td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">产品方案</td>
                                                <td height="25" class="td_bg">
                                                    <?=$info->scheme_id?$info->sche->name:''?>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">总保额</td>
                                                <td height="25" class="td_bg baoer"></td>
                                                <td width="100" height="25" class="bg_tr">保险费用</td>
                                                <td height="25" class="td_bg feiyong"></td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">起保日期</td>
                                                <td height="25" class="td_bg"><?=$info->insurer_date_start?></td>
                                                <td width="100" height="25" class="bg_tr">投保份数</td>
                                                <td height="25" class="td_bg"><?=$info->num?></td>
                                                <td width="100" height="25" class="bg_tr">座位数</td>
                                                <td height="25" class="td_bg"><?=$info->seat?></td>
                                            </tr>

                                            <!--                                            <tr>-->
<!--                                                <td height="22" colspan="6" align="center" class="td_bg">-->
<!--                                                    <input type=button class="ACT_btn baocun" name="next-btn" value=" 保存 "/>-->
<!--                                                    <input type=button class="ACT_btn submit-btn" name=Submit2 value=" 提交 "/>-->
<!--                                                </td>-->
<!--                                            </tr>-->
                                        </table>
                                    </form>




                                </TD>
                            </TR>
                        </TABLE>

                        <!--保单信息-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-on id=navcell onclick=open_up(2) name="navcell">▼核保信息</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb2 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <TR>
                                <TD vAlign=top>
                                    <form id="orderFrm">
                                        <input type="hidden" name="id" value="<?=$order_info->id?>">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">

                                            <tr>
                                                <td width="100" height="25" class="bg_tr">非车险终止日期</td>
                                                <td height="25" class="td_bg"><input type="text" value="<?=$order_info->insurer_date_end?>" name="insurer_date_end" onClick="WdatePicker()" /></td>
                                                <td width="100" height="25" class="bg_tr">非车险保单号</td>
                                                <td height="25" class="td_bg"><input type="text" value="<?=$order_info->insurer_non_no?>" name="insurer_non_no"  /></td>
                                                <td width="100" height="25" class="bg_tr">电子保单发送状态</td>
                                                <td height="25" class="td_bg">未发<input type="radio" value="1" name="el_insurance"  <?php if($order_info->el_insurance==1) echo 'checked'?>/>已发<input type="radio" value="2" name="el_insurance"  <?php if($order_info->el_insurance==2) echo 'checked'?>/></td>
                                            </tr>

                                        </table>


                                    </form>
                                </TD>
                            </TR>
                            <tr>
                                <td align="center">
<!--                                    <input type=button class="ACT_btn baocun" name=Submit1 value=" 保存 "/>-->
<!--                                    <input type=button class="ACT_btn submit-btn" name=Submit2 value=" 提交 "/>-->
<!--                                    <input type="button" class="ACT_btn back-btn" name="Submit3" value=" 返回 ">-->
                                    <input id="close-btn" type=button class="ACT_btn" name=Submit1 value=" 关闭 "/>
                                </td>
                            </tr>
                        </TABLE>
                        <!--操作记录-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-off id=navcell onclick=open_up(3) name="navcell">▲操作记录</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb3 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>
                            <tr>
                                <td align="center">
                                    <input type=button class="ACT_btn next-btn" name=Submit5 value=" 下一个 "/>
                                    <input type="button" class="ACT_btn back-btn" name="Submit3" value=" 返回 ">
                                </td>
                            </tr>
                        </TABLE>
                        <!--历史保单-->

                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<script type="text/javascript" language="javascript">



    //报价计算


    //保单处理
    function SaveOrder(status_id) {





//        if(status_id == 2){
////            if(isNull(shoufei_id)){
////                alert('收费方式必填项!');
////                return false;
////            }
//
////            }
//
//        }


        var params = $('#orderFrm').serialize();
        params = params + '&status_id=' + status_id;
        $.post('/non-auto-insurance/hb-save',params,function(obj){
            if(obj.success) {
                if(status_id > 15) {
                    $('.back-btn').click();
                }else{
                    alert(obj.msg);
                }

            } else {
                alert(obj.msg);
            }

        },'json');


    }

    //判断是否填写了选项
    function isNull(data){

        if(data == "" || data == undefined || data == null){
            return true;
        }else{
            return false;
        }
    }



    $(function(){
        $('#close-btn').click(function(){
            window.close();
        });
        var schemeid=<?=$info->scheme_id?>;
        if(schemeid){
            $.post('/scheme/chaxun',{id:schemeid},function(obj){
                if(obj.success) {
                    $('.baoer').html(obj.info.baoer);
                    $('.feiyong').html(obj.info.baofei);

                }else{
                    $('.baoer').html('');
                    $('.feiyong').html('');
                }
            },'json');
        }
//        $(document).on("change",'#scheme_id',function(){
//            get_category($(this).val());
//        })


//        $('#scheme_id').change(function(){
//             var id=$(this).val();
//            $.post('/scheme/chaxun',{id:id},function(obj){
//                    if(obj.success) {
//                        $('.baoer').html(obj.info.baoer);
//                        $('.feiyong').html(obj.info.baofei);
//
//                    }else{
//                        $('.baoer').html('');
//                        $('.feiyong').html('');
//                    }
//                },'json');
//        });
        //无效按钮
//        $('.invalid-btn').click(function(){
//            var car_id = $('#car_id').val();
//            var invalid_id = $('#invalid_id').val();
////            var invalid_id = $('#invalid_id').val();
//            if(invalid_id == 0) {
//                alert('必须选择无效理由!');
//                return;
//            }
//            if(invalid_id ==25 ||invalid_id ==26 ||invalid_id ==27 ){
//                $('.xchide').show()
////                alert('请更新保险日期')
////                $(".baocun").click()
//
//                return
//            }
//            if(confirm('是否无效这条数据?')) {
//
//                $.post('/car/invalid-a',{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 = $('#car_id').val();
//            var invalid_id = $('#invalid_id').val();
//            if(ac1==''|| ac2=='' || ac3==''){
//                alert('请填写保险日期和保险公司')
//                return false;
//            }else{
//                if(confirm('是否无效这条数据?')) {
//
//                    $.post('/car/invalid-a',{car_id:car_id,invalid_id:invalid_id,ac1:ac1,ac2:ac2,ac3:ac3},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');
//
//
//                }
//            }
//
//        })


        //操作历史
        gotoPage('/non-auto-insurance/ajax-history-index?non_id=<?=$info->id?>&page=1&t='+Math.random(),'car_history_list');
        //添加自费礼品


        //添加联系人
//        $('.add-linkman-btn').click(function(){
//            if(confirm('是否确认提交?')) {
//                var params = $("#linkmanFrm").serialize();
//                $.post('/car/linkman-save',params,function(obj){
//                    alert(obj.msg);
//                    if(obj.success) {
//                        $('#linkmanFrm')[0].reset();
//                        gotoPage('/car/ajax-linkman-index?car_id=<?//=$car_info->id?>//&t='+Math.random(),'linkman_list');
//                    }
//                },'json');
//            }
//        });





        //提交
        $('.submit-btn').click(function(){
            if(confirm('是否提交此保单?')) {
                SaveOrder(16);
            }
        });

        //返回
        $('.back-btn').click(function(){
            window.location.href = '/non-auto-insurance/hb-index';
        });
        //下一个



        //保存
        $(".baocun").click(function(){
            SaveOrder(15);
        });


    });
</script>