|
|
|
@ -1,5 +1,5 @@
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
@ -7,21 +7,26 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/helper_function.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/asset_delivery_data_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/asset_delivery_data_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/delivery_inspection_form_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/delivery_inspection_form_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/delivery_line_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/delivery_line_model.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/models/inspection_person_model.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_line_card_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_line_card_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/attachment_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/attachment_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/cost_center_form_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/cost_center_form_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/oracle_user_autocomplete_field.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/provider/attachment_type_provider.dart';
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
|
|
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
|
|
@ -129,7 +134,13 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
|
|
|
|
child: !viewOnly
|
|
|
|
child: !viewOnly
|
|
|
|
? Column(
|
|
|
|
? Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
|
|
|
|
AppFilledButton(
|
|
|
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
|
|
|
label: 'Attachments'.addTranslation,
|
|
|
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
HelperFunction.attachmentTap(context: context, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id);
|
|
|
|
|
|
|
|
}),
|
|
|
|
16.height,
|
|
|
|
16.height,
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -207,56 +218,109 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
|
|
|
|
Widget inspectionDetailsForm() {
|
|
|
|
Widget inspectionDetailsForm() {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
if (widget.requestModel?.isHMG == true) ...[
|
|
|
|
_inspectionTile(
|
|
|
|
OracleUserAutoCompleteField(
|
|
|
|
title: 'Inspected by'.addTranslation,
|
|
|
|
clearAfterPick: false,
|
|
|
|
model: model.inspectedByModel,
|
|
|
|
initialValue: model.deliveryInspectionInspectedBy ?? '',
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
label: 'Inspected by'.addTranslation,
|
|
|
|
onTap: () async {
|
|
|
|
onPick: (value) {
|
|
|
|
final result = await showInspectionBottomSheet(
|
|
|
|
model.deliveryInspectionInspectedBy = value.fullName;
|
|
|
|
context,
|
|
|
|
setState(() {});
|
|
|
|
title: 'Inspected by'.addTranslation,
|
|
|
|
},
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
onChanged: (value) {},
|
|
|
|
initialModel: model.inspectedByModel ?? InspectionPersonModel(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
8.height,
|
|
|
|
if (result != null) {
|
|
|
|
OracleUserAutoCompleteField(
|
|
|
|
setState(() => model.inspectedByModel = result);
|
|
|
|
clearAfterPick: false,
|
|
|
|
}
|
|
|
|
initialValue: model.deliveryInspectionApprovedBy ?? '',
|
|
|
|
},
|
|
|
|
label: 'Approved by'.addTranslation,
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
|
|
|
|
onPick: (value) {
|
|
|
|
8.height,
|
|
|
|
model.deliveryInspectionApprovedBy = value.fullName;
|
|
|
|
_inspectionTile(
|
|
|
|
setState(() {});
|
|
|
|
title: 'Approved by'.addTranslation,
|
|
|
|
},
|
|
|
|
model: model.approvedByModel,
|
|
|
|
),
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
] //No HMG user free text insted of dropdown ...
|
|
|
|
onTap: () async {
|
|
|
|
else ...[
|
|
|
|
final result = await showInspectionBottomSheet(
|
|
|
|
AppTextFormField(
|
|
|
|
context,
|
|
|
|
labelText: 'Inspected by'.addTranslation,
|
|
|
|
title: 'Approved by'.addTranslation,
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
initialValue: model.deliveryInspectionInspectedBy ?? '',
|
|
|
|
initialModel: model.approvedByModel ?? InspectionPersonModel(),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
);
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
if (result != null) {
|
|
|
|
showShadow: false,
|
|
|
|
setState(() => model.approvedByModel = result);
|
|
|
|
onChange: (value) {
|
|
|
|
}
|
|
|
|
model.deliveryInspectionInspectedBy = value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
if (widget.requestModel?.paymentTerm?.value == 2) ...[
|
|
|
|
),
|
|
|
|
_inspectionTile(
|
|
|
|
8.height,
|
|
|
|
title: 'Third Approved by'.addTranslation,
|
|
|
|
AppTextFormField(
|
|
|
|
model: model.thirdApprovalModel,
|
|
|
|
labelText: 'Approved by'.addTranslation,
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
onTap: () async {
|
|
|
|
initialValue: model.deliveryInspectionApprovedBy ?? '',
|
|
|
|
final result = await showInspectionBottomSheet(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
context,
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
title: 'Third Approved by'.addTranslation,
|
|
|
|
showShadow: false,
|
|
|
|
isHmg: widget.requestModel?.isHMG == true,
|
|
|
|
onChange: (value) {
|
|
|
|
initialModel: model.thirdApprovalModel ?? InspectionPersonModel(),
|
|
|
|
model.deliveryInspectionApprovedBy = value;
|
|
|
|
);
|
|
|
|
|
|
|
|
if (result != null) {
|
|
|
|
|
|
|
|
setState(() => model.thirdApprovalModel = result);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (widget.requestModel?.isHMG == true) ...[
|
|
|
|
|
|
|
|
// OracleUserAutoCompleteField(
|
|
|
|
|
|
|
|
// clearAfterPick: false,
|
|
|
|
|
|
|
|
// initialValue: model.deliveryInspectionInspectedBy ?? '',
|
|
|
|
|
|
|
|
// label: 'Inspected by'.addTranslation,
|
|
|
|
|
|
|
|
// onPick: (value) {
|
|
|
|
|
|
|
|
// model.deliveryInspectionInspectedBy = value.fullName;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// onChanged: (value) {},
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// 8.height,
|
|
|
|
|
|
|
|
// OracleUserAutoCompleteField(
|
|
|
|
|
|
|
|
// clearAfterPick: false,
|
|
|
|
|
|
|
|
// initialValue: model.deliveryInspectionApprovedBy ?? '',
|
|
|
|
|
|
|
|
// label: 'Approved by'.addTranslation,
|
|
|
|
|
|
|
|
// onChanged: (value) {},
|
|
|
|
|
|
|
|
// onPick: (value) {
|
|
|
|
|
|
|
|
// model.deliveryInspectionApprovedBy = value.fullName;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ] //No HMG user free text insted of dropdown ...
|
|
|
|
|
|
|
|
// else ...[
|
|
|
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
|
|
|
// labelText: 'Inspected by'.addTranslation,
|
|
|
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
// initialValue: model.deliveryInspectionInspectedBy ?? '',
|
|
|
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
|
|
|
// onChange: (value) {
|
|
|
|
|
|
|
|
// model.deliveryInspectionInspectedBy = value;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// 8.height,
|
|
|
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
|
|
|
// labelText: 'Approved by'.addTranslation,
|
|
|
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
// initialValue: model.deliveryInspectionApprovedBy ?? '',
|
|
|
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
|
|
|
// onChange: (value) {
|
|
|
|
|
|
|
|
// model.deliveryInspectionApprovedBy = value;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
ADatePicker(
|
|
|
|
ADatePicker(
|
|
|
|
label: 'Inspected Date/Time From'.addTranslation,
|
|
|
|
label: 'Inspected Date/Time From'.addTranslation,
|
|
|
|
@ -417,13 +481,69 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _attachmentTap() async {
|
|
|
|
Widget _inspectionTile({
|
|
|
|
Navigator.push(
|
|
|
|
required String title,
|
|
|
|
context,
|
|
|
|
InspectionPersonModel? model,
|
|
|
|
MaterialPageRoute(
|
|
|
|
required bool isHmg,
|
|
|
|
builder: (context) => AssetDeliveryAttachmentView(
|
|
|
|
required VoidCallback onTap,
|
|
|
|
tableItemId: widget.deliveryTableModel.id,
|
|
|
|
}) {
|
|
|
|
)));
|
|
|
|
return InkWell(
|
|
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.all(14),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text(title, style: AppTextStyles.textFieldLabelStyle),
|
|
|
|
|
|
|
|
6.height,
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
model?.name?.isNotEmpty == true ? model!.name! : 'Tap to add'.addTranslation,
|
|
|
|
|
|
|
|
style: AppTextStyles.bodyText,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///Need to display other info as well
|
|
|
|
|
|
|
|
// Text(
|
|
|
|
|
|
|
|
// model?.email?.isNotEmpty == true
|
|
|
|
|
|
|
|
// ? model!.email!
|
|
|
|
|
|
|
|
// : '',
|
|
|
|
|
|
|
|
// style: AppTextStyles.bodyText,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<Lookup?> showAttachmentTypePicker() {
|
|
|
|
|
|
|
|
return showDialog<Lookup>(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
builder: (_) {
|
|
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
|
|
|
content: SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProvider>(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
title: context.translation.reason,
|
|
|
|
|
|
|
|
showAsFullScreenDialog: false,
|
|
|
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
|
|
|
Navigator.pop(context, value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _cancelTap() async {
|
|
|
|
void _cancelTap() async {
|
|
|
|
@ -469,4 +589,40 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<InspectionPersonModel?> showInspectionBottomSheet(
|
|
|
|
|
|
|
|
BuildContext context, {
|
|
|
|
|
|
|
|
required String title,
|
|
|
|
|
|
|
|
required bool isHmg,
|
|
|
|
|
|
|
|
required InspectionPersonModel initialModel,
|
|
|
|
|
|
|
|
}) {
|
|
|
|
|
|
|
|
return showModalBottomSheet<InspectionPersonModel>(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
builder: (_) {
|
|
|
|
|
|
|
|
if (initialModel.localSignature == null && initialModel.signature != null) {
|
|
|
|
|
|
|
|
initialModel.localSignature = signatureFromString(initialModel.signature);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return InspectionPersonBottomSheet(
|
|
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
|
|
isHmg: isHmg,
|
|
|
|
|
|
|
|
model: InspectionPersonModel(
|
|
|
|
|
|
|
|
name: initialModel.name,
|
|
|
|
|
|
|
|
email: initialModel.email,
|
|
|
|
|
|
|
|
signature: initialModel.signature,
|
|
|
|
|
|
|
|
localSignature: initialModel.localSignature,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Uint8List? signatureFromString(String? value) {
|
|
|
|
|
|
|
|
if (value == null || !value.contains('|')) return null;
|
|
|
|
|
|
|
|
final base64Part = value.split('|').last;
|
|
|
|
|
|
|
|
return base64Decode(base64Part);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|