Commit 2bb83ebf2914c88189cdb4699627faa91733e55d

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

Atualizada interface de Quadro de Horários

 * Cadastro de horários no quadro agora depende de {{{ComponenteCurricular_Model_Componente}}}. Apenas os componentes curriculares cadastros para a escola-série serão listados como opções para cadastro
 * Corrigido bug de SQL em {{{ComponenteCurricular_Model_AnoEscolar::findComponentePorSerie()}}}
ieducar/intranet/educar_quadro_horario_horarios_cad.php
... ... @@ -32,6 +32,8 @@ require_once 'include/clsBase.inc.php';
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.
... ... @@ -192,20 +194,20 @@ class indice extends clsCadastro
192 194  
193 195 function Gerar()
194 196 {
195   -
196   - if ($_POST)
  197 + if ($_POST) {
197 198 foreach ($_POST as $campo => $val) {
198 199 $this->$campo = ( $this->$campo ) ? $this->$campo : $val;
199 200 }
  201 + }
200 202  
201   - $obrigatorio = TRUE;
202   - $desabilitado = TRUE;
203   - $get_escola = TRUE;
204   - $get_curso = TRUE;
205   - $get_escola_curso_serie = TRUE;
206   - $get_turma = TRUE;
  203 + $obrigatorio = TRUE;
  204 + $desabilitado = TRUE;
  205 + $get_escola = TRUE;
  206 + $get_curso = TRUE;
  207 + $get_escola_curso_serie = TRUE;
  208 + $get_turma = TRUE;
207 209  
208   - include('include/pmieducar/educar_campo_lista.php');
  210 + include 'include/pmieducar/educar_campo_lista.php';
209 211  
210 212 $this->campoQuebra();
211 213  
... ... @@ -215,26 +217,44 @@ class indice extends clsCadastro
215 217  
216 218 // foreign keys
217 219 $opcoes_disc = array('' => 'Selecione uma disciplina');
218   - $obj_turm_disc = new clsPmieducarDisciplinaSerie();
219   - $lst_turm_disc = $obj_turm_disc->lista(NULL, $this->ref_ref_cod_serie, 1);
220 220  
221   - if ($lst_turm_disc) {
222   - foreach ($lst_turm_disc as $registro) {
223   - $obj_disc = new clsPmieducarDisciplina($registro['ref_cod_disciplina'],
224   - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
  221 + // Componentes curriculares da série
  222 + $escolaSerieDisciplina = new clsPmieducarEscolaSerieDisciplina();
  223 + $escolaSerieDisciplinas = $escolaSerieDisciplina->lista($this->ref_ref_cod_serie,
  224 + $this->ref_cod_escola, NULL, 1);
  225 +
  226 + if (0 == count($escolaSerieDisciplinas)) {
  227 + $opcoes_disc = array('NULL' => 'A série dessa escola não possui componentes cadastrados');
  228 + }
  229 + else {
  230 + // Mapper dos componentes curriculares
  231 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
225 232  
226   - $det_disc = $obj_disc->detalhe();
227   - $opcoes_disc[$det_disc['cod_disciplina']] = $det_disc['nm_disciplina'];
  233 + foreach ($escolaSerieDisciplinas as $escolaSerieDisciplina) {
  234 + $componente = $componenteMapper->find($escolaSerieDisciplina['ref_cod_disciplina']);
  235 + $opcoes_disc[$componente->id] = $componente;
228 236 }
229 237 }
230 238  
231   - $this->campoLista('ref_cod_disciplina', 'Disciplina', $opcoes_disc,
  239 + $this->campoLista('ref_cod_disciplina', 'Componente curricular', $opcoes_disc,
232 240 $this->ref_cod_disciplina, '', FALSE, '', '', FALSE, FALSE);
233 241  
234 242 $this->campoOculto('identificador', $this->identificador);
235 243  
  244 + $opcoesDias = array(
  245 + '' => 'Selecione um dia da semana',
  246 + 1 => 'Domingo',
  247 + 2 => 'Segunda-Feira',
  248 + 3 => 'Terça-Feira',
  249 + 4 => 'Quarta-Feira',
  250 + 5 => 'Quinta-Feira',
  251 + 6 => 'Sexta-Feira',
  252 + 7 => 'Sábado'
  253 + );
  254 +
236 255 $this->campoOculto('dia_semana', $this->dia_semana);
237   - $this->campoLista('dia_semana_', 'Dia da Semana', array( '' => 'Selecione um dia da semana', 1 => 'Domingo', 2 => 'Segunda-Feira', 3 => 'Terça-Feira', 4 => 'Quarta-Feira', 5 => 'Quinta-Feira', 6 => 'Sexta-Feira', 7 => 'Sábado' ), $this->dia_semana, '', FALSE, '', '', TRUE, FALSE );
  256 + $this->campoLista('dia_semana_', 'Dia da Semana', $opcoesDias,
  257 + $this->dia_semana, '', FALSE, '', '', TRUE, FALSE);
238 258  
239 259 $this->campoHora('hora_inicial', 'Hora Inicial', $this->hora_inicial, FALSE);
240 260 $this->campoHora('hora_final', 'Hora Final', $this->hora_final, FALSE);
... ... @@ -250,15 +270,15 @@ class indice extends clsCadastro
250 270 alert('Você deve escolher a disciplina!');
251 271 return;
252 272 }
253   - elseif (document.getElementById('hora_inicial').value == '') {
  273 + else if (document.getElementById('hora_inicial').value == '') {
254 274 alert('Você deve preencher o campo Hora Inicial!');
255 275 return;
256 276 }
257   - elseif (document.getElementById('hora_final').value == '') {
  277 + else if (document.getElementById('hora_final').value == '') {
258 278 alert('Você deve preencher o campo Hora Final!');
259 279 return;
260 280 }
261   - elseif (document.getElementById('ref_cod_servidor').value == '') {
  281 + else if (document.getElementById('ref_cod_servidor').value == '') {
262 282 alert('Você deve selecionar um servidor no campo Servidor');
263 283 return;
264 284 }
... ... @@ -429,10 +449,11 @@ class indice extends clsCadastro
429 449 $this->campoTextoInv($campo['qtd_horario_'] . '_hora_final', '',
430 450 $campo['hora_final_'], 5, 255, FALSE, FALSE, TRUE);
431 451  
432   - $obj_disc = new clsPmieducarDisciplina($campo['ref_ref_cod_disciplina_']);
433   - $det_disc = $obj_disc->detalhe();
  452 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
  453 + $componente = $componenteMapper->find($campo['ref_ref_cod_disciplina_']);
  454 +
434 455 $this->campoTextoInv($campo['qtd_horario_'] . '_ref_cod_disciplina',
435   - '', $det_disc['nm_disciplina'], 30, 255, FALSE, FALSE, TRUE);
  456 + '', $componente->nome, 30, 255, FALSE, FALSE, TRUE);
436 457  
437 458 $obj_pes = new clsPessoa_($campo['ref_servidor_']);
438 459 $det_pes = $obj_pes->detalhe();
... ... @@ -824,8 +845,7 @@ function validaCampoServidor()
824 845 if (document.getElementById('lst_matriculas').value) {
825 846 pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor&professor=1&ref_cod_servidor=0&ref_cod_instituicao=' + ref_cod_instituicao + '&ref_cod_escola=' + ref_cod_escola + '&dia_semana=' + dia_semana + '&hora_inicial=' + hora_inicial + '&hora_final=' + hora_final + '&horario=S' + '&lst_matriculas=' + lst_matriculas + '&min_mat=' + min_mat + '&min_ves=' + min_ves + '&min_not=' + min_not + '&identificador=' + identificador + '&ref_cod_disciplina=' + ref_cod_disciplina + '&ref_cod_curso=' + ref_cod_curso, 'ref_cod_servidor');
826 847 }
827   - else
828   - {
  848 + else {
829 849 pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor&professor=1&ref_cod_servidor=0&ref_cod_instituicao=' + ref_cod_instituicao + '&ref_cod_escola=' + ref_cod_escola + '&dia_semana=' + dia_semana + '&hora_inicial=' + hora_inicial + '&hora_final=' + hora_final + '&horario=S' + '&min_mat=' + min_mat + '&min_ves=' + min_ves + '&min_not=' + min_not + '&identificador=' + identificador + '&ref_cod_disciplina=' + ref_cod_disciplina + '&ref_cod_curso=' + ref_cod_curso, 'ref_cod_servidor');
830 850 }
831 851 }
... ...
ieducar/intranet/educar_quadro_horario_lst.php
... ... @@ -32,6 +32,7 @@ require_once 'include/clsBase.inc.php';
32 32 require_once 'include/clsListagem.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';
35 36  
36 37 /**
37 38 * clsIndexBase class.
... ... @@ -138,6 +139,9 @@ class indice extends clsConfig
138 139 $this->ref_cod_instituicao = $obj_permissoes->getInstituicao($this->pessoa_logada);
139 140 }
140 141  
  142 + // Componente curricular
  143 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
  144 +
141 145 $obrigatorio = FALSE;
142 146 $get_instituicao = TRUE;
143 147 $get_escola = TRUE;
... ... @@ -168,17 +172,25 @@ class indice extends clsConfig
168 172  
169 173 if (is_array($resultado)) {
170 174 foreach ($resultado as $registro) {
171   - $obj_disciplina = new clsPmieducarDisciplina($registro['ref_cod_disciplina']);
172   - $det_disciplina = $obj_disciplina->detalhe();
173   - $obj_servidor = new clsPmieducarServidor();
  175 + // Componente curricular
  176 + $componente = $componenteMapper->find($registro['ref_cod_disciplina']);
  177 +
  178 + // Servidor
  179 + $obj_servidor = new clsPmieducarServidor();
174 180  
175   - $det_servidor = array_shift($obj_servidor->lista(
  181 + $det_servidor = array_shift($obj_servidor->lista(
176 182 $registro['ref_servidor'], NULL, NULL, NULL, NULL, NULL, NULL,
177 183 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE));
178 184  
179 185 $det_servidor['nome'] = array_shift(explode(' ',$det_servidor['nome']));
180 186  
181   - $texto .= "<div style='text-align: center;background-color: #F6F6F6;font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px; '>".substr( $registro["hora_inicial"], 0, 5 )." - ".substr( $registro["hora_final"], 0, 5 )." <br> {$det_disciplina["abreviatura"]} <br> {$det_servidor["nome"]}</div>";
  187 + //$texto .= "<div style='text-align: center;background-color: #F6F6F6;font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px; '>". substr($registro['hora_inicial'], 0, 5) . ' - ' . substr($registro['hora_final'], 0, 5) . " <br> {$componente->abreviatura} <br> {$det_servidor["nome"]}</div>";
  188 + $detalhes = sprintf("%s - %s<br />%s<br />%s",
  189 + substr($registro['hora_inicial'], 0, 5), substr($registro['hora_final'], 0, 5),
  190 + $componente->abreviatura, $det_servidor['nome']);
  191 +
  192 + $texto .= sprintf('<div style="text-align: center; background-color: #F6F6F6; font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px;">%s</div>',
  193 + $detalhes);
182 194 }
183 195 }
184 196 else {
... ...
ieducar/intranet/educar_relatorio_quadro_horario_proc.php
... ... @@ -33,6 +33,7 @@ require_once &#39;include/clsCadastro.inc.php&#39;;
33 33 require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
35 35 require_once 'include/clsPDF.inc.php';
  36 +require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
36 37  
37 38 /**
38 39 * clsIndexBase class.
... ... @@ -202,10 +203,11 @@ class indice extends clsCadastro
202 203 $this->pdf->quadrado_relativo($inicio_x, $this->page_y,
203 204 75, 50, 0.3);
204 205  
205   - $obj_disciplina = new clsPmieducarDisciplina($registro['ref_cod_disciplina']);
206   - $det_disciplina = $obj_disciplina->detalhe();
207   - $obj_servidor = new clsPmieducarServidor();
208   - $det_servidor = array_shift($obj_servidor->lista(
  206 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
  207 + $componente = $componenteMapper->find($registro['ref_cod_disciplina']);
  208 +
  209 + $obj_servidor = new clsPmieducarServidor();
  210 + $det_servidor = array_shift($obj_servidor->lista(
209 211 $registro['ref_servidor'], NULL, NULL, NULL, NULL,
210 212 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
211 213 NULL, NULL, TRUE));
... ... @@ -215,7 +217,7 @@ class indice extends clsCadastro
215 217 $texto = sprintf("%s - %s\n%s\n%s",
216 218 substr($registro['hora_inicial'], 0, 5),
217 219 substr($registro["hora_final"], 0, 5),
218   - $det_disciplina['abreviatura'],
  220 + $componente->abreviatura,
219 221 $det_servidor['nome']
220 222 );
221 223  
... ...
ieducar/intranet/include/pmieducar/clsPmieducarQuadroHorarioHorarios.inc.php
... ... @@ -29,6 +29,7 @@
29 29 */
30 30  
31 31 require_once 'include/pmieducar/geral.inc.php';
  32 +require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
32 33  
33 34 /**
34 35 * clsPmieducarQuadroHorarioHorarios class
... ... @@ -146,8 +147,8 @@ class clsPmieducarQuadroHorarioHorarios
146 147 elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_servidor_substituto}' AND ref_cod_instituicao = '{$ref_cod_instituicao_substituto}'")) {
147 148 $this->ref_servidor_substituto = $ref_servidor_substituto;
148 149 $this->ref_cod_instituicao_substituto = $ref_cod_instituicao_substituto;
149   - }
150 150 }
  151 + }
151 152  
152 153 if (is_numeric($ref_servidor) && is_numeric($ref_cod_instituicao_servidor)) {
153 154 if (class_exists('clsPmieducarServidor')) {
... ... @@ -170,8 +171,8 @@ class clsPmieducarQuadroHorarioHorarios
170 171 elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_servidor}' AND ref_cod_instituicao = '{$ref_cod_instituicao_servidor}'")) {
171 172 $this->ref_servidor = $ref_servidor;
172 173 $this->ref_cod_instituicao_servidor = $ref_cod_instituicao_servidor;
173   - }
174 174 }
  175 + }
175 176  
176 177 if (is_numeric($ref_servidor_substituto) && is_numeric($ref_cod_instituicao_substituto)) {
177 178 if (class_exists('clsPmieducarServidor')) {
... ... @@ -194,55 +195,32 @@ class clsPmieducarQuadroHorarioHorarios
194 195 elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_servidor_substituto}' AND ref_cod_instituicao = '{$ref_cod_instituicao_substituto}'")) {
195 196 $this->ref_servidor_substituto = $ref_servidor_substituto;
196 197 $this->ref_cod_instituicao_substituto = $ref_cod_instituicao_substituto;
197   - }
198 198 }
  199 + }
199 200  
200 201 if (is_numeric($ref_ref_cod_disciplina) && is_numeric($ref_ref_cod_serie)) {
201   - if (class_exists('clsPmieducarDisciplinaSerie')) {
202   - $tmp_obj = new clsPmieducarDisciplinaSerie($ref_ref_cod_disciplina,
203   - $ref_ref_cod_serie, 1);
  202 + $anoEscolarMapper = new ComponenteCurricular_Model_AnoEscolarDataMapper();
  203 + $componenteAnos = $anoEscolarMapper->findAll(array(), array(
  204 + 'componenteCurricular' => $ref_ref_cod_disciplina,
  205 + 'anoEscolar' => $ref_ref_cod_serie)
  206 + );
204 207  
205   - if (method_exists($tmp_obj, 'existe')) {
206   - if ($tmp_obj->existe()) {
207   - $this->ref_ref_cod_disciplina = $ref_ref_cod_disciplina;
208   - $this->ref_ref_cod_serie = $ref_ref_cod_serie;
209   - }
210   - }
211   - elseif (method_exists($tmp_obj, 'detalhe')) {
212   - if ($tmp_obj->detalhe()) {
213   - $this->ref_ref_cod_disciplina = $ref_ref_cod_disciplina;
214   - $this->ref_ref_cod_serie = $ref_ref_cod_serie;
215   - }
216   - }
217   - }
218   - elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.disciplina_serie WHERE ref_cod_disciplina = '{$ref_ref_cod_disciplina}' AND ref_cod_serie = '{$ref_ref_cod_serie}' AND ativo = '1'")) {
219   - $this->ref_ref_cod_disciplina = $ref_ref_cod_disciplina;
220   - $this->ref_ref_cod_serie = $ref_ref_cod_serie;
221   - }
  208 + if (1 == count($componenteAnos)) {
  209 + $this->ref_ref_cod_disciplina = $ref_ref_cod_disciplina;
  210 + $this->ref_ref_cod_serie = $ref_ref_cod_serie;
222 211 }
  212 + }
223 213  
224 214 if (is_numeric($ref_ref_cod_escola) && is_numeric($ref_ref_cod_serie) &&
225 215 is_numeric($ref_ref_cod_disciplina)
226 216 ) {
227   - if (class_exists('clsPmieducarEscolaSerieDisciplina')) {
228   - $tmp_obj = new clsPmieducarEscolaSerieDisciplina($ref_ref_cod_serie,
229   - $ref_ref_cod_escola, $ref_ref_cod_disciplina, 1);
  217 + $escolaSerieDisciplina = new clsPmieducarEscolaSerieDisciplina($ref_ref_cod_serie,
  218 + $ref_ref_cod_escola, $ref_ref_cod_disciplina, 1);
230 219  
231   - if (method_exists($tmp_obj, 'existe')) {
232   - if ($tmp_obj->existe()) {
233   - $this->ref_ref_cod_escola = $ref_ref_cod_escola;
234   - }
235   - }
236   - elseif (method_exists($tmp_obj, 'detalhe')) {
237   - if ($tmp_obj->detalhe()) {
238   - $this->ref_ref_cod_escola = $ref_ref_cod_escola;
239   - }
240   - }
241   - }
242   - elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.escola_serie_disciplina WHERE ref_ref_cod_escola = '{$ref_ref_cod_escola}' AND ref_ref_cod_serie = '{$ref_ref_cod_serie}' AND ref_cod_disciplina = '{$ref_ref_cod_disciplina}' AND ativo = '1'")) {
243   - $this->ref_ref_cod_escola = $ref_ref_cod_escola;
244   - }
  220 + if ($escolaSerieDisciplina->existe()) {
  221 + $this->ref_ref_cod_escola = $ref_ref_cod_escola;
245 222 }
  223 + }
246 224  
247 225 if (is_numeric($ref_cod_quadro_horario)) {
248 226 if (class_exists('clsPmieducarQuadroHorario')) {
... ... @@ -261,8 +239,8 @@ class clsPmieducarQuadroHorarioHorarios
261 239 }
262 240 elseif ($db->CampoUnico("SELECT 1 FROM pmieducar.quadro_horario WHERE cod_quadro_horario = '{$ref_cod_quadro_horario}'")) {
263 241 $this->ref_cod_quadro_horario = $ref_cod_quadro_horario;
264   - }
265 242 }
  243 + }
266 244  
267 245 if (is_numeric($sequencial)) {
268 246 $this->sequencial = $sequencial;
... ...
ieducar/modules/ComponenteCurricular/Model/AnoEscolarDataMapper.php
... ... @@ -51,8 +51,8 @@ class ComponenteCurricular_Model_AnoEscolarDataMapper extends CoreExt_DataMapper
51 51  
52 52 protected $_attributeMap = array(
53 53 'componenteCurricular' => 'componente_curricular_id',
54   - 'anoEscolar' => 'ano_escolar_id',
55   - 'cargaHoraria' => 'carga_horaria'
  54 + 'anoEscolar' => 'ano_escolar_id',
  55 + 'cargaHoraria' => 'carga_horaria'
56 56 );
57 57  
58 58 protected $_primaryKey = array(
... ... @@ -100,7 +100,7 @@ class ComponenteCurricular_Model_AnoEscolarDataMapper extends CoreExt_DataMapper
100 100 SELECT
101 101 mca.%s
102 102 FROM
103   - modules.%s mca, pmieducar.serie ps
  103 + %s mca, pmieducar.serie ps
104 104 WHERE
105 105 mca.%s = ps.cod_serie AND ps.ref_cod_curso = '%d'";
106 106  
... ...