Files

181 lines
5.5 KiB
PHP
Raw Permalink Normal View History

<?php
require_once __DIR__.'/auth_guard.php';
include '../config.php';
session_name($CFG->sessionname);
session_start();
if(!isset($_SESSION['usersession'])){
header("Location: ".$CFG->wwwroot);
}
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
?>
<div class="col-12 text-primary mt-3">
<h1>Reporte categoría</h1>
</div>
<div class="col-12 text-left my-5">
<a target="_blank" href="reporteExportCategoria.php?key=<?php echo generateRandomString(); ?>" class="p-3 btn-primary text-white btn-descarga">Descargar Reporte</a>
</div>
<div class="col-12">
<table class="table table-striped table-bordered" style="width:100%; display: block;" id="estafetatable3">
<thead>
<tr>
<th>Periodo</th>
<th>Estado del empleado</th>
<th>Número de empleado</th>
<th>Nombres(s)</th>
<th>Apellidos</th>
<th>Posición</th>
<th>Sociedad</th>
<th>División</th>
<th>Unidad organizativa</th>
<th>CeCo</th>
<th>Distrito</th>
<th>Centro de trabajo</th>
<th>Supervisor</th>
<th>Categoría</th>
<th>Tema</th>
<th>Estado</th>
</tr>
</thead>
<tbody>
<tr class="text-center"><td colspan="17">Procesando...</td></tr>
</tbody>
<tfoot>
<th>Periodo</th>
<th>Estado del empleado</th>
<th>Número de empleado</th>
<th>Nombres(s)</th>
<th>Apellidos</th>
<th>Posición</th>
<th>Sociedad</th>
<th>División</th>
<th>Unidad organizativa</th>
<th>CeCo</th>
<th>Distrito</th>
<th>Centro de trabajo</th>
<th>Supervisor</th>
<th>Categoría</th>
<th>Tema</th>
<th>Estado</th>
</tfoot>
</table>
</div>
<script type="text/javascript">
extractData();
function extractData(){
$(".layer-load").show();
var dataSet = [];
$.ajax({
url: 'reporte_getCategoria.php'
})
.done(function (data) {
var _data = JSON.parse(data);
console.log(_data.columns);
//$.each(_data.data, function (index, val) {
//dataSet[index] = [val['fecha'],val['estado_empleado'],val['numempl'],val['user'],val['apellidos'],val['posicion'],val['sociedad'],val['division'],val['unidad_organizativa'],val['ceco'],val['nomdistrito'],val['nomcentro'],val['supervisor'],val['nomcat'],val['nomcurso'],val['subtema'],val['estado']];
//});
$('#estafetatable3 tbody').empty();
$('#estafetatable3').DataTable({
dom: "Bfrtip",
buttons: [
//'pageLength',
{
extend: 'excel',
exportOptions: {
columns: ':visible'
},
autoFilter: true,
title: 'Reporte por categoría - Estafeta',
sheetName: 'Reporte general',
text: 'Exportar a Excel'
},
'colvis'
],
"language": {
"url": "../json/Spanish.json"
},
'order': [
[2, 'desc'],
[0, 'asc']
],
"responsive": true,
data: _data.data,
columns: [
{ title: "Periodo" },
{ title: "Estado del empleado" },
{ title: "Número de empleado" },
{ title: "Nombre(s)" },
{ title: "Apellidos" },
{ title: "Posición" },
{ title: "Sociedad" },
{ title: "División" },
{ title: "Unidad organizativa" },
{ title: "CeCo" },
{ title: "Distrito" },
{ title: "Centro de trabajo" },
{ title: "Supervisor" },
{ title: "Categoría" },
{ title: "Tema" },
{ title: "Estado" }
]
});
$("#estafetatable3").show();
$(".layer-load").hide();
})
.fail(function () {
})
.always(function () {
});
}
/*
var table = $('#estafetatable').DataTable({
responsive: true,
"language": {
"url": "../json/Spanish.json"
},
"initComplete": function (settings, json) {
$('div.load').remove();
$(".nooverflow").removeClass('nooverflow');
$("#estafetatable").show();
},
columnDefs: [
{ targets: 'no-sort', orderable: false }
],
"processing": true,
"serverSide": true,
"ajax": {
url: "reporte_getDataDate.php",
type: "post"
}
});
*/
</script>