forked from ufjf-dcc/tcc-web
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calendário adicionado na página inicial do secretário Closes ufjf-dcc…
- Loading branch information
1 parent
356410e
commit 2d7b6fe
Showing
2 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,75 @@ | ||
package br.ufjf.tcc.controller; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.joda.time.DateTime; | ||
import org.zkoss.bind.annotation.BindingParam; | ||
import org.zkoss.bind.annotation.Command; | ||
import org.zkoss.bind.annotation.Init; | ||
import org.zkoss.zul.Label; | ||
|
||
import br.ufjf.tcc.business.PrazoBusiness; | ||
import br.ufjf.tcc.model.CalendarioSemestre; | ||
import br.ufjf.tcc.model.Prazo; | ||
|
||
public class HomeSecretariaController extends CommonsController { | ||
private List<Prazo> prazos; | ||
private int currentPrazo = 0; | ||
private String gridTitle = "Semestre ?"; | ||
private PrazoBusiness prazoBusiness = new PrazoBusiness(); | ||
|
||
@Init | ||
public void init() { | ||
CalendarioSemestre currentCalendar = getCurrentCalendar(); | ||
|
||
if (currentCalendar != null) { | ||
prazos = getCurrentCalendar().getPrazos(); | ||
|
||
DateTime currentDay = new DateTime(new Date()); | ||
|
||
for (int i = prazos.size() - 1; i >= 0; i--) { | ||
if (currentDay.isAfter(new DateTime(prazos.get(i) | ||
.getDataFinal()))) { | ||
currentPrazo = i + 1; | ||
break; | ||
} | ||
} | ||
|
||
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); | ||
|
||
gridTitle = "Calendário " | ||
+ currentCalendar.getNomeCalendarioSemestre() | ||
+ " (Fim do semestre: " | ||
+ dateFormat.format(currentCalendar.getFinalSemestre()) | ||
+ ")"; | ||
} | ||
} | ||
|
||
public List<Prazo> getPrazos() { | ||
return prazos; | ||
} | ||
|
||
public int getCurrentPrazo() { | ||
return currentPrazo; | ||
} | ||
|
||
public String getGridTitle() { | ||
return gridTitle; | ||
} | ||
|
||
@Command | ||
public void formatDate(@BindingParam("dataFinal") Date dataFinal, | ||
@BindingParam("label") Label label) { | ||
DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); | ||
label.setValue(df.format(dataFinal)); | ||
} | ||
|
||
@Command | ||
public void getDescription(@BindingParam("tipo") int type, | ||
@BindingParam("label") Label label) { | ||
label.setValue(prazoBusiness.getDescription(type)); | ||
} | ||
} |