|
|
@ -0,0 +1,373 @@ |
|
|
|
package mx.gob.jumapacelaya.views; |
|
|
|
|
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
|
import com.vaadin.flow.component.grid.Grid; |
|
|
|
import com.vaadin.flow.component.html.*; |
|
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
|
|
|
import com.vaadin.flow.component.radiobutton.RadioButtonGroup; |
|
|
|
import com.vaadin.flow.component.radiobutton.RadioGroupVariant; |
|
|
|
import com.vaadin.flow.component.textfield.NumberField; |
|
|
|
import com.vaadin.flow.router.PageTitle; |
|
|
|
import com.vaadin.flow.router.Route; |
|
|
|
import com.vaadin.flow.theme.lumo.LumoUtility; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@PageTitle("Estudio Socioeconomico") |
|
|
|
@Route(value = "cuestionario", layout = MainLayout.class) |
|
|
|
public class CuestionarioView extends VerticalLayout { |
|
|
|
|
|
|
|
public CuestionarioView() { |
|
|
|
this.setSizeFull(); |
|
|
|
this.setSpacing(false); |
|
|
|
|
|
|
|
cabezera(); |
|
|
|
titulo(); |
|
|
|
form(); |
|
|
|
} |
|
|
|
|
|
|
|
private void cabezera() { |
|
|
|
|
|
|
|
HorizontalLayout encabezadoLayout = new HorizontalLayout(); |
|
|
|
encabezadoLayout.setWidthFull(); |
|
|
|
encabezadoLayout.setPadding(true); |
|
|
|
|
|
|
|
// Obtener la fecha actual del sistema |
|
|
|
LocalDate fechaSistema = LocalDate.now(); |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE d 'de' MMMM 'del' yyyy"); |
|
|
|
String fechaFormateada = fechaSistema.format(formatter); |
|
|
|
|
|
|
|
Span fecha = new Span(); |
|
|
|
fecha.setText("Celaya, Guanajuato a " + fechaFormateada); |
|
|
|
|
|
|
|
Image logoJmpa = new Image("images/LOGO_24'27.PNG", "JUMAPA logo"); |
|
|
|
logoJmpa.setWidth("110px"); |
|
|
|
logoJmpa.setHeight("50px"); |
|
|
|
|
|
|
|
|
|
|
|
encabezadoLayout.add(logoJmpa); |
|
|
|
encabezadoLayout.addAndExpand(new HorizontalLayout()); |
|
|
|
encabezadoLayout.add(fecha); |
|
|
|
encabezadoLayout.addAndExpand(new HorizontalLayout()); |
|
|
|
this.add(encabezadoLayout); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void titulo() { |
|
|
|
|
|
|
|
VerticalLayout tituloLayout = new VerticalLayout(); |
|
|
|
tituloLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
|
|
H4 lblTitulo = new H4(); |
|
|
|
lblTitulo.setText("VALORACIÓN DE CONDICIÓN SOCIOECONÓMICA DE USUARIOS DOMÉSTICOS"); |
|
|
|
|
|
|
|
|
|
|
|
tituloLayout.add(lblTitulo); |
|
|
|
|
|
|
|
this.add(tituloLayout); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void form() { |
|
|
|
// Contenedor principal |
|
|
|
VerticalLayout formLayout = new VerticalLayout(); |
|
|
|
|
|
|
|
// Contenedoreres para cada bloque de preguntas |
|
|
|
HorizontalLayout contenedor1 = new HorizontalLayout(); |
|
|
|
contenedor1.setWidthFull(); |
|
|
|
contenedor1.setSpacing(false); |
|
|
|
contenedor1.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor2 = new HorizontalLayout(); |
|
|
|
contenedor2.setWidthFull(); |
|
|
|
contenedor2.setSpacing(false); |
|
|
|
contenedor2.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor3 = new HorizontalLayout(); |
|
|
|
contenedor3.setWidthFull(); |
|
|
|
contenedor3.setSpacing(false); |
|
|
|
contenedor3.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor4 = new HorizontalLayout(); |
|
|
|
contenedor4.setWidthFull(); |
|
|
|
contenedor4.setSpacing(false); |
|
|
|
contenedor4.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor5 = new HorizontalLayout(); |
|
|
|
contenedor5.setWidthFull(); |
|
|
|
contenedor5.setSpacing(false); |
|
|
|
contenedor5.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor6 = new HorizontalLayout(); |
|
|
|
contenedor6.setWidthFull(); |
|
|
|
contenedor6.setSpacing(false); |
|
|
|
contenedor6.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
HorizontalLayout contenedor7 = new HorizontalLayout(); |
|
|
|
contenedor7.setWidthFull(); |
|
|
|
contenedor7.setSpacing(false); |
|
|
|
contenedor7.getStyle().set("border", "1px solid black"); |
|
|
|
|
|
|
|
// Contenedor para los resultados |
|
|
|
HorizontalLayout resultadosLayout = new HorizontalLayout(); |
|
|
|
resultadosLayout.setWidthFull(); |
|
|
|
H5 resultado = new H5("Porcentaje de descuento:"); |
|
|
|
H5 puntosTotal = new H5("Puntos obtenidos:"); |
|
|
|
H5 agua = new H5("Coeficiente de Agua (11):"); |
|
|
|
H5 drenaje = new H5("Coeficiente de Drenaje (12):"); |
|
|
|
H5 tratada = new H5("Coeficiente de Agua Tratada (112):"); |
|
|
|
VerticalLayout etiquetaLayout = new VerticalLayout(puntosTotal, resultado, agua, drenaje, tratada); |
|
|
|
etiquetaLayout.setAlignItems(Alignment.END); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Columnas ingreso familiar |
|
|
|
VerticalLayout columnaCriterio = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangos = new VerticalLayout(); |
|
|
|
columnaRangos.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntos = new VerticalLayout(); |
|
|
|
columnaPuntos.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas enfermedades |
|
|
|
VerticalLayout colunaCriterioEnf = new VerticalLayout(); |
|
|
|
VerticalLayout colunaRangoEnf = new VerticalLayout(); |
|
|
|
colunaRangoEnf.setSpacing(false); |
|
|
|
VerticalLayout colunaPuntosEnf = new VerticalLayout(); |
|
|
|
colunaPuntosEnf.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas dependientes |
|
|
|
VerticalLayout columnaCriteriosDepen = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangosDepen = new VerticalLayout(); |
|
|
|
columnaRangosDepen.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntosDepen = new VerticalLayout(); |
|
|
|
columnaPuntosDepen.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas Acesos/Salud |
|
|
|
VerticalLayout columnaCriteriosSalud = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangosSalud = new VerticalLayout(); |
|
|
|
columnaRangosSalud.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntosSalud = new VerticalLayout(); |
|
|
|
columnaPuntosSalud.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas Zona Habitacional |
|
|
|
VerticalLayout columnaCriteriosZona = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangosZona = new VerticalLayout(); |
|
|
|
columnaRangosZona.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntosZona = new VerticalLayout(); |
|
|
|
columnaPuntosZona.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas grado escolaridad |
|
|
|
VerticalLayout columnaCriteriosEscolar = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangosEscolar = new VerticalLayout(); |
|
|
|
columnaRangosEscolar.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntosEscolar = new VerticalLayout(); |
|
|
|
columnaPuntosEscolar.setSpacing(false); |
|
|
|
|
|
|
|
// Columnas edad |
|
|
|
VerticalLayout columnaCriteriosEdad = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangosEdad = new VerticalLayout(); |
|
|
|
columnaRangosEdad.setSpacing(false); |
|
|
|
VerticalLayout columnaPuntosEdad = new VerticalLayout(); |
|
|
|
columnaPuntosEdad.setSpacing(false); |
|
|
|
|
|
|
|
|
|
|
|
// Columna Etiquetas |
|
|
|
Span etiquetaCriterio = new Span("Ingreso familiar mensual"); // Columna Criterio |
|
|
|
Span etiquetaCriterioEnf = new Span("Padece alguna enfermedad crónica o discapacidad comprobable"); |
|
|
|
Span etiquetaCriterioDepen = new Span("Número de dependientes económicos"); |
|
|
|
Span etiquetaCriterioSalud = new Span("Acceso a los sistemas de Salud"); |
|
|
|
Span etiquetaCriterioZona = new Span("Zona habitacional, condiciones de la vivienda y muebles"); |
|
|
|
Span etiquetaCriteriosEscolar = new Span("Grado de escolaridad"); |
|
|
|
Span etiquetaCriteriosEdad = new Span("Edad del solicitante en años cumplidos"); |
|
|
|
|
|
|
|
|
|
|
|
/* Columnas rangos */ |
|
|
|
// Columna Rangos Ingreso |
|
|
|
Span rango1 = new Span("$6,223.20 en adelante"); |
|
|
|
Span rango2 = new Span("$ 2,500.01 a $ 6,223.19"); |
|
|
|
Span rango3 = new Span("$ 2,000.01 a $ 2,500.00"); |
|
|
|
Span rango4 = new Span("igual o menor a $ 2,000.00"); |
|
|
|
|
|
|
|
// Columna Rangos Enfermedades |
|
|
|
Span rangoenf1 = new Span("No padece enfermedad o discapacidad"); |
|
|
|
Span rangoenf2 = new Span("Quien padece, no aporta económicamente"); |
|
|
|
Span rangoenf3 = new Span("Quien padece, si aporta económicamente"); |
|
|
|
|
|
|
|
// Columna Rangos Dependientes |
|
|
|
Span rangoDepen1 = new Span("No tiene dependientes"); |
|
|
|
Span rangoDepen2 = new Span("1 a 3"); |
|
|
|
Span rangoDepen3 = new Span("4 a 6"); |
|
|
|
Span rangoDepen4 = new Span("7 a 9"); |
|
|
|
|
|
|
|
// Columnas Rangos Acceso/Salud |
|
|
|
Span rangoSalud1 = new Span("Particular"); |
|
|
|
Span rangoSalud2 = new Span("IMSS o ISSTE"); |
|
|
|
Span rangoSalud3 = new Span("ISAPEG"); |
|
|
|
Span rangoSalud4 = new Span("Ninguno"); |
|
|
|
|
|
|
|
// Columnas Rangos Zona habitacional |
|
|
|
Span rangoZona1 = new Span("Excelente"); |
|
|
|
Span rangoZona2 = new Span("Buena"); |
|
|
|
Span rangoZona3 = new Span("Regular"); |
|
|
|
Span rangoZona4 = new Span("Mala"); |
|
|
|
|
|
|
|
// Columna Rangos Escolaridad |
|
|
|
Span rangoEscolar1 = new Span("Profesional"); |
|
|
|
Span rangoEscolar2 = new Span("Preparatoria"); |
|
|
|
Span rangoEscolar3 = new Span("Secundaria"); |
|
|
|
Span rangoEscolar4 = new Span("Primaria o menos"); |
|
|
|
|
|
|
|
// Columna Rangos Edad |
|
|
|
Span rangoEdad1 = new Span("18 a 30"); |
|
|
|
Span rangoEdas2 = new Span("31 a 40"); |
|
|
|
Span rangoEdad3 = new Span("41 a 60"); |
|
|
|
Span rangoEdad4 = new Span("A partir de 61"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Columnas puntos */ |
|
|
|
// Columna puntos Ingresos |
|
|
|
RadioButtonGroup<Integer> opciones = new RadioButtonGroup<>(); |
|
|
|
opciones.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opciones.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos enfermedades |
|
|
|
RadioButtonGroup<Integer> opcionesEnf = new RadioButtonGroup<>(); |
|
|
|
opcionesEnf.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEnf.setItems(0, 5, 10); |
|
|
|
|
|
|
|
// Columna puntos dependientes |
|
|
|
RadioButtonGroup<Integer> opcionesDepen= new RadioButtonGroup<>(); |
|
|
|
opcionesDepen.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesDepen.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos salud |
|
|
|
RadioButtonGroup<Integer> opcionesSalud= new RadioButtonGroup<>(); |
|
|
|
opcionesSalud.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesSalud.setItems(3, 5, 7, 10); |
|
|
|
|
|
|
|
// Columna puntos zona habitacional |
|
|
|
RadioButtonGroup<Integer> opcionesZona= new RadioButtonGroup<>(); |
|
|
|
opcionesZona.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesZona.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos grado escolar |
|
|
|
RadioButtonGroup<Integer> opcionesEscolar= new RadioButtonGroup<>(); |
|
|
|
opcionesEscolar.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEscolar.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos edad |
|
|
|
RadioButtonGroup<Integer> opcionesEdad= new RadioButtonGroup<>(); |
|
|
|
opcionesEdad.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEdad.setItems(0, 4, 7, 10); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
columnaCriterio.add(new H5("Criterio"), etiquetaCriterio); |
|
|
|
columnaRangos.add(new H5("Rangos"), rango1, rango2, rango3, rango4); |
|
|
|
columnaPuntos.add(new H5("Puntos"), opciones); |
|
|
|
|
|
|
|
|
|
|
|
colunaCriterioEnf.add(etiquetaCriterioEnf); |
|
|
|
colunaRangoEnf.add(rangoenf1, rangoenf2, rangoenf3); |
|
|
|
colunaPuntosEnf.add(opcionesEnf); |
|
|
|
|
|
|
|
columnaCriteriosDepen.add(etiquetaCriterioDepen); |
|
|
|
columnaRangosDepen.add(rangoDepen1, rangoDepen2, rangoDepen3, rangoDepen4); |
|
|
|
columnaPuntosDepen.add(opcionesDepen); |
|
|
|
|
|
|
|
columnaCriteriosSalud.add(etiquetaCriterioSalud); |
|
|
|
columnaRangosSalud.add(rangoSalud1, rangoSalud2, rangoSalud3, rangoSalud4); |
|
|
|
columnaPuntosSalud.add(opcionesSalud); |
|
|
|
|
|
|
|
columnaCriteriosZona.add(etiquetaCriterioZona); |
|
|
|
columnaRangosZona.add(rangoZona1, rangoZona2, rangoZona3, rangoZona4); |
|
|
|
columnaPuntosZona.add(opcionesZona); |
|
|
|
|
|
|
|
columnaCriteriosEscolar.add(etiquetaCriteriosEscolar); |
|
|
|
columnaRangosEscolar.add(rangoEscolar1, rangoEscolar2, rangoEscolar3, rangoEscolar4); |
|
|
|
columnaPuntosEscolar.add(opcionesEscolar); |
|
|
|
|
|
|
|
columnaCriteriosEdad.add(etiquetaCriteriosEdad); |
|
|
|
columnaRangosEdad.add(rangoEdad1, rangoEdas2, rangoEdad3, rangoEdad4); |
|
|
|
columnaPuntosEdad.add(opcionesEdad); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
H3 puntos = new H3("0"); |
|
|
|
H3 descuento = new H3("0%"); |
|
|
|
NumberField txtAgua = new NumberField(); |
|
|
|
txtAgua.setWidth("50px"); |
|
|
|
NumberField txtDrena = new NumberField(); |
|
|
|
txtDrena.setWidth("50px"); |
|
|
|
NumberField txtTrata = new NumberField(); |
|
|
|
txtTrata.setWidth("50px"); |
|
|
|
|
|
|
|
// Boton para calcular el puntaje total |
|
|
|
Button btnCalcular = new Button("Calcular Puntaje", event -> { |
|
|
|
int total = 0; |
|
|
|
|
|
|
|
// Suma los valores seleccionados en cada Radio Button |
|
|
|
total += opciones.getValue() != null ? opciones.getValue() : 0; |
|
|
|
total += opcionesEnf.getValue() != null ? opcionesEnf.getValue() : 0; |
|
|
|
total += opcionesDepen.getValue() != null ? opcionesDepen.getValue() : 0; |
|
|
|
total += opcionesSalud.getValue() != null ? opcionesSalud.getValue() : 0; |
|
|
|
total += opcionesZona.getValue() != null ? opcionesZona.getValue() : 0; |
|
|
|
total += opcionesEscolar.getValue() != null ? opcionesEscolar.getValue() : 0; |
|
|
|
total += opcionesEdad.getValue() != null ? opcionesEdad.getValue() : 0; |
|
|
|
|
|
|
|
|
|
|
|
if (total > 60) { |
|
|
|
puntos.setText(String.valueOf(total)); |
|
|
|
descuento.setText("12%"); |
|
|
|
|
|
|
|
txtAgua.setValue(88.0); |
|
|
|
txtDrena.setValue(88.0); |
|
|
|
txtTrata.setValue(88.0); |
|
|
|
} else { |
|
|
|
puntos.setText(String.valueOf(total)); |
|
|
|
descuento.setText("0%"); |
|
|
|
|
|
|
|
txtAgua.clear(); |
|
|
|
txtDrena.clear(); |
|
|
|
txtTrata.clear(); |
|
|
|
|
|
|
|
txtAgua.setReadOnly(true); |
|
|
|
txtDrena.setReadOnly(true); |
|
|
|
txtTrata.setReadOnly(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
VerticalLayout botonLayout = new VerticalLayout(btnCalcular); |
|
|
|
botonLayout.setAlignItems(Alignment.END); |
|
|
|
VerticalLayout totalesLayout = new VerticalLayout(puntos, descuento, txtAgua, txtDrena, txtTrata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contenedor1.add(columnaCriterio, columnaRangos, columnaPuntos); |
|
|
|
contenedor2.add(colunaCriterioEnf, colunaRangoEnf, colunaPuntosEnf); |
|
|
|
contenedor3.add(columnaCriteriosDepen, columnaRangosDepen, columnaPuntosDepen); |
|
|
|
contenedor4.add(columnaCriteriosSalud, columnaRangosSalud, columnaPuntosSalud); |
|
|
|
contenedor5.add(columnaCriteriosZona, columnaRangosZona, columnaPuntosZona); |
|
|
|
contenedor6.add(columnaCriteriosEscolar, columnaRangosEscolar, columnaPuntosEscolar); |
|
|
|
contenedor7.add(columnaCriteriosEdad, columnaRangosEdad, columnaPuntosEdad); |
|
|
|
resultadosLayout.add(botonLayout, etiquetaLayout, totalesLayout); |
|
|
|
formLayout.add(contenedor1, |
|
|
|
contenedor2, |
|
|
|
contenedor3, |
|
|
|
contenedor4, |
|
|
|
contenedor5, |
|
|
|
contenedor6, |
|
|
|
contenedor7, |
|
|
|
resultadosLayout); |
|
|
|
|
|
|
|
this.add(formLayout); |
|
|
|
} |
|
|
|
} |