{% extends "baseAdmin.html" %}
{% load static %}
{% block titulo %}
  .::Configurar monto Tope y comision minima
{% endblock titulo %}
{% block content1 %}
      <script type="text/javascript">
        $("#navCOS").attr('class','dropdown active');
        $("#navcomi").attr('class','active');
      </script>
        <div class="row">
          <div class="col-md-12 col-sm-12" >
              <div class="card">
                <div class="card-header bgm-bluegray text-center"> <h2>Montos tope y comisiones mínimas</h2></div>
                <div class="card-body">
                  <div class="row" id="Result">
                    {% ifnotequal resultado '' %}
                    {% ifequal resultado 'exito' %}
                    <h4 class="bg-success" align="center">
                      Registro Exitoso!!
                    </h4>
                    {% else %}
                    <h4 class="bg-danger" align="center">
                      :( Fallo registro {{resultado}}
                    </h4>
                    {% endifequal %}
                    {% endifnotequal %}
                  </div>
                  <p></p>
                  <div class="row">
                    <div class="col-md-2 col-md-offset-1">
                      <button type="button" class="btn btn-block btn-info waves-effect" id="btnRefrescar">Actualizar</button>
                    </div>
                    <!--
                    <div class="col-md-3 ">
                      <button type="button" class="btn btn-danger btn-block" id="btnAct_ext">Actualizar Config Extorno</button>
                    </div>-->
                  </div>
                  <div class="row">
                    <br>
                    <p class="bg-success">
                      &nbsp;
                      <div class="col-md-10 col-md-offset-1">
                          <script type="text/javascript">
                            var Aux="";
                            var filaI =0;
                            $(document).ready(function () {
                              ajax_comisiones();
                              $(document).on("click",".filaR",function(){
                                var num = $(this).attr('id');
                                filaI = num;
                                var fila= $(this).attr('class');
                                $("."+fila).attr('class','filaR');
                                $("#"+num).attr('class','filaR info');
                                $("#txtpk").prop('value',Aux[filaI].pk);
                                $("#txtmt").prop('value',Aux[filaI].mt);
                                $("#txtcm").prop('value',Aux[filaI].cm);
                                $("#txtof").prop('value',Aux[filaI].of);
                                $("#txtocm").prop('value',Aux[filaI].ocm);
                                $("#txtce").prop('value',Aux[filaI].ce);
                              });
                                $('#txtmt').numeric('.');
                                $('#txtcm').numeric('.');
                                $('#txtocm').numeric('.');
                                $("#campoChk").click(function(){
                                  if($("#ts4").prop('checked')){
                                      habilitar();
                                  }else{
                                      deshabilitar();
                                  }
                                });
                                function habilitar(){
                                  $("#txtmt").prop('readonly',false);
                                  $("#txtcm").attr('readonly',false);
                                  $("#txtocm").attr('readonly',false);
                                  $("#txtce").attr('readonly',false);
                                };
                                 function deshabilitar(){
                                  $("#txtmt").prop('readonly',true);
                                  $("#txtcm").attr('readonly',true);
                                  $("#txtocm").attr('readonly',true);
                                  $("#txtce").attr('readonly',true);
                                };
                              $("#btnRefrescar").click(function(){
                                ajax_comisiones();
                              });
                              /*
                              $("#btnAct_ext").click(function(){
                                ajax_act();
                              })*/
                              function ajax_comisiones(){
                                $.ajax({
                                  url:'/comision_tope_ajax/',
                                  type:'GET',
                                  dataType:'json',
                                  success: function(data){
                                    Aux = data;
                                    var html ="";
                                    for(var i=0;i<data.length;i++){
                                        html += '<tr data-toggle="modal" data-target="#myModal" class="filaR" id="'+i+'"><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td><td>'+data[i].mt+'</td><td>'+data[i].cm+'</td><td>'+data[i].ocm+'</td><td>'+data[i].ce+'</td></tr>';
                                    }                        
                                    $('#listaR').html(html);
                                  }
                                });
                              }
                              /*
                              function ajax_act(){
                                $.ajax({
                                  url:'/actualizar_config_extornos_ofi_ajax/',
                                  type:'GET',
                                  dataType:'text',
                                  success: function(data){
                                    alert(data);
                                  }
                                });
                              }*/
                            });
                          </script>
                          <div>
                            <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <h4 class="modal-title" id="myModalLabel">Recibo</h4>
                                    </div>
                                    <div class="modal-body">
                                      <p>
                                        <div class="col-md-12 col-sm-12" >
                                            <div class="panel panel-info">
                                              <div class="panel-heading" align="center"> <h4>Detalle de configuración</h4></div>
                                               <form action="/Admin/configurar_comision_monto/" method="POST" data-toggle="validator" role="form"> {% csrf_token %}
                                                <div class="panel-body">
                                                  <div class="row">
                                                    <div class="col-md-12">
                                                      <h4 class="bg-success" align="center">
                                                        &nbsp;
                                                      </h4>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>id: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                      <input type="text" class="form-control" id="txtpk" name ="pkR" readonly="readonly" required>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>Oficina: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                      <input type="text" class="form-control" id="txtof"readonly="readonly" required>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>Monto Tope: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                      <input type="text" class="form-control"  name ="mt" id="txtmt" readonly="readonly" required>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>Comisión mínima: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                      <input type="text" class="form-control" name ="cm"id="txtcm" readonly="readonly" required>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>Otros Conceptos Mínimos: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                      <input type="text" class="form-control"  name ="ocm" id="txtocm" readonly="readonly" required>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-3 col-md-offset-2" >
                                                      <h5>Autorización de Extorno: </h5>
                                                    </div>
                                                    <div class="col-md-3">
                                                        <select class="form-control" name="ce" id="txtce" readonly="readonly">
                                                          <option value="si">si</option>
                                                          <option value="no">no</option>
                                                        </select>
                                                      <p></p>
                                                    </div>
                                                  </div>
                                                  <p></p>
                                                   <div class="row"> 
                                                    <div class="col-md-10 col-md-offset-2">
                                                      <div class="toggle-switch" data-ts-color="green" id="campoChk">
                                                          <label for="ts4" class="ts-label">Actualizar datos</label>
                                                          <input id="ts4" type="checkbox" hidden="hidden">
                                                          <label for="ts4" class="ts-helper"></label>
                                                      </div> 
                                                     </div> 
                                                  </div>
                                                  <!--<div class="row">
                                                    <div class="col-md-5 col-md-offset-6">
                                                      <div class="checkbox" id="campoChk">
                                                        <label>
                                                          <input type="checkbox" id="actualizar"> Actualizar datos
                                                        </label>
                                                      </div>
                                                    </div>
                                                  </div>-->
                                                  <p></p>
                                                  <div class="row">
                                                    <div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4">
                                                      <button class="btn btn-primary btn-block" type="submit" value="Actualizar" >Actualizar</button>
                                                    </div>

                                                  </div>
                                                </div>
                                              </form>
                                            </div>
                                        </div>
                                      </p>
                                    </div>

                                    <div class="modal-footer">
                                      <hr>
                                      <button type="button" class="btn btn-primary" data-dismiss="modal">Cerrar</button>

                                    </div>
                                  </div><!-- /.modal-content -->
                                </div><!-- /.modal-dialog -->
                              </div>
                          </div>
                          <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                  <tr>
                                    <th>Nro</th>
                                    <th>Oficina</th>
                                    <th>Monto Tope</th>
                                    <th>Comisión Mínima</th>
                                    <th>Otros Conceptos Mínimos</th>
                                    <th>Autorización de Extorno</th>
                                  </tr>
                                </thead>
                                <tbody id="listaR">
                                    
                                </tbody>
                            </table>
                          </div>
                      </div>
                    </p>
                  </div>
                  <br>
                </div>
              </div>
          </div>
        </div> 
{% endblock content1 %}