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

?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <form class="form-horizontal" id="orderFrm">
        <input type="hidden" name="car_id" value="<?=$order_info->car_id?>">
        <input type="hidden" name="order_id" value="<?=$order_info->id?>">
        <input type="hidden" name="celuo_id" value="<?=$order_info->celuo_id?>">
        <input type="hidden" name="fanxian_id" value="<?=$order_info->fanxian_id?>">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>保单信息</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <th class="bg-warning">车牌号</th>
                        <td><label><?=$order_info->car_no?></label></td>
                        <th class="bg-warning" nowrap>初登日期</th>
                        <td><label><?=$car_info->register_date?></label></td>
                        <th class="bg-warning" nowrap>座位数</th>
                        <td><label><?=$order_info->seats?></label></td>
                        <th class="bg-warning" nowrap>电子邮件</th>
                        <td><label><?=$order_info->email?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">车型</th>
                        <td><label><?=$car_info->factory_model?></label></td>
                        <th class="bg-warning" nowrap>发动机号</th>
                        <td><label><?=$order_info->engine_no?></label></td>
                        <th class="bg-warning" nowrap>车架号</th>
                        <td><label><?=$order_info->car_frame_no?></label></td>
                        <th class="bg-warning" nowrap>&nbsp;</th>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <th class="bg-warning">车主</th>
                        <td><label><?=$order_info->car_man?></label></td>
                        <th class="bg-warning">证件类型</th>
                        <td><label><?=$order_info->car_man_type?></label>
                        </td>
                        <th class="bg-warning">证件号码</th>
                        <td><label><?=$order_info->car_man_number?></label></td>
                        <th class="bg-warning">联系电话</th>
                        <td><label><?=$order_info->car_man_phone?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">被投保人</th>
                        <td><label><?=$order_info->id_man?></label></td>
                        <th class="bg-warning">证件类型</th>
                        <td><label><?=$order_info->id_man_type?></label>
                        </td>
                        <th class="bg-warning">证件号码</th>
                        <td><label><?=$order_info->id_man_number?></label></td>
                        <th class="bg-warning">联系电话</th>
                        <td><label><?=$order_info->id_man_phone?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">投保人</th>
                        <td><label><?=$order_info->link_man?></label></td>
                        <th class="bg-warning">证件类型</th>
                        <td><label><?=$order_info->link_man_type?></label>
                        </td>
                        <th class="bg-warning">证件号码</th>
                        <td><label><?=$order_info->link_man_number?></label></td>
                        <th class="bg-warning">联系电话</th>
                        <td><label><?=$order_info->link_man_phone?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning" nowrap>商业起保日期</th>
                        <td>
                            <label><?=$order_info->insurer1_begin_date?></label>
                        </td>
                        <th class="bg-warning" nowrap>交强起保日期</th>
                        <td>
                            <label><?=$order_info->insurer2_begin_date?></label>
                        </td>
                        <th class="bg-warning">保险公司</th>
                        <td>
                            <label><?=$order_info->company->name?></label>
                        </td>
                        <th class="bg-warning">车辆使用性质</th>
                        <td>
                            <label><?=$order_info->car->carUse->name?></label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>险种</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <?php
                        $len = count($insurer_type_items);
                        $index = 0;
                        for($i = 0; $i < $len; $i++) {
                            $item = $insurer_type_items[$i];
                            $order_id = $order_info->id;
                            if(!$order_id)
                                $order_id = 0;
                            $tmp_row = PriceT::find()
                                ->where('order_id='.$order_id.' and type_id='.$item->id)
                                ->one();
                            if($tmp_row->val == '') continue;
                            ?>
                            <th class="bg-warning">
                                <?=$item->name?>(<?=$item->code?>)
                            </th>
                            <td><label><?=$tmp_row->val?></label></td>
                            <td><label><?=(!empty($tmp_row) && $tmp_row->is_nopay == 1)?'不计免赔':''?></label></td>
                            <?php
                            if(($index+1)%3==0) {
                                echo '</tr>';
                                echo '<tr>';
                            }
                            $index++;
                        }
                        ?>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>保费信息</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <th class="bg-warning">商业总净保费</th>
                        <td><label><?=$order_info->total1_clear?></label></td>
                        <th class="bg-warning">商业含税总保费</th>
                        <td><label><?=$order_info->total1?></label></td>
                        <th class="bg-warning">车船税</th>
                        <td><label><?=$order_info->total3?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">交强总净保费</th>
                        <td><label><?=$order_info->total2_clear?></label></td>
                        <th class="bg-warning">交强含税总保费</th>
                        <td><label><?=$order_info->total2?></label></td>
                        <th class="bg-warning">业务自付金额</th>
                        <td><label><?=$order_info->yuangong_money?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">折扣后商业净保费</th>
                        <td><label><?=$order_info->total1_real?></label></td>
                        <th class="bg-warning">减免金额</th>
                        <td><label><?=$order_info->total1_dis?></label></td>
                        <th class="bg-warning">商业折扣率</th>
                        <td><label><?=$order_info->total1_percent?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">共计签单</th>
                        <td><label><?=$order_info->total_all?></label></td>
                        <th class="bg-warning">应收</th>
                        <td><label><?=$order_info->total_real?></label></td>
                        <th class="bg-warning">&nbsp;</th>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <th class="bg-warning">备注</th>
                        <td colspan="5"><label><?=$order_info->price_remark?></label></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>其他信息</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <th class="bg-warning">领款人</th>
                        <td><label><?=$order_info->money_man?></label></td>
                        <th class="bg-warning">开户行</th>
                        <td><label><?=$order_info->money_bank?></label></td>
                        <th class="bg-warning">银行账号</th>
                        <td><label><?=$order_info->money_no?></label></td>
                        <th class="bg-warning" nowrap></th>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <th class="bg-warning">送单地址</th>
                        <td colspan="7" class="form-inline">
                            <label><?=$order_info->sendCity?$order_info->sendCity->name:''?></label>
                            <label><?=$order_info->sendDistrict?$order_info->sendDistrict->name:''?></label>
                            <label><?=$order_info->send_address?></label>
                        </td>
                    </tr>
                    <tr>
                        <th class="bg-warning">备注</th>
                        <td colspan="7"><label><?=$order_info->remark?></label></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>核保信息</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <th class="bg-warning">商业手续费</th>
                        <td><label><?=$order_info->total1_rate?></label></td>
                        <th class="bg-warning">交强手续费</th>
                        <td><label><?=$order_info->total2_rate?></label></td>
                    </tr>
                    <tr>
                        <th class="bg-warning">内勤保险公司</th>
                        <td><label><?=$order_info->company->name?></label>
                        </td>
                        <th class="bg-warning">缴费单号</th>
                        <td><label><?=$order_info->pay_no?></label></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>正本信息</h5>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <tr>
                        <th class="bg-warning text-danger">商业保单号</th>
                        <td><input name="insurer1_no" id="insurer1_no" class="form-control" type="text" value="<?=$order_info->insurer1_no?>"></td>
                        <th class="bg-warning text-danger">交强保单号</th>
                        <td><input name="insurer2_no" id="insurer2_no" class="form-control" type="text" value="<?=$order_info->insurer2_no?>"></td>
                    </tr>
                    <tr>
                        <th class="bg-warning text-danger">商业保单文件</th>
                        <td>
                            <div class="input-group">
                                <input type="text" name="shangye_src" id="shangye_src" class="form-control" value="<?=$order_info->shangye_src?>">
                                <a href="javascript:void(0);" class="input-group-addon" id="upload1">
                                    上传文件
                                </a>
                            </div>
                        </td>
                        <th class="bg-warning text-danger">商业发票文件</th>
                        <td>
                            <div class="input-group">
                                <input type="text" name="fapiao_src" id="fapiao_src" class="form-control" value="<?=$order_info->fapiao_src?>">
                                <a href="javascript:void(0);" class="input-group-addon" id="upload2">
                                    上传文件
                                </a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="bg-warning text-danger">交强保单文件</th>
                        <td>
                            <div class="input-group">
                                <input type="text" name="jiaoqiang_src" id="jiaoqiang_src" class="form-control" value="<?=$order_info->jiaoqiang_src?>">
                                <a href="javascript:void(0);" class="input-group-addon" id="upload3">
                                    上传文件
                                </a>
                            </div>
                        </td>
                        <th class="bg-warning text-danger">交强发票文件</th>
                        <td>
                            <div class="input-group">
                                <input type="text" name="jq_fapiao_src" id="jq_fapiao_src" class="form-control" value="<?=$order_info->jq_fapiao_src?>">
                                <a href="javascript:void(0);" class="input-group-addon" id="upload4">
                                    上传文件
                                </a>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>退回理由</h5>
            </div>
            <div class="ibox-content">
                <div class="mb-8">
                    <textarea name="return_remark" id="return_remark" class="form-control"></textarea>
                </div>
                <div>
                    <div class="row">
                        <div class="col-sm-5 col-sm-offset-4">
                            <button type="button" class="btn btn-primary btn-return" type="button">
                                <strong>退 回</strong>
                            </button>
                            <button type="button" class="btn btn-primary btn-cancel" type="button">
                                <strong>放弃处理</strong>
                            </button>
                            <button type="button" class="btn btn-primary btn-save" type="button">
                                <strong>保 存</strong>
                            </button>
                            <button type="button" class="btn btn-primary btn-submit" type="button">
                                <strong>提 交</strong>
                            </button>
                            <button type="button" class="btn btn-primary btn-back" type="button">
                                <strong>返 回</strong>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>


<?php $this->beginBlock('footer_js'); ?>
<script>
    layui.use(['upload'], function(){
        var upload = layui.upload;
        var upload1 = upload.render({
            elem: '#upload1' //绑定元素
            ,url: '/common/upload' //上传接口
            ,accept: 'file'
            ,done: function(res){
                //上传完毕回调
                if(res.status == 'SUCCESS') {
                    $('#shangye_src').val(res.fileUrl);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
        var upload2 = upload.render({
            elem: '#upload2' //绑定元素
            ,url: '/common/upload' //上传接口
            ,accept: 'file'
            ,done: function(res){
                //上传完毕回调
                if(res.status == 'SUCCESS') {
                    $('#fapiao_src').val(res.fileUrl);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
        var upload3 = upload.render({
            elem: '#upload3' //绑定元素
            ,url: '/common/upload' //上传接口
            ,accept: 'file'
            ,done: function(res){
                //上传完毕回调
                if(res.status == 'SUCCESS') {
                    $('#jiaoqiang_src').val(res.fileUrl);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
        var upload4 = upload.render({
            elem: '#upload4' //绑定元素
            ,url: '/common/upload' //上传接口
            ,accept: 'file'
            ,done: function(res){
                //上传完毕回调
                if(res.status == 'SUCCESS') {
                    $('#jq_fapiao_src').val(res.fileUrl);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });

    var o = {};
    //判断是否填写了选项
    function isNull(data){

        if(data == "" || data == undefined || data == null){
            return true;
        }else{
            return false;
        }
    }
    //保存订单
    function saveOrder(status_id) {
        var params = $('#orderFrm').serialize();
        params = params + '&status_id=' + status_id;
        $.post('/insurer/original-mng-save',params,function(obj){
            parent.layer.msg(obj.msg);
            if(obj.success && status_id>5) {
                $('.btn-back').click();
            }
        },'json');
    }

    $(function() {
        $('.btn-return').click(function(){
            var remark = $('#return_remark').val();
            if(remark === '') {
                parent.layer.msg('请输入退回理由');
                return;
            }
            $.post('/insurer/return-op',{
                order_id:<?=$order_info->id?>,
                return_remark:remark,
                return_status_id:<?=$order_info->status_id?>
            },function(obj){
                parent.layer.msg(obj.msg);
                if(obj.success) {
                    $('.btn-back').click();
                }
            },'json');
        });
        $('.btn-cancel').click(function(){
            parent.layer.confirm('是否确认放弃处理？', {
                btn: ['确认','取消'], //按钮
                shade: false //不显示遮罩
            }, function(){
                var params = $("#theFrm").serialize();
                $.post('/insurer/order-cancel-save',{order_id:<?=$order_info->id?>},function(obj){
                    parent.layer.msg(obj.msg);
                    if(obj.success) {
                        $('.btn-back').click();
                    } else {
                    }
                },'json');
            }, function(){
                //
            });
        });
        $('.btn-save').click(function(){
            saveOrder(5);
        });
        $('.btn-submit').click(function(){
            saveOrder(10);
        });
        $('.btn-back').click(function() {
            window.location.href = '/insurer/original-mng';
        });
    });
</script>
<?php $this->endBlock(); ?>
