<?php
use \common\libs\MyLib;
use \common\models\PriceT;
?>
<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <form id="orderFrm">
            <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-off 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>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <input type="hidden" name="car_id" value="<?=$car_info->id?>">
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">车牌号</td>
                                            <td height="25" class="td_bg"><?=$car_info->car_no?></td>
                                            <td width="100" height="25" class="bg_tr">厂牌型号</td>
                                            <td height="25" class="td_bg"><?=$car_info->factory_model?></td>
                                            <td width="60" height="25" class="bg_tr">品牌</td>
                                            <td width="120" height="25" class="td_bg"><?=$car_info->brand?$car_info->brand->name:''?></td>
                                            <td width="60" height="25" class="bg_tr">车系</td>
                                            <td height="25" class="td_bg"><?=$car_info->series?$car_info->series->name:''?></td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">发动机号</td>
                                            <td height="25" class="td_bg"><?=$car_info->engine_no?></td>
                                            <td width="100" height="25" class="bg_tr">车架号</td>
                                            <td height="25" class="td_bg"><?=$car_info->car_frame_no?></td>
                                            <td width="60" height="25" class="bg_tr">初登日期</td>
                                            <td height="25" class="td_bg"><?=$car_info->register_date?></td>
                                            <td width="60" height="25" class="bg_tr">排量</td>
                                            <td height="25" class="td_bg"><?=$car_info->displacement?$car_info->displacement->name:''?></td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">车辆类型</td>
                                            <td height="25" class="td_bg"><?=$car_info->carType?$car_info->carType->name:''?></td>
                                            <td width="100" height="25" class="bg_tr">运营性质</td>
                                            <td height="25" class="td_bg"><?=$car_info->carUse?$car_info->carUse->name:''?></td>
                                            <td width="60" height="25" class="bg_tr">座位数</td>
                                            <td height="25" class="td_bg"><?=$car_info->seats?></td>
                                            <td width="60" height="25" class="bg_tr">年份</td>
                                            <td height="25" class="td_bg"><?=$car_info->car_year?></td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">车主</td>
                                            <td height="25" class="td_bg"><?=$car_info->car_man?></td>
                                            <td width="100" height="25" class="bg_tr">联系电话</td>
                                            <td height="25" class="td_bg"><?=$car_info->phone?></td>
                                            <td width="60" height="25" class="bg_tr">证件号码</td>
                                            <td colspan="3" height="25" class="td_bg"><?=$car_info->car_man_number?></td>
                                        </tr>
                                        <tr>
                                            <td width="60" height="25" class="bg_tr">备注</td>
                                            <td colspan="3" height="25" class="td_bg"><?=$car_info->remark?></td>
                                            <td width="100" height="25" class="bg_tr">业务员</td>
                                            <td height="25" class="td_bg"><?=$order_info->user?$order_info->user->getShowName():''?></td>
                                            <td width="60" height="25" class="bg_tr">联系电话</td>
                                            <td height="25" class="td_bg"><?=$order_info->user?$order_info->user->phone:''?></td>
                                        </tr>
                                    </table>
                                </TD>
                            </TR>
                        </TABLE>
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-off 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>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                            <input type="hidden" name="order_id" value="<?=$order_info->id?>">
                                            <tr>
                                                <td class="bg_tr">被保险人</td>
                                                <td class="td_bg"><?=$order_info->id_man?></td>
                                                <td class="bg_tr">证件号码</td>
                                                <td class="td_bg"><?=$order_info->id_number?></td>
                                                <td width="60" class="bg_tr">联系人</td>
                                                <td class="td_bg"><?=$order_info->link_man?></td>
                                                <td width="60" class="bg_tr">联系电话</td>
                                                <td class="td_bg"><?=$order_info->link_phone?></td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">送单日期</td>
                                                <td class="td_bg"><?=$order_info->send_date?></td>
                                                <td class="bg_tr">保险公司</td>
                                                <td class="td_bg"><?=$order_info->company?$order_info->company->name:''?></td>
                                                <td class="bg_tr">付款方式</td>
                                                <td class="td_bg"><?=$order_info->shoufei_id?MyLib::zhifufs($order_info->shoufei_id).'-':''?><?=$order_info->payType?$order_info->payType->name:''?></td>
                                                <td class="bg_tr">电子邮件</td>
                                                <td class="td_bg"><?=$order_info->email?></td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">商业起保日期</td>
                                                <td class="td_bg"><?=$order_info->insurer1_begin_date?></td>
                                                <td class="bg_tr">交强起保日期</td>
                                                <td class="td_bg"><?=$order_info->insurer2_begin_date?></td>
                                                <td class="bg_tr">缴费单号</td>
                                                <td colspan="3" class="td_bg"><?=$order_info->pay_no?></td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">商业保单号</td>
                                                <td class="td_bg"><?=$order_info->insurer1_no?></td>
                                                <td class="bg_tr">交强保单号</td>
                                                <td class="td_bg"><?=$order_info->insurer2_no?></td>
                                                <td rowspan="3" class="bg_tr" valign="center">备注</td>
                                                <td colspan="3" rowspan="3" valign="top" class="td_bg"><?=$order_info->remark?></td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">送单地址</td>
                                                <td colspan="3" class="td_bg">
                                                    <?=$order_info->direction1?$order_info->direction1->name:''?>
                                                    <?=$order_info->range1?$order_info->range1->name:''?>
                                                    <?=$order_info->city1?$order_info->city1->name:''?>
                                                    <?=$order_info->district1?$order_info->district1->name:''?>
                                                    <?=$order_info->send_address1?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">正本送单地址</td>
                                                <td colspan="3" class="td_bg">
                                                    <?=$order_info->direction2?$order_info->direction2->name:''?>
                                                    <?=$order_info->range2?$order_info->range2->name:''?>
                                                    <?=$order_info->city2?$order_info->city2->name:''?>
                                                    <?=$order_info->district2?$order_info->district2->name:''?>
                                                    <?=$order_info->send_address2?>
                                                </td>
                                            </tr>
                                        </table>
                                </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">
                            <tr>
                                <td valign="top">
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout:fixed;">
                                        <?php
                                        $xianzhong = '<tr><td class="bg_tr">险种</td>';
                                        $neirong = '<tr><td class="bg_tr">内容</td>';
                                        $bujimianpei = '<tr><td class="bg_tr">不计免赔</td>';
                                        foreach ($new_array as $k=>$v){
                                            $xianzhong .= "<td align='center' class='bg_tr'>".$v['zl']."</td>";
                                            $neirong .= "<td align='center' class='td_bg'>".$v['neir']."</td>";
                                            $bujimianpei .= "<td align='center' class='td_bg'>".$v['bjmp']."</td>";
                                        }
                                        echo $xianzhong.'</tr>'.$neirong.'</tr>'.$bujimianpei.'</tr>';
                                        ?>
                                    </table>
                                </td>
                            </tr>
                        </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">
                            <tr>
                                <td valign="top">
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout:fixed;">
                                        <tr>
                                            <td class="bg_tr">商业总净保费</td>
                                            <td class="td_bg"><?=$order_info->total1_clear?></td>
                                            <td class="bg_tr">商业含税总保费</td>
                                            <td class="td_bg"><?=$order_info->total1?></td>
                                            <td class="bg_tr">交强总净保费</td>
                                            <td class="td_bg"><?=$order_info->total2_clear?></td>
                                            <td class="bg_tr">交强含税总保费</td>
                                            <td class="td_bg"><?=$order_info->total2?></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">车船税</td>
                                            <td class="td_bg"><?=$order_info->total3?></td>
                                            <td class="bg_tr">共计签单</td>
                                            <td class="td_bg"><?=$order_info->total_all?></td>
                                            <td class="bg_tr">折扣后商业净保费</td>
                                            <td class="td_bg"><?=$order_info->total1_real?></td>
                                            <td class="bg_tr">减免金额</td>
                                            <td class="td_bg"><?=$order_info->total1_dis?></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">商业折扣率</td>
                                            <td class="td_bg"><?=$order_info->total1_percent?></td>
                                            <td class="bg_tr">应收</td>
                                            <td class="td_bg"><?=$order_info->total_real?></td>
                                            <td class="bg_tr">商业手续费</td>
                                            <td class="td_bg"><?=$order_info->total1_rate?></td>
                                            <td class="bg_tr">交强手续费</td>
                                            <td class="td_bg"><?=$order_info->total2_rate?></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">备注</td>
                                            <td colspan="7" class="td_bg"><?=$order_info->price_remark?></td>
                                        </tr>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                        <tr>
                                            <td class="bg_tr">商业补点比例</td>
                                            <td class="td_bg"><input type="Text" name="budian_rate" value="<?=$caiwu_info->budian_rate?>" class="supplement_proportion" />%</td>
                                            <td class="bg_tr">商业补点手续费</td>
                                            <td class="td_bg"><input type="Text" name="budian_money" value="<?=$caiwu_info->budian_money?>" readonly class="supplement_servicecharge" /></td>
                                            <td class="bg_tr"></td>
                                            <td class="td_bg"></td>
                                            <td class="bg_tr"></td>
                                            <td class="td_bg"></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">商业退保保费</td>
                                            <td class="td_bg"><input type="Text" name="business_back_money" id="business_back_money" value="<?=$caiwu_info->business_back_money?>" class="sy_tb_retreat" onblur="cal_money('business_back_money','business_back_rate','business_back_routine');"/></td>
                                            <td class="bg_tr">退保手续费比例</td>
                                            <td class="td_bg"><input type="Text" name="business_back_rate" id="business_back_rate" value="<?=$caiwu_info->business_back_rate?>" class="sy_tb_bili" onblur="cal_money('business_back_money','business_back_rate','business_back_routine');"/>%</td>
                                            <td class="bg_tr">商业退保手续费</td>
                                            <td class="td_bg"><input type="Text" name="business_back_routine" id="business_back_routine" value="<?=$caiwu_info->business_back_routine?>" class="jq_tb_routine" readonly /></td>
                                            <td class="bg_tr">商业退保日期</td>
                                            <td class="td_bg"><input type="Text" name="business_back_date" id="business_back_date" value="<?=$caiwu_info->business_back_date?>" class="Wdate" onClick="WdatePicker()" /></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">交强退保保费</td>
                                            <td class="td_bg"><input type="Text" name="force_back_money" id="force_back_money" value="<?=$caiwu_info->force_back_money?>" class="jq_tb_retreat" onblur="cal_money('force_back_money','force_back_rate','force_back_routine');"/></td>
                                            <td class="bg_tr">退保手续费比例</td>
                                            <td class="td_bg"><input type="Text" name="force_back_rate" id="force_back_rate" value="<?=$caiwu_info->force_back_rate?>" class="jq_tb_bili" onblur="cal_money('force_back_money','force_back_rate','force_back_routine');"/>%</td>
                                            <td class="bg_tr">交强退保手续费</td>
                                            <td class="td_bg"><input type="Text" name="force_back_routine" id="force_back_routine" value="<?=$caiwu_info->force_back_routine?>" class="jq_tb_routine" readonly /></td>
                                            <td class="bg_tr">交强退保日期</td>
                                            <td class="td_bg"><input type="Text" name="force_back_date" id="force_back_date" value="<?=$caiwu_info->force_back_date?>" class="Wdate" onClick="WdatePicker()" /></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </TABLE>
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-on id=navcell onclick=open_up(5) name="navcell">▼财务信息</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb5 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <tr>
                                <td valign="top">
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                        <tr>
                                            <td class="bg_tr"><span style="color:#ff0000">*</span>领款人</td>
                                            <td class="td_bg"><input name="money_man" id="money_man" type="text" value="<?=$caiwu_info->money_man?>" style="width:120px;"></td>
                                            <td class="bg_tr"><span style="color:#ff0000">*</span>银行账号</td>
                                            <td class="td_bg"><input name="money_no" id="money_no" type="text" value="<?=$caiwu_info->money_no?>" style="width:120px;"></td>
                                            <td class="bg_tr"><span style="color:#ff0000">*</span>开户行</td>
                                            <td class="td_bg"><input name="money_bank" id="money_bank" type="text" value="<?=$caiwu_info->money_bank?>" style="width:120px;"></td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">转账日期</td>
                                            <td class="td_bg"><input class="Wdate" name="transfer_date" id="transfer_date" type="text" value="<?=$caiwu_info->transfer_date?>" style="width:120px;" onClick="WdatePicker()"></td>
                                            <td class="bg_tr">转账金额</td>
                                            <td class="td_bg"><input name="transfer_money" id="transfer_money" type="text" value="<?=$caiwu_info->transfer_money?>" style="width:120px;"></td>
                                            <td class="bg_tr">转账银行</td>
                                            <td class="td_bg">
                                                <select name="transfer_bank_id">
                                                    <?php
                                                    foreach($banks as $bank) {
                                                        echo '<option value="'.$bank->id.'"';
                                                        if($bank->id == $caiwu_info->transfer_bank_id)
                                                            echo ' selected ';
                                                        echo '>'.$bank->name.'</option>';
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr">银行流水号</td>
                                            <td class="td_bg"><input name="transfer_bank_no" id="transfer_bank_no" type="text" value="<?=$caiwu_info->transfer_bank_no?>" style="width:120px;"></td>
                                            <td class="bg_tr">记账凭证</td>
                                            <td class="td_bg"><input name="caiwu_no" id="caiwu_no" type="text" value="<?=$caiwu_info->caiwu_no?>" style="width:200px;"></td>
                                            <td class="bg_tr">转账状态</td>
                                            <td class="td_bg">
                                                <select name="caiwu_status_id">
                                                    <?php
                                                    echo '<option value="0">无操作</option>';
                                                    foreach ($caiwu_status as $item){
                                                        echo '<option value="'.$item->id.'"';
                                                        echo $caiwu_info->caiwu_status_id == $item->id ? 'selected' : '';
                                                        echo '>'.$item->name.'</option>';
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                        </tr>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                        <tr>
                                            <td class="bg_tr" align="center">新保:<?=$car_info->op_user1?></td>
                                            <?php
                                            if($car_info->op_user3 != '') {
                                            ?>
                                                <td class="bg_tr" align="center">跟踪:<?=$car_info->op_user2?></td>
                                                <td class="bg_tr" align="center">续保:<?=$car_info->op_user3?></td>
                                                <?php
                                            }
                                            ?>
                                            <td class="bg_tr" align="center">送单费:<?=$order_info->sendLog?$order_info->sendLog->user->getShowName():''?></td>
                                            <?php
                                            if($order_info->op1_id > 0) {
                                                echo '<td class="bg_tr" align="center">核保:'.$order_info->op1->getShowName().'</td>';
                                            }
                                            if($order_info->op2_id > 0) {
                                                echo '<td class="bg_tr" align="center">正本:'.$order_info->op2->getShowName().'</td>';
                                            }
                                            ?>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr" align="center">新保比例</td>
                                            <?php
                                            if($car_info->op_user3 != '') {
                                            ?>
                                                <td class="bg_tr" align="center">跟踪比例</td>
                                                <td class="bg_tr" align="center">续保比例</td>
                                                <?php
                                            }
                                            ?>
                                            <td class="bg_tr" align="center">送单比例</td>
                                            <?php if($order_info->op1_id > 0) { ?>
                                                <td class="bg_tr" align="center">核保比例</td>
                                            <?php } ?>
                                            <?php if($order_info->op2_id > 0) { ?>
                                                <td class="bg_tr" align="center">正本比例</td>
                                            <?php } ?>
                                        </tr>
                                        <tr>
                                            <?php
                                            if($car_info->op_user3 != '') {
                                            ?>
                                                <td class="td_bg" align="center"><input name="rate1" id="rate1" type="text" value="<?=$caiwu_info->rate1?>" style="width:50px;" onblur="cal_money('rate1','<?=$order_info->total1_clear?>','money1','0')">%</td>
                                                <td class="td_bg" align="center"><input name="rate2" id="rate2" type="text" value="<?=$caiwu_info->rate2?>" style="width:50px;" onblur="cal_money('rate2','<?=$order_info->total1_clear?>','money2','0')">%</td>
                                                <td class="td_bg" align="center"><input name="rate3" id="rate3" type="text" value="<?=$caiwu_info->rate3?>" style="width:50px;" onblur="cal_money('rate3','<?=$order_info->total1_clear?>','money3','<?=$order_info->total1_dis?>')">%</td>
                                                <?php
                                            } else {
                                                ?>
                                                <td class="td_bg" align="center"><input name="rate1" id="rate1" type="text" value="<?=$caiwu_info->rate1?>" style="width:50px;" onblur="cal_money('rate1','<?=$order_info->total1_clear?>','money1','<?=$order_info->total1_dis?>')">%</td>
                                                <?php
                                            }
                                            ?>
                                            <td class="td_bg" align="center"><input name="send_rate" id="send_rate" type="text" value="<?=$caiwu_info->send_rate?>" style="width:100px;" readonly>%</td>
                                            <?php if($order_info->op1_id > 0) { ?>
                                                <td class="td_bg" align="center"><input name="rate4" id="rate4" type="text" value="<?=$caiwu_info->rate4?>" style="width:100px;" onblur="cal_money('rate4','<?=$order_info->total1_clear?>','money4','0')">%</td>
                                            <?php } ?>
                                            <?php if($order_info->op2_id > 0) { ?>
                                                <td class="td_bg" align="center"><input name="rate5" id="rate5" type="text" value="<?=$caiwu_info->rate5?>" style="width:100px;" onblur="cal_money('rate5','<?=$order_info->total1_clear?>','money5','0')">%</td>
                                            <?php } ?>
                                        </tr>
                                        <tr>
                                            <td class="bg_tr" align="center">新保提成</td>
                                            <?php
                                            if($car_info->op_user3 != '') {
                                            ?>
                                                <td class="bg_tr" align="center">跟踪提成</td>
                                                <td class="bg_tr" align="center">续保提成</td>
                                                <?php
                                            }
                                            ?>
                                            <td class="bg_tr" align="center">送单提成</td>
                                            <?php if($order_info->op1_id > 0) { ?>
                                                <td class="bg_tr" align="center">核保提成</td>
                                            <?php } ?>
                                            <?php if($order_info->op2_id > 0) { ?>
                                                <td class="bg_tr" align="center">正本提成</td>
                                            <?php } ?>
                                        </tr>
                                        <tr>
                                            <?php
                                            if($car_info->op_user3 != '') {
                                            ?>
                                                <td class="td_bg" align="center"><input name="money1" id="money1" type="text" value="<?=$caiwu_info->getPay($caiwu_info->rate1)?>" style="width:100px;" readonly>元</td>
                                                <td class="td_bg" align="center"><input name="money2" id="money2" type="text" value="<?=$caiwu_info->getPay($caiwu_info->rate2)?>" style="width:100px;" readonly>元</td>
                                                <td class="td_bg" align="center"><input name="money3" id="money3" type="text" value="<?=$caiwu_info->getPay($caiwu_info->rate3)?>" style="width:100px;" readonly>元</td>
                                                <?php
                                            } else {
                                                ?>
                                                <td class="td_bg" align="center"><input name="money1" id="money1" type="text" value="<?=$caiwu_info->getPay($caiwu_info->rate1)?>" style="width:100px;" readonly>元</td>
                                                <?php
                                            }
                                            ?>
                                            <td class="td_bg" align="center"><input name="send_money" id="send_money" type="text" value="<?=$caiwu_info->send_money?>" style="width:100px;" onblur="cal_rate('send_money','<?=$order_info->total1_clear?>','send_rate','0')">元</td>
                                            <?php if($order_info->op1_id > 0) { ?>
                                                <td class="td_bg" align="center"><input name="money4" id="money4" type="text" value="<?=$caiwu_info->money4?>" style="width:100px;" onblur="cal_rate('money4','<?=$order_info->total1_clear?>','rate4','0')">元</td>
                                            <?php } ?>
                                            <?php if($order_info->op2_id > 0) { ?>
                                                <td class="td_bg" align="center"><input name="money5" id="money5" type="text" value="<?=$caiwu_info->money5?>" style="width:100px;" onblur="cal_rate('money5','<?=$order_info->total1_clear?>','rate5','0')">元</td>
                                            <?php } ?>
                                        </tr>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                        <tr>
                                            <td colspan="6" class="bg_tr">实物</td>
                                        </tr>
                                        <tr>
                                        <?php
                                        $index = 0;
                                        foreach($sel_gifts as $order_gift) {
                                            if($order_gift->gift->type == 1) continue;
                                            if($index > 0 && $index%3 == 0) {
                                                echo '</tr><tr>';
                                            }
                                            ?>
                                                <td width="250" class="bg_tr"><?=$order_gift->gift->name?></td>
                                                <td class="td_bg">
                                                    <input type="hidden" name="gift_ids[]" value="<?=$order_gift->id?>">
                                                    <input type="hidden" name="gift_rates[]" value="0">
                                                    <input name="gift_prices[]" type="text" value="<?=$order_gift->price?>" style="width:60px;">元
                                                </td>
                                            <?php
                                            $index++;
                                        }
                                        if($index>0) {
                                            while($index%3!=0) {
                                                echo '<td class="td_bg"></td>';
                                                echo '<td class="td_bg"></td>';
                                                $index++;
                                            }
                                        }
                                        ?>
                                        </tr>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                        <tr>
                                            <td colspan="9" class="bg_tr">礼券</td>
                                        </tr>
                                        <tr>
                                            <?php
                                            $index = 0;
                                            foreach($sel_gifts as $order_gift) {
                                                if($order_gift->gift->type == 0) continue;
                                                if($index > 0 && $index%3 == 0) {
                                                    echo '</tr><tr>';
                                                }
                                                $index++;
                                                ?>
                                                <td width="150" class="bg_tr"><?=$order_gift->gift->name?></td>
                                                <td class="td_bg">
                                                    <input type="hidden" name="gift_ids[]" value="<?=$order_gift->id?>">
                                                    <input name="gift_rates[]" id="gift_rates_<?=$order_gift->id?>" type="text" value="<?=$order_gift->rate?>" style="width:60px;" onblur="cal_money('gift_rates_<?=$order_gift->id?>','<?=$order_info->total1_clear?>','gift_prices_<?=$order_gift->id?>','0')">%
                                                </td>
                                                <td class="td_bg">
                                                    <input name="gift_prices[]" id="gift_prices_<?=$order_gift->id?>" type="text" value="<?=$order_gift->price?>" style="width:60px;" readonly>元
                                                </td>
                                                <?php
                                            }
                                            if($index>0) {
                                                while($index%3!=0) {
                                                    echo '<td class="td_bg"></td>';
                                                    echo '<td class="td_bg"></td>';
                                                    echo '<td class="td_bg"></td>';
                                                    $index++;
                                                }
                                            }
                                            ?>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </TABLE>
                        <!--操作记录-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-off id=navcell onclick=open_up(6) name="navcell">▲操作记录</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb6 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>
                    </td>
                </tr>
            </table>
            </form>
        </td>
    </tr>
    <tr>
        <td height="22" colspan="2" align="center" class="td_bg">
            <?php
            if($caiwu_info->status_id != 10)
            {
                ?>
                <input id="return-btn" type=button class="ACT_btn" name=Submit5 value=" 退回 " />
                &nbsp;&nbsp;
                <input id="cancel-btn" type=button class="ACT_btn" name=Submit4 value=" 放弃处理 "/>
                &nbsp;&nbsp;
                <input id="save-btn" type=button class="ACT_btn" name=Submit1 value=" 保存 "/>
                &nbsp;&nbsp;
                <?php
            }
            ?>
            <input id="submit-btn" type=button class="ACT_btn" name=Submit2 value=" 提交 "/>
            &nbsp;&nbsp;
            <input id="back-btn" type="button" class="ACT_btn" name="Submit3" value=" 返回 ">
        </td>
    </tr>
</table>

<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 cal_money(obj1,val,obj3) {
        var total = Number(val)/100 * Number($('#' + obj1).val());
        $('#' + obj3).val(total.toFixed(2));
    }
    function cal_rate(obj1,val,obj3,dis) {
        if(Number(val) == 0) {
            $('#' + obj3).val('0.00');
            return;
        }
        var rate = (Number($('#' + obj1).val()))/Number(val) * 100 ;
        $('#' + obj3).val(rate.toFixed(2));
    }
    //保单处理
    function SaveOrder(status_id) {
        var param = $('#orderFrm').serialize();
        param = param + '&status_id=' + status_id;
        $.post('/insurer/financial-settlement-save',param,function(obj){
            if(obj.success) {
                if(status_id == 10) {
                    alert(obj.msg);
                    $('#back-btn').click();
                } else {
                    alert(obj.msg);
                }
            } else {
                alert(obj.msg);
            }
        },'json');
    }
    $(function(){
        var times = '<?= time(); ?>';
        //操作历史
        gotoPage('/car/ajax-history-index-xubao?car_id=<?=$car_info->id?>&page=1','car_history_list');
        //退回处理
        $('#return-btn').click(function(){
            if(confirm('是否确认退回处理?')) {
                var r = prompt('退回原因', '');
                if(r != null && r != '') {
                    $.post('/insurer/finance-return-op',{
                        order_id:<?=$order_info->id?>,
                        return_remark:r,
                    },function(obj){
                        alert(obj.msg);
                        if(obj.success) {
                            $('#back-btn').click();
                        }
                    },'json');
                } else {
                    alert('不填写原因,无法退回');
                }
            }
        });
        //放弃处理
        $('#cancel-btn').click(function(){
            if(confirm('是否确认放弃处理?')) {
                $.post('/insurer/finance-cancel-save',{order_id:<?=$order_info->id?>},function(obj){
                    if(obj.success) {
                        $('#back-btn').click();
                    } else {
                        alert(obj.msg);
                    }
                },'json');
            }
        });
        //保存
        $('#save-btn').click(function(){
            SaveOrder(13);
        });
        //提交
        $('#submit-btn').click(function(){
            if(confirm('是否提交此保单?')) {
                SaveOrder(10);
            }
        });

        //返回
        $('#back-btn').click(function(){
            window.location.href = '/insurer/financial-settlement-list?<?=$back_params?>';
        });
    });

    //点击隐藏显示
    function show(a){

        $("#"+a).slideToggle(function(){
            $("#Off"+a+",#Off"+a+"Title").toggle();
            $("#On"+a+",#On"+a+"Title").toggle();
        });
    }

    //补点手续费计算
    $(".supplement_proportion").blur(function(){

        //商业净保费
        var total1_clear = '<?=$order_info->total1_clear?>';
        //返点比例
        var proportion = $(".supplement_proportion").val();
        var proportion_last = Number(proportion);
        //计算返点手续费
        var servicecharge = total1_clear*(proportion_last/100);
        var servicecharge_last = servicecharge.toFixed(2);
        //自动结算赋值
        $(".supplement_servicecharge").val(servicecharge_last);
    });
</script>