{% load i18n %}


<script type="text/javascript">
    $(document).ready(function(){
        $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
        $('.datepicker').datepicker('setDate',new Date());
        setDatePickerZh();

        $('#dt_fr').val('{{date_from}}');
        $('#dt_to').val('{{date_to}}');

        $('.btn-qry').click(function(){
            var date_from,date_to;           
            date_fr=$('#dt_fr').val();
            date_to=$('#dt_to').val();
            var params=[];          
            if(date_fr!=''){params.push('date_from='+date_fr)};
            if(date_to!=''){params.push('date_to='+date_to)};

            if(params.length==0){
                bootbox.alert("{% trans '请先输入查询条件！'%}");
            }else{
                $.RefreshContent('{{request.path}}?'+params.join('&'));
            }
        });

        var table=$('#tb').DataTable({
            dom: 'Bfrtip',
            autoWidth: true,
            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();
                }
            });
        });  

        




        var rejected=$('#rejected').DataTable({
            dom: 'Bfrtip',
            autoWidth: true,
            buttons: [{extend:'excelHtml5',text: '导出到Excel'}],   
            language:lng,          
            data:{{rejected.data|safe}}
        });     
        rejected.columns().every( function () {                        
            var that = this;             
            $('input', this.footer() ).on( 'keyup change clear', function () {
                if ( that.search() !== this.value ) {
                    that.search( this.value ).draw();
                }
            });
        });  

        /*
        $('#tb').on("click","td a",function(event){
            event.preventDefault(); 
            var url=$(this).attr('href');
            if(url.substring(url.length-7)=='?view=1'){
                $.OpenDlg(url,'终端店注册信息',1000,700);
            }else{                     
                $.OpenUrlCfmDlg(url,"{% trans '终端店注册信息审核'   %}","{% trans '通过审核' %}","{% trans '取消审核' %}");
            }
        });

            rejected




        */


        $('#tb').on("click","td a",function(event){
            event.preventDefault(); 
            var url=$(this).attr('href');
            
            //alert(url.indexOf('/?'));

            if (url.indexOf('/?')==-1){
                $.OpenUrlCfmDlg(url,"{% trans '终端店注册信息审核'   %}","{% trans '通过审核' %}","{% trans '取消审核' %}");            
            }else{
                if(url.indexOf('view=1')>-1){
                    $.OpenDlg(url,'终端店注册信息',1000,700);
                }else{     
                    if(url.indexOf('rejected=1')>-1){
                        $.ajax({
                            type:'GET',
                            processData: false,
                            contentType: 'application/json; charset=utf-8',
                            url:url,
                            success:function(data){  
                                $('#tb a[reg_id="'+data.reg_id+'"]').remove();
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                alert('连接服务器失败');
                                return;
                            }
                        });
                        //alert('驳回注册');      
                    }
                }                
            };

            /*
            if(url.substring(url.length-7)=='?view=1'){
                $.OpenDlg(url,'终端店注册信息',1000,700);
            }else{                     
                $.OpenUrlCfmDlg(url,"{% trans '终端店注册信息审核'   %}","{% trans '通过审核' %}","{% trans '取消审核' %}");
            }
            */
        });     

        
    });
</script>



<ol class="breadcrumb">
        <li>{% trans '经销商管理' %}</li>
        <li>{% trans '终端店注册' %}</li>     
</ol>










<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">

        <div class="" role="tabpanel" data-example-id="togglable-tabs">
            <ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist"> <li role="presentation" class="active"><a href="#tab_1"
                        id="normal-tab" role="tab" data-toggle="tab">终端店审核</a></li>
                <li role="presentation" class="">      <a href="#tab_2"
                        role="tab" id="revoke-tab" data-toggle="tab">已驳回注册</a></li>        
            </ul>
    
            <div id="myTabContent" class="tab-content">
                <div role="tabpanel" class="tab-pane fade active in" id="tab_1">

                    <div class='col-sm-12 form-inline' style='margin-bottom:20px;'>
                        <div class="col-sm-3 input-group">
                            <span class="input-group-addon">{% trans "开始日期"%}</span>
                                <input class="datepicker form-control" id="dt_fr" />
                        </div>
                        <div class="col-sm-3 input-group">
                            <span class="input-group-addon">{% trans "结束日期"%}</span>
                            <input class="datepicker form-control" id="dt_to" />
                        </div>
                        <div style="float:right;">
                            <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>
                    </div>
                    <div class='clearfix' />


                    <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 role="tabpanel" class="tab-pane fade" id="tab_2">
                    <div  class="table-responsive">
                        <table id='rejected'  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                        <thead>
                        {% for c in rejected.clmns %}
                            <th>{{c}}</th>
                        {% endfor %}
                        </thead>
                        <tbody></tbody>
                        <tfoot>
                            {% for c in rejected.clmns %}
                                <th><input type="text" placeholder="{{c}}"></th>            
                            {% endfor %}            
                        </tfoot>
                        </table>
                    </div>

                </div>


        </div>
    </div>
</div
