{% load i18n %}


<ol class="breadcrumb">
    <li>  {{subtt.0}} </li> 
    <li>  {{subtt.1}} </li> 
</ol>


<style>
    #tb .popover{
        max-width:400px;
    }
</style>


<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-obj-add').click(function(){
            var url=$(this).attr('href');
            $.RefreshContent(url);        
        });
         $('#tb').on("click","td a",function(event){           
            event.preventDefault();
            url=$(this).attr('href');
            $.RefreshContent(url);             
        });   

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

            is_writeoff=$('#is_writeoff').val();
            params.push('is_writeoff='+is_writeoff);

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

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


         $("[data-toggle='popover']").popover({
            html:true,
            placement:'bottom'
        });


        $('#tb').on("change","td input[type='checkbox']",function(event){            
            var me=$(this);
            var checked=$(this).prop("checked");
            var id=$(this).attr('id').split('-')[1];
            if (checked){
                $.ajax({
                    type:'POST',                    
                    url:'/entertainment/request/ActApplication/confirm/'+id+'/',
                    success:function(d){
                        $('#tb').find('#cb-'+id).closest('td').text(d.username+d.tm);
                    }
                })
            };
        });

    });
</script>

<form role="form"  class="form-inline" style="margin-top:0px;">
    <div class="col-sm-2 input-group">
        <span class="input-group-addon">{% trans "开始日期"%}</span>
        <input class="datepicker form-control" id="dt_fr" />
    </div>
    <div class="col-sm-2 input-group">
        <span class="input-group-addon">{% trans "结束日期"%}</span>
        <input class="datepicker form-control" id="dt_to" />
    </div>
    <div class="col-sm-4 input-group">
        <span class="input-group-addon">{% trans "状态"%}</span>
        <select class="form-control" id="is_writeoff" >
            <option value='-1'>全部</option>
            <option value='1'>已核销</option>
            <option value='0'>未核销</option>
        </select>  

         <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>
  
    
         
    
    {% if show_add %}    
        <span class="pull-right">
            <span class='input-group'> 
                <button type="button" class='btn btn-obj-add l-a create-btn' href='{{murl}}'>
                    <span class='glyphicon glyphicon-plus' style='padding-right:5px;'></span>{% trans '新建' %}
                </button>
            </span>
        </span>    
    {% endif %}

</form>
<div class="clearfix"></div>
<div id="inventory-list" class="table-responsive">
    <div class='x_panel'>    
    <table id="tb" class="table table-striped table-bordered dt-responsive" 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>
