{% load i18n %}


<script type="text/javascript">
    $(document).ready(function(){    
        var page_length=10;

        var table=$('#tb').DataTable({
            dom: 'Bfrtip',
            autoWidth: true,
            pageLength: page_length,
            buttons: [{extend:'excelHtml5',text: '导出到Excel'}],
            language:lng,          
            data:{{data|safe}}
        });     
        table.columns().every( function () {                        
            var that = this;             
            $('input', this.footer() ).on( 'keyup change clear', function () {
                if ( that.search() !== this.value ) {
                    that.search( this.value ).draw();
                }
            });
        });    
        $('.btn-qry').click(function(){
            $.ajax({
                type:'POST',
                dataType:"JSON",
                url:'/sms_send/details/',
                data:JSON.stringify({'lev':$('.lev').val(),
                       'msg':$(".messages").val(),
                        'gs':'more'}),
                contentType: "application/json; charset=utf-8",
                success:function(result){
                        if (result.e) {
                            alert(result.e)
                        }else{
                        alert("ok")
                    }
                    console.log(result)
                }

            })
        })

        $('.btn-send').click(function(){
            console.log("ssssssssssssssssss",$(this).val())
            console.log("mes-to",$(".lev").val())
            console.log("messages",$(".messages").val())
            $.ajax({
                type:'POST',
                contentType: "application/json;charset=utf-8",
                dataType:"JSON",
                data:JSON.stringify({'phone':$(this).val(),
                       'msg':$(".messages").val(),
                        'gs':'one'}),
                url:'/sms_send/details/',
                success:function(result){
                    if (result.e){
                        alert(result.e)
                    }else{
                        alert("ok")
                    }
                }

            })
        });
    });
</script>



<ol class="breadcrumb">
        <li>{% trans '会员管理' %}</li>
        <li>{% trans '短信发送' %}</li>
</ol>

<div style="display:flex;flex-wrap: wrap;">
<form role="form" id="form"  class="form-inline" style="margin-top:0px;">
    <div class="form-group; ">
        <label class="">筛选对象:</label>
        <select class="lev" name="name" maxlength="100" >
            <option value="0">-请选择-</option>
            {% for  i in lev %}
                <option value="{{ i }}">{{ i.name }}</option>

            {% endfor %}
        </select>
        </select>
    </div>
    <div class="form-group; ">
        <label class="">短信内容:</label>
            <input  class="messages" placeholder="请输入短信内容" type="text" name="main" maxlength="100" >
    </div>
    <div  class="col-sm-3 input-group">
            <span class='input-group-btn'>
                <a type="button" class='btn btn-primary btn-qry'>
                    <span class='glyphicon glyphicon-search' style='padding-right:5px;'>
                    </span>{% trans '发送' %}
                </a>
            </span>
    </div>
</form>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div  class="table-responsive">
            <table id='tb'  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
            <thead>
                {% for c in clmns %}
                    <th>{{c}}</th>
                {% endfor %}
            </thead>
            <tbody></tbody>
            <tfoot>
                {% for c in clmns %}
                    <th><input type="text" placeholder="{{c}}"></th>            
                {% endfor %}            
            </tfoot>
            </table>
        </div>
    </div>
</div>
