From 8ea831c2c4059a6016d26f8c0ad4b404ccd4f623 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Thu, 2 Apr 2026 09:23:00 +0300 Subject: [PATCH] color coding changes on the monthly leave calendar and prod e-learning URL added. --- lib/api/dashboard_api_client.dart | 2 +- lib/classes/consts.dart | 8 ++-- ...get_day_hours_type_details_list_model.dart | 8 ++++ .../attendance/monthly_attendance_screen.dart | 48 +++++++++++++++++-- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 87025f2..e4c63c0 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -435,7 +435,7 @@ class DashboardApiClient { //Fetch All Courses Status Future fetchAllCoursesStatus() async { - String url = "https://elearning.hmg.com/moodle_dev/api/Fetch_All_Courses_Status.php"; + String url = ApiConsts.eLearningBaseUrl +"Fetch_All_Courses_Status.php"; Map headers = { 'x-api-key': 'bLi@mbXJeXTHd/)h&LFh%25+%25(Nbnaq6hBg%7d%5dyQbthY%7bv6ew6-5UT\$NASwucn%7d,_PSJpuwNCCen2%7djj%7b00HR2T-%5b,k7W%7d-0yepK?%258', diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index d8efe5d..7fc3540 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -4,13 +4,13 @@ class ApiConsts { // static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "http://10.201.204.101:2024"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd - // static String baseUrl = "https://hmgwebservices.com"; // Live server - // static String baseUrl = "https://mohemm.hmg.com"; // New Live server - // + static String baseUrl = "https://mohemm.hmg.com"; // New Live server + //static String eLearningBaseUrl = "https://elearning.hmg.com/moodle_dev/api/"; // Elearning server UAT + static String eLearningBaseUrl = "https://elearning.hmg.com/moodle/api/"; // Elearning server live // static String baseUrl = "http://10.20.200.111:1010/"; diff --git a/lib/models/get_day_hours_type_details_list_model.dart b/lib/models/get_day_hours_type_details_list_model.dart index e4eef25..0a0c8b0 100644 --- a/lib/models/get_day_hours_type_details_list_model.dart +++ b/lib/models/get_day_hours_type_details_list_model.dart @@ -22,6 +22,8 @@ class GetDayHoursTypeDetailsList { dynamic? fROMROWNUM; String? lATEINFLAG; String? lATEINHRS; + String? lEAVEDESCRIPTION; + String? lEAVETYPECODE; String? mISSINGSWIPEFLAG; String? nONSCHEDULEDFLAG; dynamic? nOOFROWS; @@ -66,6 +68,8 @@ class GetDayHoursTypeDetailsList { this.fROMROWNUM, this.lATEINFLAG, this.lATEINHRS, + this.lEAVEDESCRIPTION, + this.lEAVETYPECODE, this.mISSINGSWIPEFLAG, this.nONSCHEDULEDFLAG, this.nOOFROWS, @@ -110,6 +114,8 @@ class GetDayHoursTypeDetailsList { fROMROWNUM = json['FROM_ROW_NUM']; lATEINFLAG = json['LATE_IN_FLAG']; lATEINHRS = json['LATE_IN_HRS']; + lEAVEDESCRIPTION = json['LEAVE_DESCRIPTION']; + lEAVETYPECODE = json['LEAVE_TYPE_CODE']; mISSINGSWIPEFLAG = json['MISSING_SWIPE_FLAG']; nONSCHEDULEDFLAG = json['NON_SCHEDULED_FLAG']; nOOFROWS = json['NO_OF_ROWS']; @@ -156,6 +162,8 @@ class GetDayHoursTypeDetailsList { data['FROM_ROW_NUM'] = this.fROMROWNUM; data['LATE_IN_FLAG'] = this.lATEINFLAG; data['LATE_IN_HRS'] = this.lATEINHRS; + data['LEAVE_DESCRIPTION'] = this.lEAVEDESCRIPTION; + data['LEAVE_TYPE_CODE'] = this.lEAVETYPECODE; data['MISSING_SWIPE_FLAG'] = this.mISSINGSWIPEFLAG; data['NON_SCHEDULED_FLAG'] = this.nONSCHEDULEDFLAG; data['NO_OF_ROWS'] = this.nOOFROWS; diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index cce9d3b..5fbd585 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -315,6 +315,26 @@ class _MonthlyAttendanceScreenState extends State { bool isDayIsPresent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'Y'; bool isDayIsAbsent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[index].aBSENTFLAG == 'Y'; + // Get leave type code and corresponding color + String? leaveTypeCode = getDayHoursTypeDetailsList[index].lEAVETYPECODE; + Color? leaveTypeColor; + bool useGradient = false; + + // Determine color based on leave type code + if (leaveTypeCode != null && leaveTypeCode.isNotEmpty) { + leaveTypeColor = leaveTypeColors[leaveTypeCode]; + } + + // If no leave type color found, use default colors based on attendance status + if (leaveTypeColor == null) { + if (isDayIsPresent) { + leaveTypeColor = leaveTypeColors['Present']; + useGradient = true; // Use gradient for present days without leave type + } else if (isDayIsAbsent) { + leaveTypeColor = leaveTypeColors['Absent']; + } + } + if (isDayIsOff) { return Container( margin: const EdgeInsets.all(4), @@ -331,12 +351,13 @@ class _MonthlyAttendanceScreenState extends State { return Container( margin: const EdgeInsets.all(4), decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: useGradient && leaveTypeColor != null ? LinearGradient( transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [MyColors.gradiantEndColor, MyColors.gradiantStartColor], - ), + ) : null, + color: !useGradient && leaveTypeColor != null ? leaveTypeColor : null, shape: BoxShape.circle, boxShadow: [ BoxShadow( @@ -358,7 +379,7 @@ class _MonthlyAttendanceScreenState extends State { return Container( margin: const EdgeInsets.all(4), decoration: BoxDecoration( - color: MyColors.backgroundBlackColor, + color: leaveTypeColor ?? MyColors.backgroundBlackColor, shape: BoxShape.circle, boxShadow: [ BoxShadow( @@ -751,3 +772,24 @@ class Meeting { Color background; bool isAllDay; } +const Map leaveTypeColors = { + 'Present': Color(0xFF00ad62), + 'Absent': Color(0xFFcb3232), + 'HOLIDAY': Color(0xFFF26B0F), + 'BUS_TRIP': Color(0xFF001A6E), + 'WFH': Color(0xFF5DB996), + 'ANNUAL': Color(0xFFf39c12), + 'EMERGENCY': Color(0xFFFF2929), + 'EXAM': Color(0xFFCB6040), + 'HAJJ': Color(0xFF798645), + 'HALF': Color(0xFFE8B86D), + 'LWOP': Color(0xFFCD5C08), + 'LWOP_MATUNPAID': Color(0xFFE73879), + 'LWOP_UNAUUNPAID': Color(0xFFA02334), + 'MATPAID': Color(0xFFE73879), + 'MRGE': Color(0xFF0D7C66), + 'PAT': Color(0xFFC96868), + 'PROF': Color(0xFF6256CA), + 'SICK': Color(0xFFA5B68D), +}; +