chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
require_once __DIR__.'/auth_guard.php';
|
||||
//ini_set('display_errors', 1);
|
||||
//ini_set('display_startup_errors', 1);
|
||||
//error_reporting(E_ALL);
|
||||
ini_set('memory_limit', '1024M');
|
||||
//header('Content-Type: application/json');
|
||||
//header('Access-Control-Allow-Origin: *');
|
||||
//header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
||||
//header('Access-Control-Allow-Headers: *');
|
||||
|
||||
require_once("../config.php");
|
||||
dbConnect();
|
||||
global $link;
|
||||
$return = new stdClass();
|
||||
if(isset($fechainicio)) {$fechainicio = $_POST['fechaini'];} else { $fechainicio = strtotime('-4 month'); }
|
||||
if(isset($fechafin)) {$fechafin = $_POST['fechafin']; $fechafin = date('Y-m-d', strtotime($fechafin."+ 1 days") ); } else { $fechafin = strtotime('yesterday'); }
|
||||
if(isset($estado)) {$estado = $_POST['estado']; if($estado==1) { $estado = 'ACTIVO'; } else { $estado = 'BAJA'; } } else { $estado = 'ACTIVO'; };
|
||||
$sqlusers = "SELECT * FROM viewReporteCategorias";
|
||||
$resultusers = mysqli_query($link, $sqlusers);
|
||||
$data = [];
|
||||
if( $resultusers ){
|
||||
while ($row = mysqli_fetch_assoc ($resultusers)){
|
||||
$data[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sqlcolumns = "SELECT categoria.id, categoria.clave, categoria.nombre FROM categoria WHERE padre = 0 AND habilitado = 1 ORDER BY categoria.id";
|
||||
$resultcolumn= mysqli_query($link, $sqlcolumns);
|
||||
if( $resultcolumn ){
|
||||
while ($row = mysqli_fetch_assoc ($resultcolumn)){
|
||||
$categorias[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$columnasvisibles= array(
|
||||
'Estado del empleado',
|
||||
'Número de empleado',
|
||||
'Nombres(s)',
|
||||
'Apellidos',
|
||||
'Posición',
|
||||
'Sociedad',
|
||||
'División',
|
||||
'Unidad organizativa',
|
||||
'CeCo',
|
||||
'Centro de trabajo',
|
||||
'Distrito',
|
||||
'Supervisor',
|
||||
'fecha'
|
||||
);
|
||||
|
||||
foreach ($categorias as $key2 => $cat) {
|
||||
array_push($columnasvisibles, $cat['nombre']);
|
||||
}
|
||||
|
||||
for ($i=0; $i < sizeof($columnasvisibles) ; $i++) {
|
||||
$columnasvisibles[$i] = array('title' => $columnasvisibles[$i]);
|
||||
}
|
||||
$return->columnasvisibles = $columnasvisibles;
|
||||
|
||||
if (!empty($data)) {
|
||||
$anterior = '';
|
||||
$users = 0;
|
||||
$fecha_max = null;
|
||||
foreach ($data as $key1 => $col) {
|
||||
//print_r($col);die;
|
||||
//echo $col[2]."<br>";
|
||||
if ($col['numempl'] == $anterior) {
|
||||
//echo $col['numempl']." igual - ".$col['nomcat']."- ".$users." <br>";
|
||||
|
||||
if($fecha_max == null){
|
||||
//$datos[($users-1)][$col['fecha']] = $col['fecha'];
|
||||
$fecha_max = strtotime($col['fecha']);
|
||||
}else if( strtotime($col['fecha']) >= $fecha_max){
|
||||
$fecha_max = strtotime($col['fecha']);
|
||||
//$datos[($users-1)][$col['fecha']] = $col['fecha'];
|
||||
}
|
||||
$datos[($users-1)][$col['nomcat']] = $col['estado1'];
|
||||
}else{
|
||||
//echo $col['numempl']." nuevo - ".$col['nomcat']." - ".$users." <br>";
|
||||
if($fecha_max!=null){
|
||||
$datos[($users-1)]["fecha"] = date("d-m-Y",$fecha_max);
|
||||
}
|
||||
$fecha_max = null;
|
||||
$datos[$users] =
|
||||
['estado_empleado' => $col['estado_empleado'],
|
||||
'numempl' => $col['numempl'],
|
||||
'nombre' => $col['nombre'],
|
||||
'apellidos' =>$col['apellidos'],
|
||||
'posicion'=>$col['posicion'],
|
||||
'sociedad'=> $col['sociedad'],
|
||||
'division'=> $col['division'],
|
||||
'unidad_organizativa' => $col['unidad_organizativa'],
|
||||
'ceco'=>$col['ceco'],
|
||||
'nomdistrito'=>$col['nomdistrito'],
|
||||
'nomcentro' => $col['nomcentro'],
|
||||
'supervisor'=>$col['supervisor'],
|
||||
'fecha'=>$col['fecha']
|
||||
];
|
||||
|
||||
foreach ($categorias as $key2 => $cat) {
|
||||
if ($cat['nombre'] == $col['nomcat']) {
|
||||
|
||||
if($fecha_max == null){
|
||||
//$datos[$users][$col['fecha']] = $col['fecha'];
|
||||
$fecha_max = strtotime($col['fecha']);
|
||||
}else if( strtotime($col['fecha']) >= $fecha_max){
|
||||
$fecha_max = strtotime($col['fecha']);
|
||||
//$datos[$users][$col['fecha']] = $col['fecha'];
|
||||
}
|
||||
$datos[$users][$cat['nombre']] = $col['estado1'];
|
||||
|
||||
}else{
|
||||
$datos[$users][$cat['nombre']] = 'No completado';
|
||||
}
|
||||
}
|
||||
$users++;
|
||||
}
|
||||
$anterior = $col['numempl'];
|
||||
}
|
||||
//print_r($datos[0]);
|
||||
foreach ($datos as $col => $columnas) {
|
||||
$fill = [];
|
||||
foreach ($columnas as $key => $value) {
|
||||
array_push($fill, $value);
|
||||
|
||||
}
|
||||
$datos[$col] = $fill;
|
||||
}
|
||||
}else{
|
||||
$datos = [];
|
||||
}
|
||||
|
||||
//echo json_encode($datos, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); die;
|
||||
|
||||
$filtered_resultusers = array_filter($datos, function($var) use ($fechainicio, $fechafin, $estado) {
|
||||
$evtime = strtotime($var[12]);
|
||||
return $evtime <= $fechafin && $evtime >= $fechainicio && $var[0] == $estado;
|
||||
});
|
||||
$finaldata = [];
|
||||
foreach ($filtered_resultusers as $cols) {
|
||||
$finaldata[] = $cols;
|
||||
}
|
||||
//echo $sqlusers;
|
||||
//echo "<pre>".print_r($finaldata,true)."</pre>";
|
||||
$return->data = $finaldata;
|
||||
mysqli_close($link);
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user