educar_escola_serie_cad.php
24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
<?php
/**
* i-Educar - Sistema de gestão escolar
*
* Copyright (C) 2006 Prefeitura Municipal de Itajaí
* <ctima@itajai.sc.gov.br>
*
* Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
* sob os termos da Licença Pública Geral GNU conforme publicada pela Free
* Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
* qualquer versão posterior.
*
* Este programa é distribuído na expectativa de que seja útil, porém, SEM
* NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU
* ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
* do GNU para mais detalhes.
*
* Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
* com este programa; se não, escreva para a Free Software Foundation, Inc., no
* endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*
* @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Arquivo disponível desde a versão 1.0.0
* @version $Id$
*/
require_once 'include/clsBase.inc.php';
require_once 'include/clsCadastro.inc.php';
require_once 'include/clsBanco.inc.php';
require_once 'include/pmieducar/geral.inc.php';
require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
/**
* clsIndexBase class.
*
* @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Classe disponível desde a versão 1.0.0
* @version @@package_version@@
*/
class clsIndexBase extends clsBase
{
function Formular()
{
$this->SetTitulo($this->_instituicao . ' i-Educar - Escola Série');
$this->processoAp = 585;
}
}
/**
* indice class.
*
* @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Classe disponível desde a versão 1.0.0
* @todo Ver a questão de formulários que tem campos dinamicamente
* desabilitados de acordo com a requisição (GET, POST ou erro de validação).
* A forma atual de usar valores em campos hidden leva a diversos problemas
* como aumento da lógica de pré-validação nos métodos Novo() e Editar().
* @version @@package_version@@
*/
class indice extends clsCadastro
{
var $pessoa_logada;
var $ref_cod_escola;
var $ref_cod_escola_;
var $ref_cod_serie;
var $ref_cod_serie_;
var $ref_usuario_exc;
var $ref_usuario_cad;
var $hora_inicial;
var $hora_final;
var $data_cadastro;
var $data_exclusao;
var $ativo;
var $hora_inicio_intervalo;
var $hora_fim_intervalo;
var $hora_fim_intervalo_;
var $ref_cod_instituicao;
var $ref_cod_curso;
var $intervalo;
var $escola_serie_disciplina;
var $ref_cod_disciplina;
var $incluir_disciplina;
var $excluir_disciplina;
var $disciplinas;
var $carga_horaria;
function Inicializar()
{
$retorno = 'Novo';
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$this->ref_cod_serie = $_GET['ref_cod_serie'];
$this->ref_cod_escola = $_GET['ref_cod_escola'];
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra(585, $this->pessoa_logada, 7,
'educar_escola_serie_lst.php');
if (is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_serie))
{
$tmp_obj = new clsPmieducarEscolaSerie();
$lst_obj = $tmp_obj->lista($this->ref_cod_escola, $this->ref_cod_serie);
$registro = array_shift($lst_obj);
if ($registro) {
// passa todos os valores obtidos no registro para atributos do objeto
foreach ($registro as $campo => $val) {
$this->$campo = $val;
}
$this->fexcluir = $obj_permissoes->permissao_excluir(585,
$this->pessoa_logada, 7);
$retorno = 'Editar';
}
}
$this->url_cancelar = ($retorno == 'Editar') ?
sprintf('educar_escola_serie_det.php?ref_cod_escola=%d&ref_cod_serie=%d',
$registro['ref_cod_escola'], $registro['ref_cod_serie']) :
'educar_escola_serie_lst.php';
$this->nome_url_cancelar = 'Cancelar';
return $retorno;
}
function Gerar()
{
if ($_POST) {
foreach($_POST as $campo => $val) {
$this->$campo = ($this->$campo) ? $this->$campo : $val;
}
}
if (is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_serie)) {
$instituicao_desabilitado = TRUE;
$escola_desabilitado = TRUE;
$curso_desabilitado = TRUE;
$serie_desabilitado = TRUE;
$escola_serie_desabilitado = TRUE;
$this->campoOculto('ref_cod_instituicao_', $this->ref_cod_instituicao);
$this->campoOculto('ref_cod_escola_', $this->ref_cod_escola);
$this->campoOculto('ref_cod_curso_', $this->ref_cod_curso);
$this->campoOculto('ref_cod_serie_', $this->ref_cod_serie);
}
$obrigatorio = TRUE;
$get_escola = TRUE;
$get_curso = TRUE;
$get_serie = FALSE;
$get_escola_serie = TRUE;
include 'include/pmieducar/educar_campo_lista.php';
if ($this->ref_cod_escola_) {
$this->ref_cod_escola = $this->ref_cod_escola_;
}
if ($this->ref_cod_serie_) {
$this->ref_cod_serie = $this->ref_cod_serie_;
}
$opcoes_serie = array('' => 'Selecione');
// Editar
if ($this->ref_cod_curso) {
$obj_serie = new clsPmieducarSerie();
$obj_serie->setOrderby('nm_serie ASC');
$lst_serie = $obj_serie->lista(NULL, NULL, NULL,$this->ref_cod_curso,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,1);
if (is_array($lst_serie) && count($lst_serie)) {
foreach ($lst_serie as $serie) {
$opcoes_serie[$serie['cod_serie']] = $serie['nm_serie'];
}
}
}
$this->campoLista('ref_cod_serie', 'Série', $opcoes_serie, $this->ref_cod_serie,
'', FALSE, '', '', $this->ref_cod_serie ? TRUE : FALSE);
$this->hora_inicial = substr($this->hora_inicial, 0, 5);
$this->hora_final = substr($this->hora_final, 0, 5);
$this->hora_inicio_intervalo = substr($this->hora_inicio_intervalo, 0, 5);
$this->hora_fim_intervalo = substr($this->hora_fim_intervalo, 0, 5);
// hora
$this->campoHora('hora_inicial', 'Hora Inicial', $this->hora_inicial, TRUE);
$this->campoHora('hora_final', 'Hora Final', $this->hora_final, TRUE);
$this->campoHora('hora_inicio_intervalo', 'Hora Início Intervalo',
$this->hora_inicio_intervalo, TRUE);
$this->campoHora('hora_fim_intervalo', 'Hora Fim Intervalo',
$this->hora_fim_intervalo, TRUE);
$this->campoCheck("bloquear_enturmacao_sem_vagas", "Bloquear enturmação após atingir limite de vagas", $this->bloquear_enturmacao_sem_vagas);
$this->campoCheck("bloquear_cadastro_turma_para_serie_com_vagas", "Bloquear cadastro de novas turmas antes de atingir limite de vagas (no mesmo turno)", $this->bloquear_cadastro_turma_para_serie_com_vagas);
$this->campoQuebra();
// Inclui disciplinas
if (is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_serie)) {
$obj = new clsPmieducarEscolaSerieDisciplina();
$registros = $obj->lista($this->ref_cod_serie, $this->ref_cod_escola, NULL, 1);
if ($registros) {
foreach ($registros as $campo) {
$this->escola_serie_disciplina[$campo['ref_cod_disciplina']] = $campo['ref_cod_disciplina'];
$this->escola_serie_disciplina_carga[$campo['ref_cod_disciplina']] = floatval($campo['carga_horaria']);
}
}
}
$opcoes = array('' => 'Selecione');
// Editar
$disciplinas = 'Nenhuma série selecionada';
if ($this->ref_cod_serie) {
$disciplinas = '';
$conteudo = '';
// Instancia o mapper de ano escolar
$anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper();
$lista = $anoEscolar->findComponentePorSerie($this->ref_cod_serie);
// Instancia o mapper de componente curricular
$mapper = new ComponenteCurricular_Model_ComponenteDataMapper();
if (is_array($lista) && count($lista)) {
$conteudo .= '<div style="margin-bottom: 10px; float: left">';
$conteudo .= ' <span style="display: block; float: left; width: 250px;">Nome</span>';
$conteudo .= ' <span style="display: block; float: left; width: 100px;">Carga horária</span>';
$conteudo .= ' <span style="display: block; float: left">Usar padrão do componente?</span>';
$conteudo .= '</div>';
$conteudo .= '<br style="clear: left" />';
$conteudo .= '<div style="margin-bottom: 10px; float: left">';
$conteudo .= " <label style='display: block; float: left; width: 350px;'><input type='checkbox' name='CheckTodos' onClick='marcarCheck(".'"disciplinas[]"'.");'/>Marcar Todos</label>";
$conteudo .= " <label style='display: block; float: left; width: 100px;'><input type='checkbox' name='CheckTodos2' onClick='marcarCheck(".'"usar_componente[]"'.");';/>Marcar Todos</label>";
$conteudo .= '</div>';
$conteudo .= '<br style="clear: left" />';
foreach ($lista as $registro) {
$checked = '';
$usarComponente = FALSE;
if ($this->escola_serie_disciplina[$registro->id] == $registro->id) {
$checked = 'checked="checked"';
}
if (is_null($this->escola_serie_disciplina_carga[$registro->id]) ||
0 == $this->escola_serie_disciplina_carga[$registro->id]) {
$usarComponente = TRUE;
}
else {
$cargaHoraria = $this->escola_serie_disciplina_carga[$registro->id];
}
$cargaComponente = $registro->cargaHoraria;
$conteudo .= '<div style="margin-bottom: 10px; float: left">';
$conteudo .= " <label style='display: block; float: left; width: 250px'><input type=\"checkbox\" $checked name=\"disciplinas[$registro->id]\" id=\"disciplinas[]\" value=\"{$registro->id}\">{$registro}</label>";
$conteudo .= " <label style='display: block; float: left; width: 100px;'><input type='text' name='carga_horaria[$registro->id]' value='{$cargaHoraria}' size='5' maxlength='7'></label>";
$conteudo .= " <label style='display: block; float: left'><input type='checkbox' id='usar_componente[]' name='usar_componente[$registro->id]' value='1' ". ($usarComponente == TRUE ? $checked : '') .">($cargaComponente h)</label>";
$conteudo .= '</div>';
$conteudo .= '<br style="clear: left" />';
$cargaHoraria = '';
}
$disciplinas = '<table cellspacing="0" cellpadding="0" border="0">';
$disciplinas .= sprintf('<tr align="left"><td>%s</td></tr>', $conteudo);
$disciplinas .= '</table>';
}
else {
$disciplinas = 'A série/ano escolar não possui componentes curriculares cadastrados.';
}
}
$this->campoRotulo("disciplinas_", "Componentes curriculares",
"<div id='disciplinas'>$disciplinas</div>");
$this->campoQuebra();
}
function Novo()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
/*
* Se houve erro na primeira tentativa de cadastro, irá considerar apenas
* os valores enviados de forma oculta.
*/
if (isset($this->ref_cod_instituicao_)) {
$this->ref_cod_instituicao = $this->ref_cod_instituicao_;
$this->ref_cod_escola = $this->ref_cod_escola_;
$this->ref_cod_curso = $this->ref_cod_curso_;
$this->ref_cod_serie = $this->ref_cod_serie_;
}
$anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper();
$componenteAno = $anoEscolar->findComponentePorSerie($this->ref_cod_serie);
/*
* Se $disciplinas não for informado e o ano escolar tem componentes
* curriculares cadastrados, retorna erro.
*/
if (!is_array($this->disciplinas) &&
(is_array($componenteAno) && 0 < count($componenteAno))
) {
echo "<script> alert('É necessário adicionar pelo menos um componente curricular.') </script>";
$this->mensagem = 'Cadastro não realizado.<br>';
return FALSE;
}
$this->bloquear_enturmacao_sem_vagas = is_null($this->bloquear_enturmacao_sem_vagas) ? 0 : 1;
$this->bloquear_cadastro_turma_para_serie_com_vagas = is_null($this->bloquear_cadastro_turma_para_serie_com_vagas) ? 0 : 1;
$obj = new clsPmieducarEscolaSerie($this->ref_cod_escola, $this->ref_cod_serie,
$this->pessoa_logada, $this->pessoa_logada, $this->hora_inicial,
$this->hora_final, NULL, NULL, 1, $this->hora_inicio_intervalo,
$this->hora_fim_intervalo, $this->bloquear_enturmacao_sem_vagas, $this->bloquear_cadastro_turma_para_serie_com_vagas);
if ($obj->existe()) {
$cadastrou = $obj->edita();
}
else {
$cadastrou = $obj->cadastra();
}
if ($cadastrou) {
if ($this->disciplinas) {
foreach ($this->disciplinas as $key => $campo) {
$obj = new clsPmieducarEscolaSerieDisciplina($this->ref_cod_serie,
$this->ref_cod_escola, $campo, 1, $this->carga_horaria[$key]);
if ($obj->existe()) {
$cadastrou1 = $obj->edita();
}
else {
$cadastrou1 = $obj->cadastra();
}
if (!$cadastrou1) {
$this->mensagem = 'Cadastro não realizado.<br>';
echo "<!--\nErro ao cadastrar clsPmieducarEscolaSerieDisciplina\nvalores obrigatórios\nis_numeric( $this->ref_cod_serie ) && is_numeric( $this->ref_cod_escola ) && is_numeric( {$campo[$i]} ) \n-->";
return FALSE;
}
}
}
$this->mensagem .= 'Cadastro efetuado com sucesso.<br>';
header('Location: educar_escola_serie_lst.php');
die();
}
$this->mensagem = 'Cadastro não realizado.<br>';
echo "<!--\nErro ao cadastrar clsPmieducarEscolaSerie\nvalores obrigatorios\nis_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_cod_serie ) && is_numeric( $this->pessoa_logada ) && ( $this->hora_inicial ) && ( $this->hora_final ) && ( $this->hora_inicio_intervalo ) && ( $this->hora_fim_intervalo )\n-->";
return FALSE;
}
function Editar()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
/*
* Atribui valor para atributos usados em Gerar(), senão o formulário volta
* a liberar os campos Instituição, Escola e Curso que devem ser read-only
* quando em modo de edição
*/
$this->ref_cod_instituicao = $this->ref_cod_instituicao_;
$this->ref_cod_escola = $this->ref_cod_escola_;
$this->ref_cod_curso = $this->ref_cod_curso_;
$this->ref_cod_serie = $this->ref_cod_serie_;
$anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper();
$componenteAno = $anoEscolar->findComponentePorSerie($this->ref_cod_serie);
/**
* @see indice#Novo();
*/
if (!is_array($this->disciplinas) &&
(is_array($componenteAno) && 0 < count($componenteAno))
) {
echo "<script>alert('É necessário adicionar pelo menos um componente curricular.');</script>";
$this->mensagem = 'Edição não realizada.<br>';
return FALSE;
}
$this->bloquear_enturmacao_sem_vagas = is_null($this->bloquear_enturmacao_sem_vagas) ? 0 : 1;
$this->bloquear_cadastro_turma_para_serie_com_vagas = is_null($this->bloquear_cadastro_turma_para_serie_com_vagas) ? 0 : 1;
$obj = new clsPmieducarEscolaSerie($this->ref_cod_escola, $this->ref_cod_serie,
$this->pessoa_logada, NULL, $this->hora_inicial, $this->hora_final,
NULL, NULL, 1, $this->hora_inicio_intervalo, $this->hora_fim_intervalo, $this->bloquear_enturmacao_sem_vagas, $this->bloquear_cadastro_turma_para_serie_com_vagas);
$editou = $obj->edita();
$obj = new clsPmieducarEscolaSerieDisciplina($this->ref_cod_serie,
$this->ref_cod_escola, $campo, 1);
$obj->excluirTodos();
if ($editou) {
if ($this->disciplinas) {
foreach ($this->disciplinas as $key => $campo) {
if (isset($this->usar_componente[$key])) {
$carga_horaria = NULL;
}
else {
$carga_horaria = $this->carga_horaria[$key];
}
$obj = new clsPmieducarEscolaSerieDisciplina($this->ref_cod_serie,
$this->ref_cod_escola, $campo, 1, $carga_horaria);
$existe = $obj->existe();
if ($existe) {
$editou1 = $obj->edita();
if (!$editou1) {
$this->mensagem = 'Edição não realizada.<br>';
echo "<!--\nErro ao editar clsPmieducarEscolaSerieDisciplina\nvalores obrigatórios\nis_numeric( $this->ref_cod_serie_ ) && is_numeric( $this->ref_cod_escola ) && is_numeric( {$campo[$i]} ) \n-->";
return FALSE;
}
}
else {
$cadastrou = $obj->cadastra();
if (!$cadastrou) {
$this->mensagem = 'Cadastro não realizada.<br>';
echo "<!--\nErro ao editar clsPmieducarEscolaSerieDisciplina\nvalores obrigatórios\nis_numeric( $this->ref_cod_serie_ ) && is_numeric( $this->ref_cod_escola ) && is_numeric( {$campo[$i]} ) \n-->";
return FALSE;
}
}
}
}
$this->mensagem .= 'Edição efetuada com sucesso.<br>';
header('Location: educar_escola_serie_lst.php');
die();
}
$this->mensagem = 'Edição não realizada.<br>';
return FALSE;
}
function Excluir()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$obj = new clsPmieducarEscolaSerie($this->ref_cod_escola_, $this->ref_cod_serie_,
$this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, 0);
$excluiu = $obj->excluir();
if ($excluiu) {
$obj = new clsPmieducarEscolaSerieDisciplina($this->ref_cod_serie_,
$this->ref_cod_escola_, NULL, 0);
$excluiu1 = $obj->excluirTodos();
if ($excluiu1) {
$this->mensagem .= "Exclusão efetuada com sucesso.<br>";
header( "Location: educar_escola_serie_lst.php" );
die();
}
}
$this->mensagem = "Exclusão não realizada.<br>";
echo "<!--\nErro ao excluir clsPmieducarEscolaSerie\nvalores obrigatorios\nif( is_numeric( $this->ref_cod_escola_ ) && is_numeric( $this->ref_cod_serie_ ) && is_numeric( $this->pessoa_logada ) )\n-->";
return FALSE;
}
}
// Instancia objeto de página
$pagina = new clsIndexBase();
// Instancia objeto de conteúdo
$miolo = new indice();
// Atribui o conteúdo à página
$pagina->addForm($miolo);
// Gera o código HTML
$pagina->MakeAll();
?>
<script type="text/javascript">
document.getElementById('ref_cod_instituicao').onchange = function()
{
getDuploEscolaCurso();
}
document.getElementById('ref_cod_escola').onchange = function()
{
getEscolaCurso();
}
document.getElementById('ref_cod_curso').onchange = function()
{
getSerie();
var campoDisciplinas = document.getElementById('disciplinas');
campoDisciplinas.innerHTML = "Nenhuma série selecionada";
}
function getDisciplina(xml_disciplina)
{
var campoDisciplinas = document.getElementById('disciplinas');
var DOM_array = xml_disciplina.getElementsByTagName( "disciplina" );
var conteudo = '';
if (DOM_array.length) {
conteudo += '<div style="margin-bottom: 10px; float: left">';
conteudo += ' <span style="display: block; float: left; width: 250px;">Nome</span>';
conteudo += ' <label span="display: block; float: left; width: 100px">Carga horária</span>';
conteudo += ' <label span="display: block; float: left">Usar padrão do componente?</span>';
conteudo += '</div>';
conteudo += '<br style="clear: left" />';
conteudo += '<div style="margin-bottom: 10px; float: left">';
conteudo += " <label style='display: block; float: left; width: 350px;'><input type='checkbox' name='CheckTodos' onClick='marcarCheck("+'"disciplinas[]"'+");'/>Marcar Todos</label>";
conteudo += " <label style='display: block; float: left; width: 100px;'><input type='checkbox' name='CheckTodos2' onClick='marcarCheck("+'"usar_componente[]"'+");';/>Marcar Todos</label>";
conteudo += '</div>';
conteudo += '<br style="clear: left" />';
for (var i = 0; i < DOM_array.length; i++) {
id = DOM_array[i].getAttribute("cod_disciplina");
conteudo += '<div style="margin-bottom: 10px; float: left">';
conteudo += ' <label style="display: block; float: left; width: 250px;"><input type="checkbox" name="disciplinas['+ id +']" id="disciplinas[]" value="'+ id +'">'+ DOM_array[i].firstChild.data +'</label>';
conteudo += ' <label style="display: block; float: left; width: 100px;"><input type="text" name="carga_horaria['+ id +']" value="" size="5" maxlength="7"></label>';
conteudo += ' <label style="display: block; float: left"><input type="checkbox" id="usar_componente[]" name="usar_componente['+ id +']" value="1">('+ DOM_array[i].getAttribute("carga_horaria") +' h)</label>';
conteudo += '</div>';
conteudo += '<br style="clear: left" />';
}
}
else {
campoDisciplinas.innerHTML = 'A série/ano escolar não possui componentes '
+ 'curriculares cadastrados.';
}
if (conteudo) {
campoDisciplinas.innerHTML = '<table cellspacing="0" cellpadding="0" border="0">';
campoDisciplinas.innerHTML += '<tr align="left"><td>'+ conteudo +'</td></tr>';
campoDisciplinas.innerHTML += '</table>';
}
}
document.getElementById('ref_cod_serie').onchange = function()
{
var campoSerie = document.getElementById('ref_cod_serie').value;
var campoDisciplinas = document.getElementById('disciplinas');
campoDisciplinas.innerHTML = "Carregando disciplina";
var xml_disciplina = new ajax( getDisciplina );
xml_disciplina.envia("educar_disciplina_xml.php?ser=" + campoSerie);
}
after_getEscola = function()
{
getEscolaCurso();
getSerie();
var campoDisciplinas = document.getElementById('disciplinas');
campoDisciplinas.innerHTML = "Nenhuma série selecionada";
};
function getSerie()
{
var campoCurso = document.getElementById('ref_cod_curso').value;
if (document.getElementById('ref_cod_escola')) {
var campoEscola = document.getElementById('ref_cod_escola').value;
}
else if (document.getElementById('ref_ref_cod_escola')) {
var campoEscola = document.getElementById('ref_ref_cod_escola').value;
}
var campoSerie = document.getElementById('ref_cod_serie');
campoSerie.length = 1;
limpaCampos(4);
if (campoEscola && campoCurso) {
campoSerie.disabled = true;
campoSerie.options[0].text = 'Carregando séries';
var xml = new ajax(atualizaLstSerie);
xml.envia("educar_serie_not_escola_xml.php?esc="+campoEscola+"&cur="+campoCurso);
}
else {
campoSerie.options[0].text = 'Selecione';
}
}
function atualizaLstSerie(xml)
{
var campoSerie = document.getElementById('ref_cod_serie');
campoSerie.length = 1;
campoSerie.options[0].text = 'Selecione uma série';
campoSerie.disabled = false;
series = xml.getElementsByTagName('serie');
if (series.length) {
for(var i = 0; i < series.length; i++) {
campoSerie.options[campoSerie.options.length] = new Option(series[i].firstChild.data,
series[i].getAttribute('cod_serie'), false, false);
}
}
else {
campoSerie.options[0].text = 'O curso não possui nenhuma série ou todas as séries já estã associadas a essa escola';
campoSerie.disabled = true;
}
}
function marcarCheck(idValue) {
// testar com formcadastro
var contaForm = document.formcadastro.elements.length;
var campo = document.formcadastro;
var i;
if (idValue == 'disciplinas[]'){
for (i=0; i<contaForm; i++) {
if (campo.elements[i].id == idValue) {
campo.elements[i].checked = campo.CheckTodos.checked;
}
}
}else {
for (i=0; i<contaForm; i++) {
if (campo.elements[i].id == idValue) {
campo.elements[i].checked = campo.CheckTodos2.checked;
}
}
}
}
</script>