Subversion Repositories bacoAlunos

Rev

Rev 1699 | Rev 1817 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1354 jmachado 1
<%@ page import="jomm.dao.impl.AbstractDao" %>
2
<%@ page import="org.hibernate.Criteria" %>
3
<%@ page import="org.hibernate.criterion.Order" %>
4
<%@ page import="org.hibernate.criterion.Projections" %>
1814 jmachado 5
<%@ page import="pt.estgp.estgweb.utils.Globals" %>
1354 jmachado 6
<%@ page import="pt.estgp.estgweb.domain.CourseUnit" %>
1699 jmachado 7
<%@ page import="pt.estgp.estgweb.domain.TeacherImpl" %>
1354 jmachado 8
<%@ page import="static org.hibernate.criterion.Restrictions.eq" %>
1699 jmachado 9
<%@ page import="pt.estgp.estgweb.domain.User" %>
1525 jmachado 10
<%@ page import="static org.hibernate.criterion.Restrictions.eq" %>
1354 jmachado 11
<%@ page import="static org.hibernate.criterion.Restrictions.or" %>
12
<%@ page import="static org.hibernate.criterion.Restrictions.*" %>
1699 jmachado 13
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
14
<%@ page import="java.util.ArrayList" %>
1354 jmachado 15
<%@ page import="java.util.List" %>
16
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
17
<%@ taglib uri="/WEB-INF/baco.tld" prefix="baco" %>
18
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
19
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
20
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
21
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
22
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
23
<jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSessionImpl" scope="request"/>
24
 
1372 jmachado 25
<%
26
    String all = request.getParameter("all");
1525 jmachado 27
    String importYear = request.getParameter("importYear");
28
    AbstractDao.getCurrentSession().beginTransaction();
29
    if(importYear == null)
30
        importYear = UserSession.getNowConfiguration().getInterfaceImportYear();
1699 jmachado 31
 
1372 jmachado 32
%>
1354 jmachado 33
<div class="panel panel-default">
34
    <div class="panel-heading">
1525 jmachado 35
        Estatisticas Unidades nos Cursos (<%=importYear%>)
1354 jmachado 36
    </div>
37
    <div class="panel-body">
38
 
39
        <%
40
            boolean allCourses = false;
41
            List<String> comissionsRoles = null;
1379 jmachado 42
            if(UserSession.getUser().isSuperuserOrAdmin() || UserSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE) || UserSession.getUser().hasRole("services"))
1354 jmachado 43
            {
44
                allCourses = true;
45
                AbstractDao.getCurrentSession().beginTransaction();
1525 jmachado 46
 
47
 
1354 jmachado 48
                Criteria c = AbstractDao.getCurrentSession().createCriteria(CourseUnit.class)
49
                        .setProjection(Projections.projectionList().add(Projections.groupProperty("c.validationRole"))
50
                                .add(Projections.property("c.id")).add(Projections.property("c.name")).add(Projections.property("c.code")))
51
                        .createAlias("course", "c")
1525 jmachado 52
                        //.add(eq("importYear", importYear))
53
                        ;
1354 jmachado 54
                List<Object[]> validationRoles = c.list();
55
                AbstractDao.getCurrentSession().getTransaction().commit();
56
                comissionsRoles = new ArrayList<String>();
57
 
58
                %>
59
        <div class="avisosWarning" style="display: none">
60
            <div class="alert alert-warning">Existem cursos sem papel de comissão atribuido
61
                <button class="btn btn-warning" onclick="$('.avisos').toggle()">Ver/Ocultar Avisos</button>
62
            </div>
63
        </div>
64
        <div class="avisos" style="display: none">
65
                <%
66
                boolean avisos = false;
67
                for(Object[] validationRolesObj: validationRoles)
68
                {
69
                    String role = ((String) validationRolesObj[0]);
70
 
71
                    if(role == null || role.trim().length() == 0)
72
                    {
73
                        avisos = true;
74
    %>
75
                        <div class="alert alert-warning">Atenção o curso <%=validationRolesObj[1]%> (<%=validationRolesObj[2]%>) não tem papel de comissão de curso associado</div>
76
    <%
77
                    }else{
78
                        comissionsRoles.add(role);
79
                    }
80
                }
81
                if(avisos)
82
                {
83
            %>
84
                <script>
85
                    $(document).ready(function()
86
                    {
87
                        $(".avisosWarning").show();
88
                    });
89
                </script>
90
            <%
91
                }
92
            %>
93
        </div>
94
            <%
95
            }
96
            else
97
            {
1699 jmachado 98
 
99
                User persistentUser = DaoFactory.getUserDaoImpl().narrow(DaoFactory.getUserDaoImpl().get(UserSession.getUser().getId()));
1354 jmachado 100
                comissionsRoles = new ArrayList<String>();
1699 jmachado 101
                if(persistentUser instanceof TeacherImpl)
1354 jmachado 102
                {
1699 jmachado 103
                    comissionsRoles = ((TeacherImpl)persistentUser).obtainCourseComissionsAndCoordinationsRoles();
1354 jmachado 104
                }
1699 jmachado 105
 
106
 
1354 jmachado 107
        }
108
        if(comissionsRoles.size() == 0)
109
        {
110
            %>
111
            <div class="alert alert-warning">
112
                Lamentamos mas não têm qualquer comissão de curso associada
113
            </div>
114
            <%
115
        }
116
        else
117
        {
118
            %>
119
            <script>
120
                $(document).ready(
121
                        function()
122
                        {
123
                            $("#ROLE_VALIDATION_<%=comissionsRoles.get(0)%>").show();
124
                        }
125
                );
126
                function showRoleSeparator(role)
127
                {
128
                    <%
129
                    for(String roleCourse: comissionsRoles)
130
                    {
131
                    %>
132
                        if(role == '<%=roleCourse%>')
133
                        {
134
                            $("#ROLE_VALIDATION_<%=roleCourse%>").show();
135
                            $("#rolesSeparators<%=roleCourse%>").addClass("active");
136
                        }
137
                        else
138
                        {
139
                            $("#ROLE_VALIDATION_<%=roleCourse%>").hide();
140
                            $("#rolesSeparators<%=roleCourse%>").removeClass("active");
141
                        }
142
                        <%
143
                    }
144
                    %>
145
                }
146
            </script>
147
            <%
148
            try
149
            {
150
                AbstractDao.getCurrentSession().beginTransaction();
151
 
1372 jmachado 152
                if(all == null)
153
                {
1354 jmachado 154
                %>
1372 jmachado 155
                <div class="row">
156
                    <div class="dropdown col-sm-3">
157
                        <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Escolha Comissão
158
                            <span class="caret"></span></button>
159
                        <ul class="dropdown-menu">
160
                    <%--<ul class="nav nav-tabs">--%>
161
                        <%
162
                            for(String roleCourse: comissionsRoles)
163
                            {
164
                                request.setAttribute("roleCourse",roleCourse);
165
                        %>
166
                                <li id="rolesSeparators<%=roleCourse%>"><a href="javascript:showRoleSeparator('<%=roleCourse%>')"><bean:message key="user.role.${roleCourse}"/></a></li>
167
                        <%
168
                            }
169
                        %>
170
                        </ul>
171
                    </div>
172
                    <div class="col-sm-3">
173
                        <html:link styleClass="btn btn-default" action="/user/startLoadCourseCourseUnitsStatistics?all=true">Mostrar Tudo na mesma tabela</html:link>
174
                    </div>
1354 jmachado 175
                </div>
176
 
177
                <%
1372 jmachado 178
                }
179
                else if(all!=null && all.equals("true"))
180
                {
181
                %>
182
                    <html:link styleClass="btn btn-default" action="/user/startLoadCourseCourseUnitsStatistics">Filtrar por Comissão de Curso</html:link>
183
                    <table class="tablesorter tablesorterfiltered">
184
                        <thead>
185
                        <tr>
186
                            <th>Cod Curso.</th>
187
                            <th class="filter-name filter-select">Curso</th>
188
                            <th>Cod.</th>
189
                            <th class="filter-name filter-select">Sem.</th>
190
                            <th>Nome</th>
191
 
192
 
193
                            <th>Sums</th>
194
                            <th>Sums Pre</th>
195
                            <th>Sums Falt</th>
196
 
1373 jmachado 197
                            <th>Plan.</th>
1372 jmachado 198
                            <th class="filter-name filter-select">Ficha</th>
199
                            <th>Aval.Enu</th>
200
                            <th>Aval.Paut</th>
201
                            <th class="filter-name filter-select">Relat.</th>
202
                            <th class="filter-name filter-select">Pedag.</th>
203
 
204
                            <th>Conteud.</th>
205
                            <th class="filter-name filter-select">Detalhes</th>
206
 
207
                        </tr>
208
                        </thead>
209
                        <tbody>
210
            <%
211
                }
1354 jmachado 212
                for(String roleCourse: comissionsRoles)
213
                {
214
                    request.setAttribute("roleCourse",roleCourse);
1372 jmachado 215
                    if(all == null)
216
                    {
1354 jmachado 217
                    %>
218
                    <div id="ROLE_VALIDATION_<%=roleCourse%>" style="display: none">
219
                        <h1><bean:message key="user.role.${roleCourse}"/></h1>
220
                    <%
1372 jmachado 221
                    }
1354 jmachado 222
                    Criteria c = AbstractDao.getCurrentSession().createCriteria(CourseUnit.class)
223
                            .setProjection(Projections.projectionList()
224
                                    .add(Projections.groupProperty("c.id"))
225
                                    .add(Projections.property("c.name"))
226
                                    .add(Projections.property("c.code")))
227
                            .createAlias("course", "c")
1525 jmachado 228
                            .add(eq("importYear", importYear))
1354 jmachado 229
                            .add(eq("c.validationRole", roleCourse));
230
                    List<Object[]> coursesForRole = c.list();
231
 
1372 jmachado 232
                    if(all==null && coursesForRole.size() > 1)
1354 jmachado 233
                    {
234
                    %>
235
                        <div class="alert alert-info alert-small">Mais que um curso para o papel <bean:message key="user.role.${roleCourse}"/></div>
236
                    <%
237
                    }
1372 jmachado 238
                    if(all == null)
239
                    {
1354 jmachado 240
                    %>
241
                    <hr/>
242
                    <%
1372 jmachado 243
                    }
244
 
245
 
1354 jmachado 246
                    for(Object[] courseArray: coursesForRole)
247
                    {
248
                        Long courseId = (Long) courseArray[0];
249
                        String courseName = (String) courseArray[1];
250
                        String courseCode = (String) courseArray[2];
251
 
252
                        c = AbstractDao.getCurrentSession().createCriteria(CourseUnit.class)
253
                                .setProjection(Projections.distinct(Projections.property("id")))
254
                                .createAlias("course", "c")
1525 jmachado 255
                                .add(eq("importYear", importYear))
1354 jmachado 256
                                .add(eq("c.id", courseId))
257
                                ;
258
                        c.addOrder(Order.asc("name"));
259
                        List<Long> courseUnits = c.list();
260
 
1372 jmachado 261
                        if(all==null && courseUnits.size() == 0)
1354 jmachado 262
                        {
263
                        %>
264
                            <h2><bean:message key="user.role.${roleCourse}"/> </h2>
265
                            <div class="alert alert-info alert-small">
1525 jmachado 266
                                Não foram encontradas unidades curriculares no ano <%=importYear%>
1354 jmachado 267
                            </div>
268
                        <%
269
                        }
270
                        else
271
                        {
272
                                //
1525 jmachado 273
                            // List<Student> students = DaoFactory.getStudentDaoImpl().loadFromCoursesWithValidationRoles(comissionsRoles,importYear);
1372 jmachado 274
                            if(all == null)
275
                            {
1354 jmachado 276
                        %>
277
                            <h2><%=courseName%> (<%=courseCode%>)</h2>
278
                            <div class="alert alert-info alert-small">
1525 jmachado 279
                                Existem <%=courseUnits.size()%> unidades no ano <%=importYear%>
1354 jmachado 280
                            </div>
281
 
282
                            <table class="tablesorter tablesorterfiltered">
283
                                <thead>
284
                                <tr>
285
                                    <th>Cod.</th>
286
                                    <th class="filter-name filter-select">Sem.</th>
287
                                    <th>Nome</th>
288
 
289
 
290
                                    <th>Sums</th>
291
                                    <th>Sums Pre</th>
292
                                    <th>Sums Falt</th>
293
 
294
                                    <th>Plan</th>
295
                                    <th class="filter-name filter-select">Ficha</th>
296
                                    <th>Aval.Enu</th>
297
                                    <th>Aval.Paut</th>
298
                                    <th class="filter-name filter-select">Relat.</th>
299
                                    <th class="filter-name filter-select">Pedag.</th>
300
 
301
                                    <th>Conteud.</th>
302
                                    <th class="filter-name filter-select">Detalhes</th>
303
 
304
                                </tr>
305
                                </thead>
306
                                <tbody>
307
                                    <%
1372 jmachado 308
                                }
1354 jmachado 309
                                        for(Long unit: courseUnits)
310
                                        {
311
                                            Long unitId =  unit;
312
                                            CourseUnit cu = DaoFactory.getCourseUnitDaoImpl().load(unitId);
313
                                            request.setAttribute("cu",cu);
314
                                    %>
315
                                    <tr>
1372 jmachado 316
                                        <%
317
                                            if(all != null && all.equals("true"))
318
                                            {
319
                                        %>
320
                                        <td><%=courseCode%></td>
321
                                        <td><%=courseName%></td>
322
                                        <%
323
                                            }
324
                                        %>
1354 jmachado 325
                                        <td>${cu.code}</td>
326
                                        <td>${cu.semestre}</td>
327
                                        <td><html:link target="_blank" action="/user/startLoadCourseUnitFromHome?id=${cu.id}"> ${cu.name}</html:link></td>
328
                                        <td>${cu.statdtpSumaries}</td>
329
                                        <td>${cu.statdtpSumariesPrelancados}</td>
330
                                        <td>${cu.statdtpSumariesMissing}</td>
331
                                        <td>${cu.statdtpPlaneamentoFiles}</td>
332
                                        <td><bean:message key="yes.no.${cu.statdtpFichaCurricularValid}"/></td>
333
                                        <td>${cu.statdtpAvaliacaoEnunciadosFiles}</td>
334
                                        <td>${cu.statdtpAvaliacaoPautasFiles}</td>
335
                                        <td>${cu.statdtpEvaluationReportState}</td>
336
                                        <td>${cu.statdtpInqueritoPedagogicoFiles}</td>
337
                                        <td>${cu.statcontentsFiles}</td>
338
                                        <td><button class="btn btn-default" data-href="<%=request.getContextPath()%>/user/courseunits/statsAjax.jsp?courseUnitId=${cu.id}" data-title="Estatisticas da Unidade ${cu.name} (${cu.code})" data-toggle="modal" data-target="#modalAjaxRequest"><span class="glyphicon glyphicon-zoom-in"/></button> </td>
339
                                    </tr>
340
                                    <%
341
                                        }
1372 jmachado 342
 
343
                            if(all == null)
344
                            {
345
                            %>
346
 
1354 jmachado 347
                                </tbody>
348
                            </table>
349
 
350
                        <%
1372 jmachado 351
                            }
1354 jmachado 352
                        }
353
 
354
                    }
355
 
1372 jmachado 356
                    if(all == null)
357
                    {
1354 jmachado 358
                    %>
359
                    </div> <!--FIM DE ROLE VALIDATION-->
360
                    <%
1372 jmachado 361
                    }
362
 
1354 jmachado 363
                }
1372 jmachado 364
                if(all != null && all.equals("true"))
365
                {
366
                %>
367
                        </tbody>
368
                    </table>
369
                <%
370
                }
1354 jmachado 371
                AbstractDao.getCurrentSession().getTransaction().commit();
372
            }
373
            catch(Exception e)
374
            {
375
                System.out.println(e.toString());
376
                e.printStackTrace();
377
            }
378
        }
379
 
1699 jmachado 380
        AbstractDao.getCurrentSession().getTransaction().commit();
1354 jmachado 381
        %>
382
 
383
    </div>
384
</div>
385