|
|
|
|
@ -57,6 +57,15 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
|
|
|
|
|
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<MonthlyAttendanceScreen> {
|
|
|
|
|
// bool isDayIsPresent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'Y';
|
|
|
|
|
// bool isDayIsAbsent = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].aBSENTFLAG == 'Y';
|
|
|
|
|
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) {
|
|
|
|
|
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<MonthlyAttendanceScreen> {
|
|
|
|
|
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<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(
|
|
|
|
|
margin: const EdgeInsets.all(4),
|
|
|
|
|
@ -430,14 +471,22 @@ class _MonthlyAttendanceScreenState extends State<MonthlyAttendanceScreen> {
|
|
|
|
|
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<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.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;
|
|
|
|
|
|