<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="theFrm">
        <input type="hidden" name="id" value="<?=$info->id?>">
        <tr>
            <td width="100" height="25" class="bg_tr">策略名称</td>
            <td height="25" class="td_bg">
                <input name="name" type="text" id="name" value="<?=$info->name?>" style="width:200px;"/>
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="bg_tr">描述</td>
            <td height="25" class="td_bg">
                <input name="remark" type="text" id="remark" value="<?=$info->remark?>" style="width:400px;"/>
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="bg_tr">起保金额范围</td>
            <td height="25" class="td_bg">
                最小值: <input name="min_money" type="text" id="min_money" value="<?=$info->min_money?>" style="width:50px;"/>
                最大值: <input name="max_money" type="text" id="max_money" value="<?=$info->max_money?>" style="width:50px;"/>
                （0为没有限制）
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="bg_tr">可选数量</td>
            <td height="25" class="td_bg">
                <input name="sel_count" type="text" id="sel_count" value="<?=$info->sel_count?>" style="width:50px;"/>（默认为:1）
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="bg_tr">针对范围</td>
            <td height="25" class="td_bg">
                <select name="group_id">
                    <option value="0">全部</option>
                    <?php
                    foreach($group_items as $item) {
                        echo '<option value="'.$item->id.'"';
                        if($item->id == $info->group_id)
                            echo ' selected ';
                        echo '>'.$item->name.'</option>';
                    }
                    ?>
                </select>
            </td>
        </tr>
        <?php
        foreach($gift_type_items as $gift_type_item) {
            ?>
            <tr>
                <td width="100" height="25" class="bg_tr"><?=$gift_type_item->name?></td>
                <td height="25" class="td_bg">
                    <?php
                    $gift_items = $gift_type_item->gifts;
                    foreach($gift_items as $gift_item) {
                        echo '<label>';
                        echo '<input type="checkbox" name="gift_ids[]" value="'.$gift_item->id.'"';
                        if(in_array($gift_item->id,$gift_ids))
                            echo ' checked ';
                        echo '>'.$gift_item->name;
                        echo '</label>';
                        echo '<br>';
                    }
                    ?>
                </td>
            </tr>
            <?php
        }
        ?>
    </form>
    <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>
</table>
<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" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    $(function () {
        //提交按钮
        $("#submit-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                $.post('/strategy/save',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#back-btn').click();
                    }
                },'json');
            }
        });

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