for (Registration registration : registrations) {
for (RegistrationAppointment registrationAppointment : registration.getRegistrationAppointment()) {
if(!registrationAppointment.isReplacement()) {
for (Presence presence : registrationAppointment.getPresence()) {
GDDate presenceDate = new GDDate(presence.getDate());
if(presenceDate.afterOrEqualsDay(startDate) && presenceDate.beforeOrEqualsDay(endDate)) {
presences.add(presence);
}
}
} else {
for (Presence presence : registrationAppointment.getPresence()) {
GDDate presenceDate = new GDDate(presence.getDate());
if(presenceDate.afterOrEqualsDay(startDate) && presenceDate.beforeOrEqualsDay(endDate)) {
presences.add(presence);
}
}
}
}
}
if(presences.size() > 0) {
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortPresencesByDate(presences);
}
int numberOfPresences = 0;
int numberOfMisses = 0;
String statusText = "";
for (Presence presence : presences) {
if(presence.isPresent()) {
numberOfPresences++;
statusText = "Presente";
if(presence.getRegistrationAppointment().isReplacement()) {
if(presence.getRegistrationAppointment().getReplacementOfPresence() != null) {
statusText += " - Referente ao dia: " + new GDDate(presence.getRegistrationAppointment().getReplacementOfPresence().getDate()).getFormatedDate()+ " as "+presence.getRegistrationAppointment().getReplacementOfPresence().getDate().getHourOfDay() + ":00";
} else {
statusText += " - Aula extra";
}
}
} else {
numberOfMisses++;
statusText = "Ausente";
if(presence.alreadyReplaced()) {
statusText += " - Reposi��o marcada para: " + new GDDate(presence.getReplacement().getAppointmentDate()).getFormatedDate() + " as " + presence.getReplacement().getAppointmentDate().getHourOfDay() + ":00";
} else if(!presence.getRegistrationAppointment().isReplacement()) {
statusText += " - N�o marcada reposi��o";
}
}
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText(bodyStyle, new GDDate(presence.getDate()).getFormatedDate(), posX+5, 80));
page.addElement(divLine(posX+85));
int hour = presence.getDate().getHourOfDay();
page.addElement(insertText(bodyStyle, (hour <= 9 ? "0"+hour : hour) + ":00", posX+90, 50));
page.addElement(divLine(posX+140));
page.addElement(insertText(bodyStyle, statusText, posX+145, 390));