|
|
|
|
@ -4,12 +4,14 @@ import 'dart:io';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/validator/validator.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
|
import 'package:test_sa/models/device/asset.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
|
@ -28,6 +30,7 @@ import 'package:test_sa/modules/loan_module/models/loan_form_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/loan_period_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/loan_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/loan_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/medical_department_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';
|
|
|
|
|
@ -47,8 +50,9 @@ import '../../../models/new_models/department.dart';
|
|
|
|
|
|
|
|
|
|
class CreateLoanRequestView extends StatefulWidget {
|
|
|
|
|
static const String id = "/create-loan";
|
|
|
|
|
int? workOrderId;
|
|
|
|
|
|
|
|
|
|
const CreateLoanRequestView({Key? key}) : super(key: key);
|
|
|
|
|
CreateLoanRequestView({Key? key, this.workOrderId}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_CreateLoanRequestViewState createState() => _CreateLoanRequestViewState();
|
|
|
|
|
@ -61,14 +65,16 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
Asset? device;
|
|
|
|
|
TaskType? selectedType;
|
|
|
|
|
final LoanFormModel _loanFormModel = LoanFormModel();
|
|
|
|
|
bool isEng = true;
|
|
|
|
|
|
|
|
|
|
TextEditingController commentController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
bool get isBackUpRequest => widget.workOrderId != null;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// TODO: implement initState
|
|
|
|
|
super.initState();
|
|
|
|
|
Provider.of<MedicalDepartmentProvider>(context, listen: false).reset();
|
|
|
|
|
Provider.of<LoanPeriodProvider>(context, listen: false).reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -81,33 +87,36 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
// if(isEng)...[
|
|
|
|
|
// scanAssetButton(),
|
|
|
|
|
if (isBackUpRequest) ...[
|
|
|
|
|
scanAssetButton(),
|
|
|
|
|
16.height,
|
|
|
|
|
],
|
|
|
|
|
// ...contactInfoSection(),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// ],
|
|
|
|
|
contactInfoSection(),
|
|
|
|
|
...itemDetailsSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
itemDetailsSection(),
|
|
|
|
|
...doctorInfoSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
...vendorDetailsSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
vendorDetailsSection(),
|
|
|
|
|
23.height,
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
attachment: attachments,
|
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: context.isDark ? AppColor.primary10 : AppColor.neutral120),
|
|
|
|
|
//verify this if not required delete this ..
|
|
|
|
|
onChange: (attachments) {
|
|
|
|
|
attachments = attachments;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingAll(16),
|
|
|
|
|
).toShadowContainer(context, borderRadius: 20),
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
@ -124,10 +133,8 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget contactInfoSection() {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
List<Widget> contactInfoSection() {
|
|
|
|
|
return [
|
|
|
|
|
context.translation.contactInfo.heading6(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
@ -174,21 +181,82 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget itemDetailsSection() {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'Item Details'.addTranslation.heading6(context).custom(color: AppColor.black10),
|
|
|
|
|
List<Widget> doctorInfoSection() {
|
|
|
|
|
return [
|
|
|
|
|
context.translation.contactInfo.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Doctor 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.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.docName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Doctor Number",
|
|
|
|
|
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.phone,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.docNumber = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Doctor Email",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) {
|
|
|
|
|
return "Mandatory";
|
|
|
|
|
} else {
|
|
|
|
|
return Validator.isEmail(value!) ? null : context.translation.emailValidateMessage;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.docEmail = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> itemDetailsSection() {
|
|
|
|
|
return [
|
|
|
|
|
'Item Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.site,
|
|
|
|
|
initialValue: _loanFormModel.site,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select a site";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
@ -197,25 +265,14 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
//TODO need to check where to get all departments..
|
|
|
|
|
// MultipleItemDropDownMenu<TrafDepartment, DepartmentLookupProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// backgroundColor: AppColor.neutral100,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// showCancel: true,
|
|
|
|
|
// requestById: context.userProvider.user?.clientId,
|
|
|
|
|
// title: "Please specify departments and relations",
|
|
|
|
|
// initialValue: departments,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// departments = value ?? [];
|
|
|
|
|
// trafRequest?.trafDepartments = departments.map((element) => Departments(id: 0, trafId: 0, departmentId: element.id!.toInt())).toList();
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
SingleItemDropDownMenu<MedicalDepartmentModel, MedicalDepartmentProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.department,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select a department";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: _loanFormModel.department,
|
|
|
|
|
requestById: context.userProvider.user?.clientId,
|
|
|
|
|
@ -228,58 +285,81 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Item Description",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.itemDescription = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
"help-circle".toSvgAsset(height: 16, width: 16),
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
"Specify the purpose of the loan (e.g., equipment needed for a scheduled procedure or patient case)",
|
|
|
|
|
style: AppTextStyles.tinyFont2.copyWith(fontWeight: FontWeight.w400, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Request Description",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.requestDescription = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Model",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.model = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Manufacturer",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.manufacturer = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, LoanPeriodProvider>(
|
|
|
|
|
@ -287,6 +367,10 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: 'Loan Period'.addTranslation,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select loan period";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: _loanFormModel.loanProvided,
|
|
|
|
|
@ -298,62 +382,84 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget vendorDetailsSection() {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'Vendor Details'.addTranslation.heading6(context).custom(color: AppColor.black10),
|
|
|
|
|
List<Widget> vendorDetailsSection() {
|
|
|
|
|
return [
|
|
|
|
|
'Vendor Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Name",
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "Vendor Name",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
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,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorRepresentativeName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Number",
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Number",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "Vendor Number",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorNumber = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Email",
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Vendor Email",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) {
|
|
|
|
|
return "Mandatory";
|
|
|
|
|
} else {
|
|
|
|
|
return Validator.isEmail(value!) ? null : context.translation.emailValidateMessage;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
hintText: "Vendor Email",
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_loanFormModel.vendorEmail = value;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget scanAssetButton() {
|
|
|
|
|
@ -369,16 +475,33 @@ class _CreateLoanRequestViewState extends State<CreateLoanRequestView> with Tick
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _submit() async {
|
|
|
|
|
if (isBackUpRequest && device == null) {
|
|
|
|
|
"Please scan or pick asset".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
|
|
|
|
|
|
_loanFormModel?.loanAttachment = [];
|
|
|
|
|
_loanFormModel.loanAttachment = [];
|
|
|
|
|
for (var item in attachments) {
|
|
|
|
|
String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
_loanFormModel?.loanAttachment?.add(LoanAttachments(id: item.id, name: fileName));
|
|
|
|
|
_loanFormModel.loanAttachment?.add(LoanAttachments(id: item.id, name: fileName));
|
|
|
|
|
}
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);
|
|
|
|
|
// await loanProvider.addLoanRequest(context: context, task: _loanFormModel!);
|
|
|
|
|
Map<String, dynamic> body = _loanFormModel.toJson();
|
|
|
|
|
body["id"] = 0;
|
|
|
|
|
body["requestorUserID"] = context.userProvider.user!.userID;
|
|
|
|
|
|
|
|
|
|
if (isBackUpRequest) {
|
|
|
|
|
body["assetId"] = device!.id;
|
|
|
|
|
body["cMWOItemId"] = widget.workOrderId;
|
|
|
|
|
}
|
|
|
|
|
bool isSuccess = await loanProvider.addLoanRequest(body);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|