You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
4.8 KiB
Dart
104 lines
4.8 KiB
Dart
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/InPatientServices/get_inpatient_advance_history_response_model.dart';
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/my_rich_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class InPatientPaidAdvancePayment extends StatefulWidget {
|
|
const InPatientPaidAdvancePayment({Key key}) : super(key: key);
|
|
|
|
@override
|
|
State<InPatientPaidAdvancePayment> createState() => _InPatientPaidAdvancePaymentState();
|
|
}
|
|
|
|
class _InPatientPaidAdvancePaymentState extends State<InPatientPaidAdvancePayment> {
|
|
ProjectViewModel projectViewModel;
|
|
InPatientAdvanceHistoryResponseModel inPatientAdvanceHistoryResponseModel;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
getInPatientAdvancePaymentHistory();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectViewModel = Provider.of(context);
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: inPatientAdvanceHistoryResponseModel != null && inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo != null
|
|
? ListView.separated(
|
|
itemCount: inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return Container(
|
|
decoration: cardRadius(12),
|
|
padding: EdgeInsets.all(12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
MyRichText(
|
|
TranslationBase.of(context).admissionNo + ": ", inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo[index].admissionNo.toString(), projectViewModel.isArabic),
|
|
MyRichText(TranslationBase.of(context).admissionReqNo + ": ", inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo[index].admissionReqNo.toString(),
|
|
projectViewModel.isArabic),
|
|
MyRichText(
|
|
TranslationBase.of(context).date + ": ",
|
|
DateUtil.formatDateToDate(DateUtil.convertStringToDate(inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo[index].createdOn), false),
|
|
projectViewModel.isArabic),
|
|
MyRichText(
|
|
TranslationBase.of(context).amount_ + ": ", inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo[index].requestedAmount.toString(), projectViewModel.isArabic),
|
|
MyRichText(TranslationBase.of(context).status + ": ", getStatus(inPatientAdvanceHistoryResponseModel.responseInpatientAdvanceInfo[index]), projectViewModel.isArabic),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return SizedBox(
|
|
height: 12.0,
|
|
);
|
|
},
|
|
)
|
|
: getNoDataWidget(context),
|
|
);
|
|
}
|
|
|
|
String getStatus(ResponseInpatientAdvanceInfo responseInpatientAdvanceInfo) {
|
|
switch (responseInpatientAdvanceInfo.status) {
|
|
case 1:
|
|
return "Hold";
|
|
break;
|
|
case 2:
|
|
return "Active";
|
|
break;
|
|
case 4:
|
|
return "Cancelled";
|
|
break;
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
void getInPatientAdvancePaymentHistory() {
|
|
ClinicListService service = new ClinicListService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service
|
|
.getInPatientAdvancePaymentHistory(projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.projectID : projectViewModel.getAdmissionRequestInfoResponseModel.projectId, projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.admissionNo : 0,
|
|
projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.admissionRequestNo : projectViewModel.getAdmissionRequestInfoResponseModel.admissionRequestNo, context)
|
|
.then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
inPatientAdvanceHistoryResponseModel = InPatientAdvanceHistoryResponseModel.fromJson(res["responseInpatient"]);
|
|
setState(() {});
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
}
|