Commit d7c57e885157322511f71b43c290f7bd91aa82bc

Authored by Paula Bonot
Committed by GitHub
2 parents 1cc635ea e7c0fd20
Exists in 2.9 and in 7 other branches 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

Merge pull request #6199 from portabilis/issue-5882

Ajusta limitação de filtros para usuários que são "apenas" professores
ieducar/lib/Portabilis/Business/Professor.php
@@ -32,6 +32,23 @@ class Portabilis_Business_Professor @@ -32,6 +32,23 @@ class Portabilis_Business_Professor
32 return self::fetchPreparedQuery($sql, $options) == '1'; 32 return self::fetchPreparedQuery($sql, $options) == '1';
33 } 33 }
34 34
  35 + public static function isOnlyProfessor($instituicaoId, $userId)
  36 + {
  37 + $sql = "
  38 + SELECT DISTINCT funcao.professor
  39 + FROM pmieducar.servidor_funcao, pmieducar.funcao
  40 + WHERE funcao.cod_funcao = servidor_funcao.ref_cod_funcao
  41 + AND servidor_funcao.ref_cod_servidor = {$userId}
  42 + ";
  43 +
  44 + if (is_numeric($instituicaoId)) {
  45 + $sql .= " AND servidor_funcao.ref_ref_cod_instituicao = {$instituicaoId}";
  46 + }
  47 +
  48 + $funcoes = self::fetchPreparedQuery($sql);
  49 + return count($funcoes) == 1 && $funcoes[0]['professor'];
  50 + }
  51 +
35 public static function escolasAlocado($instituicaoId, $userId) 52 public static function escolasAlocado($instituicaoId, $userId)
36 { 53 {
37 if (self::necessarioVinculoTurma($instituicaoId)) { 54 if (self::necessarioVinculoTurma($instituicaoId)) {
ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php
@@ -16,9 +16,9 @@ class Portabilis_View_Helper_DynamicInput_Curso extends Portabilis_View_Helper_D @@ -16,9 +16,9 @@ class Portabilis_View_Helper_DynamicInput_Curso extends Portabilis_View_Helper_D
16 $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null); 16 $instituicaoId = $this->getInstituicaoId($options['instituicaoId'] ?? null);
17 $escolaId = $this->getEscolaId($options['escolaId'] ?? null); 17 $escolaId = $this->getEscolaId($options['escolaId'] ?? null);
18 $userId = $this->getCurrentUserId(); 18 $userId = $this->getCurrentUserId();
19 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); 19 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
20 20
21 - if ($instituicaoId && $escolaId && empty($resources) && $isProfessor) { 21 + if ($instituicaoId && $escolaId && empty($resources) && $isOnlyProfessor) {
22 $cursos = Portabilis_Business_Professor::cursosAlocado($instituicaoId, $escolaId, $userId); 22 $cursos = Portabilis_Business_Professor::cursosAlocado($instituicaoId, $escolaId, $userId);
23 $resources = Portabilis_Array_Utils::setAsIdValue($cursos, 'id', 'nome'); 23 $resources = Portabilis_Array_Utils::setAsIdValue($cursos, 'id', 'nome');
24 } elseif ($escolaId && empty($resources)) { 24 } elseif ($escolaId && empty($resources)) {
ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php
@@ -17,10 +17,10 @@ class Portabilis_View_Helper_DynamicInput_Serie extends Portabilis_View_Helper_D @@ -17,10 +17,10 @@ class Portabilis_View_Helper_DynamicInput_Serie extends Portabilis_View_Helper_D
17 $escolaId = $this->getEscolaId($options['escolaId'] ?? null); 17 $escolaId = $this->getEscolaId($options['escolaId'] ?? null);
18 $cursoId = $this->getCursoId($options['cursoId'] ?? null); 18 $cursoId = $this->getCursoId($options['cursoId'] ?? null);
19 $userId = $this->getCurrentUserId(); 19 $userId = $this->getCurrentUserId();
20 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); 20 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
21 21
22 - if ($isProfessor && Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId)) {  
23 - $series = Portabilis_Business_Professor::seriesAlocado($instituicaoId, $escolaId, $serieId, $userId); 22 + if ($isOnlyProfessor && Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId)) {
  23 + $resources = Portabilis_Business_Professor::seriesAlocado($instituicaoId, $escolaId, $cursoId, $userId);
24 } elseif ($escolaId && $cursoId && empty($resources)) { 24 } elseif ($escolaId && $cursoId && empty($resources)) {
25 $resources = App_Model_IedFinder::getSeries($instituicaoId = null, $escolaId, $cursoId); 25 $resources = App_Model_IedFinder::getSeries($instituicaoId = null, $escolaId, $cursoId);
26 } 26 }
ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php
@@ -19,9 +19,9 @@ class Portabilis_View_Helper_DynamicInput_Turma extends Portabilis_View_Helper_D @@ -19,9 +19,9 @@ class Portabilis_View_Helper_DynamicInput_Turma extends Portabilis_View_Helper_D
19 $naoFiltrarAno = $this->viewInstance->nao_filtrar_ano ?? null; 19 $naoFiltrarAno = $this->viewInstance->nao_filtrar_ano ?? null;
20 20
21 $userId = $this->getCurrentUserId(); 21 $userId = $this->getCurrentUserId();
22 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); 22 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
23 23
24 - if ($escolaId and $serieId and empty($resources) and $isProfessor) { 24 + if ($escolaId and $serieId and empty($resources) and $isOnlyProfessor) {
25 $resources = Portabilis_Business_Professor::turmasAlocado($instituicaoId, $escolaId, $serieId, $userId); 25 $resources = Portabilis_Business_Professor::turmasAlocado($instituicaoId, $escolaId, $serieId, $userId);
26 } elseif ($escolaId && $serieId && empty($resources)) { 26 } elseif ($escolaId && $serieId && empty($resources)) {
27 $resources = App_Model_IedFinder::getTurmas($escolaId, $serieId); 27 $resources = App_Model_IedFinder::getTurmas($escolaId, $serieId);
ieducar/modules/Avaliacao/Views/DiarioController.php
1 <?php 1 <?php
2 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'; 3 require_once 'Portabilis/Controller/Page/ListController.php';
36 require_once 'lib/Portabilis/View/Helper/Application.php'; 4 require_once 'lib/Portabilis/View/Helper/Application.php';
37 require_once 'Portabilis/Business/Professor.php'; 5 require_once 'Portabilis/Business/Professor.php';
38 6
39 -/**  
40 - * DiarioController class.  
41 - *  
42 - * @author Lucas D'Avila <lucasdavila@portabilis.com.br>  
43 - * @category i-Educar  
44 - * @license @@license@@  
45 - * @package Avaliacao  
46 - * @subpackage Modules  
47 - * @since Classe disponível desde a versão 1.1.0  
48 - * @version @@package_version@@  
49 - */  
50 -  
51 class DiarioController extends Portabilis_Controller_Page_ListController 7 class DiarioController extends Portabilis_Controller_Page_ListController
52 { 8 {
53 - protected $_titulo = 'Lan&ccedil;amento por turma';  
54 - protected $_processoAp = 642;  
55 -  
56 - public function Gerar() {  
57 -  
58 - $userId = Portabilis_Utils_User::currentUserId();  
59 - $componenteRequired = $isProfessor = Portabilis_Business_Professor::isProfessor(false, $userId);  
60 -  
61 - $this->inputsHelper()->input('ano', 'ano');  
62 - $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'curso', 'serie', 'turma', 'etapa'));  
63 - $this->inputsHelper()->dynamic(array('componenteCurricularForDiario'), array('required' => $componenteRequired));  
64 - $this->inputsHelper()->dynamic(array('matricula'), array('required' => FALSE )); 9 + protected $_titulo = 'Lançamento por turma';
  10 + protected $_processoAp = 642;
65 11
66 - $navegacaoTab = array('1' => 'Horizontal(padr&atilde;o)',  
67 - '2' => 'Vertical',); 12 + public function Gerar()
  13 + {
  14 + $userId = Portabilis_Utils_User::currentUserId();
  15 + $componenteRequired = Portabilis_Business_Professor::isOnlyProfessor(false, $userId);
68 16
69 - $options = array('label' =>'Navega&ccedil;&atilde;o do cursor(tab)',  
70 - 'resources' => $navegacaoTab,  
71 - 'required' => false,  
72 - 'inline' => true,  
73 - 'value' => $navegacaoTab[1]); 17 + $this->inputsHelper()->input('ano', 'ano');
  18 + $this->inputsHelper()->dynamic(['instituicao', 'escola', 'curso', 'serie', 'turma', 'etapa']);
  19 + $this->inputsHelper()->dynamic(['componenteCurricularForDiario'], ['required' => $componenteRequired]);
  20 + $this->inputsHelper()->dynamic(['matricula'], ['required' => false ]);
74 21
75 - $this->inputsHelper()->select('navegacao_tab', $options); 22 + $navegacaoTab = [
  23 + '1' => 'Horizontal(padrão)',
  24 + '2' => 'Vertical',
  25 + ];
76 26
77 - $this->inputsHelper()->hidden('mostrar_botao_replicar_todos', array('value' => $teste = config('legacy.app.faltas_notas.mostrar_botao_replicar'))); 27 + $options = [
  28 + 'label' =>'Navegação do cursor(tab)',
  29 + 'resources' => $navegacaoTab,
  30 + 'required' => false,
  31 + 'inline' => true,
  32 + 'value' => $navegacaoTab[1],
  33 + ];
78 34
79 - $this->loadResourceAssets($this->getDispatcher());  
80 - } 35 + $this->inputsHelper()->select('navegacao_tab', $options);
81 36
82 - protected function _preRender(){ 37 + $this->inputsHelper()->hidden('mostrar_botao_replicar_todos', ['value' => $teste = config('legacy.app.faltas_notas.mostrar_botao_replicar')]);
83 38
84 - parent::_preRender(); 39 + $this->loadResourceAssets($this->getDispatcher());
  40 + }
85 41
86 - $localizacao = new LocalizacaoSistema(); 42 + protected function _preRender()
  43 + {
  44 + parent::_preRender();
87 45
88 - $localizacao->entradaCaminhos( array(  
89 - $_SERVER['SERVER_NAME']."/intranet" => "In&iacute;cio",  
90 - "educar_index.php" => "Escola",  
91 - "" => "Lan&ccedil;amento de notas"  
92 - ));  
93 - $this->enviaLocalizacao($localizacao->montar(), true);  
94 - } 46 + $this->breadcrumb('Lançamento de faltas e notas', ['/intranet/educar_index.php' => 'Escola']);
  47 + }
95 } 48 }
96 ?> 49 ?>
97 50
ieducar/modules/DynamicInput/Views/ComponenteCurricularController.php
1 <?php 1 <?php
2 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 'lib/Portabilis/Controller/ApiCoreController.php'; 3 require_once 'lib/Portabilis/Controller/ApiCoreController.php';
36 require_once 'Portabilis/Business/Professor.php'; 4 require_once 'Portabilis/Business/Professor.php';
37 5
38 -/**  
39 - * ComponenteCurricularController class.  
40 - *  
41 - * @author Lucas D'Avila <lucasdavila@portabilis.com.br>  
42 - * @category i-Educar  
43 - * @license @@license@@  
44 - * @package Avaliacao  
45 - * @subpackage Modules  
46 - * @since Classe disponível desde a versão 1.1.0  
47 - * @version @@package_version@@  
48 - */  
49 class ComponenteCurricularController extends ApiCoreController 6 class ComponenteCurricularController extends ApiCoreController
50 { 7 {
51 -  
52 - protected function canGetComponentesCurriculares() {  
53 - return $this->validatesId('turma') &&  
54 - $this->validatesPresenceOf('ano');  
55 - }  
56 -  
57 - private function agrupaComponentesCurriculares($componentesCurriculares){  
58 - $options = array();  
59 -  
60 - foreach ($componentesCurriculares as $componenteCurricular) {  
61 - $areaConhecimento = (($componenteCurricular['secao_area_conhecimento'] != '') ? $componenteCurricular['secao_area_conhecimento'] . ' - ' : '') . $componenteCurricular['area_conhecimento'];  
62 - $options['__' . $componenteCurricular['id']] = array(  
63 - 'value' => mb_strtoupper($componenteCurricular['nome'], 'UTF-8'),  
64 - 'group' => mb_strtoupper($areaConhecimento, 'UTF-8')  
65 - ); 8 + protected function canGetComponentesCurriculares()
  9 + {
  10 + return
  11 + $this->validatesId('turma') &&
  12 + $this->validatesPresenceOf('ano');
66 } 13 }
67 14
68 - return $options;  
69 -  
70 - }  
71 -  
72 - protected function getComponentesCurricularesForDiario(){  
73 - if ($this->canGetComponentesCurriculares()) {  
74 - $userId = $this->getSession()->id_pessoa;  
75 - $instituicaoId = $this->getRequest()->instituicao_id;  
76 - $turmaId = $this->getRequest()->turma_id;  
77 - $ano = $this->getRequest()->ano;  
78 - $etapa = $this->getRequest()->etapa; 15 + private function agrupaComponentesCurriculares($componentesCurriculares)
  16 + {
  17 + $options = [];
  18 +
  19 + foreach ($componentesCurriculares as $componenteCurricular) {
  20 + $areaConhecimento = (($componenteCurricular['secao_area_conhecimento'] != '') ? $componenteCurricular['secao_area_conhecimento'] . ' - ' : '') . $componenteCurricular['area_conhecimento'];
  21 + $options[
  22 + '__' . $componenteCurricular['id']
  23 + ] = [
  24 + 'value' => mb_strtoupper($componenteCurricular['nome'], 'UTF-8'),
  25 + 'group' => mb_strtoupper($areaConhecimento, 'UTF-8')
  26 + ];
  27 + }
79 28
80 - if($etapa == ""){  
81 - $etapa = "0"; 29 + return $options;
82 } 30 }
83 31
84 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId);  
85 -  
86 - if ($isProfessor) {  
87 - $componentesCurriculares = Portabilis_Business_Professor::componentesCurricularesAlocado($instituicaoId, $turmaId, $ano, $userId);  
88 - }  
89 - else{  
90 - $sql = "select cc.id,  
91 - cc.nome,  
92 - ac.nome as area_conhecimento,  
93 - ac.secao as area_conhecimento_secao,  
94 - cc.ordenamento  
95 - from pmieducar.turma,  
96 - modules.componente_curricular_turma as cct,  
97 - modules.componente_curricular as cc,  
98 - modules.area_conhecimento as ac,  
99 - pmieducar.escola_ano_letivo as al  
100 - where turma.cod_turma = $1 and  
101 - cct.turma_id = turma.cod_turma and  
102 - cct.componente_curricular_id = cc.id and al.ano = $2 and  
103 - turma.ref_ref_cod_escola = al.ref_cod_escola and  
104 - cc.area_conhecimento_id = ac.id and  
105 - (turma.ref_cod_disciplina_dispensada <> cc.id OR turma.ref_cod_disciplina_dispensada is null) and  
106 - (case when cct.etapas_especificas = 1 then $3 = ANY (string_to_array(cct.etapas_utilizadas,',')::int[]) else true end)  
107 - order by ac.secao, ac.nome, cc.ordenamento, cc.nome";  
108 -  
109 - $componentesCurriculares = $this->fetchPreparedQuery($sql, array($turmaId, $ano, $etapa));  
110 -  
111 - if (count($componentesCurriculares) < 1) {  
112 - $sql = "select cc.id,  
113 - cc.nome,  
114 - ac.nome as area_conhecimento,  
115 - ac.secao as secao_area_conhecimento,  
116 - cc.ordenamento  
117 - from pmieducar.turma as t  
118 - inner join pmieducar.escola_serie_disciplina esd on (esd.ref_ref_cod_escola = t.ref_ref_cod_escola)  
119 - inner join modules.componente_curricular cc on (esd.ref_cod_disciplina = cc.id)  
120 - inner join modules.area_conhecimento ac on (cc.area_conhecimento_id = ac.id)  
121 - inner join pmieducar.escola_ano_letivo al on (esd.ref_ref_cod_escola = al.ref_cod_escola)  
122 - where t.cod_turma = $1 and  
123 - esd.ref_ref_cod_serie = t.ref_ref_cod_serie and  
124 - al.ano = $2 and  
125 - t.ativo = 1 and  
126 - esd.ativo = 1 and  
127 - al.ativo = 1 and  
128 - $2 = ANY(esd.anos_letivos) and  
129 - (t.ref_cod_disciplina_dispensada <> cc.id OR t.ref_cod_disciplina_dispensada is null) and  
130 - (case when esd.etapas_especificas = 1 then $3 = ANY (string_to_array(esd.etapas_utilizadas,',')::int[]) else true end)  
131 - order by ac.secao, ac.nome, cc.ordenamento, cc.nome";  
132 -  
133 - $componentesCurriculares = $this->fetchPreparedQuery($sql, array($turmaId, $ano, $etapa)); 32 + protected function getComponentesCurricularesForDiario()
  33 + {
  34 + if ($this->canGetComponentesCurriculares()) {
  35 + $userId = $this->getSession()->id_pessoa;
  36 + $instituicaoId = $this->getRequest()->instituicao_id;
  37 + $turmaId = $this->getRequest()->turma_id;
  38 + $ano = $this->getRequest()->ano;
  39 + $etapa = $this->getRequest()->etapa;
  40 +
  41 + if ($etapa == '') {
  42 + $etapa = '0';
  43 + }
  44 +
  45 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
  46 +
  47 + if ($isOnlyProfessor) {
  48 + $componentesCurriculares = Portabilis_Business_Professor::componentesCurricularesAlocado($instituicaoId, $turmaId, $ano, $userId);
  49 + } else {
  50 + $sql = "
  51 + SELECT
  52 + cc.id,
  53 + cc.nome,
  54 + ac.nome as area_conhecimento,
  55 + ac.secao as area_conhecimento_secao,
  56 + cc.ordenamento
  57 + FROM
  58 + pmieducar.turma,
  59 + modules.componente_curricular_turma as cct,
  60 + modules.componente_curricular as cc,
  61 + modules.area_conhecimento as ac,
  62 + pmieducar.escola_ano_letivo as al
  63 + WHERE turma.cod_turma = $1
  64 + AND cct.turma_id = turma.cod_turma
  65 + AND cct.componente_curricular_id = cc.id
  66 + AND al.ano = $2
  67 + AND turma.ref_ref_cod_escola = al.ref_cod_escola
  68 + AND cc.area_conhecimento_id = ac.id
  69 + AND (turma.ref_cod_disciplina_dispensada <> cc.id OR turma.ref_cod_disciplina_dispensada is null)
  70 + AND (
  71 + CASE
  72 + WHEN cct.etapas_especificas = 1
  73 + THEN $3 = ANY (string_to_array(cct.etapas_utilizadas,',')::int[])
  74 + ELSE true
  75 + END
  76 + )
  77 + ORDER BY
  78 + ac.secao,
  79 + ac.nome,
  80 + cc.ordenamento,
  81 + cc.nome
  82 + ";
  83 +
  84 + $componentesCurriculares = $this->fetchPreparedQuery($sql, [$turmaId, $ano, $etapa]);
  85 +
  86 + if (count($componentesCurriculares) < 1) {
  87 + $sql = "
  88 + SELECT
  89 + cc.id,
  90 + cc.nome,
  91 + ac.nome as area_conhecimento,
  92 + ac.secao as secao_area_conhecimento,
  93 + cc.ordenamento
  94 + FROM pmieducar.turma as t
  95 + INNER JOIN pmieducar.escola_serie_disciplina esd on (esd.ref_ref_cod_escola = t.ref_ref_cod_escola)
  96 + INNER JOIN modules.componente_curricular cc on (esd.ref_cod_disciplina = cc.id)
  97 + INNER JOIN modules.area_conhecimento ac on (cc.area_conhecimento_id = ac.id)
  98 + INNER JOIN pmieducar.escola_ano_letivo al on (esd.ref_ref_cod_escola = al.ref_cod_escola)
  99 + WHERE t.cod_turma = $1
  100 + AND esd.ref_ref_cod_serie = t.ref_ref_cod_serie
  101 + AND al.ano = $2
  102 + AND t.ativo = 1
  103 + AND esd.ativo = 1
  104 + AND al.ativo = 1
  105 + AND $2 = ANY(esd.anos_letivos)
  106 + AND (t.ref_cod_disciplina_dispensada <> cc.id OR t.ref_cod_disciplina_dispensada is null)
  107 + AND (
  108 + CASE
  109 + WHEN esd.etapas_especificas = 1
  110 + THEN $3 = ANY (string_to_array(esd.etapas_utilizadas,',')::int[])
  111 + ELSE true
  112 + END
  113 + )
  114 + ORDER BY
  115 + ac.secao,
  116 + ac.nome,
  117 + cc.ordenamento,
  118 + cc.nome
  119 + ";
  120 +
  121 + $componentesCurriculares = $this->fetchPreparedQuery($sql, [$turmaId, $ano, $etapa]);
  122 + }
  123 + }
  124 +
  125 + $options = [];
  126 + $options = $this->agrupaComponentesCurriculares($componentesCurriculares);
  127 +
  128 + return ['options' => $options];
134 } 129 }
135 - }  
136 -  
137 - $options = array();  
138 - $options = $this->agrupaComponentesCurriculares($componentesCurriculares);  
139 - return array('options' => $options);  
140 } 130 }
141 - }  
142 -  
143 -  
144 - protected function getComponentesCurriculares() {  
145 - if ($this->canGetComponentesCurriculares()) {  
146 -  
147 - $userId = $this->getSession()->id_pessoa;  
148 - $instituicaoId = $this->getRequest()->instituicao_id;  
149 - $turmaId = $this->getRequest()->turma_id;  
150 - $ano = $this->getRequest()->ano;  
151 -  
152 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId);  
153 -  
154 - if ($isProfessor) {  
155 - $componentesCurriculares = Portabilis_Business_Professor::componentesCurricularesAlocado($instituicaoId, $turmaId, $ano, $userId);  
156 - }  
157 - else{  
158 - $sql = "select cc.id,  
159 - cc.nome,  
160 - ac.nome as area_conhecimento,  
161 - ac.secao as area_conhecimento_secao,  
162 - cc.ordenamento  
163 - from pmieducar.turma,  
164 - modules.componente_curricular_turma as cct,  
165 - modules.componente_curricular as cc,  
166 - modules.area_conhecimento as ac,  
167 - pmieducar.escola_ano_letivo as al  
168 - where turma.cod_turma = $1 and  
169 - cct.turma_id = turma.cod_turma and  
170 - cct.escola_id = turma.ref_ref_cod_escola and  
171 - cct.componente_curricular_id = cc.id and al.ano = $2 and  
172 - cct.escola_id = al.ref_cod_escola and  
173 - cc.area_conhecimento_id = ac.id  
174 - order by ac.secao, ac.nome, cc.ordenamento, cc.nome";  
175 -  
176 -  
177 - $componentesCurriculares = $this->fetchPreparedQuery($sql, array($turmaId, $ano));  
178 -  
179 - if (count($ComponentesCurriculares) < 1) {  
180 - $sql = "select cc.id,  
181 - cc.nome,  
182 - ac.nome as area_conhecimento,  
183 - ac.secao as secao_area_conhecimento,  
184 - cc.ordenamento  
185 - from pmieducar.turma as t,  
186 - pmieducar.escola_serie_disciplina as esd,  
187 - modules.componente_curricular as cc,  
188 - modules.area_conhecimento as ac,  
189 - pmieducar.escola_ano_letivo as al  
190 - where t.cod_turma = $1 and  
191 - esd.ref_ref_cod_escola = t.ref_ref_cod_escola and  
192 - esd.ref_ref_cod_serie = t.ref_ref_cod_serie and  
193 - esd.ref_cod_disciplina = cc.id and al.ano = $2 and  
194 - esd.ref_ref_cod_escola = al.ref_cod_escola and t.ativo = 1 and  
195 - esd.ativo = 1 and  
196 - al.ativo = 1 and  
197 - $2 = ANY(esd.anos_letivos) AND  
198 - cc.area_conhecimento_id = ac.id  
199 - order by ac.secao, ac.nome, cc.ordenamento, cc.nome";  
200 -  
201 - $componentesCurriculares = $this->fetchPreparedQuery($sql, array($turmaId, $ano)); 131 +
  132 + protected function getComponentesCurriculares()
  133 + {
  134 + if ($this->canGetComponentesCurriculares()) {
  135 + $userId = $this->getSession()->id_pessoa;
  136 + $instituicaoId = $this->getRequest()->instituicao_id;
  137 + $turmaId = $this->getRequest()->turma_id;
  138 + $ano = $this->getRequest()->ano;
  139 +
  140 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
  141 +
  142 + if ($isOnlyProfessor) {
  143 + $componentesCurriculares = Portabilis_Business_Professor::componentesCurricularesAlocado($instituicaoId, $turmaId, $ano, $userId);
  144 + } else {
  145 + $sql = "
  146 + SELECT
  147 + cc.id,
  148 + cc.nome,
  149 + ac.nome as area_conhecimento,
  150 + ac.secao as area_conhecimento_secao,
  151 + cc.ordenamento
  152 + FROM
  153 + pmieducar.turma,
  154 + modules.componente_curricular_turma as cct,
  155 + modules.componente_curricular as cc,
  156 + modules.area_conhecimento as ac,
  157 + pmieducar.escola_ano_letivo as al
  158 + WHERE turma.cod_turma = $1
  159 + AND cct.turma_id = turma.cod_turma
  160 + AND cct.escola_id = turma.ref_ref_cod_escola
  161 + AND cct.componente_curricular_id = cc.id
  162 + AND al.ano = $2
  163 + AND cct.escola_id = al.ref_cod_escola
  164 + AND cc.area_conhecimento_id = ac.id
  165 + ORDER BY
  166 + ac.secao,
  167 + ac.nome,
  168 + cc.ordenamento,
  169 + cc.nome
  170 + ";
  171 +
  172 + $componentesCurriculares = $this->fetchPreparedQuery($sql, [$turmaId, $ano]);
  173 +
  174 + if (count($componentesCurriculares) < 1) {
  175 + $sql = "
  176 + SELECT
  177 + cc.id,
  178 + cc.nome,
  179 + ac.nome as area_conhecimento,
  180 + ac.secao as secao_area_conhecimento,
  181 + cc.ordenamento
  182 + FROM
  183 + pmieducar.turma as t,
  184 + pmieducar.escola_serie_disciplina as esd,
  185 + modules.componente_curricular as cc,
  186 + modules.area_conhecimento as ac,
  187 + pmieducar.escola_ano_letivo as al
  188 + WHERE t.cod_turma = $1
  189 + AND esd.ref_ref_cod_escola = t.ref_ref_cod_escola
  190 + AND esd.ref_ref_cod_serie = t.ref_ref_cod_serie
  191 + AND esd.ref_cod_disciplina = cc.id
  192 + AND al.ano = $2
  193 + AND esd.ref_ref_cod_escola = al.ref_cod_escola
  194 + AND t.ativo = 1
  195 + AND esd.ativo = 1
  196 + AND al.ativo = 1
  197 + AND $2 = ANY(esd.anos_letivos)
  198 + AND cc.area_conhecimento_id = ac.id
  199 + ORDER BY
  200 + ac.secao,
  201 + ac.nome,
  202 + cc.ordenamento,
  203 + cc.nome
  204 + ";
  205 +
  206 + $componentesCurriculares = $this->fetchPreparedQuery($sql, [$turmaId, $ano]);
  207 + }
  208 + }
  209 +
  210 + $options = [];
  211 + $options = $this->agrupaComponentesCurriculares($componentesCurriculares);
  212 +
  213 + return ['options' => $options];
202 } 214 }
203 - } 215 + }
204 216
205 - $options = array();  
206 - $options = $this->agrupaComponentesCurriculares($componentesCurriculares);  
207 - return array('options' => $options); 217 + public function Gerar()
  218 + {
  219 + if ($this->isRequestFor('get', 'componentesCurriculares')) {
  220 + $this->appendResponse($this->getComponentesCurriculares());
  221 + } elseif ($this->isRequestFor('get', 'componentesCurricularesForDiario')) {
  222 + $this->appendResponse($this->getComponentesCurricularesForDiario());
  223 + } else {
  224 + $this->notImplementedOperationError();
  225 + }
208 } 226 }
209 - }  
210 -  
211 - public function Gerar() {  
212 - if ($this->isRequestFor('get', 'componentesCurriculares'))  
213 - $this->appendResponse($this->getComponentesCurriculares());  
214 - elseif($this->isRequestFor('get', 'componentesCurricularesForDiario'))  
215 - $this->appendResponse($this->getComponentesCurricularesForDiario());  
216 - else  
217 - $this->notImplementedOperationError();  
218 - }  
219 } 227 }
ieducar/modules/DynamicInput/Views/CursoController.php
1 <?php 1 <?php
2 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 'lib/Portabilis/Controller/ApiCoreController.php';  
36 -require_once 'Portabilis/Business/Professor.php';  
37 -  
38 -/**  
39 - * CursoController class.  
40 - *  
41 - * @author Lucas D'Avila <lucasdavila@portabilis.com.br>  
42 - * @category i-Educar  
43 - * @license @@license@@  
44 - * @package Avaliacao  
45 - * @subpackage Modules  
46 - * @since Classe disponível desde a versão 1.1.0  
47 - * @version @@package_version@@  
48 - */  
49 class CursoController extends ApiCoreController 3 class CursoController extends ApiCoreController
50 { 4 {
  5 + protected function canGetCursos()
  6 + {
  7 + return
  8 + $this->validatesId('instituicao') &&
  9 + $this->validatesId('escola');
  10 + }
51 11
52 - protected function canGetCursos() {  
53 - return $this->validatesId('instituicao') &&  
54 - $this->validatesId('escola');  
55 - } 12 + protected function getCursos()
  13 + {
  14 + if ($this->canGetCursos()) {
  15 + $userId = $this->getSession()->id_pessoa;
  16 + $instituicaoId = $this->getRequest()->instituicao_id;
  17 + $escolaId = $this->getRequest()->escola_id;
  18 + $ano = $this->getRequest()->ano;
56 19
57 - protected function getCursos() {  
58 - if ($this->canGetCursos()) {  
59 - $userId = $this->getSession()->id_pessoa;  
60 - $instituicaoId = $this->getRequest()->instituicao_id;  
61 - $escolaId = $this->getRequest()->escola_id;  
62 - $ano = $this->getRequest()->ano; 20 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
63 21
64 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); 22 + if ($isOnlyProfessor) {
  23 + $cursos = Portabilis_Business_Professor::cursosAlocado($instituicaoId, $escolaId, $userId);
  24 + } else {
  25 + $params = [ $escolaId ];
65 26
66 - if ($isProfessor)  
67 - $cursos = Portabilis_Business_Professor::cursosAlocado($instituicaoId, $escolaId, $userId); 27 + $sql = '
  28 + SELECT
  29 + c.cod_curso as id,
  30 + c.nm_curso as nome
  31 + FROM
  32 + pmieducar.curso c,
  33 + pmieducar.escola_curso ec
  34 + WHERE ec.ref_cod_escola = $1
  35 + AND ec.ref_cod_curso = c.cod_curso
  36 + AND ec.ativo = 1 AND c.ativo = 1
  37 + ';
68 38
69 - else {  
70 - $params = [ $escolaId ]; 39 + if (!empty($ano)) {
  40 + $params[] = $ano;
  41 + $sql .= ' AND $2 = ANY(ec.anos_letivos) ';
  42 + }
71 43
72 - $sql = ' SELECT c.cod_curso as id, c.nm_curso as nome  
73 - FROM pmieducar.curso c, pmieducar.escola_curso ec  
74 - WHERE ec.ref_cod_escola = $1 AND ec.ref_cod_curso =  
75 - c.cod_curso AND ec.ativo = 1 AND c.ativo = 1 '; 44 + $sql .= ' ORDER BY c.nm_curso ASC ';
76 45
77 - if (!empty($ano)) {  
78 - $params[] = $ano;  
79 - $sql .= ' AND $2 = ANY(ec.anos_letivos) ';  
80 - }  
81 - $sql .= ' ORDER BY c.nm_curso ASC '; 46 + $cursos = $this->fetchPreparedQuery($sql, $params);
  47 + }
82 48
83 - $cursos = $this->fetchPreparedQuery($sql, $params);  
84 - } 49 + $options = [];
  50 + foreach ($cursos as $curso) {
  51 + $options['__' . $curso['id']] = $this->toUtf8($curso['nome']);
  52 + }
85 53
86 - $options = array();  
87 - foreach ($cursos as $curso)  
88 - $options['__' . $curso['id']] = $this->toUtf8($curso['nome']);  
89 -  
90 - return array('options' => $options); 54 + return ['options' => $options];
  55 + }
91 } 56 }
92 - }  
93 57
94 - public function Gerar() {  
95 - if ($this->isRequestFor('get', 'cursos'))  
96 - $this->appendResponse($this->getCursos());  
97 - else  
98 - $this->notImplementedOperationError();  
99 - }  
100 -}  
101 \ No newline at end of file 58 \ No newline at end of file
  59 + public function Gerar()
  60 + {
  61 + if ($this->isRequestFor('get', 'cursos')) {
  62 + $this->appendResponse($this->getCursos());
  63 + } else {
  64 + $this->notImplementedOperationError();
  65 + }
  66 + }
  67 +}
ieducar/modules/DynamicInput/Views/SerieController.php
@@ -22,10 +22,10 @@ class SerieController extends ApiCoreController @@ -22,10 +22,10 @@ class SerieController extends ApiCoreController
22 $cursoId = $this->getRequest()->curso_id; 22 $cursoId = $this->getRequest()->curso_id;
23 $ano = $this->getRequest()->ano; 23 $ano = $this->getRequest()->ano;
24 24
25 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); 25 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
26 $canLoadSeriesAlocado = Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId); 26 $canLoadSeriesAlocado = Portabilis_Business_Professor::canLoadSeriesAlocado($instituicaoId);
27 27
28 - if ($isProfessor && $canLoadSeriesAlocado) { 28 + if ($isOnlyProfessor && $canLoadSeriesAlocado) {
29 $resources = Portabilis_Business_Professor::seriesAlocado($instituicaoId, $escolaId, $cursoId, $userId); 29 $resources = Portabilis_Business_Professor::seriesAlocado($instituicaoId, $escolaId, $cursoId, $userId);
30 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome'); 30 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome');
31 } elseif ($escolaId && $cursoId && empty($resources)) { 31 } elseif ($escolaId && $cursoId && empty($resources)) {
ieducar/modules/DynamicInput/Views/TurmaController.php
1 <?php 1 <?php
2 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 'lib/Portabilis/Controller/ApiCoreController.php'; 3 require_once 'lib/Portabilis/Controller/ApiCoreController.php';
36 require_once 'Portabilis/Business/Professor.php'; 4 require_once 'Portabilis/Business/Professor.php';
37 5
38 -/**  
39 - * CursoController class.  
40 - *  
41 - * @author Lucas D'Avila <lucasdavila@portabilis.com.br>  
42 - * @category i-Educar  
43 - * @license @@license@@  
44 - * @package Avaliacao  
45 - * @subpackage Modules  
46 - * @since Classe disponível desde a versão 1.1.0  
47 - * @version @@package_version@@  
48 - */  
49 class TurmaController extends ApiCoreController 6 class TurmaController extends ApiCoreController
50 { 7 {
  8 + protected function canGetTurmas()
  9 + {
  10 + return
  11 + $this->validatesId('instituicao') &&
  12 + $this->validatesId('escola') &&
  13 + $this->validatesId('serie');
  14 + }
51 15
52 - protected function canGetTurmas() {  
53 - return $this->validatesId('instituicao') &&  
54 - $this->validatesId('escola') &&  
55 - $this->validatesId('serie');  
56 - }  
57 -  
58 - protected function turmasPorAno($escolaId, $ano) {  
59 - $anoLetivo = new clsPmieducarEscolaAnoLetivo();  
60 - $anoLetivo->ref_cod_escola = $escolaId;  
61 - $anoLetivo->ano = $ano;  
62 - $anoLetivo = $anoLetivo->detalhe();  
63 -  
64 - return ($anoLetivo['turmas_por_ano'] == 1);  
65 - }  
66 -  
67 - protected function getTurmas() {  
68 - if ($this->canGetTurmas()) {  
69 - $userId = $this->getSession()->id_pessoa;  
70 - $instituicaoId = $this->getRequest()->instituicao_id;  
71 - $escolaId = $this->getRequest()->escola_id;  
72 - $serieId = $this->getRequest()->serie_id;  
73 - $ano = $this->getRequest()->ano;  
74 - $anoEmAndamento = $this->getRequest()->ano_em_andamento;  
75 -  
76 - $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId);  
77 -  
78 - if ($isProfessor)  
79 - $turmas = Portabilis_Business_Professor::turmasAlocado($instituicaoId, $escolaId, $serieId, $userId);  
80 -  
81 - else {  
82 - if(is_numeric($ano)){  
83 -$sql = "select cod_turma as id, nm_turma || ' - ' || COALESCE(ano::varchar,'SEM ANO') as nome from pmieducar.turma where ref_ref_cod_escola = $1  
84 - and (ref_ref_cod_serie = $2 or ref_ref_cod_serie_mult = $2) and ativo = 1 and  
85 - visivel != 'f' and turma.ano = $3 order by nm_turma asc";  
86 -  
87 - $turmas = $this->fetchPreparedQuery($sql, array($escolaId, $serieId, $ano));  
88 - }else{  
89 - $sql = "select cod_turma as id, nm_turma || ' - ' || COALESCE(ano::varchar,'SEM ANO') as nome from pmieducar.turma where ref_ref_cod_escola = $1  
90 - and (ref_ref_cod_serie = $2 or ref_ref_cod_serie_mult = $2) and ativo = 1 and  
91 - visivel != 'f' order by nm_turma asc";  
92 -  
93 - $turmas = $this->fetchPreparedQuery($sql, array($escolaId, $serieId));  
94 - }  
95 -  
96 - }  
97 -  
98 - // caso no ano letivo esteja definido para filtrar turmas por ano,  
99 - // somente retorna as turmas do ano letivo. 16 + protected function turmasPorAno($escolaId, $ano)
  17 + {
  18 + $anoLetivo = new clsPmieducarEscolaAnoLetivo();
  19 + $anoLetivo->ref_cod_escola = $escolaId;
  20 + $anoLetivo->ano = $ano;
  21 + $anoLetivo = $anoLetivo->detalhe();
100 22
101 - if ($ano && $this->turmasPorAno($escolaId, $ano)) {  
102 - foreach ($turmas as $index => $t) {  
103 - $turma = new clsPmieducarTurma();  
104 - $turma->cod_turma = $t['id'];  
105 - $turma = $turma->detalhe(); 23 + return ($anoLetivo['turmas_por_ano'] == 1);
  24 + }
106 25
107 - if ($turma['ano'] != $ano)  
108 - unset($turmas[$index]); 26 + protected function getTurmas()
  27 + {
  28 + if ($this->canGetTurmas()) {
  29 + $userId = $this->getSession()->id_pessoa;
  30 + $instituicaoId = $this->getRequest()->instituicao_id;
  31 + $escolaId = $this->getRequest()->escola_id;
  32 + $serieId = $this->getRequest()->serie_id;
  33 + $ano = $this->getRequest()->ano;
  34 + $anoEmAndamento = $this->getRequest()->ano_em_andamento;
  35 +
  36 + $isOnlyProfessor = Portabilis_Business_Professor::isOnlyProfessor($instituicaoId, $userId);
  37 +
  38 + if ($isOnlyProfessor) {
  39 + $turmas = Portabilis_Business_Professor::turmasAlocado($instituicaoId, $escolaId, $serieId, $userId);
  40 + } else {
  41 + if (is_numeric($ano)) {
  42 + $sql = "
  43 + SELECT
  44 + cod_turma AS id,
  45 + nm_turma || ' - ' || COALESCE(ano::varchar,'SEM ANO') AS nome
  46 + FROM pmieducar.turma
  47 + WHERE ref_ref_cod_escola = $1
  48 + AND (
  49 + ref_ref_cod_serie = $2
  50 + OR ref_ref_cod_serie_mult = $2
  51 + )
  52 + AND ativo = 1
  53 + AND visivel != 'f'
  54 + AND turma.ano = $3
  55 + ORDER BY nm_turma asc
  56 + ";
  57 +
  58 + $turmas = $this->fetchPreparedQuery($sql, [$escolaId, $serieId, $ano]);
  59 + } else {
  60 + $sql = "
  61 + SELECT
  62 + cod_turma AS id,
  63 + nm_turma || ' - ' || COALESCE(ano::varchar,'SEM ANO') AS nome
  64 + FROM pmieducar.turma
  65 + WHERE ref_ref_cod_escola = $1
  66 + AND (
  67 + ref_ref_cod_serie = $2
  68 + OR ref_ref_cod_serie_mult = $2
  69 + ) and ativo = 1
  70 + AND visivel != 'f'
  71 + ORDER BY nm_turma asc
  72 + ";
  73 +
  74 + $turmas = $this->fetchPreparedQuery($sql, [$escolaId, $serieId]);
  75 + }
  76 + }
  77 +
  78 + // caso no ano letivo esteja definido para filtrar turmas por ano,
  79 + // somente retorna as turmas do ano letivo.
  80 +
  81 + if ($ano && $this->turmasPorAno($escolaId, $ano)) {
  82 + foreach ($turmas as $index => $t) {
  83 + $turma = new clsPmieducarTurma();
  84 + $turma->cod_turma = $t['id'];
  85 + $turma = $turma->detalhe();
  86 +
  87 + if ($turma['ano'] != $ano) {
  88 + unset($turmas[$index]);
  89 + }
  90 + }
  91 + }
  92 +
  93 + if ($anoEmAndamento == 1) {
  94 + foreach ($turmas as $index => $t) {
  95 + $turma = new clsPmieducarTurma();
  96 + $turma->cod_turma = $t['id'];
  97 + $turma = $turma->checaAnoLetivoEmAndamento();
  98 +
  99 + if (!$turma) {
  100 + unset($turmas[$index]);
  101 + }
  102 + }
  103 + }
  104 +
  105 + $options = [];
  106 + foreach ($turmas as $turma) {
  107 + $options['__' . $turma['id']] = mb_strtoupper($turma['nome'], 'UTF-8');
  108 + }
  109 +
  110 + return ['options' => $options];
109 } 111 }
110 - }  
111 -  
112 - if ($anoEmAndamento == 1) {  
113 - foreach ($turmas as $index => $t) {  
114 - $turma = new clsPmieducarTurma();  
115 - $turma->cod_turma = $t['id'];  
116 - $turma = $turma->checaAnoLetivoEmAndamento(); 112 + }
117 113
118 - if (!$turma)  
119 - unset($turmas[$index]); 114 + public function Gerar()
  115 + {
  116 + if ($this->isRequestFor('get', 'turmas')) {
  117 + $this->appendResponse($this->getTurmas());
  118 + } else {
  119 + $this->notImplementedOperationError();
120 } 120 }
121 - }  
122 -  
123 - $options = array();  
124 - foreach ($turmas as $turma)  
125 - $options['__' . $turma['id']] = mb_strtoupper($turma['nome'], 'UTF-8');  
126 -  
127 - return array('options' => $options);  
128 } 121 }
129 - }  
130 -  
131 - public function Gerar() {  
132 - if ($this->isRequestFor('get', 'turmas'))  
133 - $this->appendResponse($this->getTurmas());  
134 - else  
135 - $this->notImplementedOperationError();  
136 - }  
137 } 122 }