{% load i18n %}
<!--
<script src="/static/js/jquerydatatable/DataTables-1.10.20/js/jquery.dataTables.min.js"></script>
<script src="/static/js/jquerydatatable/Buttons-1.6.1/js/dataTables.buttons.min.js"></script>
<script src="/static/js/jquerydatatable/Buttons-1.6.1/js/buttons.html5.min.js"></script>
<script src="/static/js/jquerydatatable/Buttons-1.6.1/js/jszip.min.js"></script>
<script src="/static/js/jquerydatatable/Buttons-1.6.1/js/buttons.print.min.js"></script>
<link  href="/static/js/jquerydatatable/datatables.min.css" rel="stylesheet">
<link  href="/static/js/jquerydatatable/Buttons-1.6.1/css/buttons.dataTables.css" rel="stylesheet">
-->

<style>
    #tb {
        font-size:15px;
    }
    #tb th{
        text-align:left;
    }
    #tb tfoot th{
        padding-left:10px;
        margin-left:0px;
    }
    #tb tfoot input{
        width:98%;  
        font-size:14px;
    }
    .subt{
        display:inline-block;
    }
    .inventory-tt{
        font-size:16px;
        margin-bottom:15px;
    }
    .digest{       
        position:relative;
        top:10px;
        margin-left:15px;
    }
    .digest .g{
        color:green;
        margin-right:20px;
    }
    
</style>


<div class="subtitle"> {% trans "存货管理" %} > {{batch.voucher}} >  <span style="color:green;"> {% trans "修改" %}  </span></div>

<script type="text/javascript">    
    $(document).ready(function(){    
        $('#product_label').autocomplete({            
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/product/',
                    dataType: "json",
                    data: {
                        term: $("#product_label").val() ,//搜索栏里的内容
                        company_id:{{request.user.company_id}} //额外参数
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                $("#product_id").val(ui.item.value);
                $("#product_label").val(ui.item.label);
                return false;
            }
        });

        $('#product_id').val({{batch.product_id}});
        $('#product_label').val('{{batch.product}}');        
        $('#store_fr_id').val({{batch.store_fr_id}});
        $('#store_fr_label').val('{{batch.store_fr}}');        


        {% ifequal batch.vtype_id 2 %}
            $('#company_to_id').val({{batch.company_to_id}});
            $('#company_to_label').val('{{batch.company_to}}');
            $('#company_to_label').autocomplete({                
                source: function(request, response) {
                    $.ajax({
                        url: '/obj/ajax/autocomplete/agent/?query_all=1',
                        dataType: "json",
                        data: {
                            term:   $("#company_to_label").val() ,//搜索栏里的内容
                            company_id:  {{request.user.company_id}} //额外参数
                        },
                        success: function(data) {
                            response(data);
                        }
                    });
                },   
                select: function (event, ui) {
                    $("#company_to_id").val(ui.item.value);
                    $("#company_to_label").val(ui.item.label);
                    return false;
                }
            });
        {% endifequal %}       
       
        $('#store_fr_label').autocomplete({
            source: {{store_fr|safe}},
            select: function (event, ui) {
                $("#store_fr_id").val(ui.item.value);
                $("#store_fr_label").val(ui.item.label);
                return false;
            }
        });      
        {% if batch.store_to_id %}
            $('#store_to_id').val({{batch.store_to_id}});
            $('#store_to_label').val('{{batch.store_to}}');       
            $('#store_to_label').autocomplete({
                source: {{store_to|safe}},
                select: function (event, ui) {
                    $("#store_to_id").val(ui.item.value);
                    $("#store_to_label").val(ui.item.label);
                    return false;
                }
            });            
        {% endif %}

        //2021-07-12
        $('#inbound_ticket_label').autocomplete({
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/inbound_ticket/',
                    dataType: "json",
                    data: {
                        term: $("#inbound_ticket_label").val() ,//搜索栏里的内容
                        company_id:{{request.user.company_id}} //额外参数
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                $("#inbound_ticket_id").val(ui.item.value);
                $("#inbound_ticket_label").val(ui.item.label);
                return false;
            }
        }); 

        
        {% if batch.inbound_ticket %}            
            $("#inbound_ticket_label").val('{{batch.inbound_ticket.pici}}');            
        {% endif %}       



        $('.btn-save').click(function(){
            $('.btn').hide();
             $.SubmitForm('#obj_form form','{{request.path}}');
        });

        //2022-05-17
        $('#rmk_name').val('{{batch.rmk_name}}');
        $('#rmk_address').val('{{batch.rmk_address}}');
        //2023-05-06
        $('#remark').val('{{ batch.remark }}');

    });
</script>


<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<br />    
<div id="obj_form"  style="width:100%;">       
    <form role="form" method='post' action='{{request.path}}' class="form-horizontal"> 
    {% csrf_token %}
    <div class="form-group ">      
            <span class='digest' style='padding-left:38px'>
                <label>上传时间:<span class='g'>{{batch.tm}}</span></label>  
                <label>操作人:<span class='g'>{{batch.user}}</span></label>                
            </span>           
    </div>

    <div class="form-group ">
        <label class="col-sm-1 control-label ">{% trans '单据编号:' %} </label>
        <div class="col-sm-11">
            <input name='code' value='{{batch.code}}'   class='form-control'/>        
        </div>
    </div> 


    <div class="form-group ">
        <label class="col-sm-1 control-label ">{% trans '产品名称:' %} </label>
        <div class="col-sm-11">
            <input id='product_id' type='hidden' name='product_id' /><input id='product_label'  class='form-control'/>        
        </div>
    </div>    
    {% ifequal batch.vtype_id 1 %}
        <div class="form-group ">
            <label class="col-sm-1 control-label ">{% trans '质检员:' %} </label>
            <div class="col-sm-11">
                <input name='qc_name' value='{{batch.qc_name}}'  class='form-control' />
            </div>
        </div>
    {% endifequal %}
    {% ifequal batch.vtype_id 2 %}
        <div class="form-group ">
            <label class="col-sm-1 control-label ">{% trans '客户名称:' %} </label>
            <div class="col-sm-11">
                <input id='company_to_id' type='hidden' name='company_to_id' /><input id='company_to_label' class='form-control'/>
            </div>
        </div>
    {% endifequal %}

    {% ifequal batch.vtype_id 3 %}
        <div class="form-group ">
            <label class="col-sm-1 control-label ">{% trans '原仓库名:' %} </label>
            <div class="col-sm-11">
                <input id='store_fr_id' type='hidden' name='store_fr_id' /><input id='store_fr_label' class='form-control'/>
            </div>
        </div>    
        <div class="form-group ">
            <label class="col-sm-1 control-label ">{% trans '目的仓库:' %} </label>
            <div class="col-sm-11">
                <input id='store_to_id' type='hidden' name='store_to_id'/><input id='store_to_label' class='form-control'/>
            </div>
        </div>    
    {% else %}
        <div class="form-group ">
            <label class="col-sm-1 control-label ">{% trans '仓库名称:' %} </label>
            <div class="col-sm-11">
                <input id='store_fr_id' type='hidden' name='store_fr_id'/><input  id='store_fr_label'  class='form-control'/>
            </div>
        </div>    
    {% endifequal %}


    {% ifequal batch.vtype_id 1 %}
        {% ifequal request.user.company.cfg_company.inbound_ticket 1 %}
            <div class="form-group ">
                <label class="col-sm-1 control-label ">{% trans '入库启票:' %} </label>
                <div class="col-sm-11">
                    <input id='inbound_ticket_label' class='form-control'  value='{{batch.inbound_ticket.pici}}' />
                    <input id='inbound_ticket_id' name='inbound_ticket_id' type='hidden'  value='{{batch.inbound_ticket.id}}' />
                </div>
            </div>
        {% endifequal %}
    {% endifequal %}

    
    {% ifequal request.user.company_id 100424 %}
        <!--成义烧坊酒业股份有限公司 数据上传后修改单据可添加客户姓名地址 -->
        <div class="form-group ">
                <label class="col-sm-1 control-label ">{% trans '客户备注:' %} </label>
                <div class="col-sm-11">
                    <input name='rmk_name' id='rmk_name' class='form-control'  />                    
                </div>
        </div>
        <!--
        <div class="form-group ">
                <label class="col-sm-1 control-label ">{% trans '客户地址:' %} </label>
                <div class="col-sm-11">
                    <input name='rmk_address' id='rmk_address' class='form-control'  />                    
                </div>
        </div>
        -->
    {% endifequal %}
    <div class="form-group ">
        <label class="col-sm-1 control-label ">{% trans '备注:' %} </label>
        <div class="col-sm-11">
            <input name='remark' id='remark' class='form-control'  />
        </div>
    </div>


    <div class="pull-right" style='margin-right:15px;'>
            <a type="button" class='btn btn-primary btn-save'>
                    <span class='glyphicon glyphicon-floppy-disk' style='padding-right:5px;'></span>{% trans '保存' %}
            </a>
    </div>
    </form>
<div>
    
</div>
</div>
</div>

