{% load i18n %}


<style>
    #tb tbody .r{
        font-weight:bold;
        color:red;
    }
</style>


<ol class="breadcrumb">
    <li>  {% trans "进出存报表" %}</li> 
    <li> 标签替换 </li> 
</ol>



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

        $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
        $('.datepicker').datepicker('setDate',new Date());
        setDatePickerZh();         

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

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

        {% ifnotequal params.dt_fr '' %}
            $('#dt_fr').val('{{params.dt_fr}}');
        {% endifnotequal  %}
        {% ifnotequal params.dt_to '' %}
            $('#dt_to').val('{{params.dt_to}}');
        {% endifnotequal  %}
       
       
       
        var table=$('#tb').DataTable({
            //"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
            //"bLengthChange":true,
            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();
                }
            });
        });  
        

        $('#tb').on("click","td a.btn-view",function(event){
            $(event.target.parentNode).addClass('row_selected');
             event.preventDefault();
             $.OpenDlg($(this).attr('href'),'标签替换-明细列表',1000,700);
        });   


    });
</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-2 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 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><tr>
            {% for c in clmns %}
                <th>{{c}}</th>
            {% endfor %}                       
        </tr></thead>
        <tbody></tbody>
        <tfoot>
            {% for c in clmns %}
                <th><input type="text" placeholder="{{c}}"></th>
            {% endfor %}
        </tfoot>
    </table>   
    </div>
</div>
