{% extends "baseAdmin.html" %}
{% load static %}
{% block titulo %}
  .:: Listado Envio de Dinero
{% endblock titulo %}
{% block content1 %} 
<script type="text/javascript">
</script>
<div class="row">
  <div class="col-md-12 col-sm-12" >
      <div class="panel panel-default">
        <div class="panel-heading"> <strong>LISTADO DE ENVIOS DE DINERO POR COBRAR</strong></div>
        <div class="panel-body">
           <div class="row" >
            <h4 class="bg-success" align="center" id="ExitoMensaje">
            </h4>
          </div>
          <div class="row">
              <div class="col-md-2 col-xs-4">
                <button type="button" class="btn btn-warning btn-block btn-sm" id="btnRefrescar">Actualizar</button>
              </div>
          </div>
          <p></p>
          <div class="row">
              <div class="col-md-12">
                  <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">Detalles</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"> <h5>Detalle de Envio Recibido</h5></div>
                                    <div class="panel-body">
                                      <div class="row">
                                        <div class="col-md-12">
                                          <p class="bg-success" align="center">
                                            &nbsp;
                                          </p>
                                        </div>
                                      </div>
                                      <p></p>
                      
                                      <div class="row">
                                          <div class="col-md-4 col-md-offset-1" > 
                                            <h5>Fecha</h5> 
                                          </div>
                                          <div class="col-md-4">
                                            <input type="text" class="form-control" id="txtFecha" disabled="disabled">         
                                          </div> 
                                          <div class="col-md-2 col-md-offset-1">
                                            <input type="text" class="form-control" id="txtpk" disabled="disabled"> 
                                          </div>
                                      </div>
                                      <p></p>
                                      <div class="row">
                                          <div class="col-md-4 col-md-offset-1" > 
                                            <h5>concepto</h5> 
                                          </div>
                                          <div class="col-md-6">
                                            <input type="text" class="form-control" id="txtcon" disabled="disabled">         
                                          </div> 
                                      </div>
                                      <p></p>
                                      <div class="row">
                                          <div class="col-md-4 col-md-offset-1"> 
                                            <h5>Monto</h5> 
                                          </div>
                                          <div class="col-md-6">
                                            <input type="text" class="form-control" id="txtmonto" disabled="disabled">         
                                          </div> 
                                      </div>
                                      <p></p>
                                      <div class="row">
                                          <div class="col-md-4 col-md-offset-1"> 
                                            <h5>moneda</h5> 
                                          </div>
                                          <div class="col-md-4">
                                            <input type="text" class="form-control" id="txtmoneda" disabled="disabled">         
                                          </div> 
                                      </div>
                                      <p></p>
                                      <div class="row">
                                          <div class="col-md-4 col-md-offset-1" > 
                                            <h5>Observaciones</h5> 
                                          </div>
                                          <div class="col-md-4">
                                            <input type="text" class="form-control" id="txtObs" disabled="disabled">         
                                          </div> 
                                      </div>
                              
                                    </div>
                                  </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><!-- /.modal -->
                  
                  <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                          <tr>
                            <th>Nro</th>
                            <th>Fecha</th>
                            <th>Origen</th>
                            <th>Destino</th>
                            <!--<th>Concepto</th>-->
                            <th>Monto</th>
                            <th>Moneda</th>
                            <th>Observaciones</th>
                            <th>Estado</th>
                          </tr>
                        </thead>
                        <tbody id="listaC">
                            
                        </tbody>
                    </table>
                  </div>
              </div>
          </div>
          <br>
          <br>
        </div>
      </div>
  </div>
</div>
<script type="text/JavaScript">
    var Aux="";
    var filaI =0;
    $(document).ready(function(){
      $(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');
      });
      $(document).on("click",".filaC",function(){
        var num = $(this).attr('id');
        filaI = num;
        //--------------
        if(Aux[filaI].act =="si"){
          $("#anular").show();
        }
        else{
          $("#anular").hide();
        }
        //
        $('#txtFecha').prop("value",Aux[filaI].fecha);
        $('#txtpk').prop("value",Aux[filaI].pk);
        $('#txtcon').prop("value",Aux[filaI].concepto);
        $('#txtmonto').prop("value",Aux[filaI].monto);
        $('#txtmoneda').prop("value",Aux[filaI].moneda);
        $('#txtObs').prop("value",Aux[filaI].obs);
        $("#f").text(Aux[filaI].fecha);
        $("#con").text(Aux[filaI].concepto);
        //$("#mon").text(Aux[filaI].monto);
        //$("#mone").text(Aux[filaI].moneda);
        $("#ob").text(Aux[filaI].obs);
        var mr='';
        if(Aux[filaI].moneda=="soles")
          {
            mr="S/. "
          }
        else
          {
            mr="$/. "
          }
        $("#mon").text(mr+Aux[filaI].monto);
      });
      ajax_SaldoEnviado();
      $("#btnRefrescar").click(function(){
        ajax_SaldoEnviado();
      });
      //
      function ajax_SaldoEnviado(){
        $('.table-responsive').waitMe({effect : 'progressBar',text : 'Recuperando Datos'});
        $.ajax({
          url:'/listaSaldoEnviado_activos_total_ajax/',
          type:'GET',
          dataType:'json',
          success: function(data){
            Aux= data;
            var html ="";
            for(var i=0;i<data.length;i++){
                var estado ="";
                if(data[i].est=="recibido"){
                  estado = "success";
                }
                if(data[i].est=="anulado"){
                  estado = "danger";
                }
                html += '<tr class="filaC '+estado+'" data-toggle="modal" data-target="#myModal"' +' id="'+i+'"><th scope="row">'+(i+1)+'</td><td>'+data[i].fecha+'</td><td>'+data[i].ori+'</td><td>'+data[i].des+'</td><td>'+data[i].monto +'</td><td>'+data[i].moneda+'</td><td>'+data[i].obs+'</td><td>'+data[i].est+'</td></tr>';
            }                        
            $('#listaC').html(html);
            $('.table-responsive').waitMe('hide');

          }
        });
      }
      //
      
     //-------------------
    });
</script>
{% endblock content1 %}
