diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 9eb6548d..5e4631d7 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -511,7 +511,7 @@ const Map localizedValues = { "ourLocations": {"en": "Our Locations", "ar": "مواقعنا"}, "edit": {"en": "Edit", "ar": "تعديل"}, "whatsApp": {"en": "Whats App", "ar": " واتس اب"}, - "phone": {"en": "Phone", "ar": " موبايل"}, + "phone": {"en": "Phone", "ar": " هاتف"}, "delete": {"en": "Delete", "ar": " حذف"}, "deleteAddress": {"en": "Are you sure want to delete", "ar": " هل انت متأكد تريد حذف هذا العنوان"}, "deletedAddres": {"en": "Address has been deleted", "ar": " تم حذف العنوان"}, @@ -1744,8 +1744,8 @@ const Map localizedValues = { "ordersDashboard": {"en": "My Orders", "ar": "طلباتي"}, "productOutOfStock": {"en": "Out Of Stock", "ar": "إنتهى من المخزن"}, "productQuantity": {"en": "Quantity", "ar": "كمية"}, - "yourTurn": {"en": "your turn is after", "ar": "دورك بعد"}, "patients": {"en": "patients", "ar": "مرضي"}, "group": {"en": "Group", "ar": "مجموعة"}, + "ancillaryOrdersPaymentConfirm": {"en": "Are you sure you want to make payment for selected orders?", "ar": "هل أنت متأكد أنك تريد سداد قيمة الطلبات المختارة؟"}, }; diff --git a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart index de26c4b9..8d0ebabd 100644 --- a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart +++ b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart @@ -1,16 +1,23 @@ import "package:collection/collection.dart"; +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ordersPayment.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_proc_model.dart'; +import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/dragable_sheet.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -27,6 +34,12 @@ class AnicllaryOrdersDetails extends StatefulWidget { class _AnicllaryOrdersState extends State with SingleTickerProviderStateMixin { ProjectViewModel projectViewModel; + bool _agreeTerms = false; + String selectedPaymentMethod; + MyInAppBrowser browser; + String transID = ""; + + List selectedProcList = []; void initState() { super.initState(); @@ -40,54 +53,105 @@ class _AnicllaryOrdersState extends State with SingleTic Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getOrdersDetails(widget.appoNo, widget.orderNo, widget.projectID), - builder: (_, model, widget) => AppScaffold( - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - baseViewModel: model, - appBarTitle: TranslationBase.of(context).anicllaryOrders, - body: SingleChildScrollView( - padding: EdgeInsets.all(12), - child: model.ancillaryListsDetails.length > 0 - ? Column(children: [ - getPatientInfo(model), - getAncillaryDetails(model), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 20, - fontWeight: FontWeight.bold, - ), - Texts( - getTotalValue(model), - fontSize: 20, - fontWeight: FontWeight.bold, - ) - ], + onModelReady: (model) => model.getOrdersDetails(widget.appoNo, widget.orderNo, widget.projectID), + builder: (_, model, widget) => AppScaffold( + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + baseViewModel: model, + appBarTitle: TranslationBase.of(context).anicllaryOrders, + body: SingleChildScrollView( + padding: EdgeInsets.all(12), + child: model.ancillaryListsDetails.length > 0 + ? Column(children: [ + getPatientInfo(model), + getAncillaryDetails(model), + ]) + : getNoDataWidget(context), + ), + bottomSheet: model.ancillaryListsDetails.length > 0 + ? Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10), bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + ), + padding: EdgeInsets.only(left: 21, right: 21, top: 15, bottom: 15), + width: double.infinity, + // color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox(height: 12), + Text( + TranslationBase.of(context).YouCanPayByTheFollowingOptions, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, ), - ]) - : getNoDataWidget(context), - ), - bottomSheet: Container( - color: Theme.of(context).scaffoldBackgroundColor, - margin: EdgeInsets.only(bottom: 5.0), - width: double.infinity, - padding: EdgeInsets.all(12), - child: DefaultButton( - TranslationBase.of(context).payNow.toUpperCase(), - () { - Navigator.push( - context, - FadePage( - page: OrdersPayment(), ), - ); - }, - ), - ))); + SizedBox( + width: MediaQuery.of(context).size.width * 0.75, + child: getPaymentMethods(), + ), + _amountView(TranslationBase.of(context).patientShareTotalToDo, getTotalValue() + " " + TranslationBase.of(context).sar, isBold: true, isTotal: true), + SizedBox(height: 12), + DefaultButton( + TranslationBase.of(context).payNow.toUpperCase(), + selectedProcList.length > 0 && getTotalValue() != "0.00" + ? () { + makePayment(); + } + : null, + color: CustomColors.green, + disabledColor: CustomColors.grey2, + ), + ], + ), + ) + : Container(), + ), + ); + } + + _getNormalText(text, {bool isBold = false, bool isTotal = false}) { + return Text( + text, + style: TextStyle( + fontSize: isBold + ? isTotal + ? 16 + : 12 + : 11, + letterSpacing: -0.5, + color: isBold ? Color(0xff2E303A) : Color(0xff575757), + fontWeight: isTotal ? FontWeight.bold : FontWeight.w600, + ), + ); + } + + _amountView(String title, String value, {bool isBold = false, bool isTotal = false}) { + return Padding( + padding: const EdgeInsets.only(top: 10, bottom: 10), + child: Row(children: [ + Expanded( + child: _getNormalText(title), + ), + Expanded( + child: _getNormalText(value, isBold: isBold, isTotal: isTotal), + ), + ]), + ); } Widget getPatientInfo(AnciallryOrdersViewModel model) { @@ -229,7 +293,7 @@ class _AnicllaryOrdersState extends State with SingleTic Widget getAncillaryDetails(model) { Map newMap = groupBy(model.ancillaryListsDetails[0].ancillaryOrderProcDetailsList, (obj) => obj.procedureCategoryName); - return Padding(padding: EdgeInsets.only(top: 0, bottom: 10), child: getHeaderDetails(newMap)); + return Padding(padding: EdgeInsets.only(top: 0, bottom: 200), child: getHeaderDetails(newMap)); } Widget getHeaderDetails(newMap) { @@ -251,10 +315,11 @@ class _AnicllaryOrdersState extends State with SingleTic children: [ Table( columnWidths: { - 0: FlexColumnWidth(2.0), - 1: FlexColumnWidth(1.5), + 0: FlexColumnWidth(1.0), + 1: FlexColumnWidth(2.5), 2: FlexColumnWidth(1.5), 3: FlexColumnWidth(1.5), + 4: FlexColumnWidth(1.5), }, children: fullData(context, value), ), @@ -271,9 +336,9 @@ class _AnicllaryOrdersState extends State with SingleTic ); } - String getTotalValue(value) { + String getTotalValue() { double total = 0.0; - value.ancillaryListsDetails[0].ancillaryOrderProcDetailsList.forEach((result) => {total += result.patientShareWithTax}); + selectedProcList.forEach((result) => {total += result.patientShareWithTax}); return total.toStringAsFixed(2); } @@ -283,6 +348,7 @@ class _AnicllaryOrdersState extends State with SingleTic tableRow.add( TableRow( children: [ + Utils.tableColumnTitle(""), Utils.tableColumnTitle(TranslationBase.of(context).procedure), Utils.tableColumnTitle(TranslationBase.of(context).price), Utils.tableColumnTitle(TranslationBase.of(context).vat), @@ -294,13 +360,172 @@ class _AnicllaryOrdersState extends State with SingleTic for (int i = 0; i < value.length; i++) { tableRow.add( TableRow(children: [ + Checkbox( + value: checkIfProcedureSelected(value[i]), + onChanged: (v) { + setState(() { + addSelectedProcedure(value[i]); + }); + }), Utils.tableColumnValue('${value[i].procedureName.toString()}', isLast: true), - Utils.tableColumnValue('${value[i].patientShare.toString()}', isLast: true), - Utils.tableColumnValue('${value[i].patientTaxAmount.toString() + " " + TranslationBase.of(context).sar}', isLast: true), - Utils.tableColumnValue('${value[i].patientShareWithTax.toString() + " " + TranslationBase.of(context).sar}', isLast: true), + Utils.tableColumnValue('${value[i].patientShare.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true), + Utils.tableColumnValue('${value[i].patientTaxAmount.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true), + Utils.tableColumnValue('${value[i].patientShareWithTax.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true), ]), ); } return tableRow; } + + makePayment() { + showDraggableDialog(context, PaymentMethod( + onSelectedMethod: (String method) { + selectedPaymentMethod = method; + print(selectedPaymentMethod); + openPayment(selectedPaymentMethod, projectViewModel.authenticatedUserObject.user, double.parse(getTotalValue()), null); + }, + )); + } + + openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, double amount, AppoitmentAllHistoryResultList appo) { + browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart); + + transID = Utils.getAdvancePaymentTransID(widget.projectID, projectViewModel.authenticatedUserObject.user.patientID); + + browser.openPaymentBrowser( + amount, + "Ancillary Orders Payment", + transID, + widget.projectID.toString(), + projectViewModel.authenticatedUserObject.user.emailAddress, + paymentMethod, + projectViewModel.authenticatedUserObject.user.patientType, + projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName, + projectViewModel.authenticatedUserObject.user.patientID, + authenticatedUser, + browser, + false, + "3", + ""); + } + + onBrowserLoadStart(String url) { + print("onBrowserLoadStart"); + print(url); + + MyInAppBrowser.successURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = true; + return; + } + }); + + MyInAppBrowser.errorURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = false; + return; + } + }); + } + + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + if (isPaymentMade) checkPaymentStatus(appo); + } + + checkPaymentStatus(AppoitmentAllHistoryResultList appo) { + GifLoaderDialogUtils.showMyDialog(AppGlobal.context); + DoctorsListService service = new DoctorsListService(); + service.checkPaymentStatus(transID, AppGlobal.context).then((res) { + String paymentInfo = res['Response_Message']; + if (paymentInfo == 'Success') { + createAdvancePayment(res, appo); + } else { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + AppToast.showErrorToast(message: res['Response_Message']); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + + createAdvancePayment(res, AppoitmentAllHistoryResultList appo) { + DoctorsListService service = new DoctorsListService(); + String paymentReference = res['Fort_id'].toString(); + service.HIS_createAdvancePayment( + appo, + widget.projectID.toString(), + res['Amount'], + res['Fort_id'], + res['PaymentMethod'], + projectViewModel.authenticatedUserObject.user.patientType, + projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName, + projectViewModel.authenticatedUserObject.user.patientID, + AppGlobal.context) + .then((res) { + addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, 0, appo); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + + addAdvancedNumberRequest(String advanceNumber, String paymentReference, dynamic appointmentID, AppoitmentAllHistoryResultList appo) { + DoctorsListService service = new DoctorsListService(); + service.addAdvancedNumberRequest(advanceNumber, paymentReference, appointmentID, AppGlobal.context).then((res) { + print(res); + autoGenerateInvoice(); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + + autoGenerateInvoice() { + List selectedProcListAPI = []; + + selectedProcList.forEach((element) { + selectedProcListAPI.add({ + "ApprovalLineItemNo": element.approvalLineItemNo, + "OrderLineItemNo": element.orderLineItemNo, + "ProcedureID": element.procedureID, + }); + }); + + DoctorsListService service = new DoctorsListService(); + service.autoGenerateAncillaryOrdersInvoice(widget.orderNo, widget.projectID, widget.appoNo, selectedProcListAPI, AppGlobal.context).then((res) { + print(res); + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + + bool checkIfProcedureSelected(AncillaryOrderProcDetailsList ancillaryOrderProcDetailsList) { + if (selectedProcList.length > 0) { + if (selectedProcList.contains(ancillaryOrderProcDetailsList)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + addSelectedProcedure(AncillaryOrderProcDetailsList ancillaryOrderProcDetailsList) { + if (!checkIfProcedureSelected(ancillaryOrderProcDetailsList)) { + selectedProcList.add(ancillaryOrderProcDetailsList); + } else { + selectedProcList.remove(ancillaryOrderProcDetailsList); + } + } } diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 63e711e5..59b8eeda 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -270,7 +270,6 @@ class _BookConfirmState extends State { widget.service.insertAppointment(docObject.doctorID, docObject.clinicID, docObject.projectID, widget.selectedTime, widget.selectedDate, context).then((res) { if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess); - print(res['AppointmentNo']); Future.delayed(new Duration(milliseconds: 500), () { getPatientShare(context, res['AppointmentNo'], docObject.clinicID, docObject.projectID, docObject); diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index 52efd3e9..7743fbbb 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -94,7 +94,7 @@ class ReviewsInfo extends StatelessWidget { child: Container( child: Text( previousModel - .productDetailService[0].reviews[index].reviewText, + .productDetailService[0].reviews[index].replyText, style: TextStyle(fontSize: 20), ), ), diff --git a/lib/pages/pharmacy/order/ProductReview.dart b/lib/pages/pharmacy/order/ProductReview.dart index 288d50dd..5857b802 100644 --- a/lib/pages/pharmacy/order/ProductReview.dart +++ b/lib/pages/pharmacy/order/ProductReview.dart @@ -327,41 +327,41 @@ class _ProductReviewPageState extends State { ], ), ), - Container( - margin: EdgeInsets.only(top: 20.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return PharmacyProfilePage(moveToOrder: true); - }), - ); - }, - child: Container( - height: 50.0, - color: Colors.transparent, - child: Container( - decoration: BoxDecoration( - border: Border.all( - color: Colors.orange, - style: BorderStyle.solid, - width: 1.0), - color: Colors.transparent, - borderRadius: BorderRadius.circular(5.0)), - child: Center( - child: Text( - TranslationBase.of(context).backMyAccount, - style: TextStyle( - color: Colors.orange, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ), - ), - ), + // Container( + // margin: EdgeInsets.only(top: 20.0), + // child: InkWell( + // onTap: () { + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) { + // return PharmacyProfilePage(moveToOrder: true); + // }), + // ); + // }, + // child: Container( + // height: 50.0, + // color: Colors.transparent, + // child: Container( + // decoration: BoxDecoration( + // border: Border.all( + // color: Colors.orange, + // style: BorderStyle.solid, + // width: 1.0), + // color: Colors.transparent, + // borderRadius: BorderRadius.circular(5.0)), + // child: Center( + // child: Text( + // TranslationBase.of(context).backMyAccount, + // style: TextStyle( + // color: Colors.orange, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // ), + // ), + // ), + // ), ], ); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 80039ece..b317e106 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -904,6 +904,28 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + Future autoGenerateAncillaryOrdersInvoice(String orderNo, int projectID, dynamic appointmentID, List selectedProcListAPI, BuildContext context) async { + Map request; + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + Request req = appGlobal.getPublicRequest(); + request = { + "RequestAncillaryOrderInvoice": [ + {"MemberID": 102, "ProjectID": projectID, "AppointmentNo": appointmentID, "OrderNo": orderNo, "AncillaryOrderInvoiceProcList": selectedProcListAPI} + ] + }; + dynamic localRes; + await baseAppClient.post(GENERATE_ANCILLARY_ORDERS_INVOICE, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + Future isAllowedToAskDoctor(int docID, BuildContext context) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index ff0043e0..bda03125 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2821,6 +2821,9 @@ class TranslationBase { String get yourTurn => localizedValues["yourTurn"][locale.languageCode]; String get patients => localizedValues["patients"][locale.languageCode]; String get group => localizedValues["group"][locale.languageCode]; + String get ancillaryOrdersPaymentConfirm => localizedValues["ancillaryOrdersPaymentConfirm"][locale.languageCode]; + + } class TranslationBaseDelegate extends LocalizationsDelegate {