diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 028e93b..00572af 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -44,6 +44,7 @@ try { ), INSERTION AS ( INSERT INTO last_auditoria SELECT :usuario_id, to_jsonb(AUDITORIA_DATA) FROM AUDITORIA_DATA + WHERE REGISTRO_FECHA_IDEAL IS NOT NULL ) SELECT registro_id, @@ -59,6 +60,8 @@ try { color, estado_color, estado_icon, + estado_supervisor_id, + facultad_id, usuario_nombre, registro_fecha_supervisor, comentario, diff --git a/export/supervisor_excel.php b/export/supervisor_excel.php index c615d4f..b44c5bd 100644 --- a/export/supervisor_excel.php +++ b/export/supervisor_excel.php @@ -1,9 +1,9 @@ query( -"SELECT + "SELECT auditoria->>'registro_fecha_ideal' as registro_fecha_ideal, auditoria->>'profesor_clave' as profesor_clave, auditoria->>'profesor_nombre' as profesor_nombre, @@ -38,13 +42,28 @@ $data = $db->query( auditoria->>'justificacion' as justificacion, auditoria->>'horario_hora' as horario_hora, auditoria->>'horario_fin' as horario_fin, + (auditoria->>'estado_supervisor_id')::integer as estado_id, auditoria->>'registro_retardo' as registro_retardo FROM last_auditoria - WHERE auditoria->>'registro_fecha_ideal' IS NOT NULL - AND USUARIO_ID = ?", - [$user->user['id']] + WHERE USUARIO_ID = :usuario_id + AND auditoria->>'facultad_id' = COALESCE(:facultad_id, auditoria->>'facultad_id') + AND auditoria->>'profesor_clave' = COALESCE(:profesor_clave, auditoria->>'profesor_clave')", + [ + 'usuario_id' => $user->user['id'], + 'facultad_id' => $params['facultad_id'], + 'profesor_clave' => $profesor_clave, + ] ); +$estados = empty($params['estados']) ? null : $params['estados']; + +$data = array_filter( + $data, + fn($fila) => in_array($fila['estado_id'], $estados ?? [$fila['estado_id']]) +); + +$data = array_values($data); + empty($data) and die(json_encode(['error' => 'No se recibieron datos', 'data' => $data])); use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -122,7 +141,7 @@ array_walk($keys, function ($key, $index) use ($sheet) { $sheet->getStyle($headers_range)->applyFromArray([ 'font' => [ 'bold' => true, - 'size' => 15, + 'size' => 12, 'name' => 'Indivisa Text Sans', 'color' => ['argb' => Color::COLOR_WHITE], ], @@ -144,7 +163,7 @@ $sheet->setAutoFilter($headers_range); // Styles that are common for all rows can be set outside the loop const DEFAULT_FONT = [ - 'size' => 12, + 'size' => 10, 'name' => 'Indivisa Text Sans', 'color' => ['argb' => '001d68'] ]; @@ -206,7 +225,12 @@ foreach ($data as $index => $registro) { foreach ($sheet->getColumnIterator() as $column) { - $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); + $colIndex = $column->getColumnIndex(); + if ($colIndex === 'Q') { + $sheet->getColumnDimension($colIndex)->setWidth(100); // Ajusta el valor según el tamaño deseado + } else { + $sheet->getColumnDimension($colIndex)->setAutoSize(true); + } } $writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); diff --git a/js/auditoría.js b/js/auditoría.js index a6b9948..f38e627 100644 --- a/js/auditoría.js +++ b/js/auditoría.js @@ -290,7 +290,11 @@ const store = reactive({ headers: { 'Content-Type': 'application/json' }, - // body: JSON.stringify(this.relevant) + body: JSON.stringify({ + 'facultad_id': store.filters.facultad_id, + 'estados': store.filters.estados, + 'profesor': store.filters.profesor, + }) }); const blob = await res.blob(); window.saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);