{% load i18n %}


<style>
    #tb tbody a{
        cursor:pointer;        
    }
    .ui-autocomplete {
        z-index: 10000;
    }
    
</style>

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

        $('#dt_fr').val('{{dt_fr}}');
        $('#dt_to').val('{{dt_to}}');

        
        {% ifequal request.user.company.level_id 1 %}
            $('#vendor_name').autocomplete({   
                source: function(request, response) {
                    $.ajax({
                        url: '/obj/ajax/autocomplete/agent/',
                        dataType: "json",
                        data: {
                            term:   $("#vendor_name").val() ,//搜索栏里的内容
                            //company_id:  $('#id_company').val() ,//额外参数
                        },
                        success: function(data) {
                            response(data);
                        }
                    });
                },            
                select: function (event, ui) {
                    $("#vendor_id").val(ui.item.value);
                    $("#vendor_name").val(ui.item.label);
                    return false;
                }
            });
        {% endifequal %}
        

        

        $('.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_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('&'));
            }
        });
        
        var table=$('#tb').DataTable({                        
            dom: 'Bfrtip',
            autoWidth: false,
            buttons: [{extend:'excelHtml5',text:'导出到Excel'}],           
            language:lng,       
            pageLength: 10,
            columns:{{clmns|safe}},
            data:{{data|safe}}
        });     


        ///2025-01-03
        $('#tb').on("click","td a",function(event){  
            event.preventDefault();
            var id=$(this).attr('dn_id');           
            $.OpenDlg('/inventory/deliverynote/edit/'+id+'/','发货单明细',1000,800);           
        });  

        $('#data-content .btn-add').click(function(){            
            event.preventDefault();
            $.OpenDlg('/inventory/deliverynote/edit/','发货单明细',1000,800);      
        });
        
    });
</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>


    {% ifequal request.user.company.level_id 1 %} 
    {% endifequal %}


    <div class="col-sm-2 input-group">     
        <span class="btn btn-primary btn-qry" style='margin-top:3px;'>查询</span> 
        
    </div>

    <div class="col-sm-1 input-group">     
        <span class="btn btn-primary btn-add" style='margin-top:3px;'>新建</span>        
    </div>
   
</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.title}}</th>
                        {% endfor %}
                    </thead>
                    <tbody></tbody>
                    <tfoot>
                        {% for c in clmns %}
                            <th><input type="text" placeholder="{{c.title}}"></th>            
                        {% endfor %}            
                    </tfoot>                
                </table>
               </div>
            </div>
        </div>
    </div>
</div>



