<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td width="90%" height="25" class="td_bg" colspan="3">
            <select name="group_id" id="group_id" onchange="groupChange()">
                <?php if($groups): ?>
                    <?php foreach($groups as $group): ?>
                        <option value="<?= $group->id ?>" <?= isset($info) ? ($info->type === $group->id ? 'selected' :'') :'' ?>><?= $group->name ?></option>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
        </td>
    </tr>
</table>
<form id="theFrm7" class="frm">
    <?php if(isset($info)): ?>
    <?php $metals = \yii\helpers\ArrayHelper::index($info->fixCarMetals,'level_id') ?>
    <?php endif; ?>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <input type="hidden" name="id" value="<?= isset($info) ? $info->id : '' ?>">
        <tr>
            <td height="25" class="td_bg" align="right">项目名称:</td>
            <td height="25" class="td_bg" colspan="3">
                <input type="text" name="name" value="<?= isset($info) ? $info->name : '' ?>">
            </td>
        </tr>
        <tr>
            <td width="10%" height="25" class="td_bg" align="right" id="price">损伤程度:</td>
            <td height="25" class="td_bg">
                <input type="text" value=" <?= $levels[0]->name ?>">
            </td>
            <td width="10%" height="25" class="td_bg" align="right" id="price">工时:</td>
            <td height="25" class="td_bg">
                <input type="text" name="price[<?= $levels[0]->id ?>]" value="<?= isset($info) ? (7 === $info->type ? ($metals[$levels[0]->id]['price']) : '') :'' ?>">
            </td>
        </tr>
        <tr>
            <td width="10%" height="25" class="td_bg" align="right" id="price">损伤程度:</td>
            <td height="25" class="td_bg">
                <input type="text" value=" <?= $levels[1]->name ?>">
            </td>
            <td width="10%" height="25" class="td_bg" align="right" id="price">工时:</td>
            <td height="25" class="td_bg">
                <input type="text" name="price[<?= $levels[1]->id ?>]" value="<?= isset($info) ? (7 === $info->type ? ($metals[$levels[1]->id]['price']) : '') :'' ?>">
            </td>
        </tr>
        <tr>
            <td width="10%" height="25" class="td_bg" align="right" id="price">损伤程度:</td>
            <td height="25" class="td_bg">
                <input type="text" value=" <?= $levels[2]->name ?>">
            </td>
            <td width="10%" height="25" class="td_bg" align="right" id="price">工时:</td>
            <td height="25" class="td_bg">
                <input type="text" name="price[<?= $levels[2]->id ?>]" value="<?= isset($info) ? (7 === $info->type ? ($metals[$levels[2]->id]['price']) : '') :'' ?>">
            </td>
        </tr>
        <tr>
            <td width="10%" height="25" class="td_bg" align="right" id="price">损伤程度:</td>
            <td height="25" class="td_bg">
                <input type="text" value=" <?= $levels[3]->name ?>">
            </td>
            <td width="10%" height="25" class="td_bg" align="right" id="price">工时:</td>
            <td height="25" class="td_bg">
                <input type="text" name="price[<?= $levels[3]->id ?>]" value="<?= isset($info) ? (7 === $info->type ? ($metals[$levels[3]->id]['price']) : '') :'' ?>">
            </td>
        </tr>
        <tr>
            <td height="22" colspan="4" align="center" class="td_bg">
                <input type=button class="ACT_btn" name=Submit1
                       value=" 提交  " onclick="saveBtn()"/>
                &nbsp;&nbsp;
                <input type="button" class="ACT_btn back-btn" name="Submit2" value=" 返回 ">
            </td>
        </tr>
    </table>
</form>
<form id="theFrm8" class="frm" style="display: none">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <input type="hidden" name="id" value="<?= isset($info) ? $info->id : '' ?>">
        <tr>
            <td height="25" class="td_bg" align="right">项目名称:</td>
            <td height="25" class="td_bg">
                <input type="text" name="name" value="<?= isset($info) ? $info->name : '' ?>">
            </td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td class="td_bg" colspan="20" align="center">喷漆价格</td>
        </tr>
        <?php if($car_prices): ?>
            <?php foreach ($car_prices as $key=>$car_price): ?>
                <?php if(isset($info)): ?>
                    <?php $jidian = \yii\helpers\ArrayHelper::index($info->fixCarJidians,'car_price_id') ?>
                <?php endif; ?>
                <tr>
                    <?php foreach($car_price as $val): ?>
                        <td height="25" class="td_bg" align="right" id="price"><?= $val['price'] ?>万:</td>
                        <td height="25" class="td_bg">
                            <input type="text" name="price[<?= $val['price'] ?>]" size="5" value="<?= isset($info) ? (8 === $info->type ? $jidian[$val['id']]['price']: '') : '' ?>">
                        </td>
                    <?php endforeach; ?>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
    <table  width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td height="22"align="center" class="td_bg" colspan="2">
                <input type=button class="ACT_btn" name=Submit1
                       value=" 提交  " onclick="saveBtn()"/>
                &nbsp;&nbsp;
                <input type="button" class="ACT_btn back-btn" name="Submit2" value=" 返回 ">
            </td>
        </tr>
    </table>
</form>
<form id="theFrm9" class="frm" style="display: none">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <input type="hidden" name="id" value="<?= isset($info) ? $info->id : '' ?>">
        <tr>
            <td height="25" class="td_bg" align="right">项目名称:</td>
            <td height="25" class="td_bg">
                <input type="text" name="name" value="<?= isset($info) ? $info->name : '' ?>">
            </td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td class="td_bg" colspan="20" align="center">工时</td>
        </tr>
        <?php if($car_prices): ?>
            <?php $count = 0 ?>
            <?php foreach ($car_prices as $car_price): ?>
                <tr>
                    <?php foreach($car_price as $val): ?>
                        <?php if(isset($info)): ?>
                        <?php $jidian = \yii\helpers\ArrayHelper::index($info->fixCarJidians,'car_price_id') ?>
                        <?php endif; ?>
                        <td height="25" class="td_bg" align="right" id="price"><?= $val['price'] ?>万:</td>
                        <td height="25" class="td_bg">
                            <input type="text" name="price[<?= $val['id'] ?>]" size="5" value="<?= isset($info) ? (9 === $info->type ? $jidian[$val['id']]['price']: '') : '' ?>">
                        </td>
                    <?php endforeach; ?>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
    <table  width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td height="22"align="center" class="td_bg" colspan="2">
                <input type=button class="ACT_btn" name=Submit1
                       value=" 提交  " onclick="saveBtn()"/>
                &nbsp;&nbsp;
                <input type="button" class="ACT_btn back-btn" name="Submit2" value=" 返回 ">
            </td>
        </tr>
    </table>
</form>
<form id="theFrm12" class="frm" style="display: none">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <input type="hidden" name="id" value="<?= isset($info) ? $info->id : '' ?>">
        <tr>
            <td height="25" class="td_bg" align="right">项目名称:</td>
            <td height="25" class="td_bg">
                <input type="text" name="name" value="<?= isset($info) ? $info->name : '' ?>">
            </td>
            <td width="10%" height="25" class="td_bg" align="right" id="price">工时:</td>
            <td height="25" class="td_bg">
                <input type="text" name="price" value="<?= isset($info) ? (12 === $info->type ? $info->fixCarBeautifies->price : 0 ) : '' ?>">
            </td>
        </tr>
        <tr>
            <td height="22" colspan="4" align="center" class="td_bg">
                <input type=button class="ACT_btn" name=Submit1
                       value=" 提交  " onclick="saveBtn()"/>
                &nbsp;&nbsp;
                <input type="button" class="ACT_btn back-btn" name="Submit2" value=" 返回 ">
            </td>
        </tr>
    </table>
</form>

<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript">
    //返回按钮
    $('.back-btn').click(function () {
        window.location.href = '/fix-car-project/index';
    });
    groupChange();
    function groupChange(){
        var val = $('#group_id').val();
        if(val < 1) return false;
        $('.frm').hide();
        $('#theFrm'+ val).show();
    }

    function saveBtn(){
        var gid = $('#group_id').val(),param = $('#theFrm'+gid).serialize();
        if(gid < 1) return false;
        param += '&type=' + gid;
        $.post('/fix-car-project/info',param,function(data){
            alert(data.msg);
            if(data.success){
                history.go(-1);
            }
        },'json');
    }
</script>
