<form id="theFrm">
    <?php if(isset($info)): ?>
        <input type="hidden" name="id" value="<?= $info->id ?>">
    <?php endif; ?>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td width="20%" height="25" class="td_bg">维修部位</td>
            <td width="80%" height="25" class="td_bg"><input name="name" type="text" id="name"
                                                             value="<?= isset($info) ? $info->name : '' ?>"
                                                             size="40"/></td>
        </tr>
        <?php if(!isset($info)): ?>
        <tr>
            <td height="22" colspan="2" align="center" class="td_bg">
                <input id="submit-btn-2" type=button class="ACT_btn" name=Submit1
                       value=" 提交  "/>
                &nbsp;&nbsp;
                <input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
            </td>
        </tr>
        <?php endif; ?>
    </table>
    <?php if(isset($info)): ?>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr><th align="center" colspan="20">喷漆价格</th></tr>
            <tr>
                <td class="td_bg">3万元</td><td class="td_bg"><input name="str_3" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[3]['price'] : 0 ?>">元</td>
                <td class="td_bg">4万元</td><td class="td_bg"><input name="str_4" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[4]['price'] : 0 ?>">元</td>
                <td class="td_bg">5万元</td><td class="td_bg"><input name="str_5" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[5]['price'] : 0 ?>">元</td>
                <td class="td_bg">6万元</td><td class="td_bg"><input name="str_6" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[6]['price'] : 0 ?>">元</td>
                <td class="td_bg">7万元</td><td class="td_bg"><input name="str_7" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[7]['price'] : 0 ?>">元</td>
                <td class="td_bg">8万元</td><td class="td_bg"><input name="str_8" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[8]['price'] : 0 ?>">元</td>
                <td class="td_bg">9万元</td><td class="td_bg"><input name="str_9" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[9]['price'] : 0 ?>">元</td>
                <td class="td_bg">10万元</td><td class="td_bg"><input name="str_10" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[10]['price'] : 0 ?>">元</td>
                <td class="td_bg">11万元</td><td class="td_bg"><input name="str_11" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[11]['price'] : 0 ?>">元</td>
                <td class="td_bg">12万元</td><td class="td_bg"><input name="str_12" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[12]['price'] : 0 ?>">元</td>
            </tr>
            <tr>
                <td class="td_bg">13万元</td><td class="td_bg"><input name="str_13" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[13]['price'] : 0 ?>">元</td>
                <td class="td_bg">14万元</td><td class="td_bg"><input name="str_14" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[14]['price'] : 0 ?>">元</td>
                <td class="td_bg">15万元</td><td class="td_bg"><input name="str_15" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[15]['price'] : 0 ?>">元</td>
                <td class="td_bg">16万元</td><td class="td_bg"><input name="str_16" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[16]['price'] : 0 ?>">元</td>
                <td class="td_bg">17万元</td><td class="td_bg"><input name="str_17" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[17]['price'] : 0 ?>">元</td>
                <td class="td_bg">18万元</td><td class="td_bg"><input name="str_18" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[18]['price'] : 0 ?>">元</td>
                <td class="td_bg">19万元</td><td class="td_bg"><input name="str_19" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[19]['price'] : 0 ?>">元</td>
                <td class="td_bg">20万元</td><td class="td_bg"><input name="str_20" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[20]['price'] : 0 ?>">元</td>
                <td class="td_bg">25万元</td><td class="td_bg"><input name="str_25" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[25]['price'] : 0 ?>">元</td>
                <td class="td_bg">30万元</td><td class="td_bg"><input name="str_30" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[30]['price'] : 0 ?>">元</td>
            </tr>
            <tr>
                <td class="td_bg">35万元</td><td class="td_bg"><input name="str_35" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[35]['price'] : 0 ?>">元</td>
                <td class="td_bg">40万元</td><td class="td_bg"><input name="str_40" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[40]['price'] : 0 ?>">元</td>
                <td class="td_bg">45万元</td><td class="td_bg"><input name="str_45" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[45]['price'] : 0 ?>">元</td>
                <td class="td_bg">50万元</td><td class="td_bg"><input name="str_50" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[50]['price'] : 0 ?>">元</td>
                <td class="td_bg">55万元</td><td class="td_bg"><input name="str_55" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[55]['price'] : 0 ?>">元</td>
                <td class="td_bg">60万元</td><td class="td_bg"><input name="str_60" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[60]['price'] : 0 ?>">元</td>
                <td class="td_bg">65万元</td><td class="td_bg"><input name="str_65" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[65]['price'] : 0 ?>">元</td>
                <td class="td_bg">70万元</td><td class="td_bg"><input name="str_70" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[70]['price'] : 0 ?>">元</td>
                <td class="td_bg">75万元</td><td class="td_bg"><input name="str_75" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[75]['price'] : 0 ?>">元</td>
                <td class="td_bg">80万元</td><td class="td_bg"><input name="str_80" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[80]['price'] : 0 ?>">元</td>
            </tr>
            <tr>
                <td class="td_bg">85万元</td><td class="td_bg"><input name="str_85" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[85]['price'] : 0 ?>"></td>
                <td class="td_bg">90万元</td><td class="td_bg"><input name="str_90" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[90]['price'] : 0 ?>"></td>
                <td class="td_bg">95万元</td><td class="td_bg"><input name="str_95" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[95]['price'] : 0 ?>"></td>
                <td class="td_bg">100万元</td><td class="td_bg"><input name="str_100" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[100]['price'] : 0 ?>"></td>
                <td class="td_bg">200万元</td><td class="td_bg"><input name="str_200" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[200]['price'] : 0 ?>"></td>
                <td class="td_bg">300万元</td><td class="td_bg" colspan="9"><input name="str_300" type="text" size="2" value="<?= count($paint_prices) > 0 ? $paint_prices[300]['price'] : 0 ?>"></td>
            </tr>
        </table>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr><th align="center" colspan="8">损伤程度</th></tr>
            <tr>
                <td class="td_bg">微伤</td><td class="td_bg"><input name="damage_1" type="text" size="2" value="<?= count($damage_levels) > 0 ? $damage_levels[1]['work_hour']  : 0  ?>"></td>
                <td class="td_bg">轻度</td><td class="td_bg"><input name="damage_2" type="text" size="2" value="<?= count($damage_levels) > 0 ? $damage_levels[2]['work_hour']  : 0  ?>"></td>
                <td class="td_bg">中度</td><td class="td_bg"><input name="damage_3" type="text" size="2" value="<?= count($damage_levels) > 0 ? $damage_levels[3]['work_hour']  : 0  ?>"></td>
                <td class="td_bg">重度</td><td class="td_bg"><input name="damage_4" type="text" size="2" value="<?= count($damage_levels) > 0 ? $damage_levels[4]['work_hour']  : 0  ?>"></td>
            </tr>
            <tr>
                <td height="22" colspan="20" align="center" class="td_bg">
                    <input id="submit-btn" type=button class="ACT_btn" name=Submit1
                           value=" 保存 "/>
                    &nbsp;&nbsp;
                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
                </td>
            </tr>
        </table>
    <?php endif; ?>
</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">
    $(function () {
        //提交按钮
        $("#submit-btn").click(function () {
            if (confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                $.post('/metal-plate/save', params, function (obj) {
                    if (obj.success) {
                        $('#back-btn').click();
                    } else {
                        alert(obj.msg);
                    }
                }, 'json');
            }
        });
        //提交按钮
        $("#submit-btn-2").click(function () {
            if (confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                $.post('/metal-plate/info', params, function (obj) {
                    if (obj.success) {
                        $('#back-btn').click();
                    } else {
                        alert(obj.msg);
                    }
                }, 'json');
            }
        });
        //返回按钮
        $('#back-btn').click(function () {
            window.location.href = '/metal-plate/index';
        });
    })
</script>
