diff --git a/src/main/bundles/dev.bundle b/src/main/bundles/dev.bundle index 98765af..44ff38b 100644 Binary files a/src/main/bundles/dev.bundle and b/src/main/bundles/dev.bundle differ diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index a8d568f..1399c8b 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -22,9 +22,10 @@ private String lastName; private LocalDate birthday; private String birthCity; - @Enumerated(EnumType.STRING) - private MaritalStatus maritalStatus; + private String age; + private String residenceAddress; + private String localAddress; private String phoneNumber; private String personalEmail; private String position; @@ -33,6 +34,48 @@ private String emergencyCAddress; private String emergencyCPhone; private String emergencyCEmail; + private String numberOfChildren; + + private String ci; + private String issuedIn; + + private String pTitle1; + private String pTitle2; + private String pTitle3; + + private String pStudy1; + private String pStudy2; + private String pStudy3; + + private String certification1; + private String certification2; + private String certification3; + private String certification4; + + private String recognition; + private String achievements; + + private String language; + private String languageLevel; + + private String cod; + private String leadManager; + private String project; + + private LocalDate dateOfEntry; + private LocalDate dateOfExit; + + private String contractType; + private String seniority; + private String salary; + + private String bankName; + private String accountNumber; + + private String gpss; + private String sss; + private String beneficiaries; + @Column(columnDefinition = "TEXT") private String profileImage; @Enumerated(EnumType.STRING) @@ -77,13 +120,23 @@ ACTIVE, INACTIVE } + @Enumerated(EnumType.STRING) + private MaritalStatus maritalStatus; public enum MaritalStatus { SINGLE, MARRIED, WIDOWED, DIVORCED } + @Enumerated(EnumType.STRING) + private Gender gender; + public enum Gender { + MALE, + FEMALE + } + public Status getStatus() { + return status; } public void setStatus(final Status status) { diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 8303f8e..bdf5a82 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -45,12 +45,6 @@ import java.util.UUID; @Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class) public class EmployeeView extends BeanValidationForm implements HasUrlParameter { - private static final String SAVE_BUTTON_TEXT = "Save"; - private static final String EDIT_BUTTON_TEXT = "Edit"; - private static final String NOTIFICATION_SAVE_SUCCESS = "Employee saved successfully."; - private static final String NOTIFICATION_VALIDATE_ERROR = "Please complete the required fields correctly."; - private static final String PHONE_NUMBER_ERROR_MESSAGE = "El teléfono debe contener solo números."; - private final EmployeeService employeeService; private final ReportService reportService; @@ -59,14 +53,23 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final TextField firstName = createTextField("Nombres: ", 30, true); private final TextField lastName = createTextField("Apellidos", 30, true); private final ComboBox status = createStatusComboBox(); + private final ComboBox gender = createGenderComboBox(); private final VDatePicker birthday = new VDatePicker("Fecha de Nacimiento"); + private final TextField age = createTextField("Edad", 3, false); private final TextField birthCity = createTextField("Ciudad y País de Nacimiento", 20, false); - private final ComboBox maritalStatus = createMaritalStatusComboBox(); private final TextField residenceAddress = createTextField("Dirección de Residencia", 50, false); + private final TextField localAddress = createTextField("Dep/Provincia de Residencia", 10, false); + private final ComboBox maritalStatus = createMaritalStatusComboBox(); + private final TextField numberOfChildren = createTextField("Numero de Hijos", 3, false); + private final TextField ci = createTextField("CI", 30, false); + private final TextField issuedIn = createTextField("Expedido en ", 30, false); private final TextField phoneNumber = createTextField("Teléfono", 8, false); private final EmailField personalEmail = createEmailField("E-mail"); + private final TextField cod = createTextField("Codigo de Empleado", 30, false); private final TextField position = createTextField("Cargo", 30, false); private final TextField team = createTextField("Equipo", 30, false); + private final TextField leadManager = createTextField("Lead/Manager", 30, false); + private final TextField project = createTextField("Proyecto", 30, false); private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false); private final TextField emergencyCAddress = createTextField("Dirección de Contacto", 50, false); private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false); @@ -76,15 +79,61 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final Upload upload = new Upload(buffer); private final Image profileImagePreview = new Image(); + //INFORMACION PROFESIONAL + private final TextField pTitle1 = createTextField("Título 1", 30, false); + private final TextField pTitle2 = createTextField("Título 2", 30, false); + private final TextField pTitle3 = createTextField("Título 3", 30, false); + private final TextField pStudy1 = createTextField("Estudio 1", 30, false); + private final TextField pStudy2 = createTextField("Estudio 2", 30, false); + private final TextField pStudy3 = createTextField("Estudio 3", 30, false); + private final TextField certification1 = createTextField("Certificación 1", 30, false); + private final TextField certification2 = createTextField("Certificación 2", 30, false); + private final TextField certification3 = createTextField("Certificación 3", 30, false); + private final TextField certification4 = createTextField("Certificación 4", 30, false); + private final TextField recognition = createTextField("Reconocimientos", 30, false); + private final TextField achievements = createTextField("Logros Profesionales", 30, false); + private final TextField language = createTextField("Idioma", 30, false); + private final TextField languageLevel = createTextField("Nivel de Idioma", 30, false); + + //INFORMACION DE CONTRATACION + private final VDatePicker dateOfEntry = new VDatePicker("Fecha de Ingreso"); + private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro"); + private final TextField contractType = createTextField("Tipo de Contratación", 30, false); + private final TextField seniority = createTextField("Antiguedad", 30, false); + private final TextField salary = createTextField("Salario", 30, false); + private final TextField bankName = createTextField("Banco", 30, false); + private final TextField accountNumber = createTextField("Nro. de Cuenta", 30, false); + private final TextField gpss = createTextField("Código Único de Asegurado (GPSS)", 30, false); + private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false); + private final TextField beneficiaries = createTextField("Derechohabientes", 30, false); + + private static final String SAVE_BUTTON_TEXT = "Save"; + private static final String EDIT_BUTTON_TEXT = "Edit"; + private static final String NOTIFICATION_SAVE_SUCCESS = "Employee saved successfully."; + private static final String NOTIFICATION_VALIDATE_ERROR = "Please complete the required fields correctly."; + private static final String PHONE_NUMBER_ERROR_MESSAGE = "El teléfono debe contener solo números."; + private final Button saveButton = new Button(SAVE_BUTTON_TEXT, e -> saveEmployee()); private final Button editButton = new Button(EDIT_BUTTON_TEXT, e -> enableEditMode()); - private final Button reportButton = new Button("Ficha"); + private final Button reportButton = new Button("Generar Ficha"); private final Dialog dialog = new Dialog(); private final PdfViewer pdfViewer = new PdfViewer(); - private final H2 mt = new H2("Información General del Empleado"); - private final H3 fs = new H3("Información Personal"); - private final H3 ss = new H3("Datos de Contacto de Emergencia"); - private final H3 si = new H3("Foto del Empleado"); + + //TITULOS PARA INFORMACION PERSONAL + private final H2 infoPer = new H2("Información Personal"); + private final H3 infoGenr = new H3("Información General"); + private final H3 contEmerg = new H3("Contacto de Emergencia"); + //TITULOS PARA INFORMACIÓN PROFESIONAL + private final H2 infProf = new H2("Información Profesional"); + private final H3 titulos = new H3("Titulos Profesionales y Estudios Realizados"); + private final H3 certif = new H3("Certificaciones Profesionales"); + private final H3 logros = new H3("Otros Logros y Reconocimientos"); + private final H3 idioma = new H3("Dominio de Idiomas"); + //TITULOS PARA INFORMACIÓN ADMINISTRATIVA + private final H2 infoAdm = new H2("Información Administrativa"); + private final H3 infoCont = new H3("Información de Contratación"); + private final H3 datBanc = new H3("Datos Bancados"); + private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social"); public EmployeeView(final EmployeeService employeeService, final ReportService reportService) { super(Employee.class); @@ -105,6 +154,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl saveButton.setVisible(true); editButton.setVisible(true); reportButton.setVisible(true); + birthday.addValueChangeListener(event -> calculateAge()); reportButton.addClickListener((ComponentEventListener>) buttonClickEvent -> { var employee = getEntity(); @@ -117,6 +167,16 @@ public class EmployeeView extends BeanValidationForm implements HasUrl initDialog(); } + private void calculateAge() { + if (birthday.getValue() != null) { + int currentYear = java.time.LocalDate.now().getYear(); + int birthYear = birthday.getValue().getYear(); + int ages = currentYear - birthYear; + age.setValue(String.valueOf(ages)); + System.out.println(age); + } + } + private void configureUpload() { upload.setAcceptedFileTypes("image/jpeg", "image/png"); upload.setMaxFileSize(1024 * 1024); @@ -210,6 +270,14 @@ public class EmployeeView extends BeanValidationForm implements HasUrl return comboBox; } + private ComboBox createGenderComboBox() { + ComboBox comboBox = new ComboBox<>("Genero"); + comboBox.setItems(Employee.Gender.values()); + comboBox.setItemLabelGenerator(Employee.Gender::name); + comboBox.setRequiredIndicatorVisible(true); + return comboBox; + } + private boolean validateForm() { return !firstName.isEmpty() && !lastName.isEmpty() && status.getValue() != null; } @@ -218,6 +286,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl if (validateForm()) { Employee employee = getEntity(); employee.setStatus(status.getValue()); + employee.setAge(age.getValue()); + employeeService.createOrUpdate(employee); Notification.show(NOTIFICATION_SAVE_SUCCESS); getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class)); @@ -278,13 +348,16 @@ public class EmployeeView extends BeanValidationForm implements HasUrl } private void setFieldsReadOnly() { + username.setReadOnly(false); firstName.setReadOnly(true); lastName.setReadOnly(true); status.setReadOnly(true); birthday.setReadOnly(true); birthCity.setReadOnly(true); - maritalStatus.setReadOnly(true); residenceAddress.setReadOnly(true); + localAddress.setReadOnly(true); + maritalStatus.setReadOnly(true); + numberOfChildren.setReadOnly(true); phoneNumber.setReadOnly(true); personalEmail.setReadOnly(true); position.setReadOnly(true); @@ -295,16 +368,51 @@ public class EmployeeView extends BeanValidationForm implements HasUrl emergencyCEmail.setReadOnly(true); upload.setVisible(true); profileImagePreview.setVisible(true); + age.setReadOnly(true); + gender.setReadOnly(true); + status.setReadOnly(true); + ci.setReadOnly(true); + issuedIn.setReadOnly(true); + pTitle1.setReadOnly(true); + pTitle2.setReadOnly(true); + pTitle3.setReadOnly(true); + pStudy1.setReadOnly(true); + pStudy2.setReadOnly(true); + pStudy3.setReadOnly(true); + certification1.setReadOnly(true); + certification2.setReadOnly(true); + certification3.setReadOnly(true); + certification4.setReadOnly(true); + recognition.setReadOnly(true); + achievements.setReadOnly(true); + language.setReadOnly(true); + languageLevel.setReadOnly(true); + cod.setReadOnly(true); + leadManager.setReadOnly(true); + project.setReadOnly(true); + dateOfEntry.setReadOnly(true); + dateOfExit.setReadOnly(true); + contractType.setReadOnly(true); + seniority.setReadOnly(true); + salary.setReadOnly(true); + bankName.setReadOnly(true); + accountNumber.setReadOnly(true); + gpss.setReadOnly(true); + sss.setReadOnly(true); + beneficiaries.setReadOnly(true); } private void setFieldsEditable() { + username.setReadOnly(false); firstName.setReadOnly(false); lastName.setReadOnly(false); status.setReadOnly(false); birthday.setReadOnly(false); birthCity.setReadOnly(false); - maritalStatus.setReadOnly(false); residenceAddress.setReadOnly(false); + localAddress.setReadOnly(false); + maritalStatus.setReadOnly(false); + numberOfChildren.setReadOnly(false); phoneNumber.setReadOnly(false); personalEmail.setReadOnly(false); position.setReadOnly(false); @@ -313,15 +421,65 @@ public class EmployeeView extends BeanValidationForm implements HasUrl emergencyCAddress.setReadOnly(false); emergencyCPhone.setReadOnly(false); emergencyCEmail.setReadOnly(false); - upload.setVisible(true); + upload.setVisible(false); + age.setReadOnly(false); + gender.setReadOnly(false); + status.setReadOnly(false); + ci.setReadOnly(false); + issuedIn.setReadOnly(false); + pTitle1.setReadOnly(false); + pTitle2.setReadOnly(false); + pTitle3.setReadOnly(false); + pStudy1.setReadOnly(false); + pStudy2.setReadOnly(false); + pStudy3.setReadOnly(false); + certification1.setReadOnly(false); + certification2.setReadOnly(false); + certification3.setReadOnly(false); + certification4.setReadOnly(false); + recognition.setReadOnly(false); + achievements.setReadOnly(false); + language.setReadOnly(false); + languageLevel.setReadOnly(false); + cod.setReadOnly(false); + leadManager.setReadOnly(false); + project.setReadOnly(false); + dateOfEntry.setReadOnly(false); + dateOfExit.setReadOnly(false); + contractType.setReadOnly(false); + seniority.setReadOnly(false); + salary.setReadOnly(false); + bankName.setReadOnly(false); + accountNumber.setReadOnly(false); + gpss.setReadOnly(false); + sss.setReadOnly(false); + beneficiaries.setReadOnly(false); } @Override protected List getFormComponents() { return List.of( - mt, fs, username, firstName, lastName, status, birthday, birthCity, maritalStatus, - residenceAddress, phoneNumber, personalEmail, position, team, ss, emergencyCName, - emergencyCAddress, emergencyCPhone, emergencyCEmail, si, upload, profileImagePreview, + username, + infoPer, + infoGenr, + upload, profileImagePreview, + firstName, lastName, + gender, status, + birthday, age, + birthCity, residenceAddress, localAddress, + maritalStatus, ci, issuedIn, numberOfChildren, + phoneNumber, personalEmail, + cod, position, team, leadManager, project, + contEmerg, emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail, + infProf, + titulos, pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, + certif, certification1, certification2, certification3, certification4, + logros, recognition, achievements, + idioma, language, languageLevel, + infoAdm, + infoCont, dateOfEntry, dateOfExit, contractType, seniority, salary, + datBanc, bankName, accountNumber, + datGest, gpss, sss, beneficiaries, saveButton, editButton, reportButton, dialog ); } diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java new file mode 100644 index 0000000..faa4208 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java @@ -0,0 +1,197 @@ +package com.primefactorsolutions.views; + +import com.vaadin.flow.component.datepicker.DatePicker; +import com.vaadin.flow.component.orderedlayout.HorizontalLayout; +import com.vaadin.flow.component.textfield.TextField; +import com.vaadin.flow.component.button.Button; +import com.vaadin.flow.component.combobox.ComboBox; +import com.vaadin.flow.component.grid.Grid; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.component.html.H2; +import com.vaadin.flow.router.PageTitle; +import com.vaadin.flow.router.Route; +import com.vaadin.flow.spring.annotation.SpringComponent; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; +import java.time.LocalDate; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("Hours Worked") +@Route(value = "/hours-worked/me", layout = MainLayout.class) +public class HoursWorkedView extends VerticalLayout { + public HoursWorkedView() { + H2 title = new H2("Registro de Horas Trabajadas"); + + DatePicker datePicker = new DatePicker("Selecciona una fecha"); + datePicker.setValue(LocalDate.now()); + + ComboBox equipoDropdown = new ComboBox<>("Equipo"); + equipoDropdown.setItems("Equipo 1", "Equipo 2", "Equipo 3"); // Ejemplo de datos + + TextField empleadoSearch = new TextField("Empleado (Search)"); + + HorizontalLayout filtersLayout = new HorizontalLayout(equipoDropdown, empleadoSearch); + + Grid grid = new Grid<>(Actividad.class, false); + grid.addColumn(Actividad::getNombre).setHeader("Actividad"); + grid.addColumn(Actividad::getLunes).setHeader("Lunes"); + grid.addColumn(Actividad::getMartes).setHeader("Martes"); + grid.addColumn(Actividad::getMiercoles).setHeader("Miércoles"); + grid.addColumn(Actividad::getJueves).setHeader("Jueves"); + grid.addColumn(Actividad::getViernes).setHeader("Viernes"); + grid.addColumn(Actividad::getSabado).setHeader("Sábado"); + grid.addColumn(Actividad::getDomingo).setHeader("Domingo"); + + grid.setItems( + new Actividad.Builder() + .nombre("Actividad 1") + .lunes(3) + .martes(3) + .miercoles(3) + .jueves(3) + .viernes(3) + .sabado(1) + .domingo(2) + .build(), + new Actividad.Builder() + .nombre("Actividad 2") + .lunes(2) + .martes(2) + .miercoles(2) + .jueves(2) + .viernes(2) + .sabado(0) + .domingo(1) + .build(), + new Actividad.Builder() + .nombre("Meeting 1") + .lunes(0) + .martes(0.5) + .miercoles(0.5) + .jueves(0) + .viernes(0) + .sabado(0.5) + .domingo(0) + .build() + ); + + Button actualizarButton = new Button("Actualizar"); + Button guardarButton = new Button("Guardar"); + Button cerrarButton = new Button("Cerrar"); + + HorizontalLayout buttonsLayout = new HorizontalLayout(actualizarButton, guardarButton, cerrarButton); + + add(title, datePicker, filtersLayout, grid, buttonsLayout); + } + + public static final class Actividad { + private final String nombre; + private final double lunes; + private final double martes; + private final double miercoles; + private final double jueves; + private final double viernes; + private final double sabado; + private final double domingo; + + private Actividad(final Builder builder) { + this.nombre = builder.nombre; + this.lunes = builder.lunes; + this.martes = builder.martes; + this.miercoles = builder.miercoles; + this.jueves = builder.jueves; + this.viernes = builder.viernes; + this.sabado = builder.sabado; + this.domingo = builder.domingo; + } + + public static class Builder { + private String nombre; + private double lunes; + private double martes; + private double miercoles; + private double jueves; + private double viernes; + private double sabado; + private double domingo; + + public Builder nombre(final String nombre) { + this.nombre = nombre; + return this; + } + + public Builder lunes(final double lunes) { + this.lunes = lunes; + return this; + } + + public Builder martes(final double martes) { + this.martes = martes; + return this; + } + + public Builder miercoles(final double miercoles) { + this.miercoles = miercoles; + return this; + } + + public Builder jueves(final double jueves) { + this.jueves = jueves; + return this; + } + + public Builder viernes(final double viernes) { + this.viernes = viernes; + return this; + } + + public Builder sabado(final double sabado) { + this.sabado = sabado; + return this; + } + + public Builder domingo(final double domingo) { + this.domingo = domingo; + return this; + } + + public Actividad build() { + return new Actividad(this); + } + } + + public String getNombre() { + return nombre; + } + + public double getLunes() { + return lunes; + } + + public double getMartes() { + return martes; + } + + public double getMiercoles() { + return miercoles; + } + + public double getJueves() { + return jueves; + } + + public double getViernes() { + return viernes; + } + + public double getSabado() { + return sabado; + } + + public double getDomingo() { + return domingo; + } + } +} diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index 9ae9504..5ebd36e 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -111,6 +111,9 @@ public class MainLayout extends AppLayout { LineAwesomeIcon.SUN.create())); SideNavItem timesheet = new SideNavItem("My Timesheet", TimesheetView.class, LineAwesomeIcon.HOURGLASS_START_SOLID.create()); + timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class, + LineAwesomeIcon.ID_CARD_SOLID.create())); + SideNavItem profile = new SideNavItem("My Profile", ProfileView.class, LineAwesomeIcon.USER_EDIT_SOLID.create()); diff --git a/src/main/resources/reports/ficha.html b/src/main/resources/reports/ficha.html index 6e84b3c..1211bf0 100644 --- a/src/main/resources/reports/ficha.html +++ b/src/main/resources/reports/ficha.html @@ -5,22 +5,124 @@ size: 7in 9.25in; margin: 27mm 16mm 27mm 16mm; } + body { + font-family: Arial, sans-serif; + font-size: 12px; + } + h3 { + text-align: center; + font-weight: bold; + margin-bottom: 15px; + } + table { + width: 100%; + border-collapse: collapse; + margin-bottom: 20px; + } + td, th { + border: 1px solid black; + padding: 8px; + text-align: left; + }
-

Empleado

-
-
-
Nombre
-
${firstName!""}
-
Telefono
-
${phoneNumber!""}
-
-
-
+

FICHA DE CONTRATACIÓN

+

Información General

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nombre Completo:${firstName!""} ${lastName!""}Sexo:${gender!""}
Fecha de Nacimiento:${birthday!""}Edad:${age!""}
Ciudad y País de Nacimiento:${birthCity!""}
Dirección / Domicilio Actual:${residenceAddress!""}
Estado Civil:${maritalStatus!""}Nro. CI:${ci!""}Expedido en:${issuedIn!""}
Nro. Hijos:${numberOfChildren!""}
Nro. Celular:${phoneNumber!""}
Email:${personalEmail!""}
Código de Empleado:${cod!""}
Cargo:${position!""}
Equipo:${team!""}
+ +

Información de Contratación

+ + + + + + + + + + + + + +
Fecha de Ingreso:${dateOfEntry!""}
Tipo de Contrato:${contractType!""}
Salario:${salary!""}
+ +

Datos Bancarios

+ + + + + + + + + +
Banco:${bankName!""}
Nro. Cuenta:${accountNumber!""}
+ +

Datos de Gestora Pública y Seguro Social

+ + + + + + + + + +
Código Único de Asegurado (GPSS):${gpss!""}
Derechohabientes:${beneficiaries!""}
- - -