Worklist & Wifi attendance

merge-requests/1/merge
devmirza121 2 years ago
parent a03eb8b11a
commit 42510259bc

@ -104,7 +104,7 @@ class DashboardApiClient {
"QRValue": "",
"PointType": pointType, // NFC=2, Wifi = 3, QR= 1,
"NFCValue": nfcValue,
"WifiValue": "",
"WifiValue": pointType == 3 ? "100" : "",
"IsGpsRequired": isGpsRequired
};
postParams.addAll(AppState().postParamsJson);

@ -362,7 +362,6 @@ class WorkListApiClient {
}, url, postParams);
}
Future<GetContactNotificationBodyList?> getContactNotificationBodyList(int? notificationId) async {
String url = "${ApiConsts.erpRest}GET_CONTACT_NOTIFICATION_BODY";
Map<String, dynamic> postParams = {
@ -432,11 +431,11 @@ class WorkListApiClient {
}, url, postParams);
}
Future<GenericResponseModel> submitComment({String? comment, String? email, String? userId, int? notificationId}) async {
Future<GenericResponseModel> submitComment({String? comment, String? email, String? userId, int? notificationId, required String apiMode}) async {
String url = "${ApiConsts.erpRest}NOTIFICATION_ACTIONS";
Map<String, dynamic> postParams = {
"P_COMMENTS": comment,
"P_ACTION_MODE": "DELEGATE",
"P_ACTION_MODE": apiMode,
"P_EMAIL_ADDRESS": email,
"P_FORWARD_TO_USER_NAME": userId,
"P_NOTIFICATION_ID": notificationId,

@ -29,6 +29,19 @@ class AppState {
String? get getForgetPasswordTokenID => forgetPasswordTokenID;
//Wifi info
String? mohemmWifiSSID;
set setMohemmWifiSSID(v) => mohemmWifiSSID = mohemmWifiSSID;
String? get getMohemmWifiSSID => mohemmWifiSSID;
String? mohemmWifiPassword;
set setMohemmWifiPassword(v) => mohemmWifiPassword = v;
String? get getMohemmWifiPassword => mohemmWifiPassword;
PostParamsModel? _postParams;
PostParamsModel? get postParamsObject => _postParams;

@ -1,7 +1,7 @@
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://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/";
@ -20,4 +20,6 @@ class SharedPrefsConsts {
static String memberInformation = "memberInformation";
static String welcomeVideoUrl = "welcomeVideoUrl";
static String doNotShowWelcomeVideo = "doNotShowWelcomeVideo";
static String mohemmWifiSSID = "mohemmWifiSSID";
static String mohemmWifiPassword = "mohemmWifiPassword";
}

@ -29,7 +29,7 @@ Future<void> main() async {
await EasyLocalization.ensureInitialized();
await Firebase.initializeApp();
AppState().setPostParamsModel(
PostParamsModel(channel: 31, versionID: 3.4, mobileType: Platform.isAndroid ? "android" : "ios"),
PostParamsModel(channel: 31, versionID: 3.6, mobileType: Platform.isAndroid ? "android" : "ios"),
);
runApp(
EasyLocalization(

@ -17,6 +17,7 @@ import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart';
import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
import 'package:nfc_manager/nfc_manager.dart';
import 'package:provider/provider.dart';
import 'package:wifi_iot/wifi_iot.dart';
import '../../provider/dashboard_provider_model.dart';
import '../../widgets/location/Location.dart';
@ -198,7 +199,16 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
performNfcAttendance(model);
}
}),
attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () {}),
attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () {
if (isWifiLocationEnabled) {
Location.getCurrentLocation((LatLng? latlng) {
performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
});
} else {
performWifiAttendance(model);
}
// connectWifi();
}),
],
)
],
@ -257,6 +267,41 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
});
}
Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
if (isWifiLocationEnabled) {
print("wifi location enabled");
} else {
print("wifi not location enabled");
}
bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false);
if (v) {
await WiFiForIoTPlugin.forceWifiUsage(true);
print("connected");
Utils.showLoading(context);
try {
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
bool status = await model.fetchAttendanceTracking(context);
Utils.hideLoading(context);
await closeWifiRequest();
} catch (ex) {
print(ex);
await closeWifiRequest();
Utils.hideLoading(context);
Utils.handleException(ex, context, (msg) {
Utils.confirmDialog(context, msg);
});
}
} else {
Utils.confirmDialog(context, "Please come near to HMG wifi");
}
}
Future<bool> closeWifiRequest() async {
await WiFiForIoTPlugin.forceWifiUsage(false);
bool v = await WiFiForIoTPlugin.disconnect();
return v;
}
Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),

@ -23,6 +23,7 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart';
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LoginScreen extends StatefulWidget {
LoginScreen({Key? key}) : super(key: key);
@ -70,6 +71,7 @@ class _LoginScreenState extends State<LoginScreen> {
String? firebaseToken;
GetMobileLoginInfoListModel? loginInfo;
Future<void> checkFirebaseToken() async {
try {
Utils.showLoading(context);
@ -108,6 +110,10 @@ class _LoginScreenState extends State<LoginScreen> {
if (_autoLogin) {
AppState().setMemberInformationListModel = (await MemberInformationListModel.getFromPrefs()).first;
AppState().setPrivilegeListModel = await PrivilegeListModel.getFromPrefs();
String mohemmWifiSSID = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID);
String mohemmWifiPassword = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword);
AppState().mohemmWifiSSID = mohemmWifiSSID;
AppState().mohemmWifiPassword = mohemmWifiPassword;
}
Utils.hideLoading(context);
if (_autoLogin) {
@ -126,12 +132,11 @@ class _LoginScreenState extends State<LoginScreen> {
@override
Widget build(BuildContext context) {
username.text = "15153";
// username.text = "15153";
password.text = "Abcd@1234";
// username.text = "15444";
username.text = "15444";
// username.text = "287742";
// password.text = "509@Shafiq";
return Scaffold(
body: Column(
children: [

@ -686,8 +686,12 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().mohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().mohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword, genericResponseModel.mohemmWifiPassword!);
}
Utils.hideLoading(context);
Navigator.pop(context);
@ -695,7 +699,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
Utils.handleException(ex, context, null);
}
},
() => {
@ -705,7 +709,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
Utils.handleException(ex, context, null);
}
}
},

@ -101,7 +101,7 @@ class ApprovalLevelfragment extends StatelessWidget {
}).expanded,
Container(width: 1, height: 30, color: MyColors.lightGreyEFColor),
LocaleKeys.delegate.tr().toText12(color: MyColors.gradiantEndColor).center.paddingOnly(top: 6, bottom: 6).onPress(() {
showMyBottomSheet(context, child: DelegateSheet());
// showMyBottomSheet(context, child: DelegateSheet());
}).expanded,
],
),

@ -23,9 +23,10 @@ import '../../../models/worklist/get_favorite_replacements_model.dart';
class DelegateSheet extends StatefulWidget {
int? notificationID;
String title,apiMode;
List<GetActionHistoryList>? actionHistoryList;
DelegateSheet({this.notificationID, this.actionHistoryList});
DelegateSheet({required this.title,required this.apiMode,this.notificationID, this.actionHistoryList});
@override
State<DelegateSheet> createState() => _DelegateSheetState();
@ -114,7 +115,7 @@ class _DelegateSheetState extends State<DelegateSheet> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Delegate".toText24(),
widget.title.toText24(),
24.height,
"Search".toText16(),
20.height,
@ -359,6 +360,7 @@ class _DelegateSheetState extends State<DelegateSheet> {
showMyBottomSheet(context,
child: SelectedItemSheet(
"Comment",
apiMode: widget.apiMode,
actionHistoryList: actionHistory,
notificationID: widget.notificationID,
));
@ -403,6 +405,7 @@ class _DelegateSheetState extends State<DelegateSheet> {
showMyBottomSheet(context,
child: SelectedItemSheet(
"Comment",
apiMode: widget.apiMode,
favoriteReplacements: actionHistory,
notificationID: widget.notificationID,
));
@ -447,6 +450,7 @@ class _DelegateSheetState extends State<DelegateSheet> {
showMyBottomSheet(context,
child: SelectedItemSheet(
"Comment",
apiMode: widget.apiMode,
replacementList: actionHistory,
notificationID: widget.notificationID,
));

@ -141,7 +141,7 @@ class RequestMoreInfoSheet extends StatelessWidget {
Widget showItem(BuildContext context, String name, {bool isEnabled = false}) {
return InkWell(
onTap: () {
showMyBottomSheet(context, child: SelectedItemSheet("Request more info"));
// showMyBottomSheet(context, child: SelectedItemSheet("Request more info"));
},
child: Row(
children: [

@ -16,13 +16,13 @@ import '../../../models/worklist/get_favorite_replacements_model.dart';
import '../../../models/worklist/replacement_list_model.dart';
class SelectedItemSheet extends StatelessWidget {
String title;
String title, apiMode;
int? notificationID;
GetActionHistoryList? actionHistoryList;
GetFavoriteReplacements? favoriteReplacements;
ReplacementList? replacementList;
SelectedItemSheet(this.title, {this.notificationID, this.actionHistoryList, this.favoriteReplacements, this.replacementList});
SelectedItemSheet(this.title, {required this.apiMode, this.notificationID, this.actionHistoryList, this.favoriteReplacements, this.replacementList});
TextEditingController username = TextEditingController();
String comment = "";
@ -86,7 +86,7 @@ class SelectedItemSheet extends StatelessWidget {
Expanded(
child: DefaultButton(
"Submit",
() async {
() {
String? email = "", userId = "";
if (actionHistoryList != null) {
email = actionHistoryList!.eMAILADDRESS;
@ -98,12 +98,7 @@ class SelectedItemSheet extends StatelessWidget {
email = replacementList!.emailAddress;
userId = replacementList!.userName;
}
Utils.showLoading(context);
await WorkListApiClient().submitComment(comment: comment, email: email, userId: userId, notificationId: notificationID);
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, "delegate_reload");
performNetworkCall(context, email: email ?? "", userId: userId ?? "");
},
colors: [
Color(0xff32D892),
@ -118,6 +113,20 @@ class SelectedItemSheet extends StatelessWidget {
);
}
Future<void> performNetworkCall(BuildContext context, {String? email, String? userId}) async {
Utils.showLoading(context);
try{
await WorkListApiClient().submitComment(comment: comment, email: email, userId: userId, notificationId: notificationID, apiMode: apiMode);
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, "delegate_reload");
}catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
Widget showItem(String? name, bool? isFav) {
return Container(
decoration: BoxDecoration(

@ -24,6 +24,7 @@ import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_mod
import 'package:mohem_flutter_app/models/member_information_list_model.dart';
import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart';
import 'package:mohem_flutter_app/models/worklist_response_model.dart';
import 'package:mohem_flutter_app/ui/work_list/sheets/delegate_sheet.dart';
import 'package:mohem_flutter_app/ui/work_list/worklist_fragments/actions_fragment.dart';
import 'package:mohem_flutter_app/ui/work_list/worklist_fragments/attachments_fragment.dart';
import 'package:mohem_flutter_app/ui/work_list/worklist_fragments/detail_fragment.dart';
@ -37,6 +38,8 @@ import '../../models/worklist/hr/eit_otification_body_model.dart';
import '../../models/worklist/hr/get_basic_det_ntf_body_list_model.dart';
import '../../models/worklist/hr/get_contact_notification_body_list_model.dart';
import '../../models/worklist/hr/get_phones_notification_body_list_model.dart';
import '../../widgets/bottom_sheet.dart';
import '../../widgets/dialogs/confirm_dialog.dart';
class WorkListDetailScreen extends StatefulWidget {
WorkListDetailScreen({Key? key}) : super(key: key);
@ -107,7 +110,6 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID);
} else if (workListData!.rEQUESTTYPE == "CONTACT") {
getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID);
}
// getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999);
@ -359,19 +361,59 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
switch (notificationButton.bUTTONACTION) {
case "DELEGATE":
// do something
showMyBottomSheet(context, child: DelegateSheet(title: "Delegate", apiMode: "DELEGATE", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList));
break;
case "REQUEST_INFO":
// do something else
showMyBottomSheet(context, child: DelegateSheet(title: "Request Info", apiMode: "REQUEST_INFO", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList));
break;
case "RFC":
// do something else
break;
case "UPDATE_ACTION":
// do something else
case "APPROVE_AND_FORWARD":
// do something else
showMyBottomSheet(context,
child: DelegateSheet(title: "Approve and Forward", apiMode: "APPROVE_AND_FORWARD", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList));
break;
case "FORWARD":
// do something else
showMyBottomSheet(context, child: DelegateSheet(title: "Forward", apiMode: "FORWARD", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList));
break;
case "REJECT":
// do something else
performNetworkCall(context, email: "", userId: "");
break;
case "RETURNED":
// do something else
Navigator.pop(context);
break;
}
}
Future<void> performNetworkCall(BuildContext context, {String? email, String? userId}) async {
showDialog(
context: context,
builder: (cxt) => ConfirmDialog(
message: "Are you sure want to reject?",
okTitle: "Reject",
onTap: () async {
Navigator.pop(cxt);
Utils.showLoading(context);
try {
await WorkListApiClient().submitComment(comment: "", email: email, userId: userId, notificationId: workListData!.nOTIFICATIONID, apiMode: "REJECT");
Utils.hideLoading(context);
Navigator.pop(context, "delegate_reload");
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
),
);
}
Widget myTab(String title, int index) {
bool isSelected = (index == tabIndex);
return Column(

@ -97,11 +97,11 @@ class ActionsFragment extends StatelessWidget {
Row(
children: [
LocaleKeys.request_info.tr().toText12(color: MyColors.grey67Color).center.paddingOnly(top: 6, bottom: 6).onPress(() {
showMyBottomSheet(context, child: RequestMoreInfoSheet());
showMyBottomSheet(context, child: DelegateSheet(title: "Request Info", apiMode: "REQUEST_INFO", notificationID: notificationID, actionHistoryList: actionHistoryList));
}).expanded,
Container(width: 1, height: 30, color: MyColors.lightGreyEFColor),
LocaleKeys.delegate.tr().toText12(color: MyColors.gradiantEndColor).center.paddingOnly(top: 6, bottom: 6).onPress(() {
showMyBottomSheet(context, child: DelegateSheet(notificationID:notificationID,actionHistoryList: actionHistoryList));
showMyBottomSheet(context, child: DelegateSheet(title: "Delegate", apiMode: "DELEGATE", notificationID: notificationID, actionHistoryList: actionHistoryList));
}).expanded,
],
),

@ -63,6 +63,7 @@ dependencies:
flutter_calendar_carousel: ^2.1.0
pie_chart: ^5.1.0
open_file: ^3.2.1
wifi_iot: ^0.3.16

Loading…
Cancel
Save