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.
PatientApp-KKUMC/lib/pages/medical/my_invoices/my_invoice_page.dart

145 lines
6.8 KiB
Dart

4 years ago
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart' as DoctorListResponse;
import 'package:diplomaticquarterapp/models/MyInvoices/DentalInvoiceDetailResponse.dart';
import 'package:diplomaticquarterapp/models/MyInvoices/GetDentalAppointmentsResponse.dart';
import 'package:diplomaticquarterapp/pages/medical/my_invoices/invoice_detail_page.dart';
import 'package:diplomaticquarterapp/services/my_invoice_service/my_invoice_services.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.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/widgets/data_display/medical/doctor_card.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';
class MyInvoices extends StatefulWidget {
@override
_MyInvoicesState createState() => _MyInvoicesState();
}
class _MyInvoicesState extends State<MyInvoices> {
bool isDataLoaded = false;
2 years ago
GetDentalAppointmentsResponse? getDentalAppointmentsResponse;
DentalInvoiceDetailResponse? dentalInvoiceDetailResponse;
2 years ago
ProjectViewModel? projectViewModel;
List<ImagesInfo> imagesInfo =[];
4 years ago
@override
void initState() {
imagesInfo
.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-invoice/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-invoice/ar/0.png'));
4 years ago
WidgetsBinding.instance.addPostFrameCallback((_) {
2 years ago
if (projectViewModel!.isLogin) getDentalAppointments();
});
super.initState();
}
@override
Widget build(BuildContext context) {
4 years ago
projectViewModel = Provider.of(context);
return AppScaffold(
appBarTitle: TranslationBase.of(context).myInvoice,
isShowAppBar: true,
isShowDecPage: true,
showNewAppBar: true,
showNewAppBarTitle: true,
4 years ago
imagesInfo: imagesInfo,
body: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: isDataLoaded
? Column(
children: [
ListView.separated(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21),
itemBuilder: (context, index) {
return DoctorCard(
2 years ago
onTap: () => openInvoiceDetailsPage(getDentalAppointmentsResponse!.listDentalAppointments![index]),
isInOutPatient: true,
2 years ago
name: TranslationBase.of(context).dr.toString() + " " + (projectViewModel!.isArabic ? getDentalAppointmentsResponse!.listDentalAppointments![index].doctorNameN.toString() : getDentalAppointmentsResponse!.listDentalAppointments![index].doctorName.toString()),
billNo: getDentalAppointmentsResponse!.listDentalAppointments![index].invoiceNo.toString(),
profileUrl: getDentalAppointmentsResponse!.listDentalAppointments![index].doctorImageURL,
subName: getDentalAppointmentsResponse!.listDentalAppointments![index].projectName,
isLiveCareAppointment: false,
2 years ago
date: DateUtil.convertStringToDate(getDentalAppointmentsResponse!.listDentalAppointments![index].appointmentDate!),
isSortByClinic: true,
);
},
2 years ago
itemCount: getDentalAppointmentsResponse!.listDentalAppointments!.length,
separatorBuilder: (context, index) => SizedBox(height: 14),
),
],
)
: Container(),
),
));
}
openInvoiceDetailsPage(ListDentalAppointments listDentalAppointments) {
GifLoaderDialogUtils.showMyDialog(context);
MyInvoicesService myInvoicesService = new MyInvoicesService();
DoctorListResponse.DoctorList doctor = new DoctorListResponse.DoctorList();
2 years ago
doctor.name = projectViewModel!.isArabic ? listDentalAppointments.doctorNameN : listDentalAppointments.doctorName;
doctor.projectName = listDentalAppointments.projectName;
doctor.date = listDentalAppointments.appointmentDate;
doctor.actualDoctorRate = 0;
doctor.doctorImageURL = listDentalAppointments.doctorImageURL;
doctor.projectID = listDentalAppointments.projectID;
doctor.dayName = listDentalAppointments.invoiceNo;
doctor.clinicName = listDentalAppointments.invoiceNo.toString();
doctor.date = listDentalAppointments.appointmentDate;
doctor.noOfPatientsRate = listDentalAppointments.patientNumber;
doctor.actualDoctorRate = listDentalAppointments.doctorRate;
doctor.decimalDoctorRate = listDentalAppointments.decimalDoctorRate;
doctor.doctorID = listDentalAppointments.doctorID;
2 years ago
myInvoicesService.getDentalAppointmentInvoice(listDentalAppointments.projectID!, listDentalAppointments.appointmentNo!, listDentalAppointments.invoiceNo!, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
setState(() {
if (res['MessageStatus'] == 1) {
2 years ago
dentalInvoiceDetailResponse = DentalInvoiceDetailResponse.fromJson(res as Map<String, dynamic>);
Navigator.push(context, FadePage(page: InvoiceDetail(doctor, listDentalAppointments, dentalInvoiceDetailResponse!, context)));
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
isDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err.toString());
});
}
getDentalAppointments() {
GifLoaderDialogUtils.showMyDialog(context);
MyInvoicesService myInvoicesService = new MyInvoicesService();
myInvoicesService.getAllDentalAppointments(0, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
setState(() {
if (res['MessageStatus'] == 1) {
2 years ago
getDentalAppointmentsResponse = GetDentalAppointmentsResponse.fromJson(res as Map<String, dynamic>);
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
isDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err);
Navigator.of(context).pop();
});
}
}