


<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Producto con Mayor Rotacion</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="inicio">Inicio</a></li>
              <li class="breadcrumb-item active">Rotacion de Producto</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">

      <!-- Default box -->
      <div class="card">
 
        <div class="card-body">

            <div class="row">
              <div class ="col-6">
                <table class="table table-bordered table-striped dt-responsive tablaRotacion" style="font-size:90%; line-height:12px ">
                
                <thead>
                  
                  <tr>
                    <th>Codigo</th>
                    <th>Imagen</th>
                    <th>Cant Ventas</th>
                    <th>Producto</th>
                    <th>Categoria</th>
                    <th>Porcentaje</th>
                  </tr> 
                </thead>
                <tbody>
                <?php

        
                    $item = null;
                    $valor = null;
                    $orden = "ventas";
                    $productos = ControladorProductos::ctrMostrarProductos1($item, $valor, $orden);
                    $totalVentas = ControladorProductos::ctrMostrarSumaVentas();
                  foreach ($productos as $key => $value) {
                      echo' <tr>';
                            echo' <td>'.$value["codigo"].'</td>';
                            echo' <td><img src='.$value["imagen"].' class="img-thumbnail" width="40px"> </td>';
                            echo'<td>'.$value["ventas"].'</td>
                                <td>'.$value["descripcion"].'</td>';
                                $item1 = "id";
                                $valor1 = $value["id_categoria"];
                                $categorias = ControladorCategorias:: ctrMostrarCategorias($item1, $valor1);
                              echo'<td>'.$categorias["categoria"].'</td>';
                              echo'
                                    <td>'.ceil($value["ventas"]*100/$totalVentas["total"]).'%</td>

                            </tr>';
                      
                    }

                  ?>
                  
                </tbody>
                </table>

              </div>
              <div class ="col-6">

              <div class="">
                
                <?php

                include "reportes/productos-mas-vendidos.php";

                ?>

              </div>

              </div>
            </div>
        </div>

        <!-- /.card-body -->
      </div>
      <!-- /.card -->

    </section>
    <!-- /.content -->
  </div>

    <!-- <div class="row">
          <div  class="col-6">

          </div>

        <div class="col-6">
          
          <?php

          //include "reportes/grafico-kardexproducto.php";

          ?>
        </div>
    </div> -->

  </div>
</div>

  <script>
      
      var elemento = document.getElementById("utilidades");
      elemento.className += " active";

      var elemento = document.getElementById("utilidad");
      elemento.className += " menu-open";

      var elemento = document.getElementById("Rotacion");
      elemento.className += " active";

      var rotacion = $('.tablaRotacion').DataTable({
  "autoWidth": false,
  "stateSave":  true,
  "deferRender":true,
  "retrieve":true,
  "processing": false,
  "processing": false,
  "sScrollY": "70vh",
  "scrollCollapse":true,
  "paging":false,
  "colReorder": true,
  "language": {

          "decimal": "",
          "sEmptyTable": "No hay información",
          "sInfo": "Mostrando _START_ a _END_ de _TOTAL_ Entradas",
          "sInfoEmpty": "Mostrando 0 to 0 of 0 Entradas",
          "sInfoFiltered": "(Filtrado de _MAX_ total entradas)",
          "sInfoPostFix": "",
          "sInfoThousands": ",",
          "sLengthMenu": "Mostrar _MENU_ Entradas",
          "sLoadingRecords": "Cargando...",
          "sProcessing": "Procesando...",
          "sSearch": "Buscar:",
          "sZeroRecords": "Sin resultados encontrados",
          "oPaginate": {
              "sFirst": "Primero",
              "sLast": "Ultimo",
              "sNext": "Siguiente",
              "sPrevious": "Anterior"
          },
          "oAria": {
              "sSortAscending": ": Activar para ordenar la columna de manera ascendete",
              "sSortDescending": ": Activar para ordenar la columna de manera descendete",
          }
      },
      "dom": "Bfrtilp",
              "buttons": [
                  {
                      "extend": "pdfHtml5",
                      "download": "open",
                      "text": "<i class='fas fa-file-pdf'></i>",
                      "titleAttr" : "Exportar a pdf",
                      "className": 'btn btn-danger',
                      "filename" : function() {
                          return "Kardex"      
                        },      
                      "customize": function(doc) {
                          doc.defaultStyle.fontSize = 8; 
                          doc.defaultStyle.alignment = 'justify'
                          
                       
                      },
                       "exportOptions": {
                          "columns": ["0","1","2","3","4","5"],
                          "page": 'current'
                      },
                      "footer": true

                  },
                  {
                    "extend": "excel",
                    "text": "<i class='fas fa-file-excel'></i>",
                    "titleAttr" : "Exportar a Excel",
                    "className": 'btn btn-success',
                    "filename": function() {
                      return "Rotacion"      
                      },
                    "exportOptions": {
                      "columns": ["0","1","2","3","4","5"]
                    }
                  }
              ]
      
});

</script>

