<link rel="stylesheet" href="/css/fix_car.css">
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <h3 onclick="show('list1')">维修信息<span id="list1_title">▼</span></h3>
</div>
<div id="list1">
    <form id="theFrm">
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
            <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"><span style="color:#ff0000">*</span> 新车购置价</td>
                <td height="25" class="td_bg">
                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                </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="0">---请选择---</option>
                        <?php
                        foreach ($brand_items as $item) {
                            echo '<option value="' . $item->id . '"';
                            if ($info->brand_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="series_id" id="series_id">
                        <option value="0">---请选择---</option>
                        <?php
                        foreach ($series_items as $item) {
                            echo '<option value="' . $item->id . '"';
                            if ($info->series_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="displacement_id" id="displacement_id">
                        <option value="0">---请选择---</option>
                        <?php
                        foreach ($displacement_items as $item) {
                            echo '<option value="' . $item->id . '"';
                            if ($info->displacement_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">
                    <input type="text" name="car_year" onclick="WdatePicker({dateFmt:'yyyy'})" value="<?= $info->car_year ?>">
                </td>
            </tr>
            <tr>
                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                <td height="25" class="td_bg" colspan="7">
                    <input name="finish_date" type="text" id="finish_date" value="<?= $info->finish_date ?>"
                           style="width:100px;" readonly onClick="WdatePicker()"/>
                </td>
            </tr>
            <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>
        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
               style="table-layout: fixed;">
            <tr>
                <td class="td_bg">
                    <input type="file" id="fileUploadBtn" value="上传图片"><span style="color:#ff0000">1M/每张 | 最多上传6张</span>
                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                </td>
            </tr>

            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>" class="td_bg">
                <td class="td_bg">
                    <ul id="img-area">
                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=12')->all()): ?>
                            <?php foreach ($fixCarImg as $img): ?>
                                <li>
                                    <i data-fix-img="<?= $img->id ?>" onclick="rmImg(event,$(this))">删除</i>
                                    <img src="\<?= $img->name ?>" alt="">
                                </li>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </ul>
                </td>
            </tr>
            <tr>
                <td height="22" align="center" class="td_bg">
                    <textarea name="result" id="result" cols="30" rows="10" style="display: none"></textarea>
<!--                    <input type="button" class="ACT_btn js-insert-btn" value="提交">-->
                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                </td>
            </tr>
        </table>
    </form>
</div>
<div style="width:98%; margin: 0 auto;color:#1E5494" class="add-title">
    <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
</div>
<div id="list3">
</div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494" class="add-title">
    <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
</div>
<div id="list4">
</div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494" class="add-title">
    <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
</div>
<div id="list5">
</div>
<div style="clear: both"></div>
<div style="width:98%; margin: 0 auto;color:#1E5494" class="add-title">
    <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
</div>
<div id="list6">
</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;">
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
        <tr>
            <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
            <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
            <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
            <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
        </tr>
        <?php
        foreach ($log_items as $item) {
            ?>
            <tr>
                <td align="center" class="td_bg" nowrap><?= $item->op_man ?></td>
                <td class="td_bg" style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                <td class="td_bg" nowrap><?= $item->info ?></td>
                <td class="td_bg" style="word-break: break-all"><?= $item->remark ?></td>
            </tr>
            <?php
        }
        ?>
    </table>
</div>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
            <input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
        </td>
    </tr>
</table>
<!--对话框begin-->
<div id="dialog" style="display: none">
</div>
<!--end-->
<!--遮罩层 begin-->
<div class="mask-layer" style="display: none">
</div>
<!--end-->
<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/common.js"></script>
<script type="text/javascript" language="javascript">
    var fileCollect = []; //图片上传base64集合
    var role = '<?= $role ?>';
    uploadInit();
    maskInit();
    fixCarSave(<?=$info->status?>);
    fixCarAdd('备注',<?= $info->status +1 ?>);
    maskLayerBodyClick();

    //返回按钮
    $('#back-btn').click(function () {
        window.location.href = "/business-order/facial-list";
    });
    //打印接车单
    $('#print-btn').click(function () {
        window.open('/fix-car/print-receive?id=<?=$info->id?>');
    });
    //刷新明细
    reloadItems();

    $('#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');
        }
    });
    //图片点击加边框
    $('#img-area > li').on('click', function () {
        $(this).addClass('active-border');
        $(this).siblings().removeClass('active-border');
    });
</script>
