Commit b4b5131c73a92cb7d4044b12e19edd9453590698
1 parent
6555e8f7
Exists in
master
Adicionado modulo de processamento de histótico escolar, corrigido e melhorado c…
…adastro, listagem e detalhe de histórico escolar
Showing
9 changed files
with
2215 additions
and
62 deletions
Show diff stats
ieducar/intranet/educar_historico_escolar_cad.php
| ... | ... | @@ -30,6 +30,7 @@ require_once 'include/clsBase.inc.php'; |
| 30 | 30 | require_once 'include/clsCadastro.inc.php'; |
| 31 | 31 | require_once 'include/clsBanco.inc.php'; |
| 32 | 32 | require_once 'include/pmieducar/geral.inc.php'; |
| 33 | +require_once 'lib/Portabilis/View/Helper/Application.php'; | |
| 33 | 34 | |
| 34 | 35 | class clsIndexBase extends clsBase |
| 35 | 36 | { |
| ... | ... | @@ -73,7 +74,7 @@ class indice extends clsCadastro |
| 73 | 74 | |
| 74 | 75 | var $faltas_globalizadas; |
| 75 | 76 | var $cb_faltas_globalizadas; |
| 76 | - | |
| 77 | + var $frequencia; | |
| 77 | 78 | |
| 78 | 79 | //------INCLUI DISCIPLINA------// |
| 79 | 80 | var $historico_disciplinas; |
| ... | ... | @@ -83,6 +84,8 @@ class indice extends clsCadastro |
| 83 | 84 | var $excluir_disciplina; |
| 84 | 85 | var $ultimo_sequencial; |
| 85 | 86 | |
| 87 | + var $aceleracao; | |
| 88 | + | |
| 86 | 89 | function Inicializar() |
| 87 | 90 | { |
| 88 | 91 | $retorno = "Novo"; |
| ... | ... | @@ -102,7 +105,7 @@ class indice extends clsCadastro |
| 102 | 105 | $registro = $obj->detalhe(); |
| 103 | 106 | if( $registro ) |
| 104 | 107 | { |
| 105 | - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto | |
| 108 | + foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto | |
| 106 | 109 | $this->$campo = $val; |
| 107 | 110 | |
| 108 | 111 | if (!$this->origem) |
| ... | ... | @@ -152,7 +155,7 @@ class indice extends clsCadastro |
| 152 | 155 | { |
| 153 | 156 | $obj_instituicao = new clsPmieducarInstituicao(); |
| 154 | 157 | $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); |
| 155 | - $opcoes[""] = "Selecione"; | |
| 158 | + $opcoes["1"] = "Selecione"; | |
| 156 | 159 | if ( is_array( $lista ) && count( $lista ) ) |
| 157 | 160 | { |
| 158 | 161 | foreach ( $lista as $registro ) |
| ... | ... | @@ -181,8 +184,7 @@ class indice extends clsCadastro |
| 181 | 184 | $obj_uf = new clsUf($this->escola_uf); |
| 182 | 185 | $det_uf = $obj_uf->detalhe(); |
| 183 | 186 | } |
| 184 | - | |
| 185 | - $lista_pais_origem = array('NULL' => "País da escola"); | |
| 187 | + $lista_pais_origem = array('45' => "País da escola"); | |
| 186 | 188 | $obj_pais = new clsPais(); |
| 187 | 189 | $obj_pais_lista = $obj_pais->lista(null,null,null,"","","nome asc"); |
| 188 | 190 | if($obj_pais_lista) |
| ... | ... | @@ -192,11 +194,11 @@ class indice extends clsCadastro |
| 192 | 194 | $lista_pais_origem[$pais["idpais"]] = $pais["nome"]; |
| 193 | 195 | } |
| 194 | 196 | } |
| 195 | - $this->campoLista("idpais", "País da Escola", $lista_pais_origem, $det_uf['idpais'] ); | |
| 197 | + $this->campoLista("idpais", "País da Escola", $lista_pais_origem, $det_uf['45'] ); | |
| 196 | 198 | |
| 197 | 199 | $obj_uf = new clsUf(); |
| 198 | 200 | $lista_uf = $obj_uf->lista( false,false,$det_uf['idpais'],false,false, "sigla_uf" ); |
| 199 | - $lista_estado = array( "" => "Selecione um país" ); | |
| 201 | + $lista_estado = array( "SC" => "Selecione um país" ); | |
| 200 | 202 | if( $lista_uf ) |
| 201 | 203 | { |
| 202 | 204 | foreach ($lista_uf as $uf) |
| ... | ... | @@ -206,18 +208,31 @@ class indice extends clsCadastro |
| 206 | 208 | } |
| 207 | 209 | $this->campoLista("escola_uf", "Estado da Escola", $lista_estado, $this->escola_uf ); |
| 208 | 210 | |
| 211 | + $this->campoTexto( "nm_curso", "Curso", $this->nm_curso, 30, 255, false ); | |
| 212 | + | |
| 213 | + $opcoesGradeCurso = getOpcoesGradeCurso(); | |
| 214 | + $this->campoLista( "historico_grade_curso_id", "Grade curso", $opcoesGradeCurso, $this->historico_grade_curso_id ); | |
| 215 | + | |
| 216 | + | |
| 209 | 217 | $this->campoTexto( "nm_serie", "Série", $this->nm_serie, 30, 255, true ); |
| 210 | 218 | $this->campoNumero( "ano", "Ano", $this->ano, 4, 4, true ); |
| 211 | 219 | $this->campoMonetario( "carga_horaria", "Carga Horária", $this->carga_horaria, 8, 8, true ); |
| 212 | - $this->campoCheck( "cb_faltas_globalizadas", "Faltas Globalizadas", $this->faltas_globalizadas ); | |
| 220 | + $this->campoCheck( "cb_faltas_globalizadas", "Faltas Globalizadas", is_numeric($this->faltas_globalizadas) ? 'on' : ''); | |
| 213 | 221 | $this->campoNumero( "faltas_globalizadas", "Faltas Globalizadas", $this->faltas_globalizadas, 4, 4, false ); |
| 214 | 222 | $this->campoNumero( "dias_letivos", "Dias Letivos", $this->dias_letivos, 3, 3, true ); |
| 223 | + $this->campoMonetario( "frequencia", "Frequência", $this->frequencia, 8, 8, true ); | |
| 215 | 224 | $this->campoCheck( "extra_curricular", "Extra-Curricular", $this->extra_curricular ); |
| 225 | + $this->campoCheck( "aceleracao", "Aceleração", $this->aceleracao ); | |
| 216 | 226 | $this->campoMemo( "observacao", "Observação", $this->observacao, 60, 5, false ); |
| 217 | 227 | |
| 218 | 228 | $opcoes = array( "" => "Selecione", 1 => "Aprovado", 2 => "Reprovado", 3 => "Em Andamento", 4 => "Transferido" ); |
| 219 | 229 | $this->campoLista( "aprovado", "Situação", $opcoes, $this->aprovado ); |
| 220 | 230 | |
| 231 | + $this->campoTexto( "registro", "Registro (arquivo)", $this->registro, 30, 50, false); | |
| 232 | + $this->campoTexto( "livro", "Livro", $this->livro, 30, 50, false); | |
| 233 | + $this->campoTexto( "folha", "Folha", $this->folha, 30, 50, false); | |
| 234 | + | |
| 235 | + | |
| 221 | 236 | //---------------------INCLUI DISCIPLINAS---------------------// |
| 222 | 237 | $this->campoQuebra(); |
| 223 | 238 | |
| ... | ... | @@ -247,10 +262,12 @@ class indice extends clsCadastro |
| 247 | 262 | |
| 248 | 263 | $this->campoTabelaInicio("notas","Notas",array("Disciplina","Nota","Faltas"),$this->historico_disciplinas); |
| 249 | 264 | |
| 250 | - $this->campoTexto( "nm_disciplina", "Disciplina", $this->nm_disciplina, 30, 255, false ); | |
| 251 | - $this->campoTexto( "nota", "Nota", $this->nota, 10, 255, false ); | |
| 252 | - $this->campoNumero( "faltas", "Faltas", $this->faltas, 3, 3, false ); | |
| 253 | - //$this->campoOculto("sequencial",""); | |
| 265 | + //$this->campoTexto( "nm_disciplina", "Disciplina", $this->nm_disciplina, 30, 255, false, false, false, '', '', 'autoCompleteComponentesCurricular(this)', 'onfocus' ); | |
| 266 | + $this->campoTexto( "nm_disciplina", "Disciplina", $this->nm_disciplina, 30, 255, false, false, false, '', '', '', 'onfocus' ); | |
| 267 | + | |
| 268 | + $this->campoTexto( "nota", "Nota", $this->nota, 10, 255, false ); | |
| 269 | + $this->campoNumero( "faltas", "Faltas", $this->faltas, 3, 3, false ); | |
| 270 | + //$this->campoOculto("sequencial",""); | |
| 254 | 271 | |
| 255 | 272 | $this->campoTabelaFim(); |
| 256 | 273 | |
| ... | ... | @@ -258,6 +275,16 @@ class indice extends clsCadastro |
| 258 | 275 | |
| 259 | 276 | $this->campoQuebra(); |
| 260 | 277 | //---------------------FIM INCLUI DISCIPLINAS---------------------// |
| 278 | + | |
| 279 | + Portabilis_View_Helper_Application::loadJQueryLib($this); | |
| 280 | + Portabilis_View_Helper_Application::loadJQueryUiLib($this); | |
| 281 | + | |
| 282 | + Portabilis_View_Helper_Application::loadJavascript( | |
| 283 | + $this, | |
| 284 | + array('/modules/Portabilis/Assets/Javascripts/Utils.js', | |
| 285 | + '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js') | |
| 286 | + ); | |
| 287 | + | |
| 261 | 288 | } |
| 262 | 289 | |
| 263 | 290 | function Novo() |
| ... | ... | @@ -269,20 +296,22 @@ class indice extends clsCadastro |
| 269 | 296 | $obj_permissoes = new clsPermissoes(); |
| 270 | 297 | $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_historico_escolar_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); |
| 271 | 298 | |
| 272 | -/* $this->historico_disciplinas = unserialize( urldecode( $this->historico_disciplinas ) ); | |
| 299 | +/* $this->historico_disciplinas = unserialize( urldecode( $this->historico_disciplinas ) ); | |
| 273 | 300 | if ($this->historico_disciplinas) |
| 274 | 301 | { |
| 275 | 302 | */ |
| 276 | 303 | $this->carga_horaria = str_replace(".","",$this->carga_horaria); |
| 277 | 304 | $this->carga_horaria = str_replace(",",".",$this->carga_horaria); |
| 305 | + $this->frequencia = str_replace(".","",$this->frequencia); | |
| 306 | + $this->frequencia = str_replace(",",".",$this->frequencia); | |
| 278 | 307 | |
| 279 | 308 | if ($this->extra_curricular == 'on') |
| 280 | 309 | $this->extra_curricular = 1; |
| 281 | 310 | else |
| 282 | 311 | $this->extra_curricular = 0; |
| 283 | 312 | |
| 284 | -// echo "clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, null, null, $this->pessoa_logada, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, null, $this->ref_cod_instituicao, 1, $this->extra_curricular )"; | |
| 285 | - $obj = new clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, null, null, $this->pessoa_logada, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, $this->faltas_globalizadas, $this->ref_cod_instituicao, 1, $this->extra_curricular ); | |
| 313 | +// echo "clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, null, null, $this->pessoa_logada, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, null, $this->ref_cod_instituicao, 1, $this->extra_curricular )"; | |
| 314 | + $obj = new clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, null, null, $this->pessoa_logada, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, $this->faltas_globalizadas, $this->ref_cod_instituicao, 1, $this->extra_curricular, null, $this->frequencia, $this->registro, $this->livro, $this->folha, $this->nm_curso, $this->historico_grade_curso_id, $this->aceleracao); | |
| 286 | 315 | $cadastrou = $obj->cadastra(); |
| 287 | 316 | if( $cadastrou ) |
| 288 | 317 | { |
| ... | ... | @@ -317,7 +346,7 @@ class indice extends clsCadastro |
| 317 | 346 | $this->mensagem = "Cadastro não realizado.<br>"; |
| 318 | 347 | echo "<!--\nErro ao cadastrar clsPmieducarHistoricoEscolar\nvalores obrigatorios\nis_numeric( $this->ref_cod_aluno ) && is_numeric( $this->pessoa_logada ) && is_string( $this->nm_serie ) && is_numeric( $this->ano ) && is_numeric( $this->carga_horaria ) && is_numeric( $this->dias_letivos ) && is_string( $this->escola ) && is_string( $this->escola_cidade ) && is_string( $this->escola_uf ) && is_numeric( $this->aprovado ) && is_numeric( $this->ref_cod_instituicao ) && is_numeric( $this->extra_curricular )\n-->"; |
| 319 | 348 | return false; |
| 320 | -/* } | |
| 349 | +/* } | |
| 321 | 350 | echo "<script> alert('É necessário adicionar pelo menos 1 Disciplina!') </script>"; |
| 322 | 351 | $this->mensagem = "Cadastro não realizado.<br>"; |
| 323 | 352 | return false; |
| ... | ... | @@ -333,24 +362,28 @@ class indice extends clsCadastro |
| 333 | 362 | $obj_permissoes = new clsPermissoes(); |
| 334 | 363 | $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_historico_escolar_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); |
| 335 | 364 | |
| 336 | -/* $this->historico_disciplinas = unserialize( urldecode( $this->historico_disciplinas ) ); | |
| 365 | +/* $this->historico_disciplinas = unserialize( urldecode( $this->historico_disciplinas ) ); | |
| 337 | 366 | if ($this->historico_disciplinas) |
| 338 | 367 | { |
| 339 | 368 | */ |
| 340 | 369 | $this->carga_horaria = str_replace(".","",$this->carga_horaria); |
| 341 | 370 | $this->carga_horaria = str_replace(",",".",$this->carga_horaria); |
| 371 | + $this->frequencia = str_replace(".","",$this->frequencia); | |
| 372 | + $this->frequencia = str_replace(",",".",$this->frequencia); | |
| 342 | 373 | |
| 343 | 374 | if ($this->extra_curricular == 'on') |
| 344 | 375 | $this->extra_curricular = 1; |
| 345 | 376 | else |
| 346 | 377 | $this->extra_curricular = 0; |
| 347 | 378 | |
| 348 | - | |
| 349 | - if(!$this->cb_faltas_globalizadas) | |
| 379 | + if($this->cb_faltas_globalizadas != 'on') | |
| 350 | 380 | $this->faltas_globalizadas = 'NULL'; |
| 351 | 381 | |
| 352 | - $obj = new clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, $this->sequencial, $this->pessoa_logada, null, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, $this->faltas_globalizadas, $this->ref_cod_instituicao, 1, $this->extra_curricular ); | |
| 382 | + $this->aceleracao = is_null($this->aceleracao) ? 0 : 1; | |
| 383 | + | |
| 384 | + $obj = new clsPmieducarHistoricoEscolar( $this->ref_cod_aluno, $this->sequencial, $this->pessoa_logada, null, $this->nm_serie, $this->ano, $this->carga_horaria, $this->dias_letivos, $this->escola, $this->escola_cidade, $this->escola_uf, $this->observacao, $this->aprovado, null, null, 1, $this->faltas_globalizadas, $this->ref_cod_instituicao, 1, $this->extra_curricular, null, $this->frequencia, $this->registro, $this->livro, $this->folha, $this->nm_curso, $this->historico_grade_curso_id, $this->aceleracao); | |
| 353 | 385 | $editou = $obj->edita(); |
| 386 | + | |
| 354 | 387 | if( $editou ) |
| 355 | 388 | { |
| 356 | 389 | //--------------EDITA DISCIPLINAS--------------// |
| ... | ... | @@ -389,7 +422,7 @@ class indice extends clsCadastro |
| 389 | 422 | $this->mensagem = "Edição não realizada.<br>"; |
| 390 | 423 | echo "<!--\nErro ao editar clsPmieducarHistoricoEscolar\nvalores obrigatorios\nif( is_numeric( $this->ref_cod_aluno ) && is_numeric( $this->sequencial ) && is_numeric( $this->pessoa_logada ) )\n-->"; |
| 391 | 424 | return false; |
| 392 | -/* } | |
| 425 | +/* } | |
| 393 | 426 | echo "<script> alert('É necessário adicionar pelo menos 1 Disciplina!') </script>"; |
| 394 | 427 | $this->mensagem = "Edição não realizada.<br>"; |
| 395 | 428 | return false; |
| ... | ... | @@ -427,6 +460,22 @@ class indice extends clsCadastro |
| 427 | 460 | } |
| 428 | 461 | } |
| 429 | 462 | |
| 463 | + | |
| 464 | +function getOpcoesGradeCurso(){ | |
| 465 | + | |
| 466 | + $db = new clsBanco(); | |
| 467 | + $sql = "select * from pmieducar.historico_grade_curso where ativo = 1"; | |
| 468 | + $db->Consulta($sql); | |
| 469 | + | |
| 470 | + $opcoes = array("" => "Selecione"); | |
| 471 | + while ($db->ProximoRegistro()){ | |
| 472 | + $record = $db->Tupla(); | |
| 473 | + $opcoes[$record['id']] = $record['descricao_etapa']; | |
| 474 | + } | |
| 475 | + | |
| 476 | + return $opcoes; | |
| 477 | + } | |
| 478 | + | |
| 430 | 479 | // cria uma extensao da classe base |
| 431 | 480 | $pagina = new clsIndexBase(); |
| 432 | 481 | // cria o conteudo |
| ... | ... | @@ -435,54 +484,95 @@ $miolo = new indice(); |
| 435 | 484 | $pagina->addForm( $miolo ); |
| 436 | 485 | // gera o html |
| 437 | 486 | $pagina->MakeAll(); |
| 487 | + | |
| 438 | 488 | ?> |
| 439 | 489 | |
| 440 | 490 | <script type="text/javascript"> |
| 441 | - document.getElementById('cb_faltas_globalizadas').onclick = | |
| 442 | - function() | |
| 491 | + document.getElementById('cb_faltas_globalizadas').onclick =function() | |
| 443 | 492 | { |
| 444 | 493 | setVisibility('tr_faltas_globalizadas',this.checked); |
| 494 | + this.setAttribute('value', this.checked ? 'on' : ''); | |
| 445 | 495 | } |
| 446 | 496 | |
| 447 | 497 | document.getElementById('cb_faltas_globalizadas').onclick(); |
| 448 | 498 | |
| 449 | 499 | |
| 450 | 500 | |
| 451 | -document.getElementById('idpais').onchange = function() | |
| 452 | -{ | |
| 453 | - var campoPais = document.getElementById( 'idpais' ).value; | |
| 454 | - var campoEstado = document.getElementById( 'escola_uf' ); | |
| 501 | + document.getElementById('idpais').onchange = function() { | |
| 502 | + var campoPais = document.getElementById( 'idpais' ).value; | |
| 503 | + var campoEstado = document.getElementById( 'escola_uf' ); | |
| 455 | 504 | |
| 456 | - campoEstado.length = 1; | |
| 457 | - campoEstado.disabled = true; | |
| 458 | - campoEstado.options[0] = new Option( 'Carregando estados', '', false, false ); | |
| 505 | + campoEstado.length = 1; | |
| 506 | + campoEstado.disabled = true; | |
| 507 | + campoEstado.options[0] = new Option( 'Carregando estados', '', false, false ); | |
| 459 | 508 | |
| 460 | - var xml1 = new ajax(getEstado_XML); | |
| 461 | - strURL = "public_uf_xml.php?pais="+campoPais; | |
| 462 | - xml1.envia(strURL); | |
| 463 | -} | |
| 509 | + var xml1 = new ajax(getEstado_XML); | |
| 510 | + strURL = "public_uf_xml.php?pais="+campoPais; | |
| 511 | + xml1.envia(strURL); | |
| 512 | + } | |
| 464 | 513 | |
| 465 | -function getEstado_XML(xml) | |
| 466 | -{ | |
| 514 | + function getEstado_XML(xml) | |
| 515 | + { | |
| 467 | 516 | |
| 468 | 517 | |
| 469 | - var campoEstado = document.getElementById( 'escola_uf' ); | |
| 518 | + var campoEstado = document.getElementById( 'escola_uf' ); | |
| 470 | 519 | |
| 471 | 520 | |
| 472 | - var estados = xml.getElementsByTagName( "estado" ); | |
| 521 | + var estados = xml.getElementsByTagName( "estado" ); | |
| 473 | 522 | |
| 474 | - campoEstado.length = 1; | |
| 475 | - campoEstado.options[0] = new Option( 'Selecione um estado', '', false, false ); | |
| 476 | - for ( var j = 0; j < estados.length; j++ ) | |
| 477 | - { | |
| 523 | + campoEstado.length = 1; | |
| 524 | + campoEstado.options[0] = new Option( 'Selecione um estado', '', false, false ); | |
| 525 | + for ( var j = 0; j < estados.length; j++ ) | |
| 526 | + { | |
| 478 | 527 | |
| 479 | - campoEstado.options[campoEstado.options.length] = new Option( estados[j].firstChild.nodeValue, estados[j].getAttribute('sigla_uf'), false, false ); | |
| 528 | + campoEstado.options[campoEstado.options.length] = new Option( estados[j].firstChild.nodeValue, estados[j].getAttribute('sigla_uf'), false, false ); | |
| 480 | 529 | |
| 530 | + } | |
| 531 | + if ( campoEstado.length == 1 ) { | |
| 532 | + campoEstado.options[0] = new Option( 'País não possui estados', '', false, false ); | |
| 533 | + } | |
| 534 | + | |
| 535 | + campoEstado.disabled = false; | |
| 481 | 536 | } |
| 482 | - if ( campoEstado.length == 1 ) { | |
| 483 | - campoEstado.options[0] = new Option( 'País não possui estados', '', false, false ); | |
| 537 | + | |
| 538 | + | |
| 539 | + // autocomplete disciplina fields | |
| 540 | + | |
| 541 | + var handleSelect = function(event, ui){ | |
| 542 | + $j(event.target).val(ui.item.label); | |
| 543 | + return false; | |
| 544 | + }; | |
| 545 | + | |
| 546 | + var search = function(request, response) { | |
| 547 | + var searchPath = '/module/Api/ComponenteCurricular?oper=get&resource=componente_curricular-search'; | |
| 548 | + var params = { query : request.term }; | |
| 549 | + | |
| 550 | + $j.get(searchPath, params, function(dataResponse) { | |
| 551 | + simpleSearch.handleSearch(dataResponse, response); | |
| 552 | + }); | |
| 553 | + }; | |
| 554 | + | |
| 555 | + function setAutoComplete() { | |
| 556 | + $j.each($j('input[id^="nm_disciplina"]'), function(index, field) { | |
| 557 | + | |
| 558 | + $j(field).autocomplete({ | |
| 559 | + source : search, | |
| 560 | + select : handleSelect, | |
| 561 | + minLength : 1, | |
| 562 | + autoFocus : true | |
| 563 | + }); | |
| 564 | + | |
| 565 | + }); | |
| 484 | 566 | } |
| 485 | 567 | |
| 486 | - campoEstado.disabled = false; | |
| 487 | -} | |
| 488 | -</script> | |
| 489 | 568 | \ No newline at end of file |
| 569 | + setAutoComplete(); | |
| 570 | + | |
| 571 | + // bind event | |
| 572 | + | |
| 573 | + var $addDisciplinaButton = $j('#btn_add_tab_add_1'); | |
| 574 | + | |
| 575 | + $addDisciplinaButton.click(function(){ | |
| 576 | + setAutoComplete(); | |
| 577 | + }); | |
| 578 | + | |
| 579 | +</script> | ... | ... |
ieducar/intranet/educar_historico_escolar_det.php
| ... | ... | @@ -68,6 +68,7 @@ class indice extends clsDetalhe |
| 68 | 68 | var $origem; |
| 69 | 69 | var $extra_curricular; |
| 70 | 70 | var $ref_cod_matricula; |
| 71 | + var $frequencia; | |
| 71 | 72 | |
| 72 | 73 | function Gerar() |
| 73 | 74 | { |
| ... | ... | @@ -132,7 +133,7 @@ class indice extends clsDetalhe |
| 132 | 133 | } |
| 133 | 134 | if( $registro["nm_serie"] ) |
| 134 | 135 | { |
| 135 | - $this->addDetalhe( array( "Curso", "{$registro["nm_serie"]}") ); | |
| 136 | + $this->addDetalhe( array( "Série", "{$registro["nm_serie"]}") ); | |
| 136 | 137 | } |
| 137 | 138 | } |
| 138 | 139 | else |
| ... | ... | @@ -154,6 +155,12 @@ class indice extends clsDetalhe |
| 154 | 155 | $this->addDetalhe( array( "Série", "{$registro["nm_serie"]}") ); |
| 155 | 156 | } |
| 156 | 157 | } |
| 158 | + | |
| 159 | + if( $registro["nm_curso"] ) | |
| 160 | + { | |
| 161 | + $this->addDetalhe( array( "Curso", "{$registro["nm_curso"]}") ); | |
| 162 | + } | |
| 163 | + | |
| 157 | 164 | if( $registro["ano"] ) |
| 158 | 165 | { |
| 159 | 166 | $this->addDetalhe( array( "Ano", "{$registro["ano"]}") ); |
| ... | ... | @@ -164,10 +171,17 @@ class indice extends clsDetalhe |
| 164 | 171 | |
| 165 | 172 | $this->addDetalhe( array( "Carga Horária", "{$registro["carga_horaria"]}") ); |
| 166 | 173 | } |
| 174 | + | |
| 175 | + $this->addDetalhe( array( "Faltas globalizadas", is_numeric($registro["faltas_globalizadas"]) ? 'Sim' : 'Não')); | |
| 176 | + | |
| 167 | 177 | if( $registro["dias_letivos"] ) |
| 168 | 178 | { |
| 169 | 179 | $this->addDetalhe( array( "Dias Letivos", "{$registro["dias_letivos"]}") ); |
| 170 | 180 | } |
| 181 | + if( $registro["frequencia"] ) | |
| 182 | + { | |
| 183 | + $this->addDetalhe( array( "Frequência", "{$registro["frequencia"]}") ); | |
| 184 | + } | |
| 171 | 185 | if( $registro["extra_curricular"] ) |
| 172 | 186 | { |
| 173 | 187 | $this->addDetalhe( array( "Extra-Curricular", "Sim") ); |
| ... | ... | @@ -176,6 +190,15 @@ class indice extends clsDetalhe |
| 176 | 190 | { |
| 177 | 191 | $this->addDetalhe( array( "Extra-Curricular", "Não") ); |
| 178 | 192 | } |
| 193 | + | |
| 194 | + if( $registro["aceleracao"] ) | |
| 195 | + { | |
| 196 | + $this->addDetalhe( array( "Aceleração", "Sim") ); | |
| 197 | + } | |
| 198 | + else | |
| 199 | + { | |
| 200 | + $this->addDetalhe( array( "Aceleração", "Não") ); | |
| 201 | + } | |
| 179 | 202 | if( $registro["origem"] ) |
| 180 | 203 | { |
| 181 | 204 | $this->addDetalhe( array( "Origem", "Externo") ); |
| ... | ... | @@ -209,6 +232,21 @@ class indice extends clsDetalhe |
| 209 | 232 | $this->addDetalhe( array( "Situação", "{$registro["aprovado"]}") ); |
| 210 | 233 | } |
| 211 | 234 | |
| 235 | + if( $registro["registro"] ) | |
| 236 | + { | |
| 237 | + $this->addDetalhe( array( "Registro (arquivo)", "{$registro["registro"]}") ); | |
| 238 | + } | |
| 239 | + | |
| 240 | + if( $registro["livro"] ) | |
| 241 | + { | |
| 242 | + $this->addDetalhe( array( "Livro", "{$registro["livro"]}") ); | |
| 243 | + } | |
| 244 | + | |
| 245 | + if( $registro["folha"] ) | |
| 246 | + { | |
| 247 | + $this->addDetalhe( array( "Folha", "{$registro["folha"]}") ); | |
| 248 | + } | |
| 249 | + | |
| 212 | 250 | $obj = new clsPmieducarHistoricoDisciplinas(); |
| 213 | 251 | $obj->setOrderby("nm_disciplina ASC"); |
| 214 | 252 | $lst = $obj->lista( null,$this->ref_cod_aluno,$this->sequencial ); |
| ... | ... | @@ -240,9 +278,9 @@ class indice extends clsDetalhe |
| 240 | 278 | <td {$color} align='left'>{$valor["nm_disciplina"]}</td> |
| 241 | 279 | <td {$color} align='center'>{$valor["nota"]}</td>"; |
| 242 | 280 | |
| 243 | - if ($registro["faltas_globalizadas"] && !$prim_disciplina) | |
| 281 | + if (is_numeric($registro["faltas_globalizadas"]) && !$prim_disciplina) | |
| 244 | 282 | $tabela .= "<td rowspan='{$qtd_disciplinas}' {$color} align='center'>{$registro["faltas_globalizadas"]}</td>"; |
| 245 | - else if ( !$registro["faltas_globalizadas"] ) | |
| 283 | + else if ( !is_numeric($registro["faltas_globalizadas"]) ) | |
| 246 | 284 | $tabela .= "<td {$color} align='center'>{$valor["faltas"]}</td>"; |
| 247 | 285 | |
| 248 | 286 | $tabela .= "</tr>"; |
| ... | ... | @@ -280,4 +318,4 @@ $miolo = new indice(); |
| 280 | 318 | $pagina->addForm( $miolo ); |
| 281 | 319 | // gera o html |
| 282 | 320 | $pagina->MakeAll(); |
| 283 | -?> | |
| 284 | 321 | \ No newline at end of file |
| 322 | +?> | ... | ... |
ieducar/intranet/educar_historico_escolar_lst.php
| ... | ... | @@ -87,6 +87,7 @@ class indice extends clsListagem |
| 87 | 87 | var $ref_cod_instituicao; |
| 88 | 88 | var $ref_cod_escola; |
| 89 | 89 | var $extra_curricular; |
| 90 | + var $frequencia; | |
| 90 | 91 | |
| 91 | 92 | function Gerar() |
| 92 | 93 | { |
| ... | ... | @@ -128,10 +129,12 @@ class indice extends clsListagem |
| 128 | 129 | if (!$this->extra_curricular) |
| 129 | 130 | $lista_busca[] = "Escola"; |
| 130 | 131 | } |
| 132 | + $lista_busca = array_merge($lista_busca, array('Curso', 'Série', 'Registro', 'Livro', 'Folha')); | |
| 133 | + | |
| 131 | 134 | $this->addCabecalhos($lista_busca); |
| 132 | 135 | |
| 133 | 136 | $get_escola = true; |
| 134 | - | |
| 137 | + | |
| 135 | 138 | include("include/pmieducar/educar_campo_lista.php"); |
| 136 | 139 | |
| 137 | 140 | // outros Filtros |
| ... | ... | @@ -155,7 +158,7 @@ class indice extends clsListagem |
| 155 | 158 | $this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; |
| 156 | 159 | |
| 157 | 160 | $obj_historico_escolar = new clsPmieducarHistoricoEscolar(); |
| 158 | - $obj_historico_escolar->setOrderby( "ano ASC" ); | |
| 161 | + $obj_historico_escolar->setOrderby( "ano, sequencial ASC" ); | |
| 159 | 162 | $obj_historico_escolar->setLimite( $this->limite, $this->offset ); |
| 160 | 163 | |
| 161 | 164 | $lista = $obj_historico_escolar->lista( |
| ... | ... | @@ -180,7 +183,8 @@ class indice extends clsListagem |
| 180 | 183 | null, |
| 181 | 184 | $this->ref_cod_instituicao, |
| 182 | 185 | null, |
| 183 | - $this->extra_curricular | |
| 186 | + $this->extra_curricular, | |
| 187 | + null | |
| 184 | 188 | ); |
| 185 | 189 | |
| 186 | 190 | $total = $obj_historico_escolar->_total; |
| ... | ... | @@ -225,6 +229,13 @@ class indice extends clsListagem |
| 225 | 229 | if (!$this->extra_curricular) |
| 226 | 230 | $lista_busca[] = "<a href=\"educar_historico_escolar_det.php?ref_cod_aluno={$registro["ref_cod_aluno"]}&sequencial={$registro["sequencial"]}\">{$registro["escola"]}</a>"; |
| 227 | 231 | } |
| 232 | + | |
| 233 | + $lista_busca[] = $registro['nm_curso']; | |
| 234 | + $lista_busca[] = $registro['nm_serie']; | |
| 235 | + $lista_busca[] = $registro['registro']; | |
| 236 | + $lista_busca[] = $registro['livro']; | |
| 237 | + $lista_busca[] = $registro['folha']; | |
| 238 | + | |
| 228 | 239 | $this->addLinhas($lista_busca); |
| 229 | 240 | } |
| 230 | 241 | } |
| ... | ... | @@ -249,4 +260,4 @@ $miolo = new indice(); |
| 249 | 260 | $pagina->addForm( $miolo ); |
| 250 | 261 | // gera o html |
| 251 | 262 | $pagina->MakeAll(); |
| 252 | -?> | |
| 253 | 263 | \ No newline at end of file |
| 264 | +?> | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarHistoricoEscolar.inc.php
| ... | ... | @@ -50,6 +50,7 @@ class clsPmieducarHistoricoEscolar |
| 50 | 50 | var $data_exclusao; |
| 51 | 51 | var $ativo; |
| 52 | 52 | var $faltas_globalizadas; |
| 53 | + var $frequencia; | |
| 53 | 54 | |
| 54 | 55 | var $ref_cod_instituicao; |
| 55 | 56 | var $nm_serie; |
| ... | ... | @@ -121,13 +122,13 @@ class clsPmieducarHistoricoEscolar |
| 121 | 122 | * |
| 122 | 123 | * @return object |
| 123 | 124 | */ |
| 124 | - function clsPmieducarHistoricoEscolar( $ref_cod_aluno = null, $sequencial = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $nm_serie = null, $ano = null, $carga_horaria = null, $dias_letivos = null, $escola = null, $escola_cidade = null, $escola_uf = null, $observacao = null, $aprovado = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $faltas_globalizadas = null, $ref_cod_instituicao = null, $origem = null, $extra_curricular = null, $ref_cod_matricula = null ) | |
| 125 | + function clsPmieducarHistoricoEscolar( $ref_cod_aluno = null, $sequencial = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $nm_serie = null, $ano = null, $carga_horaria = null, $dias_letivos = null, $escola = null, $escola_cidade = null, $escola_uf = null, $observacao = null, $aprovado = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $faltas_globalizadas = null, $ref_cod_instituicao = null, $origem = null, $extra_curricular = null, $ref_cod_matricula = null, $frequencia = null, $registro = null, $livro = null, $folha = null, $nm_curso = null, $historico_grade_curso_id = null, $aceleracao = null ) | |
| 125 | 126 | { |
| 126 | 127 | $db = new clsBanco(); |
| 127 | 128 | $this->_schema = "pmieducar."; |
| 128 | 129 | $this->_tabela = "{$this->_schema}historico_escolar"; |
| 129 | 130 | |
| 130 | - $this->_campos_lista = $this->_todos_campos = "ref_cod_aluno, sequencial, ref_usuario_exc, ref_usuario_cad, ano, carga_horaria, dias_letivos, escola, escola_cidade, escola_uf, observacao, aprovado, data_cadastro, data_exclusao, ativo, faltas_globalizadas, ref_cod_instituicao, nm_serie, origem, extra_curricular, ref_cod_matricula"; | |
| 131 | + $this->_campos_lista = $this->_todos_campos = "ref_cod_aluno, sequencial, ref_usuario_exc, ref_usuario_cad, ano, carga_horaria, dias_letivos, escola, escola_cidade, escola_uf, observacao, aprovado, data_cadastro, data_exclusao, ativo, faltas_globalizadas, ref_cod_instituicao, nm_serie, origem, extra_curricular, ref_cod_matricula, frequencia, registro, livro, folha, nm_curso, historico_grade_curso_id, aceleracao"; | |
| 131 | 132 | |
| 132 | 133 | if( is_numeric( $ref_usuario_exc ) ) |
| 133 | 134 | { |
| ... | ... | @@ -334,7 +335,17 @@ class clsPmieducarHistoricoEscolar |
| 334 | 335 | { |
| 335 | 336 | $this->nm_serie = $nm_serie; |
| 336 | 337 | } |
| 338 | + if( is_numeric( $frequencia ) ) | |
| 339 | + { | |
| 340 | + $this->frequencia = $frequencia; | |
| 341 | + } | |
| 337 | 342 | |
| 343 | + $this->registro = $registro; | |
| 344 | + $this->livro = $livro; | |
| 345 | + $this->folha = $folha; | |
| 346 | + $this->nm_curso = $nm_curso; | |
| 347 | + $this->historico_grade_curso_id = $historico_grade_curso_id; | |
| 348 | + $this->aceleracao = $aceleracao; | |
| 338 | 349 | } |
| 339 | 350 | |
| 340 | 351 | /** |
| ... | ... | @@ -344,7 +355,7 @@ class clsPmieducarHistoricoEscolar |
| 344 | 355 | */ |
| 345 | 356 | function cadastra() |
| 346 | 357 | { |
| 347 | - if( is_numeric( $this->ref_cod_aluno ) && is_numeric( $this->ref_usuario_cad ) && is_string( $this->nm_serie ) && is_numeric( $this->ano ) && is_numeric( $this->carga_horaria ) && is_string( $this->escola ) && is_string( $this->escola_cidade ) && is_numeric( $this->aprovado ) && is_numeric( $this->ref_cod_instituicao ) ) | |
| 358 | + if( is_numeric( $this->ref_cod_aluno ) && is_numeric( $this->ref_usuario_cad ) && is_string( $this->nm_serie ) && is_numeric( $this->ano ) && is_numeric( $this->carga_horaria ) && is_string( $this->escola ) && is_string( $this->escola_cidade ) && is_numeric( $this->aprovado ) && is_numeric( $this->ref_cod_instituicao ) && is_numeric( $this->frequencia)) | |
| 348 | 359 | { |
| 349 | 360 | $db = new clsBanco(); |
| 350 | 361 | |
| ... | ... | @@ -448,6 +459,54 @@ class clsPmieducarHistoricoEscolar |
| 448 | 459 | $valores .= "{$gruda}'{$this->faltas_globalizadas}'"; |
| 449 | 460 | $gruda = ", "; |
| 450 | 461 | } |
| 462 | + if( is_numeric( $this->frequencia ) ) | |
| 463 | + { | |
| 464 | + $campos .= "{$gruda}frequencia"; | |
| 465 | + $valores .= "{$gruda}'{$this->frequencia}'"; | |
| 466 | + $gruda = ", "; | |
| 467 | + } | |
| 468 | + | |
| 469 | + if( is_string( $this->registro )) | |
| 470 | + { | |
| 471 | + $campos .= "{$gruda}registro"; | |
| 472 | + $valores .= "{$gruda}'{$this->registro}'"; | |
| 473 | + $gruda = ", "; | |
| 474 | + } | |
| 475 | + | |
| 476 | + if( is_string( $this->livro )) | |
| 477 | + { | |
| 478 | + $campos .= "{$gruda}livro"; | |
| 479 | + $valores .= "{$gruda}'{$this->livro}'"; | |
| 480 | + $gruda = ", "; | |
| 481 | + } | |
| 482 | + | |
| 483 | + if( is_string( $this->folha )) | |
| 484 | + { | |
| 485 | + $campos .= "{$gruda}folha"; | |
| 486 | + $valores .= "{$gruda}'{$this->folha}'"; | |
| 487 | + $gruda = ", "; | |
| 488 | + } | |
| 489 | + | |
| 490 | + if( is_string( $this->nm_curso )) | |
| 491 | + { | |
| 492 | + $campos .= "{$gruda}nm_curso"; | |
| 493 | + $valores .= "{$gruda}'{$this->nm_curso}'"; | |
| 494 | + $gruda = ", "; | |
| 495 | + } | |
| 496 | + | |
| 497 | + if( is_numeric( $this->historico_grade_curso_id )) | |
| 498 | + { | |
| 499 | + $campos .= "{$gruda}historico_grade_curso_id"; | |
| 500 | + $valores .= "{$gruda}'{$this->historico_grade_curso_id}'"; | |
| 501 | + $gruda = ", "; | |
| 502 | + } | |
| 503 | + | |
| 504 | + if (is_numeric($aceleracao)) { | |
| 505 | + $campos .= "{$gruda}aceleracao"; | |
| 506 | + $valores .= "{$gruda}'{$this->aceleracao}'"; | |
| 507 | + $gruda = ", "; | |
| 508 | + } | |
| 509 | + | |
| 451 | 510 | $campos .= "{$gruda}data_cadastro"; |
| 452 | 511 | $valores .= "{$gruda}NOW()"; |
| 453 | 512 | $gruda = ", "; |
| ... | ... | @@ -463,7 +522,6 @@ class clsPmieducarHistoricoEscolar |
| 463 | 522 | } |
| 464 | 523 | return false; |
| 465 | 524 | } |
| 466 | - | |
| 467 | 525 | /** |
| 468 | 526 | * Edita os dados de um registro |
| 469 | 527 | * |
| ... | ... | @@ -564,6 +622,11 @@ class clsPmieducarHistoricoEscolar |
| 564 | 622 | $set .= "{$gruda}ativo = '{$this->ativo}'"; |
| 565 | 623 | $gruda = ", "; |
| 566 | 624 | } |
| 625 | + if( is_numeric( $this->frequencia ) ) | |
| 626 | + { | |
| 627 | + $set .= "{$gruda}frequencia = '{$this->frequencia}'"; | |
| 628 | + $gruda = ", "; | |
| 629 | + } | |
| 567 | 630 | if( is_numeric( $this->faltas_globalizadas ) ) |
| 568 | 631 | { |
| 569 | 632 | $set .= "{$gruda}faltas_globalizadas = '{$this->faltas_globalizadas}'"; |
| ... | ... | @@ -575,6 +638,42 @@ class clsPmieducarHistoricoEscolar |
| 575 | 638 | $gruda = ", "; |
| 576 | 639 | } |
| 577 | 640 | |
| 641 | + if( is_string( $this->registro)) | |
| 642 | + { | |
| 643 | + $set .= "{$gruda}registro = '{$this->registro}'"; | |
| 644 | + $gruda = ", "; | |
| 645 | + } | |
| 646 | + | |
| 647 | + if( is_string( $this->livro)) | |
| 648 | + { | |
| 649 | + $set .= "{$gruda}livro = '{$this->livro}'"; | |
| 650 | + $gruda = ", "; | |
| 651 | + } | |
| 652 | + | |
| 653 | + if( is_string( $this->folha)) | |
| 654 | + { | |
| 655 | + $set .= "{$gruda}folha = '{$this->folha}'"; | |
| 656 | + $gruda = ", "; | |
| 657 | + } | |
| 658 | + | |
| 659 | + if( is_string( $this->nm_curso)) | |
| 660 | + { | |
| 661 | + $set .= "{$gruda}nm_curso = '{$this->nm_curso}'"; | |
| 662 | + $gruda = ", "; | |
| 663 | + } | |
| 664 | + | |
| 665 | + if( is_numeric( $this->historico_grade_curso_id)) | |
| 666 | + { | |
| 667 | + $set .= "{$gruda}historico_grade_curso_id = '{$this->historico_grade_curso_id}'"; | |
| 668 | + $gruda = ", "; | |
| 669 | + } | |
| 670 | + | |
| 671 | + if( is_numeric( $this->aceleracao)) | |
| 672 | + { | |
| 673 | + $set .= "{$gruda}aceleracao = '{$this->aceleracao}'"; | |
| 674 | + $gruda = ", "; | |
| 675 | + } | |
| 676 | + | |
| 578 | 677 | if( $set ) |
| 579 | 678 | { |
| 580 | 679 | $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE ref_cod_aluno = '{$this->ref_cod_aluno}' AND sequencial = '{$this->sequencial}'" ); |
| ... | ... | @@ -589,7 +688,7 @@ class clsPmieducarHistoricoEscolar |
| 589 | 688 | * |
| 590 | 689 | * @return array |
| 591 | 690 | */ |
| 592 | - function lista( $int_ref_cod_aluno = null, $int_sequencial = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $str_nm_serie = null, $int_ano = null, $int_carga_horaria = null, $int_dias_letivos = null, $str_escola = null, $str_escola_cidade = null, $str_escola_uf = null, $str_observacao = null, $int_aprovado = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_faltas_globalizadas = null, $int_ref_cod_instituicao = null, $int_origem = null, $int_extra_curricular = null, $int_ref_cod_matricula = null ) | |
| 691 | + function lista( $int_ref_cod_aluno = null, $int_sequencial = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $str_nm_serie = null, $int_ano = null, $int_carga_horaria = null, $int_dias_letivos = null, $str_escola = null, $str_escola_cidade = null, $str_escola_uf = null, $str_observacao = null, $int_aprovado = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_faltas_globalizadas = null, $int_ref_cod_instituicao = null, $int_origem = null, $int_extra_curricular = null, $int_ref_cod_matricula = null, $int_frequencia = null ) | |
| 593 | 692 | { |
| 594 | 693 | $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; |
| 595 | 694 | $filtros = ""; |
| ... | ... | @@ -719,6 +818,11 @@ class clsPmieducarHistoricoEscolar |
| 719 | 818 | $filtros .= "{$whereAnd} faltas_globalizadas = '{$int_faltas_globalizadas}'"; |
| 720 | 819 | $whereAnd = " AND "; |
| 721 | 820 | } |
| 821 | + if( is_numeric( $int_frequencia ) ) | |
| 822 | + { | |
| 823 | + $filtros .= "{$whereAnd} frequencia = '{$int_frequencia}'"; | |
| 824 | + $whereAnd = " AND "; | |
| 825 | + } | |
| 722 | 826 | |
| 723 | 827 | $db = new clsBanco(); |
| 724 | 828 | $countCampos = count( explode( ",", $this->_campos_lista ) ); |
| ... | ... | @@ -908,4 +1012,4 @@ class clsPmieducarHistoricoEscolar |
| 908 | 1012 | } |
| 909 | 1013 | |
| 910 | 1014 | } |
| 911 | -?> | |
| 912 | 1015 | \ No newline at end of file |
| 1016 | +?> | ... | ... |
2.58 KB
ieducar/modules/HistoricoEscolar/Static/scripts/processamento.js
0 → 100644
| ... | ... | @@ -0,0 +1,647 @@ |
| 1 | +(function($){ | |
| 2 | + | |
| 3 | + $(function(){ | |
| 4 | + var $formFilter = $('#formcadastro'); | |
| 5 | + var $submitButton = $('#botao_busca'); | |
| 6 | + var $resultTable = $('#form_resultado .tablelistagem').addClass('horizontal-expand'); | |
| 7 | + $resultTable.children().remove(); | |
| 8 | + | |
| 9 | + $('<div />').attr('id', 'first-bar-action') | |
| 10 | + .attr('class', 'bar-action hide-on-search') | |
| 11 | + .prependTo($resultTable.parent()); | |
| 12 | + | |
| 13 | + $('<div />').attr('id', 'second-bar-action') | |
| 14 | + .attr('class', 'bar-action hide-on-search') | |
| 15 | + .appendTo($resultTable.parent()); | |
| 16 | + | |
| 17 | + var $barActions = $('.bar-action').hide(); | |
| 18 | + | |
| 19 | + $('<input class="selecionar disable-on-apply-changes" type="button" value="Selecionar todos" />').appendTo($barActions); | |
| 20 | + var $selectAllButton = $barActions.find('input.selecionar'); | |
| 21 | + | |
| 22 | + $('<input class="processar disable-on-apply-changes" type="button" value="Processar" />').appendTo($barActions); | |
| 23 | + var $actionButton = $barActions.find('input.processar'); | |
| 24 | + | |
| 25 | + $('<input class="destroy disable-on-apply-changes" type="button" value="Remover" />').appendTo($barActions); | |
| 26 | + var $destroyButton = $barActions.find('input.destroy'); | |
| 27 | + | |
| 28 | + var PageUrlBase = 'processamento'; | |
| 29 | + var ApiUrlBase = 'processamentoApi'; | |
| 30 | + | |
| 31 | + var $resourceOptionsTable = $('#resource-options'); | |
| 32 | + $resourceOptionsTable.find('tr:even').addClass('even'); | |
| 33 | + $resourceOptionsTable.hide().prependTo($formFilter.parent()); | |
| 34 | + | |
| 35 | + var $disciplinasManualTable = $('#disciplinas-manual'); | |
| 36 | + $('#new-disciplina-line').click(function(){ | |
| 37 | + var $lastDisplinaRow = $disciplinasManualTable.find('tr.disciplina:last'); | |
| 38 | + var $newRow = $lastDisplinaRow.clone().removeClass('notice').insertAfter($lastDisplinaRow); | |
| 39 | + var $fieldNome = $newRow.find('input.nome'); | |
| 40 | + resetAutoCompleteNomeDisciplinaEvent($fieldNome.val('')); | |
| 41 | + $fieldNome.focus(); | |
| 42 | + setRemoveDisciplinaLineEvent($newRow.find('.remove-disciplina-line')); | |
| 43 | + }); | |
| 44 | + | |
| 45 | + function resetAutoCompleteNomeDisciplinaEvent($element){ | |
| 46 | + var handleSelect = function(event, ui){ | |
| 47 | + $j(event.target).val(ui.item.label); | |
| 48 | + return false; | |
| 49 | + }; | |
| 50 | + | |
| 51 | + var search = function(request, response) { | |
| 52 | + var searchPath = '/module/Api/ComponenteCurricular?oper=get&resource=componente_curricular-search'; | |
| 53 | + var params = { query : request.term }; | |
| 54 | + | |
| 55 | + $j.get(searchPath, params, function(dataResponse) { | |
| 56 | + simpleSearch.handleSearch(dataResponse, response); | |
| 57 | + }); | |
| 58 | + }; | |
| 59 | + | |
| 60 | + $element.autocomplete({ | |
| 61 | + source : search, | |
| 62 | + select : handleSelect, | |
| 63 | + minLength : 1, | |
| 64 | + autoFocus : true | |
| 65 | + }); | |
| 66 | + } | |
| 67 | + | |
| 68 | + function setRemoveDisciplinaLineEvent($targetElement){ | |
| 69 | + $targetElement.click(function(event){ | |
| 70 | + event.preventDefault(); | |
| 71 | + if($disciplinasManualTable.find('tr.disciplina').length > 1) | |
| 72 | + $(this).closest('tr').remove(); | |
| 73 | + else | |
| 74 | + handleMessages([{type : 'notice', msg : 'Não é possivel remover a primeira linha.'}], $(this).closest('tr')); | |
| 75 | + }); | |
| 76 | + } | |
| 77 | + setRemoveDisciplinaLineEvent($('.remove-disciplina-line')); | |
| 78 | + | |
| 79 | + var $notasField = $resourceOptionsTable.find('#notas'); | |
| 80 | + $notasField.change(function(){ | |
| 81 | + var $targetElementId = '#notas-manual'; | |
| 82 | + | |
| 83 | + if ($notasField.val() == 'informar-manualmente') | |
| 84 | + $($targetElementId).show().removeAttr('disabled'); | |
| 85 | + else if($notasField.val() == 'AP') | |
| 86 | + $($targetElementId).show().removeAttr('disabled').val('AP'); | |
| 87 | + else | |
| 88 | + $($targetElementId).hide().attr('disabled', 'disabled'); | |
| 89 | + }); | |
| 90 | + | |
| 91 | + var changeStateFieldManual = function($containerElementId, $targetElementId){ | |
| 92 | + $targetElement = $($targetElementId); | |
| 93 | + | |
| 94 | + if ($($containerElementId).val() == 'informar-manualmente'){ | |
| 95 | + $targetElement.show().removeAttr('disabled').find('.change-state-with-parent').show().removeAttr('disabled'); | |
| 96 | + } | |
| 97 | + else{ | |
| 98 | + $targetElement.hide().attr('disabled', 'disabled').find('.change-state-with-parent').hide().attr('disabled', 'disabled'); | |
| 99 | + } | |
| 100 | + }; | |
| 101 | + | |
| 102 | + $resourceOptionsTable.find('#percentual-frequencia').change(function(){ | |
| 103 | + changeStateFieldManual('#percentual-frequencia', '#percentual-frequencia-manual'); | |
| 104 | + }); | |
| 105 | + | |
| 106 | + $resourceOptionsTable.find('#faltas').change(function(){ | |
| 107 | + changeStateFieldManual('#faltas', '#faltas-manual'); | |
| 108 | + }); | |
| 109 | + | |
| 110 | + $resourceOptionsTable.find('#disciplinas').change(function(){ | |
| 111 | + changeStateFieldManual('#disciplinas', '#disciplinas-manual'); | |
| 112 | + | |
| 113 | + /*chama .change para respectivos elementos esconderem / mostrar os campos que | |
| 114 | + dependam deles*/ | |
| 115 | + if ($(this).val() == 'informar-manualmente'){ | |
| 116 | + $('.disable-and-hide-wen-disciplinas-manual').hide().attr('disabled', 'disabled').change(); | |
| 117 | + $('#disciplinas-manual').find('input.nome').focus(); | |
| 118 | + } | |
| 119 | + else | |
| 120 | + $('.disable-and-hide-wen-disciplinas-manual').show().removeAttr('disabled').change(); | |
| 121 | + | |
| 122 | + }); | |
| 123 | + | |
| 124 | + $('.disable-on-search').attr('disabled', 'disabled'); | |
| 125 | + $('.hide-on-search').hide(); | |
| 126 | + | |
| 127 | + $('#ref_cod_curso').change(function(){ | |
| 128 | + $('.clear-on-change-curso').val(''); | |
| 129 | + }); | |
| 130 | + | |
| 131 | + var $navActions = $('<p />').attr('id', 'nav-actions'); | |
| 132 | + $navActions.prependTo($formFilter.parent()); | |
| 133 | + | |
| 134 | + var $tableSearchDetails = $('<table />') | |
| 135 | + .attr('id', 'search-details') | |
| 136 | + .addClass('styled') | |
| 137 | + .addClass('horizontal-expand') | |
| 138 | + .addClass('center') | |
| 139 | + .hide() | |
| 140 | + .prependTo($formFilter.parent()); | |
| 141 | + | |
| 142 | + var $feedbackMessages = $('<div />').attr('id', 'feedback-messages').appendTo($formFilter.parent()); | |
| 143 | + | |
| 144 | + var $additionalFields = $j('#resource-options select, #resource-options input[type="text"]'); | |
| 145 | + fixupFieldsWidth($additionalFields); | |
| 146 | + | |
| 147 | + //url builders | |
| 148 | + var resourceUrlBuilder = { | |
| 149 | + buildUrl : function(urlBase, vars){ | |
| 150 | + | |
| 151 | + _vars = ''; | |
| 152 | + for(varName in vars){ | |
| 153 | + _vars += '&'+varName+'='+vars[varName]; | |
| 154 | + } | |
| 155 | + return urlBase + '?' + _vars; | |
| 156 | + } | |
| 157 | + }; | |
| 158 | + | |
| 159 | + | |
| 160 | + var deleteResourceUrlBuilder = { | |
| 161 | + buildUrl : function(urlBase, resourceName, additionalVars){ | |
| 162 | + | |
| 163 | + var vars = { | |
| 164 | + att : resourceName, | |
| 165 | + oper : 'delete', | |
| 166 | + instituicao_id : $('#ref_cod_instituicao').val(), | |
| 167 | + matricula_id : '' | |
| 168 | + }; | |
| 169 | + | |
| 170 | + return resourceUrlBuilder.buildUrl(urlBase, $.extend(vars, additionalVars)); | |
| 171 | + } | |
| 172 | + }; | |
| 173 | + | |
| 174 | + | |
| 175 | + var postResourceUrlBuilder = { | |
| 176 | + buildUrl : function(urlBase, resourceName, additionalVars){ | |
| 177 | + | |
| 178 | + var vars = { | |
| 179 | + att : resourceName, | |
| 180 | + oper : 'post', | |
| 181 | + instituicao_id : $('#ref_cod_instituicao').val(), | |
| 182 | + matricula_id : '' | |
| 183 | + }; | |
| 184 | + | |
| 185 | + return resourceUrlBuilder.buildUrl(urlBase, $.extend(vars, additionalVars)); | |
| 186 | + } | |
| 187 | + }; | |
| 188 | + | |
| 189 | + | |
| 190 | + var getResourceUrlBuilder = { | |
| 191 | + buildUrl : function(urlBase, resourceName, additionalVars){ | |
| 192 | + | |
| 193 | + var vars = { | |
| 194 | + att : resourceName, | |
| 195 | + oper : 'get', | |
| 196 | + instituicao_id : $('#ref_cod_instituicao').val(), | |
| 197 | + escola_id : $('#ref_cod_escola').val(), | |
| 198 | + curso_id : $('#ref_cod_curso').val(), | |
| 199 | + serie_id : $('#ref_cod_serie').val(), | |
| 200 | + turma_id : $('#ref_cod_turma').val(), | |
| 201 | + ano : $('#ano').val(), | |
| 202 | + etapa : $('#etapa').val() | |
| 203 | + }; | |
| 204 | + | |
| 205 | + return resourceUrlBuilder.buildUrl(urlBase, $.extend(vars, additionalVars)); | |
| 206 | + | |
| 207 | + } | |
| 208 | + }; | |
| 209 | + | |
| 210 | + | |
| 211 | + function changeResource($resourceElement, postFunction, deleteFunction){ | |
| 212 | + if ($.trim($resourceElement.val()) == '') | |
| 213 | + deleteFunction($resourceElement); | |
| 214 | + else | |
| 215 | + postFunction($resourceElement); | |
| 216 | + }; | |
| 217 | + | |
| 218 | + var changeResourceName = function(event){ | |
| 219 | + changeResource($(this), postFalta, deleteFalta); | |
| 220 | + }; | |
| 221 | + | |
| 222 | + | |
| 223 | + function postResource(options, errorCallback){ | |
| 224 | + $.ajax(options).error(errorCallback); | |
| 225 | + } | |
| 226 | + | |
| 227 | + | |
| 228 | + function updateFieldSituacao(linkToHistorico, matricula_id, situacao){ | |
| 229 | + if(situacao){ | |
| 230 | + var $fieldSituacao = $('#situacao-matricula-' + matricula_id); | |
| 231 | + var situacaoHistorico = safeUtf8Decode(situacao); | |
| 232 | + | |
| 233 | + $fieldSituacao.html(getLinkToHistorico(linkToHistorico, situacaoHistorico)); | |
| 234 | + $fieldSituacao.data('situacao_historico', situacaoHistorico); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + | |
| 239 | + //callback handlers | |
| 240 | + | |
| 241 | + //delete | |
| 242 | + function handleDelete(dataResponse){ | |
| 243 | + try{ | |
| 244 | + var $checkbox = $('matricula-' + dataResponse.matricula_id); | |
| 245 | + var $targetElement = $j('#matricula-'+dataResponse.matricula_id).closest('tr').first(); | |
| 246 | + handleMessages(dataResponse.msgs, $targetElement); | |
| 247 | + updateFieldSituacao(dataResponse.link_to_historico, dataResponse.matricula_id, dataResponse.situacao_historico); | |
| 248 | + } | |
| 249 | + catch(error){ | |
| 250 | + showNewSearchButton(); | |
| 251 | + handleMessages([{type : 'error', msg : 'Ocorreu um erro ao remover o recurso, por favor tente novamente, detalhes: ' + error}], ''); | |
| 252 | + | |
| 253 | + safeLog(dataResponse); | |
| 254 | + } | |
| 255 | + } | |
| 256 | + | |
| 257 | + | |
| 258 | + function handleErrorDeleteResource(response){ | |
| 259 | + handleMessages([{type : 'error', msg : 'Erro ao alterar recurso, detalhes:' + response.responseText}], ''); | |
| 260 | + safeLog(response); | |
| 261 | + } | |
| 262 | + | |
| 263 | + function handleErrorPost(response){ | |
| 264 | + handleMessages([{type : 'error', msg : 'Erro ao alterar recurso, detalhes:' + response.responseText}], ''); | |
| 265 | + safeLog(response); | |
| 266 | + } | |
| 267 | + | |
| 268 | + | |
| 269 | + function setTableSearchDetails(dataDetails){ | |
| 270 | + $('<caption />').html(safeUtf8Decode('<strong>Processamento dos históricos</strong>')).appendTo($tableSearchDetails); | |
| 271 | + | |
| 272 | + //set headers table | |
| 273 | + var $linha = $('<tr />'); | |
| 274 | + $('<th />').html('Ano').appendTo($linha); | |
| 275 | + $('<th />').html('Escola').appendTo($linha); | |
| 276 | + $('<th />').html('Curso').appendTo($linha); | |
| 277 | + $('<th />').html('Serie').appendTo($linha); | |
| 278 | + $('<th />').html('Turma').appendTo($linha); | |
| 279 | + $('<th />').html('Matricula').appendTo($linha); | |
| 280 | + | |
| 281 | + $linha.appendTo($tableSearchDetails); | |
| 282 | + | |
| 283 | + var $linha = $('<tr />').addClass('even'); | |
| 284 | + | |
| 285 | + $('<td />').html($('#ano').val()).appendTo($linha); | |
| 286 | + | |
| 287 | + //field escola pode ser diferente de select caso usuario comum | |
| 288 | + var $htmlEscolaField = $('#ref_cod_escola').children("[selected='selected']").html() || | |
| 289 | + $j('#tr_nm_escola span:last').html(); | |
| 290 | + $('<td />').html(safeToUpperCase($htmlEscolaField)).appendTo($linha); | |
| 291 | + | |
| 292 | + $('<td />').html(safeToUpperCase($('#ref_cod_curso').children("[value!=''][selected='selected']").html() || 'Todos')).appendTo($linha); | |
| 293 | + $('<td />').html(safeToUpperCase($('#ref_cod_serie').children("[value!=''][selected='selected']").html() || 'Todas')).appendTo($linha); | |
| 294 | + $('<td />').html(safeToUpperCase($('#ref_cod_turma').children("[value!=''][selected='selected']").html() || 'Todas')).appendTo($linha); | |
| 295 | + $('<td />').html(safeToUpperCase($('#ref_cod_matricula').children("[value!=''][selected='selected']").html() || 'Todas')).appendTo($linha); | |
| 296 | + | |
| 297 | + $linha.appendTo($tableSearchDetails); | |
| 298 | + $tableSearchDetails.show(); | |
| 299 | + | |
| 300 | + $tableSearchDetails.data('details', dataDetails); | |
| 301 | + } | |
| 302 | + | |
| 303 | + //exibe formulário nova consulta | |
| 304 | + function showSearchForm(event){ | |
| 305 | + $navActions.html(''); | |
| 306 | + $tableSearchDetails.children().remove(); | |
| 307 | + $resultTable.children().fadeOut('fast').remove(); | |
| 308 | + $formFilter.fadeIn('fast', function(){ | |
| 309 | + $(this).show() | |
| 310 | + }); | |
| 311 | + $('.disable-on-search').attr('disabled', 'disabled'); | |
| 312 | + $('.hide-on-search').hide(); | |
| 313 | + $('.disable-on-apply-changes').removeAttr('disabled'); | |
| 314 | + $actionButton.val('Processar'); | |
| 315 | + } | |
| 316 | + | |
| 317 | + | |
| 318 | + function showNewSearchButton(){ | |
| 319 | + $navActions.html( | |
| 320 | + $("<a href='#'>Nova consulta</a>") | |
| 321 | + .bind('click', showSearchForm) | |
| 322 | + .attr('style', 'text-decoration: underline') | |
| 323 | + ); | |
| 324 | + $('.disable-on-search').removeAttr('disabled'); | |
| 325 | + $('.hide-on-search').show(); | |
| 326 | + } | |
| 327 | + | |
| 328 | + function getLinkToHistorico(link, text){ | |
| 329 | + if (link) | |
| 330 | + return $('<a target="__blank" style="text-decoration:underline;" href='+link+'>'+text+'</a>'); | |
| 331 | + else | |
| 332 | + return text; | |
| 333 | + } | |
| 334 | + | |
| 335 | + | |
| 336 | + function handleMatriculasSearch(dataResponse){ | |
| 337 | + | |
| 338 | + showNewSearchButton(); | |
| 339 | + | |
| 340 | + try{ | |
| 341 | + handleMessages(dataResponse.msgs); | |
| 342 | + | |
| 343 | + if(! $.isArray(dataResponse.matriculas)) | |
| 344 | + { | |
| 345 | + $('<td />') | |
| 346 | + .html('As matriculas não poderam ser recuperadas, verifique as mensagens de erro ou tente <a alt="Recarregar página" href="/" style="text-decoration:underline">recarregar</a>.') | |
| 347 | + .addClass('center') | |
| 348 | + .appendTo($('<tr />').appendTo($resultTable)); | |
| 349 | + } | |
| 350 | + else if (dataResponse.matriculas.length < 1) | |
| 351 | + { | |
| 352 | + $('<td />') | |
| 353 | + .html('Sem matriculas em andamento nesta turma.') | |
| 354 | + .addClass('center') | |
| 355 | + .appendTo($('<tr />').appendTo($resultTable)); | |
| 356 | + } | |
| 357 | + else | |
| 358 | + { | |
| 359 | + setTableSearchDetails(); | |
| 360 | + //set headers | |
| 361 | + var $linha = $('<tr />'); | |
| 362 | + $('<th />').html('Selecionar').appendTo($linha); | |
| 363 | + $('<th />').html('Curso').appendTo($linha); | |
| 364 | + $('<th />').html(safeUtf8Decode('Série')).appendTo($linha); | |
| 365 | + $('<th />').html('Turma').appendTo($linha); | |
| 366 | + $('<th />').html('Matricula').appendTo($linha); | |
| 367 | + $('<th />').html('Aluno').appendTo($linha); | |
| 368 | + $('<th />').html('Situação').appendTo($linha); | |
| 369 | + $linha.appendTo($resultTable); | |
| 370 | + | |
| 371 | + //set rows | |
| 372 | + $.each(dataResponse.matriculas, function(index, value){ | |
| 373 | + | |
| 374 | + var $checkbox = $('<input />') | |
| 375 | + .attr('type', 'checkbox') | |
| 376 | + .attr('name', 'processar-matricula') | |
| 377 | + .attr('value', 'sim') | |
| 378 | + .attr('id', 'matricula-' + value.matricula_id) | |
| 379 | + .attr('class', 'matricula disable-on-apply-changes') | |
| 380 | + .data('matricula_id', value.matricula_id); | |
| 381 | + | |
| 382 | + var $linha = $('<tr />'); | |
| 383 | + $('<td />').html($checkbox).addClass('center').appendTo($linha); | |
| 384 | + $('<td />').html(value.nome_curso).addClass('center').appendTo($linha); | |
| 385 | + $('<td />').html(safeUtf8Decode(value.nome_serie)).addClass('center').appendTo($linha); | |
| 386 | + $('<td />').html(safeUtf8Decode(value.nome_turma)).addClass('center').appendTo($linha); | |
| 387 | + $('<td />').html(value.matricula_id).addClass('center').appendTo($linha); | |
| 388 | + $('<td />').html(value.aluno_id + " - " + safeToUpperCase(value.nome)).appendTo($linha); | |
| 389 | + | |
| 390 | + var situacaoHistorico = safeUtf8Decode(value.situacao_historico); | |
| 391 | + var $htmlSituacao = getLinkToHistorico(value.link_to_historico, situacaoHistorico); | |
| 392 | + $('<td />').html($htmlSituacao).data('situacao_historico', situacaoHistorico).attr('id', 'situacao-matricula-' + value.matricula_id).addClass('situacao').addClass('center').appendTo($linha); | |
| 393 | + | |
| 394 | + $linha.fadeIn('slow').appendTo($resultTable); | |
| 395 | + });//fim each matriculas | |
| 396 | + | |
| 397 | + $resultTable.find('tr:even').addClass('even'); | |
| 398 | + $resultTable.addClass('styled').find('checkbox:first').focus(); | |
| 399 | + | |
| 400 | + var $observacaoField = $('#observacao'); | |
| 401 | + if($.trim($observacaoField.val()) == '' || ($observacaoField.val() == $observacaoField.data('old_value'))){ | |
| 402 | + $observacaoField.val(dataResponse.observacao_padrao); | |
| 403 | + $observacaoField.data('old_value', dataResponse.observacao_padrao); | |
| 404 | + } | |
| 405 | + } | |
| 406 | + } | |
| 407 | + catch(error){ | |
| 408 | + showNewSearchButton(); | |
| 409 | + | |
| 410 | + handleMessages([{type : 'error', msg : 'Ocorreu um erro ao exibir as matriculas, por favor tente novamente, detalhes: ' + error}], ''); | |
| 411 | + | |
| 412 | + safeLog(dataResponse); | |
| 413 | + } | |
| 414 | + } | |
| 415 | + | |
| 416 | + function handleErrorMatriculasSearch(response){ | |
| 417 | + showNewSearchButton(); | |
| 418 | + | |
| 419 | + handleMessages([{type : 'error', msg : 'Ocorreu um erro ao carregar as matriculas, por favor tente novamente, detalhes:' + response.responseText}], ''); | |
| 420 | + | |
| 421 | + safeLog(response); | |
| 422 | + } | |
| 423 | + | |
| 424 | + //change submit button | |
| 425 | + var onClickSearchEvent = function(event){ | |
| 426 | + if (validatesPresenseOfValueInRequiredFields()) | |
| 427 | + { | |
| 428 | + matriculasSearchOptions.url = getResourceUrlBuilder.buildUrl(ApiUrlBase, 'matriculas', {matricula_id : $('#ref_cod_matricula').val()}); | |
| 429 | + | |
| 430 | + if (window.history && window.history.pushState) | |
| 431 | + window.history.pushState('', '', getResourceUrlBuilder.buildUrl(PageUrlBase, 'matriculas')); | |
| 432 | + | |
| 433 | + $resultTable.children().fadeOut('fast').remove(); | |
| 434 | + | |
| 435 | + $formFilter.submit(); | |
| 436 | + $formFilter.fadeOut('fast'); | |
| 437 | + $navActions | |
| 438 | + .html('Aguarde, carregando...') | |
| 439 | + .attr('style', 'text-align:center;') | |
| 440 | + .unbind('click'); | |
| 441 | + | |
| 442 | + resetAutoCompleteNomeDisciplinaEvent($disciplinasManualTable.find('input.nome')); | |
| 443 | + } | |
| 444 | + }; | |
| 445 | + $submitButton.val('Carregar'); | |
| 446 | + $submitButton.attr('onclick', ''); | |
| 447 | + $submitButton.click(onClickSearchEvent); | |
| 448 | + | |
| 449 | + //config form search | |
| 450 | + var matriculasSearchOptions = { | |
| 451 | + url : '', | |
| 452 | + dataType : 'json', | |
| 453 | + success : handleMatriculasSearch, | |
| 454 | + error : handleErrorMatriculasSearch | |
| 455 | + }; | |
| 456 | + | |
| 457 | + $formFilter.ajaxForm(matriculasSearchOptions); | |
| 458 | + | |
| 459 | + var onClickActionEvent = function(event){ | |
| 460 | + | |
| 461 | + var $firstChecked = $('input.matricula:checked:first'); | |
| 462 | + | |
| 463 | + if ($firstChecked.length < 1) | |
| 464 | + handleMessages([{type : 'error', msg : 'Selecione alguma matrícula.'}], $actionButton, true); | |
| 465 | + else { | |
| 466 | + var additionalFields = [ | |
| 467 | + $('#percentual-frequencia-manual').get(0), | |
| 468 | + $('#notas-manual').get(0), | |
| 469 | + $('#faltas-manual').get(0) | |
| 470 | + ]; | |
| 471 | + | |
| 472 | + $.each($('#disciplinas-manual').find('.obrigatorio'), function(index, requiredElement){ | |
| 473 | + additionalFields.push(requiredElement); | |
| 474 | + }); | |
| 475 | + | |
| 476 | + if (validatesPresenseOfValueInRequiredFields(additionalFields)){ | |
| 477 | + | |
| 478 | + var isValid = validatesIfValueIsNumeric($('#dias-letivos').val(), 'dias-letivos'); | |
| 479 | + | |
| 480 | + if (isValid && $('#percentual-frequencia').val() != 'buscar-boletim') | |
| 481 | + isValid = validatesIfNumericValueIsInRange($('#percentual-frequencia-manual').val(), '#percentual-frequencia-manual', 0, 100); | |
| 482 | + | |
| 483 | + var $faltas = $('#faltas'); | |
| 484 | + if (isValid && $faltas.val() != 'buscar-boletim' && $faltas.is(':visible')) | |
| 485 | + isValid = validatesIfNumericValueIsInRange($('#faltas-manual').val(), '#faltas-manual', 0, 999); | |
| 486 | + | |
| 487 | + if (isValid && $('#disciplinas').val() != 'buscar-boletim'){ | |
| 488 | + $.each($('#disciplinas-manual').find('.falta'), function(index, field){ | |
| 489 | + $field = $(field); | |
| 490 | + isValid = $.trim($field.val()) == '' || validatesIfNumericValueIsInRange($field.val(), $field, 0, 999); | |
| 491 | + }); | |
| 492 | + } | |
| 493 | + | |
| 494 | + if (isValid){ | |
| 495 | + $('.disable-on-apply-changes').attr('disabled', 'disabled'); | |
| 496 | + $actionButton.val('Aguarde processando...'); | |
| 497 | + postProcessamento($firstChecked); | |
| 498 | + } | |
| 499 | + } | |
| 500 | + } | |
| 501 | + }; | |
| 502 | + | |
| 503 | + function getDisciplinasManuais(){ | |
| 504 | + var disciplinas = []; | |
| 505 | + $.each($('#disciplinas-manual').find('.disciplina'), function(index, disciplina){ | |
| 506 | + var $disciplina = $(disciplina); | |
| 507 | + | |
| 508 | + disciplinas.push({ | |
| 509 | + nome : $disciplina.find('.nome').val(), | |
| 510 | + nota : $disciplina.find('.nota').val(), | |
| 511 | + falta : $disciplina.find('.falta').val() | |
| 512 | + }); | |
| 513 | + }); | |
| 514 | + return disciplinas; | |
| 515 | + } | |
| 516 | + | |
| 517 | + function postProcessamento($resourceElement){ | |
| 518 | + | |
| 519 | + var percentualFrequencia = $('#percentual-frequencia').val() == 'buscar-boletim' ? 'buscar-boletim' : $('#percentual-frequencia-manual').val(); | |
| 520 | + var faltas = $('#faltas').val() == 'buscar-boletim' ? 'buscar-boletim' : $('#faltas-manual').val(); | |
| 521 | + var notas = $('#notas').val() == 'buscar-boletim' ? 'buscar-boletim' : $('#notas-manual').val(); | |
| 522 | + var disciplinas = $('#disciplinas').val() == 'buscar-boletim' ? 'buscar-boletim' : getDisciplinasManuais(); | |
| 523 | + | |
| 524 | + var options = { | |
| 525 | + url : postResourceUrlBuilder.buildUrl(ApiUrlBase, 'processamento', { | |
| 526 | + matricula_id : $resourceElement.data('matricula_id') | |
| 527 | + }), | |
| 528 | + dataType : 'json', | |
| 529 | + data : { | |
| 530 | + dias_letivos : $('#dias-letivos').val(), | |
| 531 | + situacao : $('#situacao').val(), | |
| 532 | + extra_curricular : $('#extra-curricular').is(':checked') ? 1 : 0, | |
| 533 | + grade_curso_id : $('#grade-curso').val(), | |
| 534 | + percentual_frequencia : percentualFrequencia, | |
| 535 | + notas : notas, | |
| 536 | + faltas : faltas, | |
| 537 | + observacao : $('#observacao').val(), | |
| 538 | + registro : $('#registro').val(), | |
| 539 | + livro : $('#livro').val(), | |
| 540 | + folha : $('#folha').val(), | |
| 541 | + disciplinas : disciplinas | |
| 542 | + }, | |
| 543 | + success : function(dataResponse){ | |
| 544 | + afterChangeResource($resourceElement, postProcessamento); | |
| 545 | + handlePostProcessamento(dataResponse); | |
| 546 | + } | |
| 547 | + }; | |
| 548 | + | |
| 549 | + beforeChangeResource($resourceElement); | |
| 550 | + postResource(options, handleErrorPost); | |
| 551 | + } | |
| 552 | + | |
| 553 | + function deleteHistorico($resourceElement){ | |
| 554 | + var options = { | |
| 555 | + url : deleteResourceUrlBuilder.buildUrl(ApiUrlBase, 'historico', { | |
| 556 | + matricula_id : $resourceElement.data('matricula_id') | |
| 557 | + }), | |
| 558 | + dataType : 'json', | |
| 559 | + data : { | |
| 560 | + }, | |
| 561 | + success : function(dataResponse){ | |
| 562 | + afterChangeResource($resourceElement, deleteHistorico); | |
| 563 | + handlePostProcessamento(dataResponse); | |
| 564 | + } | |
| 565 | + }; | |
| 566 | + | |
| 567 | + beforeChangeResource($resourceElement); | |
| 568 | + deleteResource(options, handleErrorDeleteResource); | |
| 569 | + } | |
| 570 | + | |
| 571 | + function deleteResource(options, errorCallback){ | |
| 572 | + $.ajax(options).error(errorCallback); | |
| 573 | + } | |
| 574 | + | |
| 575 | + function beforeChangeResource($resourceElement){ | |
| 576 | + if ($resourceElement.siblings('img').length < 1); | |
| 577 | + $('<img alt="loading..." src="/modules/HistoricoEscolar/Static/images/loading.gif" />').appendTo($resourceElement.parent()); | |
| 578 | + } | |
| 579 | + | |
| 580 | + function handlePostProcessamento(dataResponse){ | |
| 581 | + try{ | |
| 582 | + var $checkbox = $('matricula-' + dataResponse.matricula_id); | |
| 583 | + var $targetElement = $j('#matricula-'+dataResponse.matricula_id).closest('tr').first(); | |
| 584 | + handleMessages(dataResponse.msgs, $targetElement); | |
| 585 | + updateFieldSituacao(dataResponse.link_to_historico, dataResponse.matricula_id, dataResponse.situacao_historico); | |
| 586 | + } | |
| 587 | + catch(error){ | |
| 588 | + showNewSearchButton(); | |
| 589 | + handleMessages([{type : 'error', msg : 'Ocorreu um erro ao enviar o processamento, por favor tente novamente, detalhes: ' + error}], ''); | |
| 590 | + | |
| 591 | + safeLog(dataResponse); | |
| 592 | + } | |
| 593 | + } | |
| 594 | + | |
| 595 | + | |
| 596 | + function afterChangeResource($resourceElement, callbackContinueNextChange){ | |
| 597 | + $resourceElement.siblings('img').remove(); | |
| 598 | + $resourceElement.attr('checked', false); | |
| 599 | + | |
| 600 | + //verifica se chegou na ultima matricula e ativa os elements desativados | |
| 601 | + var $firstChecked = $('input.matricula:checked:first'); | |
| 602 | + if ($firstChecked.length < 1){ | |
| 603 | + $('.disable-on-apply-changes').removeAttr('disabled'); | |
| 604 | + $actionButton.val('Processar'); | |
| 605 | + window.setTimeout(function(){alert(safeUtf8Decode('Operação finalizada.'));}, 1); | |
| 606 | + } | |
| 607 | + else if (typeof(callbackContinueNextChange) == 'function') | |
| 608 | + callbackContinueNextChange($firstChecked); | |
| 609 | + } | |
| 610 | + | |
| 611 | + var onClickSelectAllEvent = function(event){ | |
| 612 | + var $checked = $('input.matricula:checked'); | |
| 613 | + var $unchecked = $('input.matricula:not(:checked)'); | |
| 614 | + | |
| 615 | + $checked.attr('checked', false); | |
| 616 | + $unchecked.attr('checked', true); | |
| 617 | + }; | |
| 618 | + | |
| 619 | + var onClickDestroyEvent = function(event){ | |
| 620 | + | |
| 621 | + var $firstChecked = $('input.matricula:checked:first'); | |
| 622 | + | |
| 623 | + if ($firstChecked.length < 1) | |
| 624 | + handleMessages([{type : 'error', msg : 'Selecione alguma matrícula.'}], $actionButton, true); | |
| 625 | + else{ | |
| 626 | + | |
| 627 | + if (confirm("Confirma remoção dos históricos selecionados?")){ | |
| 628 | + | |
| 629 | + $.each($('input.matricula:checked').closest('tr').find('.situacao'), function(indice, fieldSituacao){ | |
| 630 | + var $fieldSituacao = $(fieldSituacao); | |
| 631 | + if ($fieldSituacao.data('situacao_historico') != 'Processado') | |
| 632 | + $fieldSituacao.closest('tr').find('input.matricula').attr('checked', false); | |
| 633 | + }); | |
| 634 | + | |
| 635 | + $('.disable-on-apply-changes').attr('disabled', 'disabled'); | |
| 636 | + $actionButton.val('Aguarde removendo...'); | |
| 637 | + deleteHistorico($firstChecked); | |
| 638 | + } | |
| 639 | + } | |
| 640 | + }; | |
| 641 | + | |
| 642 | + $actionButton.click(onClickActionEvent); | |
| 643 | + $selectAllButton.click(onClickSelectAllEvent); | |
| 644 | + $destroyButton.click(onClickDestroyEvent) | |
| 645 | + | |
| 646 | + }); | |
| 647 | +})(jQuery); | ... | ... |
ieducar/modules/HistoricoEscolar/Static/styles/processamento.css
0 → 100644
ieducar/modules/HistoricoEscolar/Views/ProcessamentoApiController.php
0 → 100644
| ... | ... | @@ -0,0 +1,1045 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +#error_reporting(E_ALL); | |
| 4 | +#ini_set("display_errors", 1); | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * i-Educar - Sistema de gestão escolar | |
| 8 | + * | |
| 9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 10 | + * <ctima@itajai.sc.gov.br> | |
| 11 | + * | |
| 12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 15 | + * qualquer versão posterior. | |
| 16 | + * | |
| 17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 20 | + * do GNU para mais detalhes. | |
| 21 | + * | |
| 22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
| 23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
| 24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 25 | + * | |
| 26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
| 27 | + * @category i-Educar | |
| 28 | + * @license @@license@@ | |
| 29 | + * @package Avaliacao | |
| 30 | + * @subpackage Modules | |
| 31 | + * @since Arquivo disponível desde a versão ? | |
| 32 | + * @version $Id$ | |
| 33 | + */ | |
| 34 | + | |
| 35 | +require_once 'Core/Controller/Page/EditController.php'; | |
| 36 | +require_once 'Avaliacao/Model/NotaComponenteDataMapper.php'; | |
| 37 | +require_once 'Avaliacao/Service/Boletim.php'; | |
| 38 | +require_once 'App/Model/MatriculaSituacao.php'; | |
| 39 | +require_once 'RegraAvaliacao/Model/TipoPresenca.php'; | |
| 40 | +require_once 'RegraAvaliacao/Model/TipoParecerDescritivo.php'; | |
| 41 | + | |
| 42 | +require_once 'include/pmieducar/clsPmieducarMatricula.inc.php'; | |
| 43 | +require_once 'include/pmieducar/clsPmieducarHistoricoEscolar.inc.php'; | |
| 44 | +require_once 'include/pmieducar/clsPmieducarHistoricoDisciplinas.inc.php'; | |
| 45 | + | |
| 46 | +require_once 'lib/Portabilis/String/Utils.php'; | |
| 47 | +require_once 'Portabilis/Utils/Database.php'; | |
| 48 | + | |
| 49 | + | |
| 50 | +// TODO migrar classe novo padrao api controller | |
| 51 | +class ProcessamentoApiController extends Core_Controller_Page_EditController | |
| 52 | +{ | |
| 53 | + protected $_dataMapper = 'Avaliacao_Model_NotaComponenteDataMapper'; | |
| 54 | + protected $_processoAp = 999613; | |
| 55 | + protected $_nivelAcessoOption = App_Model_NivelAcesso::SOMENTE_ESCOLA; | |
| 56 | + protected $_saveOption = FALSE; | |
| 57 | + protected $_deleteOption = FALSE; | |
| 58 | + protected $_titulo = ''; | |
| 59 | + | |
| 60 | + | |
| 61 | + protected function validatesPresenceOf(&$value, $name, $raiseExceptionOnEmpty = false, $msg = '', $addMsgOnEmpty = true){ | |
| 62 | + if (! isset($value) || (empty($value) && !is_numeric($value))){ | |
| 63 | + if ($addMsgOnEmpty) | |
| 64 | + { | |
| 65 | + $msg = empty($msg) ? "É necessário receber uma variavel '$name'" : $msg; | |
| 66 | + $this->appendMsg($msg); | |
| 67 | + } | |
| 68 | + | |
| 69 | + if ($raiseExceptionOnEmpty) | |
| 70 | + throw new Exception($msg); | |
| 71 | + | |
| 72 | + return false; | |
| 73 | + } | |
| 74 | + return true; | |
| 75 | + } | |
| 76 | + | |
| 77 | + protected function validatesValueIsNumeric(&$value, $name, $raiseExceptionOnError = false, $msg = '', $addMsgOnError = true){ | |
| 78 | + if (! is_numeric($value)){ | |
| 79 | + if ($addMsgOnError) | |
| 80 | + { | |
| 81 | + $msg = empty($msg) ? "O valor recebido para variavel '$name' deve ser numerico" : $msg; | |
| 82 | + $this->appendMsg($msg); | |
| 83 | + } | |
| 84 | + | |
| 85 | + if ($raiseExceptionOnError) | |
| 86 | + throw new Exception($msg); | |
| 87 | + | |
| 88 | + return false; | |
| 89 | + } | |
| 90 | + return true; | |
| 91 | + } | |
| 92 | + | |
| 93 | + protected function validatesValueIsArray(&$value, $name, $raiseExceptionOnError = false, $msg = '', $addMsgOnError = true){ | |
| 94 | + | |
| 95 | + if (! is_array($value)){ | |
| 96 | + if ($addMsgOnError) | |
| 97 | + { | |
| 98 | + $msg = empty($msg) ? "Deve ser recebido uma lista de '$name'" : $msg; | |
| 99 | + $this->appendMsg($msg); | |
| 100 | + } | |
| 101 | + | |
| 102 | + if ($raiseExceptionOnError) | |
| 103 | + throw new Exception($msg); | |
| 104 | + | |
| 105 | + return false; | |
| 106 | + } | |
| 107 | + return true; | |
| 108 | + } | |
| 109 | + | |
| 110 | + protected function validatesValueInSetOf(&$value, $setExpectedValues, $name, $raiseExceptionOnError = false, $msg = ''){ | |
| 111 | + if (! in_array($value, $setExpectedValues)){ | |
| 112 | + $msg = empty($msg) ? "Valor recebido na variavel '$name' é invalido" : $msg; | |
| 113 | + $this->appendMsg($msg); | |
| 114 | + | |
| 115 | + if ($raiseExceptionOnError) | |
| 116 | + throw new Exception($msg); | |
| 117 | + | |
| 118 | + return false; | |
| 119 | + } | |
| 120 | + return true; | |
| 121 | + } | |
| 122 | + | |
| 123 | + | |
| 124 | + protected function requiresLogin($raiseExceptionOnEmpty){ | |
| 125 | + return $this->validatesPresenceOf($this->getSession()->id_pessoa, '', $raiseExceptionOnEmpty, 'Usuário deve estar logado'); | |
| 126 | + } | |
| 127 | + | |
| 128 | + protected function validatesPresenceOfInstituicaoId($raiseExceptionOnEmpty){ | |
| 129 | + return $this->validatesPresenceOf($this->getRequest()->instituicao_id, 'instituicao_id', $raiseExceptionOnEmpty); | |
| 130 | + } | |
| 131 | + | |
| 132 | + protected function validatesPresenceOfEscolaId($raiseExceptionOnEmpty){ | |
| 133 | + return $this->validatesPresenceOf($this->getRequest()->escola_id, 'escola_id', $raiseExceptionOnEmpty); | |
| 134 | + } | |
| 135 | + | |
| 136 | + protected function validatesPresenceOfCursoId($raiseExceptionOnEmpty){ | |
| 137 | + return $this->validatesPresenceOf($this->getRequest()->curso_id, 'curso_id', $raiseExceptionOnEmpty); | |
| 138 | + } | |
| 139 | + | |
| 140 | + protected function validatesPresenceOfSerieId($raiseExceptionOnEmpty, $addMsgOnEmpty = true){ | |
| 141 | + return $this->validatesPresenceOf($this->getRequest()->serie_id, 'serie_id', $raiseExceptionOnEmpty, '', $addMsgOnEmpty); | |
| 142 | + } | |
| 143 | + | |
| 144 | + protected function validatesPresenceOfAno($raiseExceptionOnEmpty){ | |
| 145 | + return $this->validatesPresenceOf($this->getRequest()->ano, 'ano', $raiseExceptionOnEmpty); | |
| 146 | + } | |
| 147 | + | |
| 148 | + protected function validatesPresenceOfMatriculaId($raiseExceptionOnEmpty){ | |
| 149 | + return $this->validatesPresenceOf($this->getRequest()->matricula_id, 'matricula_id', $raiseExceptionOnEmpty); | |
| 150 | + } | |
| 151 | + | |
| 152 | + protected function validatesValueIsInBd($fieldName, &$value, $schemaName, $tableName, $raiseExceptionOnError = true){ | |
| 153 | + $sql = "select 1 from $schemaName.$tableName where $fieldName = $1"; | |
| 154 | + $isValid = Portabilis_Utils_DataBase::selectField($sql, $value) == '1'; | |
| 155 | + | |
| 156 | + if (! $isValid){ | |
| 157 | + $msg = "O valor informado {$value} para $tableName, não esta presente no banco de dados."; | |
| 158 | + $this->appendMsg($msg); | |
| 159 | + | |
| 160 | + if ($raiseExceptionOnError) | |
| 161 | + throw new Exception($msg); | |
| 162 | + | |
| 163 | + return false; | |
| 164 | + } | |
| 165 | + | |
| 166 | + return true; | |
| 167 | + } | |
| 168 | + | |
| 169 | + protected function validatesPresenceAndValueInDbOfGradeCursoId($raiseExceptionOnError){ | |
| 170 | + return $this->validatesPresenceOf($this->getRequest()->grade_curso_id, 'grade_curso_id', $raiseExceptionOnError) && | |
| 171 | + $this->validatesValueIsInBd('id', $this->getRequest()->grade_curso_id, 'pmieducar', 'historico_grade_curso', $raiseExceptionOnError); | |
| 172 | + } | |
| 173 | + | |
| 174 | + protected function validatesPresenceOfDiasLetivos($raiseExceptionOnEmpty){ | |
| 175 | + return $this->validatesPresenceOf($this->getRequest()->dias_letivos, 'dias_letivos', $raiseExceptionOnEmpty); | |
| 176 | + } | |
| 177 | + | |
| 178 | + protected function validatesValueOfAttValueIsNumeric($raiseExceptionOnError){ | |
| 179 | + return $this->validatesValueIsNumeric($this->getRequest()->att_value, 'att_value', $raiseExceptionOnError); | |
| 180 | + } | |
| 181 | + | |
| 182 | + protected function validatesPresenceOfAttValue($raiseExceptionOnEmpty){ | |
| 183 | + return $this->validatesPresenceOf($this->getRequest()->att_value, 'att_value', $raiseExceptionOnEmpty); | |
| 184 | + } | |
| 185 | + | |
| 186 | + | |
| 187 | + protected function validatesPresenceAndValueInSetOfAtt($raiseExceptionOnError){ | |
| 188 | + $result = $this->validatesPresenceOf($this->getRequest()->att, 'att', $raiseExceptionOnError); | |
| 189 | + | |
| 190 | + if ($result){ | |
| 191 | + $expectedAtts = array('matriculas', 'processamento', 'historico'); | |
| 192 | + $result = $this->validatesValueInSetOf($this->getRequest()->att, $expectedAtts, 'att', $raiseExceptionOnError); | |
| 193 | + } | |
| 194 | + return $result; | |
| 195 | + } | |
| 196 | + | |
| 197 | + | |
| 198 | + protected function validatesPresenceAndValueInSetOfOper($raiseExceptionOnError){ | |
| 199 | + $result = $this->validatesPresenceOf($this->getRequest()->oper, 'oper', $raiseExceptionOnError); | |
| 200 | + | |
| 201 | + if ($result){ | |
| 202 | + $expectedOpers = array('post', 'get', 'delete'); | |
| 203 | + $result = $this->validatesValueInSetOf($this->getRequest()->oper, $expectedOpers, 'oper', $raiseExceptionOnError); | |
| 204 | + } | |
| 205 | + return $result; | |
| 206 | + } | |
| 207 | + | |
| 208 | + | |
| 209 | + protected function validatesPresenceAndValueInSetOfExtraCurricular($raiseExceptionOnError){ | |
| 210 | + $result = $this->validatesPresenceOf($this->getRequest()->extra_curricular, 'extra_curricular', $raiseExceptionOnError); | |
| 211 | + | |
| 212 | + if ($result){ | |
| 213 | + $expectedOpers = array(0, 1); | |
| 214 | + $result = $this->validatesValueInSetOf($this->getRequest()->extra_curricular, $expectedOpers, 'extra_curricular', $raiseExceptionOnError); | |
| 215 | + } | |
| 216 | + return $result; | |
| 217 | + } | |
| 218 | + | |
| 219 | + protected function validatesPresenceAndValueOfPercentualFrequencia($raiseExceptionOnError){ | |
| 220 | + $name = 'percentual_frequencia'; | |
| 221 | + $isValid = $this->validatesPresenceOf($this->getRequest()->percentual_frequencia, $name, $raiseExceptionOnError); | |
| 222 | + | |
| 223 | + if ($isValid && $this->getRequest()->percentual_frequencia != 'buscar-boletim') | |
| 224 | + $isValid = $this->validatesValueIsNumeric($this->getRequest()->percentual_frequencia, $name, $raiseExceptionOnError); | |
| 225 | + | |
| 226 | + return $isValid; | |
| 227 | + } | |
| 228 | + | |
| 229 | + protected function validatesPresenceOfNotas($raiseExceptionOnError){ | |
| 230 | + return $this->validatesPresenceOf($this->getRequest()->notas, 'notas', $raiseExceptionOnError); | |
| 231 | + } | |
| 232 | + | |
| 233 | + protected function validatesPresenceAndValueOfFaltas($raiseExceptionOnError){ | |
| 234 | + $name = 'faltas'; | |
| 235 | + $isValid = $this->validatesPresenceOf($this->getRequest()->faltas, $name, $raiseExceptionOnError); | |
| 236 | + | |
| 237 | + if ($isValid && $this->getRequest()->faltas != 'buscar-boletim') | |
| 238 | + $isValid = $this->validatesValueIsNumeric($this->getRequest()->faltas, $name, $raiseExceptionOnError); | |
| 239 | + | |
| 240 | + return $isValid; | |
| 241 | + } | |
| 242 | + | |
| 243 | + | |
| 244 | + protected function validatesPresenceAndValueOfDisciplinas($raiseExceptionOnError){ | |
| 245 | + $name = 'disciplinas'; | |
| 246 | + $isValid = $this->validatesPresenceOf($this->getRequest()->disciplinas, $name, $raiseExceptionOnError); | |
| 247 | + | |
| 248 | + if ($isValid && $this->getRequest()->disciplinas != 'buscar-boletim'){ | |
| 249 | + $isValid = $this->validatesValueIsArray($this->getRequest()->disciplinas, 'disciplinas', $raiseExceptionOnError); | |
| 250 | + if ($isValid){ | |
| 251 | + foreach($this->getRequest()->disciplinas as $disciplina){ | |
| 252 | + $isValid = $this->validatesPresenceOf($disciplina['nome'], 'nome (para todas disciplinas)', $raiseExceptionOnError); | |
| 253 | + | |
| 254 | + if ($isValid && isset($disciplina['falta']) && trim($disciplina['falta']) != '') | |
| 255 | + $isValid = $this->validatesValueIsNumeric($disciplina['falta'], 'falta (para todas disciplinas)', $raiseExceptionOnError); | |
| 256 | + } | |
| 257 | + } | |
| 258 | + } | |
| 259 | + return $isValid; | |
| 260 | + } | |
| 261 | + | |
| 262 | + protected function validatesPresenceAndValueInSetOfSituacao($raiseExceptionOnError){ | |
| 263 | + $name = 'situacao'; | |
| 264 | + $isValid = $this->validatesPresenceOf($this->getRequest()->situacao, $name, $raiseExceptionOnError); | |
| 265 | + | |
| 266 | + if ($isValid){ | |
| 267 | + $expectedOpers = array('buscar-matricula', 'aprovado', 'reprovado', 'em-andamento', 'transferido'); | |
| 268 | + $isValid = $this->validatesValueInSetOf($this->getRequest()->situacao, $expectedOpers, $name, $raiseExceptionOnError); | |
| 269 | + } | |
| 270 | + | |
| 271 | + return $isValid; | |
| 272 | + } | |
| 273 | + | |
| 274 | + | |
| 275 | + /* esta funcao só pode ser chamada após setar $this->getService() */ | |
| 276 | + protected function validatesPresenceOfComponenteCurricularId($raiseExceptionOnEmpty, $addMsgOnEmpty = true) | |
| 277 | + { | |
| 278 | + return $this->validatesPresenceOf($this->getRequest()->componente_curricular_id, 'componente_curricular_id', $raiseExceptionOnEmpty, $msg = '', $addMsgOnEmpty); | |
| 279 | + } | |
| 280 | + | |
| 281 | + | |
| 282 | + protected function canAcceptRequest() | |
| 283 | + { | |
| 284 | + try { | |
| 285 | + $this->requiresLogin(true); | |
| 286 | + $this->validatesPresenceAndValueInSetOfAtt(true); | |
| 287 | + $this->validatesPresenceAndValueInSetOfOper(true); | |
| 288 | + } | |
| 289 | + catch (Exception $e){ | |
| 290 | + return false; | |
| 291 | + } | |
| 292 | + return true; | |
| 293 | + } | |
| 294 | + | |
| 295 | + | |
| 296 | + protected function canGetMatriculas(){ | |
| 297 | + return $this->validatesPresenceOfAno(false) && | |
| 298 | + $this->validatesPresenceOfInstituicaoId(false) && | |
| 299 | + $this->validatesPresenceOfEscolaId(false); | |
| 300 | + } | |
| 301 | + | |
| 302 | + | |
| 303 | + protected function canPostProcessamento(){ | |
| 304 | + $canPost = $this->validatesPresenceOfInstituicaoId(false) && | |
| 305 | + $this->validatesPresenceOfMatriculaId(false) && | |
| 306 | + $this->validatesPresenceOfDiasLetivos(false) && | |
| 307 | + $this->validatesPresenceAndValueInSetOfSituacao(false) && | |
| 308 | + $this->validatesPresenceAndValueInSetOfExtraCurricular(false) && | |
| 309 | + $this->validatesPresenceAndValueInDbOfGradeCursoId(false) && | |
| 310 | + $this->validatesPresenceAndValueOfPercentualFrequencia(false) && | |
| 311 | + $this->validatesPresenceAndValueOfDisciplinas(false); | |
| 312 | + | |
| 313 | + if ($canPost && $this->getRequest()->disciplinas == 'buscar-boletim') | |
| 314 | + $canPost = $this->validatesPresenceOfNotas(false) && $this->validatesPresenceAndValueOfFaltas(false); | |
| 315 | + | |
| 316 | + if($canPost){ | |
| 317 | + $sql = "select 1 from pmieducar.matricula where cod_matricula = $1 and ativo = 1"; | |
| 318 | + | |
| 319 | + if(! Portabilis_Utils_Database::selectField($sql, $this->getRequest()->matricula_id)){ | |
| 320 | + $this->appendMsg("A matricula {$this->getRequest()->matricula_id} não existe ou esta desativa", 'error'); | |
| 321 | + $canPost = false; | |
| 322 | + } | |
| 323 | + } | |
| 324 | + | |
| 325 | + if($canPost){ | |
| 326 | + $sql = "select 1 from pmieducar.matricula_turma where ref_cod_matricula = $1 and ativo = 1 limit 1"; | |
| 327 | + | |
| 328 | + if(! Portabilis_Utils_Database::selectField($sql, $this->getRequest()->matricula_id)){ | |
| 329 | + $this->appendMsg("A matricula {$this->getRequest()->matricula_id} não está enturmada.", 'error'); | |
| 330 | + $canPost = false; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 334 | + return $canPost && $this->setService(); | |
| 335 | + } | |
| 336 | + | |
| 337 | + | |
| 338 | + protected function canDeleteHistorico(){ | |
| 339 | + return $this->validatesPresenceOfInstituicaoId(false) && | |
| 340 | + $this->validatesPresenceOfMatriculaId(false); | |
| 341 | + } | |
| 342 | + | |
| 343 | + | |
| 344 | + protected function deleteHistorico(){ | |
| 345 | + if ($this->canDeleteHistorico()){ | |
| 346 | + | |
| 347 | + $matriculaId = $this->getRequest()->matricula_id; | |
| 348 | + $alunoId = $this->getAlunoIdByMatriculaId($matriculaId); | |
| 349 | + $dadosMatricula = $this->getdadosMatricula($matriculaId); | |
| 350 | + $ano = $dadosMatricula['ano']; | |
| 351 | + | |
| 352 | + if ($this->existsHistorico($alunoId, $ano, $matriculaId)){ | |
| 353 | + $sequencial = $this->getSequencial($alunoId, $ano, $matriculaId); | |
| 354 | + $this->deleteHistoricoDisplinas($alunoId, $sequencial); | |
| 355 | + | |
| 356 | + $historicoEscolar = new clsPmieducarHistoricoEscolar( | |
| 357 | + $ref_cod_aluno = $alunoId, | |
| 358 | + $sequencial, | |
| 359 | + $ref_usuario_exc = $this->getSession()->id_pessoa, | |
| 360 | + $ref_usuario_cad = null, | |
| 361 | + #TODO nm_curso | |
| 362 | + $nm_serie = null, | |
| 363 | + $ano = $ano, | |
| 364 | + $carga_horaria = null, | |
| 365 | + $dias_letivos = null, | |
| 366 | + $escola = null, | |
| 367 | + $escola_cidade = null, | |
| 368 | + $escola_uf = null, | |
| 369 | + $observacao = null, | |
| 370 | + $aprovado = null, | |
| 371 | + $data_cadastro = null, | |
| 372 | + $data_exclusao = date('Y-m-d'), | |
| 373 | + $ativo = 0 | |
| 374 | + ); | |
| 375 | + $historicoEscolar->edita(); | |
| 376 | + | |
| 377 | + $this->appendMsg('Histórico escolar removido com sucesso', 'success'); | |
| 378 | + } | |
| 379 | + else | |
| 380 | + $this->appendMsg("Histórico matricula $matriculaId inexistente ou já removido", 'notice'); | |
| 381 | + | |
| 382 | + $situacaoHistorico = $this->getSituacaoHistorico($alunoId, $ano, $matriculaId, $reload = true); | |
| 383 | + | |
| 384 | + $this->appendResponse('situacao_historico', $situacaoHistorico); | |
| 385 | + $this->appendResponse('link_to_historico', ''); | |
| 386 | + } | |
| 387 | + } | |
| 388 | + | |
| 389 | + | |
| 390 | + protected function deleteHistoricoDisplinas($alunoId, $historicoSequencial){ | |
| 391 | + $historicoDisciplinas = new clsPmieducarHistoricoDisciplinas(); | |
| 392 | + $historicoDisciplinas->excluirTodos($alunoId, $historicoSequencial); | |
| 393 | + } | |
| 394 | + | |
| 395 | + | |
| 396 | + protected function getdadosEscola($escolaId){ | |
| 397 | + | |
| 398 | + $sql = "select | |
| 399 | + | |
| 400 | + (select pes.nome from pmieducar.escola esc, cadastro.pessoa pes | |
| 401 | + where esc.ref_cod_instituicao = $1 and esc.cod_escola = $2 | |
| 402 | + and pes.idpes = esc.ref_idpes) as nome, | |
| 403 | + | |
| 404 | + (select coalesce((select coalesce((select municipio.nome from public.municipio, | |
| 405 | + cadastro.endereco_pessoa, cadastro.juridica, public.bairro, pmieducar.escola | |
| 406 | + where endereco_pessoa.idbai = bairro.idbai and bairro.idmun = municipio.idmun and | |
| 407 | + juridica.idpes = endereco_pessoa.idpes and juridica.idpes = escola.ref_idpes and | |
| 408 | + escola.cod_escola = $2),(select endereco_externo.cidade from cadastro.endereco_externo, | |
| 409 | + pmieducar.escola where endereco_externo.idpes = escola.ref_idpes and escola.cod_escola = $2))), | |
| 410 | + (select municipio from pmieducar.escola_complemento where ref_cod_escola = $2))) as cidade, | |
| 411 | + | |
| 412 | + (select coalesce((select coalesce((select municipio.sigla_uf from public.municipio, | |
| 413 | + cadastro.endereco_pessoa, cadastro.juridica, public.bairro, pmieducar.escola | |
| 414 | + where endereco_pessoa.idbai = bairro.idbai and bairro.idmun = municipio.idmun and | |
| 415 | + juridica.idpes = endereco_pessoa.idpes and juridica.idpes = escola.ref_idpes and | |
| 416 | + escola.cod_escola = $2),(select endereco_externo.sigla_uf from cadastro.endereco_externo, | |
| 417 | + pmieducar.escola where endereco_externo.idpes = escola.ref_idpes and escola.cod_escola = $2))), | |
| 418 | + (select inst.ref_sigla_uf from pmieducar.instituicao inst where inst.cod_instituicao = $1))) as uf"; | |
| 419 | + | |
| 420 | + $params = array('params' => array($this->getrequest()->instituicao_id, $escolaId), 'return_only' => 'first-line'); | |
| 421 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $params); | |
| 422 | + } | |
| 423 | + | |
| 424 | + | |
| 425 | + protected function getNextHistoricoSequencial($alunoId){ | |
| 426 | + //A consulta leva em consideração historicos inativos pois o sequencial é chave composta com ref_cod_aluno id | |
| 427 | + $sql = "select coalesce(max(sequencial), 0) + 1 from pmieducar.historico_escolar where ref_cod_aluno = $1"; | |
| 428 | + | |
| 429 | + return Portabilis_Utils_Database::selectField($sql, $alunoId); | |
| 430 | + } | |
| 431 | + | |
| 432 | + | |
| 433 | + protected function getNextHistoricoDisciplinasSequencial($historicoSequencial, $alunoId){ | |
| 434 | + $sql = "select coalesce(max(sequencial), 0) + 1 from pmieducar.historico_disciplinas where | |
| 435 | + ref_sequencial = $1 and ref_ref_cod_aluno = $2"; | |
| 436 | + | |
| 437 | + return Portabilis_Utils_Database::selectField($sql, array($historicoSequencial, $alunoId)); | |
| 438 | + } | |
| 439 | + | |
| 440 | + | |
| 441 | + protected function getSituacaoMatricula($matriculaId = null) { | |
| 442 | + if (! is_null($matriculaId)) { | |
| 443 | + | |
| 444 | + if (! is_null($this->getService(false, false))) | |
| 445 | + $situacao = $this->getService()->getOption('aprovado'); | |
| 446 | + else { | |
| 447 | + $sql = "select aprovado from pmieducar.matricula where cod_matricula = $1"; | |
| 448 | + $situacao = Portabilis_Utils_Database::selectField($sql, $matriculaId); | |
| 449 | + } | |
| 450 | + | |
| 451 | + } | |
| 452 | + | |
| 453 | + else if($this->getRequest()->situacao == 'buscar-matricula') | |
| 454 | + $situacao = $this->getService()->getOption('aprovado'); | |
| 455 | + | |
| 456 | + else { | |
| 457 | + $situacoes = array( | |
| 458 | + 'aprovado' => App_Model_MatriculaSituacao::APROVADO, | |
| 459 | + 'reprovado' => App_Model_MatriculaSituacao::REPROVADO, | |
| 460 | + 'em-andamento' => App_Model_MatriculaSituacao::EM_ANDAMENTO, | |
| 461 | + 'transferido' => App_Model_MatriculaSituacao::TRANSFERIDO | |
| 462 | + ); | |
| 463 | + | |
| 464 | + $situacao = $situacoes[$this->getRequest()->situacao]; | |
| 465 | + } | |
| 466 | + | |
| 467 | + return $situacao; | |
| 468 | + | |
| 469 | + } | |
| 470 | + | |
| 471 | + | |
| 472 | + protected function getPercentualFrequencia(){ | |
| 473 | + if($this->getRequest()->percentual_frequencia == 'buscar-boletim') | |
| 474 | + $percentual = round($this->getService()->getSituacaoFaltas()->porcentagemPresenca, 2); | |
| 475 | + else | |
| 476 | + $percentual = $this->getRequest()->percentual_frequencia; | |
| 477 | + | |
| 478 | + return str_replace(',', '.', $percentual); | |
| 479 | + } | |
| 480 | + | |
| 481 | + | |
| 482 | + protected function getFaltaGlobalizada($defaultValue=null){ | |
| 483 | + if ($this->getService()->getRegra()->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::GERAL) | |
| 484 | + return $this->getFalta(); | |
| 485 | + else | |
| 486 | + return $defaultValue; | |
| 487 | + } | |
| 488 | + | |
| 489 | + protected function postProcessamento() { | |
| 490 | + | |
| 491 | + if ($this->canPostProcessamento()){ | |
| 492 | + $matriculaId = $this->getRequest()->matricula_id; | |
| 493 | + | |
| 494 | + try { | |
| 495 | + $alunoId = $this->getAlunoIdByMatriculaId($matriculaId); | |
| 496 | + $dadosMatricula = $this->getdadosMatricula($matriculaId); | |
| 497 | + $dadosEscola = $this->getdadosEscola($dadosMatricula['escola_id']); | |
| 498 | + $ano = $dadosMatricula['ano']; | |
| 499 | + $isNewHistorico = ! $this->existsHistorico($alunoId, $ano, $matriculaId); | |
| 500 | + | |
| 501 | + if ($isNewHistorico){ | |
| 502 | + $sequencial = $this->getNextHistoricoSequencial($alunoId); | |
| 503 | + | |
| 504 | + $historicoEscolar = new clsPmieducarHistoricoEscolar( | |
| 505 | + $alunoId, | |
| 506 | + $sequencial, | |
| 507 | + $ref_usuario_exc = NULL, | |
| 508 | + $ref_usuario_cad = $this->getSession()->id_pessoa, | |
| 509 | + $dadosMatricula['nome_serie'], | |
| 510 | + $ano, | |
| 511 | + $this->getService()->getOption('serieCargaHoraria'), | |
| 512 | + $this->getRequest()->dias_letivos, | |
| 513 | + mb_strtoupper($dadosEscola['nome']), | |
| 514 | + mb_strtoupper($dadosEscola['cidade']), | |
| 515 | + $dadosEscola['uf'], | |
| 516 | + utf8_decode($this->getRequest()->observacao), | |
| 517 | + $this->getSituacaoMatricula(), | |
| 518 | + $data_cadastro = date('Y-m-d'), | |
| 519 | + $data_exclusao = NULL, | |
| 520 | + $ativo = 1, | |
| 521 | + $this->getFaltaGlobalizada($defaultValue='NULL'), | |
| 522 | + $dadosMatricula['instituicao_id'], | |
| 523 | + $origem = '', #TODO | |
| 524 | + $this->getRequest()->extra_curricular, | |
| 525 | + $matriculaId, | |
| 526 | + $this->getPercentualFrequencia(), | |
| 527 | + utf8_decode($this->getRequest()->registro), | |
| 528 | + utf8_decode($this->getRequest()->livro), | |
| 529 | + utf8_decode($this->getRequest()->folha), | |
| 530 | + $dadosMatricula['nome_curso'], | |
| 531 | + $this->getRequest()->grade_curso_id | |
| 532 | + ); | |
| 533 | + | |
| 534 | + $historicoEscolar->cadastra(); | |
| 535 | + $this->recreateHistoricoDisciplinas($sequencial, $alunoId); | |
| 536 | + | |
| 537 | + $this->appendMsg('Histórico processado com sucesso', 'success'); | |
| 538 | + } | |
| 539 | + else{ | |
| 540 | + | |
| 541 | + $sequencial = $this->getSequencial($alunoId, $ano, $matriculaId); | |
| 542 | + | |
| 543 | + $historicoEscolar = new clsPmieducarHistoricoEscolar( | |
| 544 | + $alunoId, | |
| 545 | + $sequencial, | |
| 546 | + $this->getSession()->id_pessoa, | |
| 547 | + $ref_usuario_cad = null, | |
| 548 | + $dadosMatricula['nome_serie'], | |
| 549 | + $ano, | |
| 550 | + $this->getService()->getOption('serieCargaHoraria'), | |
| 551 | + $this->getRequest()->dias_letivos, | |
| 552 | + mb_strtoupper($dadosEscola['nome']), | |
| 553 | + mb_strtoupper($dadosEscola['cidade']), | |
| 554 | + $dadosEscola['uf'], | |
| 555 | + utf8_decode($this->getRequest()->observacao), | |
| 556 | + $this->getSituacaoMatricula(), | |
| 557 | + $data_cadastro = NULL, | |
| 558 | + $data_exclusao = NULL, | |
| 559 | + $ativo = 1, | |
| 560 | + $this->getFaltaGlobalizada($defaultValue='NULL'), | |
| 561 | + $dadosMatricula['instituicao_id'], | |
| 562 | + $origem = '', #TODO | |
| 563 | + $this->getRequest()->extra_curricular, | |
| 564 | + $matriculaId, | |
| 565 | + $this->getPercentualFrequencia(), | |
| 566 | + utf8_decode($this->getRequest()->registro), | |
| 567 | + utf8_decode($this->getRequest()->livro), | |
| 568 | + utf8_decode($this->getRequest()->folha), | |
| 569 | + $dadosMatricula['nome_curso'], | |
| 570 | + $this->getRequest()->grade_curso_id | |
| 571 | + ); | |
| 572 | + | |
| 573 | + $historicoEscolar->edita(); | |
| 574 | + $this->recreateHistoricoDisciplinas($dadosHistoricoEscolar['sequencial'], $alunoId); | |
| 575 | + $this->appendMsg('Histórico reprocessado com sucesso', 'success'); | |
| 576 | + } | |
| 577 | + | |
| 578 | + } | |
| 579 | + catch (Exception $e){ | |
| 580 | + $this->appendMsg('Erro ao processar histórico, detalhes:' . $e->getMessage(), 'error', true); | |
| 581 | + } | |
| 582 | + | |
| 583 | + $situacaoHistorico = $this->getSituacaoHistorico($alunoId, $ano, $matriculaId, $reload = true); | |
| 584 | + $linkToHistorico = $this->getLinkToHistorico($alunoId, $ano, $matriculaId); | |
| 585 | + | |
| 586 | + $this->appendResponse('situacao_historico', $situacaoHistorico); | |
| 587 | + $this->appendResponse('link_to_historico', $linkToHistorico); | |
| 588 | + } | |
| 589 | + } | |
| 590 | + | |
| 591 | + | |
| 592 | + protected function _createHistoricoDisciplinas($fields){ | |
| 593 | + $historicoDisciplina = new clsPmieducarHistoricoDisciplinas( | |
| 594 | + $fields['sequencial'], | |
| 595 | + $fields['alunoId'], | |
| 596 | + $fields['historicoSequencial'], | |
| 597 | + $fields['nome'], | |
| 598 | + $fields['nota'], | |
| 599 | + $fields['falta'] | |
| 600 | + ); | |
| 601 | + $historicoDisciplina->cadastra(); | |
| 602 | + } | |
| 603 | + | |
| 604 | + | |
| 605 | + protected function recreateHistoricoDisciplinas($historicoSequencial, $alunoId){ | |
| 606 | + | |
| 607 | + $this->deleteHistoricoDisplinas($alunoId, $historicoSequencial); | |
| 608 | + | |
| 609 | + if ($this->getRequest()->disciplinas == 'buscar-boletim'){ | |
| 610 | + | |
| 611 | + $cnsNota = RegraAvaliacao_Model_Nota_TipoValor; | |
| 612 | + $tpNota = $this->getService()->getRegra()->get('tipoNota'); | |
| 613 | + $situacaoFaltasCc = $this->getService()->getSituacaoFaltas()->componentesCurriculares; | |
| 614 | + $mediasCc = $this->getService()->getMediasComponentes(); | |
| 615 | + | |
| 616 | + foreach ($this->getService()->getComponentes() as $componenteCurricular) | |
| 617 | + { | |
| 618 | + $ccId = $componenteCurricular->get('id'); | |
| 619 | + $nome = $componenteCurricular->nome; | |
| 620 | + $sequencial = $this->getNextHistoricoDisciplinasSequencial($historicoSequencial, $alunoId); | |
| 621 | + $nota = ''; | |
| 622 | + | |
| 623 | + if ($this->getRequest()->notas == 'buscar-boletim'){ | |
| 624 | + if ($tpNota == $cnsNota::NUMERICA) { | |
| 625 | + $nota = (string)$mediasCc[$ccId][0]->mediaArredondada; | |
| 626 | + } | |
| 627 | + elseif ($tpNota == $cnsNota::CONCEITUAL){ | |
| 628 | + $nota = (string)$mediasCc[$ccId][0]->media; | |
| 629 | + } | |
| 630 | + } | |
| 631 | + else | |
| 632 | + $nota = utf8_decode($this->getRequest()->notas); | |
| 633 | + | |
| 634 | + if(is_numeric($nota)) | |
| 635 | + $nota = sprintf("%.1f", $nota); | |
| 636 | + | |
| 637 | + $this->_createHistoricoDisciplinas(array( | |
| 638 | + "sequencial" => $sequencial, | |
| 639 | + "alunoId" => $alunoId, | |
| 640 | + "historicoSequencial" => $historicoSequencial, | |
| 641 | + "nome" => $nome, | |
| 642 | + "nota" => $nota, | |
| 643 | + "falta" => $this->getFalta($situacaoFaltasCc[$ccId]) | |
| 644 | + )); | |
| 645 | + } | |
| 646 | + } | |
| 647 | + else{ | |
| 648 | + foreach ($this->getRequest()->disciplinas as $disciplina){ | |
| 649 | + $sequencial = $this->getNextHistoricoDisciplinasSequencial($historicoSequencial, $alunoId); | |
| 650 | + | |
| 651 | + $this->_createHistoricoDisciplinas(array( | |
| 652 | + "sequencial" => $sequencial, | |
| 653 | + "alunoId" => $alunoId, | |
| 654 | + "historicoSequencial" => $historicoSequencial, | |
| 655 | + "nome" => utf8_decode($disciplina['nome']), | |
| 656 | + "nota" => utf8_decode($disciplina['nota']), | |
| 657 | + "falta" => $falta = $disciplina['falta'] | |
| 658 | + )); | |
| 659 | + } | |
| 660 | + } | |
| 661 | + } | |
| 662 | + | |
| 663 | + protected function getFalta($situacaoFaltaComponenteCurricular=null){ | |
| 664 | + if ($this->getRequest()->faltas == 'buscar-boletim'){ | |
| 665 | + | |
| 666 | + $cnsPresenca = RegraAvaliacao_Model_TipoPresenca; | |
| 667 | + $tpPresenca = $this->getService()->getRegra()->get('tipoPresenca'); | |
| 668 | + | |
| 669 | + //retorna '' caso não exista situacaoFalta para o componente curricular, | |
| 670 | + //como nos casos em que a regra de avaliação muda | |
| 671 | + if($tpPresenca == $cnsPresenca::POR_COMPONENTE && ! is_null($situacaoFaltaComponenteCurricular)){ | |
| 672 | + $falta = $situacaoFaltaComponenteCurricular->total; | |
| 673 | + } | |
| 674 | + elseif($tpPresenca == $cnsPresenca::POR_COMPONENTE){ | |
| 675 | + $falta = ''; | |
| 676 | + } | |
| 677 | + elseif($tpPresenca == $cnsPresenca::GERAL){ | |
| 678 | + $falta = $this->getService()->getSituacaoFaltas()->totalFaltas; | |
| 679 | + } | |
| 680 | + } | |
| 681 | + else | |
| 682 | + $falta = $this->getRequest()->faltas; | |
| 683 | + | |
| 684 | + return $falta; | |
| 685 | + } | |
| 686 | + | |
| 687 | + | |
| 688 | + protected function getDadosMatricula($matriculaId){ | |
| 689 | + $ano = $this->getAnoMatricula($matriculaId); | |
| 690 | + $sql = "select ref_ref_cod_serie as serie_id, ref_cod_curso as curso_id from pmieducar.matricula | |
| 691 | + where cod_matricula = $1"; | |
| 692 | + | |
| 693 | + $params = array('params' => $matriculaId, 'return_only' => 'first-line'); | |
| 694 | + $idsSerieCurso = Portabilis_Utils_Database::fetchPreparedQuery($sql, $params); | |
| 695 | + | |
| 696 | + $matriculas = array(); | |
| 697 | + | |
| 698 | + $matriculaTurma = new clsPmieducarMatriculaTurma(); | |
| 699 | + $matriculaTurma = $matriculaTurma->lista( | |
| 700 | + $matriculaId, | |
| 701 | + NULL, | |
| 702 | + NULL, | |
| 703 | + NULL, | |
| 704 | + NULL, | |
| 705 | + NULL, | |
| 706 | + NULL, | |
| 707 | + NULL, | |
| 708 | + 1, | |
| 709 | + $idsSerieCurso['serie_id'], | |
| 710 | + $idsSerieCurso['curso_id'] | |
| 711 | + ); | |
| 712 | + | |
| 713 | + $matriculaTurma = $matriculaTurma[0]; | |
| 714 | + | |
| 715 | + $dadosMatricula = array(); | |
| 716 | + if (is_array($matriculaTurma) && count($matriculaTurma) > 0){ | |
| 717 | + $dadosMatricula['ano'] = $ano; | |
| 718 | + $dadosMatricula['instituicao_id'] = $matriculaTurma['ref_cod_instituicao']; | |
| 719 | + $dadosMatricula['escola_id'] = $matriculaTurma['ref_ref_cod_escola']; | |
| 720 | + $dadosMatricula['serie_id'] = $matriculaTurma['ref_ref_cod_serie']; | |
| 721 | + $dadosMatricula['matricula_id'] = $matriculaTurma['ref_cod_matricula']; | |
| 722 | + $dadosMatricula['aluno_id'] = $matriculaTurma['ref_cod_aluno']; | |
| 723 | + $dadosMatricula['nome'] = $this->toUtf8($matriculaTurma['nome_aluno']); | |
| 724 | + $dadosMatricula['nome_curso'] = $this->toUtf8($matriculaTurma['nm_curso']); | |
| 725 | + $dadosMatricula['nome_serie'] = $this->getNomeSerie($matriculaTurma['ref_ref_cod_serie']); | |
| 726 | + $dadosMatricula['nome_turma'] = $this->toUtf8($matriculaTurma['nm_turma']); | |
| 727 | + $dadosMatricula['situacao_historico'] = $this->getSituacaoHistorico($matriculaTurma['ref_cod_aluno'], $ano, $matriculaId); | |
| 728 | + $dadosMatricula['link_to_historico'] = $this->getLinkToHistorico($matriculaTurma['ref_cod_aluno'], $ano, $matriculaId); | |
| 729 | + } | |
| 730 | + else { | |
| 731 | + throw new Exception("Não foi possivel recuperar os dados da matricula: $matriculaId."); | |
| 732 | + } | |
| 733 | + | |
| 734 | + return $dadosMatricula; | |
| 735 | + } | |
| 736 | + | |
| 737 | + | |
| 738 | + protected function getAlunoIdByMatriculaId($matriculaId){ | |
| 739 | + $sql = "select ref_cod_aluno from pmieducar.matricula where cod_matricula = $1"; | |
| 740 | + | |
| 741 | + return Portabilis_Utils_Database::selectField($sql, $matriculaId); | |
| 742 | + } | |
| 743 | + | |
| 744 | + | |
| 745 | + protected function getAnoMatricula($matriculaId){ | |
| 746 | + $sql = "select ano from pmieducar.matricula where cod_matricula = $1"; | |
| 747 | + | |
| 748 | + return Portabilis_Utils_Database::selectField($sql, $matriculaId); | |
| 749 | + } | |
| 750 | + | |
| 751 | + | |
| 752 | + protected function getNomeSerie($serieId){ | |
| 753 | + $sql = "select nm_serie from pmieducar.serie where cod_serie = $1"; | |
| 754 | + | |
| 755 | + return Portabilis_String_Utils::toLatin1(Portabilis_Utils_Database::selectField($sql, $serieId)); | |
| 756 | + } | |
| 757 | + | |
| 758 | + | |
| 759 | + protected function getSequencial($alunoId, $ano, $matriculaId){ | |
| 760 | + $sql = "select sequencial from pmieducar.historico_escolar where ref_cod_aluno = $1 and ano = $2 | |
| 761 | + and ref_cod_instituicao = $3 and ref_cod_matricula = $4 and ativo = 1 limit 1"; | |
| 762 | + | |
| 763 | + $params = array($alunoId, $ano, $this->getRequest()->instituicao_id, $matriculaId); | |
| 764 | + return Portabilis_Utils_Database::selectField($sql, $params); | |
| 765 | + } | |
| 766 | + | |
| 767 | + | |
| 768 | + protected function existsHistorico($alunoId, $ano, $matriculaId, $ativo = 1, $reload = false){ | |
| 769 | + if(! isset($this->existsHistorico) || $reload){ | |
| 770 | + $sql = "select 1 from pmieducar.historico_escolar where ref_cod_aluno = $1 and ano = $2 | |
| 771 | + and ref_cod_instituicao = $3 and ref_cod_matricula = $4 and ativo = $5"; | |
| 772 | + | |
| 773 | + $params = array($alunoId, $ano, $this->getRequest()->instituicao_id, $matriculaId, $ativo); | |
| 774 | + $this->existsHistorico = Portabilis_Utils_Database::selectField($sql, $params) == 1; | |
| 775 | + } | |
| 776 | + | |
| 777 | + return $this->existsHistorico; | |
| 778 | + } | |
| 779 | + | |
| 780 | + | |
| 781 | + protected function getSituacaoHistorico($alunoId, $ano, $matriculaId, $reload = false){ | |
| 782 | + if ($this->existsHistorico($alunoId, $ano, $matriculaId, 1, $reload)) | |
| 783 | + $situacao = 'Processado'; | |
| 784 | + else | |
| 785 | + $situacao = 'Sem histórico'; | |
| 786 | + | |
| 787 | + return $this->toUtf8($situacao); | |
| 788 | + } | |
| 789 | + | |
| 790 | + | |
| 791 | + protected function getLinkToHistorico($alunoId, $ano, $matriculaId){ | |
| 792 | + $sql = "select sequencial from pmieducar.historico_escolar where ref_cod_aluno = $1 and | |
| 793 | + ano = $2 and ref_cod_instituicao = $3 and ref_cod_matricula = $4 and ativo = 1"; | |
| 794 | + | |
| 795 | + $params = array($alunoId, $ano, $this->getRequest()->instituicao_id, $matriculaId); | |
| 796 | + $sequencial = Portabilis_Utils_DataBase::selectField($sql, $params); | |
| 797 | + | |
| 798 | + if (is_numeric($sequencial)) | |
| 799 | + $link = "/intranet/educar_historico_escolar_det.php?ref_cod_aluno=$alunoId&sequencial=$sequencial"; | |
| 800 | + else | |
| 801 | + $link = ''; | |
| 802 | + | |
| 803 | + return $link; | |
| 804 | + } | |
| 805 | + | |
| 806 | + | |
| 807 | + protected function getMatriculas(){ | |
| 808 | + $matriculas = array(); | |
| 809 | + | |
| 810 | + if ($this->canGetMatriculas()){ | |
| 811 | + | |
| 812 | + | |
| 813 | + $alunos = new clsPmieducarMatriculaTurma(); | |
| 814 | + $alunos->setOrderby('ref_cod_curso, ref_ref_cod_serie, ref_cod_turma, nome'); | |
| 815 | + | |
| 816 | + $alunos = $alunos->lista( | |
| 817 | + $this->getRequest()->matricula_id, | |
| 818 | + $this->getRequest()->turma_id, | |
| 819 | + NULL, | |
| 820 | + NULL, | |
| 821 | + NULL, | |
| 822 | + NULL, | |
| 823 | + NULL, | |
| 824 | + NULL, | |
| 825 | + 1, | |
| 826 | + $this->getRequest()->serie_id, | |
| 827 | + $this->getRequest()->curso_id, | |
| 828 | + $this->getRequest()->escola_id, | |
| 829 | + $this->getRequest()->instituicao_id, | |
| 830 | + $this->getRequest()->aluno_id, | |
| 831 | + NULL, | |
| 832 | + NULL, | |
| 833 | + NULL, | |
| 834 | + NULL, | |
| 835 | + $this->getRequest()->ano, | |
| 836 | + NULL, | |
| 837 | + TRUE, | |
| 838 | + NULL, | |
| 839 | + NULL, | |
| 840 | + TRUE, | |
| 841 | + NULL, | |
| 842 | + NULL, | |
| 843 | + NULL, | |
| 844 | + NULL, | |
| 845 | + NULL, | |
| 846 | + NULL | |
| 847 | + ); | |
| 848 | + | |
| 849 | + | |
| 850 | + if (! is_array($alunos)) | |
| 851 | + $alunos = array(); | |
| 852 | + | |
| 853 | + $situacoesMatricula = array('aprovado' => App_Model_MatriculaSituacao::APROVADO, | |
| 854 | + 'reprovado' => App_Model_MatriculaSituacao::REPROVADO, | |
| 855 | + 'em-andamento' => App_Model_MatriculaSituacao::EM_ANDAMENTO, | |
| 856 | + ); | |
| 857 | + | |
| 858 | + foreach($alunos as $aluno) | |
| 859 | + { | |
| 860 | + | |
| 861 | + $situacaoMatricula = $this->getSituacaoMatricula($aluno['ref_cod_matricula']); | |
| 862 | + | |
| 863 | + if (in_array($situacaoMatricula, $situacoesMatricula)){ | |
| 864 | + $matricula = array(); | |
| 865 | + $matriculaId = $aluno['ref_cod_matricula']; | |
| 866 | + $matricula['matricula_id'] = $matriculaId; | |
| 867 | + $matricula['aluno_id'] = $aluno['ref_cod_aluno']; | |
| 868 | + $matricula['nome'] = $this->toUtf8($aluno['nome_aluno']); | |
| 869 | + $matricula['nome_curso'] = $this->toUtf8($aluno['nm_curso']); | |
| 870 | + $matricula['nome_serie'] = $this->toUtf8($this->getNomeSerie($aluno['ref_ref_cod_serie'])); | |
| 871 | + $matricula['nome_turma'] = $this->toUtf8($aluno['nm_turma']); | |
| 872 | + $matricula['situacao_historico'] = $this->getSituacaoHistorico($aluno['ref_cod_aluno'], $this->getRequest()->ano, $matriculaId, $reload = true); | |
| 873 | + $matricula['link_to_historico'] = $this->getLinkToHistorico($aluno['ref_cod_aluno'], $this->getRequest()->ano, $matriculaId); | |
| 874 | + $matriculas[] = $matricula; | |
| 875 | + } | |
| 876 | + } | |
| 877 | + } | |
| 878 | + | |
| 879 | + return $matriculas; | |
| 880 | + } | |
| 881 | + | |
| 882 | + | |
| 883 | + protected function getObservacaoPadraoSerie(){ | |
| 884 | + if($this->validatesPresenceOfSerieId(false, false)){ | |
| 885 | + $sql = "select coalesce(observacao_historico, '') as observacao_historico from pmieducar.serie | |
| 886 | + where cod_serie = $1"; | |
| 887 | + | |
| 888 | + $observacao = Portabilis_Utils_DataBase::selectField($sql, $this->getRequest()->serie_id); | |
| 889 | + } | |
| 890 | + else | |
| 891 | + $observacao = ''; | |
| 892 | + | |
| 893 | + return $this->toUtf8($observacao); | |
| 894 | + } | |
| 895 | + | |
| 896 | + | |
| 897 | + protected function saveService() | |
| 898 | + { | |
| 899 | + try { | |
| 900 | + $this->getService()->save(); | |
| 901 | + } | |
| 902 | + catch (CoreExt_Service_Exception $e){ | |
| 903 | + //excecoes ignoradas :( servico lanca excecoes de alertas, que não são exatamente erros. | |
| 904 | + //error_log('CoreExt_Service_Exception ignorada: ' . $e->getMessage()); | |
| 905 | + } | |
| 906 | + } | |
| 907 | + | |
| 908 | + protected function getService($raiseExceptionOnErrors = false, $appendMsgOnErrors = true){ | |
| 909 | + if (isset($this->service) && ! is_null($this->service)) | |
| 910 | + return $this->service; | |
| 911 | + | |
| 912 | + $msg = 'Erro ao recuperar serviço boletim: serviço não definido.'; | |
| 913 | + if($appendMsgOnErrors) | |
| 914 | + $this->appendMsg($msg); | |
| 915 | + | |
| 916 | + if ($raiseExceptionOnErrors) | |
| 917 | + throw new Exception($msg); | |
| 918 | + | |
| 919 | + return null; | |
| 920 | + } | |
| 921 | + | |
| 922 | + protected function canSetService($validatesPresenceOfMatriculaId = true) | |
| 923 | + { | |
| 924 | + try { | |
| 925 | + $this->requiresLogin(true); | |
| 926 | + if ($validatesPresenceOfMatriculaId) | |
| 927 | + $this->validatesPresenceOfMatriculaId(true); | |
| 928 | + } | |
| 929 | + catch (Exception $e){ | |
| 930 | + return false; | |
| 931 | + } | |
| 932 | + return true; | |
| 933 | + } | |
| 934 | + | |
| 935 | + protected function setService($matriculaId = null){ | |
| 936 | + if ($this->canSetService($validatesPresenceOfMatriculaId = is_null($matriculaId))){ | |
| 937 | + try { | |
| 938 | + | |
| 939 | + if (! $matriculaId) | |
| 940 | + $matriculaId = $this->getRequest()->matricula_id; | |
| 941 | + | |
| 942 | + $this->service = new Avaliacao_Service_Boletim(array( | |
| 943 | + 'matricula' => $matriculaId, | |
| 944 | + 'usuario' => $this->getSession()->id_pessoa | |
| 945 | + )); | |
| 946 | + | |
| 947 | + return true; | |
| 948 | + } | |
| 949 | + catch (Exception $e){ | |
| 950 | + $this->appendMsg('Exception ao instanciar serviço boletim: ' . $e->getMessage(), 'error', $encodeToUtf8 = true); | |
| 951 | + } | |
| 952 | + } | |
| 953 | + return false; | |
| 954 | + } | |
| 955 | + | |
| 956 | + | |
| 957 | + protected function notImplementedError() | |
| 958 | + { | |
| 959 | + $this->appendMsg("Operação '{$this->getRequest()->oper}' inválida para o att '{$this->getRequest()->att}'"); | |
| 960 | + } | |
| 961 | + | |
| 962 | + | |
| 963 | + public function Gerar(){ | |
| 964 | + $this->msgs = array(); | |
| 965 | + $this->response = array(); | |
| 966 | + | |
| 967 | + if ($this->canAcceptRequest()){ | |
| 968 | + try { | |
| 969 | + | |
| 970 | + if(isset($this->getRequest()->matricula_id)) | |
| 971 | + $this->appendResponse('matricula_id', $this->getRequest()->matricula_id); | |
| 972 | + | |
| 973 | + if ($this->getRequest()->oper == 'get') | |
| 974 | + { | |
| 975 | + if ($this->getRequest()->att == 'matriculas') | |
| 976 | + { | |
| 977 | + $matriculas = $this->getMatriculas(); | |
| 978 | + $this->appendResponse('matriculas', $matriculas); | |
| 979 | + $this->appendResponse('observacao_padrao', $this->getObservacaoPadraoSerie()); | |
| 980 | + } | |
| 981 | + else | |
| 982 | + $this->notImplementedError(); | |
| 983 | + | |
| 984 | + } | |
| 985 | + elseif ($this->getRequest()->oper == 'post') | |
| 986 | + { | |
| 987 | + if ($this->getRequest()->att == 'processamento') | |
| 988 | + { | |
| 989 | + $this->postProcessamento(); | |
| 990 | + } | |
| 991 | + else | |
| 992 | + $this->notImplementedError(); | |
| 993 | + } | |
| 994 | + elseif ($this->getRequest()->oper == 'delete') | |
| 995 | + { | |
| 996 | + if ($this->getRequest()->att == 'historico') | |
| 997 | + { | |
| 998 | + $this->deleteHistorico(); | |
| 999 | + } | |
| 1000 | + else | |
| 1001 | + $this->notImplementedError(); | |
| 1002 | + } | |
| 1003 | + } | |
| 1004 | + catch (Exception $e){ | |
| 1005 | + $this->appendMsg('Exception: ' . $e->getMessage(), $type = 'error', $encodeToUtf8 = true); | |
| 1006 | + } | |
| 1007 | + } | |
| 1008 | + echo $this->prepareResponse(); | |
| 1009 | + } | |
| 1010 | + | |
| 1011 | + protected function appendResponse($name, $value){ | |
| 1012 | + $this->response[$name] = $value; | |
| 1013 | + } | |
| 1014 | + | |
| 1015 | + protected function prepareResponse(){ | |
| 1016 | + $msgs = array(); | |
| 1017 | + $this->appendResponse('att', isset($this->getRequest()->att) ? $this->getRequest()->att : ''); | |
| 1018 | + | |
| 1019 | + foreach($this->msgs as $m) | |
| 1020 | + $msgs[] = array('msg' => $m['msg'], 'type' => $m['type']); | |
| 1021 | + $this->appendResponse('msgs', $msgs); | |
| 1022 | + | |
| 1023 | + echo json_encode($this->response); | |
| 1024 | + } | |
| 1025 | + | |
| 1026 | + protected function appendMsg($msg, $type="error", $encodeToUtf8 = false){ | |
| 1027 | + if ($encodeToUtf8) | |
| 1028 | + $msg = utf8_encode($msg); | |
| 1029 | + | |
| 1030 | + //error_log("$type msg: '$msg'"); | |
| 1031 | + $this->msgs[] = array('msg' => $msg, 'type' => $type); | |
| 1032 | + } | |
| 1033 | + | |
| 1034 | + public function generate(CoreExt_Controller_Page_Interface $instance){ | |
| 1035 | + header('Content-type: application/json'); | |
| 1036 | + $instance->Gerar(); | |
| 1037 | + } | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + // TODO remover metodo, ao migrar esta classe para novo padrao | |
| 1041 | + | |
| 1042 | + protected function toUtf8($str, $options = array()) { | |
| 1043 | + return Portabilis_String_Utils::toUtf8($str, $options); | |
| 1044 | + } | |
| 1045 | +} | ... | ... |
ieducar/modules/HistoricoEscolar/Views/ProcessamentoController.php
0 → 100644
| ... | ... | @@ -0,0 +1,210 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +#error_reporting(E_ALL); | |
| 4 | +#ini_set("display_errors", 1); | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * i-Educar - Sistema de gestão escolar | |
| 8 | + * | |
| 9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 10 | + * <ctima@itajai.sc.gov.br> | |
| 11 | + * | |
| 12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 15 | + * qualquer versão posterior. | |
| 16 | + * | |
| 17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 20 | + * do GNU para mais detalhes. | |
| 21 | + * | |
| 22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
| 23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
| 24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 25 | + * | |
| 26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
| 27 | + * @category i-Educar | |
| 28 | + * @license @@license@@ | |
| 29 | + * @package Avaliacao | |
| 30 | + * @subpackage Modules | |
| 31 | + * @since Arquivo disponível desde a versão ? | |
| 32 | + * @version $Id$ | |
| 33 | + */ | |
| 34 | + | |
| 35 | +require_once 'Portabilis/Controller/Page/ListController.php'; | |
| 36 | + | |
| 37 | +class ProcessamentoController extends Portabilis_Controller_Page_ListController | |
| 38 | +{ | |
| 39 | + protected $_dataMapper = 'Avaliacao_Model_NotaAlunoDataMapper'; | |
| 40 | + protected $_titulo = 'Processamento histórico'; | |
| 41 | + protected $_processoAp = 999613; | |
| 42 | + protected $_formMap = array(); | |
| 43 | + | |
| 44 | + // #TODO migrar funcionalidade para novo padrão | |
| 45 | + protected $backwardCompatibility = true; | |
| 46 | + | |
| 47 | + public function Gerar() | |
| 48 | + { | |
| 49 | + Portabilis_View_Helper_Application::loadStylesheet($this, '/modules/HistoricoEscolar/Static/styles/processamento.css'); | |
| 50 | + | |
| 51 | + $this->inputsHelper()->dynamic(array('ano', 'instituicao', 'escola')); | |
| 52 | + $this->inputsHelper()->dynamic(array('curso', 'serie', 'turma', 'matricula'), array('required' => false)); | |
| 53 | + | |
| 54 | + $resourceOptionsTable = "<table id='resource-options' class='styled horizontal-expand hide-on-search disable-on-apply-changes'> | |
| 55 | + | |
| 56 | + <tr> | |
| 57 | + <td><label for='dias-letivos'>Quantidade dias letivos *</label></td> | |
| 58 | + <td colspan='2'><input type='text' id='dias-letivos' name='quantidade-dias-letivos' class='obrigatorio disable-on-search clear-on-change-curso validates-value-is-numeric'></input></td> | |
| 59 | + </tr> | |
| 60 | + | |
| 61 | + <tr> | |
| 62 | + <td><label for='grade-curso'>Grade curso *</label></td> | |
| 63 | + <td>{$this->getSelectGradeCurso()}</td> | |
| 64 | + </tr> | |
| 65 | + | |
| 66 | + <tr> | |
| 67 | + <td><label for='percentual-frequencia'>% Frequência *</label></td> | |
| 68 | + <td> | |
| 69 | + <select id='percentual-frequencia' class='obrigatorio disable-on-search'> | |
| 70 | + <option value=''>Selecione</option> | |
| 71 | + <option value='buscar-boletim'>Usar do boletim</option> | |
| 72 | + <option value='informar-manualmente'>Informar manualmente</option> | |
| 73 | + </select> | |
| 74 | + </td> | |
| 75 | + <td><input id='percentual-frequencia-manual' name='percentual-frequencia-manual' style='display:none;'></input></td> | |
| 76 | + </tr> | |
| 77 | + | |
| 78 | + <tr> | |
| 79 | + <td><label for='situacao'>Situação *</label></td> | |
| 80 | + <td colspan='2'> | |
| 81 | + <select id='situacao' class='obrigatorio disable-on-search'> | |
| 82 | + <option value=''>Selecione</option> | |
| 83 | + <option value='buscar-matricula'>Usar do boletim</option> | |
| 84 | + <option value='em-andamento'>Em andamento</option> | |
| 85 | + <option value='aprovado'>Aprovado</option> | |
| 86 | + <option value='reprovado'>Reprovado</option> | |
| 87 | + <option value='transferido'>Transferido</option> | |
| 88 | + </select> | |
| 89 | + </td> | |
| 90 | + </tr> | |
| 91 | + | |
| 92 | + <tr> | |
| 93 | + <td><label for='disciplinas'>Disciplinas *</label></td> | |
| 94 | + <td> | |
| 95 | + <select id='disciplinas' name='disciplinas' class='obrigatorio disable-on-search'> | |
| 96 | + <option value=''>Selecione</option> | |
| 97 | + <option value='buscar-boletim'>Usar do boletim</option> | |
| 98 | + <option value='informar-manualmente'>Informar manualmente</option> | |
| 99 | + </select> | |
| 100 | + </td> | |
| 101 | + <td> | |
| 102 | + <table id='disciplinas-manual' style='display:none;'> | |
| 103 | + <tr> | |
| 104 | + <th>Nome</th> | |
| 105 | + <th>Nota</th> | |
| 106 | + <th>Falta</th> | |
| 107 | + <th>Ação</th> | |
| 108 | + </tr> | |
| 109 | + <tr class='disciplina'> | |
| 110 | + <td><input class='nome obrigatorio disable-on-search change-state-with-parent' style='display:none;'></input></td> | |
| 111 | + <td><input class='nota' ></input></td> | |
| 112 | + <td> | |
| 113 | + <input class='falta validates-value-is-numeric'></input> | |
| 114 | + </td> | |
| 115 | + <td> | |
| 116 | + <a class='remove-disciplina-line' href='#'>Remover</a> | |
| 117 | + </td> | |
| 118 | + </tr> | |
| 119 | + <tr class='actions'> | |
| 120 | + <td colspan='4'> | |
| 121 | + <input type='button' class='action' id='new-disciplina-line' name='new-line' value='Adicionar nova'></input> | |
| 122 | + </td> | |
| 123 | + </tr> | |
| 124 | + </table> | |
| 125 | + </td> | |
| 126 | + </tr> | |
| 127 | + | |
| 128 | + <tr> | |
| 129 | + <td><label for='notas'>Notas *</label></td> | |
| 130 | + <td> | |
| 131 | + <select id='notas' class='obrigatorio disable-on-search disable-and-hide-wen-disciplinas-manual'> | |
| 132 | + <option value=''>Selecione</option> | |
| 133 | + <option value='buscar-boletim'>Lançadas no boletim</option> | |
| 134 | + <option value='AP'>AP</option> | |
| 135 | + <option value='informar-manualmente'>Informar manualmente</option> | |
| 136 | + </select> | |
| 137 | + </td> | |
| 138 | + <td><input id='notas-manual' name='notas-manual' style='display:none;'></input></td> | |
| 139 | + </tr> | |
| 140 | + | |
| 141 | + <tr> | |
| 142 | + <td><label for='faltas'>Faltas *</label></td> | |
| 143 | + <td> | |
| 144 | + <select id='faltas' class='obrigatorio disable-on-search disable-and-hide-wen-disciplinas-manual'> | |
| 145 | + <option value=''>Selecione</option> | |
| 146 | + <option value='buscar-boletim'>Lançadas no boletim</option> | |
| 147 | + <option value='informar-manualmente'>Informar manualmente</option> | |
| 148 | + </select> | |
| 149 | + </td> | |
| 150 | + <td><input id='faltas-manual' name='faltas-manual' style='display:none;'></input></td> | |
| 151 | + </tr> | |
| 152 | + | |
| 153 | + <tr> | |
| 154 | + <td><label for='registro'>Registro (arquivo)</label></td> | |
| 155 | + <td colspan='2'><input type='text' id='registro' name='registro'></input></td> | |
| 156 | + </tr> | |
| 157 | + | |
| 158 | + <tr> | |
| 159 | + <td><label for='livro'>Livro</label></td> | |
| 160 | + <td colspan='2'><input type='text' id='livro' name='livro'></input></td> | |
| 161 | + </tr> | |
| 162 | + | |
| 163 | + <tr> | |
| 164 | + <td><label for='dias-letivos'>Folha</label></td> | |
| 165 | + <td colspan='2'><input type='text' id='folha' name='folha'></input></td> | |
| 166 | + </tr> | |
| 167 | + | |
| 168 | + <tr> | |
| 169 | + <td><label for='observacao'>Observação</label></td> | |
| 170 | + <td colspan='2'><textarea id='observacao' name='observacao' cols='60' rows='5'></textarea></td> | |
| 171 | + </tr> | |
| 172 | + | |
| 173 | + <tr> | |
| 174 | + <td><label for='extra-curricular'>Extra curricular</label></td> | |
| 175 | + <td colspan='2'><input type='checkbox' id='extra-curricular' name='extra-curricular'></input></td> | |
| 176 | + </tr> | |
| 177 | + | |
| 178 | + </table>"; | |
| 179 | + | |
| 180 | + | |
| 181 | + $this->appendOutput($resourceOptionsTable); | |
| 182 | + | |
| 183 | + Portabilis_View_Helper_Application::loadJQueryUiLib($this); | |
| 184 | + | |
| 185 | + Portabilis_View_Helper_Application::loadJavascript( | |
| 186 | + $this, | |
| 187 | + array('/modules/Portabilis/Assets/Javascripts/Utils.js', | |
| 188 | + '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js', | |
| 189 | + '/modules/HistoricoEscolar/Static/scripts/processamento.js') | |
| 190 | + ); | |
| 191 | + } | |
| 192 | + | |
| 193 | + function getSelectGradeCurso(){ | |
| 194 | + $db = new clsBanco(); | |
| 195 | + $sql = "select * from pmieducar.historico_grade_curso where ativo = 1"; | |
| 196 | + $db->Consulta($sql); | |
| 197 | + | |
| 198 | + $select = "<select id='grade-curso' class='obrigatorio disable-on-search clear-on-change-curso'>"; | |
| 199 | + $select .= "<option value=''>Selecione</option>"; | |
| 200 | + | |
| 201 | + while ($db->ProximoRegistro()){ | |
| 202 | + $record = $db->Tupla(); | |
| 203 | + $select .= "<option value='{$record['id']}'>{$record['descricao_etapa']}</option>"; | |
| 204 | + } | |
| 205 | + | |
| 206 | + $select .= '</select>'; | |
| 207 | + return $select; | |
| 208 | + } | |
| 209 | +} | |
| 210 | +?> | |
| 0 | 211 | \ No newline at end of file | ... | ... |