<?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="JavaScript:void(0);" class="current"><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="index.php?act=person_bonus&op=promotion"><span>活动红包</span></a></li>
            </ul>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form id="points_form" method="post" name="form1">
        <input type="hidden" name="form_submit" value="ok" />
        <table class="table tb-type2 nobdb">
            <tbody>
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['admin_points_membername']; ?>(搜索方式)：</label>
                    <select name="input_type" id="input_type">
                        <option value="mobiles">电话号码(会员名称)</option>
                        <option value="sql">SQL语句</option>
                    </select>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                    <textarea name="members" id="members" cols="100" rows="10" class="members"></textarea>
            </tr>
            <tr>
                <td><label>是否排除品牌方：<input type="checkbox" name="ex_brand"></label></td>
            </tr>
            <tr>
                <td><label>是否排除公司员工：<input type="checkbox" name="ex_lrlz"></label></td>
            </tr>
            <tr id="tr_memberinfo">
                <td colspan="2" style="font-weight:bold;" id="td_memberinfo"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label><?php echo $lang['admin_points_operatetype']; ?>:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><select id="operatetype" name="operatetype">
                        <option value="1"><?php echo $lang['admin_points_operatetype_add']; ?></option>
                        <option value="2"><?php echo $lang['admin_points_operatetype_reduce'];?></option>
                    </select></td>
                <td class="vatop tips"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label>红包祝福语:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" id="bonus_bless" name="bonus_bless" class="txt"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation"><?php echo $lang['admin_person_bonus_rate']; ?>:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" id="bonus_rate" name="bonus_rate" class="txt"></td>
            </tr>

            <tr>
                <td colspan="2" class="required"><label class="validation"><?php echo $lang['admin_person_bonus_amount']; ?>:</label></td>
            </tr>

            <tr class="noborder">
                <td class="vatop rowform"><input type="text" id="bonus_amount" name="bonus_amount" class="txt"></td>
            </tr>

            <tr style="background: rgb(255, 255, 255);">
                <td colspan="2" class="required"><label class="validation">短信发送:</label></td>
            </tr>
            <tr>
                <td colspan="2"><label>是否发送短息：<input type="checkbox" name="send_sms" id="send_sms" checked></label></td>
            </tr>
            <tr style="background: rgb(255, 255, 255);" class="sms_template_choose">
                <td colspan="2" class="required"><label class="validation">短信模板选择:</label></td>
            </tr>
            <tr class="sms_template_choose">
                <td>
                    <select name="sms_template" id="sms_template">
                        <?php
                            $sms_tpls = $output['sms_tpls'];
                            foreach ($sms_tpls as $sms) {
                                echo "<option value=\"{$sms['yuntx_id']}\">{$sms['title']}</option>";
                            }
                        ?>
                    </select>
                </td>
            </tr>
            <tr class="sms_template_choose">
                <td colspan="2" class="required">模板内容：</td>
            </tr>
            <tr class="sms_template_choose">
                <td id="sms_content">
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot">
                <td colspan="2" ><a href="JavaScript:void(0);" class="btn" onclick="document.form1.submit()"><span><?php echo $lang['nc_submit'];?></span></a></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>

<script type="text/javascript">
    $(function(){
        $("#tr_memberinfo").hide();

        $('#points_form').validate({
            rules : {
                member_name: {
                    required : true
                },
                member_id: {
                    required : true
                },
                bonus_rate   : {
                    required : true,
                    min : 1
                }
            },
            messages : {
                member_name: {
                    required : '<?php echo $lang['admin_points_addmembername_error'];?>'
                },
                member_id : {
                    required : '<?php echo $lang['admin_points_member_error_again'];?>'
                },
                bonus_rate  : {
                    required : '<?php echo $lang['admin_points_points_null_error']; ?>',
                    min : '<?php echo $lang['admin_points_points_min_error']; ?>'
                }
            }
        });
        $('#send_sms').on('click',function(){
            var $sms_template_choose=$('.sms_template_choose');
            if($(this).is(":checked")){
                $sms_template_choose.show('500');
            }
            else {
                $sms_template_choose.hide('500');
            }
        });

        var desc_array = {};
        <?php
            $sms_tpls = $output['sms_tpls'];
            foreach ($sms_tpls as $sms) {
                echo "desc_array[{$sms["yuntx_id"]}]=\"{$sms["content"]}\";";
            }
        ?>
        $('#sms_template').on('change',function()
        {
            type = $(this).val();
            desc = desc_array[type];
            $('#sms_content').text(desc);
        });
        $('#sms_template').trigger('change');
    });
</script>