|
|
@ -1,9 +1,16 @@ |
|
|
|
package mx.gob.jumapacelaya.ui; |
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Base64; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import com.vaadin.flow.component.html.Anchor; |
|
|
|
import com.vaadin.flow.server.StreamResource; |
|
|
|
import mx.gob.jumapacelaya.services.ReportService; |
|
|
|
import org.springframework.security.core.Authentication; |
|
|
|
import org.springframework.cglib.core.Local; |
|
|
|
import org.springframework.security.core.context.SecurityContextHolder; |
|
|
@ -90,10 +97,12 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
|
|
|
|
private final SecurityService securityService; |
|
|
|
private final DatabaseService service; |
|
|
|
private final ReportService reportService; |
|
|
|
|
|
|
|
public DetallesMantView(SecurityService securityService, DatabaseService service) { |
|
|
|
public DetallesMantView(SecurityService securityService, DatabaseService service, ReportService reportService) { |
|
|
|
this.service = service; |
|
|
|
this.securityService = securityService; |
|
|
|
this.reportService = reportService; |
|
|
|
setPadding(true); |
|
|
|
|
|
|
|
mainLayout = new VerticalLayout(); |
|
|
@ -268,6 +277,34 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
btnImprimirRepo.addClickListener(e -> { |
|
|
|
try { |
|
|
|
// Prepara los parámetros para el reporte |
|
|
|
Map<String, Object> parametros = new HashMap<>(); |
|
|
|
parametros.put("PLAN_ID", planAnualIdActual); |
|
|
|
|
|
|
|
// Genera el PDF |
|
|
|
byte[] pdf = reportService.generarReporte("mantenimientoReport", parametros); |
|
|
|
|
|
|
|
// Se crea el recurso para descarga |
|
|
|
StreamResource resource = new StreamResource("reporte.pdf", () -> new ByteArrayInputStream(pdf)); |
|
|
|
Anchor downloadLink = new Anchor(resource, "Descargar Reporte"); |
|
|
|
downloadLink.getElement().setAttribute("download", true); |
|
|
|
downloadLink.setId("descargar-reporte-link"); |
|
|
|
add(downloadLink); |
|
|
|
|
|
|
|
getUI().ifPresent(ui -> |
|
|
|
ui.getPage().executeJs("document.getElementById('descargar-reporte-link').click();") |
|
|
|
); |
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
Notification.show("Error al generar el reporte: " + ex.getMessage(), 4000, Notification.Position.MIDDLE) |
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Se dispara el dialogo de confirmacion |
|
|
|
btnGuardar.addClickListener(e -> confirmDialog.open()); |
|
|
|
|
|
|
@ -554,7 +591,7 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
smtSignLayout.replace(smtSignPad, firmaSmtImg); |
|
|
|
} |
|
|
|
|
|
|
|
Image firmaGcia = new Image("images/firmaGcia.png", "Firma de la Gcia. de T.I"); |
|
|
|
Image firmaGcia = new Image("images/FirmaGerenteTI.png", "Firma de la Gcia. de T.I"); |
|
|
|
firmaGcia.setHeight("200px"); |
|
|
|
firmaGcia.setWidthFull(); |
|
|
|
|
|
|
|