{% extends "baseAdmin.html" %}
{% load static %}
{% block titulo %}
  .::Depositos Material
{% endblock titulo %}
{% block content1 %}
    <div class="container">
      <script type="text/javascript">
        $("#navCajaMaterial").attr('class','dropdown active');
        $("#navListadoEnviosMaterial").attr('class','active');
      </script>
     <form>
        <div class="row">
          <div class="col-md-12 col-sm-12" >
              <div class="card">
                <div class="card-head card-head-xs style-default"> <strong>DEPOSITOS MATERIAL</strong></div>
                <div class="card-body">
                  <div class="row" align="center">
                    <img id="loader_gif" src="{% static 'img/load.gif' %}" style=" display:none;"/>
                  </div>
                  <div class="row" >
                    <h4 class="bg-success" align="center" id="ExitoCambiar">
                    </h4>
                  </div>
                  <div class="row">
                    <div class="col-md-2 col-md-offset-1">
                      <button type="button" class="btn btn-block btn-primary" id="btnRefrescar"><span class="fa fa-refresh"></span> Actualizar</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_Deposito();
                              $(document).on("click",".filaDep",function(){
                                var num = $(this).attr('id');
                                filaI = num;
                                var fila= $(this).attr('class');
                                $("."+fila).attr('class','filaDep');
                                $("#"+num).attr('class','filaDep info');
                              });
                              $("#btnRefrescar").click(function(){
                                ajax_Deposito();
                              });
                              function ajax_Deposito(){
                                $.ajax({
                                  url:'/DepositoMaterial_ajax/',
                                  type:'GET',
                                  dataType:'json',
                                  success: function(data){
                                    Aux = data;
                                    var html ="";
                                    var esta='';
                                    for(var i=0;i<data.length;i++){
                                      if (data[i].c_estado){
                                        esta='activo';
                                      }
                                      else{
                                        esta='desactivo';
                                      }
                                        html += '<tr data-toggle="modal" data-target="#myModal" class="filaDep" id="'+i+'"><th scope="row">'+(i+1)+'</td><td>'+data[i].c_nombre+'</td><td>'+esta+'</td><td>'+data[i].p_encargado+'</td><td>'+data[i].fecha +'</td><td>'+data[i].pesoGramos+'</td></tr>';
                                    }                        
                                    $('#listaDep').html(html);
                                  }
                                });
                              }
                            });
                          </script>
                         
                          <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                  <tr>
                                    <th>Nro</th>
                                    <th>Caja</th>
                                    <th>Estado Caja</th>
                                    <th>Encargado</th>
                                    <th>Fecha Deposito</th>
                                    <th>Peso Gramo</th>
                                  </tr>
                                </thead>
                                <tbody id="listaDep">
                                    
                                </tbody>
                            </table>
                          </div>
                      </div>
                    </p>
                  </div>
                  <br>
                  <div class="row">
                    <div class="col-md-10 col-md-offset-1" align="center">
                      <nav>
                        <ul class="pagination">
                          <li>
                            <a href="#" aria-label="Previous">
                              <span aria-hidden="true">&laquo;</span>
                            </a>
                          </li>
                          <li class="active"><a href="#">1</a></li>
                          <li><a href="#">2</a></li>
                          <li><a href="#">3</a></li>
                          <li><a href="#">4</a></li>
                          <li><a href="#">5</a></li>
                          <li>
                            <a href="#" aria-label="Next">
                              <span aria-hidden="true">&raquo;</span>
                            </a>
                          </li>
                        </ul>
                      </nav>
                    </div>
                  </div>
                </div>
              </div>
          </div>
        </div>
      </form>
    </div>
{% endblock content1 %}