<form id="theFrm">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <?php if (isset($item_scale)): ?>
            <input type="hidden" name="id" value="<?= $item_scale->id ?>">
        <?php endif; ?>
        <tr>
            <td width="20%" height="25" class="td_bg">父级分类</td>
            <td width="80%" height="25" class="td_bg">
                <select name="pid" id="pid">
                    <option value="0">顶级分类</option>
                    <?php if (count($parents) > 0): ?>
                        <?php foreach ($parents as $parent): ?>
                            <option value="<?= $parent->id ?>" <?= isset($item_scale) ? ($parent->id === $item_scale->pid ? 'selected' : '') : '' ?>>
                                --<?= $parent->name ?></option>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </select>
            </td>
        </tr>
        <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($item_scale) ? $item_scale->name : '' ?>"
                                                             size="40"/></td>
        </tr>
        <tr>
            <td width="20%" height="25" class="td_bg">比例</td>
            <td width="80%" height="25" class="td_bg"><input name="scale" size="2" type="text" id="path"
                                                             value="<?= isset($item_scale) ? $item_scale->scale : 0 ?>"
                                                             size="40"/>%
            </td>
        </tr>
        <?php if(!isset($item_scale)): ?>
        <tr>
            <td height="22" colspan="2" 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>
        <?php endif; ?>
    </table>
    <?php if(isset($item_scale)): ?>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td class="td_bg">3万元</td><td class="td_bg"><input name="str_3" type="text" size="2" value="<?= count($middle) > 0 ? $middle[3]['work_hour'] : '' ?>"></td>
            <td class="td_bg">4万元</td><td class="td_bg"><input name="str_4" type="text" size="2" value="<?= count($middle) > 0 ? $middle[4]['work_hour'] : '' ?>"></td>
            <td class="td_bg">5万元</td><td class="td_bg"><input name="str_5" type="text" size="2" value="<?= count($middle) > 0 ? $middle[5]['work_hour'] : '' ?>"></td>
            <td class="td_bg">6万元</td><td class="td_bg"><input name="str_6" type="text" size="2" value="<?= count($middle) > 0 ? $middle[6]['work_hour'] : '' ?>"></td>
            <td class="td_bg">7万元</td><td class="td_bg"><input name="str_7" type="text" size="2" value="<?= count($middle) > 0 ? $middle[7]['work_hour'] : '' ?>"></td>
            <td class="td_bg">8万元</td><td class="td_bg"><input name="str_8" type="text" size="2" value="<?= count($middle) > 0 ? $middle[8]['work_hour'] : '' ?>"></td>
            <td class="td_bg">9万元</td><td class="td_bg"><input name="str_9" type="text" size="2" value="<?= count($middle) > 0 ? $middle[9]['work_hour'] : '' ?>"></td>
            <td class="td_bg">10万元</td><td class="td_bg"><input name="str_10" type="text" size="2" value="<?= count($middle) > 0 ? $middle[10]['work_hour'] : '' ?>"></td>
            <td class="td_bg">15万元</td><td class="td_bg"><input name="str_15" type="text" size="2" value="<?= count($middle) > 0 ? $middle[15]['work_hour'] : '' ?>"></td>
            <td class="td_bg">20万元</td><td class="td_bg"><input name="str_20" type="text" size="2" value="<?= count($middle) > 0 ? $middle[20]['work_hour'] : '' ?>"></td>
        </tr>
        <tr>
            <td class="td_bg">30万元</td><td class="td_bg"><input name="str_30" type="text" size="2" value="<?= count($middle) > 0 ? $middle[30]['work_hour'] : '' ?>"></td>
            <td class="td_bg">40万元</td><td class="td_bg"><input name="str_40" type="text" size="2" value="<?= count($middle) > 0 ? $middle[40]['work_hour'] : '' ?>"></td>
            <td class="td_bg">50万元</td><td class="td_bg"><input name="str_50" type="text" size="2" value="<?= count($middle) > 0 ? $middle[50]['work_hour'] : '' ?>"></td>
            <td class="td_bg">60万元</td><td class="td_bg"><input name="str_60" type="text" size="2" value="<?= count($middle) > 0 ? $middle[60]['work_hour'] : '' ?>"></td>
            <td class="td_bg">70万元</td><td class="td_bg"><input name="str_70" type="text" size="2" value="<?= count($middle) > 0 ? $middle[70]['work_hour'] : '' ?>"></td>
            <td class="td_bg">80万元</td><td class="td_bg"><input name="str_80" type="text" size="2" value="<?= count($middle) > 0 ? $middle[80]['work_hour'] : '' ?>"></td>
            <td class="td_bg">90万元</td><td class="td_bg"><input name="str_90" type="text" size="2" value="<?= count($middle) > 0 ? $middle[90]['work_hour'] : '' ?>"></td>
            <td class="td_bg">100万元</td><td class="td_bg"><input name="str_100" type="text" size="2" value="<?= count($middle) > 0 ? $middle[100]['work_hour'] : '' ?>"></td>
            <td class="td_bg">200万元</td><td class="td_bg"><input name="str_200" type="text" size="2" value="<?= count($middle) > 0 ? $middle[200]['work_hour'] : '' ?>"></td>
            <td class="td_bg">300万元</td><td class="td_bg"><input name="str_300" type="text" size="2" value="<?= count($middle) > 0 ? $middle[300]['work_hour'] : '' ?>"></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('/scale/info', params, function (obj) {
                    if (obj.success) {
                        $('#back-btn').click();
                    } else {
                        alert(obj.msg);
                    }
                }, 'json');
            }
        });

        //返回按钮
        $('#back-btn').click(function () {
            window.location.href = '/scale/index';
        });
    })
</script>
