364 lines
11 KiB
PHP
364 lines
11 KiB
PHP
|
|
<?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ías completadas</h1>
|
||
|
|
</div>
|
||
|
|
<!--
|
||
|
|
<div class="col-12 text-left my-5">
|
||
|
|
<a target="_blank" href="reporteExportCategoria_completada.php?key=<?php echo generateRandomString(); ?>" class="p-3 btn-primary text-white btn-descarga">Descargar reporte completo</a>
|
||
|
|
</div>
|
||
|
|
-->
|
||
|
|
<div class="filter col-lg-12 col-md-12 col-12 mt-4 mb-5" style="display: block;">
|
||
|
|
<label>Selecciona un rango o el estado de los usuarios</label>
|
||
|
|
<form class="row">
|
||
|
|
<div id="daterangecat" class="daterange form-control pull-left col-lg-4 col-sm-4 col-12 mr-2 mb-2">
|
||
|
|
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
|
||
|
|
<span></span> <b class="caret"></b>
|
||
|
|
</div>
|
||
|
|
<input type="hidden" class="form-control col-lg-2 col-md-2 col-6 mb-2 mr-sm-2" placeholder="Fecha inicio" id="fechaini-cat" name="fechaini-cat">
|
||
|
|
<input type="hidden" class="form-control col-lg-2 col-md-2 col-6 mb-2 mr-sm-2" placeholder="Fecha fin" id="fechafin-cat" name="fechafin-cat">
|
||
|
|
|
||
|
|
<select class="form-control col-lg-3 col-md-3 col-12 mb-2 mr-sm-2" id="filestadouser-cat" name="filestadouser-cat">
|
||
|
|
<option value="all">Todos</option>
|
||
|
|
<option value="1" selected>Activo</option>
|
||
|
|
<option value="0">Baja</option>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select class="form-control col-lg-3 col-md-3 col-12 mb-2 mr-sm-2" id="filcategoriauser-cat" name="filcategoriauser-cat">
|
||
|
|
<option value="1" selected>Activo</option>
|
||
|
|
<option value="0">Baja</option>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<button type="button" class="btn_download btn btn-primary mb-2 mr-3">Descargar</button>
|
||
|
|
<button type="button" class="btnfilter btn btn-primary mb-2">Ver</button>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
<div class="col-lg-12 col-md-12 col-12">
|
||
|
|
<button type="button" class="btn-advance btn btn-danger mb-4" style="display: none;">Mostrar Filtro avanzado</button>
|
||
|
|
</div>
|
||
|
|
<div class="col-12">
|
||
|
|
<table class="table table-striped table-bordered" style="width:100%; display: none;" id="estafetatable2">
|
||
|
|
<thead></thead>
|
||
|
|
<tbody>
|
||
|
|
<tr class="text-center"><td colspan="17">Procesando...</td></tr>
|
||
|
|
</tbody>
|
||
|
|
<tfoot>
|
||
|
|
<tr></tr>
|
||
|
|
</tfoot>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<script type="text/javascript">
|
||
|
|
$(".layer-load").hide();
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
//------------------------ DATTEPICKER --------------------------------
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
(function (factory) {
|
||
|
|
factory(moment);
|
||
|
|
}(function (moment) {
|
||
|
|
var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
|
||
|
|
monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
|
||
|
|
return moment.defineLocale('es', {
|
||
|
|
months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
||
|
|
monthsShort : function (m, format) {
|
||
|
|
if (/-MMM-/.test(format)) {
|
||
|
|
return monthsShort[m.month()];
|
||
|
|
} else {
|
||
|
|
return monthsShortDot[m.month()];
|
||
|
|
}
|
||
|
|
},
|
||
|
|
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
|
||
|
|
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
|
||
|
|
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sa'.split('_'),
|
||
|
|
longDateFormat : {
|
||
|
|
LT : 'H:mm',
|
||
|
|
LTS : 'LT:ss',
|
||
|
|
L : 'DD/MM/YYYY',
|
||
|
|
LL : 'D [de] MMMM [de] YYYY',
|
||
|
|
LLL : 'D [de] MMMM [de] YYYY LT',
|
||
|
|
LLLL : 'dddd, D [de] MMMM [de] YYYY LT'
|
||
|
|
},
|
||
|
|
calendar : {
|
||
|
|
sameDay : function () {
|
||
|
|
return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
|
||
|
|
},
|
||
|
|
nextDay : function () {
|
||
|
|
return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
|
||
|
|
},
|
||
|
|
nextWeek : function () {
|
||
|
|
return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
|
||
|
|
},
|
||
|
|
lastDay : function () {
|
||
|
|
return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
|
||
|
|
},
|
||
|
|
lastWeek : function () {
|
||
|
|
return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
|
||
|
|
},
|
||
|
|
sameElse : 'L'
|
||
|
|
},
|
||
|
|
relativeTime : {
|
||
|
|
future : 'en %s',
|
||
|
|
past : 'hace %s',
|
||
|
|
s : 'unos segundos',
|
||
|
|
m : 'un minuto',
|
||
|
|
mm : '%d minutos',
|
||
|
|
h : 'una hora',
|
||
|
|
hh : '%d horas',
|
||
|
|
d : 'un día',
|
||
|
|
dd : '%d días',
|
||
|
|
M : 'un mes',
|
||
|
|
MM : '%d meses',
|
||
|
|
y : 'un año',
|
||
|
|
yy : '%d años'
|
||
|
|
},
|
||
|
|
ordinalParse : /\d{1,2}º/,
|
||
|
|
ordinal : '%dº',
|
||
|
|
week : {
|
||
|
|
dow : 1, // Monday is the first day of the week.
|
||
|
|
doy : 4 // The week that contains Jan 4th is the first week of the year.
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}));
|
||
|
|
function cb(start, end){
|
||
|
|
$('#daterangecat span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
||
|
|
}
|
||
|
|
cb(moment().subtract(1, 'month'),moment());
|
||
|
|
date = $('#daterangecat').daterangepicker({
|
||
|
|
locale: {
|
||
|
|
format: 'YYYY-MM-DD',
|
||
|
|
customRangeLabel: 'Selecciona Rango'
|
||
|
|
},
|
||
|
|
ranges: {
|
||
|
|
'Ultimos 30 Dias': [moment().subtract(29, 'days'), moment()],
|
||
|
|
'Este Mes': [moment().startOf('month'), moment().endOf('month')],
|
||
|
|
'Mes Pasado': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
|
||
|
|
'A\u00f1o pasado': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')],
|
||
|
|
'A\u00f1o pasado - Hoy': [moment().subtract(1, 'year').startOf('year'), moment()],
|
||
|
|
'Este A\u00f1o': [moment().startOf('year'), moment()]
|
||
|
|
}
|
||
|
|
},cb);
|
||
|
|
$('.applyBtn').text('Aceptar');
|
||
|
|
$('.applyBtn').removeClass('btn-primary');
|
||
|
|
$('.applyBtn').addClass('btn-info');
|
||
|
|
$('.cancelBtn ').text('Cancelar');
|
||
|
|
$('.cancelBtn ').removeClass('btn-default');
|
||
|
|
$('.cancelBtn ').addClass('btn-danger');
|
||
|
|
$('#daterangecat').on('apply.daterangepicker', function(ev, picker) {
|
||
|
|
getJson(picker.startDate.format('YYYY-MM-DD'),picker.endDate.format('YYYY-MM-DD'));
|
||
|
|
});
|
||
|
|
function getJson ( fechaInicio, fechaFin){
|
||
|
|
if(fechaInicio==''){
|
||
|
|
fechaInicio=moment().subtract(1, 'month').format('YYYY-MM-DD');
|
||
|
|
}
|
||
|
|
if(fechaFin==''){
|
||
|
|
fechaFin=moment().format('YYYY-MM-DD');
|
||
|
|
}
|
||
|
|
$('#fechaini-cat').val(fechaInicio);
|
||
|
|
$('#fechafin-cat').val(fechaFin);
|
||
|
|
}
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
//--------------------------- FILTER ------------------------------------
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
$(".btnfilter").click(function(){
|
||
|
|
$(".btnfilter").html('Buscando...');
|
||
|
|
$("#estafetatable2").hide();
|
||
|
|
$(".layer-load").show();
|
||
|
|
if (!$("#wrapper").hasClass('toggled')) {
|
||
|
|
$("#wrapper").toggleClass("toggled");
|
||
|
|
}
|
||
|
|
if ($('#estafetatable2').hasClass('Initialize')) {
|
||
|
|
$("#estafetatable2").hide();
|
||
|
|
$(".layer-load").show();
|
||
|
|
$(".btn-advance").text('Mostrar filtro avanzado');
|
||
|
|
$("#estafetatable2").dataTable().fnDestroy();
|
||
|
|
setTimeout(function(){ extractData(); }, 800);
|
||
|
|
}else{
|
||
|
|
$('#estafetatable2').addClass('Initialize');
|
||
|
|
extractData();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
//--------------------------- DATA ------------------------------------
|
||
|
|
//----------------------------------------------------------------------
|
||
|
|
function extractData(){
|
||
|
|
var fechainit = $('#fechaini-cat').val();
|
||
|
|
var fechafin = $('#fechafin-cat').val();
|
||
|
|
var estado = $('#filestadouser-cat').val();
|
||
|
|
if( fechafin == '' ) { fechafin = moment().format('YYYY-MM-DD'); }
|
||
|
|
if( fechainit == '' ) { fechainit = moment().subtract(1, 'month').format('YYYY-MM-DD'); }
|
||
|
|
$("#estafetatable2 tfoot tr").empty();
|
||
|
|
var data = {fechaini:fechainit,fechafin:fechafin,estado:estado};
|
||
|
|
$(".layer-load").show();
|
||
|
|
var dataSet = [];
|
||
|
|
$.ajax({
|
||
|
|
type:'POST',
|
||
|
|
data:data,
|
||
|
|
/*url: 'reporte_getCategoria_completada2.php'*/
|
||
|
|
url: '_reportes_x_cat.php'
|
||
|
|
})
|
||
|
|
.done(function (data) {
|
||
|
|
var _data = JSON.parse(data);
|
||
|
|
//var _data = 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']];
|
||
|
|
//});
|
||
|
|
$.each(_data.columnasvisibles, function (index, val) {
|
||
|
|
$("#estafetatable2 tfoot tr").append('<th></th>');
|
||
|
|
});
|
||
|
|
$('#estafetatable2 tbody').empty();
|
||
|
|
$('#estafetatable2').DataTable({
|
||
|
|
searchPanes: {
|
||
|
|
viewTotal: true
|
||
|
|
},
|
||
|
|
/*dom: "Bfrtip",*/
|
||
|
|
dom: 'PBfrtip',
|
||
|
|
buttons: [
|
||
|
|
//'pageLength',
|
||
|
|
{
|
||
|
|
extend: 'excel',
|
||
|
|
exportOptions: {
|
||
|
|
//columns: ':visible'
|
||
|
|
},
|
||
|
|
autoFilter: true,
|
||
|
|
title: 'Reporte por categoría completadas - Estafeta',
|
||
|
|
sheetName: 'Reporte por categorías completadas',
|
||
|
|
text: 'Exportar a Excel'
|
||
|
|
},
|
||
|
|
'colvis'
|
||
|
|
],
|
||
|
|
"language": {
|
||
|
|
"url": "../json/Spanish.json"
|
||
|
|
},
|
||
|
|
'order':false,
|
||
|
|
/*
|
||
|
|
'order': [
|
||
|
|
[2, 'desc'],
|
||
|
|
[1, 'asc']
|
||
|
|
],
|
||
|
|
*/
|
||
|
|
"responsive": true,
|
||
|
|
data: _data.data,
|
||
|
|
columns: _data.columnasvisibles,
|
||
|
|
orderCellsTop: true,
|
||
|
|
fixedHeader: true,
|
||
|
|
initComplete: function () {
|
||
|
|
$('.btn-advance').show(300);
|
||
|
|
$('.dtsp-panesContainer').hide();
|
||
|
|
this.api().columns().every( function () {
|
||
|
|
var column = this;
|
||
|
|
var select = $('<select class="myselect"><option value="">TODOS</option></select>')
|
||
|
|
.appendTo( $(column.footer()).after())
|
||
|
|
.on('change', function () {
|
||
|
|
var val = $.fn.dataTable.util.escapeRegex(
|
||
|
|
$(this).val()
|
||
|
|
);
|
||
|
|
column
|
||
|
|
.search( val ? '^'+val+'$' : '', true, false )
|
||
|
|
.draw();
|
||
|
|
});
|
||
|
|
column.data().unique().sort().each( function ( d, j ) {
|
||
|
|
select.append( '<option value="'+d+'">'+d+'</option>' )
|
||
|
|
});
|
||
|
|
});
|
||
|
|
$(".myselect").select2();
|
||
|
|
$(".layer-load").hide();
|
||
|
|
$("#estafetatable2").show();
|
||
|
|
$(".btnfilter").html('Buscar');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
})
|
||
|
|
.fail(function () {
|
||
|
|
})
|
||
|
|
.always(function () {
|
||
|
|
});
|
||
|
|
}
|
||
|
|
$(".btn-advance").click(function(){
|
||
|
|
if($('.dtsp-panesContainer').is(':visible')) {
|
||
|
|
$(".btn-advance").text('Mostrar filtro avanzado');
|
||
|
|
}else{
|
||
|
|
$(".btn-advance").text('Ocultar filtro avanzado');
|
||
|
|
}
|
||
|
|
$('.dtsp-panesContainer').toggle(300);
|
||
|
|
});
|
||
|
|
$(".btn_download").click(function(){
|
||
|
|
var fechainit = $('#fechaini-cat').val();
|
||
|
|
var fechafin = $('#fechafin-cat').val();
|
||
|
|
var estado = $('#filestadouser-cat').val();
|
||
|
|
var categoria = $('#filcategoriauser-cat').val();
|
||
|
|
if( fechafin == '' ) { fechafin = moment().format('YYYY-MM-DD'); }
|
||
|
|
if( fechainit == '' ) { fechainit = moment().subtract(1, 'month').format('YYYY-MM-DD'); }
|
||
|
|
|
||
|
|
window.open('reporteExportCatCompletadasv2.php?categoria='+categoria+'&fechaini='+fechainit+"&fechafin="+fechafin+"&estado="+estado, '_blank');
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
listadoDeCategorias();
|
||
|
|
|
||
|
|
function listadoDeCategorias() {
|
||
|
|
$(".layer-load").show();
|
||
|
|
$.ajax({
|
||
|
|
url: 'categorias_list.php',
|
||
|
|
type: 'POST'
|
||
|
|
})
|
||
|
|
.done(function (response) {
|
||
|
|
var _data = JSON.parse(response);
|
||
|
|
|
||
|
|
$('#filcategoriauser-cat').empty();
|
||
|
|
|
||
|
|
$.each(_data.datos, function (index, val) {
|
||
|
|
if (val.padre == 0) {
|
||
|
|
$("#filcategoriauser-cat").append('<option value="' + val.id + '">' + val.nombre + '</option>');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log(_data);
|
||
|
|
$('.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>
|