Rev 1207 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@ page import="jomm.dao.impl.AbstractDao" %>
<%@ page import="pt.estgp.estgweb.domain.Course" %>
<%@ page import="pt.estgp.estgweb.domain.User" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.domain.views.CourseView" %>
<%@ page import="pt.estgp.estgweb.utils.DatesUtils" %>
<%@ page import="java.util.List" %>
<%@ page import="pt.estgp.estgweb.domain.UserSession" %>
<%@ page import="pt.estgp.estgweb.web.UserSessionProxy" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
<style>
.nav-menu li
{
padding-left: 0;
margin-left: 0;
padding-bottom: 0;
padding-top: 0;
margin-bottom: 0;
margin-top: 0;
}
</style>
<%
AbstractDao.getCurrentSession().beginTransaction();
%>
<%
String importYear = request.getParameter("importYear");
String nowInterfaceImportYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
if(importYear == null || importYear.length()==0)
{
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
}
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(importYear);
%>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 col-md-4">
<h1>Listagem de Cursos</h1>
<form role="form" action="<%=request.getContextPath()%>/user/courseComissions.do" method="post">
<div class="form-group">
<label for="importYear">Escolha o úlitmo ano em que o curso esteve ativo:</label>
<select name="importYear" id="importYear" class="form-control" onchange="this.form.submit()">
<option value="">Ultimo ano ativo</option>
<%
List<String> years = DatesUtils.getImportYears(10);
for(String year: years)
{
String activo = year.equals(importYear)?"selected":"";
%>
<option value="<%=year%>" <%=activo%>><%=year%></option>
<%
}
%>
</select>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h1>Cursos no Sistema ativos no ano <%=importYear%></h1>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table class="tablesorter tablesorterfiltered">
<thead>
<tr>
<th>Codigo</th>
<th>Tipo de Curso</th>
<th>Curso</th>
<baco:hasRole role="services,admin,all">
<th>Activo</th>
<th>Papel Comissão Curso</th>
<th>Unidades <%=importYear%></th>
<th>Unidades noutros anos</th>
</baco:hasRole>
<th>Comissão de Curso</th>
<baco:hasRole role="services,admin,all">
<th>Unidades</th>
<th>Editar</th>
</baco:hasRole>
</tr>
</thead>
<tbody>
<%
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
for(Course c: courses)
{
CourseView cv = new CourseView(c);
request.setAttribute("CourseView",cv);
int unitsSize=DaoFactory.getCourseDaoImpl().countCoursesUnits(importYear,c.getId());
int unitsSizeOthers=DaoFactory.getCourseDaoImpl().countCoursesUnitsNot(importYear, c.getId());
int totalUnits = unitsSize + unitsSizeOthers;
//So da verdadeiro se estivermos neste ano e ele estiver inativo
boolean notActiveAndActualThisYear = nowInterfaceImportYear.equals(importYear) && !cv.isStatus();
if((totalUnits > 0 && !notActiveAndActualThisYear) || userSession.getUser().isAdmin() || userSession.getUser().hasRole("services"))
{
%>
<tr>
<td>${CourseView.code}</td>
<td><bean:message key="course.${CourseView.degreeCleanCode}"/></td>
<td>${CourseView.name}</td>
<baco:hasRole role="services,admin,all">
<td>${CourseView.status}</td>
<td>
<logic:notEmpty name="CourseView" property="validationRole">
<bean:message key="user.role.${CourseView.validationRole}"/>
</logic:notEmpty>
<logic:empty name="CourseView" property="validationRole">
Papel não atribuido (Corrigir Situação)
</logic:empty>
</td>
<td>
<%=unitsSize%>
</td>
<td>
<%=unitsSizeOthers%>
</td>
</baco:hasRole>
<td>
<div class="list-group">
<%
for(User u:DaoFactory.getUserDaoImpl().loadRoleUsers(c.getValidationRole()))
{
%>
<div class="list-group-item">
<%=u.getName()%>
<baco:hasRole role="admin,services">
<a class="btn btn-default" target="_blank" href="<%=request.getContextPath()%>/user/startProfileFromSearchUsers.do?id=<%=u.getId()%>">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</baco:hasRole>
</div>
<%
}
%>
</div>
</td>
<baco:hasRole role="services,admin,all">
<td>
<a class="btn btn-default" target="_blank" href="<%=request.getContextPath()%>/user/courseCourseUnits.do?courseId=<%=c.getId()%>">
<span class="glyphicon glyphicon-list-alt"></span>
</a>
</td>
<td>
<a class="btn btn-warning" target="_blank" href="<%=request.getContextPath()%>/user/courseControllerFromServiceZone.do?dispatch=edit&courseView.id=<%=c.getId()%>">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</td>
</baco:hasRole>
</tr>
<%
}
}
%>
</tbody>
</table>
</div>
</div>
</div>
<%
AbstractDao.getCurrentSession().getTransaction().commit();
%>