Rev 1506 | Rev 1516 | Go to most recent revision | 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.CourseStudiesPlan" %>
<%@ page import="pt.estgp.estgweb.domain.CourseStudiesPlanImpl" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.web.form.courses.CourseStudiesPlansAdminForm" %>
<%@ page import="pt.estgp.estgweb.services.courses.CoursesService" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm"%>
<%
//todo temos de ter aqui o id do curso para o carregar aqui mesmo
//se queremos barras de navegação então temos de ter ser acedidos de um
//controlador que carregue o necerrário à barra ou então assumimos que
//o curso id esta sempre disponivel nas barras possiveis de chamar
AbstractDao.getCurrentSession().beginTransaction();
CourseStudiesPlanImpl planoEdicao;
boolean ultimaVersao = true;
Long courseId;
Long studyPlanId;
String versaoPlano = "Não Encontrada";
Course course;
if(request.getAttribute("CourseStudiesPlansAdminForm") != null)
{
CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) request.getAttribute("CourseStudiesPlansAdminForm");
courseId = frm.getCourseId();
studyPlanId = frm.getCourseStudiesPlan().getId();
ultimaVersao = frm.isVersaoVigor();
course = DaoFactory.getCourseDaoImpl().load(courseId);
planoEdicao = frm.getCourseStudiesPlan();
}
else
{
courseId = Long.parseLong(request.getParameter("courseId"));
studyPlanId = Long.parseLong(request.getParameter("studyPlanId"));
request.setAttribute("courseId",courseId);
request.setAttribute("studyPlanId",studyPlanId);
course = DaoFactory.getCourseDaoImpl().load(courseId);
planoEdicao = null;
for(CourseStudiesPlan plan:course.getStudiesPlans())
{
if(plan.getId() == studyPlanId)
{
versaoPlano = plan.getVersion() + "";
planoEdicao = (CourseStudiesPlanImpl) DaoFactory.getCourseStudiesPlanDaoImpl().narrow(plan);
break;
}
ultimaVersao = false;
}
//provavelmente era mais facil ter um Form Nested com toda a informação, ou então faz-se isso numa pagina propria para editar o plano em questão
}
request.setAttribute("courseId",courseId);
request.setAttribute("studyPlanId",studyPlanId);
request.setAttribute("course",course);
/*
if(planoEdicao != null)
{
}
*/
%>
<div class="panel panel-default">
<div class="panel-heading">
Edição do plano de estudos. Versão <%=versaoPlano%> <%=ultimaVersao? "(<u>é a versão em vigor</u>)":""%> do curso de <%=course.getName()%> (<%=course.getCode()%>)
<button data-toggle="modal" data-target="#modalNovaVersaoDePlano" title="Adicionar Versão do Plano de Estudos" class="btn btn-success pull-right"><span class="glyphicon glyphicon-plus"></span></button>
</div>
<div class="panel-body">
<html:errors/>
<jomm:messages/>
<div class="panel panel-default">
<div class="panel-heading">Dados do Curso</div>
<div class="panel-body">
<div class="col-sm-12">Código do Curso <label class="text-info">${course.code}</label></div>
<div class="col-sm-12">
<table class="tablesorter-blue">
<thead>
<tr>
<th>Língua</th>
<th>Nome do Curso</th>
<th>Departamento</th>
</tr>
</thead>
<tbody>
<tr>
<td>PT</td>
<td>${course.name}</td>
<td>
<%if(course.getDepartment() != null){%>${course.department.name}<%}%>
</td>
</tr>
<tr>
<td>EN</td>
<td>${course.nameEn}</td>
<td>
<%if(course.getDepartment() != null){%>${course.department.nameEn}<%}%>
</td>
</tr>
<tr>
<td>ES</td>
<td>${course.nameEs}</td>
<td>
<%if(course.getDepartment() != null){%>${course.department.nameEs}<%}%>
</td>
</tr>
<tr>
<td>FR</td>
<td>${course.nameFr}</td>
<td>
<%if(course.getDepartment() != null){%>${course.department.nameFr}<%}%>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Plano de Estudos</div>
<div class="panel-body">
<html:form action="/user/courseControllerStudiesPlan" styleClass="form-horizontal">
<%
CourseStudiesPlansAdminForm courseStudiesPlansAdminForm = (CourseStudiesPlansAdminForm) request.getAttribute("CourseStudiesPlansAdminForm");
if(courseStudiesPlansAdminForm.getCourseStudiesPlan().getId() <= 0)
{
courseStudiesPlansAdminForm.setCourseStudiesPlan(planoEdicao);
courseStudiesPlansAdminForm.setCourseId(courseId);
courseStudiesPlansAdminForm.setVersaoVigor(ultimaVersao);
courseStudiesPlansAdminForm.setPlanoEstudos(new CoursesService().loadCursoPlanoFromXml(planoEdicao.getXml()));
}
%>
<input type="hidden" name="dispatch" value="savePlano"/>
<html:hidden property="courseId"/>
<html:hidden property="versaoVigor"/>
<html:hidden property="courseStudiesPlan.id"/>
<html:hidden styleId="semestreId" property="semestreId"/>
<html:hidden styleId="perfilId" property="perfilId"/>
<div class="form-group">
<label class="control-label col-sm-2">Versão</label>
<div class="col-sm-10">
<html:text styleClass="form-control" property="courseStudiesPlan.version" size="3"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Descrição</label>
<div class="col-sm-10">
<html:text styleClass="form-control" property="courseStudiesPlan.versionDescription"/>
</div>
</div>
<%
int dummyIndexIdUnidades = 0;
int dummyIndexPerfilId = 0;
int dummyIndexSemestreId = 0;
%>
<script>
function sendUpUnidadeCurricular(dummyIndexId)
{
sendFieldUp("removed",dummyIndexId);
sendFieldUp("siges",dummyIndexId);
sendFieldUp("nome",dummyIndexId);
sendFieldUp("nomeEn",dummyIndexId);
sendFieldUp("nomeEs",dummyIndexId);
sendFieldUp("nomeFr",dummyIndexId);
sendFieldUp("totalHoras",dummyIndexId);
sendFieldUp("horasContactoT",dummyIndexId);
sendFieldUp("horasContactoTP",dummyIndexId);
sendFieldUp("horasContactoP",dummyIndexId);
sendFieldUp("horasContactoPL",dummyIndexId);
sendFieldUp("horasContactoPD",dummyIndexId);
sendFieldUp("horasContactoOT",dummyIndexId);
sendFieldUp("horasContactoE",dummyIndexId);
sendFieldUp("horasContactoS",dummyIndexId);
sendFieldUp("horasContactoTC",dummyIndexId);
sendFieldUp("horasContactoO",dummyIndexId);
sendFieldUp("ECTS",dummyIndexId);
sendFieldUp("urlUnidadeCurricular",dummyIndexId);
sendFieldUp("urlFichaCurricular",dummyIndexId);
}
function sendDownUnidadeCurricular(dummyIndexId)
{
sendFieldDown("removed",dummyIndexId);
sendFieldDown("siges",dummyIndexId);
sendFieldDown("nome",dummyIndexId);
sendFieldDown("nomeEn",dummyIndexId);
sendFieldDown("nomeEs",dummyIndexId);
sendFieldDown("nomeFr",dummyIndexId);
sendFieldDown("totalHoras",dummyIndexId);
sendFieldDown("horasContactoT",dummyIndexId);
sendFieldDown("horasContactoTP",dummyIndexId);
sendFieldDown("horasContactoP",dummyIndexId);
sendFieldDown("horasContactoPL",dummyIndexId);
sendFieldDown("horasContactoPD",dummyIndexId);
sendFieldDown("horasContactoOT",dummyIndexId);
sendFieldDown("horasContactoE",dummyIndexId);
sendFieldDown("horasContactoS",dummyIndexId);
sendFieldDown("horasContactoTC",dummyIndexId);
sendFieldDown("horasContactoO",dummyIndexId);
sendFieldDown("ECTS",dummyIndexId);
sendFieldDown("urlUnidadeCurricular",dummyIndexId);
sendFieldDown("urlFichaCurricular",dummyIndexId);
}
function sendFieldUp(field,dummyIndexId){
nome = $("#" + field + "dummyIndex" + dummyIndexId).val();
$("#" + field + "dummyIndex" + (dummyIndexId)).val($("#" + field + "dummyIndex" + (dummyIndexId-1)).val());
$("#" + field + "dummyIndex" + (dummyIndexId-1)).val(nome);
}
function sendFieldDown(field,dummyIndexId){
nome = $("#" + field + "dummyIndex" + dummyIndexId).val();
$("#" + field + "dummyIndex" + (dummyIndexId)).val($("#" + field + "dummyIndex" + (dummyIndexId+1)).val());
$("#" + field + "dummyIndex" + (dummyIndexId+1)).val(nome);
}
function removeUnit(dummyIndexId)
{
$("#removed" + "dummyIndex" + dummyIndexId).val("true");
$("#removed" + "dummyIndex" + dummyIndexId).closest("tr").hide("slow");
}
</script>
<nested:notEmpty property="planoEstudos">
<html:hidden property="planoEstudos.siges"/>
<html:hidden property="planoEstudos.nome"/>
<html:hidden property="planoEstudos.dep"/>
<nested:iterate id="semestre" property="planoEstudos.semestre" type="pt.estgp.estgweb.services.courses.xsd.Curso.Semestre">
<div class="panel panel-default">
<div class="panel-heading">
<nested:select property="id">
<html:option value="S1">Semestre 1</html:option>
<html:option value="S2">Semestre 2</html:option>
<html:option value="S3">Semestre 3</html:option>
<html:option value="S4">Semestre 4</html:option>
<html:option value="S5">Semestre 5</html:option>
<html:option value="S6">Semestre 6</html:option>
<html:option value="T1">Trimestre 1</html:option>
<html:option value="T2">Trimestre 2</html:option>
<html:option value="T3">Trimestre 3</html:option>
<html:option value="T4">Trimestre 4</html:option>
<html:option value="T5">Trimestre 5</html:option>
<html:option value="T6">Trimestre 6</html:option>
<html:option value="T7">Trimestre 7</html:option>
<html:option value="T8">Trimestre 8</html:option>
</nested:select>
<%
dummyIndexSemestreId++;
request.setAttribute("dummyIndexSemestreId",dummyIndexSemestreId);
%>
<nested:hidden property="semestreId" value="semestreDummy${dummyIndexSemestreId}"/>
<button type="button" class="btn btn-default" onclick="form.action=form.action+'#semestreDummy${dummyIndexSemestreId}';$('#semestreId').val('semestreDummy${dummyIndexSemestreId}');set(this.form,'addUnidadeSemestre');this.form.submit()">
<span class="glyphicon glyphicon-plus"> Adicionar Unidade ao Semestre</span>
</button>
<a name="semestreDummy${dummyIndexSemestreId}"></a>
</div>
<div class="panel-body">
<button class="btn btn-default" data-toggle="collapse" type="button" data-target=".langs">Ver Campos Multingua</button>
<nested:iterate id="perfil" property="perfil" type="pt.estgp.estgweb.services.courses.xsd.Curso.Semestre.Perfil">
<div class="panel panel-default">
<div class="panel-heading">
PERFIL <nested:text styleClass="form-control" property="nome"/>
<%
dummyIndexPerfilId++;
request.setAttribute("dummyIndexPerfilId",dummyIndexPerfilId);
%>
<nested:hidden property="perfilId" value="perfilDummy${dummyIndexPerfilId}"/>
<button type="button" class="btn btn-default" onclick="form.action=form.action+'#perfilDummy${dummyIndexPerfilId}';$('#perfilId').val('perfilDummy${dummyIndexPerfilId}');set(this.form,'addUnidadePerfil');this.form.submit()">
<span class="glyphicon glyphicon-plus"> Adicionar Unidade ao Perfil</span>
</button>
<a name="perfilDummy${dummyIndexPerfilId}"></a>
</div>
<div class="panel-body">
<table class="tablesorterfiltered">
<thead>
<tr>
<td></td>
<td></td>
<th>SIGES</th>
<th>Nome</th>
<th>Total</th>
<th>T</th>
<th>TP</th>
<th>P</th>
<th>PL</th>
<th>PD</th>
<th>OT</th>
<th>E</th>
<th>S</th>
<th>TC</th>
<th>O</th>
<th>ECTS</th>
<th>URL UNIDADE</th>
<th>FICHA URL</th>
</tr>
</thead>
<tbody>
<nested:size id="tamanho" property="unidade"/>
<nested:iterate id="unit" indexId="indexId" property="unidade" type="pt.estgp.estgweb.services.courses.xsd.UnidadeType">
<%
dummyIndexIdUnidades++;
request.setAttribute("dummyIndexIdUnidades","dummyIndex" + dummyIndexIdUnidades);
%>
<%
int tamanhoMinus1 = tamanho - 1;
request.setAttribute("tamanhoMinus1",tamanhoMinus1);
%>
<tr <nested:equal property="removed" value="true">class="hidden"</nested:equal>>
<td class="text-nowrap">
<nested:greaterThan value="0" name="indexId">
<button type="button" class="btn btn-warning" onclick="sendUpUnidadeCurricular(<%=dummyIndexIdUnidades%>)">
<span class="glyphicon glyphicon-arrow-up"> </span>
</button>
</nested:greaterThan>
<nested:lessThan name="indexId" value="${tamanhoMinus1}">
<button type="button" class="btn btn-warning" onclick="sendDownUnidadeCurricular(<%=dummyIndexIdUnidades%>)">
<span class="glyphicon glyphicon-arrow-down"> </span>
</button>
</nested:lessThan>
</td>
<td>
<nested:hidden styleId="removed${dummyIndexIdUnidades}" property="removed"/>
<button type="button" class="btn btn-danger" onclick="removeUnit(<%=dummyIndexIdUnidades%>)">
<span class="glyphicon glyphicon-remove"> </span>
</button>
</td>
<td><nested:text styleId="siges${dummyIndexIdUnidades}" styleClass="form-control" property="siges"/></td>
<td>
<div>
<div class="col-sm-1">(PT)</div>
<div class="col-sm-11"><nested:text styleId="nome${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nome"/></div>
<div class="langs collapse" >
<div class="col-sm-1">(EN)</div>
<div class="col-sm-11"><nested:text styleId="nomeEn${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeEn"/></div>
<div class="col-sm-1">(ES)</div>
<div class="col-sm-11"><nested:text styleId="nomeEs${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeEs"/></div>
<div class="col-sm-1">(FR)</div>
<div class="col-sm-11"><nested:text styleId="nomeFr${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeFr"/></div>
</div>
</div>
</td>
<td><nested:text styleClass="form-control" styleId="totalHoras${dummyIndexIdUnidades}" property="totalHoras"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoT${dummyIndexIdUnidades}" property="horasContacto.t"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoTP${dummyIndexIdUnidades}" property="horasContacto.TP"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoP${dummyIndexIdUnidades}" property="horasContacto.p"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoPL${dummyIndexIdUnidades}" property="horasContacto.PL"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoPD${dummyIndexIdUnidades}" property="horasContacto.PD"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoOT${dummyIndexIdUnidades}" property="horasContacto.OT"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoE${dummyIndexIdUnidades}" property="horasContacto.e"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoS${dummyIndexIdUnidades}" property="horasContacto.s"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoTC${dummyIndexIdUnidades}" property="horasContacto.TC"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoO${dummyIndexIdUnidades}" property="horasContacto.o"/></td>
<td><nested:text styleClass="form-control" styleId="ECTS${dummyIndexIdUnidades}" property="ECTS"/></td>
<td><nested:text styleClass="form-control" styleId="urlUnidadeCurricular${dummyIndexIdUnidades}" style="width:600px" property="urlUnidadeCurricular"/></td>
<td><nested:text styleClass="form-control" styleId="urlFichaCurricular${dummyIndexIdUnidades}" style="width:600px" property="urlFichaCurricular"/></td>
</tr>
</nested:iterate>
</tbody>
</table>
</div>
</div>
</nested:iterate>
<nested:notEmpty property="unidade">
<table class="tablesorterfiltered">
<thead>
<tr>
<th></th>
<th></th>
<th>SIGES</th>
<th>Nome</th>
<th>Total</th>
<th>T</th>
<th>TP</th>
<th>P</th>
<th>PL</th>
<th>PD</th>
<th>OT</th>
<th>E</th>
<th>S</th>
<th>TC</th>
<th>O</th>
<th>ECTS</th>
<th>URL UNIDADE</th>
<th>FICHA URL</th>
</tr>
</thead>
<tbody>
<nested:size id="tamanho" property="unidade"/>
<nested:iterate id="unit" property="unidade" indexId="indexId" type="pt.estgp.estgweb.services.courses.xsd.UnidadeType">
<%
dummyIndexIdUnidades++;
request.setAttribute("dummyIndexIdUnidades","dummyIndex" + dummyIndexIdUnidades);
%>
<%
int tamanhoMinus1 = tamanho - 1;
request.setAttribute("tamanhoMinus1",tamanhoMinus1);
%>
<tr <nested:equal property="removed" value="true">class="hidden"</nested:equal>>
<td class="text-nowrap">
<nested:greaterThan value="0" name="indexId">
<button type="button" class="btn btn-warning" onclick="sendUpUnidadeCurricular(<%=dummyIndexIdUnidades%>)">
<span class="glyphicon glyphicon-arrow-up"> </span>
</button>
</nested:greaterThan>
<nested:lessThan name="indexId" value="${tamanhoMinus1}">
<button type="button" class="btn btn-warning" onclick="sendDownUnidadeCurricular(<%=dummyIndexIdUnidades%>)">
<span class="glyphicon glyphicon-arrow-down"> </span>
</button>
</nested:lessThan>
</td>
<td>
<nested:hidden styleId="removed${dummyIndexIdUnidades}" property="removed"/>
<button type="button" class="btn btn-danger" onclick="removeUnit(<%=dummyIndexIdUnidades%>)" >
<span class="glyphicon glyphicon-remove"> </span>
</button>
</td>
<td><nested:text styleId="siges${dummyIndexIdUnidades}" styleClass="form-control" property="siges"/></td>
<td>
<div>
<div class="col-sm-1">(PT)</div>
<div class="col-sm-11"><nested:text styleId="nome${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nome"/></div>
<div class="langs collapse" >
<div class="col-sm-1">(EN)</div>
<div class="col-sm-11"><nested:text styleId="nomeEn${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeEn"/></div>
<div class="col-sm-1">(ES)</div>
<div class="col-sm-11"><nested:text styleId="nomeEs${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeEs"/></div>
<div class="col-sm-1">(FR)</div>
<div class="col-sm-11"><nested:text styleId="nomeFr${dummyIndexIdUnidades}" style="width:300px" styleClass="form-control" property="nomeFr"/></div>
</div>
</div>
</td>
<td><nested:text styleClass="form-control" styleId="totalHoras${dummyIndexIdUnidades}" property="totalHoras"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoT${dummyIndexIdUnidades}" property="horasContacto.t"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoTP${dummyIndexIdUnidades}" property="horasContacto.TP"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoP${dummyIndexIdUnidades}" property="horasContacto.p"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoPL${dummyIndexIdUnidades}" property="horasContacto.PL"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoPD${dummyIndexIdUnidades}" property="horasContacto.PD"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoOT${dummyIndexIdUnidades}" property="horasContacto.OT"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoE${dummyIndexIdUnidades}" property="horasContacto.e"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoS${dummyIndexIdUnidades}" property="horasContacto.s"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoTC${dummyIndexIdUnidades}" property="horasContacto.TC"/></td>
<td><nested:text styleClass="form-control" styleId="horasContactoO${dummyIndexIdUnidades}" property="horasContacto.o"/></td>
<td><nested:text styleClass="form-control" styleId="ECTS${dummyIndexIdUnidades}" property="ECTS"/></td>
<td><nested:text styleClass="form-control" styleId="urlUnidadeCurricular${dummyIndexIdUnidades}" style="width:600px" property="urlUnidadeCurricular"/></td>
<td><nested:text styleClass="form-control" styleId="urlFichaCurricular${dummyIndexIdUnidades}" style="width:600px" property="urlFichaCurricular"/></td>
</tr>
</nested:iterate>
</tbody>
</table>
</nested:notEmpty>
</div>
</div>
</nested:iterate>
</nested:notEmpty>
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
<html:submit styleClass="btn btn-success" >Salvar</html:submit>
</html:form>
</div>
</div>
</div>
</div>
<%
AbstractDao.getCurrentSession().getTransaction().commit();
%>