diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart index 98f023ec..09751698 100644 --- a/lib/backend/push_notification/pushNotificationService.dart +++ b/lib/backend/push_notification/pushNotificationService.dart @@ -587,10 +587,8 @@ class NotificationHandler { ptText: 'Mensagem', ): message['mensagem'], }), - imageHashMap: Map.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( diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart index 1b503c1e..59311bc9 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart @@ -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? labelsHashMap; final List?> statusHashMap; - final Map 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, ), ), diff --git a/lib/components/templates_components/details_component/details_component_action.dart b/lib/components/templates_components/details_component/details_component_action.dart index a1250742..eaec3e3d 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -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.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.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, }), ], ); diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart index 4dc13176..ec11007b 100644 --- a/lib/components/templates_components/details_component/details_component_widget.dart +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -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 labelsHashMap; final List?> statusHashMap; - final Map imageHashMap; + final String? imagePath; final Future Function()? onTapCardItemAction; final List 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, ), ), diff --git a/lib/pages/acess_history_page/acess_history_page_widget.dart b/lib/pages/acess_history_page/acess_history_page_widget.dart index 48a4ae87..466d031e 100644 --- a/lib/pages/acess_history_page/acess_history_page_widget.dart +++ b/lib/pages/acess_history_page/acess_history_page_widget.dart @@ -292,10 +292,8 @@ class _AcessHistoryPageWidgetState extends State { Widget _accessHistoryCardMoleculeWidget( BuildContext context, dynamic accessHistoryItem) { return CardItemTemplateComponentWidget( - imageHashMap: Map.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.from({ 'Nome:': accessHistoryItem['PES_NOME'] ?? '', 'Acesso:': accessHistoryItem['ACE_DATAHORA'] ?? '', @@ -346,10 +344,3 @@ class _AcessHistoryPageWidgetState extends State { onTapCardItemAction: () async {}); } } - -String imageUrlAtomWidget(String document, String type) { - return valueOrDefault( - "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", - ); -} diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 72c0dcf2..9ad1dfcf 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -298,10 +298,8 @@ Widget liberationDynamicListView( Widget liberationHistoryItemCard( BuildContext context, dynamic liberationHistoryItem) { return CardItemTemplateComponentWidget( - imageHashMap: Map.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.from({ 'Nome:': liberationHistoryItem['VTE_NOME'], 'Data:': liberationHistoryItem['NOT_DTENVIO'], @@ -567,10 +565,9 @@ Widget liberationHistoryItemCard( ): FlutterFlowTheme.of(context).warning, }) ], - imageHashMap: Map.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'], ), diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart index 27af1e4c..aa896f5d 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart @@ -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 visitorJsonList = []; void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item); void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item); diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index 61e1a120..438bffa5 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -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.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Inativo', + enText: 'Inactive', + ): FlutterFlowTheme.of(context).warning, + }), + ], onTapCardItemAction: () async {}, ), ), diff --git a/lib/pages/visit_history_page/visit_history_page_widget.dart b/lib/pages/visit_history_page/visit_history_page_widget.dart index 46081da0..cfc9670c 100644 --- a/lib/pages/visit_history_page/visit_history_page_widget.dart +++ b/lib/pages/visit_history_page/visit_history_page_widget.dart @@ -93,10 +93,8 @@ class _VisitHistoryWidgetState extends State { 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'] ?? '',