|
|
|
|
@ -15,6 +15,8 @@ import 'package:test_sa/models/new_models/mapped_sites.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/task_request/task_type_model.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/traf_department.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/models/loan_form_model.dart';
|
|
|
|
|
@ -28,6 +30,7 @@ import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart
|
|
|
|
|
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/providers/lookups/department_lookup_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/work_order/vendor_provider.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
|
|
|
|
import '../../../../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
|
|
|
|
|
@ -47,9 +50,11 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
TaskType? selectedType;
|
|
|
|
|
final LoanFormModel _loanFormModel = LoanFormModel();
|
|
|
|
|
final LoanFormModel _loanFormModel = LoanFormModel(isNewVendor: false);
|
|
|
|
|
|
|
|
|
|
TextEditingController commentController = TextEditingController();
|
|
|
|
|
TextEditingController vendorPhoneController = TextEditingController();
|
|
|
|
|
TextEditingController vendorEmailController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
bool get isBackUpRequest => widget.workOrderId != null;
|
|
|
|
|
|
|
|
|
|
@ -62,14 +67,21 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
|
|
|
|
|
Provider.of<LoanPeriodProvider>(context, listen: false).reset();
|
|
|
|
|
loanTypes = [Lookup(id: 0, name: "Standard", value: 1), Lookup(id: 1, name: "Backup", value: 2)];
|
|
|
|
|
|
|
|
|
|
if(isBackUpRequest){
|
|
|
|
|
if (isBackUpRequest) {
|
|
|
|
|
fillSiteDeptInfo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fillSiteDeptInfo (){
|
|
|
|
|
_loanFormModel.mappedSite = MappedSite.fromJson(widget.workOrder!.site!.toJson());
|
|
|
|
|
_loanFormModel.mappedDepartment = TrafDepartment.fromJson(widget.workOrder!.department!.toJson());
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
vendorPhoneController.dispose();
|
|
|
|
|
vendorEmailController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fillSiteDeptInfo() {
|
|
|
|
|
_loanFormModel.mappedSite = MappedSite.fromJson(widget.workOrder!.site!.toJson());
|
|
|
|
|
_loanFormModel.mappedDepartment = TrafDepartment.fromJson(widget.workOrder!.department!.toJson());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -291,13 +303,12 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if(value!=null){
|
|
|
|
|
if (value != null) {
|
|
|
|
|
_loanFormModel.mappedSite = value;
|
|
|
|
|
_loanFormModel.mappedDepartment = null;
|
|
|
|
|
Provider.of<DepartmentLookupProvider>(context,listen:false).getData(id:_loanFormModel.mappedSite?.id);
|
|
|
|
|
Provider.of<DepartmentLookupProvider>(context, listen: false).getData(id: _loanFormModel.mappedSite?.id);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
@ -430,44 +441,95 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
|
|
|
|
|
return [
|
|
|
|
|
'Vendor Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Representative Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorRepresentativeName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (!_loanFormModel.isNewVendor) ...[
|
|
|
|
|
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: 'Vendor Name'.addTranslation,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: _loanFormModel.supplier,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select vendor name";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
showShadow: false,
|
|
|
|
|
showCancel: true,
|
|
|
|
|
onSelect: (person) {
|
|
|
|
|
_loanFormModel.supplier = person;
|
|
|
|
|
_loanFormModel.vendorName = person?.name;
|
|
|
|
|
_loanFormModel.supEngineer = null;
|
|
|
|
|
_loanFormModel.vendorRepresentativeName = null;
|
|
|
|
|
vendorPhoneController.text = person?.contact ?? '';
|
|
|
|
|
vendorEmailController.text = person?.email ?? '';
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
backgroundColor: _loanFormModel.supplier?.suppliername == null
|
|
|
|
|
? context.isDark
|
|
|
|
|
? AppColor.neutral20
|
|
|
|
|
: AppColor.neutral40
|
|
|
|
|
: AppColor.fieldBgColor(context),
|
|
|
|
|
title: "Representative Name".addTranslation,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select representative name";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
enabled: _loanFormModel.supplier?.suppPersons?.isNotEmpty ?? false,
|
|
|
|
|
staticData: _loanFormModel.supplier?.suppPersons,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: _loanFormModel.supEngineer == null ? null : SuppPersons.fromJson(_loanFormModel.supEngineer?.toJson()),
|
|
|
|
|
onSelect: (suppPerson) {
|
|
|
|
|
if (suppPerson != null) {
|
|
|
|
|
_loanFormModel.vendorRepresentativeName = suppPerson.name;
|
|
|
|
|
_loanFormModel.supEngineer = SuppEngineerWorkOrders.fromJson(suppPerson.toJson());
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
] else ...[
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Representative Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorRepresentativeName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
controller: vendorPhoneController,
|
|
|
|
|
labelText: "Vendor Number",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
@ -485,7 +547,7 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
controller: vendorEmailController,
|
|
|
|
|
labelText: "Vendor Email",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) {
|
|
|
|
|
|