{% load i18n %}


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

        $('.btn-confirm').removeAttr("style",""); 
        $('.btn-confirm').unbind('click').bind('click',function(){  
            var me=$(this);
            var obj_id=$('#obj_id').val();
            var bank_name=$('#bank_name').val();
            var bank_account=$('#bank_account').val();
            var payee=$('#payee').val();

            if( $.isEmpty(bank_account) || $.isEmpty(bank_name) || $.isEmpty(payee) ){
                toastr.error("开户行、帐号、收款人不能为空！", "操作错误：",
                    {timeOut: 800, positionClass: "toast-center-center"}
                );
                
            }else{
                
                $(me).hide();     
                $.ajax({
                    type: 'post',
                    data:JSON.stringify({"bank_account":bank_account,"bank_name":bank_name,"payee":payee}), 
                    url: '{{request.path}}',    
                    success: function(data) {
                        $('#'+obj_id).find('td:nth-child(8)').text(bank_account);
                        $('#confirm-url-modal').modal('hide');                        
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert('连接服务器失败');                        
                    }                    
                });
                $(me).show();
                return; // 阻止表单自动提交事件  
            }
        });     



        
        {% if is_saved %}   
            $('#confirm-url-modal').modal('hide');                 
            var url=$('#list-tt').attr('current');
            $.ajax({
                type:'GET',
                processData: false,
                contentType: 'application/json; charset=utf-8',
                url:url,
                success: function (html) { 
                    $('#div-list').html(html);                    
                    return;
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert('连接服务器失败');
                    return;
                }
            });
            
        {% endif %}
       
    });
</script>


   
<div class="row">    
    <form role="form" method='POST' class="form-horizontal">    
        <input id="obj_id" type='hidden' value='{{obj.id}}' />
        <div class="form-group ">
            <label class="col-sm-2 control-label ">{% trans '经销商名称:' %} </label>
            <div class="col-sm-10 lb">{{ obj.payee_company.name }}</div>
        </div> 
        <div class="form-group ">
            <label class="col-sm-2 control-label ">{% trans '开户银行:' %} </label>
            <div class="col-sm-10 lb"><input id='bank_name' value='{{ obj.bank_name }}' class='form-control' /></div>
        </div> 
        <div class="form-group ">
            <label class="col-sm-2 control-label ">{% trans '银行帐号:' %} </label>
            <div class="col-sm-10 lb"><input id='bank_account' value='{{ obj.bank_account }}' class='form-control' /></div>
        </div> 
        <div class="form-group ">
            <label class="col-sm-2 control-label ">{% trans '收款人:' %} </label>
            <div class="col-sm-10 lb"><input id='payee' value='{{ obj.payee }}'  class='form-control' /></div>
        </div> 

        
         
    </form>
</div>

