diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 2adb2ba..ac320f7 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -513,5 +513,6 @@ "ourSponsor": "راعينا:", "startingIn": "يبدأ في", "youAreOutOfContest": "أنت خارج المسابقة.", - "winners": "الفائزين!!!" + "winners": "الفائزين!!!", + "fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 46ede79..1e6025c 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -513,6 +513,6 @@ "ourSponsor": "Our Sponsor:", "startingIn": "Starting in", "youAreOutOfContest": "You are out of the contest.", - "winners": "WINNERS!!!" - + "winners": "WINNERS!!!", + "fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified." } \ No newline at end of file diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index ace0881..5f2ad7e 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -133,6 +133,28 @@ class DashboardApiClient { }, url, postParams); } + //Mark Fake Location + Future markFakeLocation({String lat = "0", String? long = "0", required String sourceName}) async { + String url = "${ApiConsts.swpRest}CreateIssueInfo"; + var uuid = Uuid(); + // Generate a v4 (random) id + + Map postParams = { + "UID": uuid.v4(), //Mobile Id + "Latitude": lat, + "Longitude": long, + "QRValue": '', + "NFCValue": sourceName == 'NFC' ? sourceName : '', + "WifiValue": sourceName == 'WIFI' ? sourceName : '', + "EmployeeID": AppState().memberInformationList!.eMPLOYEENUMBER, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + //Check ITG Type Future getITGPageNotification() async { String url = "${ApiConsts.cocRest}Mohemm_ITG_GetPageNotification"; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 3d58efd..93eceee 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -2,9 +2,9 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://hmgwebservices.com"; // Live server + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index b2a92ad..67408b3 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -528,7 +528,9 @@ class CodegenLoader extends AssetLoader{ "youWantToLeaveMarathon": "هل أنت متأكد أنك تريد العودة؟ سوف تخرج من المسابقة.", "ourSponsor": "راعينا:", "startingIn": "يبدأ في", - "youAreOutOfContest": "أنت خارج المسابقة." + "youAreOutOfContest": "أنت خارج المسابقة.", + "winners": "الفائزين!!!", + "fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية" }; static const Map en_US = { "mohemm": "Mohemm", @@ -1044,7 +1046,9 @@ static const Map en_US = { "youWantToLeaveMarathon": "Are you sure you want to go back? You will be out of the contest.", "ourSponsor": "Our Sponsor:", "startingIn": "Starting in", - "youAreOutOfContest": "You are out of the contest." + "youAreOutOfContest": "You are out of the contest.", + "winners": "WINNERS!!!", + "fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified." }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 8960278..e4c6ffb 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -500,5 +500,6 @@ abstract class LocaleKeys { static const startingIn = 'startingIn'; static const youAreOutOfContest = 'youAreOutOfContest'; static const winners = 'winners'; + static const fakeLocation = 'fakeLocation'; } diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 8ec8d00..1f62d4e 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -436,6 +436,12 @@ class _WorkListDetailScreenState extends State { case "DELEGATE": returnActionImage = "assets/images/delegate.svg"; break; + case "APPROVE": + returnActionImage = "assets/images/worklist/approve.svg"; + break; + case "REJECT": + returnActionImage = "assets/images/worklist/reject.svg"; + break; case "REQUEST_INFO": returnActionImage = "assets/images/request_info.svg"; break; diff --git a/lib/widgets/location/Location.dart b/lib/widgets/location/Location.dart index 0ddca1c..d407c1c 100644 --- a/lib/widgets/location/Location.dart +++ b/lib/widgets/location/Location.dart @@ -46,12 +46,12 @@ class Location { }); } - static void getCurrentLocation(Function(LatLng?) callback, BuildContext context) { + static void getCurrentLocation(Function(LatLng?, bool isMocked) callback, BuildContext context) { void done(Position position) { //AppStorage.sp.saveLocation(position); - + bool isMocked = position.isMocked; LatLng? myCurrentLocation = LatLng(position.latitude, position.longitude); - callback(myCurrentLocation); + callback(myCurrentLocation, isMocked); } AppPermissions.location((granted) { diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index 9840700..cbf70ad 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -94,8 +94,12 @@ class _MarkAttendanceWidgetState extends State { // if (isNfcEnabled) attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { if (isNfcLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + Location.getCurrentLocation((LatLng? latlng, bool isMocked) { + if (isMocked) { + markFakeAttendance("NFC", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? ""); + } else { + performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + } }, context); } else { performNfcAttendance(widget.model); @@ -104,8 +108,12 @@ class _MarkAttendanceWidgetState extends State { if (isWifiEnabled) attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { if (isWifiLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performWifiAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + Location.getCurrentLocation((LatLng? latlng, bool isMocked) { + if (isMocked) { + markFakeAttendance("WIFI", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? ""); + } else { + performWifiAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + } }, context); } else { performWifiAttendance(widget.model); @@ -115,8 +123,12 @@ class _MarkAttendanceWidgetState extends State { if (isQrEnabled) attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { if (isQrLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performQrCodeAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + Location.getCurrentLocation((LatLng? latlng, bool isMocked) { + if (isMocked) { + markFakeAttendance("QR", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? ""); + } else { + performQrCodeAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + } }, context); } else { performQrCodeAttendance(widget.model); @@ -136,7 +148,7 @@ class _MarkAttendanceWidgetState extends State { Utils.showLoading(context); try { GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId, isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); - if(g?.messageStatus != 1) { + if (g?.messageStatus != 1) { Utils.hideLoading(context); showDialog( context: context, @@ -157,7 +169,6 @@ class _MarkAttendanceWidgetState extends State { child: SuccessDialog(widget.isFromDashboard), ); } - } catch (ex) { print(ex); Utils.hideLoading(context); @@ -171,7 +182,7 @@ class _MarkAttendanceWidgetState extends State { Utils.showLoading(context); try { GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); - if(g?.messageStatus != 1) { + if (g?.messageStatus != 1) { Utils.hideLoading(context); showDialog( context: context, @@ -276,6 +287,21 @@ class _MarkAttendanceWidgetState extends State { } } + void markFakeAttendance(String sourceName, String lat, String long) async { + Utils.showLoading(context); + try { + await DashboardApiClient().markFakeLocation(sourceName: sourceName, lat: lat, long: long); + Utils.hideLoading(context); + Utils.confirmDialog(context, LocaleKeys.fakeLocation.tr()); + } catch (ex) { + print(ex); + Utils.hideLoading(context); + Utils.handleException(ex, context, (msg) { + Utils.confirmDialog(context, msg); + }); + } + } + Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15),