diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 292bc4c..cf2ef23 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -192,4 +192,66 @@ class Utils { ], ); } + + /// EIT Forms date formats + + static String getMonthNamedFormat(DateTime date) { + /// it will return like "29-Sep-2022" + return DateFormat('dd-MMM-yyyy').format(date); + } + + static String reverseFormatDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('/', '-'); + formattedDate = formattedDate.replaceAll(' 00:00:00', ''); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatStandardDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('-', '/'); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String reverseFormatStandardDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('/', '-'); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatDate(String date) { + String formattedDate; + + if (date.isNotEmpty) { + date = date.substring(0, 10); + formattedDate = date.replaceAll('-', '/'); + formattedDate = formattedDate + ' 00:00:00'; + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatDateNew(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.split('T')[0]; + formattedDate = formattedDate + ' 00:00:00'; + } else { + formattedDate = date; + } + return formattedDate; + } } diff --git a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart index 3619311..81bc671 100644 --- a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart +++ b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart @@ -190,4 +190,6 @@ class GetAbsenceDffStructureList { data['VALIDATION_TYPE_DSP'] = this.vALIDATIONTYPEDSP; return data; } + + bool get isDefaultTypeIsCDPS => (dEFAULTTYPE == "C" || dEFAULTTYPE == "D" || dEFAULTTYPE == "P" || dEFAULTTYPE == "S"); } diff --git a/lib/models/leave_balance/get_absence_transaction_list_model.dart b/lib/models/leave_balance/get_absence_transaction_list_model.dart index ca9777d..74fb733 100644 --- a/lib/models/leave_balance/get_absence_transaction_list_model.dart +++ b/lib/models/leave_balance/get_absence_transaction_list_model.dart @@ -37,8 +37,6 @@ class GetAbsenceTransactionList { this.uPDATEBUTTON}); GetAbsenceTransactionList.fromJson(Map json) { - print("json:$json"); - print("type:ABSENCE_DAYS:${(json['ABSENCE_DAYS']).runtimeType}"); aBSENCEATTENDANCEID = json['ABSENCE_ATTENDANCE_ID']; aBSENCEATTENDANCETYPEID = json['ABSENCE_ATTENDANCE_TYPE_ID']; aBSENCECATEGORY = json['ABSENCE_CATEGORY']; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index ae7b2e2..d87fa88 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -8,6 +8,8 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; @@ -31,12 +33,14 @@ class _AddLeaveBalanceScreenState extends State { List absenceList = []; GetAbsenceAttendanceTypesList? selectedAbsenceType; - DateTime? startTime; - DateTime? endTime; - int totalDays = 0; + DateTime? startDateTime; + DateTime? endDateTime; + int? totalDays; String comment = ""; ReplacementList? selectedReplacementEmployee; + DateTime selectedDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); + @override void initState() { super.initState(); @@ -68,6 +72,21 @@ class _AddLeaveBalanceScreenState extends State { } } + void getCalculatedAbsenceDuration() async { + try { + Utils.showLoading(context); + CalculateAbsenceDuration duration = await LeaveBalanceApiClient() + .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999); + print(duration.toJson()); + totalDays = duration.pABSENCEDAYS; + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + @override void dispose() { super.dispose(); @@ -108,13 +127,13 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.startDateT.tr() + "*", - startTime == null ? "Select date" : startTime.toString(), + startDateTime == null ? "Select date" : startDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { - var start = await _selectDate(context, startTime); - if (start != startTime) { - startTime = start; + var start = await _selectDate(context); + if (start != startDateTime) { + startDateTime = start; setState(() {}); } }, @@ -122,22 +141,26 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.endDateT.tr() + "*", - endTime == null ? "Select date" : endTime.toString(), + endDateTime == null ? "Select date" : endDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, + isReadOnly: selectedAbsenceType == null || startDateTime == null, onTap: () async { - var end = await _selectDate(context, endTime); - if (end != endTime) { - endTime = end; + if (selectedAbsenceType == null || startDateTime == null) return; + var end = await _selectDate(context); + if (end != endDateTime) { + endDateTime = end; setState(() {}); + getCalculatedAbsenceDuration(); } }, ), 12.height, DynamicTextFieldWidget( "Total Days", - "Days", + totalDays?.toString() ?? "Calculated days", isInputTypeNum: true, + isEnable: false, onChange: (input) { totalDays = int.parse(input); }, @@ -171,306 +194,321 @@ class _AddLeaveBalanceScreenState extends State { comment = input; }, ), + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.only(top: 12), + itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getabsenceDffStructureList[parentIndex], parentIndex), + separatorBuilder: (cxt, index) => 0.height, + itemCount: getabsenceDffStructureList.length, + ) ], ).expanded, DefaultButton( LocaleKeys.next.tr(), - (selectedAbsenceType == null || startTime == null || endTime == null) ? null : () {}, + (selectedAbsenceType == null || startDateTime == null || endDateTime == null) ? null : () {}, ).insideContainer ], ), ); } - // Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { - // if (model.dISPLAYFLAG != "N") { - // if (model.vALIDATIONTYPE == "N") { - // if (model.fORMATTYPE == "C") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // onChange: (text) { - // model.eSERVICESDV ??= ESERVICESDV(); - // model.eSERVICESDV!.pIDCOLUMNNAME = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "N") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // isInputTypeNum: true, - // onChange: (text) { - // model.eSERVICESDV ??= ESERVICESDV(); - // model.eSERVICESDV!.pIDCOLUMNNAME = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "X") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // - // if (getabsenceDffStructureList[index].isDefaultTypeIsCDPS) { - // if (displayText.contains(" 00:00:00")) { - // displayText = displayText.replaceAll(" 00:00:00", ""); - // } - // if (displayText.contains("/")) { - // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // // DateTime date1 = DateTime(date.year, date.month, date.day); - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv; - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: formatDate(dateString), - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } else { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "Y") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // displayText = reverseFormatDate(displayText); - // // if (displayText.contains(" 00:00:00")) { - // // displayText = displayText.replaceAll(" 00:00:00", ""); - // // } - // // if (!displayText.contains("-")) { - // // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // String tempDate = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!; - // if (tempDate.contains("00:00:00")) { - // tempDate = tempDate.replaceAll("00:00:00", '').trim(); - // } - // if (tempDate.contains("/")) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); - // } else { - // selectedDate = DateFormat("yyyy-MM-dd").parse(tempDate); - // } - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv; - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: formatDate(dateString), - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } else { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } - // - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } - // } else { - // return PopupMenuButton( - // child: DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", - // isEnable: false, - // isPopup: true, - // isInputTypeNum: true, - // isReadOnly: model.rEADONLY == "Y", - // ).paddingOnly(bottom: 12), - // itemBuilder: (_) => >[ - // if (model.rEADONLY != "Y") - // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), - // ], - // onSelected: (int popipIndex) async { - // ESERVICESDV eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, - // pRETURNMSG: "null", - // pRETURNSTATUS: "null", //getabsenceDffStructureList![popipIndex].dEFAULTVALUE, - // pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }); - // } - // } else { - // return const SizedBox(); - // } - // if (model.fORMATTYPE == "N") { - // if (model.eSERVICESVS?.isNotEmpty ?? false) { - // return PopupMenuButton( - // child: DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", - // isEnable: false, - // isPopup: true, - // isInputTypeNum: true, - // isReadOnly: model.rEADONLY == "Y", - // ).paddingOnly(bottom: 12), - // itemBuilder: (_) => >[ - // if (model.rEADONLY != "Y") - // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!)), - // ], - // onSelected: (int popipIndex) async { - // ESERVICESDV eservicesdv = - // ESERVICESDV(pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, pRETURNMSG: "null", pRETURNSTATUS: "null", pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }); - // } - // - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // onChange: (text) { - // model.fieldAnswer = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // if (displayText.contains(" 00:00:00")) { - // displayText = displayText.replaceAll(" 00:00:00", ""); - // } - // if (!displayText.contains("-")) { - // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "I") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""), - // suffixIconData: Icons.access_time_filled_rounded, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // var timeString = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); - // selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); - // - // //DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // TimeOfDay _time = await _selectTime(context); - // DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); - // String time = DateFormat('HH:mm').format(tempTime).trim(); - // - // // DateTime date1 = DateTime(date.year, date.month, date.day); - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // // await calGetValueSetValues(model); - // // } - // // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // // await getDefaultValues(model); - // // } - // }, - // ).paddingOnly(bottom: 12); - // } - // - // return Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisSize: MainAxisSize.min, - // children: [], - // ).objectContainerView(); - // } + Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { + if (model.dISPLAYFLAG != "N") { + if (model.vALIDATIONTYPE == "N") { + if (model.fORMATTYPE == "C") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + model.eSERVICESDV ??= ESERVICESDV(); + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "N") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + isInputTypeNum: true, + onChange: (text) { + model.eSERVICESDV ??= ESERVICESDV(); + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + + if (getabsenceDffStructureList[index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (displayText.contains("/")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // DateTime date1 = DateTime(date.year, date.month, date.day); + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: Utils.formatDate(dateString), + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + displayText = Utils.reverseFormatDate(displayText); + // if (displayText.contains(" 00:00:00")) { + // displayText = displayText.replaceAll(" 00:00:00", ""); + // } + // if (!displayText.contains("-")) { + // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + // } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + String tempDate = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!; + if (tempDate.contains("00:00:00")) { + tempDate = tempDate.replaceAll("00:00:00", '').trim(); + } + if (tempDate.contains("/")) { + selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); + } else { + selectedDate = DateFormat("yyyy-MM-dd").parse(tempDate); + } + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: Utils.formatDate(dateString), + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } + } else { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + if (model.rEADONLY != "Y") + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), + ], + onSelected: (int popipIndex) async { + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, + pRETURNMSG: "null", + pRETURNSTATUS: "null", //getabsenceDffStructureList![popipIndex].dEFAULTVALUE, + pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }); + } + } else { + return const SizedBox(); + } + if (model.fORMATTYPE == "N") { + if (model.eSERVICESVS?.isNotEmpty ?? false) { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + if (model.rEADONLY != "Y") + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!)), + ], + onSelected: (int popipIndex) async { + ESERVICESDV eservicesdv = + ESERVICESDV(pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, pRETURNMSG: "null", pRETURNSTATUS: "null", pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }); + } + + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + //model.fieldAnswer = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (!displayText.contains("-")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "I") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + suffixIconData: Icons.access_time_filled_rounded, + isEnable: false, + onTap: () async { + if (getabsenceDffStructureList[index].mOBILEENABLED != "Y") return; + + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + var timeString = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); + selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); + + //DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + TimeOfDay _time = await _selectTime(context); + DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); + String time = DateFormat('HH:mm').format(tempTime).trim(); + + // DateTime date1 = DateTime(date.year, date.month, date.day); + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [], + ).objectContainerView(); + } - Future _selectDate(BuildContext context, DateTime? dateInput) async { - DateTime time = dateInput ?? DateTime.now(); + Future _selectDate(BuildContext context) async { + DateTime time = selectedDate; if (Platform.isIOS) { await showCupertinoModalPopup( context: context, @@ -481,22 +519,62 @@ class _AddLeaveBalanceScreenState extends State { backgroundColor: Colors.white, mode: CupertinoDatePickerMode.date, onDateTimeChanged: (value) { - if (value != dateInput) { + if (value != null && value != selectedDate) { time = value; } }, - initialDateTime: dateInput, + initialDateTime: selectedDate, ), ), ); } else { - DateTime? picked = - await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); - if (picked != null && picked != dateInput) { + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != selectedDate) { time = picked; } } time = DateTime(time.year, time.month, time.day); return time; } + + Future _selectTime(BuildContext context) async { + TimeOfDay time = TimeOfDay(hour: selectedDate.hour, minute: selectedDate.minute); + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.time, + use24hFormat: true, + onDateTimeChanged: (value) { + if (value != null && value != selectedDate) { + time = TimeOfDay(hour: value.hour, minute: value.minute); + } + }, + initialDateTime: selectedDate, + ), + ), + ); + } else { + TimeOfDay? picked = await showTimePicker( + context: context, + initialTime: time, + builder: (cxt, child) { + return MediaQuery(data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true), child: child ?? Container()); + }); + + if (picked != null && picked != time) { + time = picked; + } + // final DateTime? picked = + // await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + // if (picked != null && picked != selectedDate) { + // time = picked; + // } + } + return time; + } } diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 72b0567..4f6e527 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -281,7 +281,7 @@ class _DynamicInputScreenState extends State { // idColName = DateFormat('yyyy/MM/dd HH:mm:ss').format(DateTime(date.year, date.month, date.day)); // } - idColName = formatStandardDate(idColName!); + idColName = Utils.formatStandardDate(idColName!); } } else { val = getEitDffStructureList![j].eSERVICESDV?.pVALUECOLUMNNAME; @@ -293,7 +293,7 @@ class _DynamicInputScreenState extends State { idColName = val; if (getEitDffStructureList![j].fORMATTYPE == "X") { - idColName = formatDateNew(idColName!); + idColName = Utils.formatDateNew(idColName!); // commenting to test // DateTime date = DateFormat('yyyy-MM-dd').parse(idColName!); // idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date); @@ -406,7 +406,8 @@ class _DynamicInputScreenState extends State { padding: const EdgeInsets.all(21), itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getEitDffStructureList![parentIndex], parentIndex), separatorBuilder: (cxt, index) => 0.height, - itemCount: getEitDffStructureList!.length))) + itemCount: getEitDffStructureList!.length, + ))) .expanded, // 12.height, DefaultButton( @@ -481,16 +482,18 @@ class _DynamicInputScreenState extends State { ESERVICESDV eservicesdv; if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { eservicesdv = ESERVICESDV( - pIDCOLUMNNAME: formatDate(dateString), + pIDCOLUMNNAME: Utils.formatDate(dateString), pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } else { eservicesdv = ESERVICESDV( pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } getEitDffStructureList![index].eSERVICESDV = eservicesdv; setState(() {}); @@ -505,7 +508,7 @@ class _DynamicInputScreenState extends State { } else if (model.fORMATTYPE == "Y") { String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getEitDffStructureList![index].fieldAnswer ?? ""); if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { - displayText = reverseFormatDate(displayText); + displayText = Utils.reverseFormatDate(displayText); // if (displayText.contains(" 00:00:00")) { // displayText = displayText.replaceAll(" 00:00:00", ""); // } @@ -540,16 +543,18 @@ class _DynamicInputScreenState extends State { ESERVICESDV eservicesdv; if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { eservicesdv = ESERVICESDV( - pIDCOLUMNNAME: formatDate(dateString), + pIDCOLUMNNAME: Utils.formatDate(dateString), pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } else { eservicesdv = ESERVICESDV( pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } getEitDffStructureList![index].eSERVICESDV = eservicesdv; @@ -663,7 +668,7 @@ class _DynamicInputScreenState extends State { pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); getEitDffStructureList![index].eSERVICESDV = eservicesdv; setState(() {}); if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { @@ -736,8 +741,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - DateTime? picked = - await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; } @@ -786,59 +790,4 @@ class _DynamicInputScreenState extends State { } return time; } - - String reverseFormatDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('/', '-'); - formattedDate = formattedDate.replaceAll(' 00:00:00', ''); - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatStandardDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('-', '/'); - } else { - formattedDate = date; - } - return formattedDate; - } - - String reverseFormatStandardDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('/', '-'); - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatDate(String date) { - String formattedDate; - - if (date.isNotEmpty) { - date = date.substring(0, 10); - formattedDate = date.replaceAll('-', '/'); - formattedDate = formattedDate + ' 00:00:00'; - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatDateNew(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.split('T')[0]; - formattedDate = formattedDate + ' 00:00:00'; - } else { - formattedDate = date; - } - return formattedDate; - } }