From 2c2d16674ef8e07bb06b1655dec8e0c2f1cfd7a7 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Tue, 21 Apr 2026 15:27:19 +0300 Subject: [PATCH] calendar issue fixed and courses enabled. --- lib/provider/dashboard_provider_model.dart | 2 +- .../attendance/monthly_attendance_screen.dart | 39 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index e0224c0..965fe52 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -138,7 +138,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { DrawerMenuItem("assets/images/drawer/mowadhafi.svg", LocaleKeys.keen.tr(), AppRoutes.etqanOvr), // DrawerMenuItem("assets/images/drawer/car_parking_icon.svg", LocaleKeys.parkingQr.tr(), AppRoutes.parkingQr), DrawerMenuItem("assets/images/drawer/pending_trasactions.svg", LocaleKeys.pendingTransactions.tr(), AppRoutes.pendingTransactions), - // DrawerMenuItem("assets/images/drawer/courses.svg", "courses".tr(), AppRoutes.courses), + DrawerMenuItem("assets/images/drawer/courses.svg", "courses".tr(), AppRoutes.courses), // DrawerMenuItem("assets/images/drawer/drawer_marathon.svg", LocaleKeys.brainMarathon.tr(), AppRoutes.marathonIntroScreen), DrawerMenuItem("assets/images/drawer/change_password.svg", LocaleKeys.changePassword.tr(), AppRoutes.changePassword), ]; diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index 5fbd585..5e33708 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -301,7 +301,6 @@ class _MonthlyAttendanceScreenState extends State { monthCellBuilder: (build, details) { if (details.date.month == formattedDate.month && details.date.year == formattedDate.year) { int val = details.date.day; - int index = val-1; //check day is off // if (getDayHoursTypeDetailsList.isNotEmpty) { // bool isDayIsOff = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].dAYTYPE == 'OFF'; @@ -311,12 +310,13 @@ class _MonthlyAttendanceScreenState extends State { getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date.day).toList(); if (getDayHours.isNotEmpty) { - bool isDayIsOff = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[index].dAYTYPE == 'OFF'; - bool isDayIsPresent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'Y'; - bool isDayIsAbsent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[index].aBSENTFLAG == 'Y'; + GetDayHoursTypeDetailsList dayData = getDayHours.first; + bool isDayIsOff = dayData.aTTENDEDFLAG == 'N' && dayData.dAYTYPE == 'OFF'; + bool isDayIsPresent = dayData.aTTENDEDFLAG == 'Y'; + bool isDayIsAbsent = dayData.aTTENDEDFLAG == 'N' && dayData.aBSENTFLAG == 'Y'; // Get leave type code and corresponding color - String? leaveTypeCode = getDayHoursTypeDetailsList[index].lEAVETYPECODE; + String? leaveTypeCode = dayData.lEAVETYPECODE; Color? leaveTypeColor; bool useGradient = false; @@ -428,12 +428,18 @@ class _MonthlyAttendanceScreenState extends State { } void calendarTapped(CalendarTapDetails details) async { - dynamic index = details.date?.day; - if (index != null) { - index = index - 1; - } - pRTPID = getDayHoursTypeDetailsList[index].rTPID; - await getScheduleShiftsDetails(index, pRTPID); + if (details.date == null) return; + + // Filter to find the matching day data + List getDayHours = + getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => + DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date!.day).toList(); + + if (getDayHours.isEmpty) return; + + GetDayHoursTypeDetailsList dayData = getDayHours.first; + pRTPID = dayData.rTPID; + await getScheduleShiftsDetails(details.date!.day, pRTPID); dynamic value = getScheduleShiftsDetailsList!.pERCENTAGE; dynamic percentage; if (value!.indexOf('%') == 3) { @@ -446,8 +452,7 @@ class _MonthlyAttendanceScreenState extends State { percentage = 0; } if (details.date!.month == formattedDate.month && details.date!.year == formattedDate.year) { - int val = details.date!.day; - getDayHoursTypeDetailsList?[val - 1].aTTENDEDFLAG == 'Y' + dayData.aTTENDEDFLAG == 'Y' ? showModalBottomSheet( context: context, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)), @@ -592,7 +597,7 @@ class _MonthlyAttendanceScreenState extends State { LocaleKeys.lateIn.tr().toText11( color: MyColors.grey67Color, ), - "${getDayHoursTypeDetailsList[index].lATEINHRS}".toText22(color: MyColors.redColor, isBold: true), + "${dayData.lATEINHRS}".toText22(color: MyColors.redColor, isBold: true), ], ).expanded, Column( @@ -601,7 +606,7 @@ class _MonthlyAttendanceScreenState extends State { LocaleKeys.excess.tr().toText11( color: MyColors.grey67Color, ), - "${getDayHoursTypeDetailsList[index].eXCESSHRS}".toText22(color: MyColors.backgroundBlackColor, isBold: true), + "${dayData.eXCESSHRS}".toText22(color: MyColors.backgroundBlackColor, isBold: true), ], ).expanded, ], @@ -621,7 +626,7 @@ class _MonthlyAttendanceScreenState extends State { LocaleKeys.shortage.tr().toText11( color: MyColors.grey67Color, ), - "${getDayHoursTypeDetailsList[index].sHORTAGEHRS}".toText22(color: MyColors.backgroundBlackColor, isBold: true), + "${dayData.sHORTAGEHRS}".toText22(color: MyColors.backgroundBlackColor, isBold: true), ], ).expanded, Column( @@ -630,7 +635,7 @@ class _MonthlyAttendanceScreenState extends State { LocaleKeys.earlyOut.tr().toText11( color: MyColors.grey67Color, ), - "${getDayHoursTypeDetailsList[index].eARLYOUTHRS}".toText22(color: Colors.black, isBold: true), + "${dayData.eARLYOUTHRS}".toText22(color: Colors.black, isBold: true), ], ).expanded, ],