Commit d6e261d1 authored by Fabiano Sluzarski's avatar Fabiano Sluzarski
Browse files

Email support added, TravelRequisition class added (need to be

reviewed), PDF for the requisition (need to be reviewed) and checks to
avoid duplicates in course and organization.
parent e26c04c2
......@@ -179,6 +179,26 @@
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
......
......@@ -97,7 +97,7 @@ privileged aspect Person_Roo_Entity {
}
public static List<Person> Person.findAllPeople() {
return entityManager().createQuery("SELECT o FROM Person o", Person.class).getResultList();
return entityManager().createQuery("SELECT o FROM Person o ORDER BY name", Person.class).getResultList();
}
public static Person Person.findPerson(Long id) {
......@@ -106,7 +106,7 @@ privileged aspect Person_Roo_Entity {
}
public static List<Person> Person.findPersonEntries(int firstResult, int maxResults) {
return entityManager().createQuery("SELECT o FROM Person o", Person.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
return entityManager().createQuery("SELECT o FROM Person o ORDER BY name", Person.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
}
}
package br.ufpr.c3sl.sapos.models.scholar;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.servlet.http.HttpServletResponse;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import br.ufpr.c3sl.sapos.models.customization.Configuration;
import br.ufpr.c3sl.sapos.models.people.Person;
import br.ufpr.c3sl.sapos.models.people.Student;
import br.ufpr.c3sl.sapos.models.people.enums.UserKind;
import br.ufpr.c3sl.sapos.models.report.ReportUtil;
import br.ufpr.c3sl.sapos.models.scholar.enums.RequestStatus;
import br.ufpr.c3sl.sapos.models.scholar.enums.RequesterKind;
import br.ufpr.c3sl.sapos.models.scholar.enums.TicketKind;
import br.ufpr.c3sl.sapos.models.scholar.enums.TripKind;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
@RooJavaBean
@RooToString
@RooEntity
public class TravelRequisition { //base: Research Field
//TODO ??????
@ManyToOne
private Person person;
@Enumerated(EnumType.STRING)
private RequesterKind requesterKind;
private String justification;
private String conference;
private String place;
@Enumerated(EnumType.STRING)
private TripKind tripKind;
@Temporal(TemporalType.DATE)
@DateTimeFormat(style = "S-")
private Date startDate;
@Temporal(TemporalType.DATE)
@DateTimeFormat(style = "S-")
private Date endDate;
private Integer dayNumber;
private Float totalValue;
@Enumerated(EnumType.STRING)
private TicketKind ticketKind;
private String destinations;
private String tripStartDate;
private String tripEndDate;
private Float ticketValue;
@Enumerated(EnumType.STRING)
private RequestStatus requestStatus;
private String observations;
public static void requisitionPdf(TravelRequisition tr, HttpServletResponse response) {
response.setContentType("application/pdf");
//left,right,top,bottom margins
Document document = new Document(PageSize.A4, 80, 80, 80, 80);
Paragraph p = new Paragraph();
Phrase phr = new Phrase();
try {
try {
ReportUtil.getPdfWriter(document,response);
//PdfWriter writer = ReportUtil.getPdfWriter(document,response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
document.open();
Person person = tr.person;
ReportUtil.makeHeader(document,"PROPOSTA DE CONCESSÃO DE PASSAGENS E DIÁRIAS");
phr = new Phrase("1 – BENEFICIÁRIO: ", ReportUtil.getTitleTextFont());
p.add(phr);
phr = new Phrase(tr.requesterKind.toString(), ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
p = new Paragraph("Nome: "+person.getName(), ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph();
phr = new Phrase("Cargo/Profissão: ", ReportUtil.getNormalTextFont());
p.add(phr);
if (person.getUserKind() == UserKind.Aluno)
phr = new Phrase("Aluno", ReportUtil.getNormalTextFont());
else if (person.getUserKind() == UserKind.Professor)
phr = new Phrase("Professor", ReportUtil.getNormalTextFont());
else
phr = new Phrase("Funcionário", ReportUtil.getNormalTextFont());
p.add(phr);
phr = new Phrase(" Data de nascimento: "+person.getDateOfBirth(), ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
//TODO Unidade
phr = new Phrase("Unidade: ", ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
//TODO SIAPE
phr = new Phrase(" Matrícula SIAPE: ", ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
phr = new Phrase("RG: "+person.getRg(), ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
phr = new Phrase(" CPF: "+person.getCpf(), ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
phr = new Phrase("E-mail: "+person.getEmail(), ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
phr = new Phrase(" Telefone: "+person.getPhone(), ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
phr = new Phrase("Dados Bancários "+person.getBank().getName()+" Conta: "+person.getBankAccount(), ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
document.add(p);
//1 – BENEFICIÁRIO: ( ) Servidor ( ) Colaborador Eventual ( ) Convidado ( x ) Assessoramento Especial
//Nome: Tarcizio Alexandre Bini
//Cargo/Profissão: Aluno Doutorado Data de nascimento: 18/12/1983
//Unidade: PPGInf Matrícula SIAPE xxxxxxx
//RG: 8.342.307-2 CPF: 051.518.129-39
//E-mail: tarcizioab@c3sl.ufpr.br Telefone: (42) 3025-7866 / (42) 8826-8851 / (42) 9979-4180
//Dados Bancários BB Ag: 3233-6 c/c: 17.585-4
p = new Paragraph("2 – MOTIVO DA VIAGEM:", ReportUtil.getTitleTextFont());
document.add(p);
p = new Paragraph("Finalidade: "+tr.justification, ReportUtil.getNormalTextFont());
document.add(p);
phr = new Phrase("Local: "+tr.place, ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
phr = new Phrase(" Período "+tr.startDate+" – "+tr.endDate, ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
phr = new Phrase("Deslocamento: "+tr.tripKind, ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
document.add(p);
//2 – MOTIVO DA VIAGEM
//Finalidade: Apresentação de trabalho no evento ICEIS (International Conference on Enterprise Information System)
//Local: Pequin / China Período: 08/06/2011 – 11/06/2011
//Deslocamento: Condução Própria ( ) Aérea (X) Rodoviária ( )
p = new Paragraph();
phr = new Phrase("3 – DIÁRIAS", ReportUtil.getTitleTextFont());
p.add(phr);
phr = new Phrase(" (Em caso de opção pelo pagamento do Hotel licitado NÃO será pago diárias na conta do beneficiário)", ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
p = new Paragraph("N.º de diárias (Depósito em conta) – "+tr.dayNumber, ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("( ) Pagar diárias no Caravelle Licitado ( ) Apenas efetuar reserva no Hotel Licitado", ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("Valor das diárias (preenchido pela PRPPG) R$ ", ReportUtil.getNormalTextFont());
document.add(p);
//3 – DIÁRIAS (Em caso de opção pelo pagamento do Hotel licitado NÃO será pago diárias na conta do beneficiário)
//N.º de diárias (Depósito em conta) – 6 diárias internacional
// ( ) Pagar diárias no Caravelle Licitado ( ) Apenas efetuar reserva no Hotel Licitado
//Valor das diárias (preenchido pela PRPPG) R$
p = new Paragraph();
phr = new Phrase("4 – BILHETE DE PASSAGEM: ", ReportUtil.getTitleTextFont());
p.add(phr);
phr = new Phrase(tr.ticketKind.toString(), ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
p = new Paragraph("TRECHO: "+tr.destinations, ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("SAÍDA: "+tr.tripStartDate, ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("RETORNO: "+tr.tripEndDate, ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("Valor da passagem: "+tr.ticketValue, ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("4.1 – Reserva efetuada com o menor preço:", ReportUtil.getNormalTextFont());
document.add(p);
document.add(Chunk.NEWLINE);
p = new Paragraph("");
document.add(p);
phr = new Phrase("Data: "+ReportUtil.getTodayDate().get(Calendar.DAY_OF_MONTH)+"/"+ReportUtil.getTodayDate().get(Calendar.MONTH)+1+"/"+ReportUtil.getTodayDate().get(Calendar.YEAR), ReportUtil.getNormalTextFont());
p = new Paragraph();
p.add(phr);
phr = new Phrase(" Assinatura e Carimbo", ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
//5 – BILHETE DE PASSAGEM:
// Aérea ( x ) Rodoviária: ( ) Convencional ( ) Executivo ( ) Leito
// TRECHO: Ctba /Pequin/Ctba
// SAÍDA: DATA/HORA/EMPRESA 06/06/2011 à noite
// RETORNO: DATA/HORA/EMPRESA 12/06/2011 pela manhã
// Valor da passagem: R$
// 5.1 – Reserva efetuada com o menor preço:
// Data: 23/05/2011 Assinatura e Carimbo
p = new Paragraph("5 – AUTORIZAÇÃO DA CHEFIA", ReportUtil.getTitleTextFont());
document.add(p);
if (tr.requestStatus == RequestStatus.Confirmada) {
p = new Paragraph("Autorizo esta requisição e me comprometo a entregar os documentos comprobatórios/prestação de contas, no prazo máximo de 7 (sete) dias após o retorno da viagem.", ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("Nome do chefe: "+Configuration.findConfigValueByName(Configuration.COORDINATOR_NAME), ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("Cargo: ", ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("E-mail: "+Configuration.findConfigValueByName("coordinator.email"), ReportUtil.getNormalTextFont());
document.add(p);
p = new Paragraph("Unidade Pós Graduação em Informática", ReportUtil.getNormalTextFont());
document.add(p);
document.add(Chunk.NEWLINE);
p = new Paragraph("");
document.add(p);
p = new Paragraph();
phr = new Phrase(" Assinatura e Carimbo", ReportUtil.getNormalTextFont());
p.add(phr);
document.add(p);
}
else if (tr.requestStatus == RequestStatus.Negada) {
p = new Paragraph("Pedido negado.", ReportUtil.getNormalTextFont());
document.add(p);
}
else {
p = new Paragraph("A sua requisição está sendo processada.", ReportUtil.getNormalTextFont());
document.add(p);
}
//6 – AUTORIZAÇÃO DA CHEFIA
//Autorizo esta requisição e me comprometo a entregar os documentos comprobatórios/prestação de contas, no prazo máximo de 7 (sete) dias após o retorno da viagem.
//Nome do chefe: Luiz Eduardo Soares de Oliveira
//Cargo: Coordenador do Projeto/ PPG ____________________________________
//Telefone e e-mail r: 3655 e lesoliveira@inf..ufpr.br Assinatura e carimbo
//Unidade Pós Graduação em Informática
p = new Paragraph("6 – AUTORIZAÇÃO FINANCEIRA:", ReportUtil.getTitleTextFont());
document.add(p);
if (tr.requestStatus == RequestStatus.Confirmada) {
p = new Paragraph("Na qualidade de ordenador de despesa autorizo esta requisição de diárias e passagens.", ReportUtil.getNormalTextFont());
document.add(p);
}
else if (tr.requestStatus == RequestStatus.Negada) {
p = new Paragraph("Pedido negado.", ReportUtil.getNormalTextFont());
document.add(p);
}
else {
p = new Paragraph("A sua requisição está sendo processada.", ReportUtil.getNormalTextFont());
document.add(p);
}
//7 – AUTORIZAÇÃO FINANCEIRA:
//Na qualidade de ordenador de despesa autorizo esta requisição de diárias e passagens.
document.close();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import org.springframework.beans.factory.annotation.Configurable;
privileged aspect TravelRequisition_Roo_Configurable {
declare @type: TravelRequisition: @Configurable;
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import br.ufpr.c3sl.sapos.models.scholar.TravelRequisition;
import java.lang.Integer;
import java.lang.Long;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PersistenceContext;
import javax.persistence.Version;
import org.springframework.transaction.annotation.Transactional;
privileged aspect TravelRequisition_Roo_Entity {
declare @type: TravelRequisition: @Entity;
@PersistenceContext
transient EntityManager TravelRequisition.entityManager;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long TravelRequisition.id;
@Version
@Column(name = "version")
private Integer TravelRequisition.version;
public Long TravelRequisition.getId() {
return this.id;
}
public void TravelRequisition.setId(Long id) {
this.id = id;
}
public Integer TravelRequisition.getVersion() {
return this.version;
}
public void TravelRequisition.setVersion(Integer version) {
this.version = version;
}
@Transactional
public void TravelRequisition.persist() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.persist(this);
}
@Transactional
public void TravelRequisition.remove() {
if (this.entityManager == null) this.entityManager = entityManager();
if (this.entityManager.contains(this)) {
this.entityManager.remove(this);
} else {
TravelRequisition attached = TravelRequisition.findTravelRequisition(this.id);
this.entityManager.remove(attached);
}
}
@Transactional
public void TravelRequisition.flush() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.flush();
}
@Transactional
public void TravelRequisition.clear() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.clear();
}
@Transactional
public TravelRequisition TravelRequisition.merge() {
if (this.entityManager == null) this.entityManager = entityManager();
TravelRequisition merged = this.entityManager.merge(this);
this.entityManager.flush();
return merged;
}
public static final EntityManager TravelRequisition.entityManager() {
EntityManager em = new TravelRequisition().entityManager;
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
return em;
}
public static long TravelRequisition.countTravelRequisitions() {
return entityManager().createQuery("SELECT COUNT(o) FROM TravelRequisition o", Long.class).getSingleResult();
}
public static List<TravelRequisition> TravelRequisition.findAllTravelRequisitions() {
return entityManager().createQuery("SELECT o FROM TravelRequisition o", TravelRequisition.class).getResultList();
}
public static TravelRequisition TravelRequisition.findTravelRequisition(Long id) {
if (id == null) return null;
return entityManager().find(TravelRequisition.class, id);
}
public static List<TravelRequisition> TravelRequisition.findTravelRequisitionEntries(int firstResult, int maxResults) {
return entityManager().createQuery("SELECT o FROM TravelRequisition o", TravelRequisition.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import java.util.Date;
import br.ufpr.c3sl.sapos.models.people.Person;
import br.ufpr.c3sl.sapos.models.scholar.enums.RequestStatus;
import br.ufpr.c3sl.sapos.models.scholar.enums.RequesterKind;
import br.ufpr.c3sl.sapos.models.scholar.enums.TicketKind;
import br.ufpr.c3sl.sapos.models.scholar.enums.TripKind;
privileged aspect TravelRequisition_Roo_JavaBean {
// TODO
public Person TravelRequisition.getPerson() {
return this.person;
}
public void TravelRequisition.setPerson(Person person) {
this.person = person;
}
public RequesterKind TravelRequisition.getRequesterKind() {
return this.requesterKind;
}
public void TravelRequisition.setRequesterKind(RequesterKind requesterKind) {
this.requesterKind = requesterKind;
}
public String TravelRequisition.getJustification() {
return this.justification;
}
public void TravelRequisition.setJustification(String justification) {
this.justification = justification;
}
public String TravelRequisition.getConference() {
return this.conference;
}
public void TravelRequisition.setConference(String conference) {
this.conference = conference;
}
public String TravelRequisition.getPlace() {
return this.place;
}
public void TravelRequisition.setPlace(String place) {
this.place = place;
}
public TripKind TravelRequisition.getTripKind() {
return this.tripKind;
}
public void TravelRequisition.setTripKind(TripKind tripKind) {
this.tripKind = tripKind;
}
public Date TravelRequisition.getStartDate() {
return this.startDate;
}
public void TravelRequisition.setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date TravelRequisition.getEndDate() {
return this.endDate;
}
public void TravelRequisition.setEndDate(Date endDate) {
this.endDate = endDate;
}
public Integer TravelRequisition.getDayNumber() {
return this.dayNumber;
}
public void TravelRequisition.setDayNumber(Integer dayNumber) {
this.dayNumber = dayNumber;
}
public Float TravelRequisition.getTotalValue() {
return this.totalValue;