{% load i18n %}

<ol class="breadcrumb">
    <li>  {% trans "经销商出入库查询" %}</li>
</ol>

<script type="text/javascript">
        $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
        $('.datepicker').datepicker('setDate', new Date());
        $('#dt_fr').val('{{date_fr}}');
        $('#dt_to').val('{{date_to}}');


    $(document).ready(function(){
        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();
                }
            });
        });
        $('#agent_label').autocomplete({
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/agent/',
                    dataType: "json",
                    data: {
                        term:   $("#agent_label").val() ,//搜索栏里的内容
                        company_id:  $('#id_company').val() ,//额外参数
                        query_all:1
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },

            select: function (event, ui) {
                $("#agent_id").val(ui.item.value);
                $("#agent_label").val(ui.item.label);
                return false;
             }
    });

        $('#tb').on("click","td a",function(){
            event.preventDefault();
            //var cname=$(this).text();
            $.OpenDlg($(this).attr('href'),"经销商库存明细列表-"+$('#agent_label').val(),1100,700);
        });

        $('.btn-qry').click(function(){
            var agent_id,agent_label,date_fr,date_to;
            agent_id=$('#agent_id').val();
            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)};
            if(agent_id!=''){params.push('agent_id='+agent_id)};

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

    });
</script>






<form role="form"  class="form-inline" style="margin-top:0px;">
    <div class='col-sm-4 input-group'>
            <span class="input-group-addon">{% trans "经销商名称"%}</span>
            <input  class='form-control' id="agent_label" placeholder='经销商名称' value="{{agent_name}}"/>
            <input type="hidden" id="agent_id" value="{{agent_id}}"/>
    </div>
    <div class='col-sm-3 input-group'>
        <input class="datepicker form-control col-sm-1" id="dt_fr" />
        <span class="input-group-addon">{% trans " 到 "%}</span>
        <input class="datepicker form-control col-sm-1" 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>
        <!--
        <button class="btn btn-sm btn-primary btn-qry" type="button"><i class="fa fa-search"></i> {% trans '查找' %}</button>
        -->
    </div>
</form>
<div class="form-group col-sm-2" style="padding-left:0px;">
    <span>{% trans '经销商层级:' %}</span>
    <span style="color:green;">{{level}}</span>
</div>
<div  class="form-group col-sm-3">
    <span>{% trans '父级经销商:' %} </span>
    <span  style="color:green;">{{ parent }}</span>
</div>

<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%"  style='font-size:90%;'>
        <thead>
            <tr>
                <th  style='width:10%'>{% trans "日期时间" %}</th>
                <th  style='width:10%'>{% trans "单据类别" %}</th>
                <th  style='width:6%'>{% trans "单据编号" %}</th>
                <th  style='width:20%'>{% trans "产品名称" %}</th>
                <th>{% trans "操作商" %}</th>
                <th>{% trans "客户名称" %}</th>
                <th  style='width:6%'>{% trans "操作人" %}</th>
                <th  style='width:3%'>{{package_3}}</th>
                <th>备注</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="{{package_3}}"></th>
            <th><input type="text" placeholder="{% trans "备注" %}"></th>
        </tfoot>
    </table>
    </div>
</div>

