ajustado para receber o nome da escola e idade do aluno
This commit is contained in:
@@ -64,7 +64,8 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
status = 'CARREGANDO ESTUDANTE(S) ...';
|
||||
});
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
buscaFilhos(map['NOME']);
|
||||
print(map['PARENTESCO']);
|
||||
buscaFilhos(map['NOME'],map['PARENTESCO']);
|
||||
}else{
|
||||
setState(() {
|
||||
loading = false;
|
||||
@@ -74,10 +75,10 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
}
|
||||
}
|
||||
|
||||
buscaFilhos(String nome)async{
|
||||
buscaFilhos(String nome,String parentesco)async{
|
||||
String q = nome.replaceAll(' ', '%20').toUpperCase();
|
||||
final url = 'http://192.168.18.2:8000/buscafilhos?NOME=$q';
|
||||
// print(url);
|
||||
final url = 'http://192.168.18.2:8000/buscafilhos?NOME=$q&PARENTESCO=${parentesco.replaceAll("Ã", 'A').replaceAll('ã', 'a')}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
|
||||
@@ -87,7 +88,29 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
loading = false;
|
||||
});
|
||||
if(listAlunos.length==1){
|
||||
estudanteModelo = EstudanteModelo(nome: listAlunos[0]['NO_ALUNO'], foto: '', ra: listAlunos[0]['NR_RA'], escola: '', idade: 0, anoEscolar: 2023);
|
||||
|
||||
String dataBD = listAlunos[0]['DT_NASCIMENTO'];
|
||||
int dia = 00;
|
||||
int mes = 00;
|
||||
int ano = 0000;
|
||||
int idade = 0;
|
||||
if(dataBD!=''){
|
||||
dia = int.parse(dataBD.substring(6,8));
|
||||
mes = int.parse(dataBD.substring(4,6));
|
||||
ano = int.parse(dataBD.substring(0,4));
|
||||
final hoje = DateTime.now();
|
||||
final nasc = DateTime.utc(ano,mes,dia);
|
||||
idade = (hoje.difference(nasc).inDays/365).toInt();
|
||||
}
|
||||
|
||||
estudanteModelo = EstudanteModelo(
|
||||
nome: listAlunos[0]['NO_ALUNO'],
|
||||
foto: '',
|
||||
ra: listAlunos[0]['NR_RA'],
|
||||
escola: listAlunos[0]['NO_FANTASIA']=='' || listAlunos[0]['NO_FANTASIA']==null?listAlunos[0]['NO_RAZAO_SOCIAL']:listAlunos[0]['NO_FANTASIA'],
|
||||
idade: idade,
|
||||
anoEscolar: DateTime.now().year
|
||||
);
|
||||
Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSituacaoEscolar(estudanteModelo: estudanteModelo!)));
|
||||
}else{
|
||||
Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSelecionaFilho(listAlunos: listAlunos,)));
|
||||
|
||||
Reference in New Issue
Block a user