Update Gas refill issues fixed

main_design2.0
zaid.daoud 2 years ago
parent 5bf73172f6
commit 4f116b1ea4

@ -146,7 +146,7 @@ class GasRefillProvider extends ChangeNotifier {
Map<String, dynamic> body = {
"id": newModel.id,
"gazRefillNo": newModel.gazRefillNo ?? "",
"status": newModel.status.toJson(),
"status": newModel.status?.toJson(),
//"expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate,
if (newModel.timer?.startAt != null) "startDate": newModel.timer.startAt.toIso8601String(),
@ -154,7 +154,7 @@ class GasRefillProvider extends ChangeNotifier {
if (newModel.timer?.endAt != null) "endDate": newModel.timer.endAt.toIso8601String(),
if (newModel.timer?.endAt != null) "endTime": newModel.timer.endAt.toIso8601String(),
// "workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60),
'workingHours': newModel.timer.durationInSecond != null ? newModel.timer.durationInSecond / 60 / 60 : newModel.workingHours,
'workingHours': newModel.timer.durationInSecond != null ? newModel.timer.durationInSecond * 60 * 60 : newModel.workingHours,
"assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(),
"site": hospital?.toMap(),
"building": building?.toJson(includeFloors: false),

@ -107,9 +107,9 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
8.height,
///TBD
context.translation.gasRequest.bodyText(context),
'${context.translation.cylinderSize}: ${gasRefillModel.gazRefillDetails[0].cylinderSize.value}'.bodyText(context),
'${context.translation.site}: ${gasRefillModel.site.name}'.bodyText(context),
'${context.translation.gasRequest}: ${gasRefillModel.gazRefillDetails[0].gasType?.name}'.bodyText(context),
'${context.translation.cylinderSize}: ${gasRefillModel.gazRefillDetails[0].cylinderSize?.name}'.bodyText(context),
'${context.translation.site}: ${gasRefillModel.site?.name}'.bodyText(context),
],
),
1.width.expanded,
@ -117,18 +117,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (_userProvider.user.type == UsersTypes.engineer && (gasRefillModel.status?.value ?? 0) != 2)
CircleAvatar(
radius: 25,
backgroundColor: AppColor.neutral30,
child: CircleAvatar(
radius: 24,
backgroundColor: Colors.white,
child: Padding(
padding: const EdgeInsets.only(left: 3.0),
child: SvgPicture.asset('assets/images/update.svg'),
),
),
).onPress(
"edit".toSvgAsset(height: 48,width: 48).onPress(
() async {
_model?.fromGasRefillModel(gasRefillModel);
// setState(() {});
@ -155,8 +144,8 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
8.height,
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
8.height,
'${context.translation.requestedQuantity}: ${gasRefillModel.gazRefillDetails[0].requestedQty}'.bodyText(context),
'${context.translation.deliveredQuantity}: ${gasRefillModel.gazRefillDetails[0].deliverdQty}'.bodyText(context),
'${context.translation.requestedQuantity}: ${gasRefillModel.gazRefillDetails[0]?.requestedQty ?? 0}'.bodyText(context),
'${context.translation.deliveredQuantity}: ${gasRefillModel.gazRefillDetails[0]?.deliverdQty ?? 0}'.bodyText(context),
8.height,
],
).paddingAll(16),

@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -72,6 +73,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}
_onSubmit(BuildContext context) async {
if (_formModel.status == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.status}");
return false;
}
if (_formModel.timer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
@ -80,7 +85,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
await Fluttertoast.showToast(msg: "Please Stop The Timer");
return false;
}
if (_formModel.gazRefillDetails.isEmpty) {
if (_formModel.gazRefillDetails?.isNotEmpty ?? false) {
if (!(await _addNewModel(context))) return;
}
@ -121,14 +126,16 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
return false;
}
_formKey.currentState.save();
_currentDetails.gasType = _formModel.gazRefillDetails[0].gasType;
_currentDetails.cylinderSize = _formModel.gazRefillDetails[0].cylinderSize;
_currentDetails.cylinderType = _formModel.gazRefillDetails[0].cylinderType;
if (!(await _currentDetails.validate(context))) {
setState(() {});
return false;
}
_formModel.gazRefillDetails.insert(0, _currentDetails);
_formModel.gazRefillDetails[0].deliverdQty = _currentDetails.deliverdQty;
_validate = false;
Scrollable.ensureVisible(_DetailsKey.currentContext);
// Scrollable.ensureVisible(_DetailsKey.currentContext);
_deliveredQuantityController.clear();
_workingHoursController.clear();
_commentController.clear();
@ -159,7 +166,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
//_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = DateTime.tryParse(_formModel.expectedDate ?? "");
_formModel.timer = TimerModel(startAt: DateTime.tryParse(widget.gasRefillModel?.startDate ?? ""), endAt: DateTime.tryParse(widget.gasRefillModel?.endDate ?? ""));
_clientName = _formModel.site.custName;
_clientName = _formModel.site?.custName;
} else {
_formModel.timer = null;
_clientName = _userProvider.user?.clientName;
@ -200,10 +207,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
8.height,
/// TBD
'${context.translation.gasRequest}:'.bodyText(context),
'${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}'.bodyText(context),
'${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}'.bodyText(context),
'${context.translation.site}: ${widget.gasRefillModel.site.name}'.bodyText(context),
'${context.translation.gasRequest}: ${widget.gasRefillModel.gazRefillDetails[0].gasType.name}'.bodyText(context),
'${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.name}'.bodyText(context),
'${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty ?? 0}'.bodyText(context),
'${context.translation.site}: ${widget.gasRefillModel.site?.name}'.bodyText(context),
],
).toShadowContainer(context),
8.height,
@ -227,6 +234,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
),
8.height,
AppTextFormField(
initialValue: _formModel.gazRefillDetails[0]?.deliverdQty?.toString(),
labelText: context.translation.deliveredQuantity,
onSaved: (value) {
_currentDetails?.deliverdQty = double.tryParse(value);

Loading…
Cancel
Save