<?php
$page_title = 'Listado de Implemento';
require_once('../../includes/load.php');
// Checkin What level user has permission to view this page
page_require_level(3);
?>
<?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 Implemento</span> 
        </strong>
        <div class="pull-right">
            <a href="implemento.php" class="btn btn-primary" id="implemento"><i class="glyphicon glyphicon-plus"></i>Implemento</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;">Id</th>
                            <th style="text-align: center; padding-right: 10px;">Propietario</th>
                            <th style="text-align: center; padding-right: 10px;">Nombre</th>
                            <th style="text-align: center; padding-right: 10px;">Marca</th>
                            <th style="text-align: center; padding-right: 10px;">Modelo</th>
                            <th style="text-align: center; padding-right: 10px;">Placa</th>
                            <th style="text-align: center; padding-right: 10px;">Estado</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:'id'},
                { mData:'RazonSocial'}, 
                { mData:'NombreImplemento'},
                { mData:'MarcaImplemento'},
                { mData:'ModeloImplemento'},
                { mData:'PlacaImplemento'},  
                { mData:'EstadoActivoMI'},
                { 
                   "render": function (data, type, full, row) {
                        if ( user_level === '2') {
                            return '<center><a style="margin-right: 3pt" href="view_implemento.php?id='+ full.id +'" class="btn btn-xs btn-warning" title="Ver"><span class="glyphicon glyphicon-eye-open"></span></a></center>';
                        }
                            return '<center><a style="margin-right: 3pt" href="edit_implemento.php?id='+ full.id +'" class="btn btn-xs btn-danger confirmEditar"  title="Editar"><span class="glyphicon glyphicon-pencil"></span></a>         <a style="margin-right: 3pt" href="view_implemento.php?id='+ full.id +'" 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 implemento = document.getElementById("implemento");

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

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