fix modal in register visit

This commit is contained in:
jantunesmesias 2024-08-09 10:57:05 -03:00
parent bc1c684d72
commit 0f84ee8923
9 changed files with 152 additions and 44 deletions

View File

@ -587,10 +587,8 @@ class NotificationHandler {
ptText: 'Mensagem',
): message['mensagem'],
}),
imageHashMap: Map<String, String>.from({
'key': message['documento'],
'value': 'E',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${message['documento'] ?? ''}&tipo=E',
statusHashMap: [
{
FFLocalizations.of(context).getVariableText(

View File

@ -17,13 +17,13 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
super.key,
required this.labelsHashMap,
required this.statusHashMap,
required this.imageHashMap,
required this.imagePath,
required this.onTapCardItemAction,
});
final Map<String, String>? labelsHashMap;
final List<Map<String, Color>?> statusHashMap;
final Map<String, String> imageHashMap;
final String? imagePath;
final Future Function()? onTapCardItemAction;
@override
@ -241,8 +241,7 @@ class _CardItemTemplateComponentWidgetState
child: CachedNetworkImage(
fadeInDuration: const Duration(milliseconds: 500),
fadeOutDuration: const Duration(milliseconds: 500),
imageUrl:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}',
imageUrl: widget.imagePath ?? '',
fit: BoxFit.cover,
),
),

View File

@ -123,10 +123,8 @@ URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${vi
'Inicio': visitaWrapItem['VAW_DTINICIO'] ?? '',
'Fim': visitaWrapItem['VAW_DTFIM'] ?? '',
}),
imageHashMap: Map<String, String>.from({
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
'value': 'E',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E',
statusHashMap: [
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active)
Map<String, Color>.from({
@ -168,7 +166,7 @@ URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${vi
FFLocalizations.of(context).getVariableText(
ptText: 'Inativo',
enText: 'Inactive',
): FlutterFlowTheme.of(context).error,
): FlutterFlowTheme.of(context).warning,
}),
],
);

View File

@ -16,14 +16,14 @@ class VisitRequestTemplateComponentWidget extends StatefulWidget {
Key? key,
required this.labelsHashMap,
required this.statusHashMap,
required this.imageHashMap,
required this.imagePath,
this.onTapCardItemAction,
required this.buttons,
});
final Map<String, String> labelsHashMap;
final List<Map<String, Color>?> statusHashMap;
final Map<String, String> imageHashMap;
final String? imagePath;
final Future Function()? onTapCardItemAction;
final List<Widget> buttons;
@ -111,8 +111,7 @@ class _VisitRequestTemplateComponentWidgetState
child: CachedNetworkImage(
fadeInDuration: const Duration(milliseconds: 100),
fadeOutDuration: const Duration(milliseconds: 100),
imageUrl:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}',
imageUrl: widget.imagePath ?? '',
fit: BoxFit.cover,
),
),

View File

@ -292,10 +292,8 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
Widget _accessHistoryCardMoleculeWidget(
BuildContext context, dynamic accessHistoryItem) {
return CardItemTemplateComponentWidget(
imageHashMap: Map<String, String>.from({
'key': accessHistoryItem['PES_ID'] ?? '',
'value': accessHistoryItem['PES_TIPO'] ?? '',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${accessHistoryItem['PES_ID'] ?? ''}&tipo=${accessHistoryItem['PES_TIPO'] ?? ''}',
labelsHashMap: Map<String, String>.from({
'Nome:': accessHistoryItem['PES_NOME'] ?? '',
'Acesso:': accessHistoryItem['ACE_DATAHORA'] ?? '',
@ -346,10 +344,3 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
onTapCardItemAction: () async {});
}
}
String imageUrlAtomWidget(String document, String type) {
return valueOrDefault<String>(
"https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=$document&tipo=$type",
"https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg",
);
}

View File

@ -298,10 +298,8 @@ Widget liberationDynamicListView(
Widget liberationHistoryItemCard(
BuildContext context, dynamic liberationHistoryItem) {
return CardItemTemplateComponentWidget(
imageHashMap: Map<String, String>.from({
'key': liberationHistoryItem['VTE_ID'],
'value': 'E',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
labelsHashMap: Map<String, String>.from({
'Nome:': liberationHistoryItem['VTE_NOME'],
'Data:': liberationHistoryItem['NOT_DTENVIO'],
@ -567,10 +565,9 @@ Widget liberationHistoryItemCard(
): FlutterFlowTheme.of(context).warning,
})
],
imageHashMap: Map<String, String>.from({
'key': liberationHistoryItem['VTE_ID'],
'value': 'E',
}),
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
// changeStatusAction: answersRequest,
// vteDocument: liberationHistoryItem['VTE_DOCUMENTO'],
),

View File

@ -30,6 +30,31 @@ class ScheduleCompleteVisitPageModel
/// Local state fields for this page.
String convertDateFormat(String dateStr) {
try {
// Formato original
DateFormat originalFormat = DateFormat('d/M/y H:mm:ss');
// Novo formato
DateFormat newFormat = DateFormat('y-M-d H:mm:ss');
// Validate the input string format
if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$')
.hasMatch(dateStr)) {
return 'Invalid date format';
}
// Converte a string para DateTime
DateTime dateTime = originalFormat.parse(dateStr);
// Converte DateTime para a nova string formatada
String formattedDate = newFormat.format(dateTime);
return formattedDate;
} catch (e) {
// Handle the exception by returning an error message or a default value
return 'Invalid date format';
}
}
List<dynamic> visitorJsonList = [];
void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item);
void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item);

View File

@ -24,6 +24,7 @@ import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:provider/provider.dart';
class ScheduleCompleteVisitPageWidget extends StatefulWidget {
@ -1568,6 +1569,8 @@ Widget scheduleVisit(
),
onPressed: _model.isValid()
? () async {
log(_model.dropDownValue1.toString());
await showDialog(
context: context,
builder: (context) {
@ -1595,10 +1598,110 @@ Widget scheduleVisit(
// repeatVisitSchedule: () async {},
// ),
child: VisitRequestTemplateComponentWidget(
buttons: [],
imageHashMap: {},
labelsHashMap: {},
statusHashMap: [],
buttons: [
FlutterFlowIconButton(
icon: const Icon(Icons.done),
onPressed: () async {
showAlertDialog(
context,
FFLocalizations.of(context)
.getVariableText(
ptText: 'Ativar Visita',
enText: 'Activate Visit',
),
FFLocalizations.of(context)
.getVariableText(
ptText:
'Você tem certeza que deseja ativar essa visita?',
enText:
'Are you sure you want to activate this visit?',
), () async {
await PhpGroup.postScheduleVisitCall
.call(
devUUID: FFAppState().devUUID,
userUUID: FFAppState().userUUID,
atividade: 'putVisita',
devDesc: _model.textController3.text,
idVisitante: _model.visitorStrList,
dtInicio: _model.convertDateFormat(
_model.textController1.text ?? ''),
dtFim: _model.convertDateFormat(
_model.textController2.text ?? ''),
unica: _model.switchValue == true
? 'Sim'
: 'Não',
idMotivo: extractIdToStr(
_model.dropDownValue1!),
idNAC: extractIdToStr(
_model.dropDownValue2!),
obs: _model.textController3.text,
cliID: FFAppState().cliUUID,
)
.catchError((e) async {
await DialogUtil.errorDefault(context);
}).then((value) async {
if (PhpGroup.postScheduleVisitCall
.error(
(value.jsonBody ?? ''),
) ==
false) {
Navigator.pop(context);
Navigator.pop(context);
showSnackbar(
context,
FFLocalizations.of(context)
.getVariableText(
enText:
'Success in scheduling visit',
ptText:
'Succeso ao agendar a visita',
),
false,
);
} else {
await DialogUtil.errorDefault(
context);
Navigator.pop(context);
Navigator.pop(context);
}
});
setState(() {});
});
},
),
],
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${_model.visitorJsonList[0]['VTE_DOCUMENTO'] ?? ''}&tipo=E',
labelsHashMap: {
'Nome': _model.visitorJsonList[0]['VTE_NOME'],
'Start': _model.textController1.text,
'End': _model.textController2.text ?? '',
'Reason': (RegExp(r'MOT_DESCRICAO:\s*([^,]+)')
.firstMatch(
_model.dropDownValue1.toString())
?.group(1)
.toString()) ??
'',
'Level': (RegExp(r'NAC_DESCRICAO:\s*([^,]+)')
.firstMatch(
_model.dropDownValue2.toString())
?.group(1)
.toString()) ??
'',
'Single Visit':
_model.switchValue == true ? 'Sim' : 'Não',
if (_model.textController3.text.isNotEmpty)
'Observation': _model.textController3.text,
},
statusHashMap: [
Map<String, Color>.from({
FFLocalizations.of(context).getVariableText(
ptText: 'Inativo',
enText: 'Inactive',
): FlutterFlowTheme.of(context).warning,
}),
],
onTapCardItemAction: () async {},
),
),

View File

@ -93,10 +93,8 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
itemBuilder: (context, index) {
final visitaWrapItem = visitaWrap[index];
return CardItemTemplateComponentWidget(
imageHashMap: {
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
'value': 'E',
},
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E',
labelsHashMap: {
'Nome:': visitaWrapItem['VTE_NOME'] ?? '',
'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '',