Commit 14479dbb7655af49f6cb40554c248ea040dd18a2
1 parent
b3585ae1
Exists in
master
Lista de questionarios com filtro.
Showing
5 changed files
with
261 additions
and
4 deletions
Show diff stats
WebContent/WEB-INF/jsp/questionario/listaQuestionario.jsp
0 → 100644
| ... | ... | @@ -0,0 +1,108 @@ |
| 1 | +<%@taglib prefix="t" tagdir="/WEB-INF/tags"%> | |
| 2 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | |
| 3 | +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | |
| 4 | +<%@page contentType="text/html" pageEncoding="UTF-8"%> | |
| 5 | +<t:baseLayout> | |
| 6 | + <jsp:body> | |
| 7 | + | |
| 8 | + <form action="${pageContext.request.contextPath}/listar-questionario" method="post"> | |
| 9 | + | |
| 10 | + <fieldset> | |
| 11 | + <legend>Filtros</legend> | |
| 12 | + | |
| 13 | + | |
| 14 | + <label for="statusRelatorio">Relatório Respondido:</label> | |
| 15 | + <select id="statusRelatorio" name="statusRelatorio"> | |
| 16 | + <option value="todos" ${statusRel == ''?'selected=\"selected\"':''}>Todos</option> | |
| 17 | + <option value="sim" ${statusRel == 'sim'?'selected=\"selected\"':''}>Sim</option> | |
| 18 | + <option value="nao" ${statusRel == 'nao'?'selected=\"selected\"':''}>Não</option> | |
| 19 | + </select> | |
| 20 | + <br><br> | |
| 21 | + | |
| 22 | + <label for="statusPlanoTrabalho">Plano de trabalho Anexado:</label> | |
| 23 | + <select id="statusPlanoTrabalho" name="statusPlanoTrabalho"> | |
| 24 | + <option value="todos" ${statusPlanoTrab == ''?'selected=\"selected\"':''}>Todos</option> | |
| 25 | + <option value="sim" ${statusPlanoTrab == 'sim'?'selected=\"selected\"':''}>Sim</option> | |
| 26 | + <option value="nao" ${statusPlanoTrab == 'nao'?'selected=\"selected\"':''}>Não</option> | |
| 27 | + </select> | |
| 28 | + <br><br> | |
| 29 | + | |
| 30 | + <label for="nomeOrgao">Nome do Órgao que contenha:</label> | |
| 31 | + <input type="text" id="nomeOrgao" name="nomeOrgao" size="70" value="${nomeOrgao }"> | |
| 32 | + <br><br> | |
| 33 | + | |
| 34 | + <input type="submit" value="Listar"> | |
| 35 | + | |
| 36 | + </fieldset> | |
| 37 | + </form> | |
| 38 | + <br> | |
| 39 | + <br> | |
| 40 | + | |
| 41 | + <label>Total de solicitações: <span>${totalSolicitacoes}</span></label> | |
| 42 | + <br> | |
| 43 | + <table id="questionarios"> | |
| 44 | + <tr> | |
| 45 | + <th>Nº Linha</th> | |
| 46 | + <th>Orgão</th> | |
| 47 | + <th>Responsável</th> | |
| 48 | + <th>Cargo</th> | |
| 49 | + <th>Telefone</th> | |
| 50 | + <th>Email</th> | |
| 51 | + <th>Recebimento Email</th> | |
| 52 | + <th>Resposta Email</th> | |
| 53 | + <th>Data Relatório Respondido</th> | |
| 54 | + <th>Relatório Respondido</th> | |
| 55 | + <th>Plano de Trabalho Enviado</th> | |
| 56 | + <th>download Plano de Trabalho</th> | |
| 57 | + | |
| 58 | + </tr> | |
| 59 | + | |
| 60 | + <c:if test="${not empty lsquestionario}"> | |
| 61 | + | |
| 62 | + <c:forEach items="${lsquestionario}" var="questionario" | |
| 63 | + varStatus="contador"> | |
| 64 | + <c:if test="${contador.count mod 2 == 0}"> | |
| 65 | + <tr bgcolor="#FFFFFF"> | |
| 66 | + | |
| 67 | + </c:if> | |
| 68 | + <c:if test="${contador.count mod 2 != 0}"> | |
| 69 | + <tr bgcolor="#DAA520"> | |
| 70 | + | |
| 71 | + </c:if> | |
| 72 | + <td>${contador.count}</td> | |
| 73 | + <td>${questionario.noOrgao}</td> | |
| 74 | + <td>${questionario.responsavel}</td> | |
| 75 | + <td>${questionario.cargoResponsavel}</td> | |
| 76 | + <td>${questionario.telefone}</td> | |
| 77 | + <td>${questionario.emailDestinoOrgao}</td> | |
| 78 | + <td>${questionario.dtRecebimentoEmail}</td> | |
| 79 | + <td>${questionario.dtRespostaEmail}</td> | |
| 80 | + <td>${questionario.dataRespostaQuestionario}</td> | |
| 81 | + | |
| 82 | + <c:if test="${not empty questionario.dataRespostaQuestionario}"> | |
| 83 | + <td><input type="checkbox" checked="checked" | |
| 84 | + disabled="disabled"> </td> | |
| 85 | + </c:if> | |
| 86 | + <c:if test="${empty questionario.dataRespostaQuestionario}"> | |
| 87 | + <td><input type="checkbox" disabled="disabled"> </td> | |
| 88 | + </c:if> | |
| 89 | + | |
| 90 | + | |
| 91 | + <c:if test="${questionario.planoTrabalhoEnviado == true}"> | |
| 92 | + <td><input type="checkbox" checked="checked" | |
| 93 | + disabled="disabled"> </td> | |
| 94 | + </c:if> | |
| 95 | + <c:if test="${questionario.planoTrabalhoEnviado == false}"> | |
| 96 | + <td><input type="checkbox" disabled="disabled"> </td> | |
| 97 | + </c:if> | |
| 98 | + <td><a | |
| 99 | + href="${pageContext.request.contextPath}/recuperar-plano-trabalho/${questionario.idQuestionario}">Recuperar</a></td> | |
| 100 | + </tr> | |
| 101 | + | |
| 102 | + </c:forEach> | |
| 103 | + </c:if> | |
| 104 | + | |
| 105 | + </table> | |
| 106 | + | |
| 107 | + </jsp:body> | |
| 108 | +</t:baseLayout> | |
| 0 | 109 | \ No newline at end of file | ... | ... |
WebContent/WEB-INF/jsp/questionario/questionario.jsp
| ... | ... | @@ -112,10 +112,7 @@ table, th, td { |
| 112 | 112 | </c:if> |
| 113 | 113 | |
| 114 | 114 | </table> |
| 115 | -<!-- <a href="${pageContext.request.contextPath}/recuperar-plano-trabalho">Recuperar Plano de Trabalho</a>--> | |
| 116 | -</body> | |
| 117 | - | |
| 118 | - | |
| 119 | 115 | |
| 116 | +</body> | |
| 120 | 117 | |
| 121 | 118 | </html> |
| 122 | 119 | \ No newline at end of file | ... | ... |
src/br/com/controller/QuestionarioController.java
| ... | ... | @@ -59,7 +59,31 @@ public class QuestionarioController { |
| 59 | 59 | public void confirmacaoHash() { |
| 60 | 60 | |
| 61 | 61 | } |
| 62 | + | |
| 63 | + @Path("/lista-questionario") | |
| 64 | + public void listaQuestionario() { | |
| 62 | 65 | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Path("/listar-questionario") | |
| 69 | + public void listarQuestionarioComFiltro(String statusRelatorio, String statusPlanoTrabalho, String nomeOrgao) { | |
| 70 | + | |
| 71 | + QuestionarioDao questionarioDao = new QuestionarioDao(); | |
| 72 | + List<Questionario> lsquestionario = new ArrayList<Questionario>(); | |
| 73 | + lsquestionario = questionarioDao.retornarListaQuestionarioComFiltro(path, statusRelatorio, statusPlanoTrabalho, nomeOrgao); | |
| 74 | + result.include("lsquestionario", lsquestionario); | |
| 75 | + result.include("totalSolicitacoes", lsquestionario.size()); | |
| 76 | + result.include("statusRel", statusRelatorio.equalsIgnoreCase("todos")? "" :statusRelatorio); | |
| 77 | + result.include("statusPlanoTrab", statusPlanoTrabalho.equalsIgnoreCase("todos")? "" :statusPlanoTrabalho); | |
| 78 | + result.include("nomeOrgao", nomeOrgao != null? nomeOrgao:""); | |
| 79 | + | |
| 80 | + this.validator.add(new ValidationMessage("", "")); | |
| 81 | + this.validator.onErrorUsePageOf(QuestionarioController.class).listaQuestionario(); | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + } | |
| 63 | 87 | |
| 64 | 88 | @Path("/salvar-questionario") |
| 65 | 89 | public void questionarioSalvar(String autorizacao, String noOrgao, String nomeResponsavel, |
| ... | ... | @@ -250,5 +274,7 @@ public class QuestionarioController { |
| 250 | 274 | |
| 251 | 275 | |
| 252 | 276 | } |
| 277 | + | |
| 278 | + | |
| 253 | 279 | |
| 254 | 280 | } | ... | ... |
src/br/com/dao/QuestionarioDao.java
| ... | ... | @@ -79,6 +79,76 @@ public class QuestionarioDao { |
| 79 | 79 | return listaQuestionario; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + public List<Questionario> retornarListaQuestionarioComFiltro(String path, String statusRelatorio, String statusPlanoTrabalho, String nomeOrgao) { | |
| 83 | + | |
| 84 | + List<Questionario> listaQuestionario = new ArrayList<Questionario>(); | |
| 85 | + | |
| 86 | + ResultSet rset = null; | |
| 87 | + Questionario questionario; | |
| 88 | + RespostaQuestionarioDao respostaQuestionarioDao; | |
| 89 | + PlanoTrabalhoDao planoTrabalhoDao; | |
| 90 | + | |
| 91 | + rset = retornarQuestionarioComFiltro(path, statusRelatorio, statusPlanoTrabalho, nomeOrgao); | |
| 92 | + String dataRespostaQuestionario = ""; | |
| 93 | + try { | |
| 94 | + while (rset.next()) { | |
| 95 | + dataRespostaQuestionario = ""; | |
| 96 | + | |
| 97 | + questionario = new Questionario(); | |
| 98 | + respostaQuestionarioDao = new RespostaQuestionarioDao(); | |
| 99 | + planoTrabalhoDao = new PlanoTrabalhoDao(); | |
| 100 | + | |
| 101 | + questionario.setIdQuestionario(rset.getInt("id_questionario")); | |
| 102 | + questionario.setDtInicioQuestionario(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("dt_inicio_questionario"))); | |
| 103 | + questionario.setDtFimQuestionario(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("dt_fim_questionario"))); | |
| 104 | + questionario.setNoOrgao(rset.getString("no_orgao")); | |
| 105 | + questionario.setHashAutenticacao(rset.getString("hash_autenticacao")); | |
| 106 | + questionario.setQuestionario_respondido(rset.getBoolean("questionario_respondido")); | |
| 107 | + questionario.setEmailDestinoOrgao(rset.getString("email_destino_orgao")); | |
| 108 | + questionario.setResponsavel(rset.getString("responsavel")); | |
| 109 | + questionario.setCargoResponsavel(rset.getString("cargo_responsavel")); | |
| 110 | + questionario.setTelefone(rset.getString("telefone")); | |
| 111 | + questionario.setIdAutorizacaoGeracaoHash(rset.getInt("idAutorizacao")); | |
| 112 | + questionario.setDtRecebimentoEmail(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("data_recebimento_email"))); | |
| 113 | + | |
| 114 | + dataRespostaQuestionario = rset.getString("data_resposta_email"); | |
| 115 | + if(dataRespostaQuestionario != null) | |
| 116 | + { | |
| 117 | + questionario.setDtRespostaEmail(DateUtil.dataHoraFormatadaDiaMesAnoComParametro(dataRespostaQuestionario)); | |
| 118 | + } | |
| 119 | + else | |
| 120 | + { | |
| 121 | + questionario.setDtRespostaEmail(dataRespostaQuestionario); | |
| 122 | + } | |
| 123 | + | |
| 124 | + | |
| 125 | + questionario.setDataRespostaQuestionario(respostaQuestionarioDao.verificaRespostaQuestionario(path, rset.getInt("id_questionario"))); | |
| 126 | + | |
| 127 | + questionario.setPlanoTrabalhoEnviado( planoTrabalhoDao.verificaPlanoTrabalho(path, rset.getInt("id_questionario")) > -1 ? true : false); | |
| 128 | + | |
| 129 | + if(statusPlanoTrabalho.equalsIgnoreCase("todos")) | |
| 130 | + { | |
| 131 | + listaQuestionario.add(questionario); | |
| 132 | + } | |
| 133 | + else | |
| 134 | + { | |
| 135 | + if(statusPlanoTrabalho.equalsIgnoreCase("sim") && questionario.isPlanoTrabalhoEnviado()) | |
| 136 | + { | |
| 137 | + listaQuestionario.add(questionario); | |
| 138 | + } | |
| 139 | + else if(statusPlanoTrabalho.equalsIgnoreCase("nao") && !questionario.isPlanoTrabalhoEnviado()) | |
| 140 | + { | |
| 141 | + listaQuestionario.add(questionario); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + | |
| 145 | + } | |
| 146 | + } catch (Exception e) { | |
| 147 | + e.printStackTrace(); | |
| 148 | + } | |
| 149 | + | |
| 150 | + return listaQuestionario; | |
| 151 | + } | |
| 82 | 152 | |
| 83 | 153 | public ResultSet retornarQuestionario(String path) { |
| 84 | 154 | |
| ... | ... | @@ -113,6 +183,59 @@ public class QuestionarioDao { |
| 113 | 183 | |
| 114 | 184 | } |
| 115 | 185 | |
| 186 | + public ResultSet retornarQuestionarioComFiltro(String path, String statusRelatorio, String statusPlanoTrabalho, String nomeOrgao) { | |
| 187 | + | |
| 188 | + StringBuffer sql = new StringBuffer(); | |
| 189 | + Connection con = Conexao.conecta(path); | |
| 190 | + Statement estado; | |
| 191 | + ResultSet rset = null; | |
| 192 | + String sqlConvertida = ""; | |
| 193 | + try { | |
| 194 | + estado = con.createStatement(); | |
| 195 | + | |
| 196 | + estado.execute(sql.toString()); | |
| 197 | + sql.append(" SELECT * "); | |
| 198 | + sql.append(" FROM public.questionario"); | |
| 199 | + sql.append(" Where "); | |
| 200 | + | |
| 201 | + if(nomeOrgao != null) | |
| 202 | + { | |
| 203 | + sql.append(" and upper (no_orgao) like upper('%"+ nomeOrgao +"%') "); | |
| 204 | + } | |
| 205 | + | |
| 206 | + if(statusRelatorio.equalsIgnoreCase("sim")) | |
| 207 | + { | |
| 208 | + sql.append(" and questionario_respondido = true "); | |
| 209 | + | |
| 210 | + }else if(statusRelatorio.equalsIgnoreCase("nao")) | |
| 211 | + { | |
| 212 | + sql.append(" and questionario_respondido = false " ); | |
| 213 | + } | |
| 214 | + | |
| 215 | + | |
| 216 | + sql.append(" order by no_orgao;"); | |
| 217 | + | |
| 218 | + sqlConvertida = sql.toString().replace("Where and" , "Where ").replace("Where order by no_orgao", " order by no_orgao"); | |
| 219 | + rset = estado.executeQuery(sqlConvertida); | |
| 220 | + | |
| 221 | + return rset; | |
| 222 | + | |
| 223 | + } catch (SQLException e) { | |
| 224 | + e.printStackTrace(); | |
| 225 | + return null; | |
| 226 | + | |
| 227 | + } finally { | |
| 228 | + if (con != null) { | |
| 229 | + try { | |
| 230 | + con.close(); | |
| 231 | + } catch (SQLException e) { | |
| 232 | + e.printStackTrace(); | |
| 233 | + } | |
| 234 | + } | |
| 235 | + } | |
| 236 | + | |
| 237 | + } | |
| 238 | + | |
| 116 | 239 | public boolean atualizarDataRespostaQuestionario(String path, int idQuestionario) |
| 117 | 240 | { |
| 118 | 241 | ... | ... |