697 lines
26 KiB
Dart
697 lines
26 KiB
Dart
import 'dart:convert';
|
|
import 'package:flutter_calendar_carousel/classes/event.dart';
|
|
import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/dropdown_turma.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/dropdown_disciplina.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/dropdown_periodo.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/item_aluno_presenca.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/snackBars.dart';
|
|
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
|
import 'package:rkm_educa_prof_app/controllers/main_controllers.dart';
|
|
import 'package:rkm_educa_prof_app/modelos/modelo_periodo.dart';
|
|
import '../componentes/appbar_custom.dart';
|
|
import '../componentes/drawer_custom.dart';
|
|
import '../componentes/item_subtitulo_texto.dart';
|
|
import '../modelos/modelo_disciplina.dart';
|
|
import '../modelos/modelo_presenca_aluno.dart';
|
|
import '../utils/cores.dart';
|
|
import '../utils/dimensoes.dart';
|
|
|
|
class TelaFaltas extends StatefulWidget {
|
|
List dados;
|
|
|
|
TelaFaltas({
|
|
required this.dados
|
|
});
|
|
|
|
@override
|
|
State<TelaFaltas> createState() => _TelaFaltasState();
|
|
}
|
|
|
|
class _TelaFaltasState extends State<TelaFaltas> {
|
|
|
|
List<ModeloDisciplina> disciplinas = [];
|
|
List<ModeloPeriodo> periodos = [];
|
|
List<ModeloPresencaAluno> alunos = [];
|
|
List<int> AULAS = [];
|
|
List turmas = [];
|
|
List tipoEnsino = [];
|
|
ModeloDisciplina? selecionaDisciplina;
|
|
String? selecionaTurma;
|
|
ModeloPeriodo? selecionaPeriodo;
|
|
int ID_TIPO_ENSINO = 0;
|
|
int CD_DISCIPLINA = 0;
|
|
int CD_SALA = 0;
|
|
DateTime? DT_INICIAL;
|
|
DateTime? DT_FINAL;
|
|
bool exibirCalendario = false;
|
|
DateTime dataAtual = DateTime.now();
|
|
DateTime? _dataSelecionada;
|
|
double hightLine = 40;
|
|
int DIA_SEMANA = 0;
|
|
bool edit = false;
|
|
bool novaChamada = false;
|
|
String SIGLA_TIPO_ENSINO = '';
|
|
List<int> DIARIO_CLASSE = [];
|
|
bool SALVANDO = false;
|
|
|
|
EventList<Event> _markedDateMap = new EventList<Event>(
|
|
events: {},
|
|
);
|
|
|
|
Widget _eventIcon(String dia,Color cor) => Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(30),
|
|
color: cor,
|
|
),
|
|
width: 40,
|
|
height: 40,
|
|
child: Center(
|
|
child: TextCustom(text: dia,fontWeight: FontWeight.bold,size: 14.0,color: Colors.white),
|
|
),
|
|
);
|
|
|
|
buscarDisciplinas()async{
|
|
print('dados');
|
|
print(widget.dados);
|
|
final url = '${widget.dados[2]}/buscardisciplinasprof?USUARIO_SISTEMA=${widget.dados[8]}&CIDADE=${widget.dados[0]}&ANO=${DateTime.now().year}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
var map = json.decode(response.body);
|
|
// print(map);
|
|
List list = map;
|
|
for(int i = 0; list.length > i; i++){
|
|
tipoEnsino.add(list[i]['CD_TIPO_ENSINO']);
|
|
disciplinas.add(
|
|
ModeloDisciplina(
|
|
CD_ANO_DISCIPLINA: list[i]['CD_ANO_DISCIPLINA'],
|
|
CD_CAD_DIVERSO: list[i]['CD_CAD_DIVERSO'],
|
|
CD_SALA: list[i]['CD_SALA'],
|
|
CD_SERIE: list[i]['CD_SERIE'],
|
|
ANO_ATRIBUICAO: list[i]['ANO_ATRIBUICAO'],
|
|
CD_DISCIPLINA: list[i]['CD_DISCIPLINA'],
|
|
CD_TIPO_ENSINO: list[i]['CD_TIPO_ENSINO'],
|
|
DESCRICAO: list[i]['DESCRICAO'],
|
|
ABREVIATURA: list[i]['ABREVIATURA'],
|
|
TURMA: list[i]['TURMA'].toString().trim(),
|
|
DESC_SERIE: list[i]['DESC_SERIE'].toString().trim(),
|
|
GRAU: list[i]['GRAU'].toString().trim(),
|
|
HR_INICIO: list[i]['HR_INICIO'].toString().trim()
|
|
)
|
|
);
|
|
|
|
turmas.add(
|
|
'${disciplinas[i].GRAU} - ${disciplinas[i].DESC_SERIE} - ${disciplinas[i].TURMA} - ${disciplinas[i].HR_INICIO.toString().trim().toUpperCase()=='07:00:00'?'MANHA':'TARDE'}'
|
|
);
|
|
if(SIGLA_TIPO_ENSINO != disciplinas[i].GRAU.toString().trim().toUpperCase()){
|
|
SIGLA_TIPO_ENSINO = disciplinas[i].GRAU.toString().trim().toUpperCase();
|
|
}
|
|
if(turmas.isNotEmpty){
|
|
List duplicada = turmas.toSet().toList();
|
|
turmas = duplicada;
|
|
}
|
|
}
|
|
setState(() {});
|
|
// print(disciplinas);
|
|
}
|
|
|
|
buscarPediodoBimestral()async{
|
|
final url = '${widget.dados[2]}/buscarperiodobimestral?CIDADE=${widget.dados[0]}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
var map = json.decode(response.body);
|
|
// print(map);
|
|
List list = map;
|
|
for(int i = 0; list.length > i; i++){
|
|
periodos.add(ModeloPeriodo(PERIODO: list[i]['PERIODO'], NO_PERIODO: list[i]['NO_PERIODO']));
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
buscarPediodoDatas(String id)async{
|
|
final url = '${widget.dados[2]}/buscarintervalodatas?ID_TIPO_ENSINO=${ID_TIPO_ENSINO}&ANO=${DateTime.now().year}-01-01&NR_SEQUENCIA=${id}&CIDADE=${widget.dados[0]}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
var map = json.decode(response.body);
|
|
print(map);
|
|
List list = map;
|
|
if(list.isNotEmpty){
|
|
for(int i = 0; list.length > i; i ++){
|
|
if(list[i]['NO_TITULO'].toString().toUpperCase().trim() == 'BIMESTRE'){
|
|
List dataListInicial = list[i]['DT_INICIAL'].toString().split('-');
|
|
List dataListFinal = list[i]['DT_FINAL'].toString().split('-');
|
|
int diaInicial = int.parse(dataListInicial[2]);
|
|
int mesInicial = int.parse(dataListInicial[1]);
|
|
int anoInicial = int.parse(dataListInicial[0]);
|
|
|
|
int diaFinal = int.parse(dataListFinal[2]);
|
|
int mesFinal = int.parse(dataListFinal[1]);
|
|
int anoFinal = int.parse(dataListFinal[0]);
|
|
DT_INICIAL = DateTime(anoInicial,mesInicial,diaInicial);
|
|
DT_FINAL = DateTime(anoFinal,mesFinal,diaFinal);
|
|
dataAtual = DT_INICIAL!;
|
|
setState(() {});
|
|
}
|
|
}
|
|
print('INICIAL ${DT_INICIAL}');
|
|
print('FINAL ${DT_FINAL}');
|
|
}
|
|
}
|
|
|
|
buscarGrade(int CD_SALA, int CD_DISCIPLINA)async{
|
|
final url = '${widget.dados[2]}/buscargrade?CD_SALA=${CD_SALA}&CD_DISCIPLINA=${CD_DISCIPLINA}&CIDADE=${widget.dados[0]}';
|
|
// print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
List map = json.decode(response.body);
|
|
if(map.isNotEmpty){
|
|
// print(map);
|
|
AULAS.clear();
|
|
List diasSemana = [];
|
|
List semana = ['DOMINGO', 'SEGUNDAS', 'TERÇAS', 'QUARTAS', 'QUINTAS', 'SEXTAS', 'SÁBADOS'];
|
|
for(int i = 0; map.length > i; i ++){
|
|
diasSemana.add(int.parse(map[i]['DIA_SEMANA'].toString().trim()));
|
|
if(DIA_SEMANA==map[i]['DIA_SEMANA']){
|
|
AULAS.add(map[i]['AULA']);
|
|
}
|
|
}
|
|
print('AULAS');
|
|
print(AULAS);
|
|
List diasAula = diasSemana.toSet().toList();
|
|
diasSemana = diasAula;
|
|
if(!diasSemana.contains(DIA_SEMANA)){
|
|
_dataSelecionada = null;
|
|
_markedDateMap.clear();
|
|
showSnackBar(context, 'ESSA AULA É AS ${semana[diasSemana[0]]}!', Colors.red);
|
|
}else{
|
|
if(_dataSelecionada!=null){
|
|
// print('dias das aulas');
|
|
// print(diasSemana);
|
|
// print('aulas');
|
|
// print(AULAS);
|
|
buscarChamadasRealizadas();
|
|
}else{
|
|
showSnackBar(context, 'Selecione uma data!', Colors.red);
|
|
}
|
|
}
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
buscarChamadasRealizadas()async{
|
|
String dia = _dataSelecionada!.day.toString();
|
|
String mes = _dataSelecionada!.month.toString();
|
|
String ano = _dataSelecionada!.year.toString();
|
|
|
|
final url = '${widget.dados[2]}/buscarchamadasrealizadas?'
|
|
'CD_SALA=${CD_SALA}&CD_DISCIPLINA=${CD_DISCIPLINA}&DATA=$ano-$mes-$dia&ANO=${int.parse(ano)}&CIDADE=${widget.dados[0]}';
|
|
// print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
List map = json.decode(response.body);
|
|
// print(map);
|
|
if(map.isNotEmpty){
|
|
alunos.clear();
|
|
for(int i = 0; map.length > i; i++){
|
|
|
|
int indexAluno = alunos.indexWhere((aluno) => aluno.CD_MATRICULA == map[i]['CD_MATRICULA']);
|
|
|
|
if(indexAluno == -1){
|
|
alunos.add(
|
|
ModeloPresencaAluno(
|
|
DT_DIARIO_CLASSE: map[i]['DT_DIARIO_CLASSE'],
|
|
CD_SALA: CD_SALA,
|
|
CD_MATRICULA: map[i]['CD_MATRICULA'],
|
|
CD_ALUNO: map[i]['CD_ALUNO'],
|
|
NO_ALUNO: map[i]['NO_ALUNO'],
|
|
NR_TURMA: map[i]['NR_TURMA'],
|
|
CD_DISCIPLINA: map[i]['CD_DISCIPLINA'],
|
|
CD_AULA1: map[i]['CD_AULA'] == 1?1:0,
|
|
CD_AULA2: map[i]['CD_AULA'] == 2?2:0,
|
|
CD_AULA3: map[i]['CD_AULA'] == 3?3:0,
|
|
CD_AULA4: map[i]['CD_AULA'] == 4?4:0,
|
|
CD_AULA5: map[i]['CD_AULA'] == 5?5:0,
|
|
FL_PRESENTE_AUSENTE1: map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false,
|
|
FL_PRESENTE_AUSENTE2: map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false,
|
|
FL_PRESENTE_AUSENTE3: map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false,
|
|
FL_PRESENTE_AUSENTE4: map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false,
|
|
FL_PRESENTE_AUSENTE5: map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false,
|
|
STATUS: map[i]['STATUS'],
|
|
)
|
|
);
|
|
}else{
|
|
if(map[i]['CD_AULA'] == 1){
|
|
alunos[indexAluno].CD_AULA1 = 1;
|
|
alunos[indexAluno].FL_PRESENTE_AUSENTE1 = map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false;
|
|
}else if(map[i]['CD_AULA'] == 2){
|
|
alunos[indexAluno].CD_AULA2 = 2;
|
|
alunos[indexAluno].FL_PRESENTE_AUSENTE2 = map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false;
|
|
}else if(map[i]['CD_AULA'] == 3){
|
|
alunos[indexAluno].CD_AULA3 = 3;
|
|
alunos[indexAluno].FL_PRESENTE_AUSENTE3 = map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false;
|
|
}else if(map[i]['CD_AULA'] == 4){
|
|
alunos[indexAluno].CD_AULA4 = 4;
|
|
alunos[indexAluno].FL_PRESENTE_AUSENTE4 = map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false;
|
|
}else if(map[i]['CD_AULA'] == 5){
|
|
alunos[indexAluno].CD_AULA5 = 5;
|
|
alunos[indexAluno].FL_PRESENTE_AUSENTE5 = map[i]['FL_PRESENTE_AUSENTE'].toString().toUpperCase()=='A'?true:false;
|
|
}
|
|
}
|
|
}
|
|
novaChamada = false;
|
|
SALVANDO = false;
|
|
edit = false;
|
|
print('alunos : ${alunos.length}');
|
|
}else{
|
|
print('chamada não realizada');
|
|
showSnackBar(context, 'NOVA CHAMADA!', Colors.deepOrangeAccent);
|
|
novaChamada = true;
|
|
buscarNovaChamada(CD_SALA, ano);
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
buscarNovaChamada(int sala, String ano)async{
|
|
final url = '${widget.dados[2]}/buscarnovachamada?''CD_SALA=${sala}&ANO=${ano}&CIDADE=${widget.dados[0]}';
|
|
// print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
List map = json.decode(response.body);
|
|
// print(map);
|
|
if(map.isNotEmpty){
|
|
|
|
String dia = _dataSelecionada!.day.toString();
|
|
String mes = _dataSelecionada!.month.toString();
|
|
String ano = _dataSelecionada!.year.toString();
|
|
|
|
alunos.clear();
|
|
for(int i = 0; map.length > i; i++){
|
|
alunos.add(
|
|
new ModeloPresencaAluno(
|
|
DT_DIARIO_CLASSE: '$ano-$mes-$dia',
|
|
CD_SALA: sala,
|
|
CD_MATRICULA: map[i]['CD_MATRICULA'],
|
|
CD_ALUNO: map[i]['CD_ALUNO'],
|
|
NO_ALUNO: map[i]['NO_ALUNO'],
|
|
NR_TURMA: map[i]['NR_TURMA'],
|
|
CD_DISCIPLINA: CD_DISCIPLINA,
|
|
STATUS: map[i]['STATUS'],
|
|
CD_AULA1: AULAS.contains(1)?1:0,
|
|
CD_AULA2: AULAS.contains(2)?2:0,
|
|
CD_AULA3: AULAS.contains(3)?3:0,
|
|
CD_AULA4: AULAS.contains(4)?4:0,
|
|
CD_AULA5: AULAS.contains(5)?5:0,
|
|
)
|
|
);
|
|
}
|
|
}else{
|
|
showSnackBar(context, 'NÃO FOI POSSÍVEL CRIAR UMA NOVA CHAMADA', Colors.red);
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
buscarCodigoCalendario()async{
|
|
String dia = _dataSelecionada!.day.toString();
|
|
String mes = _dataSelecionada!.month.toString();
|
|
String ano = _dataSelecionada!.year.toString();
|
|
|
|
final url = '${widget.dados[2]}/buscarcodigocalendario?CD_CAD_DIVERSO=${widget.dados[4]}&'
|
|
'DT_CALENDARIO=$ano-$mes-$dia&SIGLA=$SIGLA_TIPO_ENSINO&CIDADE=${widget.dados[0]}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
List map = json.decode(response.body);
|
|
|
|
print('CD_CALENDARIO');
|
|
print(map[0]['CD_CALENDARIO']);
|
|
|
|
buscarDiarioClasse(dia, mes, ano, map[0]['CD_CALENDARIO']);
|
|
}
|
|
|
|
buscarDiarioClasse(String dia, String mes, String ano,int CD_CALENDARIO)async{
|
|
List<int> buscaAulas = [];
|
|
for(int i = 0; AULAS.length > i; i++){
|
|
final url = '${widget.dados[2]}/buscardiarioclasse?CD_AULA=${AULAS[i]}&CD_SALA=$CD_SALA&'
|
|
'DT_DIARIO_CLASSE=$ano-$mes-$dia&CIDADE=${widget.dados[0]}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
List map = json.decode(response.body);
|
|
print(map);
|
|
if(map.isNotEmpty){
|
|
buscaAulas.add(AULAS[i]);
|
|
}
|
|
}
|
|
|
|
if(buscaAulas.isEmpty){
|
|
DIARIO_CLASSE = [];
|
|
List dados = [
|
|
'$ano-$mes-$dia',
|
|
CD_SALA,
|
|
CD_CALENDARIO,
|
|
CD_DISCIPLINA
|
|
];
|
|
|
|
for(int i = 0; AULAS.length> i; i++){
|
|
DIARIO_CLASSE.add(await MainControllers().salvarDiarioClasse(widget.dados, dados, AULAS[i])) ;
|
|
}
|
|
}
|
|
print('DIARIO_CLASSE : $DIARIO_CLASSE');
|
|
|
|
if(DIARIO_CLASSE.isNotEmpty){
|
|
bool SALVAMENTO_BANCO = await MainControllers().verificarDadosNovaChamada(alunos,widget.dados);
|
|
if(SALVAMENTO_BANCO){
|
|
showSnackBar(context, 'CHAMADA FOI SALVA', Colors.green);
|
|
buscarChamadasRealizadas();
|
|
}
|
|
}
|
|
}
|
|
|
|
atualizarData(DateTime date, List<Event> events){
|
|
|
|
int resultado = date.compareTo(DateTime.now());
|
|
|
|
print(resultado);
|
|
|
|
if(resultado <= 0 ){
|
|
_markedDateMap.clear();_markedDateMap.add(
|
|
date,
|
|
Event(
|
|
date: date,
|
|
icon: _eventIcon(date.day.toString(),Colors.deepOrangeAccent)
|
|
)
|
|
);
|
|
|
|
alunos.clear();
|
|
selecionaDisciplina = null;
|
|
_dataSelecionada = date;
|
|
DIA_SEMANA = date.weekday;
|
|
setState(() {});
|
|
// events.forEach((event) => print(event.title));
|
|
print(_dataSelecionada);
|
|
}else{
|
|
showSnackBar(context, 'Esta data maior do que a atual', Colors.red);
|
|
}
|
|
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
buscarDisciplinas();
|
|
buscarPediodoBimestral();
|
|
}
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
TextStyle textStyle = TextStyle(
|
|
color: PaletaCores.cinza,
|
|
fontWeight: FontWeight.bold,
|
|
fontFamily: 'Nunito',
|
|
fontSize: 14
|
|
);
|
|
|
|
TextStyle selectedDayTextStyle = TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontFamily: 'Nunito',
|
|
fontSize: 14
|
|
);
|
|
|
|
TextStyle textStyleFDS = TextStyle(
|
|
color: Colors.red,
|
|
fontWeight: FontWeight.bold,
|
|
fontFamily: 'Nunito',
|
|
fontSize: 14
|
|
);
|
|
|
|
final _calendario = CalendarCarousel<Event>(
|
|
locale: 'pt',
|
|
weekdayTextStyle: TextStyle(color: PaletaCores.cinza,fontSize: 14,fontFamily: 'Nunito',),
|
|
daysTextStyle: textStyle,
|
|
selectedDayButtonColor: Colors.deepOrangeAccent,
|
|
weekendTextStyle: textStyleFDS,
|
|
markedDatesMap: _markedDateMap,
|
|
height: Dimensoes.height*0.45,
|
|
targetDateTime: dataAtual,
|
|
markedDateCustomTextStyle: selectedDayTextStyle,
|
|
markedDateMoreShowTotal: null,
|
|
showHeader: false,
|
|
todayTextStyle: textStyle,
|
|
isScrollable: false,
|
|
todayButtonColor: Colors.white,
|
|
selectedDayTextStyle: selectedDayTextStyle,
|
|
minSelectedDate: DT_INICIAL,
|
|
maxSelectedDate: DT_FINAL,
|
|
markedDateIconBuilder: (event){
|
|
return event.icon;
|
|
},
|
|
selectedDateTime: _dataSelecionada,
|
|
onDayPressed: (DateTime date, List<Event> events) {
|
|
atualizarData(date!,events);
|
|
},
|
|
);
|
|
|
|
return Scaffold(
|
|
appBar: AppBarCustom().appbar(context, 'LANÇAMENTO DE FALTAS'),
|
|
drawer: DrawerCustom(dados: widget.dados,),
|
|
bottomNavigationBar: SALVANDO?Container(width: 0,height: 0,):exibirCalendario?Container(height: 0,width: 0,):edit?Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SALVANDO?Container():CircleAvatar(
|
|
backgroundColor: Colors.red,
|
|
child: IconButton(
|
|
icon: Icon(Icons.clear,color: Colors.white,),
|
|
onPressed: (){
|
|
setState(()=>edit=false);
|
|
buscarGrade(CD_SALA,CD_DISCIPLINA);
|
|
}
|
|
),
|
|
),
|
|
SizedBox(width: 10,),
|
|
SALVANDO?Container():CircleAvatar(
|
|
backgroundColor: PaletaCores.verdeCalendario,
|
|
child: IconButton(
|
|
icon: Icon(Icons.check,color: Colors.white,),
|
|
onPressed: ()async{
|
|
if(novaChamada){
|
|
setState(()=>SALVANDO = true);
|
|
buscarCodigoCalendario();
|
|
}else{
|
|
setState(()=>SALVANDO = true);
|
|
bool aguardandoAlteracao = await MainControllers().atualizarChamada(alunos,widget.dados);
|
|
if(aguardandoAlteracao){
|
|
buscarChamadasRealizadas();
|
|
setState(()=>SALVANDO = false);
|
|
setState(()=>edit=false);
|
|
showSnackBar(context, 'DADOS SALVOS COM SUCESSO', Colors.green);
|
|
}else{
|
|
setState(()=>SALVANDO = false);
|
|
showSnackBar(context, 'DADOS NÃO FORAM SALVOS', Colors.red);
|
|
}
|
|
}
|
|
}
|
|
)
|
|
),
|
|
],
|
|
),
|
|
):Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
CircleAvatar(
|
|
backgroundColor: Colors.deepOrangeAccent,
|
|
child: IconButton(
|
|
icon: Icon(Icons.edit, color: Colors.white),
|
|
onPressed: ()=> setState(()=>edit=true)
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: exibirCalendario?Container(
|
|
child: ListView(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
IconButton(
|
|
onPressed: (){
|
|
if(DT_INICIAL!.month < dataAtual.month){
|
|
dataAtual = DateTime(dataAtual.year, dataAtual.month -1);
|
|
setState(() {});
|
|
}
|
|
},
|
|
icon: Icon(Icons.arrow_left,size: 30,color: PaletaCores.cinzaClaro,)
|
|
),
|
|
TextCustom(text: DateFormat('MMMM / yyyy','pt_Br').format(dataAtual),fontWeight: FontWeight.bold),
|
|
IconButton(
|
|
onPressed: (){
|
|
if(DT_FINAL!.month > dataAtual.month){
|
|
dataAtual = DateTime(dataAtual.year, dataAtual.month +1);
|
|
setState(() {});
|
|
}
|
|
},
|
|
icon: Icon(Icons.arrow_right,size: 30,color: PaletaCores.cinzaClaro,)
|
|
),
|
|
],
|
|
),
|
|
_calendario,
|
|
Center(child: TextButton(
|
|
style: TextButton.styleFrom(
|
|
backgroundColor: Colors.deepOrangeAccent,
|
|
),
|
|
onPressed: ()=>setState(()=>exibirCalendario = false),
|
|
child: TextCustom(text: 'SELECIONAR', color: Colors.white, size: 10.0),
|
|
),)
|
|
],
|
|
),
|
|
):ListView(
|
|
padding: EdgeInsets.all(20),
|
|
children: [
|
|
ItemSubtituloTexto(titulo:'Escola: ',subtitulo: widget.dados[3]),
|
|
ItemSubtituloTexto(titulo:'Tipo Falta: ',subtitulo: 'AULA'),
|
|
DropdownTurma(
|
|
titulo: 'Turma: ',
|
|
seleciona: selecionaTurma,
|
|
itens: turmas,
|
|
hightLine: hightLine,
|
|
onChanged:edit?null: (value){
|
|
selecionaTurma = value!.toString();
|
|
selecionaDisciplina = null;
|
|
selecionaPeriodo = null;
|
|
int index = turmas.indexOf(selecionaTurma);
|
|
ID_TIPO_ENSINO = tipoEnsino[index];
|
|
_dataSelecionada = null;
|
|
alunos.clear();
|
|
setState(() {});
|
|
},
|
|
),
|
|
selecionaTurma==null?Container():DropdownPeriodo(
|
|
titulo: 'Período: ',
|
|
seleciona: selecionaPeriodo,
|
|
hightLine: hightLine,
|
|
itens: periodos.map((value) => DropdownMenuItem<ModeloPeriodo>(
|
|
value: value,
|
|
child: TextCustom(
|
|
text: value.NO_PERIODO,
|
|
size: 12.0,
|
|
color: Colors.black54,
|
|
),
|
|
)
|
|
).toList(),
|
|
onChanged:edit?null: (ModeloPeriodo? value){
|
|
selecionaPeriodo = value;
|
|
_dataSelecionada = null;
|
|
alunos.clear();
|
|
buscarPediodoDatas(value!.PERIODO);
|
|
setState(() {});
|
|
},
|
|
),
|
|
selecionaTurma ==null || selecionaPeriodo== null?Container(): Container(
|
|
height: hightLine,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
TextCustom(text: 'Data: ',fontWeight: FontWeight.bold),
|
|
SizedBox(width: 10,),
|
|
_dataSelecionada!= null?GestureDetector(
|
|
onTap:edit?null: ()=>setState(()=>exibirCalendario = true),
|
|
child: Container(
|
|
child: TextCustom(text: DateFormat('dd/MM/yyyy', 'pt_BR').format(_dataSelecionada!),size: 12.0,),
|
|
),
|
|
):Container(),
|
|
IconButton(
|
|
onPressed:edit?null: ()=>setState(()=>exibirCalendario = true),
|
|
icon: Icon(Icons.calendar_month,size: 25)
|
|
)
|
|
],
|
|
),
|
|
),
|
|
selecionaTurma==null || selecionaPeriodo== null || _dataSelecionada== null?Container():
|
|
DropdownDisciplina(
|
|
titulo: 'Disciplina: ',
|
|
seleciona: selecionaDisciplina,
|
|
hightLine: hightLine,
|
|
listDropDown: disciplinas.map((value) => DropdownMenuItem<ModeloDisciplina>(
|
|
value: value,
|
|
child: TextCustom(
|
|
text: value.DESCRICAO,
|
|
size: 12.0,
|
|
color: Colors.black54,
|
|
),
|
|
)
|
|
).toList(),
|
|
onChanged:edit?null: (ModeloDisciplina? value){
|
|
alunos.clear();
|
|
selecionaDisciplina = value;
|
|
print('CD_DISCIPLINA : '+ value!.CD_DISCIPLINA.toString());
|
|
print('CD_SALA : '+ value!.CD_SALA.toString());
|
|
CD_DISCIPLINA = value!.CD_DISCIPLINA;
|
|
CD_SALA = value!.CD_SALA;
|
|
buscarGrade(value!.CD_SALA,value!.CD_DISCIPLINA);
|
|
setState(() {});
|
|
},
|
|
),
|
|
SALVANDO?Container(
|
|
height: Dimensoes.height*0.55,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
CircularProgressIndicator(color: Colors.deepOrangeAccent),
|
|
SizedBox(height: 50),
|
|
TextCustom(text: 'Salvando dados dos estudantes.\nAguarde...', fontWeight: FontWeight.bold,maxLines: 2,)
|
|
],
|
|
),
|
|
):Container(),
|
|
SALVANDO || alunos.isEmpty?Container():Container(
|
|
child: Row(
|
|
children: [
|
|
TextCustom(text: 'ESTUDANTE',size: 12.0, fontWeight: FontWeight.bold),
|
|
Spacer(),
|
|
TextCustom(text: 'FALTAS AULA',size: 12.0, fontWeight: FontWeight.bold),
|
|
],
|
|
),
|
|
),
|
|
SALVANDO || alunos.isEmpty?Container():Container(
|
|
height: Dimensoes.height*0.55,
|
|
child: ListView.builder(
|
|
itemCount: alunos.length,
|
|
itemBuilder: (context, index){
|
|
return ItemAlunoPresenca(
|
|
edit: edit,
|
|
onChanged1: (value)=>setState((){
|
|
alunos[index].FL_PRESENTE_AUSENTE1 = value!;
|
|
alunos[index].STATUS_DADOS = 'ALTERADO';
|
|
}),
|
|
onChanged2: (value)=>setState((){
|
|
alunos[index].FL_PRESENTE_AUSENTE2 = value!;
|
|
alunos[index].STATUS_DADOS = 'ALTERADO';
|
|
}),
|
|
onChanged3: (value)=>setState((){
|
|
alunos[index].FL_PRESENTE_AUSENTE3 = value!;
|
|
alunos[index].STATUS_DADOS = 'ALTERADO';
|
|
}),
|
|
onChanged4: (value)=>setState((){
|
|
alunos[index].FL_PRESENTE_AUSENTE4 = value!;
|
|
alunos[index].STATUS_DADOS = 'ALTERADO';
|
|
}),
|
|
onChanged5: (value)=>setState((){
|
|
alunos[index].FL_PRESENTE_AUSENTE5 = value!;
|
|
alunos[index].STATUS_DADOS = 'ALTERADO';
|
|
}),
|
|
aluno: alunos[index],
|
|
);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
)
|
|
);
|
|
}
|
|
}
|