{% extends "base.html" %}
{% load static %}
{% block titulo %}
Intercambios Pagados
{% endblock titulo %}
{% block content1 %} 
<script type="text/javascript">
  $("#navInter").attr('class','dropdown active');
  $("#navInterPagadas").attr('class','active');
</script>
<div class="row">
  <div class="col-md-12 col-sm-12" >
      <div class="panel panel-default">
        <div class="panel-heading panel-toolbar">
          <strong>INTERCAMBIOS PAGADOS</strong>
          <button type="button" class="btn btn-default btn-sm" id="RefrescarLista"><span class="fa fa-refresh"></span> Actualizar</button>
        </div>
        <div class="panel-body">
          <div class="row myb-4">
            <div class="col-md-2">
                <div class="select">
                  <select class="form-control form-control-sm" id="comboFiltroF">
                    <option value="h">Hoy</option>
                    <option value="f">Fecha</option>
                    <option value="ef">Entre Fechas</option>
                  </select>
                </div>
              </div>
              <div class="col-md-2" id="div-f1">
                <input type='text' class=" form-control" id="txtfecha1" autocomplete="off">
              </div>
              <div class="col-md-2" id="div-f2">
                <input type='text' class="form-control" id="txtfecha2" autocomplete="off">
              </div>
              <div class="col-md-1" align="center">
                <button type="button" class=" btn btn-sm btn-danger" id="buscarF"> FILTRAR</button>
              </div>
              <div class="col-md-2 col-md-offset-2" align="center">
                <button type="button" class=" btn btn-sm btn-primary" id="adelanto">Pagos con adelanto</button>
              </div>
          </div>
          <div class="row">
              <div class="col-md-4">
                <input type="text" class="form-control" placeholder="Nombre o Apellidos (Beneficiado o Solicitante)" id="filtro">
              </div>
              <div class="col-md-1" >
                <button type="button" class="btn btn-primary btn-block btn-sm" id="buscar"><i class="fa fa-search" ></i> Buscar</button>
                <p></p>
              </div>
            </div>
          <div class="row">
              <div class="col-md-12">
                  
                  <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                          <tr >
                            <th>Beneficiado</th>
                            <th>Monto</th>
                            <th>Remitente</th>
                            <th>Fecha</th>
                            <th>Pagador</th>
                            <th>P/I</th>
                            <th>Comision</th>
                            <th>Otros</th>
                            <th>Moneda</th>
                            <th>Obs.</th>
                            <th>Detalle</th>
                            <th>Estado</th>
                          </tr>
                        </thead>
                        <tbody id="listaTransf">
                        </tbody>
                    </table>
                  </div>
              </div>
          </div>
        </div>
      </div>
  </div>
</div>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <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>
          <label class="modal-title" id="myModalLabel">Detalle Intercambio</label>
        </div>
        <div class="modal-body">
          <div class="row">
            <div class="col-md-6" >
                <div class="panel panel-default">
                  <div class="panel-heading" align="center"> <strong>SOLICITANTE</strong></div>
                  <div class="panel-body">
                    <div class="row myb-4">
                      <div class="col-md-8">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>DNI/RUC:</label></div>
                            <input type="text" class="form-control" id="txtDNI">
                          </div>
                        </div>
                      </div>
                      
                    </div>
                    <div class="row">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Nombres</label></div>
                            <input type="text" class="form-control" id="txtNombres_Soli">
                          </div>
                        </div>
                      </div>
                    </div>
                    <br>
                    <div class="row">
                      <div class="panel panel-default">
                        <div class="panel-heading" align="center"> <strong>BENEFICIADO</strong></div>
                      </div>
                    </div>
                    <div class="row myb-4">
                      <div class="col-md-8">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>DNI/RUC:</label></div>
                            <input type="text" class="form-control" id="txtN" disabled>
                          </div>
                        </div>
                      </div>
                      
                    </div>
                    <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Nombres</label></div>
                            <input type="text" class="form-control" id="txtNombres_Bene" disabled="disabled">
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="row myb-4">
                      <div class="col-md-12">
                        <button type="button" class="btn btn-primary btn-sm" id="movi" data-toggle="modal" data-target="#modal_movimientos">PAGOS DE ADELANTO</button>
                      </div>
                    </div>
                    
                  </div>
                </div>
            </div>
            <div class="col-md-6">
              <div class="panel panel-success">
                <div class="panel-heading panel-toolbar">
                  <strong>INTERCAMBIO</strong>
                  <button type="button" class="btn btn-success btn-sm" data-dismiss="modal" id="rimprimir">Re-imprimir</button>
                </div>
                <div class="panel-body">
                  <div class="row myb-4">
                      <div class="col-md-8">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>ID</label></div>
                            <input type="text" class="form-control" id="txtIDtrans" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-8">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Estado</label></div>
                            <input type="text" class="form-control" id="txtEstadoTrans" disabled="disabled">
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Fecha de Pago</label></div>
                            <input type="text" class="form-control" id="txtFecha" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Personal Emisor</label></div>
                            <input type="text" class="form-control" id="txtPersonalE" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Oficina Origen</label></div>
                            <input type="text" class="form-control" id="txtOficinaOri" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Cantidad</label></div>
                            <input type="text" class="form-control t-monto" id="txtMonto" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Comisión</label></div>
                           <input type="text" class="form-control t-monto" id="txtComicion" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12">
                        <div class="form-group">
                          <div class="input-group">
                            <div class="input-group-addon" ><label>Egreso Extra</label></div>
                           <input type="text" class="form-control t-monto" id="txtEgresoExtra" disabled="disabled">   
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="row myb-4">
                      <div class="col-md-12"> 
                        <h5>Observaciones</h5> 
                      </div>
                      <div class="col-md-12">
                        <!--
                        <input type="text" class="form-control" id="txtObs" disabled="disabled">-->
                        <textarea class="form-control" rows="2" id="txtObs" disabled="disabled" ></textarea >         
                      </div> 
                  </div>
                  <p></p>
                  <div class="row">
                      <div class="col-md-12"> 
                        <h5>Detalle Otros Conceptos</h5> 
                      </div>
                      <div class="col-md-12">
                        <!--
                        <input type="text" class="form-control" id="txtObs" disabled="disabled">-->
                        <textarea class="form-control" rows="2" id="txtotros_con" disabled="disabled" ></textarea >         
                      </div> 
                  </div>
                    <!--<div class="row">
                      <div class="col-md-4 col-md-offset-4">
                        <button type="button" class="btn btn-default"id="pagoT">Pagar</button>
                      </div>
                    </div>-->
                </div>
              </div>
            </div>
          </div>
        </div>

      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
    <!--<input type="button" class="btn btn-default btn-block" data-toggle="modal" data-target="#myModal" value="Clientes">-->
<div id="modal1" 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">Detalles</h4>
        </div>
        <div class="modal-body">
          <div  id="platillaI"  style="font-family:'Lucida Console', Monaco, monospace;font-size:13px;">
            <h5 align="center"><b>PAGO DE TRANSFERENCIA</b></h5>
            <h6 align="center">(Intercambio)[reimpresion]</h6>
            <table>
              <tr nowrap>================================</tr>
            </table>
            <table>
              <tr>
                <td  valign="top" style="padding-top:10px;"><b>Origen:</b></td>
                <td style="padding-top:10px;"><div style="width:20px;height:20px;"> </div></td>
                <td id="plOri" style="padding-top:10px;" ></td>
              </tr>
              <tr >
                <td  valign="top" style="padding-top:10px;"><b>Beneficiado:</b></td>
                <td style="padding-top:10px;"><div style="width:20px;"> </div></td>
                <td id="plB" style="padding-top:10px;"></td>
              </tr>
              <tr>
                <td  valign="top" style="padding-top:10px;"><b>Remitente:</b></td> 
                <td style="padding-top:10px;"><div style="width:20px;height:15px;"> </div></td>
                <td id="plR" style="padding-top:10px;"></td>
              </tr>
            </table>
            <table>
               <tr>
                <th style="padding-top:10px;">Observaciones:</th> 
              </tr>
              <tr >
                <td id="plObs"></td>
              </tr>
              <tr>
                <th style="padding-top:10px;">Fecha de pago:</th> 
              </tr>
              <tr>
                <td id="fepa"></td>
              </tr>
            </table>
            <table>
              <tr>
                <td><b>Monto:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="plM">0.00</h4></td>
              </tr>
              <tr>
                <td><b>Egreso extra:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="plM_e"></h4></td>
              </tr>
            </table>
            <table>
              <tr>
                <td nowrap>&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
               <tr>
                <td nowrap>__________&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap  style="font-size:12px">Op. {{ nombre_usuario }}</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap>&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap>__________&nbsp;</td>
                <td><div style="width:50px;height:50px;"> </div></td>
                 <td nowrap><div style="margin-top:-40px;width:75px;height:85px;border:1px solid #000;"> </div></td>
              </tr>
              <tr>
                <td nowrap style="font-size:12px"><b>DNI:</b>&nbsp;<b id="idn"></b></td>
                <td>&nbsp;</td>
                <td nowrap></td>
              </tr>
              
            </table>
            <p id ="hopa"></p>
          </div>
        </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><!-- /.modal -->
<div id="modal_movimientos" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <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">Movimiento de Adelantos</h4>
        </div>
        <div class="modal-body">
          <div class="row">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-hover table-bordered">
                    <thead>
                      <tr >
                        <th>#</th>
                        <th>Fecha</th>
                        <th>Pagador</th>
                        <th>N°</th>
                        <th>Saldo Anterior</th>
                        <th>Monto Adelanto</th>
                        <th>Saldo</th>
                        <th>Observaciones</th>
                        <th>Egreso extra</th>
                        <th>Reimpresion</th>
                      </tr>
                    </thead>
                    <tbody id="listaMov">
                    </tbody>
                </table>
              </div>
            </div>
            
          </div>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="modalreA" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-body">
          <div  id="platillaIAde" style="font-family:'Lucida Console', Monaco, monospace;font-size:13px;">
            
            <label align="center"><b>PAGO DE INTERCAMBIO</b></label>
            <h6 align="center"> (Adelanto) reimpresion</h6>
            <table>
              <tr nowrap>================================</tr>
            </table>
            <table>
              <tr>
                <td id="oficinaRecibo5" style="width:100px;">{{ SITE_URL }}</td>
                <td style="padding-top:-10px;"><div style="width:20px;"> </div></td>
                <td style="width:80px; text-align:right;">Nº<span id="nror5"></span></td>
              </tr>
            </table>
            <table>
              <tr>
                <td  valign="top" style="padding-top:10px;"><b>Origen:</b></td>
                <td style="padding-top:10px;"><div style="width:20px;height:20px;"> </div></td>
                <td id="plOri5" style="padding-top:10px;" ></td>
              </tr>
              <tr >
                <td  valign="top" style="padding-top:10px;"><b>Beneficiado:</b></td>
                <td style="padding-top:10px;"><div style="width:20px;"> </div></td>
                <td id="plB5" style="padding-top:10px;"></td>
              </tr>
              <tr>
                <td  valign="top" style="padding-top:10px;"><b>Remitente:</b></td> 
                <td style="padding-top:10px;"><div style="width:20px;height:15px;"> </div></td>
                <td id="plR5" style="padding-top:10px;"></td>
              </tr>
            </table>
            <table>
               <tr>
                <th style="padding-top:10px;">Observaciones:</th> 
              </tr>
              <tr >
                <td id="plObs5"></td>
              </tr>
              <tr>
                <th style="padding-top:10px;">Fecha de pago:</th> 
              </tr>
              <tr>
                <td id="fepa5"></td>
              </tr>
            </table>
            <table>
              <tr>
                <td><b>Saldo Anterior:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="saldoa5">0.00</h4></td>
              </tr>
              <tr>
                <td><b>Monto:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="plM5">0.00</h4></td>
              </tr>
              <tr>
                <td><b>Saldo:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="saldo5">0.00</h4></td>
              </tr>
               <tr>
                <td><b>Egreso extra:</b></td>
                <td><div style="width:30px;height:20px;"> </div></td>
                <td nowrap><h4 id="plM_e5"></h4></td>
              </tr>
            </table>
            <table>
              <tr>
                <td nowrap>&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
               <tr>
                <td nowrap>__________&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap  style="font-size:12px">Op. {{ nombre_usuario }}</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap>&nbsp;</td>
                <td>&nbsp;&nbsp;</td>
                <td nowrap>&nbsp;</td>
              </tr>
              <tr>
                <td nowrap>__________&nbsp;</td>
                <td><div style="width:50px;height:50px;"> </div></td>
                <td nowrap><div style="margin-top:-40px;width:75px;height:85px;border:1px solid #000;"> </div></td>
              </tr>
              <tr>
                <td nowrap><b>DNI:</b>&nbsp;<b id="idn5"></b></td>
                <td>&nbsp;</td>
                <td nowrap></td>
              </tr>
              
            </table>
            <p id ="hopa5"></p>
          </div>
        </div>

      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/JavaScript">
    var Aux="";
    var filaI =0;
    var pagina=1;
    $(document).ready(function(){
      /*$(document).on("click",".detalles",function(){
          var cod = $(this).attr('id');
          showDetalles(cod);
      });*/
      $(document).on('show.bs.modal', '.modal', function () {
          var zIndex = 1040 + (10 * $('.modal:visible').length);
          $(this).css('z-index', zIndex);
          setTimeout(function() {
              $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
          }, 0);
      });
      $(document).on('hidden.bs.modal', '.modal', function () {
          $('.modal:visible').length && $(document.body).addClass('modal-open');
      });
      //----
      $('#txtfecha1').datetimepicker({
        locale: 'es',
        format: 'YYYY-MM-DD'
      });
      $('#txtfecha2').datetimepicker({
        locale: 'es',
        format: 'YYYY-MM-DD'
      });
      //
      $("#div-f1").hide();
      $("#div-f2").hide();
      //
      $("#comboFiltroF").change(function(){
        if($("#comboFiltroF").val()=="ef"){
          $("#div-f1").show();
          $("#txtfecha1").prop("value","");
          $("#div-f2").show();
          $("#txtfecha2").prop("value","");
        }
        if($("#comboFiltroF").val()=="f"){
          $("#txtfecha1").prop("value","");
          $("#div-f1").show();
          $("#txtfecha2").prop("value","");
          $("#div-f2").hide();
        }
        if($("#comboFiltroF").val()=="h"){
          $("#txtfecha1").prop("value","");
          $("#div-f1").hide();
          $("#txtfecha2").prop("value","");
          $("#div-f2").hide();
        }
      });
      //
      $("#buscarF").click(function(){
        ajax_Transferencias();
      })
      //
      ajax_Transferencias();
      $("#RefrescarLista").click(function(){
        ajax_Transferencias();
      });
      

      $("#rimprimir").click(function(){
          $('#platillaI').printThis();
      });
      
      $(document).on("click",".filaTrans",function(){
        var num = $(this).attr('id');
        filaI = num;
        var fila= $(this).attr('class');
        //$("."+fila).attr('class','filaTrans');
        //$("#"+num).attr('class','filaTrans info');
        //insertar datos en modal
        //$('#extornarT').prop('disabled',false);
        //$('#ForzarpagoT').prop('disabled',false);
        //$('#extornarT').show();
        //$('#ForzarpagoT').show();
        //--------------
        $('#txtEstadoTrans').prop("value",Aux[filaI].estado);
        $('#txtDNI').prop("value",Aux[filaI].dni_rmt);
        $('#txtNombres_Soli').prop("value",Aux[filaI].nombre_rmt+" "+Aux[filaI].paterno_rmt +" "+ Aux[filaI].materno_rmt);
        $('#txtNombres_Bene').prop("value",Aux[filaI].nombre_bnf +" "+ Aux[filaI].paterno_bnf +" "+ Aux[filaI].materno_bnf);
        $("#txtN").prop('value',Aux[filaI].dni_bnf);
        $('#txtIDtrans').prop("value",Aux[filaI].id_trans);
        $('#txtFecha').prop("value",Aux[filaI].fecha);
        $('#txtPersonalE').prop("value",Aux[filaI].id_personal);
        $('#txtOficinaOri').prop("value",Aux[filaI].oficina_ori);
        $('#txtMonto').prop("value",Aux[filaI].monto);
        $('#txtComicion').prop("value",Aux[filaI].comicion);
        $('#txtEgresoExtra').prop("value",Aux[filaI].egreso_extra);
        $('#txtObs').prop("value",Aux[filaI].obs);
        $('#txtotros_con').prop("value",Aux[filaI].otros_conceptos);
        $('#txtEgresoExtra').prop("value",Aux[filaI].egreso_extra);
        /*if(Aux[filaI].estado !="activo"){
          //$('#extornarT').prop('disabled',true);
          //$('#ForzarpagoT').prop('disabled',true);
          $('#pagoT').hide();
        }*/
        $("#plB5").text(Aux[filaI].nombre_bnf +" "+ Aux[filaI].paterno_bnf +" "+ Aux[filaI].materno_bnf);
        $("#plR5").text(Aux[filaI].nombre_rmt+" "+Aux[filaI].paterno_rmt +" "+ Aux[filaI].materno_rmt);
        $("#plB").text(Aux[filaI].nombre_bnf +" "+ Aux[filaI].paterno_bnf +" "+ Aux[filaI].materno_bnf);
        $("#plR").text(Aux[filaI].nombre_rmt+" "+Aux[filaI].paterno_rmt +" "+ Aux[filaI].materno_rmt);
         $("#plOri5").text(Aux[filaI].oficina_ori);
        $("#plObs").text(Aux[filaI].obs);
        $("#idn").text(Aux[filaI].dni_bnf);
        $("#fepa").text(Aux[filaI].fecha);
        var mr="";
        if(Aux[filaI].moneda=="soles")
          {
            mr="S/. ";
          }
        else
          {
            mr="$/. ";
        }
        $("#plM").text(mr +String(Aux[filaI].monto));
        $("#plOri").text(Aux[filaI].oficina_ori);
        $("#plM_e").text(Aux[filaI].egreso_extra);
      });
      //otra funcion
      function ocultarmodal(){
        $('#myModal').modal('hide')
      };
      //otra funcion
      function ajax_Transferencias(){
        $('.table-responsive').waitMe({effect : 'progressBar',text : 'Recuperando Datos'});
        $.ajax({
          data:{'pg':pagina,'filtro':$("#comboFiltroF").val(),'F1':$("#txtfecha1").val(),'F2':$("#txtfecha2").val()},
          url:'/listaIntercPagadas_ajax/',
          //async:false,
          type:'GET',
          dataType:'json',
          success: function(data){
            Aux = data;
            var html ="";
            for(var i=0;i<data.length;i++){
              var estado ="";
              if(data[i].estado =="extornado"){
                estado="danger";
              }
              if(data[i].estado=="pagado"){
                estado = "success";
              }
              html += '<tr data-toggle="modal" data-target="#myModal" class="filaTrans '+estado+'" id="'+i+'"><td>'+data[i].nombre_bnf+' '+data[i].paterno_bnf+' '+data[i].materno_bnf+'</td><td><b>'+data[i].monto+'</b></td><td>'+data[i].nombre_rmt+' '+data[i].paterno_rmt+' '+data[i].materno_rmt+'</td><td>'+data[i].fecha+'</td><td>'+data[i].pagador+'</td><td>'+data[i].nroRecibo+'</td><td><b>'+data[i].comicion+'</b></td><td><b>'+data[i].monto_conceptos+'</b></td><td>'+data[i].moneda+'</td><td>'+data[i].obs+'</td><td>'+data[i].otros_conceptos+'</td><td>'+data[i].estado+'</td></tr>';
            }
            $('#listaTransf').html(html);
            $('.table-responsive').waitMe('hide');
          }
        });
      };

        $("#buscar").click(function(){
        $('#listaTransf').html('');
        pagina=1;
        PonerInicioPag();
        ajax_TransferenciasTotal_filtro();
      });

      //
      function ajax_TransferenciasTotal_filtro(){
        $('.table-responsive').waitMe({effect : 'progressBar',text : 'Recuperando Datos'});
        $.ajax({
          data:{'pg':pagina,'filtro':$("#filtro").val()},
          url:'/listaIntercPagadasTotal_filtro_ajax/',
          //async:false,
          type:'GET',
          dataType:'json',
          success: function(data){
            Aux = data;
            var html ="";
            for(var i=0;i<data.length;i++){
              var estado ="";
              if(data[i].estado =="extornado"){
                estado="danger";
              }
              if(data[i].estado=="pagado"){
                estado = "success";
              }
              html += '<tr data-toggle="modal" data-target="#myModal" class="filaTrans '+estado+'" id="'+i+'"><td>'+data[i].nombre_bnf+' '+data[i].paterno_bnf+' '+data[i].materno_bnf+'</td><td><b>'+data[i].monto+'</b></td><td>'+data[i].nombre_rmt+' '+data[i].paterno_rmt+' '+data[i].materno_rmt+'</td><td>'+data[i].fecha+'</td><td>'+data[i].pagador+'</td><td style="color:#2e6da4;font-size:16px;font-weight:bold;">'+data[i].oficina_ori+'</td><td>'+data[i].nroRecibo+'</td><td><b>'+data[i].comicion+'</b></td><td><b>'+data[i].monto_conceptos+'</b></td><td>'+data[i].moneda+'</td><td>'+data[i].obs+'</td><td>'+data[i].otros_conceptos+'</td><td>'+data[i].estado+'</td></tr>';
            }
            $('#listaTransf').html(html);
            $('.table-responsive').waitMe('hide');
          }
        });
      };
      
      $("#adelanto").click(function(){
        ajax_intercambios_adelanto()
      })
      function ajax_intercambios_adelanto(){
        $('.table-responsive').waitMe({effect : 'progressBar',text : 'Recuperando Datos'});
        $.ajax({
          data:{'pg':pagina},
          url:'/listaIntercPagadasadelanto_ajax/',
          //async:false,
          type:'GET',
          dataType:'json',
          success: function(data){
            Aux = data;
            var html ="";
            for(var i=0;i<data.length;i++){
              var estado ="";
              if(data[i].estado =="extornado"){
                estado="danger";
              }
              if(data[i].estado=="pagado"){
                estado = "success";
              }
              html += '<tr data-toggle="modal" data-target="#myModal" class="filaTrans '+estado+'" id="'+i+'"><td>'+data[i].nombre_bnf+' '+data[i].paterno_bnf+' '+data[i].materno_bnf+'</td><td><b>'+data[i].monto+'</b></td><td>'+data[i].nombre_rmt+' '+data[i].paterno_rmt+' '+data[i].materno_rmt+'</td><td>'+data[i].fecha+'</td><td>'+data[i].pagador+'</td><td style="color:#2e6da4;font-size:16px;font-weight:bold;">'+data[i].oficina_ori+'</td><td>'+data[i].nroRecibo+'</td><td><b>'+data[i].comicion+'</b></td><td><b>'+data[i].monto_conceptos+'</b></td><td>'+data[i].moneda+'</td><td>'+data[i].obs+'</td><td>'+data[i].otros_conceptos+'</td><td>'+data[i].estado+'</td></tr>';
            }
            $('#listaTransf').html(html);
            $('.table-responsive').waitMe('hide');
          }
        });
      };

      function PonerInicioPag(){
          $(".pag").attr('class','pag');
          $("#pag1").attr('class','active pag');
          $("#pg1").text(1);
          $("#pg2").text(2);
          $("#pg3").text(3);
          $("#pg4").text(4);
          $("#pg5").text(5);
      };
      //
      $(".pag").click(function(){
        $(".pag").attr('class','pag');
        $(this).attr('class','active pag');
        pagina = $(this).text();
        ajax_Transferencias();
      })
      $("#ant").click(function(){
        var pag = $("#pg1").text();
        pag= parseInt(pag);
        if(pag>1){
          $("#pg1").text(pag-1);
          pag= $("#pg2").text();
          pag= parseInt(pag);
          $("#pg2").text(pag-1);
           pag= $("#pg3").text();
          pag= parseInt(pag);
          $("#pg3").text(pag-1);
           pag= $("#pg4").text();
          pag= parseInt(pag);
          $("#pg4").text(pag-1);
           pag= $("#pg5").text();
          pag= parseInt(pag);
          $("#pg5").text(pag-1);
        }
      });
      $("#pos").click(function(){
        var pag = $("#pg1").text();
        pag= parseInt(pag);
        $("#pg1").text(pag+1);
        pag = $("#pg2").text();
        pag= parseInt(pag);
        $("#pg2").text(pag+1);
        pag = $("#pg3").text();
        pag= parseInt(pag);
        $("#pg3").text(pag+1);
        pag = $("#pg4").text();
        pag= parseInt(pag);
        $("#pg4").text(pag+1);
        pag = $("#pg5").text();
        pag= parseInt(pag);
        $("#pg5").text(pag+1);
      });
      //------------     adelantos mov      -----------
    $("#movi").click(function(){
      ajax_movimientosAdelanto(Aux[filaI].id_trans);
    });
    function ajax_movimientosAdelanto(idI){
      $('#listaMov').html("");
      $.ajax({
        data:{'idI':idI},
        url:'/adelantos_intercambio_ajax/',
        //async:false,
        type:'GET', 
        dataType:'json',
        success: function(data){
          Aux_movi=data;
          var html ="";
          for(var i=0;i<data.length;i++){
            html += '<tr ><th scope="row">'+(i+1)+'</th><td><b>'+data[i].f+'</b></td><td>'+data[i].p+'</td><td>'+data[i].nroR+'</td><td>'+data[i].saldoa+'</td><td><b>'+data[i].monto+'</b></td><td>'+data[i].saldo+'</td><td>'+data[i].obs+'</td><td>'+data[i].egreso+'</td><td><button type="button" class="btn btn-success btn-xs btn-reimp" id="'+i+'"> Reimprimir </button></td></tr>';
          }
          $('#listaMov').html(html);
          $(".btn-reimp").click(function(){
            var indice = $(this).prop('id');
            $("#nror5").text(Aux_movi[indice].nroR);
            $("#saldoa5").text(Aux_movi[indice].saldoa);
            $("#plM5").text(Aux_movi[indice].monto);
            $("#saldo5").text(Aux_movi[indice].saldo);
            $("#plObs5").text(Aux_movi[indice].obs);
            $("#fepa5").text(Aux_movi[indice].f);
            $('#platillaIAde').printThis();
            //alert(idOficina);
          })
        }
      });
    };
    //-----------------------------------------------
    });
</script>
{% endblock content1 %}
