ano letivo recuperando do banco de dados
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:rkm_educa_app/telas/tela_agenda.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_botetim.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_chamada.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_contatos.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_historico.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_login.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_passe.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_perfil.dart';
|
||||
@@ -19,6 +18,7 @@ import 'item_drawer.dart';
|
||||
class DrawerCustom extends StatelessWidget {
|
||||
List<EstudanteModelo> alunos;
|
||||
int indiceFilhos;
|
||||
|
||||
DrawerCustom({
|
||||
required this.alunos,
|
||||
required this.indiceFilhos,
|
||||
@@ -72,12 +72,12 @@ class DrawerCustom extends StatelessWidget {
|
||||
Container(height: 1,color: PaletaCores.divider,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
ItemDrawer(
|
||||
icone: LineIcons.clipboardList,
|
||||
texto: 'Boletim Escolar ${DateTime.now().year}',
|
||||
texto: 'Boletim Escolar ${alunos[indiceFilhos].ANO_LETIVO}',
|
||||
onPressed: ()=>Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context)=>
|
||||
TelaBoletim(
|
||||
estudanteModelo: alunos[indiceFilhos],
|
||||
ano: '${DateTime.now().year}',
|
||||
ano: '${alunos[indiceFilhos].ANO_LETIVO}',
|
||||
turma: "${alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['DESC_SERIE']} ${alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['TURMA']}",
|
||||
matricula: alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['CD_MATRICULA'].toString()
|
||||
)
|
||||
@@ -87,12 +87,12 @@ class DrawerCustom extends StatelessWidget {
|
||||
Container(height: 1,color: PaletaCores.divider,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
ItemDrawer(
|
||||
icone: LineIcons.fileContract,
|
||||
texto: 'Boletim Escolar ${DateTime.now().year-1}',
|
||||
texto: 'Boletim Escolar ${alunos[indiceFilhos].ANO_LETIVO-1}',
|
||||
onPressed: ()=> Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context)=>
|
||||
TelaBoletim(
|
||||
estudanteModelo: alunos[indiceFilhos],
|
||||
ano: '${DateTime.now().year-1}',
|
||||
ano: '${alunos[indiceFilhos].ANO_LETIVO-1}',
|
||||
turma: "${alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['DESC_SERIE']} ${alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['TURMA']}",
|
||||
matricula: alunos[indiceFilhos].dados[alunos[indiceFilhos].nroAluno]['CD_MATRICULA'].toString()
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:gainer_crypto/crypto.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -44,10 +46,8 @@ class MainControllers{
|
||||
}
|
||||
salvarLog(EstudanteModelo estudanteModelo,String TELA)async{
|
||||
final url = '${estudanteModelo.URL}/log';
|
||||
|
||||
// print('dados');
|
||||
// print(widget.estudanteModelo.dados);
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(url),
|
||||
body:{
|
||||
@@ -63,4 +63,22 @@ class MainControllers{
|
||||
|
||||
print('response : ${response.body}');
|
||||
}
|
||||
Future<int> pegarAno(String urlAPI,String cidade)async{
|
||||
final url = '$urlAPI/mostrar_boletim?ANO=${DateTime.now().year}&CIDADE=$cidade';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
String data = map[0]['DT_INICIAL'];
|
||||
DateTime dataInicial = DateTime.parse(data);
|
||||
// print(dataInicial);
|
||||
// print(DateTime.now());
|
||||
// print((DateTime.now().difference(dataInicial).inDays).toInt());
|
||||
if(DateTime.now().difference(dataInicial).inDays>=0){
|
||||
print('exibir ano atual');
|
||||
return DateTime.now().year;
|
||||
}else{
|
||||
print('exibir ano anterior');
|
||||
return DateTime.now().year-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_app/componentes/appbar_custom.dart';
|
||||
import 'package:rkm_educa_app/componentes/drawer_custom.dart';
|
||||
import 'package:rkm_educa_app/componentes/item_bimestre.dart';
|
||||
import 'package:rkm_educa_app/componentes/item_disciplina.dart';
|
||||
import 'package:rkm_educa_app/componentes/item_modelo.dart';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:brasil_fields/brasil_fields.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rkm_educa_app/Telas/tela_situacao_escolar.dart';
|
||||
import 'package:rkm_educa_app/controllers/main_controllers.dart';
|
||||
import 'package:rkm_educa_app/modelos/estudante_modelo.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_cadastro.dart';
|
||||
import 'package:rkm_educa_app/telas/tela_seleciona_filho.dart';
|
||||
@@ -124,8 +124,11 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
status = 'CARREGANDO ESTUDANTE(S) ...';
|
||||
});
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
_prefService.createCacheLogin(map['CPF'], map['SENHA']).then((value){
|
||||
buscaFilhos(map['NOME'],map['PARENTESCO'],map['CIDADE'],map['CPF'].toString().replaceAll('-', '').replaceAll('.', ''));
|
||||
_prefService.createCacheLogin(map['CPF'], map['SENHA']).then((value)async{
|
||||
int ano = 0;
|
||||
ano = await MainControllers().pegarAno(urlAPI,map['CIDADE']);
|
||||
print(ano);
|
||||
buscaFilhos(map['NOME'],map['PARENTESCO'],map['CIDADE'],map['CPF'].toString().replaceAll('-', '').replaceAll('.', ''),ano);
|
||||
});
|
||||
}else{
|
||||
setState(() {
|
||||
@@ -151,7 +154,7 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
}
|
||||
}
|
||||
|
||||
buscaFilhos(String nome,String parentesco,String cidade, String CPF)async{
|
||||
buscaFilhos(String nome,String parentesco,String cidade, String CPF,int anoLetivo)async{
|
||||
String q = nome.replaceAll(' ', '%20').toUpperCase();
|
||||
final url = '$urlAPI/buscafilhos?NOME=$q&PARENTESCO=${parentesco.replaceAll("Ã", 'A').replaceAll('ã', 'a')}&CIDADE=$cidade';
|
||||
print(url);
|
||||
@@ -188,7 +191,7 @@ class _TelaLoginState extends State<TelaLogin> {
|
||||
RA_ALUNO: listAlunos[0]['NR_RA'],
|
||||
ESCOLA: listAlunos[0]['NO_FANTASIA']=='' || listAlunos[0]['NO_FANTASIA']==null?listAlunos[0]['NO_RAZAO_SOCIAL']:listAlunos[0]['NO_FANTASIA'],
|
||||
IDADE_ALUNO: idade,
|
||||
ANO_LETIVO: DateTime.now().year,
|
||||
ANO_LETIVO: anoLetivo,
|
||||
dados: listAlunos,
|
||||
nroAluno: 0,
|
||||
cidade: cidade,
|
||||
|
||||
Reference in New Issue
Block a user