import 'dart:convert'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:shared_preferences/shared_preferences.dart'; class MemberInformationListModel { int? businesSGroupId; int? persoNId; int? persoNTypeId; int? assignmenTId; String? assignmenTStartDate; String? assignmenTEndDate; String? primarYFlag; String? currenTEmployeeFlag; int? assignmenTStatusTypeId; dynamic normaLHours; dynamic frequency; dynamic frequencYMeaning; String? employeENumber; String? nationaLIdentifier; String? systeMPersonType; String? persoNType; String? manuaLTimecardFlag; String? manuaLTimecardMeaning; String? swipeSExemptedFlag; String? swipeSExemptedMeaning; String? assignmenTNumber; dynamic uniTNumber; String? useRStatus; String? employmenTCategory; String? assignmenTType; String? employmenTCategoryMeaning; String? peRInformationCategory; String? nationalitYCode; String? nationalitYMeaning; String? hirEDate; String? roWNum; int? servicEYears; int? servicEDays; dynamic actuaLTerminationDate; String? employeEEmailAddress; int? joBId; int? positioNId; int? organizatioNId; int? locatioNId; int? payrolLId; dynamic gradEId; String? positioNName; String? organizatioNName; String? locatioNName; String? payrolLName; String? payrolLCode; dynamic gradEName; String? employeEMobileNumber; String? employeEWorkNumber; String? employeeQr; bool? businessCardPrivilege; String? businessCardQr; int? supervisoRId; dynamic supervisoRAssignmentId; String? supervisoRNumber; String? supervisoRName; String? supervisoRDisplayName; String? supervisoREmailAddress; String? supervisoRMobileNumber; String? supervisoRWorkNumber; String? employeEImage; int? tKPersonId; String? tKEmployeeNumber; String? tKEmployeeName; String? tKEmployeeDisplayName; String? tKEmailAddress; int? nOOfRows; int? froMRowNum; int? tORowNum; int? ledgeRId; int? servicEMonths; String? employeeNameEn; dynamic employeENameAr; String? jobNameEn; dynamic joBNameAr; String? employeeDisplayNameEn; dynamic employeEDisplayNameAr; String? mobileNumberWithZipCode; MemberInformationListModel({ this.businesSGroupId, this.persoNId, this.persoNTypeId, this.assignmenTId, this.assignmenTStartDate, this.assignmenTEndDate, this.primarYFlag, this.currenTEmployeeFlag, this.assignmenTStatusTypeId, this.normaLHours, this.frequency, this.frequencYMeaning, this.employeENumber, this.nationaLIdentifier, this.systeMPersonType, this.persoNType, this.manuaLTimecardFlag, this.manuaLTimecardMeaning, this.swipeSExemptedFlag, this.swipeSExemptedMeaning, this.assignmenTNumber, this.uniTNumber, this.useRStatus, this.employmenTCategory, this.assignmenTType, this.employmenTCategoryMeaning, this.peRInformationCategory, this.nationalitYCode, this.nationalitYMeaning, this.hirEDate, this.roWNum, this.servicEYears, this.servicEDays, this.actuaLTerminationDate, this.employeEEmailAddress, this.joBId, this.positioNId, this.organizatioNId, this.locatioNId, this.payrolLId, this.gradEId, this.positioNName, this.organizatioNName, this.locatioNName, this.payrolLName, this.payrolLCode, this.gradEName, this.employeEMobileNumber, this.employeEWorkNumber, this.employeeQr, this.businessCardPrivilege, this.businessCardQr, this.supervisoRId, this.supervisoRAssignmentId, this.supervisoRNumber, this.supervisoRName, this.supervisoRDisplayName, this.supervisoREmailAddress, this.supervisoRMobileNumber, this.supervisoRWorkNumber, this.employeEImage, this.tKPersonId, this.tKEmployeeNumber, this.tKEmployeeName, this.tKEmployeeDisplayName, this.tKEmailAddress, this.nOOfRows, this.froMRowNum, this.tORowNum, this.ledgeRId, this.servicEMonths, this.employeeNameEn, this.employeENameAr, this.jobNameEn, this.joBNameAr, this.employeeDisplayNameEn, this.employeEDisplayNameAr, this.mobileNumberWithZipCode, }); factory MemberInformationListModel.fromRawJson(String str) => MemberInformationListModel.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory MemberInformationListModel.fromJson(Map json) => MemberInformationListModel( businesSGroupId: json["businesS_GROUP_ID"], persoNId: json["persoN_ID"], persoNTypeId: json["persoN_TYPE_ID"], assignmenTId: json["assignmenT_ID"], assignmenTStartDate: json["assignmenT_START_DATE"], assignmenTEndDate: json["assignmenT_END_DATE"], primarYFlag: json["primarY_FLAG"], currenTEmployeeFlag: json["currenT_EMPLOYEE_FLAG"], assignmenTStatusTypeId: json["assignmenT_STATUS_TYPE_ID"], normaLHours: json["normaL_HOURS"], frequency: json["frequency"], frequencYMeaning: json["frequencY_MEANING"], employeENumber: json["employeE_NUMBER"], nationaLIdentifier: json["nationaL_IDENTIFIER"], systeMPersonType: json["systeM_PERSON_TYPE"], persoNType: json["persoN_TYPE"], manuaLTimecardFlag: json["manuaL_TIMECARD_FLAG"], manuaLTimecardMeaning: json["manuaL_TIMECARD_MEANING"], swipeSExemptedFlag: json["swipeS_EXEMPTED_FLAG"], swipeSExemptedMeaning: json["swipeS_EXEMPTED_MEANING"], assignmenTNumber: json["assignmenT_NUMBER"], uniTNumber: json["uniT_NUMBER"], useRStatus: json["useR_STATUS"], employmenTCategory: json["employmenT_CATEGORY"], assignmenTType: json["assignmenT_TYPE"], employmenTCategoryMeaning: json["employmenT_CATEGORY_MEANING"], peRInformationCategory: json["peR_INFORMATION_CATEGORY"], nationalitYCode: json["nationalitY_CODE"], nationalitYMeaning: json["nationalitY_MEANING"], hirEDate: json["hirE_DATE"], roWNum: json["roW_NUM"], servicEYears: json["servicE_YEARS"], servicEDays: json["servicE_DAYS"], actuaLTerminationDate: json["actuaL_TERMINATION_DATE"], employeEEmailAddress: json["employeE_EMAIL_ADDRESS"], joBId: json["joB_ID"], positioNId: json["positioN_ID"], organizatioNId: json["organizatioN_ID"], locatioNId: json["locatioN_ID"], payrolLId: json["payrolL_ID"], gradEId: json["gradE_ID"], positioNName: json["positioN_NAME"], organizatioNName: json["organizatioN_NAME"], locatioNName: json["locatioN_NAME"], payrolLName: json["payrolL_NAME"], payrolLCode: json["payrolL_CODE"], gradEName: json["gradE_NAME"], employeEMobileNumber: json["employeE_MOBILE_NUMBER"], employeEWorkNumber: json["employeE_WORK_NUMBER"], employeeQr: json["employeeQR"], businessCardPrivilege: json["businessCardPrivilege"], businessCardQr: json["businessCardQR"], supervisoRId: json["supervisoR_ID"], supervisoRAssignmentId: json["supervisoR_ASSIGNMENT_ID"], supervisoRNumber: json["supervisoR_NUMBER"], supervisoRName: json["supervisoR_NAME"], supervisoRDisplayName: json["supervisoR_DISPLAY_NAME"], supervisoREmailAddress: json["supervisoR_EMAIL_ADDRESS"], supervisoRMobileNumber: json["supervisoR_MOBILE_NUMBER"], supervisoRWorkNumber: json["supervisoR_WORK_NUMBER"], employeEImage: json["employeE_IMAGE"], tKPersonId: json["tK_PERSON_ID"], tKEmployeeNumber: json["tK_EMPLOYEE_NUMBER"], tKEmployeeName: json["tK_EMPLOYEE_NAME"], tKEmployeeDisplayName: json["tK_EMPLOYEE_DISPLAY_NAME"], tKEmailAddress: json["tK_EMAIL_ADDRESS"], nOOfRows: json["nO_OF_ROWS"], froMRowNum: json["froM_ROW_NUM"], tORowNum: json["tO_ROW_NUM"], ledgeRId: json["ledgeR_ID"], servicEMonths: json["servicE_MONTHS"], employeeNameEn: json["EMPLOYEE_NAME_EN"], employeENameAr: json["employeE_NAME_AR"], jobNameEn: json["JOB_NAME_EN"], joBNameAr: json["joB_NAME_AR"], employeeDisplayNameEn: json["EMPLOYEE_DISPLAY_NAME_EN"], employeEDisplayNameAr: json["employeE_DISPLAY_NAME_AR"], mobileNumberWithZipCode: json["mobileNumberWithZipCode"], ); Map toJson() => { "businesS_GROUP_ID": businesSGroupId, "persoN_ID": persoNId, "persoN_TYPE_ID": persoNTypeId, "assignmenT_ID": assignmenTId, "assignmenT_START_DATE": assignmenTStartDate, "assignmenT_END_DATE": assignmenTEndDate, "primarY_FLAG": primarYFlag, "currenT_EMPLOYEE_FLAG": currenTEmployeeFlag, "assignmenT_STATUS_TYPE_ID": assignmenTStatusTypeId, "normaL_HOURS": normaLHours, "frequency": frequency, "frequencY_MEANING": frequencYMeaning, "employeE_NUMBER": employeENumber, "nationaL_IDENTIFIER": nationaLIdentifier, "systeM_PERSON_TYPE": systeMPersonType, "persoN_TYPE": persoNType, "manuaL_TIMECARD_FLAG": manuaLTimecardFlag, "manuaL_TIMECARD_MEANING": manuaLTimecardMeaning, "swipeS_EXEMPTED_FLAG": swipeSExemptedFlag, "swipeS_EXEMPTED_MEANING": swipeSExemptedMeaning, "assignmenT_NUMBER": assignmenTNumber, "uniT_NUMBER": uniTNumber, "useR_STATUS": useRStatus, "employmenT_CATEGORY": employmenTCategory, "assignmenT_TYPE": assignmenTType, "employmenT_CATEGORY_MEANING": employmenTCategoryMeaning, "peR_INFORMATION_CATEGORY": peRInformationCategory, "nationalitY_CODE": nationalitYCode, "nationalitY_MEANING": nationalitYMeaning, "hirE_DATE": hirEDate, "roW_NUM": roWNum, "servicE_YEARS": servicEYears, "servicE_DAYS": servicEDays, "actuaL_TERMINATION_DATE": actuaLTerminationDate, "employeE_EMAIL_ADDRESS": employeEEmailAddress, "joB_ID": joBId, "positioN_ID": positioNId, "organizatioN_ID": organizatioNId, "locatioN_ID": locatioNId, "payrolL_ID": payrolLId, "gradE_ID": gradEId, "positioN_NAME": positioNName, "organizatioN_NAME": organizatioNName, "locatioN_NAME": locatioNName, "payrolL_NAME": payrolLName, "payrolL_CODE": payrolLCode, "gradE_NAME": gradEName, "employeE_MOBILE_NUMBER": employeEMobileNumber, "employeE_WORK_NUMBER": employeEWorkNumber, "employeeQR": employeeQr, "businessCardPrivilege": businessCardPrivilege, "businessCardQR": businessCardQr, "supervisoR_ID": supervisoRId, "supervisoR_ASSIGNMENT_ID": supervisoRAssignmentId, "supervisoR_NUMBER": supervisoRNumber, "supervisoR_NAME": supervisoRName, "supervisoR_DISPLAY_NAME": supervisoRDisplayName, "supervisoR_EMAIL_ADDRESS": supervisoREmailAddress, "supervisoR_MOBILE_NUMBER": supervisoRMobileNumber, "supervisoR_WORK_NUMBER": supervisoRWorkNumber, "employeE_IMAGE": employeEImage, "tK_PERSON_ID": tKPersonId, "tK_EMPLOYEE_NUMBER": tKEmployeeNumber, "tK_EMPLOYEE_NAME": tKEmployeeName, "tK_EMPLOYEE_DISPLAY_NAME": tKEmployeeDisplayName, "tK_EMAIL_ADDRESS": tKEmailAddress, "nO_OF_ROWS": nOOfRows, "froM_ROW_NUM": froMRowNum, "tO_ROW_NUM": tORowNum, "ledgeR_ID": ledgeRId, "servicE_MONTHS": servicEMonths, "EMPLOYEE_NAME_EN": employeeNameEn, "employeE_NAME_AR": employeENameAr, "JOB_NAME_EN": jobNameEn, "joB_NAME_AR": joBNameAr, "EMPLOYEE_DISPLAY_NAME_EN": employeeDisplayNameEn, "employeE_DISPLAY_NAME_AR": employeEDisplayNameAr, "mobileNumberWithZipCode": mobileNumberWithZipCode, }; String getPositionName() { String positionName = ""; List list = positionName?.split(".") ?? []; if (list.isNotEmpty) { if (list.length > 1) { positionName = list[0] + " " + list[1]; } else { positionName = list.first; } } return positionName; } static Future> getFromPrefs() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List encodedList = prefs.getStringList( SharedPrefsConsts.memberInformation) ?? []; return encodedList.map((e) => MemberInformationListModel.fromJson(jsonDecode(e))).toList(); } static Future saveToPrefs(List list) async { SharedPreferences prefs = await SharedPreferences.getInstance(); List encodedList = list.map((e) => jsonEncode(e.toJson())).toList(); await prefs.setStringList(SharedPrefsConsts.memberInformation, encodedList); } }