Skip to content

Commit

Permalink
Calendário adicionado na página inicial do secretário Closes ufjf-dcc…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecaetanov committed Apr 29, 2019
1 parent 356410e commit 2d7b6fe
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 6 deletions.
25 changes: 19 additions & 6 deletions WebContent/pages/home-secretaria.zul
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@
</div>
</column>
</columns>
<rows>
</grid>
<grid
emptyMessage="O calendário do semestre ainda não foi cadastrado no sistema."
model="@load(vm.prazos) @template('prazos')" style="margin:10px">
<auxhead sclass="text-center">
<auxheader colspan="2" label="@load(vm.gridTitle)" />
</auxhead>
<columns>
<column label="Data" width="80px" />
<column label="Descrição" />
</columns>
<template name="prazos">
<row>
<div align="center">
<label
value="Página inicial em construção. Utilize o menu no topo para navegar pelo sistema." />
</div>
<label
onCreate="@command('formatDate', dataFinal=each.dataFinal, label=self)"
style="@load(each.tipo eq vm.currentPrazo ? 'color:#337AB7;' : (each.tipo lt vm.currentPrazo ? 'color:#D3D3D3' : ''))" />
<label
onCreate="@command('getDescription', tipo=each.tipo, label=self)"
style="@load(each.tipo eq vm.currentPrazo ? 'color:#337AB7;' : (each.tipo lt vm.currentPrazo ? 'color:#D3D3D3' : ''))" />
</row>
</rows>
</template>
</grid>
</vlayout>
</div>
Expand Down
69 changes: 69 additions & 0 deletions src/br/ufjf/tcc/controller/HomeSecretariaController.java
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));
}
}

0 comments on commit 2d7b6fe

Please sign in to comment.