<?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>
<script type="text/javascript" language="javascript" src="/js/common2.js"></script>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
                <tr>
                    <td height="120" valign="top" class="td_bg">
                        <!--车辆信息-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-on id=navcell onclick=open_up(1) name="navcell">▼修车车辆信息</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb1 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <TR>
                                <form id="carFrm">
                                    <TD vAlign=top>
                                        <?php if($uid < 5){ ?>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <input type="hidden" id="id" name="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" id="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_man_number" id="car_man_number" value="<?=$car_info->car_man_number?>" style="width:300px;">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td width="100" height="25" class="bg_tr">商业止保日期</td>
                                                    <td height="25" class="td_bg">
                                                        <input class="act_date" name="insurer1_date" type="text" value="<?=$car_info->insurer1_date?>" onclick="WdatePicker()"/>
                                                    </td>
                                                    <td width="100" height="25" class="bg_tr">交强止保日期</td>
                                                    <td height="25" class="td_bg">
                                                        <input class="act_date" name="insurer2_date" type="text" value="<?=$car_info->insurer2_date?>" onclick="WdatePicker()"/>
                                                    </td>
                                                    <td width="100" height="25" class="bg_tr">保险公司</td>
                                                    <td colspan="3" height="25" class="td_bg">
                                                        <input type="text" name="company" id="company" value="<?=$car_info->company?>" style="width:300px;">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td width="100" height="25" class="bg_tr">备注</td>
                                                    <td colspan="7" class="td_bg">
                                                        <input type="text" name="car_remark" id="car_remark" value="<?=$car_info->remark?>" style="width:600px;">
                                                    </td>
                                                </tr>
                                            </table>
                                        <?php }else{  ?>
                                            <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="60" height="25" class="bg_tr">品牌</td>
                                                    <td width="120" height="25" class="td_bg">
                                                            <?php
                                                            foreach($brand_items as $item) {
                                                                if($car_info->brand_id == $item->id){
                                                                    echo $item->name;
                                                                }
                                                            }
                                                            ?>
                                                    </td>
                                                    <td width="60" height="25" class="bg_tr">车系</td>
                                                    <td height="25" class="td_bg">
                                                            <?php
                                                            foreach($series_items as $item) {
                                                                if($car_info->series_id == $item->id){
                                                                    echo $item->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">
                                                            <?php
                                                            foreach($displacement_items as $item) {
                                                                if($car_info->displacement_id == $item->id){
                                                                    echo $item->name;
                                                                }
                                                            }
                                                            ?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td width="100" height="25" class="bg_tr">车辆类型</td>
                                                    <td height="25" class="td_bg">
                                                            <?php
                                                            foreach($car_type_items as $item) {
                                                                if($car_info->car_type_id == $item->id){
                                                                    echo $item->name;
                                                                }
                                                            }
                                                            ?>
                                                    </td>
                                                    <td width="100" height="25" class="bg_tr">运营性质</td>
                                                    <td height="25" class="td_bg">
                                                            <?php
                                                            foreach($car_use_items as $item) {
                                                                if($car_info->car_use_id == $item->id){
                                                                    echo $item->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="100" height="25" class="bg_tr">商业止保日期</td>
                                                    <td height="25" class="td_bg">
                                                        <?=$car_info->insurer1_date?>
                                                    </td>
                                                    <td width="100" height="25" class="bg_tr">交强止保日期</td>
                                                    <td height="25" class="td_bg">
                                                        <?=$car_info->insurer2_date?>
                                                    </td>
                                                    <td width="100" height="25" class="bg_tr">保险公司</td>
                                                    <td colspan="3" height="25" class="td_bg">
                                                        <?=$car_info->company?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td width="60" height="25" class="bg_tr">备注</td>
                                                    <td colspan="7" height="25" class="td_bg">
                                                        <?=$car_info->remark?>
                                                    </td>
                                                </tr>
                                            </table>
                                        <?php }  ?>
                                    </TD>
                                </form>
                            </TR>
                            <tr>
                                <td align="center">
                                    <!--如果用户ID小于5，说明是有权限的-->
                                    <?php if($uid < 5){ ?>
                                        <input type=button class="act_btn save-btn" name=Submit4 value=" 保存 "/>
                                    <?php } ?>
                                    <!--如果用户ID小于5，说明是有权限的-->
                                    <input type=button class="act_btn next-btn" name=Submit5 value=" 下一个 "/>
                                    &nbsp;&nbsp;
                                    <input type="button" class="act_btn back-btn" name="Submit3" value=" 返回 ">
                                </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" class="hide-table">
                            <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?>
                                                <button onclick="strCall('<?= $car_info->phone ?>')">拨号</button>
                                                <button onclick="strHook()">挂机</button>
                                            </td>
                                            <td width="100" height="25" class="bg_tr">车主证件号码</td>
                                            <td height="25" class="td_bg">
                                                <?=$car_info->car_man_number?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <form id="myform">
                                                <input type="hidden" name="car_id" value="<?=$car_info->id?>" />
                                                <td width="100" height="25" class="bg_tr">商业止保日期</td>
                                                <td height="25" class="td_bg"><input class="act_date" name="insurer1_date" type="text" value="<?=$car_info->insurer1_date?>" onclick="WdatePicker()"/></td>
                                                <td width="100" height="25" class="bg_tr">交强止保日期</td>
                                                <td height="25" class="td_bg"><input class="act_date" name="insurer2_date" type="text" value="<?=$car_info->insurer2_date?>" onclick="WdatePicker()"/></td>
                                                <td width="100" height="25" class="bg_tr">保险公司</td>
                                                <td height="25" class="td_bg"><input type="text" value="<?=$car_info->company?>" name="company" /></td>
                                            </form>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">新保座席</td>
                                            <td height="25" class="td_bg"><?=$car_info->op_user1?></td>
                                            <td width="100" height="25" class="bg_tr">客服代表</td>
                                            <td height="25" class="td_bg"><?=$car_info->op_user2?></td>
                                            <td width="100" height="25" class="bg_tr">续保座席</td>
                                            <td height="25" class="td_bg"><?=$car_info->op_user3?></td>
                                        </tr>
                                        <tr>
                                            <td width="100" height="25" class="bg_tr">备注</td>
                                            <td colspan="3" height="25" class="td_bg"><?=$car_info->remark?></td>
                                            <td height="25" class="bg_tr">区域</td>
                                            <td class="td_bg">
                                                <span style="color:red;font-size:16px;">
                                                    <?php
                                                    if($car_info->location == 3){
                                                        echo '本区';
                                                    }else if($car_info->location == 6){
                                                        echo '外区';
                                                    }
                                                    ?>
                                                </span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22" colspan="6" align="center" class="td_bg">
                                                <input type=button class="ACT_btn baocun" name="next-btn" value=" 保存 "/>
                                            </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" id="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 class="td_bg">
                                                    <div align="left">
                                                        <select name="ptype">
                                                            <option value="0">--选择类型--</option>
                                                            <?php foreach($list as $k=>$v){ ?>
                                                                <option value='<?= $v->code; ?>'><?= $v->name; ?></option>
                                                            <?php } ?>
                                                        </select>
                                                    </div>
                                                </td>
                                                <td align="right" class="bg_tr">当天预约人数：</td>
                                                <td width="80" 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:700px; height: 30px;"></textarea>
                                                    </div>
                                                </td>
                                                <td align="right" class="bg_tr">业务分组：</td>
                                                <td class="td_bg">
                                                    <select name="business_group_id">
                                                        <option value="0">请选择</option>
                                                        <?php
                                                        foreach ($business_group as $k => $v){
                                                            echo '<option value="'.$v->id.'"';
                                                            echo $v->id == $business_group_id ? 'selected' : '';
                                                            echo '>'.$v->name.'</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" colspan="8" align="center" class="td_bg">
                                                    <?php
                                                    $insurer_date = $car_info->insurer1_date;
                                                    if($insurer_date == '') {
                                                        $insurer_date = $car_info->insurer2_date;
                                                    }
                                                    $begin_zhi_date = date('Y-m-d',strtotime('-3 month',strtotime($insurer_date.' 00:00:00')));
                                                    $cur_date = date('Y-m-d');
                                                    //echo '该提示放弃时间'.$begin_zhi_date.'当前'.$cur_date;
                                                    $d1 = strtotime($cur_date);
                                                    $d2 = strtotime($begin_zhi_date);
                                                    $Days = round(($d2-$d1)/3600/24);
                                                    $day = (int)$Days;
                                                    if($day <= 0){
                                                        echo '<input type=button class="act_btn2 cancel-btn" name="cancel-btn" value=" 放弃 " style="border:0px solid #111; font-size:12px; height: 26px; width: 94px; cursor: hand; background:url(\'/images/act_btn2.gif\') no-repeat;" />';
                                                    }
//                                                    $cur_year = date('Y');
//                                                    $cur_date = date('m-d');
//                                                    $year_date = date('Y',strtotime($insurer_date.' 00:00:00'));
//                                                    $begin_date = date('m-d',strtotime('-3 month',strtotime($insurer_date.' 00:00:00')));
//                                                    $end_date = date('m-d',strtotime($insurer_date.' 00:00:00'));
//                                                    echo '今年：'.$cur_year.'<br>结束年份：'.$year_date.'<br>今天日期'.$cur_date.'<br>到期前三个月日期'.$begin_date.'<br>最后真正到期日期'.$end_date.'<br>';
//                                                    if((date('m') < 10) && ($cur_year >= $year_date && $cur_date >= $begin_date && $cur_date <= $end_date)){
//                                                        echo '<input type=button class="act_btn2 cancel-btn" name="cancel-btn" value=" 放弃 "/>';
//                                                    }else if((date('m') >= 10) && ($cur_date >= $begin_date)){
//                                                        echo '<input type=button class="act_btn2 cancel-btn" name="cancel-btn" value=" 放弃 "/>';
//                                                    }
                                                    ?>
                                                    <input id="appointment-save-btn" type=button class="ACT_btn" name="appointment-save-btn" value=" 预约保存 "/>
                                                    <input type=button class="ACT_btn next-btn" name="next-btn" value=" 下一个 "/>
                                                    <input type="button" class="ACT_btn back-btn" name="back-btn" value=" 返回 ">
                                                    <input type="hidden" name="car_id" id="car_id" value="<?=$car_info->id?>">
                                                    <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 type=button class="ACT_btn invalid-btn" name="invalid-btn" value=" 无效数据 "/>
                                                </td>
                                            </tr>
                                        </form>
                                    </table>
                                    <div id="appointment_list"></div>
                                </TD>
                            </TR>
                        </TABLE>
                        <!--保单信息-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-off id=navcell onclick=open_up(3) name="navcell">▲保单信息</TD>
                            </tr>
                            </tbody>
                        </table>
                        <TABLE id=tb3 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <tr>
                                            <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>被保险人</td>
                                            <td width="120" align="center" class="bg_tr" nowrap>商业起保日期</td>
                                            <td width="120" align="center" class="bg_tr" nowrap>交强起保日期</td>
                                            <td width="120" align="center" class="bg_tr" nowrap>出单日期</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>共计签单</td>
                                            <td width="130" align="center" class="bg_tr" nowrap>业务员</td>
                                            <td width="50" align="center" class="bg_tr" nowrap>状态</td>
                                            <td width="50" align="center" class="bg_tr" nowrap>操作</td>
                                        </tr>
                                        <?php
                                        $order_items = $car_info->getOrders()->orderBy('print_date DESC, id DESC')->all();
                                        foreach($order_items as $index => $item) {
                                            ?>
                                            <tr>
                                                <td align="center" class="td_bg"nowrap ><?=$index+1?></td>
                                                <td class="td_bg" nowrap><?=$item->id_man?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->insurer1_begin_date?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->insurer2_begin_date?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->print_date?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->total_all?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->user?$item->user->getShowName():''?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->status?$item->status->name:''?></td>
                                                <td align="center" class="td_bg" nowrap>[<a href="/insurer/info?id=<?=$item->id?>" target="_blank">详情</a>]</td>
                                            </tr>
                                            <?php
                                        }
                                        ?>
                                    </table>
                                </TD>
                            </TR>
                            <tr>
                                <td align="center">
                                    <input type="button" class="ACT_btn back-btn" name="Submit3" value=" 返回 ">
                                </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" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <!-- 新的礼品开始 -->
                                    <?php if($items){ ?>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <tr>
                                            <td width="50" align="center" class="bg_tr" nowrap>礼品编号</td>
                                            <td width="150" align="center" class="bg_tr" nowrap>礼品名称</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>操作时间</td>
                                            <td width="50" align="center" class="bg_tr" nowrap>状态</td>
                                            <td width="50" align="center" class="bg_tr" nowrap>操作员</td>
                                        </tr>
                                        <?php
                                        foreach($items as $index => $item) {
                                        ?>
                                            <tr>
                                                <td align="center" class="td_bg"nowrap ><?=sprintf("%07d",$item->code)?></td>
                                                <td align="center" class="td_bg" style="word-break: break-all;"><?=$item->type->name?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->use_date?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->getStatus()?></td>
                                                <td align="center" class="td_bg" nowrap><?php
                                                    if($item->status > 0)
                                                        echo $item->user?$item->user->getShowName():'---'
                                                    ?>
                                                </td>
                                            </tr>
                                        <?php
                                        }
                                        ?>
                                    </table>
                                    <?php } ?>
                                    <!-- 新的礼品结束 -->
                                    <!-- 旧的礼品开始 -->
                                    <?php if($gift_items){ ?>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table" style="table-layout: fixed;">
                                        <tr>
                                            <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                            <td width="120" align="center" class="bg_tr" nowrap>礼品名称</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>类型</td>
                                            <td width="50%" align="center" class="bg_tr" nowrap>描述</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>分类</td>
                                            <td width="80" align="center" class="bg_tr" nowrap>添加者</td>
                                            <td width="130" align="center" class="bg_tr" nowrap>操作时间</td>
                                            <td width="50" align="center" class="bg_tr" nowrap>状态</td>
                                        </tr>
                                        <?php
                                        foreach($gift_items as $index => $item) {
                                            if(!$item->gift) continue;
                                            ?>
                                            <tr>
                                                <td align="center" class="td_bg"nowrap ><?=$index+1?></td>
                                                <td class="td_bg" style="word-break: break-all;"><?=$item->gift->name?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->gift->type->name?></td>
                                                <td class="td_bg" style="word-break: break-all;"><?=$item->gift->remark?></td>
                                                <td align="center" class="td_bg" nowrap><?=$item->strategy_id>0?'公司礼品':'自费礼品'?></td>
                                                <td class="td_bg" nowrap><?=$item->user?$item->user->getShowName():''?></td>
                                                <td align="center" class="td_bg" nowrap><?=date('Y-m-d H:i:s',$item->submit_time)?></td>
                                                <td align="center" class="td_bg" nowrap>
                                                    <?php
                                                    if($item->status == 0) echo '未出库';
                                                    if($item->status == 1) echo '已出库';
                                                    if($item->status == 2) echo '正在退换';
                                                    ?>
                                                </td>
                                            </tr>
                                            <?php
                                        }
                                        ?>
                                    </table>
                                    <?php } ?>
                                    <!-- 旧的礼品结束 -->
                                </TD>
                            </TR>
                            <tr>
                                <td align="center">
                                    <input type="button" class="ACT_btn back-btn" name="Submit3" value=" 返回 ">
                                </td>
                            </tr>
                        </TABLE>
                        <!--操作记录-->
                        <table>
                            <tbody>
                            <tr>
                                <TD height="30" align="center" class=tab-off 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" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <div id="car_history_list"></div>
                                </TD>
                            </TR>
                            <tr>
                                <td align="center">
                                    <input type="button" class="ACT_btn back-btn" name="Submit3" value=" 返回 ">
                                </td>
                            </tr>
                        </TABLE>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<script type="text/javascript" language="javascript">
    function strCall(phone) {
//        parent.frames[0].test();
        parent.drtCall(phone);
    }
    function strHook() {
        parent.drtHook();
    }
    var next_index = <?=$next_index?>;
    $(function(){
        //预约人数
        $('#pdate').blur(function(){
            var params = $("#appointmentFrm").serialize();
            $.post('/appointment/count',params,function(obj){
                if(obj.success) {
                    $('#day_count').html(obj.count);
                }
            },'json');
        });
        $('#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');
            }
        });
        //保存
        $('.save-btn').click(function(){
            var params = $('#carFrm').serialize();
            $.post('/car/save',params,function(obj){
                alert(obj.msg);
                window.location.reload();
            },'json');
        });

        //无效按钮
        $('.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) {
                        $('#appointment-save-btn').attr('disabled',true);
                        $('.save-btn').attr('disabled',true);
                        $('.invalid-btn').attr('disabled',true);
                    }
                },'json');
            }
        });
        //操作历史
        var times = '<?= time(); ?>';
        gotoPage('/car/ajax-history-index?car_id=<?=$car_info->id?>&page=1&time='+times,'car_history_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');

        //返回
        $('.back-btn').click(function(){
            <?php
            $url = '';
            if($type == 1)
                $url = '/track/first?'.$back_params;
            if($type == 2)
                $url = '/track/today?'.$back_params;
            if($type == 3)
                $url = '/track/all?'.$back_params;
            echo 'window.location.href = "'.$url.'"';
            ?>
        });
        //放弃
        $('.cancel-btn').click(function(){
//            //这里是后来需求改了，暂时注释
//            if(location == 6){
//                var url = '/track/car-cancel-e';
//            }else if(location == 3 || ptype == 3){
//                var url = '/track/car-cancel';
//            }

            var location = '<?= $car_info->location; ?>';
            var ptype = $('#appointment_list').children("table").children("tbody").children("tr").eq(1).children(".ptyp").attr('data');

            if(location == 3){
                //C库数据
                //放d
                var url = '/track/car-cancel';
            }else if(location == 6 && ptype == 5){
                var url = '/track/car-cancel-e';
            }else{
                //无效
                alert('不是目标客户，请点击无效数据按钮！');
                return false;
            }
            if(confirm('是否确认放弃?')) {
                $.post(url,{id:<?=$car_info->id?>},function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('.back-btn').click();
                    }
                },'json');
            }
        });

        //保存
        $(".baocun").click(function(){
            var params = $('#myform').serialize();
            $.post('/car/baocun',params,function(obj){
                alert(obj.msg);
            },'json');
        });

        //下一个
        $('.next-btn').click(function(){
            var params = 'index=' + next_index + '&type=<?=$type?>';
            $.get('/track/ajax-next',params,function(obj){
                if(obj.success) {
                    if(obj.car_id > 0) {
                        window.location.href = '/car/info-track?id=' + obj.car_id + '&type=<?=$type?>&next_index=<?=$next_index?>' + '&back_params=' + encodeURIComponent('<?=$back_params?>');
                    } else {
                        alert('没有记录');
                    }
                }
            },'json');
        });
    });
</script>