380 lines
16 KiB
Dart
380 lines
16 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:rkm/config/const_variable.dart';
|
|
import 'package:rkm/widgets/appbar_default.dart';
|
|
import 'package:rkm/widgets/onbackbutton.dart';
|
|
import 'package:rkm/widgets/text_default.dart';
|
|
import 'package:sqflite/sqflite.dart';
|
|
import '../config/color_palette.dart';
|
|
import '../service/db/db_querys.dart';
|
|
import '../service/db/db_sqlite_load.dart';
|
|
import '../service/shared_preferences/shared_preferences_service.dart';
|
|
import '../widgets/button_default.dart';
|
|
import '../widgets/dropdown_button_default.dart';
|
|
import '../widgets/title_containers.dart';
|
|
|
|
class EditProceduresScreen extends StatefulWidget {
|
|
String username;
|
|
|
|
EditProceduresScreen({required this.username});
|
|
|
|
@override
|
|
State<EditProceduresScreen> createState() => _EditProceduresScreenState();
|
|
}
|
|
|
|
class _EditProceduresScreenState extends State<EditProceduresScreen> {
|
|
|
|
var controllerProfessional = TextEditingController();
|
|
var controllerUnit = TextEditingController();
|
|
var NOME_PROFISSIONAL = TextEditingController();
|
|
var NOME_UNIDADE = TextEditingController();
|
|
List listCBO = [];
|
|
List listINEPROF = [];
|
|
String? selectCBO;
|
|
String? INE_RESP_CADASTRO;
|
|
String? date;
|
|
int idUsuario = 0;
|
|
String idUnidade = '';
|
|
|
|
escolherprazoInicio(BuildContext context) async {
|
|
var pickDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(2022),
|
|
lastDate: DateTime(2025));
|
|
if (pickDate != null) {
|
|
setState(() {
|
|
date=null;
|
|
date = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day);
|
|
});
|
|
}
|
|
}
|
|
|
|
String formatData({int? year, int? month, int? day}) {
|
|
DateTime data = DateTime(year!, month!, day!);
|
|
String formattedDate = DateFormat('dd/MM/yyyy').format(data);
|
|
return formattedDate;
|
|
}
|
|
|
|
|
|
getUser()async{
|
|
final PrefService _prefService = PrefService();
|
|
_prefService.readCacheIDUser().then((value){
|
|
if(value != null){
|
|
idUsuario = int.parse(value);
|
|
}
|
|
}).then((value)async{
|
|
await DBQuerys().buscaProfissionalCadInd(idUsuario).then((list){
|
|
// ID_PROFISSIONAL = list['ID_PROFISSIONAL'];
|
|
NOME_PROFISSIONAL.text = list['NOME_PROFISSIONAL'];
|
|
// String CNS_PROFISSIONAL = list['CNS_PROFISSIONAL'];
|
|
// if(CNS_PROFISSIONAL == 999999999999999 || CNS_PROFISSIONAL == '999999999999999'){
|
|
// CNS_VALIDO = true;
|
|
// }
|
|
loadCBO();
|
|
});
|
|
});
|
|
_prefService.readCacheUnidade().then((value){
|
|
if(value!=null){
|
|
idUnidade = value[0];
|
|
NOME_UNIDADE.text = value[1];
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
loadCBO()async{
|
|
Database dbcbo = await DbSqliteLoad().intialDB();
|
|
var query = 'SELECT * FROM PROFISSIONAIS_CBOS WHERE ID_PROFISSIONAL = $idUsuario';
|
|
List listcbo = await dbcbo.rawQuery(query);
|
|
|
|
if(listcbo.length!=0){
|
|
for(int i = 0; listcbo.length>i;i++){
|
|
await DBQuerys().buscaCBOSProfissional(listcbo[i]['CODIGO_CBO']).then((cbo)async{
|
|
if(cbo.length!=0){
|
|
listCBO.add(cbo[0]['DESCRICAO_CBO']+' - '+listcbo[i]['CODIGO_CBO'].toString());
|
|
}
|
|
});
|
|
}
|
|
}
|
|
loadEquipe();
|
|
}
|
|
|
|
loadEquipe()async{
|
|
List list = await DBQuerys().buscaDadosProfissional(idUnidade,idUsuario);
|
|
for(int i=0; list.length > i;i++){
|
|
INE_RESP_CADASTRO = 'INE: ${list[i]['INE']} / Área: ${list[i]['AREA']} - Microárea : ${list[i]['MICROAREA']}';
|
|
listINEPROF.add('INE: ${list[i]['INE']} / Área: ${list[i]['AREA']} - Microárea : ${list[i]['MICROAREA']}');
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getUser();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
double width = MediaQuery.of(context).size.width;
|
|
double height = MediaQuery.of(context).size.height;
|
|
|
|
return WillPopScope(
|
|
onWillPop: ()async => await OnBackButton().onBackButton(context, widget.username),
|
|
child: Scaffold(
|
|
appBar: AppBarDefault().appbar(context, 'RKM AB - Procedimentos Consolidados',widget.username),
|
|
body: Container(
|
|
decoration: ConstVariable().backgroundGradient,
|
|
width: width,
|
|
height: height,
|
|
padding: EdgeInsets.all(10),
|
|
child: ListView(
|
|
children: [
|
|
Card(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
TitleContainers(title: 'Procedimentos',),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.center,
|
|
height: height*0.32,
|
|
width: width*0.2,
|
|
child: Icon(Icons.info_outlined,size: 100,color: ColorPalette.black54,)
|
|
),
|
|
Container(
|
|
height: height*0.32,
|
|
width: width*0.75,
|
|
child: ListView.separated(
|
|
itemCount: ConstVariable().listProcedures.length,
|
|
separatorBuilder: (context,index)=>Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
itemBuilder: (context,index){
|
|
return Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: ConstVariable().listProcedures[index],
|
|
color: ColorPalette.black54,
|
|
fontSize: 18
|
|
),
|
|
);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Card(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
TitleContainers(title: 'Outros',),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.center,
|
|
height: height*0.24,
|
|
width: width*0.2,
|
|
child: Icon(Icons.tag,size: 100,color: ColorPalette.black54,)
|
|
),
|
|
Container(
|
|
height: height*0.25,
|
|
width: width*0.75,
|
|
child: ListView(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Profissional',
|
|
color: ColorPalette.black54,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 5,vertical: 10),
|
|
padding: EdgeInsets.all(5),
|
|
width: width*0.5,
|
|
color: ColorPalette.titleContainer,
|
|
child: TextDefault(text: NOME_PROFISSIONAL.text,color: ColorPalette.black54,fontSize: 15,),
|
|
)
|
|
],
|
|
),
|
|
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Unidade',
|
|
color: ColorPalette.black54,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 5),
|
|
padding: EdgeInsets.all(5),
|
|
width: width*0.5,
|
|
color: ColorPalette.titleContainer,
|
|
child: TextDefault(
|
|
text: NOME_UNIDADE.text,
|
|
color: ColorPalette.black54,
|
|
fontSize: 15,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'CBO',
|
|
color: ColorPalette.black54,
|
|
fontWeigth: FontWeight.bold,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 0),
|
|
padding: EdgeInsets.all(0),
|
|
child: DropDownButtonDefault(
|
|
title: '',
|
|
fontSize: 15,
|
|
width: width*0.4,
|
|
widthContainer: width*0.3,
|
|
select: selectCBO,
|
|
list: listCBO,
|
|
onChanged: (value){
|
|
setState(() {
|
|
selectCBO = value!;
|
|
});
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Código Equipe',
|
|
color: ColorPalette.black54,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 0),
|
|
padding: EdgeInsets.all(0),
|
|
child: DropDownButtonDefault(
|
|
title: '',
|
|
fontSize: 15,
|
|
width: width*0.5,
|
|
widthContainer: width*0.4,
|
|
select: INE_RESP_CADASTRO,
|
|
list: listINEPROF,
|
|
onChanged: (value){
|
|
setState(() {
|
|
INE_RESP_CADASTRO = value!;
|
|
});
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
date!=null
|
|
?GestureDetector(
|
|
onTap: ()=>escolherprazoInicio(context),
|
|
child: Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Data',
|
|
color: ColorPalette.black54,
|
|
fontWeigth: FontWeight.bold,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 5),
|
|
padding: EdgeInsets.all(5),
|
|
width: width*0.5,
|
|
child: TextDefault(
|
|
text: date!,
|
|
color: ColorPalette.black54,
|
|
fontSize: 15,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
):GestureDetector(
|
|
onTap: ()=>escolherprazoInicio(context),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Data',
|
|
color: ColorPalette.black54,
|
|
fontWeigth: FontWeight.bold,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
),
|
|
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,),
|
|
]
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
ButtonDefault(
|
|
onPressed: (){},
|
|
title: 'Salvar',
|
|
borderColor: ColorPalette.appBar,
|
|
background: ColorPalette.appBar,
|
|
textColor: ColorPalette.white,
|
|
width: width,
|
|
),
|
|
ButtonDefault(
|
|
onPressed: ()=>Navigator.pop(context),
|
|
title: 'Cancelar',
|
|
background: ColorPalette.blackButton,
|
|
borderColor: ColorPalette.blackButton,
|
|
textColor: ColorPalette.white,
|
|
width: width,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|