Subversion Repositories bacoAlunos

Rev

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