From a498a229d17400669629c32a7a56548e095b7d29 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 12 Dec 2024 11:55:03 +0300 Subject: [PATCH] install and return qty added on spare part edit. --- lib/l10n/app_ar.arb | 2 + lib/l10n/app_en.arb | 2 + .../spare_part/activity_spare_part_model.dart | 6 ++ lib/new_views/pages/land_page/land_page.dart | 12 ++-- .../land_page/non_hmg_employee_view.dart | 0 .../forms/spare_part/spare_part_request.dart | 60 ++++++++++++++++++- pubspec.lock | 56 +++++++++++++++++ pubspec.yaml | 2 + 8 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 lib/new_views/pages/land_page/non_hmg_employee_view.dart diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index c639d9d6..1c26a336 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -238,6 +238,8 @@ "otpSentToNumber": "تم إرسال رمز التحقق إلى الرقم", "havingTroubleReceivingOtp": "تواجه صعوبة في استلام رمز التحقق؟", "quantity": "كمية", + "installedQty": "الكمية المثبتة", + "returnQty": "كمية العودة", "oracleNo": "رقم أوراكل", "no": "لا", "yes": "نعم", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 6513c04c..0792944f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -217,6 +217,8 @@ "operatingHours": "Operating Hours", "partName": "Part Name", "quantity": "Quantity", + "installedQty": "Installed Qty", + "returnQty": "Return Qty", "oracleNo": "Oracle No.", "reasons": "Reasons", "addSparePartActionHeading": "Do you want to create another spare part request?", diff --git a/lib/models/helper_data_models/spare_part/activity_spare_part_model.dart b/lib/models/helper_data_models/spare_part/activity_spare_part_model.dart index 49c437ab..1c51821f 100644 --- a/lib/models/helper_data_models/spare_part/activity_spare_part_model.dart +++ b/lib/models/helper_data_models/spare_part/activity_spare_part_model.dart @@ -9,6 +9,8 @@ class SparePartHelperModel { SparePart? sparePart; Lookup? activityStatus; num? quantity; + num? installQty; + num? returnQty; String? comment; List? sparePartAttachments; @@ -17,6 +19,8 @@ class SparePartHelperModel { this.workOrderId, this.partCatalogItemId, this.quantity, + this.installQty, + this.returnQty, this.sparePart, this.activityStatusId, this.activityStatus, @@ -30,6 +34,8 @@ class SparePartHelperModel { data['workOrderId'] = workOrderId; data['partCatalogItemId'] = sparePart?.id; data['quantity'] = quantity; + data['installQty'] = installQty; + data['returnQty'] = returnQty; if(activityStatus!=null){ data['activityStatusId'] = activityStatus?.id; } diff --git a/lib/new_views/pages/land_page/land_page.dart b/lib/new_views/pages/land_page/land_page.dart index 7317beea..24595584 100644 --- a/lib/new_views/pages/land_page/land_page.dart +++ b/lib/new_views/pages/land_page/land_page.dart @@ -106,8 +106,8 @@ class _LandPageState extends State { })), // const old_page.LandPage(), const MyRequestsPage(), - if(_userProvider!.user!.type != UsersTypes.engineer) const SizedBox(), - // if (_userProvider!.user!.type != UsersTypes.engineer) const CalendarPage(), + if (_userProvider!.user!.type != UsersTypes.engineer) const SizedBox(), + // if (_userProvider!.user!.type != UsersTypes.engineer) const CalendarPage(), const MyAssetsPage(fromBottomBar: true), ]; checkLocalAuth(); @@ -135,23 +135,21 @@ class _LandPageState extends State { selectedIndex: currentPageIndex, onPressed: (index) { bool isEngineer = _userProvider!.user!.type == UsersTypes.engineer; - if (!isEngineer&& index == 2) { + if (!isEngineer && index == 2) { showModalBottomSheet( context: context, useSafeArea: true, backgroundColor: Colors.white, builder: (context) => const CreateRequestTypeBottomSheet(), ); - } - else if (index == (!isEngineer ? 4 : 3)) { + } else if (index == (!isEngineer ? 4 : 3)) { showModalBottomSheet( context: context, useSafeArea: true, backgroundColor: Colors.transparent, builder: (context) => const ContactUsBottomSheet(), ); - } - else { + } else { setState(() { currentPageIndex = index; }); diff --git a/lib/new_views/pages/land_page/non_hmg_employee_view.dart b/lib/new_views/pages/land_page/non_hmg_employee_view.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/service_request_latest/views/forms/spare_part/spare_part_request.dart b/lib/service_request_latest/views/forms/spare_part/spare_part_request.dart index 03e97d9d..8b779152 100644 --- a/lib/service_request_latest/views/forms/spare_part/spare_part_request.dart +++ b/lib/service_request_latest/views/forms/spare_part/spare_part_request.dart @@ -45,10 +45,13 @@ class _SparePartRequestState extends State with TickerProvider final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); final TextEditingController _partQtyController = TextEditingController(); + final TextEditingController _installQtyController = TextEditingController(); + final TextEditingController _returnQtyController = TextEditingController(); final TextEditingController _oracleNoController = TextEditingController(); final TextEditingController _descriptionController = TextEditingController(); Lookup statusLookup = Lookup.fromJson({"id": 5619, "name": "New", "value": 1}); + int? activityStatus; @override void initState() { @@ -61,14 +64,18 @@ class _SparePartRequestState extends State with TickerProvider sparePartAttachments: _requestDetailProvider?.sparePartHelperModel?.sparePartAttachments ?? [], sparePart: _requestDetailProvider?.sparePartHelperModel?.sparePart ?? SparePart(), quantity: _requestDetailProvider?.sparePartHelperModel?.quantity, + installQty: _requestDetailProvider?.sparePartHelperModel?.installQty, + returnQty: _requestDetailProvider?.sparePartHelperModel?.returnQty, activityStatusId: _requestDetailProvider?.sparePartHelperModel?.activityStatusId ?? statusLookup.id, activityStatus: _requestDetailProvider?.sparePartHelperModel?.activityStatus ?? statusLookup, comment: _requestDetailProvider?.sparePartHelperModel?.comment ?? '', ); - _partQtyController.text = _requestDetailProvider?.sparePartHelperModel?.quantity != null ? _requestDetailProvider!.sparePartHelperModel!.quantity.toString() : ''; + _partQtyController.text = _requestDetailProvider?.sparePartHelperModel?.quantity != null ? _requestDetailProvider!.sparePartHelperModel!.quantity!.round().toString() : ''; + _installQtyController.text = _requestDetailProvider?.sparePartHelperModel?.installQty != null ? _requestDetailProvider!.sparePartHelperModel!.installQty!.round().toString() : ''; + _returnQtyController.text = _requestDetailProvider?.sparePartHelperModel?.returnQty != null ? _requestDetailProvider!.sparePartHelperModel!.returnQty!.round().toString() : ''; _oracleNoController.text = _requestDetailProvider?.sparePartHelperModel?.sparePart?.oracleCode != null ? _requestDetailProvider!.sparePartHelperModel!.sparePart!.oracleCode! : ''; _descriptionController.text = _requestDetailProvider?.sparePartHelperModel?.comment != null ? _requestDetailProvider!.sparePartHelperModel!.comment! : ''; - + activityStatus = _requestDetailProvider?.sparePartHelperModel?.activityStatus?.value; scheduleMicrotask(() async { _isLoading = true; _files = _requestDetailProvider?.sparePartHelperModel?.sparePartAttachments?.map((e) => MultiFilesPickerModel(e.id!, File(e.name!))).toList() ?? []; @@ -83,6 +90,8 @@ class _SparePartRequestState extends State with TickerProvider void restValues({required ServiceRequestDetailProvider requestDetailProvider}) { requestDetailProvider.sparePartHelperModel = SparePartHelperModel(id: 0, workOrderId: _requestDetailProvider?.currentWorkOrder?.data?.requestId, sparePartAttachments: []); _partQtyController.clear(); + _installQtyController.clear(); + _returnQtyController.clear(); _oracleNoController.clear(); _descriptionController.clear(); _files = []; @@ -91,6 +100,8 @@ class _SparePartRequestState extends State with TickerProvider @override void dispose() { _partQtyController.dispose(); + _installQtyController.dispose(); + _returnQtyController.dispose(); _oracleNoController.dispose(); _descriptionController.dispose(); super.dispose(); @@ -103,6 +114,7 @@ class _SparePartRequestState extends State with TickerProvider @override Widget build(BuildContext context) { + bool showInstallAndReturnQty = activityStatus == 3 || activityStatus == 4; return Scaffold( key: _scaffoldKey, appBar: DefaultAppBar(title: context.translation.sparePartRequest), @@ -172,6 +184,50 @@ class _SparePartRequestState extends State with TickerProvider }, ), 12.height, + if(showInstallAndReturnQty) ...[ + AppTextFormField( + controller: _installQtyController, + labelText: context.translation.quantity, + textInputType: TextInputType.number, + labelStyle: AppTextStyles.textFieldLabelStyle, + showWithoutDecoration: true, + backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, + enable: requestDetailProvider.sparePartHelperModel?.sparePart?.id != null, + validator: (value) => value == null || value.isEmpty + ? context.translation.requiredField + : Validator.isNumeric(value) + ? null + : context.translation.onlyNumbers, + onChange: (value) { + requestDetailProvider.sparePartHelperModel?.installQty = num.tryParse(value ?? ""); + }, + onSaved: (text) { + requestDetailProvider.sparePartHelperModel?.installQty = num.tryParse(text ?? ""); + }, + ), + 12.height, + AppTextFormField( + controller: _returnQtyController, + labelText: context.translation.quantity, + textInputType: TextInputType.number, + labelStyle: AppTextStyles.textFieldLabelStyle, + showWithoutDecoration: true, + backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, + enable: requestDetailProvider.sparePartHelperModel?.sparePart?.id != null, + validator: (value) => value == null || value.isEmpty + ? context.translation.requiredField + : Validator.isNumeric(value) + ? null + : context.translation.onlyNumbers, + onChange: (value) { + requestDetailProvider.sparePartHelperModel?.returnQty = num.tryParse(value ?? ""); + }, + onSaved: (text) { + requestDetailProvider.sparePartHelperModel?.returnQty = num.tryParse(text ?? ""); + }, + ), + 12.height, + ], AppTextFormField( labelStyle: AppTextStyles.textFieldLabelStyle, controller: _oracleNoController, diff --git a/pubspec.lock b/pubspec.lock index 74d2d527..d697b8e8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -573,6 +573,54 @@ packages: url: "https://pub.dev" source: hosted version: "10.7.0" + geolocator: + dependency: "direct main" + description: + name: geolocator + sha256: "5c23f3613f50586c0bbb2b8f970240ae66b3bd992088cf60dd5ee2e6f7dde3a8" + url: "https://pub.dev" + source: hosted + version: "9.0.2" + geolocator_android: + dependency: transitive + description: + name: geolocator_android + sha256: "7aefc530db47d90d0580b552df3242440a10fe60814496a979aa67aa98b1fd47" + url: "https://pub.dev" + source: hosted + version: "4.6.1" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + sha256: "6154ea2682563f69fc0125762ed7e91e7ed85d0b9776595653be33918e064807" + url: "https://pub.dev" + source: hosted + version: "2.3.8+1" + geolocator_platform_interface: + dependency: transitive + description: + name: geolocator_platform_interface + sha256: "386ce3d9cce47838355000070b1d0b13efb5bc430f8ecda7e9238c8409ace012" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + geolocator_web: + dependency: transitive + description: + name: geolocator_web + sha256: "102e7da05b48ca6bf0a5bda0010f886b171d1a08059f01bfe02addd0175ebece" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + sha256: "4f4218f122a6978d0ad655fa3541eea74c67417440b09f0657238810d5af6bdc" + url: "https://pub.dev" + source: hosted + version: "0.1.3" get: dependency: transitive description: @@ -629,6 +677,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + huawei_location: + dependency: "direct main" + description: + name: huawei_location + sha256: db937f0df4073ba6f3cdc1005855ee231aaf6bf5c2bd05a702d928d7e8bb4ee9 + url: "https://pub.dev" + source: hosted + version: "6.12.0+303" huawei_push: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4125a975..8d591cec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -87,6 +87,8 @@ dependencies: local_auth: ^2.3.0 google_api_availability: ^5.0.0 huawei_push: ^6.5.0+300 + huawei_location: ^6.11.0+301 + geolocator: ^9.0.2 local_auth_darwin: any dev_dependencies: