Vacaciones #79
@ -28,36 +28,42 @@ public class Employee extends BaseEntity implements UserDetails {
|
||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El apellido solo debe contener letras")
|
||||
private String lastName;
|
||||
private LocalDate birthday;
|
||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "La ciudad de nacimiento solo debe contener letras")
|
||||
@Pattern(regexp = "^[a-zA-Z ,]+$", message = "La ciudad de nacimiento solo debe contener letras, espacios o comas")
|
||||
private String birthCity;
|
||||
private String age;
|
||||
@Size(max = 100, message = "La dirección de residencia no debe exceder 100 caracteres")
|
||||
@Size(max = 50, message = "La dirección de residencia no debe exceder 50 caracteres")
|
||||
private String residenceAddress;
|
||||
@Size(max = 100, message = "La dirección local no debe exceder 100 caracteres")
|
||||
@Size(max = 30, message = "La dirección local no debe exceder 100 caracteres")
|
||||
@Pattern(regexp = "^[a-zA-Z -]+$", message = "La dirección local solo debe contener letras y guion")
|
||||
private String localAddress;
|
||||
@Pattern(regexp = "^[0-9]+$", message = "El número de teléfono debe contener solo números")
|
||||
private String phoneNumber;
|
||||
@Email(message = "El correo personal no tiene un formato válido")
|
||||
private String personalEmail;
|
||||
|
||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El cargo solo debe contener letras")
|
||||
private String position;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "team_id", nullable = false)
|
||||
private Team team;
|
||||
@Size(max = 100, message = "El nombre de contacto de emergencia no debe exceder 100 caracteres")
|
||||
|
||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre y apellido de contacto"
|
||||
+ " de emergencia solo debe contener letras")
|
||||
private String emergencyCName;
|
||||
@Size(max = 100, message = "La dirección de contacto de emergencia no debe exceder 100 caracteres")
|
||||
private String emergencyCAddress;
|
||||
@Pattern(regexp = "^[0-9]+$", message = "El teléfono de contacto de emergencia debe contener solo números")
|
||||
@Pattern(regexp = "^[0-9]+$", message = "El teléfono de contacto de emergencia "
|
||||
+ " debe contener solo números")
|
||||
private String emergencyCPhone;
|
||||
@Email(message = "El correo de contacto de emergencia no tiene un formato válido")
|
||||
private String emergencyCEmail;
|
||||
|
||||
@Max(value = 10, message = "El número de hijos no puede exceder a 10")
|
||||
@Pattern(regexp = "^[0-9]+$", message = "La cantidad de hijos debe contener solo números")
|
||||
private String numberOfChildren;
|
||||
|
||||
@Pattern(regexp = "^[0-9]+$", message = "El CI debe contener solo números")
|
||||
private String ci;
|
||||
private String issuedIn;
|
||||
@Size(max = 100, message = "El título no debe exceder 100 caracteres")
|
||||
private String pTitle1;
|
||||
private String pTitle2;
|
||||
private String pTitle3;
|
||||
@ -70,9 +76,7 @@ public class Employee extends BaseEntity implements UserDetails {
|
||||
private String certification2;
|
||||
private String certification3;
|
||||
private String certification4;
|
||||
@Size(max = 255, message = "El reconocimiento no debe exceder 255 caracteres")
|
||||
private String recognition;
|
||||
@Size(max = 500, message = "Los logros no deben exceder 500 caracteres")
|
||||
private String achievements;
|
||||
|
||||
private String language;
|
||||
|
@ -56,7 +56,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
private final TimeOffRequestService requestService;
|
||||
private final TeamService teamService;
|
||||
|
||||
|
||||
// TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente.
|
||||
private final TextField username = createTextField("Username: ", 30, true);
|
||||
private final TextField firstName = createTextField("Nombres: ", 30, true);
|
||||
@ -65,24 +64,21 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
private final ComboBox<Employee.Gender> 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 TextField birthCity = createTextField("Ciudad y País de Nacimiento ejemplo: (Ciudad, País) ",
|
||||
30, false);
|
||||
private final TextField residenceAddress = createTextField("Dirección de Residencia", 50, false);
|
||||
private final TextField localAddress = createTextField("Dep/Provincia de Residencia", 10, false);
|
||||
private final TextField localAddress = createTextField("Departamento y Provincia de Residencia "
|
||||
+ " ejemplo: (Departamento-Provincia)", 30, false);
|
||||
private final ComboBox<Employee.MaritalStatus> 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 numberOfChildren = createTextField("Numero de Hijos", 2, false);
|
||||
private final TextField ci = createTextField("CI", 10, false);
|
||||
private final TextField issuedIn = createTextField("Expedido en ", 10, 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 ComboBox<Team> team = new ComboBox<>("Equipo");
|
||||
private final TextField leadManager = createTextField("Lead/Manager", 30, false);
|
||||
private final TextField project = createTextField("Proyecto", 30, false);
|
||||
private final EmailField personalEmail = createEmailField("E-mail ejemplo: (ejemplo@gmail.com)");
|
||||
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);
|
||||
private final EmailField emergencyCEmail = createEmailField("Email de Contacto");
|
||||
private final EmailField emergencyCEmail = createEmailField("Email de Contacto ejemplo: (ejemplo@gmail.com)");
|
||||
|
||||
private final MemoryBuffer buffer = new MemoryBuffer();
|
||||
private final Upload upload = new Upload(buffer);
|
||||
@ -101,10 +97,15 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
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 language = createTextField("Idioma", 50, false);
|
||||
private final TextField languageLevel = createTextField("Nivel de Idioma", 30, false);
|
||||
|
||||
//INFORMACION DE CONTRATACION
|
||||
//INFORMACION ADMINISTRATIVA
|
||||
private final TextField cod = createTextField("Codigo de Empleado", 20, false);
|
||||
private final TextField position = createTextField("Cargo", 30, false);
|
||||
private final ComboBox<Team> team = new ComboBox<>("Equipo");
|
||||
private final TextField leadManager = createTextField("Lead/Manager", 30, false);
|
||||
private final TextField project = createTextField("Proyecto", 30, false);
|
||||
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);
|
||||
@ -141,7 +142,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
//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 datBanc = new H3("Datos Bancarios");
|
||||
private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social");
|
||||
|
||||
public EmployeeView(final EmployeeService employeeService,
|
||||
@ -176,6 +177,9 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
editButton.setVisible(true);
|
||||
reportButton.setVisible(true);
|
||||
birthday.addValueChangeListener(event -> calculateAge());
|
||||
birthday.setMax(java.time.LocalDate.now());
|
||||
dateOfEntry.addValueChangeListener(event -> calculateSeniority());
|
||||
dateOfEntry.addValueChangeListener(event -> calculateSeniority());
|
||||
|
||||
reportButton.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
var employee = getEntity();
|
||||
@ -203,10 +207,30 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
int birthYear = birthday.getValue().getYear();
|
||||
int ages = currentYear - birthYear;
|
||||
age.setValue(String.valueOf(ages));
|
||||
if (ages < 18) {
|
||||
birthday.setInvalid(true);
|
||||
birthday.setErrorMessage("La edad no puede ser menor a 18 años.");
|
||||
Notification.show("La edad ingresada no es válida, debe ser mayor o igual a 18 años.");
|
||||
} else {
|
||||
birthday.setInvalid(false);
|
||||
}
|
||||
System.out.println(age);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateSeniority() {
|
||||
LocalDate entryDate = dateOfEntry.getValue();
|
||||
LocalDate exitDate = dateOfExit.getValue() != null ? dateOfExit.getValue() : LocalDate.now();
|
||||
|
||||
if (entryDate != null) {
|
||||
long yearsOfService = ChronoUnit.YEARS.between(entryDate, exitDate);
|
||||
String seniorityValue = yearsOfService + " años ";
|
||||
seniority.setValue(seniorityValue);
|
||||
} else {
|
||||
seniority.setValue("No disponible");
|
||||
}
|
||||
}
|
||||
|
||||
private void configureUpload() {
|
||||
upload.setAcceptedFileTypes("image/jpeg", "image/png");
|
||||
upload.setMaxFileSize(1024 * 1024);
|
||||
@ -218,11 +242,15 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
|
||||
getEntity().setProfileImage(base64Image);
|
||||
|
||||
profileImagePreview.setSrc("data:image/jpeg;base64," + base64Image);
|
||||
profileImagePreview.setSrc("data:image/png;base64," + base64Image);
|
||||
profileImagePreview.setMaxWidth("150px");
|
||||
profileImagePreview.setMaxHeight("150px");
|
||||
} catch (IOException e) {
|
||||
Notification.show("Error al subir la imagen.");
|
||||
Notification.show("Error al subir la imagen: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
Notification.show("Error en el servidor al procesar la imagen.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -393,12 +421,12 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
if (employee.getProfileImage() != null && !employee.getProfileImage().isEmpty()) {
|
||||
profileImagePreview.setSrc("data:image/jpeg;base64," + employee.getProfileImage());
|
||||
profileImagePreview.setVisible(true);
|
||||
profileImagePreview.setMaxWidth("150px");
|
||||
profileImagePreview.setMaxHeight("150px");
|
||||
profileImagePreview.setMaxWidth("250px");
|
||||
profileImagePreview.setMaxHeight("250px");
|
||||
|
||||
upload.setVisible(false);
|
||||
upload.setVisible(true);
|
||||
} else {
|
||||
profileImagePreview.setVisible(false);
|
||||
profileImagePreview.setVisible(true);
|
||||
upload.setVisible(true);
|
||||
}
|
||||
}
|
||||
@ -478,6 +506,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
emergencyCPhone.setReadOnly(false);
|
||||
emergencyCEmail.setReadOnly(false);
|
||||
upload.setVisible(false);
|
||||
profileImagePreview.setVisible(true);
|
||||
age.setReadOnly(false);
|
||||
gender.setReadOnly(false);
|
||||
status.setReadOnly(false);
|
||||
@ -525,7 +554,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
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,
|
||||
@ -533,6 +561,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
logros, recognition, achievements,
|
||||
idioma, language, languageLevel,
|
||||
infoAdm,
|
||||
cod, position, team, leadManager, project,
|
||||
infoCont, dateOfEntry, dateOfExit, contractType, seniority, salary,
|
||||
datBanc, bankName, accountNumber,
|
||||
datGest, gpss, sss, beneficiaries,
|
||||
|
Loading…
Reference in New Issue
Block a user