Commit 9ccca106b9ffc0d0bf8e552432df65b7e397e125

Authored by Eriksen Costa Paixão
1 parent de6fdef1
Exists in master

Atualizado CRUD de Servidores:

 * Cadastro de servidor agora depende de {{{ComponenteCurricular_Model_Componente}}} quando este possui uma função de professor e tem componentes curriculares atribuídos a ele (anteriormente, disciplinas)
 * Corrigido bug que apagava as disciplinas/cursos de um servidor quando seu cadastro era editado (para função de professor)
 * SQL de listagem de servidores (em {{{clsPmieducarServidor::lista()}}} modificado para o caso de professor (quando flag {{{$boo_professor}}} != FALSE}}}), selecionando apenas um professor candidato que lecione os mesmos componentes curriculares nos mesmos cursos. Outras correções lógicas realizadas
 * Atualizado arquivo SQL de instalação, com novo delta criado (delta 17)
   * Alterações no schema de {{{pmieducar.servidor_disciplina}}} para refletir o novo schema de componentes curriculares, onde cada componente pode ser atribuído a diversos anos/séries escolares (anteriormente era uma relação 1-1):
     * Campo {{{ref_cod_curso}}} adicionado
     * ''Primary key'' atualizada para englobar o campo {{{ref_cod_curso}}}
ieducar/intranet/educar_disciplina_xml.php
... ... @@ -25,10 +25,10 @@
25 25 * @license @@license@@
26 26 * @package iEd_Pmieducar
27 27 * @since Arquivo disponível desde a versão 1.0.0
28   - * @version $Id: /ieducar/branches/1.1.0-avaliacao/ieducar/intranet/educar_disciplina_xml.php 1021 2009-12-20T22:17:05.346011Z eriksencosta $
  28 + * @version $Id$
29 29 */
30 30  
31   -header( 'Content-type: text/xml; charset=ISO-8859-1');
  31 +header('Content-type: text/xml; charset=ISO-8859-1');
32 32  
33 33 require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/funcoes.inc.php';
... ...
ieducar/intranet/educar_pesquisa_servidor_lst.php
... ... @@ -193,7 +193,7 @@ class indice extends clsListagem
193 193  
194 194 $hora_inicial_ = explode(':', $_SESSION['hora_inicial']);
195 195 $hora_final_ = explode(':', $_SESSION['hora_final']);
196   - $horas_ini = sprintf('%02d', (int) abs($hora_final_[0]) - abs($hora_inicial_[0]));
  196 + $horas_ini = sprintf('%02d', (int) abs($hora_final_[0]) - abs($hora_inicial_[0]));
197 197 $minutos_ini = sprintf('%02d', (int) abs($hora_final_[1]) - abs($hora_inicial_[1]));
198 198  
199 199 $h_m_ini = ($hora_inicial_[0] * 60) + $hora_inicial_[1];
... ... @@ -246,7 +246,7 @@ class indice extends clsListagem
246 246 // aos professores e não selecionar aqueles em que o curso não seja
247 247 // globalizado e sem disciplinas cadastradas
248 248 $this->ref_cod_disciplina = $this->ref_cod_disciplina ?
249   - $this->ref_cod_disciplina : "NULL";
  249 + $this->ref_cod_disciplina : NULL;
250 250  
251 251 // Passa NULL para $alocacao_escola_instituicao senão o seu filtro anula
252 252 // um anterior (referente a selecionar somente servidores não alocados),
... ... @@ -331,10 +331,10 @@ class indice extends clsListagem
331 331 if ($_SESSION['tipo']) {
332 332 if (is_string($_SESSION['campo1']) && is_string($_SESSION['campo2'])) {
333 333 if (is_string( $_SESSION['horario'])) {
334   - $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}','{$registro['nome']}'); addVal1('{$_SESSION['campo2']}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
  334 + $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['nome']}','{$registro['cod_servidor']}'); addVal1('{$_SESSION['campo2']}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
335 335 }
336 336 else {
337   - $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}',null); addVal1('{$_SESSION['campo2']}','{$registro['nome']}',null); $setAll fecha();\"";
  337 + $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}', null); addVal1('{$_SESSION['campo2']}','{$registro['nome']}', null); $setAll fecha();\"";
338 338 }
339 339 }
340 340 elseif (is_string($_SESSION['campo1'])) {
... ... @@ -386,9 +386,9 @@ function addVal1(campo, valor, opcao)
386 386 {
387 387 if (window.parent.document.getElementById(campo)) {
388 388 if (window.parent.document.getElementById(campo).type == 'select-one') {
389   - obj = window.parent.document.getElementById( campo );
  389 + obj = window.parent.document.getElementById(campo);
390 390 novoIndice = obj.options.length;
391   - obj.options[novoIndice] = new Option( opcao );
  391 + obj.options[novoIndice] = new Option(opcao);
392 392 opcao = obj.options[novoIndice];
393 393 opcao.value = valor;
394 394 opcao.selected = true;
... ... @@ -396,7 +396,7 @@ function addVal1(campo, valor, opcao)
396 396 }
397 397 else if (window.parent.document.getElementById(campo)) {
398 398 obj = window.parent.document.getElementById(campo);
399   - obj.value = valor;
  399 + obj.value = opcao;
400 400 }
401 401 }
402 402 }
... ... @@ -424,7 +424,7 @@ function clearAll()
424 424 }
425 425  
426 426 for (var ct =0;ct < num_alocacao;ct++) {
427   - var elements = window.parent.document.getElementById('ref_cod_servidor_substituto_' + ct).value='';
  427 + var elements = window.parent.document.getElementById('ref_cod_servidor_substituto_' + ct).value='';
428 428 }
429 429 }
430 430  
... ...
ieducar/intranet/educar_servidor_cad.php
1 1 <?php
2 2  
3   -/*
4   - * i-Educar - Sistema de gestão de escolas
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
5 5 *
6   - * Copyright (c) 2006 Prefeitura Municipal de Itajaí
7   - * <ctima@itajai.sc.gov.br>
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
8 8 *
9   - * Este programa é software livre; você pode redistribuÃí-lo e/ou modificá-lo
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
10 10 * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
11 11 * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
12 12 * qualquer versão posterior.
... ... @@ -19,16 +19,13 @@
19 19 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
20 20 * com este programa; se não, escreva para a Free Software Foundation, Inc., no
21 21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22   - */
23   -
24   -/**
25   - * Formulário de cadastro de servidor
26 22 *
27   - * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
28   - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
29   - * @package Core
30   - * @since Arquivo disponível desde a versão 1.0.0
31   - * @version $Id$
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
32 29 */
33 30  
34 31 require_once 'include/clsBase.inc.php';
... ... @@ -36,14 +33,35 @@ require_once &#39;include/clsCadastro.inc.php&#39;;
36 33 require_once 'include/clsBanco.inc.php';
37 34 require_once 'include/pmieducar/geral.inc.php';
38 35  
39   -
40   -class clsIndexBase extends clsBase {
41   - public function Formular() {
42   - $this->SetTitulo($this->_instituicao . " i-Educar - Servidor");
43   - $this->processoAp = "635";
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
  46 +class clsIndexBase extends clsBase
  47 +{
  48 + function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor');
  51 + $this->processoAp = 635;
44 52 }
45 53 }
46 54  
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
47 65 class indice extends clsCadastro
48 66 {
49 67 var $pessoa_logada;
... ... @@ -98,14 +116,14 @@ class indice extends clsCadastro
98 116 }
99 117  
100 118 $db = new clsBanco();
101   - $consulta = "
  119 + $consulta = sprintf("
102 120 SELECT
103 121 SUBSTR(COALESCE(SUM(carga_horaria), '00:00'), 0, 6) AS horas_utilizadas
104 122 FROM
105 123 pmieducar.servidor_alocacao
106 124 WHERE
107   - ref_cod_servidor = '{$this->cod_servidor}' AND
108   - ativo = 1";
  125 + ref_cod_servidor = '%d' AND
  126 + ativo = 1", $this->cod_servidor);
109 127  
110 128 $this->total_horas_alocadas = $db->CampoUnico($consulta);
111 129  
... ... @@ -247,15 +265,15 @@ class indice extends clsCadastro
247 265 }
248 266  
249 267 $this->campoTabelaInicio('funcao', 'Funções Servidor',
250   - array("Função", "Disciplinas", "Cursos"), ($this->ref_cod_funcao));
  268 + array("Função", "Componentes Curriculares", "Cursos"), ($this->ref_cod_funcao));
251 269  
252 270 $funcao = 'popless()';
253 271  
254 272 $this->campoLista('ref_cod_funcao', 'Função', $opcoes, $this->ref_cod_funcao,
255 273 'funcaoChange(this)', '', '', '');
256 274  
257   - $this->campoRotulo('disciplina', 'Disciplinas',
258   - "<img src='imagens/lupa_antiga.png' border='0' style='cursor:pointer;' alt='Buscar Disciplina' title='Buscar Disciplina' onclick=\"$funcao\">");
  275 + $this->campoRotulo('disciplina', 'Componentes Curriculares',
  276 + "<img src='imagens/lupa_antiga.png' border='0' style='cursor:pointer;' alt='Buscar Componente Curricular' title='Buscar Componente Curricular' onclick=\"$funcao\">");
259 277  
260 278 $funcao = 'popCurso()';
261 279  
... ... @@ -301,7 +319,9 @@ class indice extends clsCadastro
301 319 $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3,
302 320 'educar_servidor_lst.php');
303 321  
304   - $obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_instituicao );
  322 + $obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL, NULL,
  323 + NULL, NULL, $this->ref_cod_instituicao);
  324 +
305 325 if ($obj->detalhe()) {
306 326 $this->carga_horaria = str_replace(',', '.', $this->carga_horaria);
307 327 $obj = new clsPmieducarServidor($this->cod_servidor,
... ... @@ -361,8 +381,10 @@ class indice extends clsCadastro
361 381  
362 382 if ($this->ref_cod_instituicao == $this->ref_cod_instituicao_original) {
363 383 $this->carga_horaria = str_replace(',', '.', $this->carga_horaria);
  384 +
364 385 $obj = new clsPmieducarServidor($this->cod_servidor, $this->ref_cod_deficiencia,
365 386 $this->ref_idesco, $this->carga_horaria, NULL, NULL, 1, $this->ref_cod_instituicao);
  387 +
366 388 $editou = $obj->edita();
367 389  
368 390 if ($editou) {
... ... @@ -483,15 +505,13 @@ class indice extends clsCadastro
483 505 {
484 506 @session_start();
485 507 $cursos_disciplina = $_SESSION['cursos_disciplina'];
486   - $cursos_servidor = $_SESSION['cursos_servidor'];
  508 + $cursos_servidor = $_SESSION['cursos_servidor'];
487 509 @session_write_close();
488 510  
489   - $this->excluiFuncoes();
490   - $this->excluiCursos();
491   -
492 511 $existe_funcao_professor = FALSE;
493 512  
494 513 if ($this->ref_cod_funcao) {
  514 + $this->excluiFuncoes();
495 515 foreach ($this->ref_cod_funcao as $funcao) {
496 516 $funcao_professor = explode('-', $funcao);
497 517 $funcao = array_shift($funcao_professor);
... ... @@ -511,11 +531,13 @@ class indice extends clsCadastro
511 531  
512 532 if ($existe_funcao_professor) {
513 533 if ($cursos_disciplina) {
  534 + $this->excluiDisciplinas();
514 535 foreach ($cursos_disciplina as $curso => $disciplinas) {
515 536 if ($disciplinas) {
516 537 foreach ($disciplinas as $disciplina) {
517 538 $obj_servidor_disciplina = new clsPmieducarServidorDisciplina(
518   - $disciplina, $this->ref_cod_instituicao, $this->cod_servidor);
  539 + $disciplina, $this->ref_cod_instituicao, $this->cod_servidor,
  540 + $curso);
519 541  
520 542 if (!$obj_servidor_disciplina->existe()) {
521 543 $obj_servidor_disciplina->cadastra();
... ... @@ -526,6 +548,7 @@ class indice extends clsCadastro
526 548 }
527 549  
528 550 if ($cursos_servidor) {
  551 + $this->excluiCursos();
529 552 foreach ($cursos_servidor as $curso) {
530 553 $obj_curso_servidor = new clsPmieducarServidorCursoMinistra($curso,
531 554 $this->ref_cod_instituicao, $this->cod_servidor);
... ... @@ -540,17 +563,20 @@ class indice extends clsCadastro
540 563  
541 564 function excluiFuncoes()
542 565 {
543   - $obj_servidor_disciplina = new clsPmieducarServidorDisciplina(NULL,
544   - $this->ref_cod_instituicao,$this->cod_servidor);
545   -
546   - $obj_servidor_disciplina->excluirTodos();
547   -
548 566 $obj_servidor_funcao = new clsPmieducarServidorFuncao($this->ref_cod_instituicao,
549 567 $this->cod_servidor);
550 568  
551 569 $obj_servidor_funcao->excluirTodos();
552 570 }
553 571  
  572 + function excluiDisciplinas()
  573 + {
  574 + $obj_servidor_disciplina = new clsPmieducarServidorDisciplina(NULL,
  575 + $this->ref_cod_instituicao, $this->cod_servidor);
  576 +
  577 + $obj_servidor_disciplina->excluirTodos();
  578 + }
  579 +
554 580 function excluiCursos()
555 581 {
556 582 $obj_servidor_curso = new clsPmieducarServidorCursoMinistra(NULL,
... ... @@ -577,7 +603,8 @@ $pagina-&gt;MakeAll();
577 603 /**
578 604 * Carrega as opções de um campo select de funções via Ajax
579 605 */
580   -function getFuncao(id_campo) {
  606 +function getFuncao(id_campo)
  607 +{
581 608 var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
582 609 var campoFuncao = document.getElementById(id_campo);
583 610 campoFuncao.length = 1;
... ... @@ -598,7 +625,8 @@ function getFuncao(id_campo) {
598 625 * Parse de resultado da chamada Ajax de getFuncao(). Adiciona cada item
599 626 * retornado como option do select
600 627 */
601   -function atualizaLstFuncao(xml) {
  628 +function atualizaLstFuncao(xml)
  629 +{
602 630 var campoFuncao = document.getElementById(arguments[1]);
603 631  
604 632 campoFuncao.length = 1;
... ... @@ -628,7 +656,8 @@ function atualizaLstFuncao(xml) {
628 656 *
629 657 * É um toggle on/off
630 658 */
631   -function funcaoChange(campo) {
  659 +function funcaoChange(campo)
  660 +{
632 661 var valor = campo.value.split("-");
633 662 var id = /[0-9]+/.exec(campo.id)[0];
634 663 var professor = (valor[1] == true);
... ... @@ -711,7 +740,8 @@ function getArrayHora(hora) {
711 740 return array_h;
712 741 }
713 742  
714   -function acao2() {
  743 +function acao2()
  744 +{
715 745 var total_horas_alocadas = getArrayHora(document.getElementById('total_horas_alocadas').value);
716 746 var carga_horaria = (document.getElementById('carga_horaria').value).replace(',', '.');
717 747  
... ... @@ -730,19 +760,22 @@ if (document.getElementById(&#39;total_horas_alocadas&#39;)) {
730 760 }
731 761  
732 762  
733   -function popless() {
  763 +function popless()
  764 +{
734 765 var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
735 766 var campoServidor = document.getElementById('cod_servidor').value;
736 767 pesquisa_valores_popless1('educar_servidor_disciplina_lst.php?ref_cod_servidor='+campoServidor+'&ref_cod_instituicao='+campoInstituicao, '');
737 768 }
738 769  
739   -function popCurso() {
  770 +function popCurso()
  771 +{
740 772 var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
741 773 var campoServidor = document.getElementById('cod_servidor').value;
742 774 pesquisa_valores_popless('educar_servidor_curso_lst.php?ref_cod_servidor='+campoServidor+'&ref_cod_instituicao='+campoInstituicao, '');
743 775 }
744 776  
745   -function pesquisa_valores_popless1(caminho, campo) {
  777 +function pesquisa_valores_popless1(caminho, campo)
  778 +{
746 779 new_id = DOM_divs.length;
747 780 div = 'div_dinamico_' + new_id;
748 781 if (caminho.indexOf('?') == -1) {
... ...
ieducar/intranet/educar_servidor_det.php
1 1 <?php
2 2  
3   -/*
  3 +/**
4 4 * i-Educar - Sistema de gestão escolar
5 5 *
6 6 * Copyright (C) 2006 Prefeitura Municipal de Itajaí
... ... @@ -19,45 +19,57 @@
19 19 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
20 20 * com este programa; se não, escreva para a Free Software Foundation, Inc., no
21 21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22   - */
23   -
24   -/**
25   - * Mostra detalhes do cadastro de um servidor junto com ações de cadastro
26 22 *
27   - * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
28   - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
29   - * @package Core
30   - * @subpackage Servidor
31   - * @since Disponível desde a versão 1.0.0
32   - * @version $Id$
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
33 29 */
34 30  
35 31 require_once 'include/clsBase.inc.php';
36 32 require_once 'include/clsDetalhe.inc.php';
37 33 require_once 'include/clsBanco.inc.php';
38 34 require_once 'include/pmieducar/geral.inc.php';
  35 +require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
39 36  
40   -
  37 +/**
  38 + * clsIndexBase class.
  39 + *
  40 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  41 + * @category i-Educar
  42 + * @license @@license@@
  43 + * @package iEd_Pmieducar
  44 + * @since Classe disponível desde a versão 1.0.0
  45 + * @version @@package_version@@
  46 + */
41 47 class clsIndexBase extends clsBase {
42   - public function Formular() {
  48 + function Formular()
  49 + {
43 50 $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor');
44   - $this->processoAp = '635';
  51 + $this->processoAp = 635;
45 52 }
46 53 }
47 54  
48   -
49   -class indice extends clsDetalhe {
50   -
51   - /**
52   - * Título da página
53   - * @var string
54   - */
55   - public $titulo;
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
  65 +class indice extends clsDetalhe
  66 +{
  67 + var $titulo;
56 68  
57 69 /**
58 70 * Atributos de dados
59 71 */
60   - public
  72 + var
61 73 $cod_servidor = NULL,
62 74 $ref_cod_deficiencia = NULL,
63 75 $ref_idesco = NULL,
... ... @@ -69,23 +81,25 @@ class indice extends clsDetalhe {
69 81 $ref_cod_instituicao = NULL,
70 82 $alocacao_array = array();
71 83  
72   -
73   -
74 84 /**
75 85 * Implementação do método Gerar()
76 86 */
77   - public function Gerar() {
  87 + function Gerar()
  88 + {
78 89 session_start();
79 90 $this->pessoa_logada = $_SESSION['id_pessoa'];
80 91 session_write_close();
81 92  
82 93 $this->titulo = 'Servidor - Detalhe';
83   - $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
  94 + $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg',
  95 + 'Intranet');
  96 +
  97 + $this->cod_servidor = $_GET['cod_servidor'];
  98 + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao'];
84 99  
85   - $this->cod_servidor = $_GET["cod_servidor"];
86   - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"];
  100 + $tmp_obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL,
  101 + NULL, NULL, NULL, $this->ref_cod_instituicao);
87 102  
88   - $tmp_obj = new clsPmieducarServidor( $this->cod_servidor,null,null,null,null,null,null,$this->ref_cod_instituicao );
89 103 $registro = $tmp_obj->detalhe();
90 104  
91 105 if (!$registro) {
... ... @@ -126,7 +140,7 @@ class indice extends clsDetalhe {
126 140 $obj = new clsPmieducarServidorAlocacao();
127 141 $obj->setOrderby('periodo, carga_horaria');
128 142 $lista = $obj->lista(NULL, $this->ref_cod_instituicao, NULL, NULL, NULL,
129   - $this->cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ,1);
  143 + $this->cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
130 144  
131 145 if ($lista) {
132 146 // Passa todos os valores do registro para atributos do objeto
... ... @@ -149,7 +163,7 @@ class indice extends clsDetalhe {
149 163 }
150 164  
151 165 if ($registro['matricula']) {
152   - $this->addDetalhe(array('Matr&iacute;cula', $registro['matricula']));
  166 + $this->addDetalhe(array('Matrícula', $registro['matricula']));
153 167 }
154 168  
155 169 if ($registro['nome']) {
... ... @@ -157,11 +171,11 @@ class indice extends clsDetalhe {
157 171 }
158 172  
159 173 if ($registro['ref_cod_instituicao']) {
160   - $this->addDetalhe( array( "Institui&ccedil;&atilde;o", $registro['ref_cod_instituicao']));
  174 + $this->addDetalhe( array( "Instituição", $registro['ref_cod_instituicao']));
161 175 }
162 176  
163 177 if ($registro['ref_cod_deficiencia']) {
164   - $this->addDetalhe(array('Defici&eacute;ncia', $registro['ref_cod_deficiencia']));
  178 + $this->addDetalhe(array('Deficiência', $registro['ref_cod_deficiencia']));
165 179 }
166 180  
167 181 if( $registro['ref_idesco']) {
... ... @@ -176,7 +190,7 @@ class indice extends clsDetalhe {
176 190 }
177 191  
178 192 if ($registro['ref_cod_funcao']) {
179   - $this->addDetalhe(array('Fun&ccedil;&atilde;o', $registro['ref_cod_funcao']));
  193 + $this->addDetalhe(array('Função', $registro['ref_cod_funcao']));
180 194 }
181 195  
182 196 $obj_funcao = new clsPmieducarServidorFuncao();
... ... @@ -186,10 +200,10 @@ class indice extends clsDetalhe {
186 200 $tabela .= "
187 201 <table cellspacing='0' cellpadding='0' border='0'>
188 202 <tr bgcolor='#A1B3BD' align='center'>
189   - <td width='150'>Fun&ccedil;&atilde;o</td>
  203 + <td width='150'>Função</td>
190 204 </tr>";
191 205  
192   - $class = "formlttd";
  206 + $class = 'formlttd';
193 207  
194 208 $tab_disc = NULL;
195 209  
... ... @@ -203,16 +217,16 @@ class indice extends clsDetalhe {
203 217 $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
204 218 $tab_disc .= "
205 219 <tr>
206   - <td bgcolor='#A1B3BD' align='center'>Disciplinas</td>
  220 + <td bgcolor='#A1B3BD' align='center'>Componentes Curriculares</td>
207 221 </tr>";
208 222  
  223 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
209 224 foreach ($lst_disciplina_servidor as $disciplina) {
210   - $obj_disciplina = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);
211   - $det_disciplina = $obj_disciplina->detalhe();
  225 + $componente = $componenteMapper->find($disciplina['ref_cod_disciplina']);
212 226  
213 227 $tab_disc .= "
214 228 <tr class='$class2' align='center'>
215   - <td align='left'>{$det_disciplina['nm_disciplina']}</td>
  229 + <td align='left'>{$componente->nome}</td>
216 230 </tr>";
217 231  
218 232 $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
... ... @@ -225,7 +239,7 @@ class indice extends clsDetalhe {
225 239 $lst_servidor_curso = $obj_servidor_curso->lista(NULL,
226 240 $this->ref_cod_instituicao, $this->cod_servidor);
227 241  
228   - if($lst_servidor_curso) {
  242 + if ($lst_servidor_curso) {
229 243 $tab_curso .= "<table cellspacing='0' cellpadding='0' width='200' border='0' style='border:1px dotted #000000'>";
230 244  
231 245 $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
... ... @@ -279,7 +293,7 @@ class indice extends clsDetalhe {
279 293 }
280 294  
281 295 $tabela .= "</table>";
282   - $this->addDetalhe(array('Fun&ccedil;&atilde;o',
  296 + $this->addDetalhe(array('Função',
283 297 "<a href='javascript:trocaDisplay(\"det_f\");' >Mostrar detalhe</a><div id='det_f' name='det_f' style='display:none;'>".$tabela."</div>"));
284 298 }
285 299  
... ... @@ -293,25 +307,25 @@ class indice extends clsDetalhe {
293 307 $horas = (int)$cargaHoraria;
294 308 $minutos = round(($cargaHoraria - $horas) * 60);
295 309 $cargaHoraria = sprintf('%02d:%02d', $horas, $minutos);
296   - $this->addDetalhe(array('Carga Hor&aacute;ria', $cargaHoraria));
  310 + $this->addDetalhe(array('Carga Horária', $cargaHoraria));
297 311 }
298 312  
299 313 $dias_da_semana = array(
300 314 '' => 'Selecione',
301 315 1 => 'Domingo',
302 316 2 => 'Segunda',
303   - 3 => 'Ter&ccedil;a',
  317 + 3 => 'Terça',
304 318 4 => 'Quarta',
305 319 5 => 'Quinta',
306 320 6 => 'Sexta',
307   - 7 => 'S&aacute;bado');
  321 + 7 => 'Sábado');
308 322  
309 323 if ($this->alocacao_array) {
310 324 $tabela .= "
311 325 <table cellspacing='0' cellpadding='0' border='0'>
312 326 <tr bgcolor='#A1B3BD' align='center'>
313   - <td width='150'>Carga Horaria</td>
314   - <td width='80'>Periodo</td>
  327 + <td width='150'>Carga Horária</td>
  328 + <td width='80'>Período</td>
315 329 <td width='150'>Escola</td>
316 330 </tr>";
317 331  
... ... @@ -341,7 +355,7 @@ class indice extends clsDetalhe {
341 355  
342 356 $tabela .= "</table>";
343 357  
344   - $this->addDetalhe(array('Hor&aacute;rios de trabalho',
  358 + $this->addDetalhe(array('Horários de trabalho',
345 359 "<a href='javascript:trocaDisplay(\"det_pree\");' >Mostrar detalhe</a><div id='det_pree' name='det_pree' style='display:none;'>".$tabela."</div>"));
346 360 }
347 361  
... ... @@ -357,10 +371,10 @@ class indice extends clsDetalhe {
357 371 $this->array_botao = array();
358 372 $this->array_botao_url_script = array();
359 373  
360   - $this->array_botao[] = 'Avalia&ccedil;&atilde;o de Desempenho';
  374 + $this->array_botao[] = 'Avaliação de Desempenho';
361 375 $this->array_botao_url_script[] = "go(\"educar_avaliacao_desempenho_lst.php?{$get_padrao}\");";
362 376  
363   - $this->array_botao[] = 'Forma&ccedil;&atilde;o';
  377 + $this->array_botao[] = 'Formação';
364 378 $this->array_botao_url_script[] = "go(\"educar_servidor_formacao_lst.php?{$get_padrao}\");";
365 379  
366 380 $this->array_botao[] = 'Faltas/Atrasos';
... ... @@ -378,7 +392,7 @@ class indice extends clsDetalhe {
378 392 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
379 393  
380 394 if ($lista) {
381   - $this->array_botao[] = 'Substituir Hor&aacute;rio Servidor';
  395 + $this->array_botao[] = 'Substituir Horário Servidor';
382 396 $this->array_botao_url_script[] = "go(\"educar_servidor_substituicao_cad.php?{$get_padrao}\");";
383 397 }
384 398  
... ... @@ -412,14 +426,15 @@ $pagina-&gt;addForm($miolo);
412 426 // Gera o HTML
413 427 $pagina->MakeAll();
414 428 ?>
415   -
416 429 <script type="text/javascript">
417   -function trocaDisplay(id) {
  430 +function trocaDisplay(id)
  431 +{
418 432 var element = document.getElementById(id);
419   - element.style.display = (element.style.display == "none") ? "inline" : "none";
  433 + element.style.display = (element.style.display == 'none') ? 'inline' : 'none';
420 434 }
421 435  
422   -function popless() {
  436 +function popless()
  437 +{
423 438 var campoServidor = <?=$_GET["cod_servidor"];?>;
424 439 var campoInstituicao = <?=$_GET["ref_cod_instituicao"];?>;
425 440 pesquisa_valores_popless('educar_servidor_nivel_cad.php?ref_cod_servidor='+campoServidor+'&ref_cod_instituicao='+campoInstituicao, '');
... ...
ieducar/intranet/educar_servidor_disciplina_lst.php
... ... @@ -32,6 +32,8 @@ require_once &#39;include/clsBase.inc.php&#39;;
32 32 require_once 'include/clsCadastro.inc.php';
33 33 require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
  35 +require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
  36 +require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
35 37  
36 38 /**
37 39 * clsIndexBase class.
... ... @@ -48,9 +50,9 @@ class clsIndexBase extends clsBase
48 50 function Formular()
49 51 {
50 52 $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Disciplina');
51   - $this->processoAp = 0;
52   - $this->renderBanner = FALSE;
53   - $this->renderMenu = FALSE;
  53 + $this->processoAp = 0;
  54 + $this->renderBanner = FALSE;
  55 + $this->renderMenu = FALSE;
54 56 $this->renderMenuSuspenso = FALSE;
55 57 }
56 58 }
... ... @@ -114,13 +116,14 @@ class indice extends clsCadastro
114 116 if (!$this->cursos_disciplina) {
115 117 $obj_servidor_disciplina = new clsPmieducarServidorDisciplina();
116 118 $lst_servidor_disciplina = $obj_servidor_disciplina->lista(NULL,
117   - $this->ref_cod_instituicao,$this->cod_servidor);
  119 + $this->ref_cod_instituicao, $this->cod_servidor);
118 120  
119 121 if ($lst_servidor_disciplina) {
120 122 foreach ($lst_servidor_disciplina as $disciplina) {
121   - $obj_disciplina = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);
122   - $det_disciplina = $obj_disciplina->detalhe();
123   - $this->cursos_disciplina[$det_disciplina['ref_cod_curso']][$disciplina['ref_cod_disciplina']] = $disciplina['ref_cod_disciplina'];
  123 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
  124 + $componente = $componenteMapper->find($disciplina['ref_cod_disciplina']);
  125 +
  126 + $this->cursos_disciplina[$disciplina['ref_cod_curso']][$disciplina['ref_cod_disciplina']] = $disciplina['ref_cod_disciplina'];
124 127 }
125 128 }
126 129 }
... ... @@ -148,7 +151,7 @@ class indice extends clsCadastro
148 151 $obj_cursos->setOrderby('nm_curso');
149 152 $lst_cursos = $obj_cursos->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
150 153 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
151   - NULL, NULL, NULL,1, NULL,$this->ref_cod_instituicao);
  154 + NULL, NULL, NULL,1, NULL, $this->ref_cod_instituicao);
152 155  
153 156 if ($lst_cursos) {
154 157 foreach ($lst_cursos as $curso) {
... ... @@ -161,11 +164,12 @@ class indice extends clsCadastro
161 164 $lst_opcoes = array();
162 165 $arr_valores = array();
163 166  
164   - if($this->cursos_disciplina) {
  167 +
  168 + if ($this->cursos_disciplina) {
165 169 foreach ($this->cursos_disciplina as $curso => $disciplinas) {
166 170 if ($disciplinas) {
167 171 foreach ($disciplinas as $disciplina) {
168   - $arr_valores[] = array($curso,$disciplina);
  172 + $arr_valores[] = array($curso, $disciplina);
169 173 }
170 174 }
171 175 }
... ... @@ -177,21 +181,27 @@ class indice extends clsCadastro
177 181 NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, $curso,
178 182 $this->ref_cod_instituicao);
179 183  
  184 + $componenteAnoDataMapper = new ComponenteCurricular_Model_AnoEscolarDataMapper();
  185 + $componentes = $componenteAnoDataMapper->findComponentePorCurso($curso);
  186 +
180 187 $opcoes_disc = array();
181   - foreach ($lst_disciplinas as $disciplina) {
182   - $opcoes_disc[$disciplina['cod_disciplina']] = $disciplina['nm_disciplina'];
  188 + foreach ($componentes as $componente) {
  189 + $opcoes_disc[$componente->id] = $componente->nome;
183 190 }
184 191  
185   - $lst_opcoes[] = array($opcoes_curso,$opcoes_disc);
  192 + $lst_opcoes[] = array($opcoes_curso, $opcoes_disc);
186 193 }
187 194 }
188 195  
189   - $this->campoTabelaInicio('funcao', 'Disciplinas', array('Curso','Disciplina'),
  196 + $this->campoTabelaInicio('funcao', 'Componentes Curriculares', array('Curso', 'Componente Curricular'),
190 197 $arr_valores, '', $lst_opcoes);
191 198  
  199 + // Cursos
192 200 $this->campoLista('ref_cod_curso', 'Curso', $opcoes_curso,
193 201 $this->ref_cod_curso, 'trocaCurso(this)', '', '', '');
194   - $this->campoLista('ref_cod_disciplina', 'Disciplina', $opcoes,
  202 +
  203 + // Disciplinas
  204 + $this->campoLista('ref_cod_disciplina', 'Componente Curricular', $opcoes,
195 205 $this->ref_cod_disciplina, '', '', '', '');
196 206  
197 207 $this->campoTabelaFim();
... ...
ieducar/intranet/include/pmieducar/clsPmieducarServidor.inc.php
... ... @@ -107,7 +107,7 @@ class clsPmieducarServidor
107 107 /**
108 108 * Construtor.
109 109 */
110   - public function clsPmieducarServidor(
  110 + function clsPmieducarServidor(
111 111 $cod_servidor = NULL, $ref_cod_deficiencia = NULL, $ref_idesco = NULL,
112 112 $carga_horaria = NULL, $data_cadastro = NULL, $data_exclusao = NULL,
113 113 $ativo = NULL, $ref_cod_instituicao = NULL, $ref_cod_subnivel = NULL)
... ... @@ -408,7 +408,7 @@ class clsPmieducarServidor
408 408 * @return array|bool Array com os resultados da query SELECT ou FALSE caso
409 409 * nenhum registro tenha sido encontrado
410 410 */
411   - public function lista(
  411 + function lista(
412 412 $int_cod_servidor = NULL,
413 413 $int_ref_cod_deficiencia = NULL,
414 414 $int_ref_idesco = NULL,
... ... @@ -551,168 +551,176 @@ class clsPmieducarServidor
551 551  
552 552 $whereAnd = " AND ";
553 553 }
  554 + else {
  555 + if (is_numeric($alocacao_escola_instituicao)) {
  556 + $filtros .= "
  557 + {$whereAnd} s.cod_servidor IN
  558 + (SELECT a.ref_cod_servidor
  559 + FROM pmieducar.servidor_alocacao a
  560 + WHERE ";
554 561  
555   - if (is_numeric($alocacao_escola_instituicao)) {
556   - $filtros .= "
557   - {$whereAnd} s.cod_servidor IN
558   - (SELECT a.ref_cod_servidor
559   - FROM pmieducar.servidor_alocacao a
560   - WHERE ";
  562 + if (is_numeric($int_ref_cod_instituicao)) {
  563 + $filtros .= $whereAnd . " a.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'";
  564 + }
561 565  
562   - if (is_numeric($int_ref_cod_instituicao)) {
563   - $filtros .= " a.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'";
564   - }
  566 + if (is_numeric($int_ref_cod_escola)) {
  567 + $filtros .= $whereAnd . " and ref_cod_escola = '{$int_ref_cod_escola}' ";
  568 + }
565 569  
566   - if (is_numeric($int_ref_cod_escola)) {
567   - $filtros .= " and ref_cod_escola = '{$int_ref_cod_escola}' ";
  570 + $filtros .= ') ';
568 571 }
569 572  
570   - $filtros .= ') ';
571   - }
  573 + if (is_array($array_horario)) {
  574 + $cond = "AND";
  575 + if (is_numeric($int_ref_cod_instituicao)) {
  576 + $where .= " {$cond} a.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}' ";
  577 + $cond = "AND";
  578 + }
572 579  
573   - if (is_array($array_horario)) {
574   - $cond = "";
575   - if (is_numeric($int_ref_cod_instituicao)) {
576   - $where .= " {$cond} a.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}' ";
577   - $cond = "AND";
578   - }
  580 + if (is_numeric($int_ref_cod_escola)) {
  581 + $where .= " {$cond} a.ref_cod_escola = '{$int_ref_cod_escola}' ";
  582 + $cond = "AND";
  583 + }
579 584  
580   - if (is_numeric($int_ref_cod_escola)) {
581   - $where .= " {$cond} a.ref_cod_escola = '{$int_ref_cod_escola}' ";
  585 + $where .= " {$cond} a.ativo = '1'";
582 586 $cond = "AND";
583   - }
584 587  
585   - $where .= " {$cond} a.ativo = '1'";
586   - $cond = "AND";
  588 + $hora_ini = explode(":", $array_horario[1]);
  589 + $hora_fim = explode(":", $array_horario[2]);
  590 + $horas = sprintf("%02d", (int) abs($hora_fim[0]) - abs($hora_ini[0]));
  591 + $minutos = sprintf("%02d", (int) abs($hora_fim[1]) - abs($hora_ini[1]));
587 592  
588   - $hora_ini = explode(":", $array_horario[1]);
589   - $hora_fim = explode(":", $array_horario[2]);
590   - $horas = sprintf("%02d", (int) abs($hora_fim[0]) - abs($hora_ini[0]));
591   - $minutos = sprintf("%02d", (int) abs($hora_fim[1]) - abs($hora_ini[1]));
  593 + // Remove qualquer AND que esteja no início da cláusula SQL
  594 + $wherePieces = explode(' ', trim($where));
  595 + if ('AND' == $wherePieces[0]) {
  596 + array_shift($wherePieces);
  597 + $where = implode(' ', $wherePieces);
  598 + }
592 599  
593   - if ($matutino) {
594   - if (is_string($str_horario) && $str_horario == "S") {
595   - // A somatória retorna nulo
596   - $filtros .= "
597   - {$whereAnd} s.cod_servidor IN (SELECT a.ref_cod_servidor
598   - FROM pmieducar.servidor_alocacao a
599   - WHERE $where
600   - AND a.periodo = 1
601   - AND a.carga_horaria >= COALESCE(
602   - (SELECT SUM(qhh.hora_final - qhh.hora_inicial)
603   - FROM pmieducar.quadro_horario_horarios qhh
604   - WHERE qhh.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
605   - AND qhh.ref_cod_escola = '$int_ref_cod_escola'
606   - AND hora_inicial >= '08:00'
607   - AND hora_inicial <= '12:00'
608   - AND qhh.ativo = '1'
609   - AND qhh.dia_semana <> '$int_dia_semana'
610   - AND qhh.ref_servidor = a.ref_cod_servidor
611   - GROUP BY qhh.ref_servidor) ,'00:00') + '$str_hr_mat' + COALESCE(
612   - (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
613   - FROM pmieducar.quadro_horario_horarios_aux qhha
614   - WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
615   - AND qhha.ref_cod_escola = $int_ref_cod_escola
  600 + if ($matutino) {
  601 + if (is_string($str_horario) && $str_horario == "S") {
  602 + // A somatória retorna nulo
  603 + $filtros .= "
  604 + {$whereAnd} s.cod_servidor IN (SELECT a.ref_cod_servidor
  605 + FROM pmieducar.servidor_alocacao a
  606 + WHERE $where
  607 + AND a.periodo = 1
  608 + AND a.carga_horaria >= COALESCE(
  609 + (SELECT SUM(qhh.hora_final - qhh.hora_inicial)
  610 + FROM pmieducar.quadro_horario_horarios qhh
  611 + WHERE qhh.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
  612 + AND qhh.ref_cod_escola = '$int_ref_cod_escola'
616 613 AND hora_inicial >= '08:00'
617 614 AND hora_inicial <= '12:00'
618   - AND qhha.ref_servidor = a.ref_cod_servidor
619   - AND identificador = '$int_identificador'
620   - GROUP BY qhha.ref_servidor),'00:00'))";
  615 + AND qhh.ativo = '1'
  616 + AND qhh.dia_semana <> '$int_dia_semana'
  617 + AND qhh.ref_servidor = a.ref_cod_servidor
  618 + GROUP BY qhh.ref_servidor) ,'00:00') + '$str_hr_mat' + COALESCE(
  619 + (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
  620 + FROM pmieducar.quadro_horario_horarios_aux qhha
  621 + WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
  622 + AND qhha.ref_cod_escola = $int_ref_cod_escola
  623 + AND hora_inicial >= '08:00'
  624 + AND hora_inicial <= '12:00'
  625 + AND qhha.ref_servidor = a.ref_cod_servidor
  626 + AND identificador = '$int_identificador'
  627 + GROUP BY qhha.ref_servidor),'00:00'))";
  628 + }
  629 + else {
  630 + $filtros .= "
  631 + {$whereAnd} s.cod_servidor NOT IN (SELECT a.ref_cod_servidor
  632 + FROM pmieducar.servidor_alocacao a
  633 + WHERE $where
  634 + AND a.periodo = 1)";
  635 + }
621 636 }
622   - else {
623   - $filtros .= "
624   - {$whereAnd} s.cod_servidor NOT IN (SELECT a.ref_cod_servidor
625   - FROM pmieducar.servidor_alocacao a
626   - WHERE $where
627   - AND a.periodo = 1)";
  637 +
  638 + if ($vespertino) {
  639 + if (is_string($str_horario) && $str_horario == "S") {
  640 + $filtros .= "
  641 + {$whereAnd} s.cod_servidor IN
  642 + (SELECT a.ref_cod_servidor
  643 + FROM pmieducar.servidor_alocacao a
  644 + WHERE $where
  645 + AND a.periodo = 2
  646 + AND a.carga_horaria >= COALESCE(
  647 + (SELECT SUM( qhh.hora_final - qhh.hora_inicial )
  648 + FROM pmieducar.quadro_horario_horarios qhh
  649 + WHERE qhh.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
  650 + AND qhh.ref_cod_escola = '$int_ref_cod_escola'
  651 + AND qhh.ativo = '1'
  652 + AND hora_inicial >= '12:00'
  653 + AND hora_inicial <= '18:00'
  654 + AND qhh.dia_semana <> '$int_dia_semana'
  655 + AND qhh.ref_servidor = a.ref_cod_servidor
  656 + GROUP BY qhh.ref_servidor ),'00:00') + '$str_hr_ves' + COALESCE(
  657 + (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
  658 + FROM pmieducar.quadro_horario_horarios_aux qhha
  659 + WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
  660 + AND qhha.ref_cod_escola = '$int_ref_cod_escola'
  661 + AND qhha.ref_servidor = a.ref_cod_servidor
  662 + AND hora_inicial >= '12:00'
  663 + AND hora_inicial <= '18:00'
  664 + AND identificador = '$int_identificador'
  665 + GROUP BY qhha.ref_servidor),'00:00') )";
  666 + }
  667 + else {
  668 + $filtros .= "
  669 + {$whereAnd} s.cod_servidor NOT IN ( SELECT a.ref_cod_servidor
  670 + FROM pmieducar.servidor_alocacao a
  671 + WHERE $where
  672 + AND a.periodo = 2 )";
  673 + }
628 674 }
629   - }
630 675  
631   - if ($vespertino) {
632   - if (is_string($str_horario) && $str_horario == "S") {
  676 + if ($noturno) {
  677 + if (is_string($str_horario) && $str_horario == "S") {
633 678 $filtros .= "
634   - {$whereAnd} s.cod_servidor IN
635   - (SELECT a.ref_cod_servidor
  679 + {$whereAnd} s.cod_servidor IN ( SELECT a.ref_cod_servidor
636 680 FROM pmieducar.servidor_alocacao a
637 681 WHERE $where
638   - AND a.periodo = 2
  682 + AND a.periodo = 3
639 683 AND a.carga_horaria >= COALESCE(
640   - (SELECT SUM( qhh.hora_final - qhh.hora_inicial )
  684 + (SELECT SUM(qhh.hora_final - qhh.hora_inicial)
641 685 FROM pmieducar.quadro_horario_horarios qhh
642 686 WHERE qhh.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
643 687 AND qhh.ref_cod_escola = '$int_ref_cod_escola'
644 688 AND qhh.ativo = '1'
645   - AND hora_inicial >= '12:00'
646   - AND hora_inicial <= '18:00'
  689 + AND hora_inicial >= '18:00'
  690 + AND hora_inicial <= '23:00'
647 691 AND qhh.dia_semana <> '$int_dia_semana'
648   - AND qhh.ref_servidor = a.ref_cod_servidor
649   - GROUP BY qhh.ref_servidor ),'00:00') + '$str_hr_ves' + COALESCE(
650   - (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
  692 + GROUP BY qhh.ref_servidor ),'00:00') + '$str_hr_not' + COALESCE(
  693 + (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
651 694 FROM pmieducar.quadro_horario_horarios_aux qhha
652 695 WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
653 696 AND qhha.ref_cod_escola = '$int_ref_cod_escola'
654 697 AND qhha.ref_servidor = a.ref_cod_servidor
655   - AND hora_inicial >= '12:00'
656   - AND hora_inicial <= '18:00'
  698 + AND hora_inicial >= '18:00'
  699 + AND hora_inicial <= '23:00'
657 700 AND identificador = '$int_identificador'
658 701 GROUP BY qhha.ref_servidor),'00:00') )";
  702 + }
  703 + else {
  704 + $filtros .= "
  705 + {$whereAnd} s.cod_servidor NOT IN (
  706 + SELECT a.ref_cod_servidor
  707 + FROM pmieducar.servidor_alocacao a
  708 + WHERE $where
  709 + AND a.periodo = 3 )";
  710 + }
659 711 }
660   - else {
661   - $filtros .= "
662   - {$whereAnd} s.cod_servidor NOT IN ( SELECT a.ref_cod_servidor
663   - FROM pmieducar.servidor_alocacao a
664   - WHERE $where
665   - AND a.periodo = 2 )";
666   - }
667   - }
668 712  
669   - if ($noturno) {
670 713 if (is_string($str_horario) && $str_horario == "S") {
671   - $filtros .= "
672   - {$whereAnd} s.cod_servidor IN ( SELECT a.ref_cod_servidor
673   - FROM pmieducar.servidor_alocacao a
674   - WHERE $where
675   - AND a.periodo = 3
676   - AND a.carga_horaria >= COALESCE(
677   - (SELECT SUM(qhh.hora_final - qhh.hora_inicial)
678   - FROM pmieducar.quadro_horario_horarios qhh
679   - WHERE qhh.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
680   - AND qhh.ref_cod_escola = '$int_ref_cod_escola'
681   - AND qhh.ativo = '1'
682   - AND hora_inicial >= '18:00'
683   - AND hora_inicial <= '23:00'
684   - AND qhh.dia_semana <> '$int_dia_semana'
685   - GROUP BY qhh.ref_servidor ),'00:00') + '$str_hr_not' + COALESCE(
686   - (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
687   - FROM pmieducar.quadro_horario_horarios_aux qhha
688   - WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
689   - AND qhha.ref_cod_escola = '$int_ref_cod_escola'
690   - AND qhha.ref_servidor = a.ref_cod_servidor
691   - AND hora_inicial >= '18:00'
692   - AND hora_inicial <= '23:00'
693   - AND identificador = '$int_identificador'
694   - GROUP BY qhha.ref_servidor),'00:00') )";
695 714 }
696 715 else {
697 716 $filtros .= "
698   - {$whereAnd} s.cod_servidor NOT IN (
699   - SELECT a.ref_cod_servidor
700   - FROM pmieducar.servidor_alocacao a
701   - WHERE $where
702   - AND a.periodo = 3 )";
  717 + {$whereAnd} s.carga_horaria >= COALESCE(
  718 + (SELECT sum(hora_final - hora_inicial) + '" . abs($horas) . ":" . abs($minutos)."'
  719 + FROM pmieducar.servidor_alocacao sa
  720 + WHERE sa.ref_cod_servidor = s.cod_servidor
  721 + AND sa.ref_ref_cod_instituicao ='{$int_ref_cod_instituicao}'),'00:00') ";
703 722 }
704 723 }
705   -
706   - if (is_string($str_horario) && $str_horario == "S") {
707   - }
708   - else {
709   - $filtros .= "
710   - {$whereAnd} s.carga_horaria >= COALESCE(
711   - (SELECT sum(hora_final - hora_inicial) + '" . abs($horas) . ":" . abs($minutos)."'
712   - FROM pmieducar.servidor_alocacao sa
713   - WHERE sa.ref_cod_servidor = s.cod_servidor
714   - AND sa.ref_ref_cod_instituicao ='{$int_ref_cod_instituicao}'),'00:00') ";
715   - }
716 724 }
717 725  
718 726 if ((is_array($array_horario) && $str_not_in_servidor) || (is_string($str_tipo) && $str_not_in_servidor)) {
... ... @@ -723,42 +731,53 @@ class clsPmieducarServidor
723 731 $obj_curso = new clsPmieducarCurso($int_ref_cod_curso);
724 732 $det_curso = $obj_curso->detalhe();
725 733  
726   - if ($det_curso['falta_ch_globalizada']) {
727   - // Busca professores independentemente da disciplina, somente verifica
728   - // se é professor e se ministra a disciplina para o curso
729   - $filtros .= "
730   - {$whereAnd} EXISTS
731   - (SELECT 1
732   - FROM pmieducar.servidor_curso_ministra scm
733   - WHERE scm.ref_cod_curso = $int_ref_cod_curso AND
734   - scm.ref_ref_cod_instituicao = s.ref_cod_instituicao AND
735   - s.cod_servidor = scm.ref_cod_servidor)";
736   - $whereAnd = " AND ";
737   - }
738   - else {
739   - // Verifica se o professor está habilitado para ministrar a disciplina
740   - if (is_numeric($int_ref_cod_disciplina)) {
741   - $filtros .= "
742   - {$whereAnd} EXISTS
743   - (SELECT 1
744   - FROM pmieducar.servidor_disciplina sd
745   - WHERE sd.ref_cod_disciplina = $int_ref_cod_disciplina AND
746   - sd.ref_ref_cod_instituicao = s.ref_cod_instituicao AND
747   - s.cod_servidor = sd.ref_cod_servidor)";
748   - $whereAnd = " AND ";
749   - }
750   - }
751   -
752 734 // Seleciona apenas servidor cuja uma de suas funções seja a de professor
  735 + // @todo Extract method
753 736 if ($boo_professor) {
  737 + /*
  738 + * Caso os códigos de disciplina e de curso não sejam informado, mas o de
  739 + * servidor para não buscar sim, seleciona as disciplinas deste servidor
  740 + * com o qual o professor candidato terá que lecionar para ser retornado
  741 + * na query.
  742 + */
  743 + if (!$int_ref_cod_disciplina && !$int_ref_cod_curso) {
  744 + $servidorDisciplina = new clsPmieducarServidorDisciplina();
  745 + $disciplinas = $servidorDisciplina->lista(NULL, NULL, $str_not_in_servidor);
  746 + $servidorDisciplinas = array();
  747 +
  748 + if (is_array($disciplinas)) {
  749 + foreach ($disciplinas as $disciplina) {
  750 + $servidorDisciplinas[] = sprintf(
  751 + '(sd.ref_cod_disciplina = %d AND sd.ref_cod_curso = %d)',
  752 + $disciplina['ref_cod_disciplina'], $disciplina['ref_cod_curso']);
  753 + }
  754 +
  755 + $servidorDisciplinas = sprintf('AND (%s)', implode(' AND ', $servidorDisciplinas));
  756 + }
  757 + else {
  758 + $servidorDisciplinas = '';
  759 + }
  760 + }
  761 + else {
  762 + $servidorDisciplinas = sprintf(
  763 + 'AND sd.ref_cod_disciplina = %d AND sd.ref_cod_curso = %d',
  764 + $int_ref_cod_disciplina, $int_ref_cod_curso);
  765 + }
  766 +
754 767 $filtros .= "
755 768 {$whereAnd} EXISTS
756   - (SELECT 1
757   - FROM pmieducar.servidor_funcao sf, pmieducar.funcao f
758   - WHERE f.cod_funcao = sf.ref_cod_funcao AND
  769 + (SELECT
  770 + 1
  771 + FROM
  772 + pmieducar.servidor_funcao sf, pmieducar.funcao f, pmieducar.servidor_disciplina sd
  773 + WHERE
  774 + f.cod_funcao = sf.ref_cod_funcao AND
759 775 f.professor = 1 AND
760 776 sf.ref_ref_cod_instituicao = s.ref_cod_instituicao AND
761   - s.cod_servidor = sf.ref_cod_servidor)";
  777 + s.cod_servidor = sf.ref_cod_servidor AND
  778 + s.cod_servidor = sd.ref_cod_servidor AND
  779 + s.ref_cod_instituicao = sd.ref_ref_cod_instituicao
  780 + {$servidorDisciplinas})";
762 781 $whereAnd = " AND ";
763 782 }
764 783  
... ... @@ -796,9 +815,6 @@ class clsPmieducarServidor
796 815 $sql = "SELECT {$this->_campos_lista2} FROM {$this->_schema}servidor s{$tabela_compl} {$filtros}" .
797 816 $this->getOrderby() . $this->getLimite();
798 817  
799   - #print '<pre>' . $sql;
800   - #print PHP_EOL . PHP_EOL . "SELECT COUNT(0) FROM {$this->_schema}servidor s{$tabela_compl} {$filtros}";
801   - #exit();
802 818 $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_schema}servidor s{$tabela_compl} {$filtros}");
803 819  
804 820 // Executa a query
... ... @@ -891,7 +907,7 @@ class clsPmieducarServidor
891 907 * função. O array interno contém o nome da função e se a função desempenha
892 908 * um papel de professor
893 909 */
894   - public function getServidorFuncoes()
  910 + function getServidorFuncoes()
895 911 {
896 912 $db = new clsBanco();
897 913  
... ... @@ -928,7 +944,7 @@ class clsPmieducarServidor
928 944 * @return array|bool Array com códigos das disciplinas ordenados ou FALSE
929 945 * caso o servidor não tenha disciplinas
930 946 */
931   - public function getServidorDisciplinasQuadroHorarioHorarios($codServidor = NULL,
  947 + function getServidorDisciplinasQuadroHorarioHorarios($codServidor = NULL,
932 948 $codInstituicao = NULL)
933 949 {
934 950  
... ... @@ -970,7 +986,7 @@ class clsPmieducarServidor
970 986 * @return array|bool Array com códigos das disciplinas ordenados ou FALSE
971 987 * caso o servidor não tenha disciplinas
972 988 */
973   - public function getServidorDisciplinas($codServidor = NULL,
  989 + function getServidorDisciplinas($codServidor = NULL,
974 990 $codInstituicao = NULL)
975 991 {
976 992 $codServidor = $codServidor != NULL ? $codServidor : $this->cod_servidor;
... ... @@ -1015,7 +1031,7 @@ class clsPmieducarServidor
1015 1031 * @since Método disponível desde a versão 1.0.2
1016 1032 * @return bool TRUE caso o servidor desempenhe a função de professor
1017 1033 */
1018   - public function isProfessor()
  1034 + function isProfessor()
1019 1035 {
1020 1036 $funcoes = $this->getServidorFuncoes();
1021 1037  
... ...
ieducar/intranet/include/pmieducar/clsPmieducarServidorDisciplina.inc.php
... ... @@ -29,6 +29,7 @@
29 29 */
30 30  
31 31 require_once 'include/pmieducar/geral.inc.php';
  32 +require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
32 33  
33 34 /**
34 35 * clsPmieducarServidorDisciplina class.
... ... @@ -45,6 +46,7 @@ class clsPmieducarServidorDisciplina
45 46 var $ref_cod_disciplina;
46 47 var $ref_ref_cod_instituicao;
47 48 var $ref_cod_servidor;
  49 + var $ref_cod_curso;
48 50  
49 51 /**
50 52 * Armazena o total de resultados obtidos na última chamada ao método lista().
... ... @@ -99,55 +101,41 @@ class clsPmieducarServidorDisciplina
99 101 /**
100 102 * Construtor.
101 103 */
102   - function clsPmieducarServidorDisciplina( $ref_cod_disciplina = null, $ref_ref_cod_instituicao = null, $ref_cod_servidor = null )
  104 + function clsPmieducarServidorDisciplina($ref_cod_disciplina = NULL,
  105 + $ref_ref_cod_instituicao = NULL, $ref_cod_servidor = NULL, $ref_cod_curso = NULL)
103 106 {
104 107 $db = new clsBanco();
105 108 $this->_schema = 'pmieducar.';
106 109 $this->_tabela = $this->_schema . 'servidor_disciplina';
107 110  
108   - $this->_campos_lista = $this->_todos_campos = 'ref_cod_disciplina, ref_ref_cod_instituicao, ref_cod_servidor';
  111 + $this->_campos_lista = $this->_todos_campos = 'ref_cod_disciplina, ref_ref_cod_instituicao, ref_cod_servidor, ref_cod_curso';
109 112  
110 113 if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) {
111   - if (class_exists('clsPmieducarServidor')) {
112   - $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL,
113   - NULL, NULL, NULL, $ref_ref_cod_instituicao);
114   -
115   - if (method_exists($tmp_obj, 'existe')) {
116   - if ($tmp_obj->existe()) {
117   - $this->ref_cod_servidor = $ref_cod_servidor;
118   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
119   - }
120   - }
121   - elseif (method_exists($tmp_obj, 'detalhe')) {
122   - if ($tmp_obj->detalhe()) {
123   - $this->ref_cod_servidor = $ref_cod_servidor;
124   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
125   - }
126   - }
127   - }
128   - elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) {
  114 + $servidor = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL,
  115 + NULL, NULL, NULL, $ref_ref_cod_instituicao);
  116 +
  117 + if ($servidor->existe()) {
129 118 $this->ref_cod_servidor = $ref_cod_servidor;
130 119 $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
131 120 }
132 121 }
133 122  
134 123 if (is_numeric($ref_cod_disciplina)) {
135   - if (class_exists('clsPmieducarDisciplina')) {
136   - $tmp_obj = new clsPmieducarDisciplina($ref_cod_disciplina);
137   - if (method_exists($tmp_obj, 'existe')) {
138   - if ($tmp_obj->existe()) {
139   - $this->ref_cod_disciplina = $ref_cod_disciplina;
140   - }
141   - }
142   - elseif (method_exists($tmp_obj, 'detalhe')) {
143   - if ($tmp_obj->detalhe()) {
144   - $this->ref_cod_disciplina = $ref_cod_disciplina;
145   - }
146   - }
147   - }
148   - elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.disciplina WHERE cod_disciplina = '{$ref_cod_disciplina}'")) {
  124 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
  125 + try {
  126 + $componenteMapper->find($ref_cod_disciplina);
149 127 $this->ref_cod_disciplina = $ref_cod_disciplina;
150 128 }
  129 + catch (Exception $e) {
  130 + }
  131 + }
  132 +
  133 + if (is_numeric($ref_cod_curso)) {
  134 + $curso = new clsPmieducarCurso($ref_cod_curso);
  135 +
  136 + if ($curso->existe()) {
  137 + $this->ref_cod_curso = $ref_cod_curso;
  138 + }
151 139 }
152 140 }
153 141  
... ... @@ -159,13 +147,14 @@ class clsPmieducarServidorDisciplina
159 147 {
160 148 if (is_numeric($this->ref_cod_disciplina) &&
161 149 is_numeric($this->ref_ref_cod_instituicao) &&
162   - is_numeric($this->ref_cod_servidor)
  150 + is_numeric($this->ref_cod_servidor) &&
  151 + is_numeric($this->ref_cod_curso)
163 152 ) {
164 153 $db = new clsBanco();
165 154  
166   - $campos = '';
  155 + $campos = '';
167 156 $valores = '';
168   - $gruda = '';
  157 + $gruda = '';
169 158  
170 159 if (is_numeric($this->ref_cod_disciplina)) {
171 160 $campos .= "{$gruda}ref_cod_disciplina";
... ... @@ -185,6 +174,12 @@ class clsPmieducarServidorDisciplina
185 174 $gruda = ", ";
186 175 }
187 176  
  177 + if (is_numeric($this->ref_cod_curso)) {
  178 + $campos .= "{$gruda}ref_cod_curso";
  179 + $valores .= "{$gruda}'{$this->ref_cod_curso}'";
  180 + $gruda = ", ";
  181 + }
  182 +
188 183 $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)");
189 184 return TRUE;
190 185 }
... ... @@ -199,13 +194,15 @@ class clsPmieducarServidorDisciplina
199 194 function edita()
200 195 {
201 196 if (is_numeric($this->ref_cod_disciplina) &&
202   - is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_cod_servidor)
  197 + is_numeric($this->ref_ref_cod_instituicao) &&
  198 + is_numeric($this->ref_cod_servidor) &&
  199 + is_numeric($this->ref_cod_curso)
203 200 ) {
204 201 $db = new clsBanco();
205 202 $set = '';
206 203  
207 204 if ($set) {
208   - $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_cod_disciplina = '{$this->ref_cod_disciplina}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_servidor = '{$this->ref_cod_servidor}'");
  205 + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_cod_disciplina = '{$this->ref_cod_disciplina}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_servidor = '{$this->ref_cod_servidor}' AND ref_cod_curso = '{$this->ref_cod_curso}'");
209 206 return TRUE;
210 207 }
211 208 }
... ... @@ -218,7 +215,7 @@ class clsPmieducarServidorDisciplina
218 215 * @return array
219 216 */
220 217 function lista($int_ref_cod_disciplina = NULL, $int_ref_ref_cod_instituicao = NULL,
221   - $int_ref_cod_servidor = NULL)
  218 + $int_ref_cod_servidor = NULL, $int_ref_cod_curso = NULL)
222 219 {
223 220 $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
224 221 $filtros = "";
... ... @@ -240,6 +237,11 @@ class clsPmieducarServidorDisciplina
240 237 $whereAnd = " AND ";
241 238 }
242 239  
  240 + if (is_numeric($int_ref_cod_curso)) {
  241 + $filtros .= "{$whereAnd} ref_cod_curso = '{$int_ref_cod_curso}'";
  242 + $whereAnd = " AND ";
  243 + }
  244 +
243 245 $db = new clsBanco();
244 246 $countCampos = count(explode(',', $this->_campos_lista));
245 247 $resultado = array();
... ... @@ -278,8 +280,10 @@ class clsPmieducarServidorDisciplina
278 280 function detalhe()
279 281 {
280 282 if (is_numeric($this->ref_cod_disciplina) &&
281   - is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_cod_servidor))
282   - {
  283 + is_numeric($this->ref_ref_cod_instituicao) &&
  284 + is_numeric($this->ref_cod_servidor) &&
  285 + is_numeric($this->ref_cod_curso)
  286 + ) {
283 287 $db = new clsBanco();
284 288 $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_cod_disciplina = '{$this->ref_cod_disciplina}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_servidor = '{$this->ref_cod_servidor}'");
285 289 $db->ProximoRegistro();
... ... @@ -296,10 +300,12 @@ class clsPmieducarServidorDisciplina
296 300 function existe()
297 301 {
298 302 if (is_numeric($this->ref_cod_disciplina) &&
299   - is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_cod_servidor)
  303 + is_numeric($this->ref_ref_cod_instituicao) &&
  304 + is_numeric($this->ref_cod_servidor) &&
  305 + is_numeric($this->ref_cod_curso)
300 306 ) {
301 307 $db = new clsBanco();
302   - $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE ref_cod_disciplina = '{$this->ref_cod_disciplina}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_servidor = '{$this->ref_cod_servidor}'");
  308 + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE ref_cod_disciplina = '{$this->ref_cod_disciplina}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_servidor = '{$this->ref_cod_servidor}' AND ref_cod_curso = '{$this->ref_cod_curso}'");
303 309 if ($db->ProximoRegistro()) {
304 310 return TRUE;
305 311 }
... ... @@ -313,9 +319,11 @@ class clsPmieducarServidorDisciplina
313 319 */
314 320 function excluir()
315 321 {
316   - if (is_numeric($this->ref_cod_disciplina) && is_numeric($this->ref_ref_cod_instituicao) &&
317   - is_numeric($this->ref_cod_servidor))
318   - {
  322 + if (is_numeric($this->ref_cod_disciplina) &&
  323 + is_numeric($this->ref_ref_cod_instituicao) &&
  324 + is_numeric($this->ref_cod_servidor) &&
  325 + is_numeric($this->ref_cod_curso)
  326 + ) {
319 327 }
320 328 return FALSE;
321 329 }
... ...
ieducar/misc/database/deltas/17_adiciona_campo_curso_componente_ano_escolar_e_atualiza_constraint_servidor_disciplina.sql 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +-- //
  2 +
  3 +--
  4 +-- Atualiza a foreign key constraint de pmieducar.serie_disciplina
  5 +-- para referenciar modules.componente_curricular.
  6 +--
  7 +-- Adiciona referências a pmieducar.curso na tabela
  8 +-- pmieducar.servidor_disciplina.
  9 +--
  10 +-- Essa medida faz parte da tarefa de substituição do sistema de notas/faltas
  11 +-- por um módulo mais robusto e parametrizável.
  12 +--
  13 +-- @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br>
  14 +-- @license @@license@@
  15 +-- @version $Id$
  16 +--
  17 +
  18 +ALTER TABLE "pmieducar"."servidor_disciplina"
  19 + DROP CONSTRAINT servidor_disciplina_ref_cod_disciplina_fkey;
  20 +
  21 +ALTER TABLE "pmieducar"."servidor_disciplina"
  22 + ADD CONSTRAINT servidor_disciplina_ref_cod_disciplina_fkey
  23 + FOREIGN KEY (ref_cod_disciplina)
  24 + REFERENCES modules.componente_curricular(id)
  25 + ON DELETE RESTRICT
  26 + ON UPDATE RESTRICT;
  27 +
  28 +ALTER TABLE "pmieducar"."servidor_disciplina"
  29 + DROP CONSTRAINT servidor_disciplina_pkey;
  30 +
  31 +ALTER TABLE "pmieducar"."servidor_disciplina"
  32 + ADD COLUMN ref_cod_curso integer;
  33 +
  34 +ALTER TABLE "pmieducar"."servidor_disciplina"
  35 + ADD CONSTRAINT servidor_disciplina_pkey
  36 + PRIMARY KEY (ref_cod_disciplina, ref_ref_cod_instituicao,
  37 + ref_cod_servidor, ref_cod_curso);
  38 +
  39 +-- //@UNDO
  40 +
  41 +ALTER TABLE "pmieducar"."servidor_disciplina"
  42 + DROP CONSTRAINT escola_serie_disciplina_ref_cod_disciplina_fkey;
  43 +
  44 +ALTER TABLE "pmieducar"."servidor_disciplina"
  45 + ADD CONSTRAINT servidor_disciplina_ref_cod_disciplina_fkey
  46 + FOREIGN KEY (ref_cod_disciplina)
  47 + REFERENCES pmieducar.disciplina(cod_disciplina)
  48 + ON DELETE RESTRICT
  49 + ON UPDATE RESTRICT;
  50 +
  51 +ALTER TABLE "pmieducar"."servidor_disciplina"
  52 + DROP CONSTRAINT servidor_disciplina_pkey;
  53 +
  54 +ALTER TABLE "pmieducar"."servidor_disciplina"
  55 + ADD CONSTRAINT servidor_disciplina_pkey
  56 + PRIMARY KEY (ref_cod_disciplina, ref_ref_cod_instituicao, ref_cod_servidor);
  57 +
  58 +ALTER TABLE "pmieducar"."servidor_disciplina" DROP COLUMN ref_cod_curso;
  59 +
  60 +-- //
0 61 \ No newline at end of file
... ...
ieducar/misc/database/ieducar.sql
... ... @@ -14321,7 +14321,8 @@ CREATE TABLE servidor_curso_ministra (
14321 14321 CREATE TABLE servidor_disciplina (
14322 14322 ref_cod_disciplina integer NOT NULL,
14323 14323 ref_ref_cod_instituicao integer NOT NULL,
14324   - ref_cod_servidor integer NOT NULL
  14324 + ref_cod_servidor integer NOT NULL,
  14325 + ref_cod_curso integer NOT NULL
14325 14326 );
14326 14327  
14327 14328  
... ... @@ -19941,6 +19942,7 @@ INSERT INTO changelog VALUES (13, &#39;Main&#39;, &#39;NOW()&#39;, &#39;NOW()&#39;, &#39;dbdeploy&#39;, &#39;13_adic
19941 19942 INSERT INTO changelog VALUES (14, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '14_adiciona_campo_etapa_modules_nota_componente_curricular_media.sql');
19942 19943 INSERT INTO changelog VALUES (15, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '15_atualiza_foreign_key_modules_falta_geral.sql');
19943 19944 INSERT INTO changelog VALUES (16, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '16_permissoes_para_modules_e_correcao_menus.sql');
  19945 +INSERT INTO changelog VALUES (17, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '17_adiciona_campo_curso_componente_ano_escolar_e_atualiza_constraint_servidor_disciplina.sql');
19944 19946  
19945 19947  
19946 19948 --
... ... @@ -27879,7 +27881,7 @@ ALTER TABLE ONLY servidor_curso_ministra
27879 27881 --
27880 27882  
27881 27883 ALTER TABLE ONLY servidor_disciplina
27882   - ADD CONSTRAINT servidor_disciplina_pkey PRIMARY KEY (ref_cod_disciplina, ref_ref_cod_instituicao, ref_cod_servidor);
  27884 + ADD CONSTRAINT servidor_disciplina_pkey PRIMARY KEY (ref_cod_disciplina, ref_ref_cod_instituicao, ref_cod_servidor, ref_cod_curso);
27883 27885  
27884 27886  
27885 27887 --
... ... @@ -28754,7 +28756,7 @@ CREATE UNIQUE INDEX componente_curricular_id_key ON componente_curricular USING
28754 28756  
28755 28757  
28756 28758 --
28757   --- Name: regra_avaliacao_id_key; Type: INDEX; Schema: modules; Owner: -; Tablespace:
  28759 +-- Name: regra_avaliacao_id_key; Type: INDEX; Schema: modules; Owner: -; Tablespace:
28758 28760 --
28759 28761  
28760 28762 CREATE UNIQUE INDEX regra_avaliacao_id_key ON regra_avaliacao USING btree (id);
... ... @@ -35368,7 +35370,7 @@ ALTER TABLE ONLY servidor_curso_ministra
35368 35370 --
35369 35371  
35370 35372 ALTER TABLE ONLY servidor_disciplina
35371   - ADD CONSTRAINT servidor_disciplina_ref_cod_disciplina_fkey FOREIGN KEY (ref_cod_disciplina) REFERENCES disciplina(cod_disciplina) ON UPDATE RESTRICT ON DELETE RESTRICT;
  35373 + ADD CONSTRAINT servidor_disciplina_ref_cod_disciplina_fkey FOREIGN KEY (ref_cod_disciplina) REFERENCES modules.componente_curricular(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
35372 35374  
35373 35375  
35374 35376 --
... ...