|
|
|
|
@ -14,6 +14,7 @@ import 'package:test_sa/modules/internal_audit_module/models/system_internal_aud
|
|
|
|
|
import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart';
|
|
|
|
|
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/update_system_internal_audit_page.dart';
|
|
|
|
|
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/models/loan_attachment_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/loan_provider.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
@ -26,185 +27,91 @@ import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
import '../models/loan_request_model.dart';
|
|
|
|
|
|
|
|
|
|
class LoanEquipmentDetailPage extends StatefulWidget {
|
|
|
|
|
class LoanEquipmentDetailPage extends StatelessWidget {
|
|
|
|
|
static const String id = "/loan-equipment-detail-page";
|
|
|
|
|
final int loanId;
|
|
|
|
|
|
|
|
|
|
LoanEquipmentDetailPage({Key? key, required this.loanId}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_LoanEquipmentDetailPageState createState() {
|
|
|
|
|
return _LoanEquipmentDetailPageState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
bool isWoType = true;
|
|
|
|
|
|
|
|
|
|
late LoanProvider _loanProvider;
|
|
|
|
|
List<InternalAuditAttachments> allAttachments = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_loanProvider = Provider.of<LoanProvider>(context, listen: false);
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
_loanProvider.getLoanById(widget.loanId);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Future<void> getLoanData() async {
|
|
|
|
|
// model = await _loanProvider.getLoanById(widget.loanId);
|
|
|
|
|
// allAttachments.clear();
|
|
|
|
|
// allAttachments = [
|
|
|
|
|
// // ...(model?.attachments ?? []),
|
|
|
|
|
// // ...(model?.engineerData?.attachments ?? []),
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: const DefaultAppBar(title: "Request Details"),
|
|
|
|
|
body: Selector<LoanProvider, bool>(
|
|
|
|
|
selector: (_, provider) => provider.isLoading,
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
|
|
|
|
LoanRequestModel? model = Provider.of<LoanProvider>(context, listen: false).loanData;
|
|
|
|
|
if (model == null) const NoDataFound().center;
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: FutureBuilder<LoanRequestModel?>(
|
|
|
|
|
future: Provider.of<LoanProvider>(context, listen: false).getLoanById(loanId),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<LoanRequestModel?> snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
|
|
|
|
if (snapshot.data == null) return const NoDataFound().center;
|
|
|
|
|
|
|
|
|
|
List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// StatusLabel(
|
|
|
|
|
// label: model.priority!,
|
|
|
|
|
// textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.priority!),
|
|
|
|
|
// backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.priority!),
|
|
|
|
|
// ),
|
|
|
|
|
// 8.width,
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: model?.loanStatusName!,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, model?.loanStatusName!),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, model?.loanStatusName!),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: snapshot.data!.loanStatusName!,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.loanStatusName!),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.loanStatusName!),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
Text(
|
|
|
|
|
snapshot.data!.createdDate?.toServiceRequestCardFormat ?? "-",
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
...requesterDetails(context, snapshot.data!),
|
|
|
|
|
12.height,
|
|
|
|
|
...requestDetails(context, snapshot.data!),
|
|
|
|
|
12.height,
|
|
|
|
|
...assetDetails(context, snapshot.data!),
|
|
|
|
|
12.height,
|
|
|
|
|
...installationDetails(context, snapshot.data!),
|
|
|
|
|
12.height,
|
|
|
|
|
...doctorDetails(context, snapshot.data!),
|
|
|
|
|
12.height,
|
|
|
|
|
...vendorDetails(context, snapshot.data!),
|
|
|
|
|
if (allAttachments.isNotEmpty) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
Text(
|
|
|
|
|
model?.createdDate?.toServiceRequestCardFormat ?? "-",
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
"Attachments".addTranslation,
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
...requestDetails(model!),
|
|
|
|
|
12.height,
|
|
|
|
|
...assetDetails(model),
|
|
|
|
|
12.height,
|
|
|
|
|
...requesterDetails(model),
|
|
|
|
|
12.height,
|
|
|
|
|
...doctorDetails(model),
|
|
|
|
|
12.height,
|
|
|
|
|
...vendorDetails(model),
|
|
|
|
|
// assetInformation(),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// workOrderInformation(),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// //TODO need to check for comments
|
|
|
|
|
// if (model?.findingDescription?.isNotEmpty ?? false) ...[
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// // Text(
|
|
|
|
|
// // "Comments".addTranslation,
|
|
|
|
|
// // style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
// // ),
|
|
|
|
|
// model!.findingDescription!.bodyText(context),
|
|
|
|
|
// ],
|
|
|
|
|
//TODO need to check for attachments
|
|
|
|
|
if (allAttachments.isNotEmpty) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
Text(
|
|
|
|
|
"Attachments".addTranslation,
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(0).toShadowContainer(context),
|
|
|
|
|
).expanded,
|
|
|
|
|
// if (context.userProvider.isEngineer)
|
|
|
|
|
// FooterActionButton.footerContainer(
|
|
|
|
|
// context: context,
|
|
|
|
|
// child: AppFilledButton(
|
|
|
|
|
// buttonColor: AppColor.primary10,
|
|
|
|
|
// label: "Update",
|
|
|
|
|
// onPressed: () async {
|
|
|
|
|
// final result = await Navigator.of(context).push(
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
// builder: (_) => UpdateSystemInternalAuditPage(model: model),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// if (result == true) {
|
|
|
|
|
// // await getAuditData();
|
|
|
|
|
// // setState(() {}); // refresh UI with new model
|
|
|
|
|
// }
|
|
|
|
|
// }),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Widget workOrderInformation() {
|
|
|
|
|
// final details = model?.workOrderDetails;
|
|
|
|
|
// return Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// Text(
|
|
|
|
|
// "WO Info",
|
|
|
|
|
// style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
// ),
|
|
|
|
|
// 6.height,
|
|
|
|
|
// labelValueText(context, context.translation.woNumber, details?.workOrderNo),
|
|
|
|
|
// labelValueText(context, 'WO Type'.addTranslation, model?.workOrderType?.name),
|
|
|
|
|
// labelValueText(context, context.translation.site, details?.woSite),
|
|
|
|
|
// labelValueText(context, context.translation.assetName, details?.woAssetName),
|
|
|
|
|
// labelValueText(context, context.translation.manufacture, details?.woManufacturer),
|
|
|
|
|
// labelValueText(context, context.translation.model, details?.woModel),
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
List<Widget> requestDetails(LoanRequestModel loanData) {
|
|
|
|
|
List<Widget> requestDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
6.height,
|
|
|
|
|
'Loan Type: ${loanData.loanTypeName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Loan No: ${loanData.reqCode ?? "-"}'.bodyText(context),
|
|
|
|
|
'Loan Period: ${loanData.loanPeriodName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${loanData.siteName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.department}: ${loanData.departmentName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> vendorDetails(LoanRequestModel loanData) {
|
|
|
|
|
List<Widget> vendorDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${loanData.vendorName ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -214,7 +121,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> assetDetails(LoanRequestModel loanData) {
|
|
|
|
|
List<Widget> assetDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'${context.translation.assetName}: ${loanData.assetName ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -225,7 +132,17 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> doctorDetails(LoanRequestModel loanData) {
|
|
|
|
|
List<Widget> installationDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Installation & Pullout Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Installation EDD: ${loanData.installationEDD?.toServiceRequestDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
'Installation Date: ${loanData.installationEDD?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
'Pullout EDD: ${loanData.pulloutEDD?.toServiceRequestDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
'Pullout Date: ${loanData.pulloutDate?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> doctorDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${loanData.doctorName ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -234,7 +151,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> requesterDetails(LoanRequestModel loanData) {
|
|
|
|
|
List<Widget> requesterDetails(BuildContext context, LoanRequestModel loanData) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${loanData.requestorUserIdForDisplay ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -244,25 +161,6 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Widget assetInformation() {
|
|
|
|
|
// final details = model?.workOrderDetails;
|
|
|
|
|
// return Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// Text(
|
|
|
|
|
// "Asset Details",
|
|
|
|
|
// style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
// ),
|
|
|
|
|
// 6.height,
|
|
|
|
|
// labelValueText(context, context.translation.assetName, details?.woAssetName),
|
|
|
|
|
// labelValueText(context, context.translation.assetNo, details?.woAssetNo),
|
|
|
|
|
// labelValueText(context, context.translation.manufacture, details?.woManufacturer),
|
|
|
|
|
// labelValueText(context, context.translation.model, details?.woModel),
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Widget labelValueText(BuildContext context, String label, String? value) {
|
|
|
|
|
if (value == null || value.isEmpty) return const SizedBox.shrink();
|
|
|
|
|
|
|
|
|
|
@ -277,7 +175,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget checklistWidget({required String value}) {
|
|
|
|
|
Widget checklistWidget(BuildContext context, {required String value}) {
|
|
|
|
|
return Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
|