Subversion Repositories bacoAlunos

Rev

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