boldStyle_8.setPdfEncoding("Cp1252");
boldStyle_8.setPdfEmbedded(false);
jasperPrint.addStyle(boldStyle_8);
JRPrintPage page = new JRBasePrintPage();
posY = convert(10);
int posX = convert(10);
try {
page.addElement(printImage("titleReport.gif", posX, posY, 535, 45));
// page.addElement(printImage("logoReport.gif", posX+11, posY, 65, 45));
page.addElement(insertTitle(contTitle, posX+65, posY+11, 385));
page.addElement(printImage("corporateLogo.jpg", posX+456, posY, 77, 45));
List<Registration> registrationList = new ArrayList<Registration>();
int totalPerAttendant = 0;
posY += 50;
if(type == 1) {
totalPerAttendant = 0;
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
GDDate registrationDate = new GDDate(registration.getRegistrationDate());
if(registration.isActive() && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
registrationList.add(registration);
}
}
if(registrationList.size()>0){
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortRegistrationByDate(registrationList);
}
insertRegisteredtHeaderTable(page, posX);
total = 0;
for (Registration registration : registrationList) {
insertRegisteredDataTable(page, posX, registration);
totalPerAttendant++;
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
page.addElement(insertFooter(boldStyle, "Total de Alunos Ativos: "+totalPerAttendant+" Total R$ "+new Money(total).getFormatedValue(), posY));
int totalRegistrered = totalPerAttendant;
float totalPayed = total;
posY += 30;
page.addElement(printImage("titleReport.gif", posX, posY, 535, 45));
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
page.addElement(insertTitle("Alunos Matr�culados no per�odo, j� Finalizadas.", posX+35, posY+11, 410));
page.addElement(printImage("corporateLogo.jpg", posX+456, posY, 77, 45));
posY += 55;
totalPerAttendant = 0;
total = (float) 0.0;
registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
GDDate registrationDate = new GDDate(registration.getRegistrationDate());
if(!registration.isActive() && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
registrationList.add(registration);
}
}
if(registrationList.size()>0){
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortRegistrationByDate(registrationList);
}
insertRegisteredtHeaderTable(page, posX);
total = 0;
for (Registration registration : registrationList) {
insertRegisteredDataTable(page, posX, registration);
totalPerAttendant++;
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
page.addElement(insertFooter(boldStyle, "Total de Alunos Desativatos: "+totalPerAttendant+" Total R$ "+new Money(total).getFormatedValue(), posY));
posY += 30;
page.addElement(insertFooter(boldStyle, "Total Geral de Alunos no Periodo: "+(totalRegistrered+totalPerAttendant)+" Total R$ "+new Money(total+totalPayed).getFormatedValue(), posY));
jasperPrint.addPage(page);
}
else if(type == 2){
int totalStudents = 0;
Money totalMoney = new Money(0.0);
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
if(registration.isActive()) {
registrationList.add(registration);
}
}
if(registrationList.size()>0){
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortRegistrationByDate(registrationList);
}
Map <String, Person> attendantMap = (Map<String, Person>) system.query(new GetEmployee());
for (Person attendant : attendantMap.values()) {
total = 0;
int i = 0;
totalPerAttendant = 0;
for (Registration registration : registrationList) {
// String attendantName = ((Person) system.query(new GetEmployee(((Student) registration.getStudent().getPersonType("student")).getAttendanceResponsable()))).getName();
GDDate registrationDate = new GDDate(registration.getRegistrationDate());
if((registration.getEmployee().getName().equals(attendant.getName())) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
if(i == 0) {
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitle(boldStyle, attendant.getName(), posX+5, posY+5));
posY += 25;
insertRegisteredByAttendentHeaderTable(page, posX);
}
boolean addinfo = true;
String paidParcelsAndTotalParcels = ("00 / " + (registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size()));;
String parcelDate = "___/___/___";
String parcelPayDate = "___/___/___";
String parcelValueBeforeParcelDateExpiration = "R$_________";
List<Parcel> parcels = registration.getParcels();
int parcelid = 1;
for (int p = 0; p < parcels.size(); p++ ){
Parcel parcel = parcels.get(p);
if (!parcel.isRegistrationTax()){
if ( parcelid==1 ){
totalPerAttendant++;
total += new Money(parcel.getValueBeforeParcelDateExpiration()).getFloatValue();
totalStudents++;
totalMoney.credit(parcel.getValueBeforeParcelDateExpiration());
}
if ( parcel.getPayDate() != null){
paidParcelsAndTotalParcels = (parcelid > 9 ? parcelid : "0"+(parcelid) ) + " / " + ( registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size());
}
GDDate parcelGDDate = new GDDate(parcel.getDate());
if ( parcelGDDate.afterOrEqualsDay(startDate) && parcelGDDate.beforeOrEqualsDay(finishDate)){
parcelDate = parcel.getDate();
parcelPayDate = (parcel.getPayDate() == null ? "___/___/___":parcel.getPayDate().getFormatedDate());
parcelValueBeforeParcelDateExpiration = "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue();
addinfo = false;
}
if (addinfo && parcelid == parcels.size()){
parcelDate = parcel.getDate();
parcelPayDate = (parcel.getPayDate() == null ? "___/___/___":parcel.getPayDate().getFormatedDate());
parcelValueBeforeParcelDateExpiration = "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue();
}
parcelid++;
}
}
page.addElement(divLine(posX));
page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 50));
page.addElement(divLine(posX+55));
page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+60, 300));
page.addElement(divLine(posX+257));
page.addElement(insertText(bodyStyle, registration.getDuration()+" meses", posX+262, 70));
page.addElement(divLine(posX+307));
page.addElement(insertText(bodyStyle, paidParcelsAndTotalParcels, posX+315, 60));
page.addElement(divLine(posX+350));
page.addElement(insertText(bodyStyle, parcelDate , posX+358, 80));
page.addElement(divLine(posX+413));
page.addElement(insertText(bodyStyle, parcelPayDate, posX+421, 80));
page.addElement(divLine(posX+475));
page.addElement(insertText(bodyStyle, parcelValueBeforeParcelDateExpiration, posX+480, 100));
page.addElement(divLine(posX+534));
posY += 13;
page.addElement(drawHorizontalLine(posX, posY, 535));
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
insertRegisteredByAttendentHeaderTable(page, posX);
}
i++;
}
else
{
if((!registration.getEmployee().getName().equals(attendant.getName())) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
// System.out.println(registration.getEmployee().getName());
}
}
if(posY > (convert(277)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
if(i > 0){
posY += 3;
// page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant+" Total R$ "+new Money(total).getFormatedValue(), posY));
page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY));
posY += 18;
}
}
page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: " + totalStudents/*+" Total Geral R$ " + totalMoney.getFormatedValue()*/, posY));
posY += 16;
page.addElement(insertText(bodyStyle, " Obs: O campo Parcela exibe a Quantidade de Parcelas Pagas e o Total Geral de Parcelas (Pagas/Total)\n", posX+5, 510));
posY += 10;
page.addElement(insertText(bodyStyle, "O campo Pagamento exibe a Data de Pagamento, quando este n�o foi efetuado � exibido __/__/__ indicando que a parcela est� em aberto.", posX+79, 390,30));
jasperPrint.addPage(page);
} else if(type == 3){
int totalhowDoYouKnowVisualmidia = 0;
List <String> howDoYouKnowVisualmidiaList = (List<String>) system.query(new GetHowDoYouKnowVisualmidia());
for (String howDoYouKnowVisualmidia : howDoYouKnowVisualmidiaList) {
int i = 0;
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
registrationList.add(registration);
}
if(registrationList.size()>0){
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortRegistrationByDate(registrationList);
}
for (Registration registration : registrationList) {
Student student = (Student) registration.getStudent().getPersonType("student");
GDDate registrationDate = new GDDate(registration.getRegistrationDate());
if((student.getHowDoYouKnowVisualMidia().equals(howDoYouKnowVisualmidia)) && registration.isActive() && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
if(i == 0) {
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitle(boldStyle, howDoYouKnowVisualmidia, posX+5, posY+5));
posY += 25;
totalPerAttendant = 0;
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertCenterBoldText("Data", posX+5, posY, 70));
page.addElement(divLine(posX+75));
page.addElement(insertCenterBoldText("Nome", posX+80, posY, 300));
page.addElement(divLine(posX+380));
page.addElement(insertCenterBoldText("Dura��o", posX+385, posY, 70));
page.addElement(divLine(posX+455));
page.addElement(insertCenterBoldText("Valor", posX+460, posY, 75));
posY += 15;
}
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 70));
page.addElement(divLine(posX+75));
page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+80, 300));
page.addElement(divLine(posX+380));
page.addElement(insertText(bodyStyle, registration.getDuration()+" meses", posX+385, 70));
page.addElement(divLine(posX+455));
Parcel parcel = registration.getParcel(0);
if(parcel != null){
page.addElement(insertText(bodyStyle, "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue(), posX+460, 75));
}else{
page.addElement(insertText(bodyStyle, "R$ ______", posX+460, 75));
}
posY += 15;
totalPerAttendant++;
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
i++;
}
}
if(i > 0) {
page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY+2));
posY += 15;
totalhowDoYouKnowVisualmidia += totalPerAttendant;
}
}
posY += 7;
page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: "+totalhowDoYouKnowVisualmidia, posY+2));
jasperPrint.addPage(page);
} else if(type == 4) {
totalPerAttendant = 0;
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertCenterBoldText("Data", posX+5, posY, 70));
page.addElement(divLine(posX+75));
page.addElement(insertCenterBoldText("Nome", posX+80, posY, 230));
page.addElement(divLine(posX+310));
page.addElement(insertCenterBoldText("Telefone", posX+315, posY, 100));
page.addElement(divLine(posX+415));
page.addElement(insertCenterBoldText("Atendente", posX+420, posY, 115));
posY += 15;
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
if(!registration.isActive()) {
registrationList.add(registration);
}
}
if(registrationList.size()>0){
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
sortAlgorithm.sortRegistrationByDate(registrationList);
}
total = 0;
for (Registration registration : registrationList) {
if(!registration.isActive()) {
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 70));
page.addElement(divLine(posX+75));
page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+80, 230));
page.addElement(divLine(posX+310));
page.addElement(insertText(bodyStyle, registration.getStudent().getPhone(), posX+315, 100));
page.addElement(divLine(posX+415));
page.addElement(insertText(bodyStyle, registration.getEmployee().getName(), posX+420, 115));
posY += 15;
totalPerAttendant++;
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
}
page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY));
posY += 15;
jasperPrint.addPage(page);
} else if(type == 5) {
Money totalDesistent = new Money(0.0);
int totalStudents = 0;
for (String status : statusList) {
total = (float) 0.0;
int i = 0;
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
registrationList.clear();
for (Registration registration : registrationMap.values()) {
if(!registration.isActive()) {
registrationList.add(registration);
}
}
// if(registrationList.size()>0){
// MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
// sortAlgorithm.sortRegistrationByDate(registrationList);
// }
Comparator<Registration> comparator = new Comparator<Registration>() {
@Override
public int compare(Registration o1, Registration o2) {
int result = -1;
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(o1.getEndDate().getDate());
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(o2.getEndDate().getDate());
result = calendar1.compareTo(calendar2);
return result;
}
};
Collections.sort(registrationList,comparator);
for (Registration registration : registrationList) {
GDDate registrationDate = new GDDate(registration.getEndDate());
if(checkStatus(status, registration.getEndStatus()) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
if (i == 0){
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitle(boldStyle, status, posX+5, posY+5));
posY += 25;
totalPerAttendant = 0;
insertEndedRegistrationHeaderTable(page, posX);
i++;
}
// page.addElement(drawRectangle(posX, posY, 535, 13, 0));
page.addElement(divLine(posX));
page.addElement(insertText(bodyStyle, registrationDate.getFormatedDate(), posX+5, 48));
page.addElement(divLine(posX+58));
page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+63, 152));
page.addElement(divLine(posX+206));
String paidParcelsAndTotalParcels = (getParcelsValue(registration) > 9 ? getParcelsValue(registration) : "0"+getParcelsValue(registration) ) + " / " + ( registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size());
// page.addElement(insertText(bodyStyle, (getParcelsValue(registration) == 0 ? "" : new Money(getParcelsValue(registration)).getFormatedValue()), posX+275, 70));
page.addElement(insertText(bodyStyle, paidParcelsAndTotalParcels, posX+217, 70));
page.addElement(divLine(posX+258));
Parcel parcel0 = (registration.getParcels().size()> 0 ? registration.getParcel(0).isRegistrationTax() ? registration.getParcel(1) : registration.getParcel(0) : null);
if(parcel0 != null){
page.addElement(insertText(bodyStyle, "R$ " + new Money(parcel0.getValueBeforeParcelDateExpiration()).getFormatedValue(), posX+265, 100));
total += new Money(parcel0.getValueBeforeParcelDateExpiration()).getFloatValue();
} else{
page.addElement(insertText(bodyStyle, "R$ ______", posX+265, 100));
}
page.addElement(divLine(posX+320));
page.addElement(insertText(bodyStyle, registration.getEndStatus().get(0), posX+325, 86));
page.addElement(divLine(posX+410));
page.addElement(insertText(bodyStyle, registration.getEndEmployee().getName(), posX+415, 120));
page.addElement(divLine(posX+534));
posY += 13;
page.addElement(drawHorizontalLine(posX, posY, 535));
totalPerAttendant++;
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
insertEndedRegistrationHeaderTable(page, posX);
}
}
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
// insertHeaderTable(page, posX);
}
}
if(i > 0){
totalDesistent.credit(total);
totalStudents+=totalPerAttendant;
page.addElement(insertFooter(boldStyle, "Total de Alunos: " + totalPerAttendant + " Total R$ " + new Money(total).getFormatedValue(), posY));
posY += 18;
}
if (status.equals(statusList.get(statusList.size()-1)) ){
page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: " + totalStudents+" Total Geral R$ " + totalDesistent.getFormatedValue(), posY));
posY += 16;
page.addElement(insertText(bodyStyle, " Obs: O campo Parcela exibe a Quantidade de Parcelas Pagas e o Total Geral de Parcelas (Pagas/Total)", posX+5, 510));
}
}
jasperPrint.addPage(page);
//relatorio de alunos que nao estao no registration appoitment map
} else if (type == 6) {
List<RegistrationAppointment> registrationAppointmentList = new ArrayList<RegistrationAppointment>();
Map<String, List <RegistrationAppointment>> registrationAppoitmentMap = (Map<String, List <RegistrationAppointment>>) system.query(new GetAllAppointmentMap());
for (String idMap : registrationAppoitmentMap.keySet()) {
for (RegistrationAppointment registrationAppointment : registrationAppoitmentMap.get(idMap)) {
registrationAppointmentList.add(registrationAppointment);
}
}
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
List<Registration> registrations = new ArrayList<Registration>();
for (Registration registration : registrationMap.values()) {
if ( registration.isActive() )
registrations.add(registration); //adiciona no relat�rio apenas os Registrations ativos
}
for(int i=0; i<registrationAppointmentList.size(); i++) {
if (registrations.contains(registrationAppointmentList.get(i).getRegistration())) {
registrations.remove(registrationAppointmentList.get(i).getRegistration());
}
}
int i = 0;
for (Registration registration: registrations) {
Comparator<Registration> comparator = new Comparator<Registration>() {
@Override
public int compare(Registration o1, Registration o2) {
int result = -1;
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
calendar1.set(Integer.parseInt(o1.getRegistrationDate().substring(6, o1.getRegistrationDate().length())), Integer.parseInt(o1.getRegistrationDate().substring(3, 5)), Integer.parseInt(o1.getRegistrationDate().substring(0, 2)));
calendar2.set(Integer.parseInt(o2.getRegistrationDate().substring(6, o1.getRegistrationDate().length())), Integer.parseInt(o2.getRegistrationDate().substring(3, 5)), Integer.parseInt(o2.getRegistrationDate().substring(0, 2)));
result = calendar1.compareTo(calendar2);
return result;
}
};
Collections.sort(registrations,comparator);
if (i == 0){
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitle(boldStyle, "Relat�rio de todos Alunos sem agendamento de aula", posX+5, posY+5));
posY += 25;
totalPerAttendant = 0;
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertCenterBoldText("Data matr�cula", posX+5, posY, 100));
page.addElement(divLine(posX+110));
page.addElement(insertCenterBoldText("Nome", posX+115, posY, 70));
// page.addElement(divLine(posX+450));
// page.addElement(insertCenterBoldText("Status", posX+450, posY, 70));
posY += 15;
i++;
}
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+20, 100));
page.addElement(divLine(posX+110));
page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+115, 530));
// page.addElement(divLine(posX+450));
// page.addElement(insertText(bodyStyle, (registration.isActive() ? "Ativo" : "Desativo"), posX+455, 70));
posY += 15;
page.addElement(drawHorizontalLine(posX, posY, 535));
totalPerAttendant++;
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
if(posY > (convert(297)-20)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
if(i > 0){
page.addElement(insertFooter(boldStyle, "Total de Alunos: " + totalPerAttendant, posY));
posY += 15;
}
jasperPrint.addPage(page);