Commit 633134f4ab8f6beb9202bf2d1fd54de0b87f4a8a
1 parent
93d88034
Exists in
master
Adicionado assets / fixups utilizados pelo lançamento de turma
Showing
3 changed files
with
1089 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,806 @@ |
1 | +//$j('#form_resultado').submit(function(event) {event.preventDefault()}); | |
2 | + | |
3 | +// variaveis usadas pelo modulo Frontend/Process.js | |
4 | +var PAGE_URL_BASE = 'diario'; | |
5 | +var API_URL_BASE = 'diarioApi'; | |
6 | + | |
7 | +var RESOURCE_NAME = 'matricula'; | |
8 | +var RESOURCES_NAME = 'matriculas'; | |
9 | + | |
10 | +var POST_LABEL = ''; | |
11 | +var DELETE_LABEL = ''; | |
12 | + | |
13 | +var SEARCH_ORIENTATION = ''; | |
14 | + | |
15 | +// funcoes usados pelo modulo Frontend/Process.js | |
16 | +var onClickSelectAllEvent = false; | |
17 | +var onClickActionEvent = false; | |
18 | +var onClickDeleteEvent = false; | |
19 | + | |
20 | +//url builders | |
21 | + | |
22 | +var deleteResourceUrlBuilder = { | |
23 | + buildUrl : function(urlBase, resourceName, additionalVars) { | |
24 | + | |
25 | + var vars = { | |
26 | + resource : resourceName, | |
27 | + oper : 'delete', | |
28 | + instituicao_id : $j('#ref_cod_instituicao').val(), | |
29 | + escola_id : $j('#ref_cod_escola').val(), | |
30 | + curso_id : $j('#ref_cod_curso').val(), | |
31 | + serie_id : $j('#ref_ref_cod_serie').val(), | |
32 | + turma_id : $j('#ref_cod_turma').val(), | |
33 | + ano_escolar : $j('#ano').val(), | |
34 | + etapa : $j('#etapa').val() | |
35 | + }; | |
36 | + | |
37 | + return resourceUrlBuilder.buildUrl(urlBase, $j.extend(vars, additionalVars)); | |
38 | + } | |
39 | +}; | |
40 | + | |
41 | + | |
42 | +var postResourceUrlBuilder = { | |
43 | + buildUrl : function(urlBase, resourceName, additionalVars) { | |
44 | + | |
45 | + var vars = { | |
46 | + resource : resourceName, | |
47 | + oper : 'post', | |
48 | + instituicao_id : $j('#ref_cod_instituicao').val(), | |
49 | + escola_id : $j('#ref_cod_escola').val(), | |
50 | + curso_id : $j('#ref_cod_curso').val(), | |
51 | + serie_id : $j('#ref_ref_cod_serie').val(), | |
52 | + turma_id : $j('#ref_cod_turma').val(), | |
53 | + ano_escolar : $j('#ano').val(), | |
54 | + componente_curricular_id : $j('#ref_cod_componente_curricular').val(), | |
55 | + etapa : $j('#etapa').val(), | |
56 | + matricula_id : $j('#etapa').val() | |
57 | + }; | |
58 | + | |
59 | + return resourceUrlBuilder.buildUrl(urlBase, $j.extend(vars, additionalVars)); | |
60 | + | |
61 | + } | |
62 | +}; | |
63 | + | |
64 | + | |
65 | +var getResourceUrlBuilder = { | |
66 | + buildUrl : function(urlBase, resourceName, additionalVars) { | |
67 | + | |
68 | + var vars = { | |
69 | + resource : resourceName, | |
70 | + oper : 'get', | |
71 | + instituicao_id : $j('#ref_cod_instituicao').val(), | |
72 | + escola_id : $j('#ref_cod_escola').val(), | |
73 | + curso_id : $j('#ref_cod_curso').val(), | |
74 | + serie_id : $j('#ref_ref_cod_serie').val(), | |
75 | + turma_id : $j('#ref_cod_turma').val(), | |
76 | + ano_escolar : $j('#ano').val(), | |
77 | + componente_curricular_id : $j('#ref_cod_componente_curricular').val(), | |
78 | + etapa : $j('#etapa').val(), | |
79 | + matricula_id : $j('#ref_cod_matricula').val() | |
80 | + }; | |
81 | + | |
82 | + return resourceUrlBuilder.buildUrl(urlBase, $j.extend(vars, additionalVars)); | |
83 | + | |
84 | + } | |
85 | +}; | |
86 | + | |
87 | + | |
88 | +function changeResource($resourceElement, postFunction, deleteFunction) { | |
89 | + if ($j.trim($resourceElement.val()) == '') | |
90 | + deleteFunction($resourceElement); | |
91 | + else | |
92 | + postFunction($resourceElement); | |
93 | +}; | |
94 | + | |
95 | + | |
96 | +function setDefaultFaltaIfEmpty(matricula_id, componente_curricular_id) { | |
97 | + var $element = $j('#falta-matricula-' + matricula_id + '-cc-' + componente_curricular_id); | |
98 | + if ($j.trim($element.val()) == '') { | |
99 | + $element.val(0); | |
100 | + $element.change(); | |
101 | + } | |
102 | +} | |
103 | + | |
104 | + | |
105 | +var changeNota = function(event) { | |
106 | + var $element = $j(this); | |
107 | + setDefaultFaltaIfEmpty($element.data('matricula_id'), $element.data('componente_curricular_id')); | |
108 | + changeResource($element, postNota, deleteNota); | |
109 | +}; | |
110 | + | |
111 | + | |
112 | +var changeNotaExame = function(event) { | |
113 | + var $element = $j(this); | |
114 | + setDefaultFaltaIfEmpty($element.data('matricula_id'), $element.data('componente_curricular_id')); | |
115 | + changeResource($element, postNotaExame, deleteNotaExame); | |
116 | +}; | |
117 | + | |
118 | + | |
119 | +var changeFalta = function(event) { | |
120 | + $element = $j(this); | |
121 | + changeResource($element, postFalta, deleteFalta); | |
122 | + | |
123 | + // se presenca geral, muda o valor em todas faltas da mesma matricula | |
124 | + if ($tableSearchDetails.data('details').tipo_presenca == 'geral') { | |
125 | + var $fieldsFaltaMatricula = $element.closest('table').find('.falta-matricula-' + $element | |
126 | + .data('matricula_id') + '-cc') | |
127 | + .not($element); | |
128 | + | |
129 | + $fieldsFaltaMatricula.val($element.val()); | |
130 | + $fieldsFaltaMatricula.data('old_value', $element.val()); | |
131 | + } | |
132 | +}; | |
133 | + | |
134 | + | |
135 | +var changeParecer = function(event) { | |
136 | + var $element = $j(this); | |
137 | + setDefaultFaltaIfEmpty($element.data('matricula_id'), $element.data('componente_curricular_id')); | |
138 | + changeResource($element, postParecer, deleteParecer); | |
139 | + | |
140 | + // se parecer geral, muda o valor em todos pareceres da mesma matricula | |
141 | + var parecerGeral = $j.inArray($tableSearchDetails.data('details').tipo_parecer_descritivo, | |
142 | + ['etapa_geral', 'anual_geral']) > -1; | |
143 | + | |
144 | + if (parecerGeral) { | |
145 | + var $fieldsParecerMatricula = $element.closest('table').find('.parecer-matricula-' + $element | |
146 | + .data('matricula_id') + '-cc') | |
147 | + .not($element); | |
148 | + | |
149 | + $fieldsParecerMatricula.val($element.val()); | |
150 | + $fieldsParecerMatricula.data('old_value', $element.val()); | |
151 | + } | |
152 | +}; | |
153 | + | |
154 | + | |
155 | +function afterChangeResource($resourceElement) { | |
156 | + $resourceElement.removeAttr('disabled').siblings('img').remove(); | |
157 | + | |
158 | + var resourceElementTabIndex = $resourceElement.attr('tabindex'); | |
159 | + var focusedElementTabIndex = $j('.tabable:focus').first().attr('tabindex'); | |
160 | + var lastElementTabIndex = $resourceElement.closest('form').find('.tabable').last().attr('tabindex'); | |
161 | + | |
162 | + // percorre os proximos elementos enquanto não chegar no ultimo | |
163 | + for(var nextTabIndex = resourceElementTabIndex + 1; nextTabIndex < lastElementTabIndex + 1; nextTabIndex++) { | |
164 | + //var $nextElement = $j($resourceElement.closest('form').find('.tabable:[tabindex="'+nextTabIndex+'"]')).first(); | |
165 | + var $nextElement = $j($resourceElement.closest('form').find('.tabable[tabindex="'+nextTabIndex+'"]')).first(); | |
166 | + | |
167 | + // seta foco no proximo elemento, caso este seja visivel e o elemento alterado ainda esteja focado | |
168 | + if($nextElement.is(':visible')) { | |
169 | + if(resourceElementTabIndex == focusedElementTabIndex) | |
170 | + $nextElement.focus(); | |
171 | + | |
172 | + break; | |
173 | + } | |
174 | + } | |
175 | +} | |
176 | + | |
177 | +function postNota($notaFieldElement) { | |
178 | + | |
179 | + $notaFieldElement.val($notaFieldElement.val().replace(',', '.')); | |
180 | + | |
181 | + if (validatesIfValueIsNumeric($notaFieldElement.val(), $notaFieldElement.attr('id')) && | |
182 | + validatesIfNumericValueIsInRange($notaFieldElement.val(), $notaFieldElement.attr('id'), 0, 10) && | |
183 | + validatesIfValueIsInSet($notaFieldElement.val(), $notaFieldElement.attr('id'), $tableSearchDetails.data('details').opcoes_notas)) { | |
184 | + | |
185 | + beforeChangeResource($notaFieldElement); | |
186 | + | |
187 | + var additionalVars = { | |
188 | + matricula_id : $notaFieldElement.data('matricula_id'), | |
189 | + componente_curricular_id : $notaFieldElement.data('componente_curricular_id') | |
190 | + }; | |
191 | + | |
192 | + var options = { | |
193 | + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'nota', additionalVars), | |
194 | + dataType : 'json', | |
195 | + data : {att_value : $notaFieldElement.val()}, | |
196 | + success : function(dataResponse) { | |
197 | + afterChangeResource($notaFieldElement); | |
198 | + handleChange(dataResponse); | |
199 | + } | |
200 | + }; | |
201 | + | |
202 | + $notaFieldElement.data('old_value', $notaFieldElement.val()); | |
203 | + postResource(options, handleErrorOnPostResource); | |
204 | + } | |
205 | +} | |
206 | + | |
207 | + | |
208 | +function postNotaExame($notaExameFieldElement) { | |
209 | + | |
210 | + $notaExameFieldElement.val($notaExameFieldElement.val().replace(',', '.')); | |
211 | + | |
212 | + if (validatesIfValueIsNumeric($notaExameFieldElement.val(), $notaExameFieldElement.attr('id')) && | |
213 | + validatesIfNumericValueIsInRange($notaExameFieldElement.val(), $notaExameFieldElement.attr('id'), 0, 10) && | |
214 | + validatesIfValueIsInSet($notaExameFieldElement.val(), $notaExameFieldElement.attr('id'), $tableSearchDetails.data('details').opcoes_notas)) { | |
215 | + | |
216 | + beforeChangeResource($notaExameFieldElement); | |
217 | + | |
218 | + var additionalVars = { | |
219 | + matricula_id : $notaExameFieldElement.data('matricula_id'), | |
220 | + componente_curricular_id : $notaExameFieldElement.data('componente_curricular_id'), | |
221 | + etapa : 'Rc' | |
222 | + }; | |
223 | + | |
224 | + var options = { | |
225 | + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'nota_exame', additionalVars), | |
226 | + dataType : 'json', | |
227 | + data : {att_value : $notaExameFieldElement.val()}, | |
228 | + success : function(dataResponse) { | |
229 | + afterChangeResource($notaExameFieldElement); | |
230 | + handleChange(dataResponse); | |
231 | + } | |
232 | + }; | |
233 | + | |
234 | + $notaExameFieldElement.data('old_value', $notaExameFieldElement.val()); | |
235 | + postResource(options, handleErrorOnPostResource); | |
236 | + } | |
237 | +} | |
238 | + | |
239 | + | |
240 | +function postFalta($faltaFieldElement) { | |
241 | + $faltaFieldElement.val($faltaFieldElement.val().replace(',', '.')); | |
242 | + | |
243 | + //falta é persistida como inteiro | |
244 | + if ($j.isNumeric($faltaFieldElement.val())) | |
245 | + $faltaFieldElement.val(parseInt($faltaFieldElement.val()).toString()); | |
246 | + | |
247 | + if (validatesIfValueIsNumeric($faltaFieldElement.val(), $faltaFieldElement.attr('id')) && | |
248 | + validatesIfNumericValueIsInRange($faltaFieldElement.val(), $faltaFieldElement.attr('id'), 0, 100)) { | |
249 | + | |
250 | + beforeChangeResource($faltaFieldElement); | |
251 | + | |
252 | + var additionalVars = { | |
253 | + matricula_id : $faltaFieldElement.data('matricula_id'), | |
254 | + componente_curricular_id : $faltaFieldElement.data('componente_curricular_id') | |
255 | + }; | |
256 | + | |
257 | + var options = { | |
258 | + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'falta', additionalVars), | |
259 | + dataType : 'json', | |
260 | + data : {att_value : $faltaFieldElement.val()}, | |
261 | + success : function(dataResponse) { | |
262 | + afterChangeResource($faltaFieldElement); | |
263 | + handleChange(dataResponse); | |
264 | + } | |
265 | + }; | |
266 | + | |
267 | + $faltaFieldElement.data('old_value', $faltaFieldElement.val()); | |
268 | + postResource(options, handleErrorOnPostResource); | |
269 | + } | |
270 | +} | |
271 | + | |
272 | + | |
273 | +function getEtapaParecer() { | |
274 | + if ($tableSearchDetails.data('details').tipo_parecer_descritivo.split('_')[0] == 'anual') | |
275 | + var etapaParecer = 'An'; | |
276 | + else | |
277 | + var etapaParecer = $j('#etapa').val(); | |
278 | + | |
279 | + return etapaParecer; | |
280 | +} | |
281 | + | |
282 | + | |
283 | +function postParecer($parecerFieldElement) { | |
284 | + var additionalVars = { | |
285 | + matricula_id : $parecerFieldElement.data('matricula_id'), | |
286 | + componente_curricular_id : $parecerFieldElement.data('componente_curricular_id'), | |
287 | + etapa : getEtapaParecer() | |
288 | + }; | |
289 | + | |
290 | + var options = { | |
291 | + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'parecer', additionalVars), | |
292 | + dataType : 'json', | |
293 | + data : {att_value : $parecerFieldElement.val()}, | |
294 | + success : function(dataResponse) { | |
295 | + afterChangeResource($parecerFieldElement); | |
296 | + handleChange(dataResponse); | |
297 | + } | |
298 | + }; | |
299 | + | |
300 | + $parecerFieldElement.data('old_value', $parecerFieldElement.val()); | |
301 | + postResource(options, handleErrorOnPostResource); | |
302 | +} | |
303 | + | |
304 | + | |
305 | +function confirmDelete(resourceName) { | |
306 | + return confirm(safeUtf8Decode('Confirma exclusão ' + resourceName.replace('_',' ') + '?')); | |
307 | +} | |
308 | + | |
309 | + | |
310 | +function deleteResource(resourceName, $resourceElement, options, handleErrorOnDeleteResource) { | |
311 | + if (confirmDelete(resourceName)) { | |
312 | + beforeChangeResource($resourceElement); | |
313 | + $resourceElement.data('old_value', ''); | |
314 | + $j.ajax(options).error(handleErrorOnDeleteResource); | |
315 | + } | |
316 | + else | |
317 | + { | |
318 | + afterChangeResource($resourceElement); | |
319 | + $resourceElement.val($resourceElement.data('old_value')); | |
320 | + } | |
321 | +} | |
322 | + | |
323 | + | |
324 | +function deleteNota($notaFieldElement) { | |
325 | + var resourceName = 'nota'; | |
326 | + | |
327 | + var additionalVars = { | |
328 | + instituicao_id : $j('#ref_cod_instituicao').val(), | |
329 | + escola_id : $j('#ref_cod_escola').val(), | |
330 | + curso_id : $j('#ref_cod_curso').val(), | |
331 | + serie_id : $j('#ref_ref_cod_serie').val(), | |
332 | + turma_id : $j('#ref_cod_turma').val(), | |
333 | + ano_escolar : $j('#ano').val(), | |
334 | + componente_curricular_id : $notaFieldElement.data('componente_curricular_id'), | |
335 | + etapa : $j('#etapa').val(), | |
336 | + matricula_id : $notaFieldElement.data('matricula_id') | |
337 | + }; | |
338 | + | |
339 | + var options = { | |
340 | + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, resourceName, additionalVars), | |
341 | + dataType : 'json', | |
342 | + success : function(dataResponse) { | |
343 | + afterChangeResource($notaFieldElement); | |
344 | + handleChange(dataResponse); | |
345 | + } | |
346 | + }; | |
347 | + | |
348 | + deleteResource(resourceName, $notaFieldElement, options, handleErrorOnDeleteResource); | |
349 | +}; | |
350 | + | |
351 | + | |
352 | +function deleteNotaExame($notaExameFieldElement) { | |
353 | + var resourceName = 'nota_exame'; | |
354 | + | |
355 | + var additionalVars = { | |
356 | + componente_curricular_id : $notaExameFieldElement.data('componente_curricular_id'), | |
357 | + etapa : 'Rc', | |
358 | + matricula_id : $notaExameFieldElement.data('matricula_id') | |
359 | + }; | |
360 | + | |
361 | + var options = { | |
362 | + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, resourceName, additionalVars), | |
363 | + dataType : 'json', | |
364 | + success : function(dataResponse) { | |
365 | + afterChangeResource($notaExameFieldElement); | |
366 | + handleChange(dataResponse); | |
367 | + } | |
368 | + }; | |
369 | + | |
370 | + deleteResource(resourceName, $notaExameFieldElement, options, handleErrorOnDeleteResource); | |
371 | +}; | |
372 | + | |
373 | + | |
374 | +function deleteFalta($faltaFieldElement) { | |
375 | + | |
376 | + //excluir falta se nota, nota exame e parecer (não existirem ou) estiverem sem valor | |
377 | + var matriculaId = $faltaFieldElement.data('matricula_id'); | |
378 | + var ccId = $faltaFieldElement.data('componente_curricular_id'); | |
379 | + | |
380 | + var $notaField = $j('#nota-matricula-'+ matriculaId + '-cc-' + ccId); | |
381 | + var $notaExameField = $j('#nota-exame-matricula-'+ matriculaId + '-cc-' + ccId); | |
382 | + var $parecerField = $j('#parecer-matricula-'+ matriculaId + '-cc-' + ccId); | |
383 | + | |
384 | + if(($notaField.length < 1 || $notaField.val() == '') && | |
385 | + ($notaExameField.length < 1 || $notaExameField.val() == '') && | |
386 | + ($parecerField.length < 1 || $j.trim($parecerField.val()) == '') | |
387 | + ) { | |
388 | + var resourceName = 'falta'; | |
389 | + | |
390 | + var additionalVars = { | |
391 | + componente_curricular_id : $faltaFieldElement.data('componente_curricular_id'), | |
392 | + matricula_id : $faltaFieldElement.data('matricula_id') | |
393 | + }; | |
394 | + | |
395 | + var options = { | |
396 | + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, resourceName, additionalVars), | |
397 | + dataType : 'json', | |
398 | + success : function(dataResponse) { | |
399 | + afterChangeResource($faltaFieldElement); | |
400 | + handleChange(dataResponse); | |
401 | + } | |
402 | + }; | |
403 | + | |
404 | + deleteResource(resourceName, $faltaFieldElement, options, handleErrorOnDeleteResource); | |
405 | + } | |
406 | + else{ | |
407 | + | |
408 | + $faltaFieldElement.val($faltaFieldElement.data('old_value')); | |
409 | + | |
410 | + handleMessages([{type : 'error', msg : safeUtf8Decode('Falta não pode ser removida após ter lançado notas ou parecer descritivo, tente definir como 0 (zero).')}], $faltaFieldElement.attr('id')); | |
411 | + } | |
412 | +} | |
413 | + | |
414 | + | |
415 | +function deleteParecer($parecerFieldElement) { | |
416 | + var resourceName = 'parecer'; | |
417 | + | |
418 | + var additionalVars = { | |
419 | + componente_curricular_id : $parecerFieldElement.data('componente_curricular_id'), | |
420 | + matricula_id : $parecerFieldElement.data('matricula_id'), | |
421 | + etapa : getEtapaParecer() | |
422 | + }; | |
423 | + | |
424 | + var options = { | |
425 | + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, resourceName, additionalVars), | |
426 | + dataType : 'json', | |
427 | + success : function(dataResponse) { | |
428 | + afterChangeResource($parecerFieldElement); | |
429 | + handleChange(dataResponse); | |
430 | + } | |
431 | + }; | |
432 | + | |
433 | + deleteResource(resourceName, $parecerFieldElement, options, handleErrorOnDeleteResource); | |
434 | +} | |
435 | + | |
436 | + | |
437 | +//callback handlers | |
438 | + | |
439 | +function handleChange(dataResponse) { | |
440 | + var targetId = dataResponse.resource + '-matricula-' + dataResponse.matricula_id + | |
441 | + '-cc-' + dataResponse.componente_curricular_id; | |
442 | + | |
443 | + handleMessages(dataResponse.msgs, targetId); | |
444 | + updateResourceRow(dataResponse); | |
445 | +} | |
446 | + | |
447 | + | |
448 | +function setTableSearchDetails($tableSearchDetails, dataDetails) { | |
449 | + var componenteCurricularSelected = ($j('#ref_cod_componente_curricular').val() != ''); | |
450 | + | |
451 | + $j('<caption />').html('<strong>Lançamento de notas por turma</strong>').appendTo($tableSearchDetails); | |
452 | + | |
453 | + //set headers table | |
454 | + var $linha = $j('<tr />'); | |
455 | + | |
456 | + if (componenteCurricularSelected) | |
457 | + $j('<th />').html('Componente curricular').appendTo($linha); | |
458 | + | |
459 | + $j('<th />').html('Etapa').appendTo($linha); | |
460 | + $j('<th />').html('Turma').appendTo($linha); | |
461 | + $j('<th />').html(safeUtf8Decode('Série')).appendTo($linha); | |
462 | + $j('<th />').html('Ano').appendTo($linha); | |
463 | + $j('<th />').html('Escola').appendTo($linha); | |
464 | + $j('<th />').html('Regra avaliação').appendTo($linha); | |
465 | + $j('<th />').html('Tipo nota').appendTo($linha); | |
466 | + $j('<th />').html('Tipo presença').appendTo($linha); | |
467 | + $j('<th />').html('Tipo parecer').appendTo($linha); | |
468 | + | |
469 | + $linha.appendTo($tableSearchDetails); | |
470 | + | |
471 | + var $linha = $j('<tr />').addClass('cellColor'); | |
472 | + | |
473 | + if (componenteCurricularSelected) | |
474 | + $j('<td />').html(safeToUpperCase($j('#ref_cod_componente_curricular').children("[selected='selected']").html())).appendTo($linha); | |
475 | + | |
476 | + $j('<td />').html(safeToUpperCase($j('#etapa').children("[selected='selected']").html())).appendTo($linha); | |
477 | + $j('<td />').html(safeToUpperCase($j('#ref_cod_turma').children("[selected='selected']").html())).appendTo($linha); | |
478 | + $j('<td />').html(safeToUpperCase($j('#ref_ref_cod_serie').children("[selected='selected']").html())).appendTo($linha); | |
479 | + $j('<td />').html($j('#ano').val()).appendTo($linha); | |
480 | + | |
481 | + //field escola pode ser diferente de select caso usuario comum | |
482 | + var $htmlEscolaField = $j('#ref_cod_escola').children("[selected='selected']").html() || | |
483 | + $j('#tr_nm_escola span:last').html(); | |
484 | + | |
485 | + $j('<td />').html(safeToUpperCase($htmlEscolaField)).appendTo($linha); | |
486 | + $j('<td />').html(dataDetails.id + ' - ' +safeToUpperCase(dataDetails.nome)).appendTo($linha); | |
487 | + | |
488 | + //corrige acentuação | |
489 | + var tipoNota = dataDetails.tipo_nota.replace('_', ' '); | |
490 | + if (tipoNota == 'numerica') | |
491 | + tipoNota = 'numérica'; | |
492 | + $j('<td />').html(safeToUpperCase(safeUtf8Decode(tipoNota))).appendTo($linha); | |
493 | + | |
494 | + $j('<td />').html(safeToUpperCase(dataDetails.tipo_presenca.replace('_', ' '))).appendTo($linha); | |
495 | + $j('<td />').html(safeToUpperCase(dataDetails.tipo_parecer_descritivo.replace('_', ' '))).appendTo($linha); | |
496 | + | |
497 | + $linha.appendTo($tableSearchDetails); | |
498 | + $tableSearchDetails.show(); | |
499 | + | |
500 | + //dataDetails.opcoes_notas = safeSortArray(dataDetails.opcoes_notas); | |
501 | + $tableSearchDetails.data('details', dataDetails); | |
502 | +} | |
503 | + | |
504 | +var nextTabIndex = 1; | |
505 | + | |
506 | +function setNextTabIndex($element) { | |
507 | + $element.attr('tabindex', nextTabIndex); | |
508 | + $element.addClass('tabable'); | |
509 | + nextTabIndex += 1; | |
510 | +} | |
511 | + | |
512 | +function handleSearch($resultTable, dataResponse) { | |
513 | + var componenteCurricularSelected = ($j('#ref_cod_componente_curricular').val() != ''); | |
514 | + | |
515 | + // resets next tabindex | |
516 | + var nextTabIndex = 1; | |
517 | + | |
518 | + //set headers | |
519 | + var $linha = $j('<tr />'); | |
520 | + $j('<th />').html(safeUtf8Decode('Matrícula')).appendTo($linha); | |
521 | + $j('<th />').attr('colspan', componenteCurricularSelected ? 0 : 4).html('Aluno').appendTo($linha); | |
522 | + | |
523 | + if (componenteCurricularSelected) | |
524 | + updateComponenteCurricularHeaders($linha, $j('<th />')); | |
525 | + | |
526 | + $linha.appendTo($resultTable); | |
527 | + | |
528 | + //set (result) rows | |
529 | + $j.each(dataResponse.matriculas, function(index, value) { | |
530 | + var $linha = $j('<tr />').addClass(componenteCurricularSelected ? '' : 'strong'); | |
531 | + | |
532 | + $j('<td />').html(value.matricula_id).addClass('center').appendTo($linha); | |
533 | + $j('<td />').html(value.aluno_id + ' - ' +safeToUpperCase(value.nome)) | |
534 | + .attr('colspan', componenteCurricularSelected ? 0 : 4) | |
535 | + .appendTo($linha); | |
536 | + | |
537 | + if (componenteCurricularSelected && value.componentes_curriculares.length > 0) | |
538 | + updateComponenteCurricular($linha, value.matricula_id, value.componentes_curriculares[0]); | |
539 | + | |
540 | + $linha.fadeIn('slow').appendTo($resultTable); | |
541 | + $linha.appendTo($resultTable); | |
542 | + | |
543 | + if (! componenteCurricularSelected) | |
544 | + updateComponenteCurriculares($resultTable, value.matricula_id, value.componentes_curriculares); | |
545 | + }); | |
546 | + | |
547 | + // seta colspan [th, td].aluno quando exibe nota exame | |
548 | + if ($tableSearchDetails.data('details').tipo_nota != 'nenhum' && | |
549 | + $tableSearchDetails.data('details').quantidade_etapas == $j('#etapa').val()) { | |
550 | + $resultTable.find('[colspan]').attr('colspan', componenteCurricularSelected ? 1 : 5); | |
551 | + } | |
552 | + | |
553 | + $resultTable.find('tr:even').addClass('even'); | |
554 | + | |
555 | + //set onchange events | |
556 | + var $notaFields = $resultTable.find('.nota-matricula-cc'); | |
557 | + var $notaExameFields = $resultTable.find('.nota-exame-matricula-cc'); | |
558 | + var $faltaFields = $resultTable.find('.falta-matricula-cc'); | |
559 | + var $parecerFields = $resultTable.find('.parecer-matricula-cc'); | |
560 | + $notaFields.on('change', changeNota); | |
561 | + $notaExameFields.on('change', changeNotaExame); | |
562 | + $faltaFields.on('change', changeFalta); | |
563 | + $parecerFields.on('change', changeParecer); | |
564 | + | |
565 | + $resultTable.addClass('styled').find('.tabable:first').focus(); | |
566 | +} | |
567 | + | |
568 | +function _notaField(matriculaId, componenteCurricularId, klass, id, value) { | |
569 | + if($tableSearchDetails.data('details').tipo_nota == 'conceitual') { | |
570 | + var opcoesNotas = $tableSearchDetails.data('details').opcoes_notas; | |
571 | + | |
572 | + var $notaField = $j('<select />') | |
573 | + .addClass(klass) | |
574 | + .attr('id', id) | |
575 | + .data('matricula_id', matriculaId) | |
576 | + .data('componente_curricular_id', componenteCurricularId); | |
577 | + | |
578 | + // adiciona opcoes notas ao select | |
579 | + var $option = $j('<option />').appendTo($notaField); | |
580 | + for(key in opcoesNotas) { | |
581 | + var $option = $j('<option />').val(key).html(opcoesNotas[key]); | |
582 | + | |
583 | + if (value == key) | |
584 | + $option.attr('selected', 'selected'); | |
585 | + | |
586 | + $option.appendTo($notaField); | |
587 | + } | |
588 | + } | |
589 | + else { | |
590 | + var $notaField = $j('<input />').addClass(klass) | |
591 | + .attr('id', id) | |
592 | + .attr('maxlength', '4') | |
593 | + .attr('size', '4') | |
594 | + .val(value) | |
595 | + .data('matricula_id', matriculaId) | |
596 | + .data('componente_curricular_id', componenteCurricularId); | |
597 | + } | |
598 | + | |
599 | + $notaField.data('old_value', value); | |
600 | + setNextTabIndex($notaField); | |
601 | + | |
602 | + return $j('<td />').html($notaField).addClass('center'); | |
603 | +} | |
604 | + | |
605 | + | |
606 | +function notaField(matriculaId, componenteCurricularId, value) { | |
607 | + return _notaField(matriculaId, | |
608 | + componenteCurricularId, | |
609 | + 'nota-matricula-cc', | |
610 | + 'nota-matricula-' + matriculaId + '-cc-' + componenteCurricularId, | |
611 | + value); | |
612 | +} | |
613 | + | |
614 | + | |
615 | +function notaExameField(matriculaId, componenteCurricularId, value) { | |
616 | + return _notaField(matriculaId, | |
617 | + componenteCurricularId, | |
618 | + 'nota-exame-matricula-cc', | |
619 | + 'nota-exame-matricula-' + matriculaId + '-cc-' + componenteCurricularId, | |
620 | + value); | |
621 | +} | |
622 | + | |
623 | + | |
624 | +function faltaField(matriculaId, componenteCurricularId, value) { | |
625 | + var $faltaField = $j('<input />').addClass('falta-matricula-cc') | |
626 | + .addClass('falta-matricula-' + matriculaId + '-cc') | |
627 | + .attr('id', 'falta-matricula-' + matriculaId + '-cc-' + componenteCurricularId) | |
628 | + .attr('maxlength', '4') | |
629 | + .attr('size', '4') | |
630 | + .val(value) | |
631 | + .data('old_value', value) | |
632 | + .data('matricula_id', matriculaId) | |
633 | + .data('componente_curricular_id', componenteCurricularId); | |
634 | + | |
635 | + setNextTabIndex($faltaField); | |
636 | + return $j('<td />').html($faltaField).addClass('center'); | |
637 | +} | |
638 | + | |
639 | +function parecerField(matriculaId, componenteCurricularId, value) { | |
640 | + var $parecerField = $j('<textarea />').attr('cols', '40') | |
641 | + .attr('rows', '5') | |
642 | + .addClass('parecer-matricula-cc') | |
643 | + .addClass('parecer-matricula-' + matriculaId + '-cc') | |
644 | + .attr('id', 'parecer-matricula-' + matriculaId + '-cc-' + componenteCurricularId) | |
645 | + .val(value) | |
646 | + .data('old_value', value) | |
647 | + .data('matricula_id', matriculaId) | |
648 | + .data('componente_curricular_id', componenteCurricularId); | |
649 | + | |
650 | + setNextTabIndex($parecerField); | |
651 | + return $j('<td />').addClass('center').html($parecerField); | |
652 | +} | |
653 | + | |
654 | +function updateComponenteCurricular($targetElement, matriculaId, cc) { | |
655 | + var useNota = $tableSearchDetails.data('details').tipo_nota != 'nenhum'; | |
656 | + var useParecer = $tableSearchDetails.data('details').tipo_parecer_descritivo != 'nenhum'; | |
657 | + | |
658 | + var $situacaoTd = $j('<td />').addClass('situacao-matricula-cc') | |
659 | + .attr('id', 'situacao-matricula-' + matriculaId + '-cc-' + cc.id) | |
660 | + .data('matricula_id', matriculaId) | |
661 | + .data('componente_curricular_id', cc.id) | |
662 | + .addClass('center') | |
663 | + .html(cc.situacao) | |
664 | + .appendTo($targetElement); | |
665 | + | |
666 | + colorizeSituacaoTd($situacaoTd, cc.situacao); | |
667 | + | |
668 | + if(useNota) { | |
669 | + notaField(matriculaId, cc.id, cc.nota_atual).appendTo($targetElement); | |
670 | + | |
671 | + // mostra nota exame caso estiver selecionado a ultima etapa | |
672 | + if ($tableSearchDetails.data('details').quantidade_etapas == $j('#etapa').val()) { | |
673 | + var $fieldNotaExame = notaExameField(matriculaId, cc.id, cc.nota_exame); | |
674 | + | |
675 | + if (cc.nota_exame == '' && safeToLowerCase(cc.situacao) != 'em exame') | |
676 | + $fieldNotaExame.children().hide(); | |
677 | + | |
678 | + $fieldNotaExame.appendTo($targetElement); | |
679 | + } | |
680 | + | |
681 | + } | |
682 | + | |
683 | + faltaField(matriculaId, cc.id, cc.falta_atual).appendTo($targetElement); | |
684 | + | |
685 | + if (useParecer) | |
686 | + parecerField(matriculaId, cc.id, cc.parecer_atual).appendTo($targetElement); | |
687 | +} | |
688 | + | |
689 | +function updateComponenteCurricularHeaders($targetElement, $tagElement) { | |
690 | + var useNota = $tableSearchDetails.data('details').tipo_nota != 'nenhum'; | |
691 | + var useParecer = $tableSearchDetails.data('details').tipo_parecer_descritivo != 'nenhum'; | |
692 | + | |
693 | + $tagElement.clone().addClass('center').html(safeUtf8Decode('Situação')).appendTo($targetElement); | |
694 | + | |
695 | + if (useNota) { | |
696 | + $tagElement.clone().addClass('center').html('Nota').appendTo($targetElement); | |
697 | + | |
698 | + if ($tableSearchDetails.data('details').quantidade_etapas == $j('#etapa').val()) | |
699 | + $tagElement.clone().addClass('center').html('Nota exame').appendTo($targetElement); | |
700 | + } | |
701 | + | |
702 | + $tagElement.clone().addClass('center').html('Falta').appendTo($targetElement); | |
703 | + | |
704 | + if (useParecer) | |
705 | + $tagElement.clone().addClass('center').html('Parecer descritivo').appendTo($targetElement); | |
706 | +} | |
707 | + | |
708 | +function updateComponenteCurriculares($targetElement, matriculaId, componentesCurriculares) { | |
709 | + var useNota = $tableSearchDetails.data('details').tipo_nota != 'nenhum'; | |
710 | + var useParecer = $tableSearchDetails.data('details').tipo_parecer_descritivo != 'nenhum'; | |
711 | + | |
712 | + var $ccHeader = $j('<tr />').addClass('strong'); | |
713 | + | |
714 | + $j('<td />').addClass('center').html('Componente curricular').appendTo($ccHeader); | |
715 | + updateComponenteCurricularHeaders($ccHeader, $j('<td />')); | |
716 | + | |
717 | + $ccHeader.appendTo($targetElement); | |
718 | + | |
719 | + $j.each(componentesCurriculares, function(index, cc) { | |
720 | + var $ccRow = $j('<tr />'); | |
721 | + | |
722 | + $j('<td />').addClass('center').html(cc.nome).appendTo($ccRow); | |
723 | + updateComponenteCurricular($ccRow, matriculaId, cc); | |
724 | + | |
725 | + $ccRow.appendTo($targetElement); | |
726 | + }); | |
727 | +} | |
728 | + | |
729 | + | |
730 | +function updateResourceRow(dataResponse) { | |
731 | + var matriculaId = dataResponse.matricula_id; | |
732 | + var ccId = dataResponse.componente_curricular_id; | |
733 | + | |
734 | + var $situacaoField = $j('#situacao-matricula-' + matriculaId + '-cc-' + ccId); | |
735 | + var $fieldNotaExame = $j('#nota-exame-matricula-' + matriculaId + '-cc-' + ccId); | |
736 | + | |
737 | + $situacaoField.html(dataResponse.situacao); | |
738 | + colorizeSituacaoTd($situacaoField.closest('td'), dataResponse.situacao); | |
739 | + | |
740 | + if (! $fieldNotaExame.is(':visible') && | |
741 | + ($fieldNotaExame.val() != '' || safeToLowerCase(dataResponse.situacao) == 'em exame')) { | |
742 | + | |
743 | + $fieldNotaExame.show(); | |
744 | + $fieldNotaExame.focus(); | |
745 | + } | |
746 | + else if($fieldNotaExame.val() == '' && safeToLowerCase(dataResponse.situacao) != 'em exame') | |
747 | + $fieldNotaExame.hide(); | |
748 | +} | |
749 | + | |
750 | +function colorizeSituacaoTd(tdElement, situacao) { | |
751 | + if (safeToLowerCase(situacao) == 'retido') | |
752 | + $j(tdElement).addClass('error'); | |
753 | + else | |
754 | + $j(tdElement).removeClass('error'); | |
755 | +} | |
756 | + | |
757 | +function canSearch(){ | |
758 | + | |
759 | + if ($j('#ref_cod_matricula').val() == '' && $j('#ref_cod_componente_curricular').val() == '') { | |
760 | + alert(safeUtf8Decode('Selecione um Componente curricular e/ou uma Matrícula')); | |
761 | + return false; | |
762 | + } | |
763 | + | |
764 | + return true; | |
765 | +} | |
766 | + | |
767 | +function selectNextOption($selectElement){ | |
768 | + var $nextOption = $selectElement.find('option:selected').next('option'); | |
769 | + | |
770 | + if ($nextOption.val() != undefined) { | |
771 | + $selectElement.val($nextOption.val()); | |
772 | + | |
773 | + clearSearchResult(); | |
774 | + $j('#botao_busca').click(); | |
775 | + } | |
776 | + | |
777 | + else { | |
778 | + alert(safeUtf8Decode('Você chegou na ultima opção.')); | |
779 | + showSearchForm(); | |
780 | + } | |
781 | +} | |
782 | + | |
783 | +function nextComponenteCurricular(){ | |
784 | + selectNextOption($j('#ref_cod_componente_curricular')); | |
785 | +} | |
786 | + | |
787 | +function nextMatricula(){ | |
788 | + selectNextOption($j('#ref_cod_matricula')); | |
789 | +} | |
790 | + | |
791 | +function showNextSelectionButton() { | |
792 | + var $ccField = $j('#ref_cod_componente_curricular'); | |
793 | + var $matriculaField = $j('#ref_cod_matricula'); | |
794 | + | |
795 | + if ($ccField.val() != '') { | |
796 | + $j("<a href='#'>Proximo componente curricular</a>").bind('click', nextComponenteCurricular) | |
797 | + .attr('style', 'text-decoration: underline') | |
798 | + .appendTo($navActions); | |
799 | + } | |
800 | + | |
801 | + if ($matriculaField.val() != '') { | |
802 | + $j("<a href='#'>Proxima matricula</a>").bind('click', nextMatricula) | |
803 | + .attr('style', 'text-decoration: underline') | |
804 | + .appendTo($navActions); | |
805 | + } | |
806 | +} | ... | ... |
ieducar/modules/Avaliacao/Assets/Javascripts/Promocao.js
0 → 100644
... | ... | @@ -0,0 +1,121 @@ |
1 | +// variaveis usadas pelo modulo Frontend/Process.js | |
2 | + | |
3 | +processOptions.validatesResourcesAfterSearch = false; | |
4 | + | |
5 | +// #DEPRECADO, migrar para novo padrao processOptions | |
6 | +var PAGE_URL_BASE = 'promocao'; | |
7 | +var API_URL_BASE = 'promocaoApi'; | |
8 | +var RESOURCE_NAME = 'promocao'; | |
9 | +var RESOURCES_NAME = 'quantidade_matriculas'; | |
10 | +var POST_LABEL = ''; | |
11 | +var DELETE_LABEL = ''; | |
12 | +var SEARCH_ORIENTATION = ''; | |
13 | + | |
14 | +// funcoes usados pelo modulo Frontend/Process.js | |
15 | +var onClickSelectAllEvent = false; | |
16 | +var onClickActionEvent = false; | |
17 | +var onClickDeleteEvent = false; | |
18 | + | |
19 | +//url builders | |
20 | + | |
21 | +var setTableSearchDetails = function(){ } | |
22 | + | |
23 | +var postPromocaoMatricula = function(){ | |
24 | + var $proximoMatriculaIdField = $j('#proximo-matricula-id'); | |
25 | + $proximoMatriculaIdField.data('initial_matricula_id', $proximoMatriculaIdField.val()) | |
26 | + | |
27 | + if (validatesIfValueIsNumeric($proximoMatriculaIdField.val())) { | |
28 | + var options = { | |
29 | + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'promocao', {matricula_id : $proximoMatriculaIdField.val()}), | |
30 | + dataType : 'json', | |
31 | + data : { | |
32 | + instituicao_id : $j('#instituicao_id').val(), | |
33 | + ano_escolar : $j('#ano_escolar').val(), | |
34 | + }, | |
35 | + success : handlePostPromocaoMatricula | |
36 | + }; | |
37 | + | |
38 | + postResource(options); | |
39 | + } | |
40 | +} | |
41 | + | |
42 | + | |
43 | +var deleteOldComponentesCurriculares = function() { | |
44 | + var options = { | |
45 | + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, 'old_componentes_curriculares', {ano_escolar : $j('#ano_escolar').val()}), | |
46 | + dataType : 'json', | |
47 | + data : {}, | |
48 | + success : handleDelete | |
49 | + }; | |
50 | + | |
51 | + deleteResource(options); | |
52 | +} | |
53 | + | |
54 | + | |
55 | +//callback handlers | |
56 | + | |
57 | +function handlePostPromocaoMatricula(dataResponse){ | |
58 | + handleMessages(dataResponse.msgs); | |
59 | + | |
60 | + var $proximoMatriculaIdField = $j('#proximo-matricula-id'); | |
61 | + $proximoMatriculaIdField.val(dataResponse.result.proximo_matricula_id); | |
62 | + | |
63 | + if($j('#continuar-processo').is(':checked') && | |
64 | + $j.isNumeric($proximoMatriculaIdField.val()) && | |
65 | + $proximoMatriculaIdField.data('initial_matricula_id') != $proximoMatriculaIdField.val()){ | |
66 | + $j('#promover-matricula').click(); | |
67 | + } | |
68 | + else if(($j('#continuar-processo').is(':checked') && | |
69 | + $proximoMatriculaIdField.data('initial_matricula_id') == $proximoMatriculaIdField.val()) || | |
70 | + ! $j.isNumeric($proximoMatriculaIdField.val())){ | |
71 | + alert('Processo finalizado'); | |
72 | + } | |
73 | +} | |
74 | + | |
75 | + | |
76 | +function handleDelete(dataResponse){ | |
77 | + handleMessages(dataResponse.msgs); | |
78 | +} | |
79 | + | |
80 | +function handleSearch($resultTable, dataResponse) { | |
81 | + var $text = $j('<p />').html('Quantidade de matrículas em andamento: ' + | |
82 | + dataResponse.quantidade_matriculas + '<br />'); | |
83 | + | |
84 | + $j('<input />').attr('type', 'checkbox').attr('id', 'continuar-processo').attr('name', 'continuar-processo').appendTo($text); | |
85 | + $j('<span />').html('Continuar processo <br />').appendTo($text); | |
86 | + | |
87 | + $j('<span />').html('proxima matricula:').appendTo($text); | |
88 | + $j('<input />').attr('type', 'text').attr('name', 'proximo-matricula-id').attr('id', 'proximo-matricula-id').val('0').appendTo($text); | |
89 | + | |
90 | + $j('<br />').appendTo($text); | |
91 | + | |
92 | + $j('<a />').attr('id', 'promover-matricula') | |
93 | + .attr('href', '#') | |
94 | + .html('Iniciar processo') | |
95 | + .attr('style', 'text-decoration:underline') | |
96 | + .bind('click', postPromocaoMatricula) | |
97 | + .appendTo($text); | |
98 | + | |
99 | + $j('<span />').html(' ').appendTo($text); | |
100 | + | |
101 | + $j('<a />').attr('id', 'delete-old-componentes-curriculares') | |
102 | + .attr('href', '#') | |
103 | + .html('Limpar antigos componentes curriculares') | |
104 | + .attr('style', 'text-decoration:underline') | |
105 | + .bind('click', deleteOldComponentesCurriculares) | |
106 | + .appendTo($text); | |
107 | + | |
108 | + $j('<span />').html(' ').appendTo($text); | |
109 | + | |
110 | + $j('<a />').attr('id', 'clear-messages') | |
111 | + .attr('href', '#') | |
112 | + .html('Limpar mensagens') | |
113 | + .attr('style', 'text-decoration:underline') | |
114 | + .bind('click', function(){ | |
115 | + $j('#feedback-messages').children().remove(); | |
116 | + $j('#feedback-messages-success').children().remove(); | |
117 | + }) | |
118 | + .appendTo($text); | |
119 | + | |
120 | + $j('<td />').html($text).appendTo($j('<tr />').appendTo($resultTable)); | |
121 | +} | |
0 | 122 | \ No newline at end of file | ... | ... |
ieducar/modules/Avaliacao/Fixups/CleanComponentesCurriculares.php
0 → 100644
... | ... | @@ -0,0 +1,162 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
32 | + | |
33 | +/** | |
34 | + * CleanComponentesCurriculares class. | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package Portabilis | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | + | |
44 | +/* Ao desvincular componente curriculares, as notas, medias e faltas lançadas para estes continuam na base de dados | |
45 | + impedindo que o aluno seja promovido, caso todas notas ou faltas destes componentes não tenham sido lançadas. | |
46 | + para impedir isto, é removido as notas, medias e faltas lançadas para os componentes removidos. | |
47 | +*/ | |
48 | + | |
49 | +class CleanComponentesCurriculares { | |
50 | + | |
51 | + public static function destroyOldResources($anoEscolar) { | |
52 | + self::destroyOldNotas($anoEscolar); | |
53 | + self::destroyOldNotasMedias($anoEscolar); | |
54 | + self::destroyOldFaltas($anoEscolar); | |
55 | + } | |
56 | + | |
57 | + protected static function destroyOldNotas($anoEscolar) { | |
58 | + $sql = "delete from modules.nota_componente_curricular where id in ( | |
59 | + select ncc.id from modules.nota_componente_curricular as ncc, | |
60 | + modules.nota_aluno as na, | |
61 | + pmieducar.matricula as m, | |
62 | + pmieducar.matricula_turma as mt | |
63 | + | |
64 | + where ncc.nota_aluno_id = na.id and | |
65 | + m.cod_matricula = na.matricula_id and | |
66 | + m.cod_matricula = mt.ref_cod_matricula and | |
67 | + m.ativo = 1 and | |
68 | + mt.ativo = m.ativo and | |
69 | + m.ano = $1 and | |
70 | + --m.aprovado = 3 and | |
71 | + | |
72 | + CASE WHEN (select 1 from modules.componente_curricular_turma | |
73 | + WHERE componente_curricular_turma.turma_id = mt.ref_cod_turma AND | |
74 | + componente_curricular_turma.escola_id = m.ref_ref_cod_escola limit 1) = 1 THEN | |
75 | + | |
76 | + ncc.componente_curricular_id not in (select cct.componente_curricular_id from modules.componente_curricular_turma as cct where | |
77 | + cct.turma_id = mt.ref_cod_turma) | |
78 | + | |
79 | + | |
80 | + ELSE | |
81 | + ncc.componente_curricular_id not in (select ccs.ref_cod_disciplina from pmieducar.escola_serie_disciplina as ccs where | |
82 | + ccs.ref_ref_cod_serie = m.ref_ref_cod_serie and | |
83 | + ccs.ref_ref_cod_escola = m.ref_ref_cod_escola and ccs.ativo = 1) | |
84 | + END | |
85 | + );"; | |
86 | + | |
87 | + self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); | |
88 | + } | |
89 | + | |
90 | + protected static function destroyOldNotasMedias($anoEscolar) { | |
91 | + $sql = "delete from modules.nota_componente_curricular_media where nota_aluno_id||componente_curricular_id in ( | |
92 | + select nccm.nota_aluno_id|| nccm.componente_curricular_id from modules.nota_componente_curricular_media as nccm, | |
93 | + modules.nota_aluno as na, | |
94 | + pmieducar.matricula as m, | |
95 | + pmieducar.matricula_turma as mt | |
96 | + | |
97 | + where nccm.nota_aluno_id = na.id and | |
98 | + m.cod_matricula = na.matricula_id and | |
99 | + m.cod_matricula = mt.ref_cod_matricula and | |
100 | + m.ativo = 1 and | |
101 | + mt.ativo = m.ativo and | |
102 | + m.ano = $1 and | |
103 | + --m.aprovado = 3 and | |
104 | + | |
105 | + CASE WHEN (select 1 from modules.componente_curricular_turma | |
106 | + WHERE componente_curricular_turma.turma_id = mt.ref_cod_turma AND | |
107 | + componente_curricular_turma.escola_id = m.ref_ref_cod_escola limit 1) = 1 THEN | |
108 | + | |
109 | + nccm.componente_curricular_id not in (select cct.componente_curricular_id from modules.componente_curricular_turma as cct where | |
110 | + cct.turma_id = mt.ref_cod_turma) | |
111 | + | |
112 | + | |
113 | + ELSE | |
114 | + nccm.componente_curricular_id not in (select ccs.ref_cod_disciplina from pmieducar.escola_serie_disciplina as ccs where | |
115 | + ccs.ref_ref_cod_serie = m.ref_ref_cod_serie and | |
116 | + ccs.ref_ref_cod_escola = m.ref_ref_cod_escola and ccs.ativo = 1) | |
117 | + END | |
118 | + );"; | |
119 | + | |
120 | + self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); | |
121 | + } | |
122 | + | |
123 | + protected static function destroyOldFaltas($anoEscolar) { | |
124 | + $sql = "delete from modules.falta_componente_curricular where id in ( | |
125 | + select fcc.id from modules.falta_componente_curricular as fcc, | |
126 | + modules.falta_aluno as fa, | |
127 | + pmieducar.matricula as m, | |
128 | + pmieducar.matricula_turma as mt | |
129 | + | |
130 | + where fcc.falta_aluno_id = fa.id and | |
131 | + m.cod_matricula = fa.matricula_id and | |
132 | + m.cod_matricula = mt.ref_cod_matricula and | |
133 | + m.ativo = 1 and | |
134 | + mt.ativo = m.ativo and | |
135 | + m.ano = $1 and | |
136 | + --m.aprovado = 3 and | |
137 | + | |
138 | + CASE WHEN (select 1 from modules.componente_curricular_turma | |
139 | + WHERE componente_curricular_turma.turma_id = mt.ref_cod_turma AND | |
140 | + componente_curricular_turma.escola_id = m.ref_ref_cod_escola limit 1) = 1 THEN | |
141 | + | |
142 | + fcc.componente_curricular_id not in (select cct.componente_curricular_id from modules.componente_curricular_turma as cct where | |
143 | + cct.turma_id = mt.ref_cod_turma) | |
144 | + | |
145 | + ELSE | |
146 | + fcc.componente_curricular_id not in (select ccs.ref_cod_disciplina from pmieducar.escola_serie_disciplina as ccs where | |
147 | + ccs.ref_ref_cod_serie = m.ref_ref_cod_serie and | |
148 | + ccs.ref_ref_cod_escola = m.ref_ref_cod_escola and ccs.ativo = 1) | |
149 | + END | |
150 | + | |
151 | + );"; | |
152 | + self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); | |
153 | + } | |
154 | + | |
155 | + // wrappers for Portabilis*Utils* | |
156 | + | |
157 | + protected static function fetchPreparedQuery($sql, $options = array()) { | |
158 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
159 | + } | |
160 | + | |
161 | +} | |
162 | +?> | |
0 | 163 | \ No newline at end of file | ... | ... |