{% extends "base.html" %}
{% load static %}
{% block titulo %}
Saldo de Cajas
{% endblock titulo %}
{% block content1 %} 
      <script type="text/javascript">
        $("#navIE").attr('class','dropdown active');
        $("#navCsaldo").attr('class','active');
      </script>
      <form action="">
        <!--<div class="row"><br><br><br><br></div>-->
        <div class="row">
          <div class="col-md-12" >
              <div class="panel panel-default">
                <div class="panel-heading panel-toolbar"> 
                  <strong>SALDO CAJA</strong>
                  <button type="button" class="btn btn-default btn-sm" id="btnRefrescar"><span class="fa fa-refresh"></span> Actualizar</button>
                </div>
                <div class="panel-body">
                  <div class="row">
                      <div class="col-md-12">
                          
                          <div class="table-responsive">
                            <table class="table table-hover">
                               <thead>
                                  <tr>
                                    <th colspan="2">Detalle Caja</th>
                                    <th colspan="2">Caja Transferencias</th>
                                    {% ifequal cajaDo 'si' %}
                                    <th colspan="2" class="info">Caja Dolar</th>
                                    {% endifequal %}
                                    {% if tipoSis ==  'material' or tipoSis ==  'hibrido'  %} 
                                    <th colspan="3" class="warning">Caja Material</th>
                                    {% endif %}
                                    <th>Estado</th>
                                  </tr>
                                  <tr>
                                    <th>Nombre</th>
                                    <th>Operador</th>
                                    <th>Saldo Soles</th>
                                    <th>Saldo Dolares</th>
                                    {% ifequal cajaDo 'si' %}
                                    <th class="info">Saldo Soles</th>
                                    <th class="info">Saldo Dolares</th>
                                    {% endifequal %}
                                    {% if tipoSis ==  'material' or tipoSis ==  'hibrido'  %}
                                    <th class="warning">Saldo Soles</th>
                                    <th class="warning">Saldo Dolares</th>
                                    <th class="warning">Saldo Material</th>
                                    {% endif %}
                                    <th>Estado</th>
                                  </tr>
                                </thead>
                                <tbody id="listaCa">
                                </tbody>
                            </table>
                          </div>
                      </div>
                  </div>
                  <br>
                </div>
              </div>
          </div>
        </div>
      </form>
<script type="text/javascript">
  $(document).ready(function () {
    ajax_caja();
    $("#btnRefrescar").click(function(){
      ajax_caja();
    });
    function ajax_caja(){
      $('.table-responsive').waitMe({effect : 'progressBar',text : 'Recuperando Datos'});
      $.ajax({
        url:'/caja_saldo_admin_ajax/',
        type:'GET',
        dataType:'json',
        success: function(data){
          Aux3 = data;
          var html ="";
          var html_do ="";
          var html_ma ="";
          var esta= '';
          var sty= '';
          for(var i=0;i<data.length;i++){

              if(data[i].c_estado)
                {
                  esta='activo';
                  sty='';
                }
              else
                {
                  sty='danger';
                  esta='desactivo';
                };
              {% ifequal cajaDo 'si' %}
              html_do='<td>'+data[i].saldo_soles_do+'</td>'+'<td>'+data[i].saldo_dolares_do+'</td>';
              {% endifequal %}
              {% if tipoSis ==  'material' or tipoSis ==  'hibrido'  %} 
               html_ma='<td>'+data[i].saldo_soles_ma+'</td>'+'<td>'+data[i].saldo_dolares_ma+'</td>'+ '<td>'+data[i].saldo_material_ma+'</td>';
              {% endif %}
              html += '<tr class="filaCa '+sty+'" id="'+i+'"><td>'+data[i].c_nombre+'</td><td>'+data[i].p_nombre+' '+data[i].p_ap+' '+data[i].p_am+'</td><td>'+data[i].saldo_soles+'</td><td>'+data[i].saldo_dolares+'</td>'+html_do+html_ma+'<td>'+esta+'</td></tr>';


          }                        
          $('#listaCa').html(html);
          $('.table-responsive').waitMe('hide');
        }
      });
    };
  });
</script>
{% endblock content1 %}