{% load i18n %}





<ol class="breadcrumb">
        <li>{% trans "进销存报表" %}</li>
        <li>{% trans "出入库列表" %}</li>
</ol>

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

        $('#store_label').autocomplete({
            source: {{stores}},
            select: function (event, ui) {
                $("#store_id").val(ui.item.value);
                $("#store_label").val(ui.item.label);
                return false;
            }
        });
        $('#product_label').autocomplete({
            source: {{products}},
            select: function (event, ui) {
                $("#product_id").val(ui.item.value);
                $("#product_label").val(ui.item.label);
                return false;
            }
        });
        

        $('.btn-qry').click(function(){
            var store_id,product_id,date_from,date_to;
            store_id=$('#store_id').val();
            product_id=$('#product_id').val();
            date_fr=$('#dt_fr').val();
            date_to=$('#dt_to').val();
            var params=[];
            /*
            if(store_id!=''){
                params.push('store_id='+store_id);
                params.push('store_label='+$('#store_label').val());
            };
            if(product_id!=''){
                params.push('product_id='+product_id);
                params.push('product_label='+$('#product_label').val());
            };
            */
            if(date_fr!=''){params.push('date_fr='+date_fr)};
            if(date_to!=''){params.push('date_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  %}
        {% ifnotequal params.store_id '' %}
            $('#store_id').val('{{params.store_id}}');
            $('#store_label').val('{{params.store_label}}');
        {% endifnotequal  %}
        {% ifnotequal params.product_id '' %}
            $('#product_id').val('{{params.product_id}}');
            $("#product_label").val('{{params.product_label}}');
        {% endifnotequal  %}
       
        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();
                }
            });
        });  
    });
</script>

<form role="form"  class="form-inline" style="margin-top:35px;">
    <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>
</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>
                <th  style='width:15%'>{% trans "仓库名称" %}</th>
                <th  style='width:20%'>{% trans "产品名称" %}</th>
                <th  style='width:8%'>{% trans "成品入库" %}</th>
                <th  style='width:8%'>{% trans "标签退库" %}</th>
                <th  style='width:8%'>{% trans "转入" %}</th>
                <th  style='width:8%'>{% trans "转出" %}</th>
                <th  style='width:8%'>{% trans "销售出库" %}</th>
                <th  style='width:8%'>{% trans "销售退库" %}</th>
            </tr>            
        </thead>
        <tbody></tbody>
        <tfoot>
            <th><input type="text" placeholder="{% trans "仓库名称" %}"></th>
            <th><input type="text" placeholder="{% trans "产品名称" %}"></th>
            <th><input type="text" placeholder="{% trans "成品入库" %}"></th>
            <th><input type="text" placeholder="{% trans "标签退库" %}"></th>
            <th><input type="text" placeholder="{% trans "转入" %}"></th>
            <th><input type="text" placeholder="{% trans "转出" %}"></th>
            <th><input type="text" placeholder="{% trans "销售出库" %}"></th>
            <th><input type="text" placeholder="{% trans "销售退库" %}"></th>            
        </tfoot>
    </table>    
    </div>
</div>
