fixes for monthly calendar color coding .. and ticket screen

master
Sultan khan 5 months ago
parent 4a09bbdf1b
commit a6454776dd

@ -57,6 +57,15 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
Utils.showLoading(context); Utils.showLoading(context);
getTimeCardSummaryList = await MonthlyAttendanceApiClient().getTimeCardSummary(searchMonth, searchYear); getTimeCardSummaryList = await MonthlyAttendanceApiClient().getTimeCardSummary(searchMonth, searchYear);
getDayHoursTypeDetailsList = await MonthlyAttendanceApiClient().getDayHoursTypeDetails(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); Utils.hideLoading(context);
_calendarController.displayDate = formattedDate; _calendarController.displayDate = formattedDate;
setState(() {}); setState(() {});
@ -307,10 +316,19 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
// bool isDayIsPresent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'Y'; // bool isDayIsPresent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'Y';
// bool isDayIsAbsent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].aBSENTFLAG == 'Y'; // bool isDayIsAbsent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].aBSENTFLAG == 'Y';
List<GetDayHoursTypeDetailsList> getDayHours = List<GetDayHoursTypeDetailsList> 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) { if (getDayHours.isNotEmpty) {
GetDayHoursTypeDetailsList dayData = getDayHours.first; 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 isDayIsOff = dayData.aTTENDEDFLAG == 'N' && dayData.dAYTYPE == 'OFF';
bool isDayIsPresent = dayData.aTTENDEDFLAG == 'Y'; bool isDayIsPresent = dayData.aTTENDEDFLAG == 'Y';
bool isDayIsAbsent = dayData.aTTENDEDFLAG == 'N' && dayData.aBSENTFLAG == 'Y'; bool isDayIsAbsent = dayData.aTTENDEDFLAG == 'N' && dayData.aBSENTFLAG == 'Y';
@ -321,8 +339,9 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
bool useGradient = false; bool useGradient = false;
// Determine color based on leave type code // Determine color based on leave type code
if (leaveTypeCode != null && leaveTypeCode.isNotEmpty) { if (leaveTypeCode != null && leaveTypeCode.isNotEmpty && leaveTypeCode.trim().isNotEmpty) {
leaveTypeColor = leaveTypeColors[leaveTypeCode]; leaveTypeColor = leaveTypeColors[leaveTypeCode];
print('Matched color for $leaveTypeCode: $leaveTypeColor');
} }
// If no leave type color found, use default colors based on attendance status // If no leave type color found, use default colors based on attendance status
@ -396,6 +415,28 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
), ),
); );
} }
// 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( return Container(
margin: const EdgeInsets.all(4), margin: const EdgeInsets.all(4),
@ -430,14 +471,22 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
void calendarTapped(CalendarTapDetails details) async { void calendarTapped(CalendarTapDetails details) async {
if (details.date == null) return; if (details.date == null) return;
// Filter to find the matching day data // Filter to find the matching day data with full date comparison
List<GetDayHoursTypeDetailsList> getDayHours = List<GetDayHoursTypeDetailsList> getDayHours =
getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) {
DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date!.day).toList(); 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; if (getDayHours.isEmpty) return;
GetDayHoursTypeDetailsList dayData = getDayHours.first; GetDayHoursTypeDetailsList dayData = getDayHours.first;
// Debug logging
print('Tapped Day: ${details.date!.day}, LEAVE_TYPE_CODE: ${dayData.lEAVETYPECODE}');
pRTPID = dayData.rTPID; pRTPID = dayData.rTPID;
await getScheduleShiftsDetails(details.date!.day, pRTPID); await getScheduleShiftsDetails(details.date!.day, pRTPID);
dynamic value = getScheduleShiftsDetailsList!.pERCENTAGE; dynamic value = getScheduleShiftsDetailsList!.pERCENTAGE;

@ -1,4 +1,3 @@
import 'dart:convert';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -61,23 +60,24 @@ class _TicketDetailedScreenState extends State<TicketDetailedScreen> {
appBar: AppBarWidget(context, title:LocaleKeys.ticketDetails.tr()), appBar: AppBarWidget(context, title:LocaleKeys.ticketDetails.tr()),
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
ListView( Expanded(
padding: const EdgeInsets.all(21), child: ListView(
physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(21),
children: <Widget>[ physics: const BouncingScrollPhysics(),
if (dashboardProviderModel == null && dashboardProviderModel?.accrualTicketBalanceList == null) ...<Widget>[Utils.getNoDataWidget(context).paddingOnly(top: 50)] else ...<Widget>[ children: <Widget>[
Container( if (dashboardProviderModel == null && dashboardProviderModel?.accrualTicketBalanceList == null) ...<Widget>[Utils.getNoDataWidget(context).paddingOnly(top: 50)] else ...<Widget>[
padding: const EdgeInsets.all(16.0), Container(
decoration: BoxDecoration( padding: const EdgeInsets.all(16.0),
color: Colors.white, decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0), color: Colors.white,
boxShadow: <BoxShadow>[BoxShadow(color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3))], borderRadius: BorderRadius.circular(12.0),
), boxShadow: <BoxShadow>[BoxShadow(color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3))],
child: Column( ),
children: <Widget>[ child: Column(
Row( children: <Widget>[
children: <Widget>[ Row(
LocaleKeys.currentTicketBalance.tr().toText20().expanded, children: <Widget>[
Expanded(child: LocaleKeys.currentTicketBalance.tr().toText20()),
Row( Row(
children: <Widget>[ children: <Widget>[
const Icon(Icons.calendar_month_rounded, color: MyColors.darkIconColor, size: 16), const Icon(Icons.calendar_month_rounded, color: MyColors.darkIconColor, size: 16),
@ -116,11 +116,10 @@ class _TicketDetailedScreenState extends State<TicketDetailedScreen> {
), ),
const SizedBox(height: 21), const SizedBox(height: 21),
(dashboardProviderModel != null && dashboardProviderModel!.ticketHistoryTransactionList != null && dashboardProviderModel!.ticketHistoryTransactionList!.isNotEmpty) (dashboardProviderModel != null && dashboardProviderModel!.ticketHistoryTransactionList != null && dashboardProviderModel!.ticketHistoryTransactionList!.isNotEmpty)
? ListView( ? Column(
shrinkWrap: true, crossAxisAlignment: CrossAxisAlignment.start,
physics: const NeverScrollableScrollPhysics(),
children: <Widget>[ children: <Widget>[
LocaleKeys.ticketHistory.tr().toText20().expanded, LocaleKeys.ticketHistory.tr().toText20(),
12.height, 12.height,
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
@ -220,9 +219,10 @@ class _TicketDetailedScreenState extends State<TicketDetailedScreen> {
], ],
) )
: const SizedBox(), : const SizedBox(),
],
], ],
], ),
).expanded, ),
DefaultButton(LocaleKeys.proceedBooking.tr(), () { DefaultButton(LocaleKeys.proceedBooking.tr(), () {
if (widget.url != null && widget.jwtToken != null) { if (widget.url != null && widget.jwtToken != null) {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => SsoLoginWebView(url: widget.url, jwtToken: widget.jwtToken))); Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => SsoLoginWebView(url: widget.url, jwtToken: widget.jwtToken)));

Loading…
Cancel
Save