Subversion Repositories bacoAlunos

Rev

Rev 1926 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1926 Rev 1984
Line 1... Line -...
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-
 
2
<%@ page import="jomm.dao.impl.AbstractDao" %>
-
 
3
<%@ page import="pt.estgp.estgweb.domain.CourseImpl" %>
-
 
4
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
-
 
5
<%@ page import="pt.estgp.estgweb.utils.documentBuilder.TextComponent" %>
-
 
6
<%@ page import="pt.estgp.estgweb.utils.documentBuilder.ImageComponent" %>
-
 
7
<%@ page import="pt.estgp.estgweb.services.courses.CourseReportServices" %>
-
 
8
<%@ page import="pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument" %>
-
 
9
<%@ page import="org.json.JSONException" %>
1
<!--TEMPLATES FOR DOCUMENT BUILDER-->
10
 
2
 
11
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
-
 
12
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
-
 
13
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
-
 
14
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
-
 
15
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
-
 
16
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
-
 
17
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
-
 
18
 
-
 
19
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css">
-
 
20
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script>
-
 
21
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css">
-
 
22
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
-
 
23
<script>
-
 
24
    function demoFromHTML() {
-
 
25
        var pdf = new jsPDF('p', 'pt', 'letter');
-
 
26
        // source can be HTML-formatted string, or a reference
-
 
27
        // to an actual DOM element from which the text will be scraped.
-
 
28
        source = $('#courseReportApp')[0];
-
 
29
 
-
 
30
        // we support special element handlers. Register them with jQuery-style
-
 
31
        // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
-
 
32
        // There is no support for any other type of selectors
-
 
33
        // (class, of compound) at this time.
-
 
34
        specialElementHandlers = {
-
 
35
            // element with id of "bypass" - jQuery style selector
-
 
36
            '#bypassme': function (element, renderer) {
-
 
37
                // true = "handled elsewhere, bypass text extraction"
-
 
38
                return true
-
 
39
            }
-
 
40
        };
-
 
41
        margins = {
-
 
42
            top: 80,
-
 
43
            bottom: 60,
-
 
44
            left: 40,
-
 
45
            width: 522
-
 
46
        };
-
 
47
        // all coords and widths are in jsPDF instance's declared units
-
 
48
        // 'inches' in this case
-
 
49
        pdf.fromHTML(
-
 
50
            source, // HTML string or DOM elem ref.
-
 
51
            margins.left, // x coord
-
 
52
            margins.top, { // y coord
-
 
53
                'width': margins.width, // max width of content on PDF
-
 
54
                'elementHandlers': specialElementHandlers
-
 
55
            },
-
 
56
 
-
 
57
            function (dispose) {
-
 
58
                // dispose: object with X, Y of the last line add to the PDF
-
 
59
                //          this allow the insertion of new lines after html
-
 
60
                //var pdfDocument =  pdf.save('Test.pdf');
-
 
61
                var pdfDocument = pdf.output();
-
 
62
 
-
 
63
                var boundary = '---------------------------';
-
 
64
                boundary += Math.floor(Math.random()*32768);
-
 
65
                boundary += Math.floor(Math.random()*32768);
-
 
66
                boundary += Math.floor(Math.random()*32768);
-
 
67
 
-
 
68
                var body = '';
-
 
69
                body += '--' + boundary + '\r\n' +
-
 
70
                    'Content-Disposition: form-data; name="filesInputId-UPLOAD[]"; filename="20170530_210340.pdf"' + '\r\n';
-
 
71
                body += 'Content-Type: application/pdf';
-
 
72
                body += '\r\n\r\n';
-
 
73
                body += pdfDocument;
-
 
74
                body += '\r\n'
-
 
75
                body += '--' + boundary + '--';
-
 
76
 
-
 
77
 
-
 
78
 
-
 
79
                $.ajax({
-
 
80
                    type: "POST",
-
 
81
                    cache: false,
-
 
82
                    url: "<%=request.getContextPath()%>/filesUpload",
-
 
83
                    data: body ,
-
 
84
                    processData: false,
-
 
85
                    contentType : 'multipart/form-data; boundary=' + boundary,
-
 
86
                    success: function (data) {
-
 
87
                        alert('success');
-
 
88
                        return false;
-
 
89
                    }
-
 
90
                });
-
 
91
            }, margins
-
 
92
        );
-
 
93
    }
-
 
94
</script>
-
 
95
 
-
 
96
<%
-
 
97
 
-
 
98
    String courseCode = request.getParameter("courseCode");
-
 
99
    String year = request.getParameter("year");
-
 
100
    AbstractDao.getCurrentSession().beginTransaction();
-
 
101
    CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode);
-
 
102
    request.setAttribute("course",courseImpl);
-
 
103
    CourseReportDocument courseReport = null;
-
 
104
    try {
-
 
105
        courseReport = new CourseReportServices().createNewCourseReportDocument(courseCode, year);
-
 
106
    } catch (Throwable e) {
-
 
107
    System.out.println(e);
-
 
108
    e.printStackTrace();
-
 
109
    }
-
 
110
    String courseReportJson = courseReport.toJson();
-
 
111
    request.setAttribute("courseDocumentJson",courseReportJson);
-
 
112
    request.setAttribute("courseDocument",courseReport);
-
 
113
 
-
 
114
%>
-
 
115
<%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%>
-
 
116
 
-
 
117
<div class="container-fluid">
-
 
118
 
-
 
119
    <style>
-
 
120
        .separatorSection
-
 
121
        {
-
 
122
            border: 1px solid #ddd;
-
 
123
        }
-
 
124
    </style>
-
 
125
 
-
 
126
 
-
 
127
    <!-- Apresentacao da Unidade -->
-
 
128
 
-
 
129
    <div class="panel panel-default">
-
 
130
        <div class="panel-heading">
-
 
131
            Relatório Anual do curso: ${course.name}
-
 
132
        </div>
-
 
133
        <div class="panel-body">
-
 
134
 
-
 
135
            <p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p>
-
 
136
            <p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p>
-
 
137
            <p><b class="label-info">Departamento:</b> ${course.department.name}</p>
-
 
138
            <p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p>
-
 
139
 
-
 
140
 
-
 
141
 
-
 
142
 
-
 
143
            <script>
-
 
144
 
-
 
145
                //Especifico da aplicacao
-
 
146
                var courseReportApp = angular.module('courseReportApp', ['ui.tree']);
-
 
147
                GLOBAL_BacoAngularAppDependencies.push('courseReportApp');
-
 
148
 
-
 
149
 
-
 
150
                courseReportApp.directive('resizable', function () {
-
 
151
                    return {
-
 
152
                        restrict: 'A',
-
 
153
                        scope: {
-
 
154
                            callback: '&onResize'
-
 
155
                        },
-
 
156
                        link: function postLink(scope, elem, attrs) {
-
 
157
                            elem.resizable();
-
 
158
                            elem.on('resize', function (evt, ui, comp) {
-
 
159
                                scope.$apply(function() {
-
 
160
                                    if (scope.callback) {
-
 
161
                                        scope.callback({$evt: evt, $ui: ui, $comp: comp });
-
 
162
                                    }
-
 
163
                                })
-
 
164
                            });
-
 
165
                        }
-
 
166
                    };
-
 
167
                });
-
 
168
 
-
 
169
 
-
 
170
                courseReportApp.controller('courseReportAppController', function($scope)
-
 
171
                {
-
 
172
 
-
 
173
                    $scope.docAppSelector = "#courseReportApp";
-
 
174
                    $scope.report = <%=courseReportJson%>
-
 
175
 
-
 
176
                        $scope.resize = function(evt,ui,comp) {
-
 
177
                            //console.log (evt,ui);
-
 
178
                            comp.width = ui.size.width;
-
 
179
                            comp.height = ui.size.height;
-
 
180
                        }
-
 
181
 
-
 
182
                    /**
-
 
183
                     * @classe class to match
-
 
184
                     * @superClasses array of strings
-
 
185
                     * */
-
 
186
                    $scope.contains = function(obj,classe)
-
 
187
                    {
-
 
188
                        if(obj['@class'] && obj['@class'] == classe)
-
 
189
                            return true;
-
 
190
                        if(obj.allSuperClasses)
-
 
191
                        {
-
 
192
                            for(var i in obj.allSuperClasses)
-
 
193
                            {
-
 
194
                                if(classe == obj.allSuperClasses[i])
-
 
195
                                    return true;
-
 
196
                            }
-
 
197
                        }
-
 
198
                        return false;
-
 
199
                    }
-
 
200
 
-
 
201
                    $scope.showSep = function(section,subSection)
-
 
202
                    {
-
 
203
                        var s;
-
 
204
                        for(s in section.sections)
-
 
205
                        {
-
 
206
                            section.sections[s].active = false;
-
 
207
                        }
-
 
208
                        /*$(".separatorSectionNav").each(function()
-
 
209
                         {
-
 
210
                         angular.element($(this)).scope().section.active = false;
-
 
211
                         });*/
-
 
212
                        subSection.active = true;
-
 
213
                    }
-
 
214
 
-
 
215
                    /**
-
 
216
                     * Este metodo devolve o template mais profundo na hierarquia de classes
-
 
217
                     * permitindo emular o override, quanto mais especifica for a classe
-
 
218
                     * e caso exista template é esse o template devolvido
-
 
219
                     * procura um script com o id da classe e se nao existir
-
 
220
                     * vai subindo nas super classes
-
 
221
                     * @param obj
-
 
222
                     * @returns {*}
-
 
223
                     */
-
 
224
                    $scope.class2id = function(obj)
-
 
225
                    {
-
 
226
                        var objClassId = obj["@class"].replaceAll(".","_");
-
 
227
                        if($("script#" + objClassId).length > 0)
-
 
228
                        {
-
 
229
                            return objClassId;
-
 
230
                        }
-
 
231
                        if(obj.allSuperClasses)
-
 
232
                        {
-
 
233
                            var s;
-
 
234
                            for(s in obj.allSuperClasses)
-
 
235
                            {
-
 
236
                                var superClass = obj.allSuperClasses[s];
-
 
237
                                var superClassId = superClass.replaceAll(".","_");
-
 
238
                                if($("script#" + superClassId).length > 0)
-
 
239
                                {
-
 
240
                                    return superClassId;
-
 
241
                                }
-
 
242
                            }
-
 
243
                        }
-
 
244
                        return obj["@class"].replaceAll(".","_");
-
 
245
                    }
-
 
246
 
-
 
247
                    $scope.addText = function(parentCustomPane)
-
 
248
                    {
-
 
249
                        $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent")
-
 
250
                    }
-
 
251
 
-
 
252
                    $scope.addImage = function(parentCustomPane)
-
 
253
                    {
-
 
254
                        $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent")
-
 
255
                    }
-
 
256
 
-
 
257
                    $scope.addSimpleDocComponent = function(parentCustomPane,classComponent)
-
 
258
                    {
-
 
259
                        if(!parentCustomPane.components)
-
 
260
                        {
-
 
261
                            parentCustomPane.components = [];
-
 
262
                        }
-
 
263
                        parentCustomPane.components.push(
-
 
264
                            {
-
 
265
                                "@class" : classComponent
-
 
266
                            }
-
 
267
                        );
-
 
268
                    }
-
 
269
                    $scope.removeComponent = function(index,array)
-
 
270
                    {
-
 
271
                        array.splice(index,1);
-
 
272
                    }
-
 
273
 
-
 
274
                    $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement)
-
 
275
                    {
-
 
276
                        var modelObject = BacoAngularUtils.getAngularElementModel(targetElement);
-
 
277
 
-
 
278
                        if(modelObject.image && modelObject.image.identifier)
-
 
279
                        {
-
 
280
                            widgetCallWithActionParameters(
-
 
281
                                "<%=request.getContextPath()%>/user/json/repository.do",
-
 
282
                                "replaceRepositoryFileFromTempPrivateDomain",
-
 
283
                                {
-
 
284
                                    "identifier" : modelObject.image.identifier,
-
 
285
                                    "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
286
                                },
-
 
287
                                "#courseReportApp",
-
 
288
                                function(repositoryFile4JsonView)
-
 
289
                                {
-
 
290
                                    modelObject.image = repositoryFile4JsonView;
-
 
291
                                    //image URL is generated on reimport just to avoid caching
-
 
292
                                    modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
293
                                    angular.element($("#courseReportApp")).scope().$apply();
-
 
294
                                },
-
 
295
                                function(){}
-
 
296
                            );
-
 
297
                        }
-
 
298
                        else
-
 
299
                        {
-
 
300
                            widgetCallWithActionParameters(
-
 
301
                                "<%=request.getContextPath()%>/user/json/repository.do",
-
 
302
                                "saveRepositoryFileFromTempPrivateDomain",
-
 
303
                                {
-
 
304
                                    "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
305
                                },
-
 
306
                                "#courseReportApp",
-
 
307
                                function(repositoryFile4JsonView)
-
 
308
                                {
-
 
309
                                    modelObject.image = repositoryFile4JsonView;
-
 
310
                                    modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
311
                                    angular.element($("#courseReportApp")).scope().$apply();
-
 
312
                                },
-
 
313
                                function(){}
-
 
314
                            );
-
 
315
                        }
-
 
316
                    }
-
 
317
 
-
 
318
                    /* Guardar courseReport 7/12/2017 */
-
 
319
                    $scope.saveCourseReportDoc = function()
-
 
320
                    {
-
 
321
                        widgetCallWithActionParameters(
-
 
322
                            "<%=request.getContextPath()%>/user/courseReport.do",
-
 
323
                            "saveCourseReportDoc",
-
 
324
                            {
-
 
325
                                "courseReportDocument" : BacoJS.stringifyOrdered($scope.report)
-
 
326
                            },
-
 
327
                            "#courseReportApp",
-
 
328
                            function(json)
-
 
329
                            {
-
 
330
                                alert(BacoJS.stringifyOrdered(json));
-
 
331
                            },
-
 
332
                            function(){}
-
 
333
                        );
-
 
334
                    }
-
 
335
 
-
 
336
 
-
 
337
 
-
 
338
 
-
 
339
                });
-
 
340
            </script>
-
 
341
 
-
 
342
            <!--TEMPLATES FOR DOCUMENT BUILDER-->
-
 
343
            <jsp:include page="../utils/documentsBuilder.jsp"/>
-
 
344
            <jsp:include page="coursereport/templates.jsp"/>
-
 
345
 
-
 
346
            <div class="form-vertical">
-
 
347
                <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController">
-
 
348
                    <div class="web-mensages"></div>
-
 
349
                    <button class="btn" ng-click="saveCourseReportDoc()">Save</button>
-
 
350
 
-
 
351
                    <div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'">
-
 
352
 
-
 
353
                    </div>
-
 
354
 
-
 
355
                   <!-- <pre class="code">{{ report | json }}</pre> -->
-
 
356
 
-
 
357
 
-
 
358
 
-
 
359
                </div><!--App-->
-
 
360
            </div> <!--form-->
-
 
361
 
-
 
362
        </div><!--Panel Body-->
-
 
363
 
-
 
364
    </div><!--Panel-->
-
 
365
 
-
 
366
</div><!--container-fluid-->
-
 
367
 
-
 
368
<%
-
 
369
    AbstractDao.getCurrentSession().getTransaction().commit();
-
 
370
%>
-
 
371
 
3
<jsp:include page="../utils/reportEdit.jsp"/>
-
 
4
<jsp:include page="coursereport/templates.jsp"/>
-
 
5
 
372
Generated by GNU Enscript 1.6.5.2.
6
Generated by GNU Enscript 1.6.5.2.