<!--<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>
<script type="text/javascript" language="javascript" src="/js/common.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>
    #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-color: #F5F5F5;
    }
    .active-down-bg{
        background-color: black;
    }

    .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;
    }
    .red_1{
        color:red;
    }
    .green_1{
        color:green;
    }
</style>
<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" id="new_price" 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>
    </form>
</div>
<div style="width:98%; margin: 0 auto;color:#1E5494">
    <input type="button" class="act_btn" onclick="webUploader(8,<?= $info->id ?>)" value="图片上传">
    <input type="button" class="act_btn" onclick="openImgDialog(<?= $info->id ?>,8)" value="查看图片">
</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 colspan="8" height="22" colspan="2" align="center" class="td_bg">
            <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="返回">
            <input type="button" class="ACT_btn" value="刷新" onclick="window.location.reload()">
        </td>
    </tr>
</table>
<!--对话框begin-->
<div id="dialog" style="display: none">
</div>
<!--end-->
<!-- 图片弹窗 -->
<div id="img-box" style="display: none">
</div>
<!-- end -->
<!--遮罩层 begin-->
<div class="mask-layer" style="display: none">
</div>
<!--end-->
<script src="/js/upload.js"></script>
<script type="text/javascript" language="javascript">
    maskInit();
    fixCarSave(<?=$info->status?>);
    maskLayerBodyClick();

    //返回按钮
    $('#back-btn').click(function () {
        window.location.href = "/business-order/bottom-work-list";
    });
    //刷新明细
    var frontDeskId = $('#id').val();
    if (frontDeskId > 0) {
        gotoPage('/business-order/ajax-paint-work-list?fix_id=' + frontDeskId, 'divBox');
    }

    //添加
    $(".js-insert-btn").click(function () {
        var id = $('#id').val(),
            item_id = [],
            new_car_price = 0;

        if($('.red_1').length > 0 ){
            alert('还有未完成的维修项目');
            return false;
        }

        //新车购置价
        new_car_price = $('#new_price').val();
        if(isNaN(new_car_price)){
            alert('新车购置价为纯数字');
            return false;
        }

        $('.item_id').each(function(){
            item_id.push($(this).val());
        });

        var sys_remark = $('#sys_remark').val();
        if (sys_remark == '') {
            alert('请先输入备注');
            return;
        }
        if (id > 0) {
            if (confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                params = params + '&status=9&new_car_price='+new_car_price+'&item_id='+item_id;
                $.post('/business-order/paint-work-save', params, function (obj) {
                    alert(obj.msg);
                    if (obj.success) {
                        $('#id').val(obj.fix_id);
                        $('#back-btn').click();
                    }
                }, 'json');
            }
        } else {
            alert('请先保存维修信息');
        }
    });
</script>
