<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <h3><?php echo $lang['nc_member_bonusmanage']?></h3>
            <ul class="tab-base">
                <li><a href="index.php?act=person_bonus&op=add"><span><?php echo $lang['nc_manage']?></span></a></li>
                <li><a href="index.php?act=person_bonus&op=log"><span><?php echo $lang['admin_person_bonus_log_title']?></span></a></li>
                <li><a href="javascript:void(0)" class="current"><span>活动红包</span></a></li>
            </ul>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form id="promotion_form" method="post" name="promotion_form">
        <input type="hidden" name="form_submit" value="ok" />
        <table class="table tb-type2 nobdb">
            <tbody>
                <tr>
                    <td colspan="2" class="required"><label class="validation">红包名称:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" id="type_name" name="type_name" class="txt"></td>
                </tr>

                <tr>
                    <td colspan="2" class="required"><label class="validation">红包祝福语:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" id="bonus_bless" name="type_bless" class="txt"></td>
                </tr>
                <tr>
                    <td colspan="2" class="required">
                        <label class="validation">活动红包类型:
                            <select name="send_type" id="send_type">
                                <option value="1">随机红包</option>
                                <option value="2">普通红包</option>
                            </select>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="required">
                        <label class="validation">
                            红包信息：（折扣率|金额（随机是总金额，普通红包是单个金额）| 个数 #（多种折扣率之间以#隔开）
                        </label>
                    </td>
                </tr>
                <tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <input type="text" placeholder="rate|amount|num#rate|amount|num" name="bonus_rate" class="txt">
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="required">
                        <label class="validation">红包使用有效期:&nbsp;&nbsp;<input type="number" placeholder="请输入红包使用有效期" name="usable_days">&nbsp;&nbsp;天</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <label class="validation">活动开始时间:(2017-03-01 10:00:00)</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <input type="text" placeholder="2017-03-01 10:00:00" name="start_time" class="txt">
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <label class="validation">活动结束时间:(2017-03-02 10:00:00)</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <input type="text" placeholder="2017-03-02 10:00:00" name="end_time" class="txt">
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <label class="validation">红包份数:</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <input type="text" placeholder="1" name="copies" class="txt">
                    </td>
                </tr>
            </tbody>

            <tfoot>
                <tr>
                    <td colspan="2" ><a href="JavaScript:void(0);" class="btn" id="promotion_submit"><span><?php echo $lang['nc_submit'];?></span></a></td>
                </tr>
            </tfoot>
            <?php
            if(!empty($output['type_sn']))
            {
                echo '<tr><td><label>生成的红包序列号:'. $output['type_sn'] . '</label></td></tr>';
                echo '<tr class="noborder"><td class="vatop rowform"><label>'.$output['bonus_url'] .'</label></td></tr>';
                
            }
            ?>

        </table>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        var validate = function(form)
        {
                var validate_pass=false;
                var subInput=$(form).find('input');
                for(var i=0;i<subInput.length;i++) {
                    if(subInput.eq(i).val() == "") {
                        (function(j){
                            subInput.eq(i).focus();
                            alert(subInput.eq(i).attr('name')+'不能为空！');
                        })(i);
                        validate_pass=false;
                     break;
                    }
                    else {
                        validate_pass=true;
                    }
                }
            if(validate_pass) {
                return true;
            }
        };

        $('#promotion_submit').on('click',function()
        {
            $('#promotion_form').submit();

//            if(validate('#promotion_form'))
//            {
//                if(!confirm('确定提交？')) {
//                    return;
//                }
//                else {
//                    $('#promotion_form').submit();
//                }
//            }
        });
    });

</script>

