Excel sin recibir datos

This commit is contained in:
Your Name
2025-01-20 09:28:41 -06:00
parent 13f89636fc
commit 184abed9a1
2 changed files with 64 additions and 11 deletions

View File

@@ -1,4 +1,3 @@
<?php
$fecha = date('d_m_Y');
@@ -6,7 +5,24 @@ header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetm
header("Content-Disposition: attachment;filename=horario_$fecha.xlsx");
header("Cache-Control: max-age=0");
require_once "../vendor/autoload.php";
$ruta = "..";
require_once "$ruta/class/c_login.php";
if (!isset($_SESSION['user'])) {
http_response_code(401);
die(json_encode(['error' => 'unauthorized']));
}
$user = unserialize($_SESSION['user']);
/* $json = file_get_contents('php://input');
$data = json_decode($json, true); */
$query = $db
->where('usuario_id', $user->user['id'])
->getOne('last_auditoria', 'auditoria')['auditoria'];
$data = json_decode($query, true);
empty($data) and die(json_encode(['error' => 'No se recibieron datos', 'data' => $data]));
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Border;
@@ -28,11 +44,6 @@ $drawing->setName('La Salle')
->setOffsetX(10)
->setWorksheet($spreadsheet->getActiveSheet());
$json = file_get_contents('php://input');
$data = json_decode($json, true);
empty($data) and die(json_encode(['error' => 'No se recibieron datos', 'data' => $data]));
$data_excel = array(
"FECHA" => 'registro_fecha_ideal',
"CLAVE" => 'profesor_clave',
@@ -137,8 +148,8 @@ function getFormattedValue($key, $registro)
'registro_fecha_supervisor' => is_null($registro[$key]) ? 'Sin registro' : date('H:i', strtotime($registro[$key])),
'nombre' => $registro[$key] ?? "Sin registro",
'horario_hora_completa' => "{$registro['horario_hora']} - {$registro['horario_fin']}",
'usuario_nombre',
'salon_array' => implode(", ", json_decode($registro[$key], true)),
'usuario_nombre' => $registro[$key] ?? "Sin registro",
'salon_array' => json_encode($registro[$key], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
'justificacion',
'comentario' => $registro[$key] ?? "Sin registro",
default => $registro[$key]

View File

@@ -290,7 +290,7 @@ const store = reactive({
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.relevant)
// body: JSON.stringify(this.relevant)
});
const blob = await res.blob();
window.saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);
@@ -314,8 +314,50 @@ const store = reactive({
}
},
});
const detalle = reactive({
correo: null,
facultad: null,
materia: null,
carrera: null,
nivel: null,
horario_grupo: null,
reset() {
this.correo = null
this.facultad = null
this.materia = null
this.carrera = null
this.nivel = null
this.horario_grupo = null
},
async obtener_detalle(horario_id, profesor_id) {
detalle.reset();
$('div.modal#cargando').modal('show');
try {
const resultado = await (await fetch(`action/action_auditoria_detalle.php?${new URLSearchParams({ horario_id, profesor_id })}`)).json();
this.correo = resultado.profesor_correo;
this.facultad = resultado.facultad;
this.materia = resultado.materia;
this.carrera = resultado.carrera;
this.nivel = resultado.nivel;
this.grupo = resultado.grupo;
}
catch (error) {
console.log('Error:', error)
}
finally {
$('div.modal#cargando').modal('hide');
}
}
});
createApp({
store,
detalle,
messages: [],
get clase_vista() {
return store.current.clase_vista;