<?php
use \common\libs\MyLib;
use \common\models\PriceT;
?>
<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>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td colspan="13" height="22" class="td_bg">
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                <TBODY>
                <TR>
                    <TD height="30" align="center" class=tab-on id=navcell onclick=switchCell(1) name="navcell">预约信息</TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(2) name="navcell">保单信息</TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(3) name="navcell">自费礼品</TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(4) name="navcell">操作记录</TD>
                    <TD height="30" class=tab-none>&nbsp;</TD>
                </TR>
                </TBODY>
            </TABLE>
        </td>
    </tr>
    <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 id=tb 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 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="100" height="25" class="bg_tr">品牌</td>
                                            <td height="25" class="td_bg"><?=$car_info->brand?$car_info->brand->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="100" height="25" class="bg_tr">初登日期</td>
                                            <td height="25" class="td_bg"><?=$car_info->register_date?></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="100" height="25" class="bg_tr">座位数</td>
                                            <td height="25" class="td_bg">
                                                <?=$car_info->seats?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">车系</td>
                                            <td height="25" class="td_bg"><?=$car_info->series?$car_info->series->name:''?></td>
                                            <td width="100" height="25" class="bg_tr">排量</td>
                                            <td height="25" class="td_bg"><?=$car_info->displacement?$car_info->displacement->name:''?></td>
                                            <td width="100" 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="100" height="25" class="bg_tr"></td>
                                            <td height="25" class="td_bg"></td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">备注</td>
                                            <td colspan="5" height="25" class="td_bg"><?=$car_info->remark?></td>
                                        </tr>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <form id="appointmentFrm">
                                            <input type="hidden" name="car_id" value="<?=$car_info->id?>">
                                            <tr>
                                                <td align="right" class="bg_tr">预约日期：</td>
                                                <td class="td_bg">
                                                    <div align="left">
                                                        <input class="act_date" name="pdate" type="text" value="" onClick="WdatePicker()"/>
                                                    </div>
                                                </td>
                                                <td align="right" class="bg_tr">预约时间：</td>
                                                <td class="td_bg">
                                                    <div align="left">
                                                        <select name="ptime">
                                                            <option>08:00</option>
                                                            <option>08:30</option>
                                                            <option>09:00</option>
                                                            <option>09:30</option>
                                                            <option>10:00</option>
                                                            <option>10:30</option>
                                                            <option>11:00</option>
                                                            <option>11:30</option>
                                                            <option>12:00</option>
                                                            <option>13:00</option>
                                                            <option>13:30</option>
                                                            <option>14:00</option>
                                                            <option>14:30</option>
                                                            <option>15:00</option>
                                                            <option>15:30</option>
                                                            <option>16:00</option>
                                                            <option>16:30</option>
                                                            <option>17:00</option>
                                                        </select>
                                                    </div>
                                                </td>
                                                <td align="right" class="bg_tr">当天预约人数：</td>
                                                <td width="50" class="td_bg">
                                                    <div align="left">
                                                        <span id="day_count">0</span>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right" class="bg_tr">预约备注：</td>
                                                <td colspan="5" class="td_bg">
                                                    <div align="left">
                                                        <textarea name="remark" style="width:600px; height: 30px;"></textarea>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" colspan="6" align="center" class="td_bg">
                                                    <input id="appointment-save-btn" type=button class="ACT_btn" name="appointment-save-btn" value=" 保存 "/>
                                                </td>
                                            </tr>
                                        </form>
                                    </table>
                                    <div id="appointment_list"></div>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <form id="orderFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                            <input type="hidden" id="car_id" name="car_id" value="<?=$car_info->id?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">车牌号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_no" type="text" value="<?=$car_info->car_no?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">厂牌型号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="factory_model" type="text" value="<?=$car_info->factory_model?>" style="width:100px;"/>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">品牌</td>
                                                <td width="120" height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($brand_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($car_info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($series_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($car_info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" value="<?=$car_info->engine_no?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" value="<?=$car_info->car_frame_no?>" style="width:100px;"/>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">初登日期</td>
                                                <td height="25" class="td_bg">
                                                    <input class="act_date" name="register_date" type="text" value="<?=$car_info->register_date?>" onclick="WdatePicker()"/>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($displacement_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($car_info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">车辆类型</td>
                                                <td height="25" class="td_bg">
                                                    <select id="car_type_id" name="car_type_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($car_type_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($car_info->car_type_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">运营性质</td>
                                                <td height="25" class="td_bg">
                                                    <select name="car_use_id" id="car_use_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($car_use_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($car_info->car_use_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">座位数</td>
                                                <td height="25" class="td_bg">
                                                    <input name="seats" type="text" value="<?=$car_info->seats?>" style="width:50px;"/>
                                                </td>
                                                <td width="60" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?=$car_info->car_year?>" style="width:50px;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">车主</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" id="car_man" name="car_man" value="<?=$car_info->car_man?>" style="width:100px;" >
                                                </td>
                                                <td width="100" height="25" class="bg_tr">联系电话</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" id="phone" name="phone" value="<?=$car_info->phone?>" style="width:100px;" >
                                                </td>
                                                <td width="60" height="25" class="bg_tr">备注</td>
                                                <td colspan="3" height="25" class="td_bg">
                                                    <input type="text" name="car_remark" id="car_remark" value="<?=$car_info->remark?>" style="width:300px;">
                                                </td>
                                            </tr>
                                        </table>
                                        <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">
                                                    <input type="text" id="id_man" name="id_man" value="<?=$order_info->id_man?>" style="width:100px;">
                                                </td>
                                                <td class="bg_tr">证件号码</td>
                                                <td class="td_bg">
                                                    <input type="text" id="id_number" name="id_number" value="<?=$order_info->id_number?>" style="width:100px;">
                                                </td>
                                                <td width="60" class="bg_tr">联系人</td>
                                                <td class="td_bg">
                                                    <input type="text" id="link_man" name="link_man" value="<?=$order_info->link_man?>" style="width:100px;">
                                                </td>
                                                <td width="60" class="bg_tr">联系电话</td>
                                                <td class="td_bg">
                                                    <input type="text" id="link_phone" name="link_phone" value="<?=$order_info->link_phone?>" style="width:100px;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">送单日期</td>
                                                <td class="td_bg">
                                                    <input class="act_date" type="text" id="send_date" name="send_date" value="<?=$order_info->send_date?>" onClick="WdatePicker()">
                                                </td>
                                                <td class="bg_tr">保险公司</td>
                                                <td class="td_bg">
                                                    <select name="company_id" id="company_id" style="width:100px;">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($insurer_company_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->company_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td class="bg_tr">付款方式</td>
                                                <td class="td_bg">
                                                    <select name="pay_type_id" id="pay_type_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($pay_type_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->pay_type_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td class="bg_tr">电子邮件</td>
                                                <td class="td_bg">
                                                    <input type="text" id="email" name="email" value="<?=$order_info->email?>" style="width:100px;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">商业起保日期</td>
                                                <td class="td_bg">
                                                    <input class="act_date" type="text" id="insurer1_begin_date" name="insurer1_begin_date" value="<?=$order_info->insurer1_begin_date?>" onClick="WdatePicker()">
                                                </td>
                                                <td class="bg_tr">交强起保日期</td>
                                                <td class="td_bg">
                                                    <input class="act_date" type="text" id="insurer2_begin_date" name="insurer2_begin_date" value="<?=$order_info->insurer2_begin_date?>" onClick="WdatePicker()">
                                                </td>
                                                <td rowspan="2" class="bg_tr" valign="center">备注</td>
                                                <td colspan="3" rowspan="2" valign="top" class="td_bg">
                                                    <textarea style="width:260px; height: 80px;" name="order_remark" id="order_remark"><?=$order_info->remark?></textarea>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">送单地址</td>
                                                <td colspan="3" class="td_bg">
                                                    <select name="direction1_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($direction_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->direction1_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="range1_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($range_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->range1_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="city1_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($city_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->city1_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="district1_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($district_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->district1_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <input type="text" id="send_address1" name="send_address1" value="<?=$order_info->send_address1?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_tr">正本送单地址</td>
                                                <td colspan="3" class="td_bg">
                                                    <select name="direction2_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($direction_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->direction2_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="range2_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($range_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->range2_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="city2_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($city_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->city2_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <select name="district2_id">
                                                        <option value="0"></option>
                                                        <?php
                                                        foreach($district_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($item->id == $order_info->district2_id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                    <input type="text" id="send_address2" name="send_address2" value="<?=$order_info->send_address2?>">
                                                </td>
                                                <td class="bg_tr">成功理由</td>
                                                <td colspan="3" class="td_bg">
                                                    <select name="success_id" id="success_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach($success_items as $item) {
                                                            echo '<option value="'.$item->id.'"';
                                                            if($order_info->success_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>'.$item->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
                                            <tr>
                                                <td width="70%" valign="top">
                                                    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                                        <tr>
                                                            <td align="center" class="bg_tr">险种</td>
                                                            <td align="center" class="bg_tr">内容</td>
                                                            <td align="center" class="bg_tr" nowrap>不计免赔</td>
                                                            <td align="center" class="bg_tr">险种</td>
                                                            <td align="center" class="bg_tr">内容</td>
                                                            <td align="center" class="bg_tr" nowrap>不计免赔</td>
                                                        </tr>
                                                        <?php
                                                        $len = count($insurer_type_items);
                                                        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();
                                                            ?>
                                                            <tr>
                                                                <td class="bg_tr" nowrap><?=$item->name?>(<?=$item->code?>)</td>
                                                                <td class="td_bg"><?php
                                                                    if($item->content != '') {
                                                                        $tmp_items = explode(',',$item->content);
                                                                        echo '<select name="types['.$item->id.']">';
                                                                        $tmp_items = explode(',',$item->content);
                                                                        foreach($tmp_items as $tmp_item) {
                                                                            echo '<option';
                                                                            if(!empty($tmp_row) && $tmp_row->val == $tmp_item)
                                                                                echo ' selected ';
                                                                            echo '>'.$tmp_item.'</option>';
                                                                        }
                                                                        echo '</select>';
                                                                    } else {
                                                                        echo '<input name="types['.$item->id.']" style="width:80px;" type="text"';
                                                                        if(!empty($tmp_row))
                                                                            echo ' value="'.$tmp_row->val.'" ';
                                                                        echo '>';
                                                                    }
                                                                    ?>
                                                                </td>
                                                                <td align="center" class="td_bg"><?php
                                                                    if($item->has_nopay) {
                                                                        echo '<input type="checkbox" value="1" name="nopays['.$item->id.']"';
                                                                        if(!empty($tmp_row) && $tmp_row->is_nopay == 1)
                                                                            echo ' checked ';
                                                                        echo '>';
                                                                    }
                                                                    ?>
                                                                </td>
                                                                <?php
                                                                $i++;
                                                                if($i == $len) {
                                                                    echo '<td></td>';
                                                                    echo '<td></td>';
                                                                    echo '<td></td>';
                                                                    break;
                                                                } else {
                                                                    $item = $insurer_type_items[$i];
                                                                    ?>
                                                                    <td class="bg_tr" nowrap><?=$item->name?>(<?=$item->code?>)</td>
                                                                    <td class="td_bg"><?php
                                                                        if($item->content != '') {
                                                                            $tmp_items = explode(',',$item->content);
                                                                            echo '<select name="types['.$item->id.']">';
                                                                            $tmp_items = explode(',',$item->content);
                                                                            foreach($tmp_items as $tmp_item) {
                                                                                echo '<option';
                                                                                if(!empty($tmp_row) && $tmp_row->val == $tmp_item)
                                                                                    echo ' selected ';
                                                                                echo '>'.$tmp_item.'</option>';
                                                                            }
                                                                            echo '</select>';
                                                                        } else {
                                                                            echo '<input name="types['.$item->id.']" style="width:100px;" type="text"';
                                                                            if(!empty($tmp_row))
                                                                                echo ' value="'.$tmp_row->val.'" ';
                                                                            echo '>';
                                                                        }
                                                                        ?>
                                                                    </td>
                                                                    <td align="center" class="td_bg"><?php
                                                                        if($item->has_nopay) {
                                                                            echo '<input type="checkbox" value="1" name="nopays['.$item->id.']"';
                                                                            if(!empty($tmp_row) && $tmp_row->is_nopay == 1)
                                                                                echo ' checked ';
                                                                            echo '>';
                                                                        }
                                                                        ?>
                                                                    </td>
                                                                    <?php
                                                                }
                                                                ?>
                                                            </tr>
                                                            <?php
                                                        }
                                                        ?>
                                                    </table>
                                                </td>
                                                <td width="10px;">&nbsp;</td>
                                                <td width="30%" valign="top">
                                                    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
                                                        <tr>
                                                            <td class="bg_tr">商业总净保费</td>
                                                            <td class="td_bg"><input name="total1_clear" id="total1_clear" type="text" value="<?=$order_info->total1_clear?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">商业含税总保费</td>
                                                            <td class="td_bg"><input name="total1" id="total1" type="text" value="<?=$order_info->total1?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">交强总净保费</td>
                                                            <td class="td_bg"><input name="total2_clear" id="total2_clear" type="text" value="<?=$order_info->total2_clear?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">交强含税总保费</td>
                                                            <td class="td_bg"><input name="total2" id="total2" type="text" value="<?=$order_info->total2?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">车船税</td>
                                                            <td class="td_bg"><input name="total3" id="total3" type="text" value="<?=$order_info->total3?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">折扣后商业净保费</td>
                                                            <td class="td_bg"><input name="total1_real" id="total1_real" type="text" value="<?=$order_info->total1_real?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">减免金额</td>
                                                            <td class="td_bg"><input name="total1_dis" id="total1_dis" type="text" value="<?=$order_info->total1_dis?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">商业折扣率</td>
                                                            <td class="td_bg"><input name="total1_percent" id="total1_percent" type="text" value="<?=$order_info->total1_percent?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">共计签单</td>
                                                            <td class="td_bg"><input name="total_all" id="total_all" type="text" value="<?=$order_info->total_all?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">应收</td>
                                                            <td class="td_bg"><input name="total_real" id="total_real" type="text" value="<?=$order_info->total_real?>" style="width:100px;"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="bg_tr">备注</td>
                                                            <td class="td_bg"><input name="price_remark" id="price_remark" type="text" value="<?=$order_info->price_remark?>" style="width:100px;"></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <form id="giftFrm">
                                            <input type="hidden" name="car_id" value="<?=$car_info->id?>">
                                            <tr>
                                                <td width="100" align="right" class="bg_tr">礼品：</td>
                                                <td class="td_bg">
                                                    <div align="left">
                                                        <select name="gift_id">
                                                            <option value="0">---请选择---</option>
                                                            <?php
                                                            foreach($gift_items as $item) {
                                                                echo '<option value="'.$item->id.'">'.$item->name.'</option>';
                                                            }
                                                            ?>
                                                        </select>
                                                        <input id="gift-add-btn" type=button class="ACT_btn" name="gift-add-btn" value=" 添加 "/>
                                                    </div>
                                                </td>
                                            </tr>
                                        </form>
                                    </table>
                                    <div id="gift_list"></div>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb 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>
        </td>
    </tr>
    <tr>
        <td height="22" colspan="2" align="center" class="td_bg">
            <select name="invalid_id" id="invalid_id">
                <option value="0">请选择无效理由</option>
                <?php
                foreach($failure_items as $item) {
                    echo '<option value="'.$item->id.'">'.$item->name.'</option>';
                }
                ?>
            </select>
            <input id="invalid-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;
            <select name="status_id" id="status_id">
                <option value="0"></option>
                <option value="2">核保管理</option>
                <?php
//                if($order_info->return_status_id > 3)
//                    echo '<option value="3">送保单打印</option>';
                if($order_info->return_status_id > 4)
                    echo '<option value="4">配送调度</option>';
                if($order_info->return_status_id > 5)
                    echo '<option value="5">正本管理</option>';
//                if($order_info->return_status_id > 6)
//                    echo '<option value="6">正本打印</option>';
//                if($order_info->return_status_id > 7)
//                    echo '<option value="7">正本快递打印</option>';
//                if($order_info->return_status_id > 8)
//                    echo '<option value="8">正本配送</option>';
//                if($order_info->return_status_id > 9)
//                    echo '<option value="9">保单办结</option>';
                ?>
            </select>
            <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">
    //报价计算
    function calc() {
        var total1_clear = Number($('#total1_clear').val());
        var total1 = Number($('#total1').val());
        var total2_clear = Number($('#total2_clear').val());
        var total2 = Number($('#total2').val());
        var total3 = Number($('#total3').val());
        var total1_real = Number($('#total1_real').val());
        var total1_dis = Number($('#total1_dis').val());
        var total1_percent = Number($('#total1_percent').val());
        var total_all = Number($('#total_all').val());
        var total_real = Number($('#total_real').val());
        total1 = 1.06 * total1_clear;
        total2 = 1.06 * total2_clear;
        total_all = total1 + total2 + total3;
        total1_dis = total1_clear - total1_real;
        total_real = total_all - total1_dis;
        total1_percent = parseFloat(total1_real/total1_clear);
        $('#total1').val(total1.toFixed(2));
        $('#total2').val(total2.toFixed(2));
        $('#total1_dis').val(total1_dis.toFixed(2));
        $('#total1_percent').val(total1_percent.toFixed(2));
        $('#total_all').val(total_all.toFixed(2));
        $('#total_real').val(total_real.toFixed(2));
    }
    //保单处理
    function SaveOrder(status_id) {
        var param = $('#orderFrm').serialize();
        param = param + '&status_id=' + status_id;
        $.post('/car/order-save',param,function(obj){
            if(obj.success) {
                $('#back-btn').click();
            } else {
                alert(obj.msg);
            }
        },'json');
    }
    $(function(){
        //无效按钮
        $('#invalid-btn').click(function(){
            var car_id = $('#car_id').val();
            var invalid_id = $('#invalid_id').val();
            if(invalid_id == 0) {
                alert('必须选择无效理由!');
                return;
            }
            if(confirm('是否无效这条数据?')) {
                $.post('/car/invalid',{car_id:car_id,invalid_id:invalid_id},function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#back-btn').click();
                    }
                },'json');
            }
        });
        gotoPage('/car/ajax-history-index?car_id=<?=$car_info->id?>&page=1','car_history_list');
        //添加礼品
        $('#gift-add-btn').click(function(){
            var params = $('#giftFrm').serialize();
            $.post('/gift/car-add-save',params,function(obj){
                alert(obj.msg);
                if(obj.success) {
                    $('#giftFrm')[0].reset();
                    gotoPage('/gift/ajax-car-index?car_id=<?=$car_info->id?>','gift_list');
                }
            },'json');
        });
        gotoPage('/gift/ajax-car-index?car_id=<?=$car_info->id?>','gift_list');
        //添加预约
        $('#appointment-save-btn').click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#appointmentFrm").serialize();
                $.post('/appointment/save',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#appointmentFrm')[0].reset();
                        gotoPage('/appointment/ajax-index?car_id=<?=$car_info->id?>&page=1','appointment_list');
                    }
                },'json');
            }
        });
        gotoPage('/appointment/ajax-index?car_id=<?=$car_info->id?>&page=1','appointment_list');

        $('#brand_id').change(function(){
            var brand_id = $(this).val();
            $('#series_id').html('<option value="0">---请选择---</option>');
            $('#displacement_id').html('<option value="0">---请选择---</option>');
            if(brand_id > 0) {
                $.get('/car/series',{brand_id:brand_id},function(obj){
                    if(obj.success) {
                        $('#series_id').html(obj.html);
                    }
                },'json');
            }
        });
        $('#series_id').change(function(){
            var series_id = $(this).val();
            $('#displacement_id').html('<option value="0">---请选择---</option>');
            if(series_id > 0) {
                $.get('/car/displacement',{series_id:series_id},function(obj){
                    if(obj.success) {
                        $('#displacement_id').html(obj.html);
                    }
                },'json');
            }
        });
        $('#total1_clear').blur(function(){
            calc();
        });
        $('#total2_clear').blur(function(){
            calc();
        });
        $('#total1_dis').blur(function(){
            calc();
        });
        $('#total1_real').blur(function(){
            calc();
        });

        //保存
        $('#save-btn').click(function(){
            SaveOrder(1);
        });
        //提交
        $('#submit-btn').click(function(){
            var status_id = $('#status_id').val();
            if(status_id == 0) {
                alert('请先选择提交目标');
                return;
            }
            if(confirm('是否提交此保单？')) {
                SaveOrder(status_id);
            }
        });

        //返回
        $('#back-btn').click(function(){
            window.location.href = '/insurer/my-return-list';
        });
    });
</script>