diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index d71e45dc..84c967b7 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -28,7 +28,6 @@ class GasRefillProvider extends ChangeNotifier { building = null; floor = null; department = null; - gasRefillAttachments.clear(); } // state code of current request to defied error message @@ -46,14 +45,6 @@ class GasRefillProvider extends ChangeNotifier { // done _loading = true // failed _loading = false bool isLoading = false; - List _gasRefillAttachments = []; - - List get gasRefillAttachments => _gasRefillAttachments; - - set gasRefillAttachments(List value) { - _gasRefillAttachments = value; - notifyListeners(); - } diff --git a/lib/models/new_models/gas_refill_model.dart b/lib/models/new_models/gas_refill_model.dart index 0750dd33..1c53f2f6 100644 --- a/lib/models/new_models/gas_refill_model.dart +++ b/lib/models/new_models/gas_refill_model.dart @@ -267,7 +267,10 @@ class GasRefillModel { employeeId = model.employeeId; name = model.name; techComment = model.techComment; + gasRefillAttachments = model.gasRefillAttachments; createdDate = model.createdDate; + workingHours = model.workingHours; + gasRefillTimers=model.gasRefillTimers; } GasRefillModel copyWith({ diff --git a/lib/new_views/pages/new_gas_refill_request_page.dart b/lib/new_views/pages/new_gas_refill_request_page.dart index f9f9dadc..e1fb13cf 100644 --- a/lib/new_views/pages/new_gas_refill_request_page.dart +++ b/lib/new_views/pages/new_gas_refill_request_page.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:developer'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -45,6 +46,7 @@ class _NewGasRefillRequestPageState extends State { Lookup? _requestedQuantity; final TextEditingController _commentController = TextEditingController(); GasRefillProvider? _gasRefillProvider; + List _files = []; static List gasQuantity = [ Lookup(name: "1", id: 1, value: 1), @@ -61,13 +63,11 @@ class _NewGasRefillRequestPageState extends State { _gasModel =GasRefillModel(); _currentDetails = GasRefillDetails(); _gasModel = GasRefillModel(gasRefillDetails: []); - _gasRefillProvider!.gasRefillAttachments.clear(); } @override void dispose() { super.dispose(); - _gasRefillProvider!.gasRefillAttachments.clear(); } @override @@ -220,7 +220,7 @@ class _NewGasRefillRequestPageState extends State { 8.height, MultiFilesPicker( label: context.translation.attachFiles, - files: _gasRefillProvider!.gasRefillAttachments, + files:_files, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -243,7 +243,7 @@ class _NewGasRefillRequestPageState extends State { _gasModel.gasRefillDetails=[]; _gasModel.gasRefillDetails?.add(_currentDetails); _gasModel.gasRefillAttachments = []; - for (var item in _gasRefillProvider!.gasRefillAttachments) { + for (var item in _files) { _gasModel.gasRefillAttachments?.add(GasRefillAttachments( id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); } diff --git a/lib/views/pages/device_transfer/update_device_transfer.dart b/lib/views/pages/device_transfer/update_device_transfer.dart index 7e4071dd..7585da18 100644 --- a/lib/views/pages/device_transfer/update_device_transfer.dart +++ b/lib/views/pages/device_transfer/update_device_transfer.dart @@ -687,6 +687,7 @@ class _AssistantEmployeeCardState extends State { if (employee == null) { widget.formModel?.assistantEmployees = []; } else { + selectedEmployee = employee; widget.formModel?.assistantEmployees = [employee.copyWith(id: 0)]; widget.formModel?.modelAssistantEmployees?.employeeId = employee.user?.id; } diff --git a/lib/views/pages/user/gas_refill/gas_refill_form.dart b/lib/views/pages/user/gas_refill/gas_refill_form.dart index a03281e2..ebe2ceb1 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_form.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_form.dart @@ -69,6 +69,7 @@ class _GasRefillFormState extends State { bool _firstTime = true; Lookup? _deliveredQuantity; + List _attachments = []; static List deliveredQuantity = [ Lookup(name: "1", id: 1, value: 1), @@ -86,9 +87,8 @@ class _GasRefillFormState extends State { if (widget.gasRefillModel != null) { _formModel.fromGasRefillModel(widget.gasRefillModel!); - // totalWorkingHours = - // _formModel?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0; - + totalWorkingHours = + _formModel.gasRefillTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDate!).difference(DateTime.parse(item.startDate!)).inSeconds) ?? 0; _commentController.text = _formModel.techComment ?? ""; try { _deliveredQuantity = deliveredQuantity.singleWhere((element) => element.value == _formModel.gasRefillDetails![0].deliverdQty); @@ -96,8 +96,7 @@ class _GasRefillFormState extends State { } catch (ex) {} } if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) { - _gasRefillProvider?.gasRefillAttachments = []; - _gasRefillProvider?.gasRefillAttachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList()); + _attachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList()); } } @@ -138,7 +137,7 @@ class _GasRefillFormState extends State { ); }); _formModel.gasRefillAttachments = []; - for (var item in _gasRefillProvider!.gasRefillAttachments) { + for (var item in _attachments) { _formModel.gasRefillAttachments ?.add(GasRefillAttachments(id: 0,gasRefillId: _formModel.id??0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); } @@ -263,7 +262,7 @@ class _GasRefillFormState extends State { // : context.translation.onlyNumbers, // ), // 8.height, - _timerWidget(context, _formModel.workingHours ?? 0), + _timerWidget(context, totalWorkingHours ?? 0), 8.height, // SingleItemDropDownMenu( // context: context, @@ -301,7 +300,7 @@ class _GasRefillFormState extends State { 16.height, MultiFilesPicker( label: context.translation.attachFiles, - files: _gasRefillProvider!.gasRefillAttachments, + files: _attachments, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),