<?php
$page_title = 'Listado de Produccion M.I.';
require_once('../../includes/load.php');
// Checkin What level user has permission to view this page
page_require_level(5);
?>
<?php include_once('../../layouts/header.php'); ?>
<div class="row">
 <div class="col-md-12">
   <?php echo display_msg($msg); ?>
 </div>
<div class="col-md-16">
  <div class="panel panel-default">
    <div class="panel-heading clearfix">
        <strong>
          <span class="glyphicon glyphicon-cog"></span>
          <span>Listado de Produccion M.I.</span> 
        </strong>
        <div class="pull-right">
            <a href="maquinaria.php" class="btn btn-primary" id="maquinaria"><i class="glyphicon glyphicon-plus"></i>Produccion</a>
            <a href="../reportes/listadomi.php" class="btn btn-success"><i class="fi fi-sr-tractor"></i>Produccion MI</a>
        </div>
    </div>
    <div class="col-12">          
                <div class="panel-body">
                <table class="table table-bordered table-striped"  id="mytable">
                    <thead>
                        <tr>
                            <th style="text-align: center; padding-right: 10px;">Produccion</th>
                            <th style="text-align: center; padding-right: 10px;">Operacion</th>
                            <th style="text-align: center; padding-right: 10px;">Registro</th>
                            <th style="text-align: center; padding-right: 10px;">Ejecucion</th>
                            <th style="text-align: center; padding-right: 10px;">Maquinaria</th>
                            <th style="text-align: center; padding-right: 10px;">Horas</th>
                            <th style="text-align: center; padding-right: 10px;">Implemento</th>
                            <th style="text-align: center; padding-right: 10px;">Granja</th>
                            <th style="text-align: center; padding-right: 10px;">Servicio</th>
                            <th style="text-align: center; padding-right: 10px;">Opciones</th>
                        </tr>
                    </thead>
                </table>
            </div>
    </div>
  </div>
</div>
</div>
<?php include_once('../../layouts/footer.php'); ?>
<script>
$( document ).ready(function() {
var user_level = '<?= remove_junk($user['user_level'])?>';
var table = $('#mytable').dataTable({
          responsive: true,
          deferRender: true,
          columnDefs: [{
                "defaultContent": "-",
                "targets": "_all"
              }],
          dom: '<"row"<"col-sm-12 col-md-4"l><"col-sm-12 col-md-4"<"dt-buttons btn-group flex-wrap"B>><"col-sm-12 col-md-4"f>>t<"row"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>',
              buttons: [
                'copyHtml5',
                'excelHtml5',
                'csvHtml5',
             ],
         "autoWidth": false,
         "bProcessing": true,
         "aLengthMenu": [[7, 10, 25, 50, -1], [7, 10, 25, 50, "All"]],
         "language":{
            "lengthMenu": "Mostrar _MENU_ registros por pagina",
            "info": "Mostrando pagina _PAGE_ de _PAGES_",
            "infoEmpty": "No hay registros disponibles",
            "infoFiltered": "(filtrada de _MAX_ registros)",
            "loadingRecords": "Cargando...",
            "processing":     "Procesando...",
            "search": "Buscar:",
            "zeroRecords":    "No se encontraron registros coincidentes",
            "paginate": {
                "next":       "Siguiente",
                "previous":   "Anterior"
            },  
         },
         "sAjaxSource": "data/data.php",
          "bPaginate":true,
          "iDisplayLength": 7,
          "order": [[0, "ASC"]],
         "aoColumns": [
                { mData:'IdProduccionMI'},
                { mData:'id'}, 
                { mData:'FechaRegistroUsuario'},
                { mData:'FechaRegistroProduccionMI'},
                { mData:'NombreActivo'},
                { mData:'HorasProduccion'}, 
                { mData:'NombreImplemento'}, 
                { mData:'GNombre'},
                { mData:'NombreTipoServicioMI'}, 
                { 
                   "render": function (data, type, full, row) {
                        if ( user_level === '2' || user_level === '4'  || user_level === '5') {
                            return '<center> <a style="margin-right: 3pt" href="view_maquinaria.php?id='+ full.IdProduccionMI +'" class="btn btn-xs btn-warning" title="Ver"><span class="glyphicon glyphicon-eye-open"></span></a></center>';
                        }else{
                            return '<center><a style="margin-right: 3pt" href="edit_maquinaria.php?id='+ full.IdProduccionMI +'" class="btn btn-xs btn-danger confirmEditar"  title="Editar"><span class="glyphicon glyphicon-pencil"></span></a>         <a style="margin-right: 3pt" href="view_maquinaria.php?id='+ full.IdProduccionMI +'" class="btn btn-xs btn-warning" title="Ver"><span class="glyphicon glyphicon-eye-open"></span></a></center>'; 
                        }
                                                    
                   }

                }    
                           
        ]


}); 

});
 //VISUALIZAR CAMPOS DEPENDIENDO AL USUARIO QUE ENTRA 
 var maquinaria = document.getElementById("maquinaria");

 var user_level = '<?= remove_junk($user['user_level'])?>';

 if ( user_level === '2' || user_level === '4'  || user_level === '5') {
// O bien, para esconderlo
maquinaria.style.display = "none";
 }
</script>