|
|
|
|
@ -7,12 +7,13 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da
|
|
|
|
|
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/widgets/buttons/secondary_button.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.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';
|
|
|
|
|
@ -38,7 +39,7 @@ class _EdPaymentInformationPageState extends State<EdPaymentInformationPage> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
projectViewModel = Provider.of(context);
|
|
|
|
|
return BaseView<EdOnlineViewModel>(
|
|
|
|
|
onModelReady: (model) => model.getPatientPaymentInformation(),
|
|
|
|
|
onModelReady: (model) async => await model.getPatientPaymentInformation(),
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
@ -46,75 +47,129 @@ class _EdPaymentInformationPageState extends State<EdPaymentInformationPage> {
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), color: Colors.white),
|
|
|
|
|
margin: EdgeInsets.fromLTRB(0.0, 30.0, 0.0, 5.0),
|
|
|
|
|
padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 20.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
margin: EdgeInsets.only(left: 0.0, right: 20.0, top: 30.0),
|
|
|
|
|
child: Text(TranslationBase.of(context).testFee, style: TextStyle(color: Colors.black, fontSize: 22.0, fontWeight: FontWeight.bold)),
|
|
|
|
|
),
|
|
|
|
|
if (model.erPatientShareModel != null)
|
|
|
|
|
Table(
|
|
|
|
|
children: [
|
|
|
|
|
TableRow(children: [
|
|
|
|
|
TableCell(child: Texts(TranslationBase.of(context).testFee)),
|
|
|
|
|
TableCell(child: Texts(model.erPatientShareModel.patientShare.toStringAsFixed(2))),
|
|
|
|
|
]),
|
|
|
|
|
TableRow(children: [
|
|
|
|
|
TableCell(child: Texts(TranslationBase.of(context).patientTaxToDo)),
|
|
|
|
|
TableCell(child: Texts(model.erPatientShareModel.patientTaxAmount.toStringAsFixed(2))),
|
|
|
|
|
]),
|
|
|
|
|
TableRow(children: [
|
|
|
|
|
TableCell(child: Texts(TranslationBase.of(context).patientShareTotalToDo)),
|
|
|
|
|
TableCell(child: Texts(model.erPatientShareModel.patientShareWithTax.toStringAsFixed(2))),
|
|
|
|
|
]),
|
|
|
|
|
],
|
|
|
|
|
decoration: cardRadius(12),
|
|
|
|
|
margin: EdgeInsets.fromLTRB(12.0, 30.0, 12.0, 5.0),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(TranslationBase.of(context).payment,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontSize: 16.0,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.64,
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.only(top: 10, bottom: 3),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(TranslationBase.of(context).patientShareToDo),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(model.erPatientShareModel.patientShare.toStringAsFixed(2) ?? "0", isBold: true),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
mDivider(Colors.grey[200]),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.only(top: 3, bottom: 3),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(TranslationBase.of(context).patientTaxToDo),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(model.erPatientShareModel.patientTaxAmount.toStringAsFixed(2) ?? "0", isBold: true),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mDivider(Colors.grey[200]),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.only(top: 3, bottom: 3),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(TranslationBase.of(context).patientShareTotalToDo),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: _getNormalText(model.erPatientShareModel.patientShareWithTax.toStringAsFixed(2) ?? "0", isBold: true),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mHeight(50.0),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).payOptions,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12.0,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.46,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(margin: EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0), child: getPaymentMethods()),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: Container(
|
|
|
|
|
height: 76,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
label: TranslationBase.of(context).next.toUpperCase(),
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.push(context, FadePage(page: PaymentMethod(
|
|
|
|
|
onSelectedMethod: (String metohd, [String selectedInstallmentPlan]) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
))).then(
|
|
|
|
|
(value) {
|
|
|
|
|
//TODO Haroun call API here
|
|
|
|
|
print(value);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.selectedHospital.iD;
|
|
|
|
|
openPayment(value[0], projectViewModel.user, model.erPatientShareModel.patientShareWithTax, appo);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
color: CustomColors.appBackgroudGreyColor,
|
|
|
|
|
padding: EdgeInsets.all(12.0),
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).payNow.toUpperCase(),
|
|
|
|
|
() {
|
|
|
|
|
Navigator.push(context, FadePage(page: PaymentMethod(
|
|
|
|
|
onSelectedMethod: (String metohd, [String selectedInstallmentPlan]) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
))).then(
|
|
|
|
|
(value) {
|
|
|
|
|
//TODO Haroun call API here
|
|
|
|
|
print(value);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.selectedHospital.iD;
|
|
|
|
|
openPayment(value[0], projectViewModel.user, model.erPatientShareModel.patientShareWithTax, appo);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
color: CustomColors.green,
|
|
|
|
|
disabledColor: CustomColors.grey2,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getNormalText(text, {bool isBold = false}) {
|
|
|
|
|
return Text(
|
|
|
|
|
text,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: isBold ? 12 : 10,
|
|
|
|
|
letterSpacing: -0.5,
|
|
|
|
|
color: isBold ? Colors.black : Colors.grey[700],
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, double amount, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart);
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.selectedHospital.iD, projectViewModel.user.patientID);
|
|
|
|
|
browser.openPaymentBrowser(amount, "ER Online Check-In", transID, appo.projectID.toString(),
|
|
|
|
|
authenticatedUser.emailAddress, paymentMethod, authenticatedUser.patientType, authenticatedUser.firstName, authenticatedUser.patientID, authenticatedUser, browser, false, "3", "");
|
|
|
|
|
browser.openPaymentBrowser(amount, "ER Online Check-In", transID, appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, authenticatedUser.patientType,
|
|
|
|
|
authenticatedUser.firstName, authenticatedUser.patientID, authenticatedUser, browser, false, "3", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
@ -163,13 +218,12 @@ class _EdPaymentInformationPageState extends State<EdPaymentInformationPage> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ER_createAdvancePayment(res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
ER_createAdvancePayment(payment_res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
String paymentReference = res['Fort_id'].toString();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
|
|
|
|
|
service.ER_createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], AppGlobal.context).then((res) {
|
|
|
|
|
service.ER_createAdvancePayment(appo, appo.projectID.toString(), payment_res['Amount'], payment_res['Fort_id'], payment_res['PaymentMethod'], AppGlobal.context).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
ER_InsertEROnlinePaymentDetails(res, appo);
|
|
|
|
|
ER_InsertEROnlinePaymentDetails(payment_res, appo);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
@ -177,11 +231,13 @@ class _EdPaymentInformationPageState extends State<EdPaymentInformationPage> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ER_InsertEROnlinePaymentDetails(res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
ER_InsertEROnlinePaymentDetails(payment_res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
|
|
|
|
|
service.ER_InsertEROnlinePaymentDetails(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], AppGlobal.context).then((res) {
|
|
|
|
|
service.ER_InsertEROnlinePaymentDetails(appo, appo.projectID.toString(), payment_res['Amount'], payment_res['Fort_id'], payment_res['PaymentMethod'], AppGlobal.context).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).success);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
|