{% 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-obj-add").click(function () { 
            event.preventDefault();
            $.RefreshContent($(this).attr('href'));        
        })

        $('.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: false,
            buttons: [{extend:'excelHtml5',text:'导出到Excel'}],           
            language:lng,       
            pageLength: 5,
            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();
                }
            });
        });  


        $('#tb').on("click","td a.lnk",function(event){                     
            event.preventDefault();       
            $.RefreshContent($(this).attr('href'));   
                         
        });  
        $('#tb').on("click","td a.view-img",function(event){                     
            event.preventDefault();       
            //$.RefreshContent($(this).attr('href'));   
            $.OpenDlg($(this).attr('href'),'发票附件:')             
        });     



    });
</script>






<ol class="breadcrumb">
    <li>{% trans "渠道促销" %}</li>
    <li>{% trans "发票录入" %}</li>
</ol>



<form role="form"  class="form-inline" style="margin-top:0px;">
    <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 class="col-sm-2 input-group">     
        <span class="btn btn-primary btn-qry" style='margin-top:3px;'>查询</span>        
    </div>
    {% if show_add %}  
        <div style="float: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>       
        </div>
    {% endif %}    
</form>
<div class="clearfix"></div>

<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">            
            <div class="x_content">
               <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>
    </div>
</div>
