<!--<link rel="stylesheet" href="/css/fix_car.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>
<link rel="stylesheet" href="/js/webuploader/webuploader.css">
<link rel="stylesheet" href="/css/style.css">
<script src="/js/webuploader/webuploader.js"></script>
<style>
    #dialog {
        position: fixed;
        left: 26%;
        top: 10%;
        background: #FFFFFF;
        border: 1px solid #333333;
        padding: 10px;
        width: 500px;
        z-index: 1000;
    }
    #img-box {
        position: fixed;
        left: 0%;
        top: 0%;
        background: #FFFFFF;
        border: 1px solid #333333;
        padding: 10px;
        width: 90%;
        height: 80%;
        z-index: 1000;
        overflow-y: scroll;
    }

    #img-box ul li {
        list-style: none;
        float: left;
        padding: 10px;
    }

    #img-box ul li, #img-box ul li img {
        width: 200px;
        height: 100px;
    }

    #img-box ul li i {
        position: absolute;
        cursor: pointer;
    }

    .active-bg {
        background: #F5F5F5;
    }

    .mask-layer {
        position: absolute;
        top: 0px;
        filter: alpha(opacity=60);
        background-color: #777;
        z-index: 10;
        left: 0px;
        opacity: 0.5;
        -moz-opacity: 0.5;
        width: 100%;
        height: 3000px;
    }

    .add-title > h3 {
        float: left;
        cursor: pointer;
    }
</style>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <h3 onclick="show('list1')">维修信息<span id="list1_title">▲</span></h3>
</div>
<form id="theFrm">
<input type="hidden" id="id" name="id" value="<?= $info->id ?>">
<input type="hidden" name="car_id" value="<?= $info->car_id ?>">
<div id="list1" style="display: none">
        <!--    车辆信息begin    -->
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    车牌号
                </td>
                <td height="25" class="td_bg" nowrap>
                    <input name="car_no" type="text" id="car_no"
                           value="<?= $info->car_no ?>"
                           style="width:100px;"/>
                </td>
                <td width="100" height="25" class="bg_tr">发动机号</td>
                <td height="25" class="td_bg">
                    <input name="engine_no" type="text" id="engine_no"
                           value="<?= $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" id="car_frame_no"
                           value="<?= $info->car_frame_no ?>" style="width:100px;"/>
                </td>
                <td width="100" height="25" class="bg_tr">新车购置价</td>
                <td height="25" class="td_bg">
                    <input name="new_price" type="text" id="new_price"
                           value="<?= $info->new_price ?>" style="width:100px;"/>
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    品牌
                </td>
                <td height="25" class="td_bg">
                    <select id="brand_id" name="brand_id">
                        <option value="">---请选择---</option>
                        <?php foreach ($brand_items as $item): ?>
                            <option value="<?= $item->id ?>" <?= $info->brand_id == $item->id ? 'selected' : '' ?>><?= $item->name ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>车系
                </td>
                <td height="25" class="td_bg">
                    <select name="series_id" id="series_id">
                        <option value="">---请选择---</option>
                        <?php foreach ($series_items as $item): ?>
                            <option value="<?= $item->id ?>" <?= $info->series_id == $item->id ? 'selected' : '' ?>><?= $item->name ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">排量</td>
                <td height="25" class="td_bg">
                    <select name="displacement_id" id="displacement_id">
                        <option value="">---请选择---</option>
                        <?php foreach ($displacement_items as $item): ?>
                            <option value="<?= $item->id ?>" <?= $info->displacement_id == $item->id ? 'selected' : '' ?>><?= $item->name ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">年份</td>
                <td height="25" class="td_bg">
                    <input type="text" id="car_year" name="car_year"
                           onclick="WdatePicker({dateFmt:'yyyy'})" readonly
                           value="<?= $info->car_year ?>" style="width:100px;">
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    联系人
                </td>
                <td height="25" class="td_bg">
                    <input name="link_man" type="text" id="company"
                           value="<?= $info->link_man ?>"
                           style="width:100px;"/>
                </td>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    电话
                </td>
                <td height="25" class="td_bg" colspan="5">
                    <input type="text" name="link_phone" value="<?= $info->link_phone ?>">
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr">
                    被保险人
                </td>
                <td height="25" class="td_bg">
                    <input name="id_man" type="text" id="company"
                           value="<?= $info->id_man ?>"
                           style="width:100px;"/>
                </td>
                <td width="100" height="25" class="bg_tr">
                    电话
                </td>
                <td height="25" class="td_bg">
                    <input type="text" name="id_phone" value="<?= $info->id_phone ?>">
                </td>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    事故类型
                </td>
                <td height="25" class="td_bg">
                    <select name="accident_type" id="accident_type">
                        <option value="单方" <?= "单方" === $info->accident_type ? 'selected' : '' ?>>单方</option>
                        <option value="双方" <?= "双方" === $info->accident_type ? 'selected' : '' ?>>双方</option>
                        <option value="多方" <?= "多方" === $info->accident_type ? 'selected' : '' ?>>多方</option>
                        <option value="自费维修" <?= "自费维修" === $info->accident_type ? 'selected' : '' ?>>自费维修</option>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">
                    责任
                </td>
                <td height="25" class="td_bg">
                    <select name="responsibility" id="responsibility">
                        <option value="全责" <?= "全责" === $info->responsibility ? 'selected' : '' ?>>全责</option>
                        <option value="无责" <?= "无责" === $info->responsibility ? 'selected' : '' ?>>无责</option>
                        <option value="主要责任" <?= "主要责任" === $info->responsibility ? 'selected' : '' ?>>主要责任</option>
                        <option value="次要责任" <?= "次要责任" === $info->responsibility ? 'selected' : '' ?>>次要责任</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr">
                    保险公司
                </td>
                <td height="25" class="td_bg">
                    <select name="company" id="company">
                        <option value="1" <?= '1' === $info->company ? 'selected' : '' ?>>人保</option>
                        <option value="2" <?= '2' === $info->company ? 'selected' : '' ?>>平安</option>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">
                    商业保单号
                </td>
                <td height="25" class="td_bg">
                    <input type="text" name="insurer1_no" value="<?= $info->insurer1_no ?>">
                </td>
                <td width="100" height="25" class="bg_tr">
                    交强保单号
                </td>
                <td height="25" class="td_bg">
                    <input type="text" name="insurer2_no" value="<?= $info->insurer2_no ?>">
                </td>
                <td width="100" height="25" class="bg_tr">
                    险项
                </td>
                <td height="25" class="td_bg">
                    <input type="text" name="insurer_type" value="<?= $info->insurer_type ?>">
                </td>
            </tr>
        </table>
        <!--    end    -->
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    接车日期
                </td>
                <td height="25" class="td_bg">
                    <input name="receive_date" type="text" id="receive_date"
                           value="<?= $info->receive_date ?>" readonly
                           onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:ii'})"/>
                </td>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    交车方式
                </td>
                <td height="25" class="td_bg">
                    <select name="receive_type" id="receive_type">
                        <option value="">--请选择--</option>
                        <option value="上门接车" <?= $info->receive_type === '上门接车' ? 'selected' : '' ?>>上门接车</option>
                        <option value="客户自送" <?= $info->receive_type === '客户自送' ? 'selected' : '' ?>>客户自送</option>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">代步车</td>
                <td height="25" class="td_bg">
                    <select name="replace_car_id">
                        <option value="0">--请选择--</option>
                        <option value="1" <?= 1 === $info->replace_car_id ? 'selected' : '' ?>>不需要</option>
                        <option value="2" <?= 2 === $info->replace_car_id ? 'selected' : '' ?>>京A74110</option>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">接车司机</td>
                <td height="25" class="td_bg">
                    <select name="driver_id">
                        <option value="0">请选择</option>
                        <?php
                        foreach ($driver_items as $item) {
                            echo '<option value="' . $item->id . '"';
                            if ($item->id == $info->driver_id)
                                echo ' selected ';
                            echo '>' . $item->getShowName() . '</option>';
                        }
                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr">方位</td>
                <td height="25" class="td_bg">
                    <select name="direction_id" id="direction_id">
                        <option value="0">请选择</option>
                        <?php foreach ($direction_items as $item): ?>
                            <option value="<?= $item->id ?>" <?= $info->direction_id == $item->id ? 'selected' : '' ?>><?= $item->name ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr">范围</td>
                <td height="25" class="td_bg">
                    <select name="range_id" id="range_id">
                        <option value="0">请选择</option>
                        <?php foreach ($range_items as $item): ?>
                            <option value="<?= $item->id ?>" <?= $info->range_id == $item->id ? 'selected' : '' ?>><?= $item->name ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
                <td width="100" height="25" class="bg_tr"><span
                            style="color:#ff0000">*</span>
                    地址
                </td>
                <td colspan="3" height="25" class="td_bg">
                    <input name="address" type="text" id="address"
                           value="<?= $info->address ?>"
                           style="width:80%;"/>
                </td>
            </tr>
        </table>
</div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <h3 onclick="show('list2')">司机接车<span id="list2_title">▲</span></h3>
</div>
<div id="list2" style="display: none">
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
           style="table-layout: fixed;">
        <tr>
            <td rowspan="2" class="bg_tr" align="center" valign="center">
                交接物品
            </td>
            <td width="50" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>行驶本
            </td>
            <td class="td_bg">
                <input type="radio" name="driving_this" value="1" <?= $info->driving_this === 1 ? 'checked' : '' ?>>
                原件
                <input type="radio" name="driving_this" value="2" <?= $info->driving_this === 2 ? 'checked' : '' ?>>
                复印件
            </td>
            <td width="200" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>驾驶本
            </td>
            <td class="td_bg">
                <input type="radio" name="driver_licesne"
                       value="1" <?= $info->driver_licesne === 1 ? 'checked' : '' ?>>
                原件
                <input type="radio" name="driver_licesne"
                       value="2" <?= $info->driver_licesne === 2 ? 'checked' : '' ?>>
                复印件
            </td>
            <td width="80" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>身份证
            </td>
            <td class="td_bg">
                <input type="radio" name="identity_card_paper"
                       value="1" <?= $info->identity_card_paper === 1 ? 'checked' : '' ?>> 原件
                <input type="radio" name="identity_card_paper"
                       value="2" <?= $info->identity_card_paper === 2 ? 'checked' : '' ?>> 复印件
            </td>
        </tr>
        <tr>
            <td width="50" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>车钥匙
            </td>
            <td class="td_bg">
                <input type="radio" name="car_key" value="1" <?= $info->car_key === 1 ? 'checked' : '' ?>> 一副
                <input type="radio" name="car_key" value="2" <?= $info->car_key === 2 ? 'checked' : '' ?>> 二副
            </td>
            <td width="200" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>保险单
            </td>
            <td class="td_bg">
                <input type="radio" name="policy_of_insurance"
                       value="1" <?= $info->policy_of_insurance === 1 ? 'checked' : '' ?>> 原件
                <input type="radio" name="policy_of_insurance"
                       value="2" <?= $info->policy_of_insurance === 2 ? 'checked' : '' ?>> 复印件
            </td>
            <td width="80" align="center" class="bg_tr" nowrap><span
                        style="color:#ff0000">*</span>交警证明
            </td>
            <td class="td_bg">
                <input type="radio" name="police_to_prove"
                       value="1" <?= $info->police_to_prove === 1 ? 'checked' : '' ?>> 原件
                <input type="radio" name="police_to_prove"
                       value="2" <?= $info->police_to_prove === 2 ? 'checked' : '' ?>> 复印件
            </td>
        </tr>
        <tr>
            <td class="bg_tr" align="center" valign="center">随车物品</td>
            <td class="td_bg" colspan="6">
                <input type="checkbox" name="follow_car_items[]"
                       value="1" <?= strpos($info->follow_car_items, '1') !== false ? 'checked' : '' ?>> 备胎
                <input type="checkbox" name="follow_car_items[]"
                       value="2" <?= strpos($info->follow_car_items, '2') !== false ? 'checked' : '' ?>> 工具
                <input type="checkbox" name="follow_car_items[]"
                       value="3" <?= strpos($info->follow_car_items, '3') !== false ? 'checked' : '' ?>> 警告牌
                <input type="checkbox" name="follow_car_items[]"
                       value="4" <?= strpos($info->follow_car_items, '4') !== false ? 'checked' : '' ?>> 灭火器
            </td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
           style="table-layout: fixed;">
        <tr>
            <td width="100" height="25" class="bg_tr"><span
                        style="color:#ff0000">*</span>接车里程数
            </td>
            <td height="25" class="td_bg">
                <input type="text" id="receive_mileage" name="receive_mileage"
                       value="<?= $info->receive_mileage ?>">
            </td>
            <td width="100" height="25" class="bg_tr"><span
                        style="color:#ff0000">*</span>接车油表数
            </td>
            <td height="25" class="td_bg">
                <select name="receive_oil" id="receive_oil">
                    <option value="">--请选择--</option>
                    <option value="1/2" <?= '1/2' === $info->receive_oil ? 'selected' : '' ?>>1/2</option>
                    <option value="2/2" <?= '2/2' === $info->receive_oil ? 'selected' : '' ?>>2/2</option>
                    <option value="1/3" <?= '1/3' === $info->receive_oil ? 'selected' : '' ?>>1/3</option>
                    <option value="2/3" <?= '2/3' === $info->receive_oil ? 'selected' : '' ?>>2/3</option>
                    <option value="3/3" <?= '3/3' === $info->receive_oil ? 'selected' : '' ?>>3/3</option>
                </select>
            </td>
            <td width="100" height="25" class="bg_tr">预计出厂时间</td>
            <td height="25" class="td_bg" colspan="3">
                <input type="text" id="finish_date" name="finish_date" value="<?= $info->finish_date ?>"
                       onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="bg_tr"><span
                        style="color:#ff0000">*</span>进厂里程数
            </td>
            <td height="25" class="td_bg">
                <input type="text" id="factory_mileage" name="factory_mileage"
                       value="<?= $info->factory_mileage ?>">
            </td>
            <td width="100" height="25" class="bg_tr"><span
                        style="color:#ff0000">*</span>进厂油表数
            </td>
            <td height="25" class="td_bg" colspan="5">
                <select name="factory_oil" id="factory_oil">
                    <option value="">--请选择--</option>
                    <option value="1/2" <?= '1/2' === $info->factory_oil ? 'selected' : '' ?>>1/2</option>
                    <option value="2/2" <?= '2/2' === $info->factory_oil ? 'selected' : '' ?>>2/2</option>
                    <option value="1/3" <?= '1/3' === $info->factory_oil ? 'selected' : '' ?>>1/3</option>
                    <option value="2/3" <?= '2/3' === $info->factory_oil ? 'selected' : '' ?>>2/3</option>
                    <option value="3/3" <?= '3/3' === $info->factory_oil ? 'selected' : '' ?>>3/3</option>
                </select>
            </td>
        </tr>
    </table>
</div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <h3 onclick="show('list3')">查勘定损<span id="list3_title">▼</span></h3>
</div>
<div id="list3">
    <div style="width:98%; margin: 0 auto;color:#1E5494">
        <input type="button" class="ACT_btn" value="添加报案号" onclick="appendReport()">
        <input type="button" class="ACT_btn" value="删除" onclick="removeReport()">
    </div>
    <div id="report_no">
    <?php if (!empty($reports)): ?>
        <?php foreach ($reports as $report): ?>
            <input type="hidden" name="report_id[]" value="<?= $report->id ?>">
            <table id="cloneByTab" width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                   class="table"
                   style="table-layout: fixed;">
                <tr>
                    <td rowspan="5" width="20" class="td_bg">
                        <input type="checkbox" class="js-report-checkbox" value="<?= $report->id ?>"></td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>报案号</td>
                    <td height="25" class="td_bg">
                        <input class="clone-by" name="report_no[]" type="text" value="<?= $report->report_no ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>报案人</td>
                    <td height="25" class="td_bg">
                        <input id="baoan_man" class="clone-by" name="baoan_man[]" type="text" value="<?= $report->baoan_man ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>报案时间</td>
                    <td height="25" class="td_bg">
                        <input id="baoan_time" class="clone-by" name="baoan_time[]" type="text" value="<?= $report->baoan_time ?>"
                               onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>出险时间</td>
                    <td height="25" class="td_bg">
                        <input id="chuxian_time" class="clone-by" name="chuxian_time[]" type="text" value="<?= $report->chuxian_time ?>"
                               onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
                    </td>
                </tr>
                <tr>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>出险地点</td>
                    <td height="25" class="td_bg" colspan="3">
                        <input id="baoan_address" class="clone-by" name="baoan_address[]" type="text" value="<?= $report->baoan_address ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>事故描述</td>
                    <td height="25" class="td_bg" colspan="3">
                        <input id="shigu_info" class="clone-by" name="shigu_info[]" type="text" value="<?= $report->shigu_info ?>">
                    </td>
                </tr>
               <tr>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>理赔公司</td>
                    <td height="25" class="td_bg">
                        <select name="lipei_company[]" id="lipei_company">
                            <?php if($insurer_companies): ?>
                                <?php foreach($insurer_companies as $insurer_company): ?>
                                    <option value="<?= $insurer_company->id ?>"><?= $insurer_company->name ?></option>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </select>
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>定损工时费</td>
                    <td height="25" class="td_bg">
                        <input id="dingsun_hour_money" class="clone-by" name="dingsun_hour_money[]" type="text" oninput="setDingSunMoney($(this))" value="<?= $report->dingsun_hour_money ?>" oninput="setDingSunMoney($(this))">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>定损换件费</td>
                    <td height="25" class="td_bg">
                        <input id="dingsun_huanjian_money" class="clone-by" name="dingsun_huanjian_money[]" type="text" oninput="setDingSunMoney($(this))" value="<?= $report->dingsun_huanjian_money ?>" oninput="setDingSunMoney($(this))">
                    </td>
                     <td width="100" height="25" class="bg_tr"><span
                                 style="color:#ff0000">*</span>赔付比例</td>
                    <td height="25" class="td_bg">
                        <input id="peifu_bili" class="clone-by" name="peifu_bili[]" type="hu" oninput="setDingSunMoney($(this))" value="<?= $report->peifu_bili ?>" oninput="setDingSunMoney($(this))">
                    </td>
                </tr>
                <tr>
                     <td width="100" height="25" class="bg_tr"><span
                                 style="color:#ff0000">*</span>车主定损金额</td>
                    <td height="25" class="td_bg">
                        <input id="zhuche_money" class="clone-by" name="zhuche_money[]" type="text" readonly value="<?= $report->zhuche_money ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>赔付金额</td>
                    <td height="25" class="td_bg">
                        <input id="peifu_money" class="clone-by" name="peifu_money[]" type="text" readonly value="<?= $report->peifu_money ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>客户自付</td>
                    <td height="25" class="td_bg" colspan="3">
                        <input id="kehu_money" class="clone-by" name="kehu_money[]" type="text" readonly value="<?= $report->kehu_money ?>">
                    </td>
                </tr>
                <tr>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>拖车</td>
                    <td height="25" class="td_bg">
                        <select name="tuoche[]" id="tuoche">
                            <?php if($tuoche): ?>
                                <?php foreach($tuoche as $val): ?>
                                    <option value="<?= $val->id ?>" <?= $report->tuoche === $val->id ? 'selected' : '' ?>><?= $val->name ?></option>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </select>
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>拖车费用</td>
                    <td height="25" class="td_bg">
                        <input id="tuoche_money" class="clone-by" name="tuoche_money[]" type="text" value="<?= $report->tuoche_money ?>">
                    </td>
                     <td width="100" height="25" class="bg_tr"><span
                                 style="color:#ff0000">*</span>三者外修</td>
                    <td height="25" class="td_bg">
                        <input id="sanzhe_money" class="clone-by" name="sanzhe_money[]" type="text" value="<?= $report->sanzhe_money ?>">
                    </td>
                    <td width="100" height="25" class="bg_tr"><span
                                style="color:#ff0000">*</span>物损</td>
                    <td height="25" class="td_bg">
                        <input id="wusun_money" class="clone-by" name="wusun_money[]" type="text" value="<?= $report->wusun_money ?>">
                    </td>
                </tr>
            </table>
        <?php endforeach; ?>
    <?php else: ?>
        <table id="cloneByTab" width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
               class="table"
               style="table-layout: fixed;">
    <tr>
         <td rowspan="5" width="20" class="td_bg"><input type="checkbox" class="js-report-checkbox"></td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>报案号</td>
        <td height="25" class="td_bg">
            <input id="report_no" class="clone-by" name="report_no[]" type="text">
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>报案人</td>
        <td height="25" class="td_bg">
            <input id="baoan_man" class="clone-by" name="baoan_man[]" type="text">
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>报案时间</td>
        <td height="25" class="td_bg">
            <input id="baoan_time" class="clone-by" name="baoan_time[]" type="text"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>出险时间</td>
        <td height="25" class="td_bg">
            <input id="chuxian_time" class="clone-by" name="chuxian_time[]" type="text"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
        </td>
    </tr>
    <tr>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>出险地点</td>
        <td height="25" class="td_bg" colspan="3">
            <input id="baoan_address" class="clone-by" name="baoan_address[]" type="text"
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>事故描述</td>
        <td height="25" class="td_bg" colspan="3">
            <input id="shigu_info" class="clone-by" name="shigu_info[]" type="text"
        </td>
    </tr>
    <tr>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>理赔公司</td>
        <td height="25" class="td_bg">
            <select name="lipei_company[]" id="lipei_company">
                <?php if($insurer_companies): ?>
                    <option value="">--请选择--</option>
                    <?php foreach($insurer_companies as $insurer_company): ?>
                        <option value="<?= $insurer_company->name ?>"><?= $insurer_company->name ?></option>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>定损工时费</td>
        <td height="25" class="td_bg">
            <input id="dingsun_hour_money" class="clone-by" name="dingsun_hour_money[]" type="text" oninput="setDingSunMoney($(this))">
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>定损换件费</td>
        <td height="25" class="td_bg">
            <input id="dingsun_huanjian_money" class="clone-by" name="dingsun_huanjian_money[]" type="text" oninput="setDingSunMoney($(this))">
        </td>
         <td width="100" height="25" class="bg_tr"><span
                     style="color:#ff0000">*</span>赔付比例</td>
        <td height="25" class="td_bg">
            <input id="peifu_bili" class="clone-by" name="peifu_bili[]" type="hu" oninput="setDingSunMoney($(this))">
        </td>
    </tr>
    <tr>
         <td width="100" height="25" class="bg_tr"><span
                     style="color:#ff0000">*</span>车主定损金额</td>
        <td height="25" class="td_bg">
            <input id="zhuche_money" class="clone-by" name="zhuche_money[]" type="text" readonly>
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>赔付金额</td>
        <td height="25" class="td_bg">
            <input id="peifu_money" class="clone-by" name="peifu_money[]" type="text" readonly>
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>客户自付</td>
        <td height="25" class="td_bg" colspan="3">
            <input id="kehu_money" class="clone-by" name="kehu_money[]" type="text" readonly>
        </td>
    </tr>
    <tr>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>拖车</td>
        <td height="25" class="td_bg">
              <select name="tuoche[]" id="tuoche">
                <?php if($tuoche): ?>
                    <?php foreach($tuoche as $val): ?>
                        <option value="<?= $val->id ?>"><?= $val->name ?></option>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>拖车费用</td>
        <td height="25" class="td_bg">
            <input id="tuoche_money" class="clone-by" name="tuoche_money[]" type="text">
        </td>
         <td width="100" height="25" class="bg_tr"><span
                     style="color:#ff0000">*</span>三者外修</td>
        <td height="25" class="td_bg">
            <input id="sanzhe_money" class="clone-by" name="sanzhe_money[]" type="text">
        </td>
        <td width="100" height="25" class="bg_tr"><span
                    style="color:#ff0000">*</span>物损</td>
        <td height="25" class="td_bg">
            <input id="wusun_money" class="clone-by" name="wusun_money[]" type="text">
        </td>
    </tr>
</table>
    <?php endif; ?>
    </div>
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
           style="table-layout: fixed;">
        <tr>
            <td width="100" height="25" class="bg_tr">备注</td>
            <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="sys_remark" id="sys_remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
            </td>
        </tr>
    </table>
</div>
</form>
<div style="clear: both"></div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <input type="button" class="act_btn" onclick="webUploader(4,<?= $info->id ?>)" value="图片上传">
    <input type="button" class="act_btn" onclick="openImgDialog(<?= $info->id ?>,4)" value="查看图片">
    <input type="button" class="ACT_btn" value="清单添加" onclick="location.href='/store-room/get-tree?car_price=<?= $info->new_price ?>&id=<?= $info->id ?>'">
</div>
<div id="web-up"></div>
<div style="clear: both"></div>
<div id="divBox"></div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
</div>
<div id="list7" style="display: none;">
    <?= $this->render('logs-view',['log_items'=>$log_items]) ?>
</div>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td height="22" align="center" class="td_bg">
            <textarea name="result" id="result" cols="30" rows="10" style="display: none"></textarea>
            <?php if (4 === $info->status): ?>
                <input type="button" class="ACT_btn js-insert-btn" value="提交">
                <input type="button" class="ACT_btn js-update-btn" value="保存">
            <?php endif; ?>
            <input id="back-btn" type="button" class="ACT_btn" value="返回">
        </td>
    </tr>
</table>
<!--对话框begin-->
<div id="dialog" style="display: none">
</div>
<!--end-->
<!--遮罩层 begin-->
<div class="mask-layer" style="display: none">
</div>
<!--end-->
<!-- 图片弹窗 -->
<div id="img-box" style="display: none">
</div>
<!-- end -->
<script src="/js/upload.js"></script>
<script type="text/javascript" language="javascript" src="/js/common.js"></script>
<script type="text/javascript" language="javascript">
    maskInit();
    maskLayerBodyClick();
    //保存按钮
    $(".js-update-btn").click(function () {
        if (confirm('是否确认提交?')) {
            var params = $("#theFrm").serialize();
            params += '&status=' + '<?= $info->status ?>';
            $.post('/business-order/setting-loss-exploration-add', params, function (obj) {
                alert(obj.msg);
                if (obj.success) {
                    $('#id').val(obj.fix_id);
                    window.location.reload();
                }
            }, 'json');
        }
    });
    //添加按钮
    $(".js-insert-btn").click(function () {
        var id = $('#id').val();
        var sys_remark = $('#sys_remark').val();
        if (sys_remark == '') {
            alert('请先输入备注');
            return;
        }
        if (id > 0) {
            if (confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                params = params + '&status=' + '<?= $info->status + 1 ?>';
                $.post('/business-order/setting-loss-exploration-add', params, function (obj) {
                    alert(obj.msg);
                    if (obj.success) {
                        $('#id').val(obj.fix_id);
                        $('#back-btn').click();
                    }
                }, 'json');
            }
        } else {
            alert('请先保存维修信息');
        }
    });
    //返回按钮
    $('#back-btn').click(function () {
        window.location.href = "/business-order/setting-loss-exploration-list";
    });
    //打印接车单
    $('#print-btn').click(function () {
        window.open('/fix-car/print-receive?id=<?=$info->id?>');
    });
    //追加报案号
    function appendReport() {
        var $clone = $('#cloneByTab').clone();
        $clone.find('.js-report-checkbox').val('-1');
        $clone.find('.clone-by').val('');
        $('#report_no').append($clone);
    }

    //报案号删除
    function removeReport() {
        var $boxes = $('.js-report-checkbox:checked'), $remArr = [];
        if ($boxes.length <= 0) {
            alert('删除失败!');
            return false;
        }

        if (!confirm('确定要删除吗？')) return false;

        $boxes.each(function (i) {
            if ('-1' == $(this).val()) {
                $(this).parents('table').remove();
            } else {
                $(this).parents('table').addClass('js-report-remove-' + $(this).val());
                $remArr.push($(this).val());
            }
        })

        if ($remArr.length > 0) {
            $.post('/business-order/remove-report', {rem_arr: $remArr}, function (data) {
                if (data.success) {
                    for (var i = 0; i < data.content.length; i++) {
                        $('.js-report-remove-' + data.content[i]).remove();
                    }
                }
            })
        }
    }

    //定损金额
    function setDingSunMoney(obj){
        var dingsun_hour_money = obj.parents('table').find('#dingsun_hour_money').val() ? obj.parents('table').find('#dingsun_hour_money').val() : 0,
            dingsun_huanjian_money = obj.parents('table').find('#dingsun_huanjian_money').val() ? obj.parents('table').find('#dingsun_huanjian_money').val() : 0,
            peifu_bili = obj.parents('table').find('#peifu_bili').val();

        if(!peifu_bili ){
            peifu_bili = 0;
        }else if(peifu_bili < 0){
            peifu_bili = 0;
            obj.parents('table').find('#peifu_bili').val(peifu_bili);
        }else if(peifu_bili > 100){
            peifu_bili = 100;
            obj.parents('table').find('#peifu_bili').val(peifu_bili);
        }
        obj.parents('table').find('#zhuche_money').val((parseFloat(dingsun_hour_money) + parseFloat(dingsun_huanjian_money)).toFixed(2));
        obj.parents('table').find('#peifu_money').val((parseFloat(peifu_bili)/100*(parseFloat(dingsun_hour_money) + parseFloat(dingsun_huanjian_money))).toFixed(2));
        obj.parents('table').find('#kehu_money').val(((parseFloat(dingsun_hour_money) + parseFloat(dingsun_huanjian_money)) - obj.parents('table').find('#peifu_money').val()).toFixed(2));
    }
    //清单列表
    refreshItemList(<?= $info->id ?>,13,'is_report');
</script>
