From a6454776ddaf51474076d26783c9065f8b69fb45 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Thu, 23 Apr 2026 15:59:13 +0300 Subject: [PATCH] fixes for monthly calendar color coding .. and ticket screen --- .../attendance/monthly_attendance_screen.dart | 59 +++++++++++++++++-- .../ticket/ticket_detailed_screen.dart | 48 +++++++-------- 2 files changed, 78 insertions(+), 29 deletions(-) diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index 5e33708..7b5776e 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -57,6 +57,15 @@ class _MonthlyAttendanceScreenState extends State { Utils.showLoading(context); getTimeCardSummaryList = await MonthlyAttendanceApiClient().getTimeCardSummary(searchMonth, searchYear); getDayHoursTypeDetailsList = await MonthlyAttendanceApiClient().getDayHoursTypeDetails(searchMonth, searchYear); + + // Debug logging to check the data + print('Total days received: ${getDayHoursTypeDetailsList.length}'); + for (var day in getDayHoursTypeDetailsList) { + if (day.lEAVETYPECODE != null && day.lEAVETYPECODE!.isNotEmpty) { + print('Date: ${day.sCHEDULEDATE}, LEAVE_TYPE_CODE: ${day.lEAVETYPECODE}'); + } + } + Utils.hideLoading(context); _calendarController.displayDate = formattedDate; setState(() {}); @@ -307,10 +316,19 @@ class _MonthlyAttendanceScreenState extends State { // bool isDayIsPresent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'Y'; // bool isDayIsAbsent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].aBSENTFLAG == 'Y'; List getDayHours = - getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date.day).toList(); + getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) { + DateTime scheduleDate = DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!); + return scheduleDate.day == details.date.day && + scheduleDate.month == details.date.month && + scheduleDate.year == details.date.year; + }).toList(); if (getDayHours.isNotEmpty) { GetDayHoursTypeDetailsList dayData = getDayHours.first; + + // Debug logging + print('Day: ${details.date.day}, LEAVE_TYPE_CODE: ${dayData.lEAVETYPECODE}, ATTENDED_FLAG: ${dayData.aTTENDEDFLAG}, DAY_TYPE: ${dayData.dAYTYPE}'); + bool isDayIsOff = dayData.aTTENDEDFLAG == 'N' && dayData.dAYTYPE == 'OFF'; bool isDayIsPresent = dayData.aTTENDEDFLAG == 'Y'; bool isDayIsAbsent = dayData.aTTENDEDFLAG == 'N' && dayData.aBSENTFLAG == 'Y'; @@ -321,8 +339,9 @@ class _MonthlyAttendanceScreenState extends State { bool useGradient = false; // Determine color based on leave type code - if (leaveTypeCode != null && leaveTypeCode.isNotEmpty) { + if (leaveTypeCode != null && leaveTypeCode.isNotEmpty && leaveTypeCode.trim().isNotEmpty) { leaveTypeColor = leaveTypeColors[leaveTypeCode]; + print('Matched color for $leaveTypeCode: $leaveTypeColor'); } // If no leave type color found, use default colors based on attendance status @@ -396,6 +415,28 @@ class _MonthlyAttendanceScreenState extends State { ), ); } + // Handle days with leave type codes (HOLIDAY, WFH, etc.) that are not present/absent/off + else if (leaveTypeColor != null) { + return Container( + margin: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: leaveTypeColor, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + offset: const Offset(0, 2), + blurRadius: 26, + color: MyColors.blackColor.withOpacity(0.100), + ), + ], + ), + alignment: Alignment.center, + child: Text( + "$val", + style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: MyColors.white), + ), + ); + } } return Container( margin: const EdgeInsets.all(4), @@ -430,14 +471,22 @@ class _MonthlyAttendanceScreenState extends State { void calendarTapped(CalendarTapDetails details) async { if (details.date == null) return; - // Filter to find the matching day data + // Filter to find the matching day data with full date comparison List getDayHours = - getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => - DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date!.day).toList(); + getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) { + DateTime scheduleDate = DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!); + return scheduleDate.day == details.date!.day && + scheduleDate.month == details.date!.month && + scheduleDate.year == details.date!.year; + }).toList(); if (getDayHours.isEmpty) return; GetDayHoursTypeDetailsList dayData = getDayHours.first; + + // Debug logging + print('Tapped Day: ${details.date!.day}, LEAVE_TYPE_CODE: ${dayData.lEAVETYPECODE}'); + pRTPID = dayData.rTPID; await getScheduleShiftsDetails(details.date!.day, pRTPID); dynamic value = getScheduleShiftsDetailsList!.pERCENTAGE; diff --git a/lib/ui/screens/ticket/ticket_detailed_screen.dart b/lib/ui/screens/ticket/ticket_detailed_screen.dart index 7959f39..5a412cf 100644 --- a/lib/ui/screens/ticket/ticket_detailed_screen.dart +++ b/lib/ui/screens/ticket/ticket_detailed_screen.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -61,23 +60,24 @@ class _TicketDetailedScreenState extends State { appBar: AppBarWidget(context, title:LocaleKeys.ticketDetails.tr()), body: Column( children: [ - ListView( - padding: const EdgeInsets.all(21), - physics: const BouncingScrollPhysics(), - children: [ - if (dashboardProviderModel == null && dashboardProviderModel?.accrualTicketBalanceList == null) ...[Utils.getNoDataWidget(context).paddingOnly(top: 50)] else ...[ - Container( - padding: const EdgeInsets.all(16.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.0), - boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3))], - ), - child: Column( - children: [ - Row( - children: [ - LocaleKeys.currentTicketBalance.tr().toText20().expanded, + Expanded( + child: ListView( + padding: const EdgeInsets.all(21), + physics: const BouncingScrollPhysics(), + children: [ + if (dashboardProviderModel == null && dashboardProviderModel?.accrualTicketBalanceList == null) ...[Utils.getNoDataWidget(context).paddingOnly(top: 50)] else ...[ + Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.0), + boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3))], + ), + child: Column( + children: [ + Row( + children: [ + Expanded(child: LocaleKeys.currentTicketBalance.tr().toText20()), Row( children: [ const Icon(Icons.calendar_month_rounded, color: MyColors.darkIconColor, size: 16), @@ -116,11 +116,10 @@ class _TicketDetailedScreenState extends State { ), const SizedBox(height: 21), (dashboardProviderModel != null && dashboardProviderModel!.ticketHistoryTransactionList != null && dashboardProviderModel!.ticketHistoryTransactionList!.isNotEmpty) - ? ListView( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.ticketHistory.tr().toText20().expanded, + LocaleKeys.ticketHistory.tr().toText20(), 12.height, ListView.separated( physics: const NeverScrollableScrollPhysics(), @@ -220,9 +219,10 @@ class _TicketDetailedScreenState extends State { ], ) : const SizedBox(), + ], ], - ], - ).expanded, + ), + ), DefaultButton(LocaleKeys.proceedBooking.tr(), () { if (widget.url != null && widget.jwtToken != null) { Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => SsoLoginWebView(url: widget.url, jwtToken: widget.jwtToken)));