{% load i18n %}

<style> 
    .word-wrap{
        width: 100%;white-space: normal;word-wrap: break-word;word-break: break-all;
    }

    #tb tbody td:nth-child(12){
        padding:2px;
    }
</style>


<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,
            order: {{order|safe}},
            data:{{data|safe}},
            columnDefs: [{"targets": [ 0 ], "visible": false }],
            createdRow: function ( row, data, index) {
                $(row).attr('obj_id', data[0]);                
            }
        });
        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-obj-add").click(function () { 
            event.preventDefault();
            $.RefreshContent($(this).attr('href'));        
        });

        $('#tb').on("click","td a.edit",function(event){
            event.preventDefault();    
            $.RefreshContent($(this).attr('href'));            
        });         

        $('#tb').on('click','button.approve',function(){        
            var tr=$(this).closest('tr');
            var td=$(this).closest('td');
            var name=$(tr).find('a.edit').text();
            var id=$(tr).attr('obj_id');          
            var msg = name+':\n您确定要通过当前门店的审核吗？';                 
            if (confirm(msg)==true){
                $.ajax({
                    type:'GET',
                    processData: false,
                    contentType: 'application/json; charset=utf-8',
                    url:'/company/franchise/action/outlet/approve/'+id+'/',
                    success:function(data){
                        $(td).html('已审核');
                    }
                });
            };
        });
    });
</script>



<ol class="breadcrumb">
        <li>{{subtt.0}}</li>
        <li>加盟商门店列表</li>     
</ol>
{% if show_add %}
    <div class="title_right">
        <div class="pull-right">
            <span class='input-group'>
                <a type="button" class='btn btn-obj-add l-a create-btn' href='{{murl}}'>
                    <span class='glyphicon glyphicon-plus' style='padding-right:5px;'></span>{% trans '新建' %}
                </a>
            </span>
        </div>
    </div>        
{% endif %}



<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>
