educar_turma_cad.php
80.7 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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
<?php
use App\Services\iDiarioService;
use App\Services\SchoolClassService;
use App\Models\School;
use App\Models\LegacyCourse;
use iEducar\Modules\Educacenso\Model\TipoAtendimentoTurma;
use iEducar\Support\View\SelectOptions;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\RedirectResponse;
use RuntimeException;
use Throwable;
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 'include/modules/clsModulesAuditoriaGeral.inc.php';
require_once 'lib/Portabilis/Date/Utils.php';
require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php';
require_once 'Portabilis/View/Helper/Application.php';
require_once 'Portabilis/String/Utils.php';
require_once 'Portabilis/Utils/CustomLabel.php';
require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
require_once 'ComponenteCurricular/Model/TurmaDataMapper.php';
require_once 'lib/App/Model/Educacenso/LocalFuncionamentoDiferenciado.php';
require_once 'lib/App/Model/Educacenso/TipoMediacaoDidaticoPedagogico.php';
class clsIndexBase extends clsBase
{
public function Formular()
{
$this->SetTitulo($this->_instituicao . ' i-Educar - Turma');
$this->processoAp = 586;
}
}
class indice extends clsCadastro
{
public $pessoa_logada;
public $cod_turma;
public $ref_usuario_exc;
public $ref_usuario_cad;
public $ref_cod_serie;
public $ref_cod_serie_;
public $ref_ref_cod_escola;
public $ref_cod_infra_predio_comodo;
public $nm_turma;
public $sgl_turma;
public $max_aluno;
public $multiseriada;
public $data_cadastro;
public $data_exclusao;
public $ativo;
public $ref_cod_turma_tipo;
public $hora_inicial;
public $hora_final;
public $hora_inicio_intervalo;
public $hora_fim_intervalo;
public $ref_cod_instituicao;
public $ref_cod_curso;
public $ref_cod_escola_;
public $padrao_ano_escolar;
public $ref_cod_regente;
public $ref_cod_instituicao_regente;
public $ref_cod_serie_mult;
public $turma_modulo = [];
public $incluir_modulo;
public $excluir_modulo;
public $visivel;
public $tipo_atendimento;
public $atividades_complementares;
public $cod_curso_profissional;
public $etapa_educacenso;
public $ref_cod_disciplina_dispensada;
public $codigo_inep_educacenso;
public $tipo_mediacao_didatico_pedagogico;
public $dias_semana;
public $tipo_boletim;
public $tipo_boletim_diferenciado;
public $sequencial;
public $ref_cod_modulo;
public $data_inicio;
public $data_fim;
public $dias_letivos;
public $etapas_especificas;
public $etapas_utilizadas;
public $local_funcionamento_diferenciado;
public $definirComponentePorEtapa;
public $modulos = [];
public $retorno;
public $dias_da_semana = [
'' => 'Selecione',
1 => 'Domingo',
2 => 'Segunda',
3 => 'Terça',
4 => 'Quarta',
5 => 'Quinta',
6 => 'Sexta',
7 => 'Sábado'
];
public $nao_informar_educacenso;
public $ano_letivo;
public $nome_url_cancelar = 'Cancelar';
public $url_cancelar = 'educar_turma_lst.php';
public function Inicializar()
{
$retorno = 'Novo';
$this->cod_turma = $_GET['cod_turma'];
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra(586, $this->pessoa_logada, 7, 'educar_turma_lst.php');
if (is_numeric($this->cod_turma)) {
$obj_turma = new clsPmieducarTurma($this->cod_turma);
$registro = $obj_turma->detalhe();
$obj_esc = new clsPmieducarEscola($registro['ref_ref_cod_escola']);
$det_esc = $obj_esc->detalhe();
$obj_ser = new clsPmieducarSerie($registro['ref_ref_cod_serie']);
$det_ser = $obj_ser->detalhe();
$regra_avaliacao_id = $det_ser['regra_avaliacao_id'];
if ($regra_avaliacao_id) {
$regra_avaliacao_mapper = new RegraAvaliacao_Model_RegraDataMapper();
$regra_avaliacao = $regra_avaliacao_mapper->find($regra_avaliacao_id);
$this->definirComponentePorEtapa = ($regra_avaliacao->definirComponentePorEtapa == 1);
}
$this->dependencia_administrativa = $det_esc['dependencia_administrativa'];
$this->ref_cod_escola = $det_esc['cod_escola'];
$this->ref_cod_instituicao = $det_esc['ref_cod_instituicao'];
$this->ref_cod_curso = $det_ser['ref_cod_curso'];
$this->ref_cod_serie = $det_ser['cod_serie'];
$obj_curso = new clsPmieducarCurso(($this->ref_cod_curso));
$det_curso = $obj_curso->detalhe();
$this->padrao_ano_escolar = $det_curso['padrao_ano_escolar'];
$this->modalidade_curso = $det_curso['modalidade_curso'];
$inep = $obj_turma->getInep();
if ($inep) {
$this->codigo_inep_educacenso = $inep;
}
if ($registro) {
foreach ($registro as $campo => $val) {
$this->$campo = $val;
}
$objTurma = new clsPmieducarTurma($this->cod_turma);
$possuiAlunosVinculados = $objTurma->possuiAlunosVinculados();
if ($possuiAlunosVinculados) {
$this->script_excluir = 'excluir_turma_com_matriculas();';
}
$this->fexcluir = $obj_permissoes->permissao_excluir(
586,
$this->pessoa_logada,
7,
'educar_turma_lst.php'
);
$retorno = 'Editar';
}
}
if (is_string($this->dias_semana)) {
$this->dias_semana = explode(',', str_replace(['{', '}'], '', $this->dias_semana));
}
if (is_string($this->atividades_complementares)) {
$this->atividades_complementares = explode(',', str_replace(['{', '}'], '', $this->atividades_complementares));
}
if (is_string($this->cod_curso_profissional)) {
$this->cod_curso_profissional = explode(',', str_replace(['{', '}'], '', $this->cod_curso_profissional));
}
$this->url_cancelar = $retorno == 'Editar' ?
'educar_turma_det.php?cod_turma=' . $registro['cod_turma'] : 'educar_turma_lst.php';
$nomeMenu = $retorno == 'Editar' ? $retorno : 'Cadastrar';
$this->breadcrumb($nomeMenu . ' turma', [
url('intranet/educar_index.php') => 'Escola',
]);
$this->retorno = $retorno;
return $retorno;
}
public function Gerar()
{
if ($_POST) {
foreach ($_POST as $campo => $val) {
$this->$campo = $this->$campo ? $this->$campo : $val;
}
}
if (is_numeric($this->cod_turma)) {
$obj_turma = new clsPmieducarTurma($this->cod_turma);
$registro = $obj_turma->detalhe();
$obj_esc = new clsPmieducarEscola($registro['ref_ref_cod_escola']);
$det_esc = $obj_esc->detalhe();
$obj_ser = new clsPmieducarSerie($registro['ref_ref_cod_serie']);
$det_ser = $obj_ser->detalhe();
$this->ref_cod_escola = $det_esc['cod_escola'];
$this->ref_cod_instituicao = $det_esc['ref_cod_instituicao'];
$this->ref_cod_curso = $det_ser['ref_cod_curso'];
$this->ref_cod_serie = $det_ser['cod_serie'];
$this->ano = $registro['ano'];
}
$obrigarCamposCenso = $this->validarCamposObrigatoriosCenso();
if (is_numeric($this->ano_letivo)) {
$this->ano = $this->ano_letivo;
}
$this->campoOculto('obrigar_campos_censo', (int)$obrigarCamposCenso);
$this->campoOculto('cod_turma', $this->cod_turma);
$this->campoOculto('dependencia_administrativa', $this->dependencia_administrativa);
$this->campoOculto('modalidade_curso', $this->modalidade_curso);
$this->campoOculto('retorno', $this->retorno);
$bloqueia = false;
if (!isset($this->cod_turma)) {
$bloqueia = false;
} else {
if (is_numeric($this->cod_turma)) {
$obj_matriculas_turma = new clsPmieducarMatriculaTurma();
$obj_matriculas_turma->setOrderby('nome_aluno');
$lst_matriculas_turma = $obj_matriculas_turma->lista(
null,
$this->cod_turma,
null,
null,
null,
null,
null,
null,
1,
null,
null,
null,
null,
null,
null,
[1, 2, 3],
null,
null,
null,
null,
true,
null,
1,
true
);
if (is_array($lst_matriculas_turma) && count($lst_matriculas_turma) > 0) {
$bloqueia = true;
}
}
}
$desabilitado = $bloqueia;
$this->inputsHelper()->dynamic('instituicao', ['value' => $this->ref_cod_instituicao, 'disabled' => $desabilitado]);
$this->inputsHelper()->dynamic('escola', ['value' => $this->ref_cod_escola, 'disabled' => $desabilitado]);
$this->inputsHelper()->dynamic('curso', ['value' => $this->ref_cod_curso, 'disabled' => $desabilitado]);
$this->inputsHelper()->dynamic('serie', ['value' => $this->ref_cod_serie, 'disabled' => $desabilitado]);
$this->inputsHelper()->dynamic('anoLetivo', ['value' => $this->ano, 'disabled' => $desabilitado]);
// Infra prédio cômodo
$opcoes = ['' => 'Selecione'];
// Editar
if ($this->ref_ref_cod_escola) {
$obj_infra_predio = new clsPmieducarInfraPredio();
$obj_infra_predio->setOrderby('nm_predio ASC');
$lst_infra_predio = $obj_infra_predio->lista(
null,
null,
null,
$this->ref_ref_cod_escola,
null,
null,
null,
null,
null,
null,
null,
1
);
if (is_array($lst_infra_predio) && count($lst_infra_predio)) {
foreach ($lst_infra_predio as $predio) {
$obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo();
$lst_infra_predio_comodo = $obj_infra_predio_comodo->lista(
null,
null,
null,
null,
$predio['cod_infra_predio'],
null,
null,
null,
null,
null,
null,
null,
1
);
if (is_array($lst_infra_predio_comodo) && count($lst_infra_predio_comodo)) {
foreach ($lst_infra_predio_comodo as $comodo) {
$opcoes[$comodo['cod_infra_predio_comodo']] = $comodo['nm_comodo'];
}
}
}
}
}
$this->campoLista(
'ref_cod_infra_predio_comodo',
'Sala',
$opcoes,
$this->ref_cod_infra_predio_comodo,
null,
null,
null,
null,
null,
false
);
$array_servidor = ['' => 'Selecione um servidor'];
if ($this->ref_cod_regente) {
$obj_pessoa = new clsPessoa_($this->ref_cod_regente);
$det = $obj_pessoa->detalhe();
$array_servidor[$this->ref_cod_regente] = $det['nome'];
}
$this->campoListaPesq('ref_cod_regente', 'Professor/Regente', $array_servidor, $this->ref_cod_regente, '', '', false, '', '', null, null, '', true, false, false);
// Turma tipo
$opcoes = ['' => 'Selecione'];
// Editar
$objTemp = new clsPmieducarTurmaTipo();
$objTemp->setOrderby('nm_tipo ASC');
$lista = $objTemp->lista(
null,
null,
null,
null,
null,
null,
null,
null,
null,
1,
$this->ref_cod_instituicao
);
if (is_array($lista) && count($lista)) {
foreach ($lista as $registro) {
$opcoes[$registro['cod_turma_tipo']] = $registro['nm_tipo'];
}
}
$script = 'javascript:showExpansivelIframe(520, 170, \'educar_turma_tipo_cad_pop.php\');';
if ($this->ref_cod_instituicao && $this->ref_cod_escola && $this->ref_cod_curso) {
$script = sprintf(
'<div id=\'img_turma\' border=\'0\' onclick=\'%s\'>',
$script
);
} else {
$script = sprintf(
'<div id=\'img_turma\' border=\'0\' onclick=\'%s\'>',
$script
);
}
$this->campoLista(
'ref_cod_turma_tipo',
'Tipo de turma',
$opcoes,
$this->ref_cod_turma_tipo,
'',
false,
'',
$script
);
$this->campoTexto('nm_turma', 'Nome da turma', $this->nm_turma, 30, 255, true);
$this->campoTexto('sgl_turma', _cl('turma.detalhe.sigla'), $this->sgl_turma, 15, 15, false);
$this->campoNumero('max_aluno', 'Máximo de Alunos', $this->max_aluno, 3, 3, true);
unset($opcoes);
if (!is_null($this->ref_cod_serie)) {
$anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper();
$opcaoPadrao = [null => 'Selecione'];
$listaComponentes = $anoEscolar->findComponentePorSerie($this->ref_cod_serie);
if (!empty($listaComponentes)) {
foreach ($listaComponentes as $componente) {
$componente->nome = ucwords(strtolower($componente->nome));
$opcoes["{$componente->id}"] = "{$componente->nome}";
}
$opcoes = $opcaoPadrao + $opcoes;
$this->campoLista('ref_cod_disciplina_dispensada', 'Disciplina dispensada', $opcoes, $this->ref_cod_disciplina_dispensada, '', false, '', '', false, false);
}
}
$ativo = isset($this->cod_turma) ? dbBool($this->visivel) : true;
$this->campoCheck('visivel', 'Ativo', $ativo);
$this->campoCheck(
'multiseriada',
'Multi-Seriada',
$this->multiseriada,
'',
false,
false
);
$this->campoLista(
'ref_cod_serie_mult',
'Série',
['' => 'Selecione'],
'',
'',
false,
'',
'',
'',
false
);
$this->campoOculto('ref_cod_serie_mult_', $this->ref_ref_cod_serie_mult);
$resources = SelectOptions::tiposMediacaoDidaticoPedagogico();
$options = ['label' => 'Tipo de mediação didático pedagógico', 'resources' => $resources, 'value' => $this->tipo_mediacao_didatico_pedagogico, 'required' => $obrigarCamposCenso, 'size' => 70,];
$this->inputsHelper()->select('tipo_mediacao_didatico_pedagogico', $options);
$this->campoQuebra2();
// hora
if ($obrigarCamposCenso && !$this->obrigaCamposHorario()) {
$this->hora_inicial = '';
$this->hora_final = '';
$this->hora_inicio_intervalo = '';
$this->hora_fim_intervalo = '';
$this->dias_semana = [];
}
$this->campoRotulo(
'horario_funcionamento_turma',
'<b>Horário de funcionamento da turma</b>'
);
$this->campoHora('hora_inicial', 'Hora inicial', $this->hora_inicial, false, null, null, null);
$this->campoHora(
'hora_inicio_intervalo',
'Hora inicial do intervalo',
$this->hora_inicio_intervalo,
false,
null,
null,
null
);
$this->campoHora('hora_fim_intervalo', 'Hora final do intervalo', $this->hora_fim_intervalo, false, null, null, null);
$this->campoHora('hora_final', 'Hora final', $this->hora_final, false, null, null, null);
$helperOptions = ['objectName' => 'dias_semana'];
$options = ['label' => 'Dias da semana',
'size' => 50,
'required' => false,
'disabled' => $obrigarCamposCenso && !$this->obrigaCamposHorario(),
'options' => ['values' => $this->dias_semana,
'all_values' => [1 => 'Domingo',
2 => 'Segunda',
3 => 'Terça',
4 => 'Quarta',
5 => 'Quinta',
6 => 'Sexta',
7 => 'Sábado']]];
$this->inputsHelper()->multipleSearchCustom('', $options, $helperOptions);
$this->inputsHelper()->turmaTurno();
// modelos boletim
require_once 'Reports/Tipos/TipoBoletim.php';
require_once 'Portabilis/Array/Utils.php';
$tiposBoletim = Portabilis_Model_Report_TipoBoletim::getInstance()->getEnums();
$tiposBoletim = Portabilis_Array_Utils::insertIn(null, 'Selecione um modelo', $tiposBoletim);
$this->campoLista('tipo_boletim', 'Modelo relatório boletim', $tiposBoletim, $this->tipo_boletim);
$this->campoLista('tipo_boletim_diferenciado', 'Modelo relatório boletim diferenciado', $tiposBoletim, $this->tipo_boletim_diferenciado, '', false, '', '', false, false);
$this->montaListaComponentesSerieEscola();
$objTemp = new clsPmieducarModulo();
$objTemp->setOrderby('nm_tipo ASC');
$lista = $objTemp->lista(
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
1,
null
);
$opcoesCampoModulo = [];
if (is_array($lista) && count($lista)) {
$this->modulos = $lista;
foreach ($lista as $registro) {
$opcoesCampoModulo[$registro['cod_modulo']] = sprintf('%s - %d etapa(s)', $registro['nm_tipo'], $registro['num_etapas']);
}
}
$registros = [];
if (is_numeric($this->cod_turma)) {
$objTurma = new clsPmieducarTurmaModulo();
$objTurma->setOrderBy('sequencial ASC');
$registros = $objTurma->lista($this->cod_turma);
}
if (
empty($registros)
&& is_numeric($this->ano)
&& is_numeric($this->ref_cod_escola)
) {
$objAno = new clsPmieducarAnoLetivoModulo();
$objAno->setOrderBy('sequencial ASC');
$registros = $objAno->lista($this->ano, $this->ref_cod_escola);
}
if ($this->padrao_ano_escolar != 1) {
$qtd_registros = 0;
$moduloSelecionado = 0;
if ($registros) {
$moduloSelecionado = $registros[0]['ref_cod_modulo'];
foreach ($registros as $campo) {
$this->turma_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_inicio']);
$this->turma_modulo[$qtd_registros][] = dataFromPgToBr($campo['data_fim']);
$this->turma_modulo[$qtd_registros][] = $campo['dias_letivos'];
$qtd_registros++;
}
}
}
$this->campoQuebra2();
$this->campoRotulo('etapas_cabecalho', '<b>Etapas da turma</b>');
$this->campoLista(
'ref_cod_modulo',
'Etapa',
$opcoesCampoModulo,
$moduloSelecionado,
null,
null,
null,
null,
null,
true
);
$this->campoTabelaInicio('turma_modulo', 'Etapas', ['Data inicial', 'Data final', 'Dias Letivos'], $this->turma_modulo);
$this->campoData('data_inicio', 'Data Início', $this->data_inicio, false);
$this->campoData('data_fim', 'Data Fim', $this->data_fim, false);
$this->campoTexto('dias_letivos', 'Dias Letivos', $this->dias_letivos_, 9);
$this->campoTabelaFim();
$this->campoOculto('padrao_ano_escolar', $this->padrao_ano_escolar);
$this->acao_enviar = 'valida()';
$this->inputsHelper()->integer('codigo_inep_educacenso', ['label' => 'Código INEP',
'label_hint' => 'Somente números',
'placeholder' => 'INEP',
'required' => false,
'max_length' => 14,
'value' => $this->codigo_inep_educacenso]);
$resources = [null => 'Selecione',
0 => 'Escolarização',
4 => 'Atividade complementar',
5 => 'Atendimento educacional especializado (AEE)'];
$options = ['label' => 'Tipo de atendimento', 'resources' => $resources, 'value' => $this->tipo_atendimento, 'required' => $obrigarCamposCenso, 'size' => 70,];
$this->inputsHelper()->select('tipo_atendimento', $options);
$atividadesComplementares = loadJson('educacenso_json/atividades_complementares.json');
$helperOptions = ['objectName' => 'atividades_complementares'];
$options = ['label' => 'Tipos de atividades complementares',
'size' => 50,
'required' => false,
'options' => ['values' => $this->atividades_complementares,
'all_values' => $atividadesComplementares]];
$this->inputsHelper()->multipleSearchCustom('', $options, $helperOptions);
$resources = Portabilis_Utils_Database::fetchPreparedQuery('SELECT id,nome FROM modules.etapas_educacenso');
$resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome');
$resources = Portabilis_Array_Utils::merge($resources, ['null' => 'Selecione']);
$etapas_educacenso = loadJson('educacenso_json/etapas_ensino.json');
$etapas_educacenso = array_replace([null => 'Selecione'], $etapas_educacenso);
$options = ['label' => 'Etapa de ensino', 'resources' => $etapas_educacenso, 'value' => $this->etapa_educacenso, 'required' => false, 'size' => 70,];
$this->inputsHelper()->select('etapa_educacenso', $options);
$cursos = loadJson('educacenso_json/cursos_da_educacao_profissional.json');
$helperOptions = ['objectName' => 'cod_curso_profissional',
'type' => 'single'];
$options = ['label' => 'Curso de educação profissional',
'size' => 50,
'required' => false,
'options' => ['values' => $this->cod_curso_profissional,
'all_values' => $cursos]];
$this->inputsHelper()->multipleSearchCustom('', $options, $helperOptions);
$resources = App_Model_LocalFuncionamentoDiferenciado::getInstance()->getEnums();
$resources = array_replace([null => 'Selecione'], $resources);
$options = ['label' => 'Local de funcionamento diferenciado', 'resources' => $resources, 'value' => $this->local_funcionamento_diferenciado, 'required' => false, 'size' => 70,];
$this->inputsHelper()->select('local_funcionamento_diferenciado', $options);
$options = ['label' => Portabilis_String_Utils::toLatin1('Não informar esta turma no Censo escolar'),
'value' => $this->nao_informar_educacenso,
'label_hint' => Portabilis_String_Utils::toLatin1('Caso este campo seja selecionado, esta turma e todas as matrículas vinculadas a mesma, não serão informadas no arquivo de exportação do Censo escolar')];
$this->inputsHelper()->checkbox('nao_informar_educacenso', $options);
$scripts = [
'/modules/Cadastro/Assets/Javascripts/Turma.js',
'/intranet/scripts/etapas.js'
];
Portabilis_View_Helper_Application::loadJavascript($this, $scripts);
$styles = ['/modules/Cadastro/Assets/Stylesheets/Turma.css'];
Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
}
protected function obrigaCamposHorario()
{
return $this->tipo_mediacao_didatico_pedagogico == App_Model_TipoMediacaoDidaticoPedagogico::PRESENCIAL;
}
public function montaListaComponentesSerieEscola()
{
$this->campoQuebra2();
if ($this->ref_cod_serie) {
$conteudo = '';
try {
$lista = App_Model_IedFinder::getEscolaSerieDisciplina(
$this->ref_cod_serie,
$this->ref_cod_escola,
null,
null,
null,
true,
$this->ano
);
} catch (Throwable $e) {
return;
}
// Instancia o mapper de turma
$componenteTurmaMapper = new ComponenteCurricular_Model_TurmaDataMapper();
$componentesTurma = [];
if (isset($this->cod_turma) && is_numeric($this->cod_turma)) {
$componentesTurma = $componenteTurmaMapper->findAll(
[],
['turma' => $this->cod_turma]
);
}
$componentes = [];
foreach ($componentesTurma as $componenteTurma) {
$componentes[$componenteTurma->get('componenteCurricular')] = $componenteTurma;
}
unset($componentesTurma);
$instituicao = new clsPmieducarInstituicao($this->ref_cod_instituicao);
$instituicao = $instituicao->detalhe();
$podeCadastrarComponenteDiferenciado = dbBool($instituicao['componente_curricular_turma']);
if ($podeCadastrarComponenteDiferenciado) {
$checkDefinirComponente = ($componentes == true);
$disableDefinirComponente = false;
} else {
$disableDefinirComponente = true;
}
$this->campoCheck(
'definir_componentes_diferenciados',
'Definir componentes curriculares diferenciados',
$checkDefinirComponente,
null,
false,
false,
$disableDefinirComponente,
Portabilis_String_Utils::toLatin1('Está opção poderá ser utilizada, somente se no cadastro da instituição o parâmetro de permissão estiver habilitado')
);
$this->escola_serie_disciplina = [];
if (is_array($lista) && count($lista)) {
$conteudo .= '<div style="margin-bottom: 10px;">';
$conteudo .= ' <span style="display: block; float: left; width: 250px;">Nome</span>';
$conteudo .= ' <span style="display: block; float: left; width: 100px;">Nome abreviado</span>';
$conteudo .= ' <span style="display: block; float: left; width: 100px;">Carga horária</span>';
$conteudo .= ' <span style="display: block; float: left;width: 100px;">Usar padrão do componente?</span>';
if ($this->definirComponentePorEtapa) {
$conteudo .= ' <span style="display: block; float: left;width: 150px;">Usar etapas específicas?</span>';
}
$conteudo .= ' <span style="display: block; float: left">Possui docente vínculado?</span>';
$conteudo .= '</div>';
$conteudo .= '<br style="clear: left" />';
foreach ($lista as $registro) {
$checked = '';
$usarComponente = false;
$docenteVinculado = false;
$checkedEtapaEspecifica = '';
$etapaUtilizada = '';
if ($componentes[$registro->id]->etapasEspecificas == '1') {
$checkedEtapaEspecifica = 'checked="checked"';
$etapaUtilizada = $componentes[$registro->id]->etapasUtilizadas;
}
if (isset($componentes[$registro->id])) {
$checked = 'checked="checked"';
}
if (is_null($componentes[$registro->id]->cargaHoraria) ||
0 == $componentes[$registro->id]->cargaHoraria) {
$usarComponente = true;
} else {
$cargaHoraria = $componentes[$registro->id]->cargaHoraria;
}
$cargaComponente = $registro->cargaHoraria;
if (1 == $componentes[$registro->id]->docenteVinculado) {
$docenteVinculado = true;
}
$conteudo .= '<div style="margin-bottom: 10px; float: left" class="linha-disciplina" >';
$conteudo .= " <label style='display: block; float: left; width: 250px'><input type=\"checkbox\" $checked name=\"disciplinas[$registro->id]\" class='check-disciplina' id=\"disciplinas[]\" value=\"{$registro->id}\">{$registro}</label>";
$conteudo .= " <span style='display: block; float: left; width: 100px'>{$registro->abreviatura}</span>";
$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; width: 100px;'><input type='checkbox' name='usar_componente[$registro->id]' value='1' " . ($usarComponente == true ? $checked : '') . ">($cargaComponente h)</label>";
if ($this->definirComponentePorEtapa) {
$conteudo .= " <input style='float:left;' type='checkbox' id='etapas_especificas[]' name='etapas_especificas[$registro->id]' value='1' " . $checkedEtapaEspecifica . '></label>';
$conteudo .= " <label style='display: block; float: left; width: 150px;'>Etapas utilizadas: <input type='text' class='etapas_utilizadas' name='etapas_utilizadas[$registro->id]' value='{$etapaUtilizada}' size='5' maxlength='7'></label>";
}
$conteudo .= " <label style='display: block; float: left'><input type='checkbox' name='docente_vinculado[$registro->id]' value='1' " . ($docenteVinculado == true ? $checked : '') . '></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.';
}
}
$help = [];
$label = 'Componentes curriculares definidos em séries da escola';
$label = sprintf($label, $help);
$this->campoRotulo(
'disciplinas_',
$label,
"<div id='disciplinas'>$disciplinas</div>"
);
}
/**
* @see SchoolClassService::isAvailableName()
*
* @param int $ano
* @param int $curso
* @param int $serie
* @param int $escola
* @param string $nome
* @param int|null $id
*
* @return bool
*/
public function nomeEstaDisponivel($ano, $curso, $serie, $escola, $nome, $id = null)
{
$service = new SchoolClassService();
return $service->isAvailableName($nome, $curso, $serie, $escola, $ano, $id);
}
/**
* Valida o campo Boletim Diferenciado
*
* @param $levelId
* @param $academicYear
* @param $alternativeReportCard
* @return bool
*/
public function temBoletimDiferenciado($levelId, $academicYear, $alternativeReportCard)
{
if ($alternativeReportCard) {
return true;
}
$service = new SchoolClassService();
if ($service->isRequiredAlternativeReportCard($levelId, $academicYear)) {
return false;
}
return true;
}
public function Novo()
{
if (!$this->canCreateTurma($this->ref_cod_escola, $this->ref_cod_serie, $this->turma_turno_id)) {
return false;
}
if (!$this->verificaModulos()) {
return false;
}
if (!$this->verificaCamposCenso()) {
return false;
}
if (!$this->nomeEstaDisponivel($this->ano_letivo, $this->ref_cod_curso, $this->ref_cod_serie, $this->ref_cod_escola, $this->nm_turma)) {
$this->mensagem = 'O nome da turma já está sendo utilizado nesta escola, para o curso, série e anos informados.';
return false;
}
if (!$this->temBoletimDiferenciado($this->ref_cod_serie, $this->ano_letivo, $this->tipo_boletim_diferenciado)) {
$this->mensagem = 'O campo \'<b>Boletim diferenciado</b>\' é obrigatório quando a regra de avaliação da série possui regra diferenciada definida.';
return false;
}
$this->ref_cod_instituicao_regente = $this->ref_cod_instituicao;
$this->multiseriada = isset($this->multiseriada) ? 1 : 0;
$this->visivel = isset($this->visivel);
$objTurma = $this->montaObjetoTurma(null, $this->pessoa_logada);
$this->cod_turma = $cadastrou = $objTurma->cadastra();
if (!$cadastrou) {
$this->mensagem = 'Cadastro não realizado.';
return false;
}
$turma = new clsPmieducarTurma($this->cod_turma);
$turma = $turma->detalhe();
$auditoria = new clsModulesAuditoriaGeral('turma', $this->pessoa_logada, $this->cod_turma);
$auditoria->inclusao($turma);
$this->atualizaComponentesCurriculares(
$this->ref_cod_serie,
$this->ref_cod_escola,
$this->cod_turma,
$this->disciplinas,
$this->carga_horaria,
$this->usar_componente,
$this->docente_vinculado
);
$this->cadastraInepTurma($this->cod_turma, $this->codigo_inep_educacenso);
if (!$this->atualizaModulos()) {
return false;
}
$this->mensagem = 'Cadastro efetuado com sucesso.';
$this->simpleRedirect('educar_turma_lst.php');
}
public function Editar()
{
$turmaDetalhe = new clsPmieducarTurma($this->cod_turma);
$possuiAlunosVinculados = $turmaDetalhe->possuiAlunosVinculados();
$turmaDetalhe = $turmaDetalhe->detalhe();
$this->ref_cod_curso = $turmaDetalhe['ref_cod_curso'];
$this->ref_ref_cod_escola = $turmaDetalhe['ref_ref_cod_escola'];
if (!$this->verificaModulos()) {
return false;
}
if (!$this->verificaCamposCenso()) {
return false;
}
$this->visivel = isset($this->visivel);
if (!$this->visivel && $possuiAlunosVinculados) {
$this->mensagem = 'Não foi possível inativar a turma, pois a mesma possui matrículas vinculadas.';
return false;
}
$this->multiseriada = isset($this->multiseriada) ? 1 : 0;
$objTurma = $this->montaObjetoTurma($this->cod_turma, null, $this->pessoa_logada);
$dadosTurma = $objTurma->detalhe();
if (!$this->nomeEstaDisponivel($dadosTurma['ano'], $this->ref_cod_curso, $dadosTurma['ref_ref_cod_serie'], $dadosTurma['ref_ref_cod_escola'], $this->nm_turma, $this->cod_turma)) {
$this->mensagem = 'O nome da turma já está sendo utilizado nesta escola, para o curso, série e anos informados.';
return false;
}
if (!$this->temBoletimDiferenciado($dadosTurma['ref_ref_cod_serie'], $dadosTurma['ano'], $this->tipo_boletim_diferenciado)) {
$this->mensagem = 'O campo \'<b>Boletim diferenciado</b>\' é obrigatório quando a regra de avaliação da série possui regra diferenciada definida.';
return false;
}
if (!$this->verificaTurno()) {
return false;
}
if (is_null($this->ref_cod_instituicao)) {
$this->ref_cod_instituicao = $turmaDetalhe['ref_cod_instituicao'];
$this->ref_cod_instituicao_regente = $turmaDetalhe['ref_cod_instituicao'];
} else {
$this->ref_cod_instituicao_regente = $this->ref_cod_instituicao;
}
$editou = $objTurma->edita();
if (!$editou) {
$this->mensagem = 'Edição não realizada.';
return false;
}
$auditoria = new clsModulesAuditoriaGeral('turma', $this->pessoa_logada, $this->cod_turma);
$auditoria->alteracao($turmaDetalhe, $objTurma->detalhe());
$this->atualizaComponentesCurriculares(
$turmaDetalhe['ref_ref_cod_serie'],
$turmaDetalhe['ref_ref_cod_escola'],
$this->cod_turma,
$this->disciplinas,
$this->carga_horaria,
$this->usar_componente,
$this->docente_vinculado
);
$this->cadastraInepTurma($this->cod_turma, $this->codigo_inep_educacenso);
if (!$this->atualizaModulos()) {
return false;
}
$this->mensagem = 'Edição efetuada com sucesso.';
throw new HttpResponseException(
new RedirectResponse('educar_turma_lst.php')
);
}
protected function validaCamposHorario()
{
if (!$this->obrigaCamposHorario()) {
return true;
}
if (empty($this->hora_inicial)) {
$this->mensagem = 'O campo hora inicial é obrigatório';
return false;
}
if (empty($this->hora_final)) {
$this->mensagem = 'O campo hora final é obrigatório';
return false;
}
if (empty($this->hora_inicio_intervalo)) {
$this->mensagem = 'O campo hora início intervalo é obrigatório';
return false;
}
if (empty($this->hora_fim_intervalo)) {
$this->mensagem = 'O campo hora fim intervalo é obrigatório';
return false;
}
if (empty($this->dias_semana)) {
$this->mensagem = 'O campo dias da semana é obrigatório';
return false;
}
return true;
}
protected function validaCampoAtividadesComplementares()
{
if ($this->tipo_atendimento == 4 && empty($this->atividades_complementares)) {
$this->mensagem = 'Campo atividades complementares é obrigatório';
return false;
}
return true;
}
protected function validaCampoTipoAtendimento()
{
if ($this->tipo_atendimento != 0 && in_array($this->tipo_mediacao_didatico_pedagogico, [
App_Model_TipoMediacaoDidaticoPedagogico::SEMIPRESENCIAL,
App_Model_TipoMediacaoDidaticoPedagogico::EDUCACAO_A_DISTANCIA
])) {
$this->mensagem = 'O campo: Tipo de atendimento deve ser: Escolarização quando o campo: Tipo de mediação didático-pedagógica for: Semipresencial ou Educação a Distância.';
return false;
}
return true;
}
protected function validaCampoLocalFuncionamentoDiferenciado()
{
$school = School::find($this->ref_ref_cod_escola);
$localFuncionamentoEscola = $school->local_funcionamento;
if (is_string($localFuncionamentoEscola)) {
$localFuncionamentoEscola = explode(',', str_replace(array('{', "}"), '', $localFuncionamentoEscola));
}
$localFuncionamentoEscola = (array) $localFuncionamentoEscola;
if (!in_array(9, $localFuncionamentoEscola) && $this->local_funcionamento_diferenciado == App_Model_LocalFuncionamentoDiferenciado::UNIDADE_ATENDIMENTO_SOCIOEDUCATIVO) {
$this->mensagem = 'Não é possível selecionar a opção: Unidade de atendimento socioeducativo quando o local de funcionamento da escola não for: Unidade de atendimento socioeducativo.';
return false;
}
if (!in_array(10, $localFuncionamentoEscola) && $this->local_funcionamento_diferenciado == App_Model_LocalFuncionamentoDiferenciado::UNIDADE_PRISIONAL) {
$this->mensagem = 'Não é possível selecionar a opção: Unidade prisional quando o local de funcionamento da escola não for: Unidade prisional.';
return false;
}
return true;
}
protected function validaTipoAtendimento()
{
if ($this->tipo_atendimento == 4 && empty($this->atividades_complementares)) {
$this->mensagem = 'Campo atividades complementares é obrigatório';
return false;
}
return true;
}
protected function validaCampoEtapaEnsino()
{
if (!empty($this->tipo_atendimento) &&
$this->tipo_atendimento != -1 &&
$this->tipo_atendimento != 4 &&
$this->tipo_atendimento != 5) {
$this->mensagem = 'Campo etapa de ensino é obrigatório';
return false;
}
return true;
}
private function validaEtapaEducacenso()
{
$course = LegacyCourse::find($this->ref_cod_curso);
if ($this->tipo_atendimento != TipoAtendimentoTurma::ESCOLARIZACAO) {
return true;
}
if ($course->modalidade_curso == 1 && !in_array($this->etapa_educacenso, [1, 2, 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 35, 36, 37, 38, 41, 56])) {
$this->mensagem = 'Quando a modalidade do curso é: Ensino regular, o campo: Etapa de ensino deve ser uma das seguintes opções: 1, 2, 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 35, 36, 37, 38, 41 ou 56.';
return false;
}
if ($course->modalidade_curso == 2 && !in_array($this->etapa_educacenso, [1, 2, 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 41, 56, 39, 40, 69, 70, 71, 72, 73, 74, 64, 67, 68])) {
$this->mensagem = 'Quando a modalidade do curso é: Educação Especial - Modalidade Substitutiva, o campo: Etapa de ensino deve ser uma das seguintes opções: 1, 2, 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 41, 56, 39, 40, 69, 70, 71, 72, 73, 74, 64, 67 ou 68.';
return false;
}
if ($course->modalidade_curso == 3 && !in_array($this->etapa_educacenso, [69, 70, 71, 72])) {
$this->mensagem = 'Quando a modalidade do curso é: Educação de Jovens e Adultos (EJA), o campo: Etapa de ensino deve ser uma das seguintes opções: 69, 70, 71 ou 72.';
return false;
}
if ($course->modalidade_curso == 4 && !in_array($this->etapa_educacenso, [30, 31, 32, 33, 34, 39, 40, 73, 74, 64, 67, 68])) {
$this->mensagem = 'Quando a modalidade do curso é: Educação Profissional, o campo: Etapa de ensino deve ser uma das seguintes opções: 30, 31, 32, 33, 34, 39, 40, 73, 74, 64, 67 ou 68.';
return false;
}
if ($this->tipo_mediacao_didatico_pedagogico == App_Model_TipoMediacaoDidaticoPedagogico::SEMIPRESENCIAL && !in_array($this->etapa_educacenso, [69, 70, 71, 72])) {
$this->mensagem = 'Quando o campo: Tipo de mediação didático-pedagógica é: Semipresencial, o campo: Etapa de ensino deve ser uma das seguintes opções: 69, 70, 71 ou 72';
return false;
}
if ($this->tipo_mediacao_didatico_pedagogico == App_Model_TipoMediacaoDidaticoPedagogico::EDUCACAO_A_DISTANCIA && !in_array($this->etapa_educacenso, [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 70, 71, 73, 74, 64, 67, 68])) {
$this->mensagem = 'Quando o campo: Tipo de mediação didático-pedagógica é: Educação a Distância, o campo: Etapa de ensino deve ser uma das seguintes opções: 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 70, 71, 73, 74, 64, 67 ou 68';
return false;
}
if (in_array($this->local_funcionamento_diferenciado, [App_Model_LocalFuncionamentoDiferenciado::UNIDADE_ATENDIMENTO_SOCIOEDUCATIVO, App_Model_LocalFuncionamentoDiferenciado::UNIDADE_PRISIONAL]) &&
in_array($this->etapa_educacenso, [1, 2, 3, 56])
) {
$nomeOpcao = (App_Model_LocalFuncionamentoDiferenciado::getInstance()->getEnums())[$this->local_funcionamento_diferenciado];
$this->mensagem = "Quando o campo: Local de funcionamento diferenciado é: {$nomeOpcao}, o campo: Etapa de ensino não pode ser nenhuma das seguintes opções: 1, 2, 3 ou 56";
return false;
}
return true;
}
protected function verificaCamposCenso()
{
if (!$this->validarCamposObrigatoriosCenso()) {
return true;
}
if (!$this->validaCamposHorario()) {
return false;
}
if (!$this->validaEtapaEducacenso()) {
return false;
}
if (!$this->validaCampoAtividadesComplementares()) {
return false;
}
if (!$this->validaCampoEtapaEnsino()) {
return false;
}
if (!$this->validaCampoTipoAtendimento()) {
return false;
}
if (!$this->validaCampoLocalFuncionamentoDiferenciado()) {
return false;
}
return true;
}
protected function verificaTurno()
{
$turmaId = (int) $this->cod_turma;
$turnoId = (int) $this->turma_turno_id;
$count = 0;
if ($turnoId === clsPmieducarTurma::TURNO_INTEGRAL) { // Se integral não pode ter vínculos noturnos
$count += DB::table('pmieducar.matricula_turma as mt')
->join('pmieducar.turma as t', 't.cod_turma', '=', 'mt.ref_cod_turma')
->where('mt.turno_id', clsPmieducarTurma::TURNO_NOTURNO)
->where('t.cod_turma', $turmaId)
->count();
$count += DB::table('modules.professor_turma as pt')
->join('pmieducar.turma as t', 't.cod_turma', '=', 'pt.turma_id')
->where('pt.turno_id', clsPmieducarTurma::TURNO_NOTURNO)
->where('t.cod_turma', $turmaId)
->count();
} else { // Se ñ é integral não pode ter vínculos diferentes do novo turno
$count += DB::table('pmieducar.matricula_turma as mt')
->join('pmieducar.turma as t', 't.cod_turma', '=', 'mt.ref_cod_turma')
->where('mt.turno_id', '<>', $turnoId)
->where('t.cod_turma', $turmaId)
->count();
$count += DB::table('modules.professor_turma as pt')
->join('pmieducar.turma as t', 't.cod_turma', '=', 'pt.turma_id')
->where('pt.turno_id', '<>', $turnoId)
->where('t.cod_turma', $turmaId)
->count();
}
if ($count > 0) {
$this->mensagem = 'Existem enturmações ou professores atrelados a esta turma em turnos diferentes do especificado.';
return false;
}
return true;
}
public function montaObjetoTurma($codTurma = null, $usuarioCad = null, $usuarioExc = null)
{
$this->dias_semana = '{' . implode(',', $this->dias_semana) . '}';
$this->atividades_complementares = '{' . implode(',', $this->atividades_complementares) . '}';
$this->cod_curso_profissional = $this->cod_curso_profissional[0];
if ($this->tipo_atendimento != 4) {
$this->atividades_complementares = '{}';
}
$etapasCursoTecnico = [30, 31, 32, 33, 34, 39, 40, 64, 74];
if (!in_array($this->etapa_educacenso, $etapasCursoTecnico)) {
$this->cod_curso_profissional = null;
}
$objTurma = new clsPmieducarTurma($codTurma);
$objTurma->ref_usuario_cad = $usuarioCad;
$objTurma->ref_usuario_exc = $usuarioExc;
$objTurma->ref_ref_cod_serie = $this->ref_cod_serie;
$objTurma->ref_ref_cod_escola = $this->ref_cod_escola;
$objTurma->ref_cod_infra_predio_comodo = $this->ref_cod_infra_predio_comodo;
$objTurma->nm_turma = $this->nm_turma;
$objTurma->sgl_turma = $this->sgl_turma;
$objTurma->max_aluno = $this->max_aluno;
$objTurma->multiseriada = $this->multiseriada;
$objTurma->ativo = 1;
$objTurma->ref_cod_turma_tipo = $this->ref_cod_turma_tipo;
$objTurma->hora_inicial = $this->hora_inicial;
$objTurma->hora_final = $this->hora_final;
$objTurma->hora_inicio_intervalo = $this->hora_inicio_intervalo;
$objTurma->hora_fim_intervalo = $this->hora_fim_intervalo;
$objTurma->ref_cod_regente = $this->ref_cod_regente;
$objTurma->ref_cod_instituicao_regente = $this->ref_cod_instituicao_regente;
$objTurma->ref_cod_instituicao = $this->ref_cod_instituicao;
$objTurma->ref_cod_curso = $this->ref_cod_curso;
$objTurma->ref_ref_cod_serie_mult = $objTurma->multiseriada ? $this->ref_cod_serie_mult : null;
$objTurma->ref_ref_cod_escola_mult = $objTurma->multiseriada ? $this->ref_cod_escola : null;
$objTurma->visivel = $this->visivel;
$objTurma->turma_turno_id = $this->turma_turno_id;
$objTurma->tipo_boletim = $this->tipo_boletim;
$objTurma->tipo_boletim_diferenciado = $this->tipo_boletim_diferenciado;
$objTurma->ano = $this->ano_letivo;
$objTurma->tipo_atendimento = $this->tipo_atendimento;
$objTurma->cod_curso_profissional = $this->cod_curso_profissional;
$objTurma->etapa_educacenso = $this->etapa_educacenso == '' ? null : $this->etapa_educacenso;
$objTurma->ref_cod_disciplina_dispensada = $this->ref_cod_disciplina_dispensada == '' ? null : $this->ref_cod_disciplina_dispensada;
$objTurma->nao_informar_educacenso = $this->nao_informar_educacenso == 'on' ? 1 : 0;
$objTurma->tipo_mediacao_didatico_pedagogico = $this->tipo_mediacao_didatico_pedagogico;
$objTurma->dias_semana = $this->dias_semana;
$objTurma->atividades_complementares = $this->atividades_complementares;
$objTurma->local_funcionamento_diferenciado = $this->local_funcionamento_diferenciado;
return $objTurma;
}
protected function validaModulos()
{
$turmaId = $this->cod_turma;
$etapasCount = count($this->data_inicio);
$etapasCountAntigo = (int) Portabilis_Utils_Database::selectField(
'SELECT COUNT(*) AS count FROM pmieducar.turma_modulo WHERE ref_cod_turma = $1',
[$turmaId]
);
if ($etapasCount >= $etapasCountAntigo) {
return true;
}
$etapasTmp = $etapasCount;
$etapas = [];
while ($etapasTmp < $etapasCountAntigo) {
$etapasTmp += 1;
$etapas[] = $etapasTmp;
}
$counts = [];
$counts[] = DB::table('modules.falta_componente_curricular as fcc')
->join('modules.falta_aluno as fa', 'fa.id', '=', 'fcc.falta_aluno_id')
->join('pmieducar.matricula as m', 'm.cod_matricula', '=', 'fa.matricula_id')
->join('pmieducar.matricula_turma as mt', 'mt.ref_cod_matricula', '=', 'm.cod_matricula')
->whereIn('fcc.etapa', $etapas)
->where('mt.ref_cod_turma', $turmaId)
->where('m.ativo', 1)
->count();
$counts[] = DB::table('modules.falta_geral as fg')
->join('modules.falta_aluno as fa', 'fa.id', '=', 'fg.falta_aluno_id')
->join('pmieducar.matricula as m', 'm.cod_matricula', '=', 'fa.matricula_id')
->join('pmieducar.matricula_turma as mt', 'mt.ref_cod_matricula', '=', 'm.cod_matricula')
->whereIn('fg.etapa', $etapas)
->where('mt.ref_cod_turma', $turmaId)
->where('m.ativo', 1)
->count();
$counts[] = DB::table('modules.nota_componente_curricular as ncc')
->join('modules.nota_aluno as na', 'na.id', '=', 'ncc.nota_aluno_id')
->join('pmieducar.matricula as m', 'm.cod_matricula', '=', 'na.matricula_id')
->join('pmieducar.matricula_turma as mt', 'mt.ref_cod_matricula', '=', 'm.cod_matricula')
->whereIn('ncc.etapa', $etapas)
->where('mt.ref_cod_turma', $turmaId)
->where('m.ativo', 1)
->count();
$sum = array_sum($counts);
if ($sum > 0) {
throw new RuntimeException('Não foi possível remover uma das etapas pois existem notas ou faltas lançadas.');
}
$iDiarioService = app(iDiarioService::class);
foreach ($etapas as $etapa) {
if ($iDiarioService->getStepActivityByClassroom($turmaId, $etapa)) {
throw new RuntimeException('Não foi possível remover uma das etapas pois existem notas ou faltas lançadas no diário online.');
}
}
return true;
}
public function atualizaModulos()
{
try {
$this->validaModulos();
} catch (Exception $e) {
$this->Inicializar();
$this->mensagem = $e->getMessage();
return false;
}
$objModulo = new clsPmieducarTurmaModulo();
$excluiu = $objModulo->excluirTodos($this->cod_turma);
$modulos = $this->montaModulos();
if (!$excluiu) {
$this->mensagem = 'Edição não realizada.';
return false;
}
foreach ($modulos as $modulo) {
$this->cadastraModulo($modulo);
}
return true;
}
public function montaModulos()
{
// itera pelo campo `data_inicio`, um dos campos referentes às etapas,
// para definir sequencialmente os dados de cada etapa
foreach ($this->data_inicio as $key => $modulo) {
$turmaModulo[$key]['sequencial'] = $key + 1;
$turmaModulo[$key]['ref_cod_modulo'] = $this->ref_cod_modulo;
$turmaModulo[$key]['data_inicio'] = $this->data_inicio[$key];
$turmaModulo[$key]['data_fim'] = $this->data_fim[$key];
$turmaModulo[$key]['dias_letivos'] = $this->dias_letivos[$key];
}
return $turmaModulo;
}
public function cadastraModulo($modulo)
{
$modulo['data_inicio'] = dataToBanco($modulo['data_inicio']);
$modulo['data_fim'] = dataToBanco($modulo['data_fim']);
$objModulo = new clsPmieducarTurmaModulo($this->cod_turma);
$objModulo->ref_cod_modulo = $modulo['ref_cod_modulo'];
$objModulo->sequencial = $modulo['sequencial'];
$objModulo->data_inicio = $modulo['data_inicio'];
$objModulo->data_fim = $modulo['data_fim'];
$objModulo->dias_letivos = $modulo['dias_letivos'];
$cadastrou = $objModulo->cadastra();
if (!$cadastrou) {
}
return true;
}
public function verificaModulos()
{
$cursoPadraoAnoEscolar = $this->padrao_ano_escolar == 1;
$possuiModulosInformados = (count($this->data_inicio) > 1 || $this->data_inicio[0] != '');
if ($cursoPadraoAnoEscolar) {
return true;
}
if (!$possuiModulosInformados) {
$this->mensagem = 'Edição não realizada.';
return false;
}
return true;
}
public function atualizaComponentesCurriculares($codSerie, $codEscola, $codTurma, $componentes, $cargaHoraria, $usarComponente, $docente)
{
require_once 'ComponenteCurricular/Model/TurmaDataMapper.php';
$mapper = new ComponenteCurricular_Model_TurmaDataMapper();
$componentesTurma = [];
foreach ($componentes as $key => $value) {
$carga = isset($usarComponente[$key]) ?
null : $cargaHoraria[$key];
$docente_ = isset($docente[$key]) ?
1 : 0;
$etapasEspecificas = isset($this->etapas_especificas[$key]) ?
1 : 0;
$etapasUtilizadas = ($etapasEspecificas == 1) ? $this->etapas_utilizadas[$key] : null;
$componentesTurma[] = [
'id' => $value,
'cargaHoraria' => $carga,
'docenteVinculado' => $docente_,
'etapasEspecificas' => $etapasEspecificas,
'etapasUtilizadas' => $etapasUtilizadas
];
}
$mapper->bulkUpdate($codSerie, $codEscola, $codTurma, $componentesTurma);
}
public function cadastraInepTurma($cod_turma, $codigo_inep_educacenso)
{
$turma = new clsPmieducarTurma($cod_turma);
$turma->updateInep($codigo_inep_educacenso);
}
public function Excluir()
{
$obj = new clsPmieducarTurma(
$this->cod_turma,
$this->pessoa_logada,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
0
);
if ($obj->possuiAlunosVinculados()) {
$this->mensagem = 'Exclusão não realizada.';
return false;
}
$turma = $obj->detalhe();
$excluiu = $obj->excluir();
if ($excluiu) {
$obj = new clsPmieducarTurmaModulo();
$excluiu1 = $obj->excluirTodos($this->cod_turma);
if ($excluiu1) {
$auditoria = new clsModulesAuditoriaGeral('turma', $this->pessoa_logada, $this->cod_turma);
$auditoria->exclusao($turma);
$this->mensagem = 'Exclusão efetuada com sucesso.';
throw new HttpResponseException(
new RedirectResponse('educar_turma_lst.php')
);
} else {
$this->mensagem = 'Exclusão não realizada.';
return false;
}
}
$this->mensagem = 'Exclusão não realizada.';
return false;
}
protected function getDb()
{
if (!isset($this->db)) {
$this->db = new clsBanco();
}
return $this->db;
}
protected function getEscolaSerie($escolaId, $serieId)
{
$escolaSerie = new clsPmieducarEscolaSerie();
$escolaSerie->ref_cod_escola = $escolaId;
$escolaSerie->ref_cod_serie = $serieId;
return $escolaSerie->detalhe();
}
protected function getAnoEscolarEmAndamento($escolaId)
{
return $this->getDb()->CampoUnico("select ano from pmieducar.escola_ano_letivo where ativo = 1 and andamento = 1 and ref_cod_escola = $escolaId");
}
protected function getCountMatriculas($escolaId, $turmaId)
{
$ano = $this->getAnoEscolarEmAndamento($escolaId);
if (!is_numeric($ano)) {
$this->mensagem = 'Não foi possivel obter um ano em andamento, por favor, inicie um ano para a escola ou desative a configuração (para série e escola) \'Bloquear cadastro de novas turmas antes de atingir limite de vagas (no mesmo turno)\'.';
return false;
}
$sql = "select count(cod_matricula) as matriculas from pmieducar.matricula, pmieducar.matricula_turma where ano = $ano and matricula.ativo = 1 and matricula_turma.ativo = matricula.ativo and cod_matricula = ref_cod_matricula and ref_cod_turma = $turmaId";
return $this->getDb()->CampoUnico($sql);
}
protected function canCreateTurma($escolaId, $serieId, $turnoId)
{
$escolaSerie = $this->getEscolaSerie($escolaId, $serieId);
if ($escolaSerie['bloquear_cadastro_turma_para_serie_com_vagas'] == 1) {
$turmas = new clsPmieducarTurma();
$turmas = $turmas->lista(null, null, null, $serieId, $escolaId, null, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, true, $turnoId, null, null, true);
foreach ($turmas as $turma) {
$countMatriculas = $this->getCountMatriculas($escolaId, $turma['cod_turma']);
// countMatriculas retorna false e adiciona mensagem, se não obter ano em andamento
if ($countMatriculas === false) {
return false;
} elseif ($turma['max_aluno'] - $countMatriculas > 0) {
$vagas = $turma['max_aluno'] - $countMatriculas;
$this->mensagem = "Não é possivel cadastrar turmas, pois ainda existem $vagas vagas em aberto na turma '{$turma['nm_turma']}' desta serie e turno.\n\nTal limitação ocorre devido definição feita para esta escola e série.";
return false;
}
}
}
return true;
}
public function gerarJsonDosModulos()
{
$retorno = [];
foreach ($this->modulos as $modulo) {
$retorno[$modulo['cod_modulo']] = [
'label' => $modulo['nm_tipo'],
'etapas' => (int)$modulo['num_etapas']
];
}
return json_encode($retorno);
}
}
// 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'>
var modulosDisponiveis = <?php echo $miolo->gerarJsonDosModulos(); ?>;
function getComodo() {
var campoEscola = document.getElementById('ref_cod_escola').value;
var campoComodo = document.getElementById('ref_cod_infra_predio_comodo');
campoComodo.disabled = true;
campoComodo.length = 1;
campoComodo.options[0] = new Option('Selecione uma sala', '', false, false);
var xml1 = new ajax(atualizaTurmaCad_TipoComodo);
strURL = 'educar_escola_comodo_xml.php?esc=' + campoEscola;
xml1.envia(strURL);
}
function atualizaTurmaCad_TipoComodo(xml) {
var campoComodo = document.getElementById('ref_cod_infra_predio_comodo');
campoComodo.disabled = false;
var tipo_comodo = xml.getElementsByTagName('item');
if (tipo_comodo.length) {
for (var i = 0; i < tipo_comodo.length; i += 2) {
campoComodo.options[campoComodo.options.length] = new Option(
tipo_comodo[i + 1].firstChild.data, tipo_comodo[i].firstChild.data, false, false
);
}
} else {
campoComodo.length = 1;
campoComodo.options[0] = new Option('A escola n\u00e3o possui nenhuma sala', '', false, false);
}
}
function getTipoTurma() {
var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
var campoTipoTurma = document.getElementById('ref_cod_turma_tipo');
campoTipoTurma.disabled = true;
campoTipoTurma.length = 1;
campoTipoTurma.options[0] = new Option('Selecione um tipo de turma', '', false, false);
var xml1 = new ajax(atualizaTurmaCad_TipoTurma);
strURL = 'educar_tipo_turma_xml.php?ins=' + campoInstituicao;
xml1.envia(strURL);
}
function atualizaTurmaCad_TipoTurma(xml) {
var tipo_turma = xml.getElementsByTagName('item');
var campoTipoTurma = document.getElementById('ref_cod_turma_tipo');
campoTipoTurma.disabled = false;
if (tipo_turma.length) {
for (var i = 0; i < tipo_turma.length; i += 2) {
campoTipoTurma.options[campoTipoTurma.options.length] = new Option(
tipo_turma[i + 1].firstChild.data, tipo_turma[i].firstChild.data, false, false
);
}
} else {
campoTipoTurma.length = 1;
campoTipoTurma.options[0] = new Option(
'A institui\u00e7\u00e3o n\u00e3o possui nenhum tipo de turma', '', false, false
);
}
}
function getModulo() {
var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
var campoEscola = document.getElementById('ref_cod_instituicao').value;
var campoModulo = document.getElementById('ref_cod_modulo');
var url = 'educar_modulo_instituicao_xml.php';
var pars = '?inst=' + campoInstituicao;
var xml1 = new ajax(getModulo_xml);
strURL = url + pars;
xml1.envia(strURL);
}
function getModulo_xml(xml) {
var campoModulo = document.getElementById('ref_cod_modulo');
var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
campoModulo.length = 1;
campoModulo.options[0] = new Option('Selecione um m\u00f3dulo', '', false, false);
var DOM_modulos = xml.getElementsByTagName('item');
for (var j = 0; j < DOM_modulos.length; j += 2) {
campoModulo.options[campoModulo.options.length] = new Option(
DOM_modulos[j + 1].firstChild.nodeValue, DOM_modulos[j].firstChild.nodeValue,
false, false
);
}
if (campoModulo.length == 1 && campoInstituicao != '') {
campoModulo.options[0] = new Option(
'A institui\u00e7\u00e3o n\u00e3o possui nenhum m\u00f3dulo', '', false, false
);
}
}
var evtOnLoad = function () {
setVisibility('tr_hora_inicial', false);
setVisibility('tr_hora_final', false);
setVisibility('tr_hora_inicio_intervalo', false);
setVisibility('tr_hora_fim_intervalo', false);
if (!document.getElementById('ref_cod_serie').value) {
setVisibility('tr_multiseriada', false);
setVisibility('tr_ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
setVisibility('ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
} else {
if (document.getElementById('multiseriada').checked) {
changeMultiSerie();
document.getElementById('ref_cod_serie_mult').value =
document.getElementById('ref_cod_serie_mult_').value;
} else {
setVisibility('tr_ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
setVisibility('ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
}
}
// HIDE quebra de linha
var hr_tag = document.getElementsByTagName('hr');
for (var ct = 0; ct < hr_tag.length; ct++) {
setVisibility(hr_tag[ct].parentNode.parentNode, false);
}
setVisibility('tr_hora_inicial', true);
setVisibility('tr_hora_final', true);
setVisibility('tr_hora_inicio_intervalo', true);
setVisibility('tr_hora_fim_intervalo', true);
if (document.getElementById('padrao_ano_escolar').value == '') {
setModuleAndPhasesVisibility(false);
} else if (document.getElementById('padrao_ano_escolar').value == 0) {
setModuleAndPhasesVisibility(true);
var hr_tag = document.getElementsByTagName('hr');
for (var ct = 0; ct < hr_tag.length; ct++) {
setVisibility(hr_tag[ct].parentNode.parentNode, true);
}
} else {
setModuleAndPhasesVisibility(false);
}
}
if (window.addEventListener) {
// Mozilla
window.addEventListener('load', evtOnLoad, false);
} else if (window.attachEvent) {
// IE
window.attachEvent('onload', evtOnLoad);
}
document.getElementById('ref_cod_curso').onchange = function () {
setVisibility('tr_multiseriada', document.getElementById('ref_cod_serie').value ? true : false);
setVisibility('tr_ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
setVisibility('ref_cod_serie_mult', document.getElementById('multiseriada').checked ? true : false);
hideMultiSerie();
getEscolaCursoSerie();
PadraoAnoEscolar_xml();
}
function PadraoAnoEscolar_xml() {
var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
var xml1 = new ajax(PadraoAnoEscolar);
strURL = 'educar_curso_xml.php?ins=' + campoInstituicao;
xml1.envia(strURL);
}
function changeMultiSerie() {
var campoCurso = document.getElementById('ref_cod_curso').value;
var campoSerie = document.getElementById('ref_cod_serie').value;
var xml1 = new ajax(atualizaMultiSerie);
strURL = 'educar_sequencia_serie_xml.php?cur=' + campoCurso + '&ser_dif=' + campoSerie;
xml1.envia(strURL);
}
function atualizaMultiSerie(xml) {
var campoMultiSeriada = document.getElementById('multiseriada');
var checked = campoMultiSeriada.checked;
var multiBool = (document.getElementById('multiseriada').checked == true &&
document.getElementById('ref_cod_serie').value != '') ? true : false;
setVisibility('tr_ref_cod_serie_mult', multiBool);
setVisibility('ref_cod_serie_mult', multiBool);
if (!checked) {
document.getElementById('ref_cod_serie_mult').value = '';
return;
}
var campoEscola = document.getElementById('ref_cod_escola').value;
var campoCurso = document.getElementById('ref_cod_curso').value;
var campoSerieMult = document.getElementById('ref_cod_serie_mult');
var campoSerie = document.getElementById('ref_cod_serie');
campoSerieMult.length = 1;
campoSerieMult.options[0] = new Option('Selecione uma s\u00e9rie', '', false, false);
var multi_serie = xml.getElementsByTagName('serie');
if (multi_serie.length) {
for (var i = 0; i < multi_serie.length; i++) {
campoSerieMult.options[campoSerieMult.options.length] = new Option(
multi_serie[i].firstChild.data, multi_serie[i].getAttribute('cod_serie'), false, false
);
}
}
if (campoSerieMult.length == 1 && campoCurso != '') {
campoSerieMult.options[0] = new Option('O curso n\u00e3o possui nenhuma s\u00e9rie', '', false, false);
}
document.getElementById('ref_cod_serie_mult').value = document.getElementById('ref_cod_serie_mult_').value;
}
document.getElementById('multiseriada').onclick = function () {
changeMultiSerie();
}
document.getElementById('ref_cod_serie').onchange = function () {
if (this.value) {
codEscola = document.getElementById('ref_cod_escola').value;
getHoraEscolaSerie();
}
if (document.getElementById('multiseriada').checked == true) {
changeMultiSerie();
}
hideMultiSerie();
}
function hideMultiSerie() {
setVisibility('tr_multiseriada', document.getElementById('ref_cod_serie').value != '' ? true : false);
var multiBool = (document.getElementById('multiseriada').checked == true &&
document.getElementById('ref_cod_serie').value != '') ? true : false;
setVisibility('ref_cod_serie_mult', multiBool);
setVisibility('tr_ref_cod_serie_mult', multiBool);
}
function PadraoAnoEscolar(xml) {
var escola_curso_ = new Array();
if (xml != null) {
escola_curso_ = xml.getElementsByTagName('curso');
}
campoCurso = document.getElementById('ref_cod_curso').value;
for (var j = 0; j < escola_curso_.length; j++) {
if (escola_curso_[j].getAttribute('cod_curso') == campoCurso) {
document.getElementById('padrao_ano_escolar').value =
escola_curso_[j].getAttribute('padrao_ano_escolar');
}
}
setModuleAndPhasesVisibility(false);
setVisibility('tr_hora_inicial', true);
setVisibility('tr_hora_final', true);
setVisibility('tr_hora_inicio_intervalo', true);
setVisibility('tr_hora_fim_intervalo', true);
if (campoCurso == '') {
return;
}
var campoCurso = document.getElementById('ref_cod_curso').value;
if (document.getElementById('padrao_ano_escolar').value == 0) {
setModuleAndPhasesVisibility(true);
buscaEtapasDaEscola();
}
}
function setModuleAndPhasesVisibility(show) {
setVisibility('tr_etapas_cabecalho', show);
setVisibility('tr_ref_cod_modulo', show);
setVisibility('tr_turma_modulo', show);
}
function getHoraEscolaSerie() {
var campoEscola = document.getElementById('ref_cod_escola').value;
var campoSerie = document.getElementById('ref_cod_serie').value;
var xml1 = new ajax(atualizaTurmaCad_EscolaSerie);
strURL = 'educar_escola_serie_hora_xml.php?esc=' + campoEscola + '&ser=' + campoSerie;
xml1.envia(strURL);
}
function atualizaTurmaCad_EscolaSerie(xml) {
var campoHoraInicial = document.getElementById('hora_inicial');
var campoHoraFinal = document.getElementById('hora_final');
var campoHoraInicioIntervalo = document.getElementById('hora_inicio_intervalo');
var campoHoraFimIntervalo = document.getElementById('hora_fim_intervalo');
var DOM_escola_serie_hora = xml.getElementsByTagName('item');
if (DOM_escola_serie_hora.length) {
horaInicial = (DOM_escola_serie_hora[0].firstChild || {}).data;
horaFinal = (DOM_escola_serie_hora[1].firstChild || {}).data;
horaInicioIntervalo = (DOM_escola_serie_hora[2].firstChild || {}).data;
horaFimIntervalo = (DOM_escola_serie_hora[3].firstChild || {}).data;
campoHoraInicial.value = typeof(horaInicial) != 'undefined' ? horaInicial : null;
campoHoraFinal.value = typeof(horaFinal) != 'undefined' ? horaFinal : null;
campoHoraInicioIntervalo.value = typeof(horaInicioIntervalo) != 'undefined' ? horaInicioIntervalo : null;
campoHoraFimIntervalo.value = typeof(horaFimIntervalo) != 'undefined' ? horaFimIntervalo : null;
}
}
function valida() {
if (validaHorarioInicialFinal() && validaHoras() && validaAtividadesComplementares()) {
if (document.getElementById('padrao_ano_escolar').value == 1) {
var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
var campoEscola = document.getElementById('ref_cod_escola').value;
var campoTurma = document.getElementById('cod_turma').value;
var campoComodo = document.getElementById('ref_cod_infra_predio_comodo').value;
var campoCurso = document.getElementById('ref_cod_curso').value;
var campoSerie = document.getElementById('ref_cod_serie').value;
var url = 'educar_turma_sala_xml.php';
var pars = '?inst=' + campoInstituicao + '&esc=' + campoEscola + '¬_tur=' +
campoTurma + '&com=' + campoComodo + '&cur=' + campoCurso + '&ser=' + campoSerie;
var xml1 = new ajax(valida_xml);
strURL = url + pars;
xml1.envia(strURL);
} else {
valida_xml(null);
}
}
}
function valida_xml(xml) {
var DOM_turma_sala = new Array();
if (xml != null) {
DOM_turma_sala = xml.getElementsByTagName('item');
}
var campoCurso = document.getElementById('ref_cod_curso').value;
if (document.getElementById('ref_cod_escola').value) {
if (!document.getElementById('ref_cod_serie').value) {
alert("Preencha o campo 'Serie' corretamente!");
document.getElementById('ref_cod_serie').focus();
return false;
}
}
if (document.getElementById('multiseriada').checked) {
if (!document.getElementById('ref_cod_serie_mult')) {
alert("Preencha o campo 'Serie Multi-seriada' corretamente!");
document.getElementById('ref_cod_serie_mult').focus();
return false;
}
}
if (document.getElementById('padrao_ano_escolar').value == 1) {
var campoHoraInicial = document.getElementById('hora_inicial').value;
var campoHoraFinal = document.getElementById('hora_final').value;
var campoHoraInicioIntervalo = document.getElementById('hora_inicio_intervalo').value;
var campoHoraFimIntervalo = document.getElementById('hora_fim_intervalo').value;
}
if (document.getElementById('padrao_ano_escolar') == 1) {
for (var j = 0; j < DOM_turma_sala.length; j += 2) {
if (
(DOM_turma_sala[j].firstChild.nodeValue <= document.getElementById('hora_inicial').value) &&
(document.getElementById('hora_inicial').value <= DOM_turma_sala[j + 1].firstChild.nodeValue)
||
(DOM_turma_sala[j].firstChild.nodeValue <= document.getElementById('hora_final').value) &&
(document.getElementById('hora_final').value <= DOM_turma_sala[j + 1].firstChild.nodeValue)
) {
alert("ATENÇÃO!\nA 'sala' ja esta alocada nesse horario!\nPor favor, escolha outro horario ou sala.");
return false;
}
}
}
if (!acao()) {
return false;
}
document.forms[0].submit();
}
function excluir_turma_com_matriculas() {
document.formcadastro.reset();
alert(stringUtils.toUtf8('Não foi possível excluir a turma, pois a mesma possui matrículas vinculadas.'));
}
function validaCampoServidor() {
if (document.getElementById('ref_cod_instituicao').value)
ref_cod_instituicao = document.getElementById('ref_cod_instituicao').value;
else {
alert('Selecione uma instituicao');
return false;
}
if (document.getElementById('ref_cod_escola').value) {
ref_cod_escola = document.getElementById('ref_cod_escola').value;
} else {
alert('Selecione uma escola');
return false;
}
pesquisa_valores_popless('educar_pesquisa_professor_lst.php?campo1=ref_cod_regente&professor=1&ref_cod_servidor=0&ref_cod_instituicao=' + ref_cod_instituicao + '&ref_cod_escola=' + ref_cod_escola, 'ref_cod_servidor');
}
document.getElementById('ref_cod_regente_lupa').onclick = function () {
validaCampoServidor();
}
function getEscolaCursoSerie() {
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;
if (campoEscola && campoCurso) {
campoSerie.disabled = true;
campoSerie.options[0].text = 'Carregando series';
var xml = new ajax(atualizaLstEscolaCursoSerie);
xml.envia('educar_escola_curso_serie_xml.php?esc=' + campoEscola + '&cur=' + campoCurso);
} else {
campoSerie.options[0].text = 'Selecione';
}
}
function atualizaLstEscolaCursoSerie(xml) {
var campoSerie = document.getElementById('ref_cod_serie');
campoSerie.length = 1;
campoSerie.options[0].text = 'Selecione uma s\u00e9rie';
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 = 'A escola/curso n\u00e3o possui nenhuma s\u00e9rie';
}
}
$j(document).ready(function () {
$j('#scripts').closest('tr').hide();
disableInputsDisciplinas();
});
$j('.etapas_utilizadas').mask("9,9,9,9", {placeholder: "1,2,3..."});
$j("#definir_componentes_diferenciados").on("click", function () {
disableInputsDisciplinas();
});
$j('.check-disciplina').on('change', function () {
var enabled = $j(this).prop('checked');
$j(this).closest('.linha-disciplina').find('input:not(.check-disciplina)').attr("disabled", !enabled);
});
function disableInputsDisciplinas() {
var disable = $j('#definir_componentes_diferenciados').prop('checked');
$j("#disciplinas").find("input").attr("disabled", !disable);
$j("#disciplinas").find('.check-disciplina').each(function () {
$j(this).trigger("change");
})
}
</script>