|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/all_requests_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';
|
|
|
|
|
@ -145,25 +145,6 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
// 8.height,
|
|
|
|
|
// 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: _medicalGasFormModel.department,
|
|
|
|
|
// requestById: context.userProvider.user?.clientId,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// _medicalGasFormModel.department = value;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
SingleItemDropDownMenu<MedicalGasSupplierModel, MedicalGasSupplierProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.supplier,
|
|
|
|
|
@ -171,6 +152,10 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select a supplier";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_medicalGasFormModel.supplier = value;
|
|
|
|
|
@ -178,7 +163,6 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
setGasInfo();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
if (medicalGasInfo != null) medicalGasInfoWidget(),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, borderRadius: 20),
|
|
|
|
|
@ -256,7 +240,22 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: model.requestedQuantity != null ? model.requestedQuantity.toString() : '',
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
enable: true,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null || value.trim().isEmpty) {
|
|
|
|
|
return "This field is required";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final intVal = int.tryParse(value);
|
|
|
|
|
if (intVal == null) {
|
|
|
|
|
return "Enter a valid number";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (intVal <= 0) {
|
|
|
|
|
return "Value must be greater than 0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
@ -274,6 +273,8 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _update({bool isSubmitted = false}) async {
|
|
|
|
|
if (!_formKey.currentState!.validate()) return;
|
|
|
|
|
_formKey.currentState?.save();
|
|
|
|
|
if (medicalGasInfo != null && medicalGasInfo!.attributeInfo!.isNotEmpty) {
|
|
|
|
|
_medicalGasFormModel.gasRequestDetail = [];
|
|
|
|
|
for (var item in medicalGasInfo!.attributeInfo!) {
|
|
|
|
|
@ -284,15 +285,19 @@ class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPag
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_medicalGasFormModel.isSubmitted = isSubmitted;
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
await medicalGasInspectionProvider.saveMedicalGas(model: _medicalGasFormModel).then((status) async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (status) {
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
AllRequestsProvider allRequestsProvider = Provider.of<AllRequestsProvider>(context, listen: false);
|
|
|
|
|
allRequestsProvider.reset();
|
|
|
|
|
await allRequestsProvider.getAllRequests(context, typeTransaction: 14);
|
|
|
|
|
} else {
|
|
|
|
|
//This should be handled from backend.
|
|
|
|
|
Fluttertoast.showToast(msg: 'No gas available for selected site', toastLength: Toast.LENGTH_LONG);
|
|
|
|
|
Fluttertoast.showToast(msg: 'Something went wrong', toastLength: Toast.LENGTH_LONG);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|