diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index 6179ac8f..eb4d129f 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -548,5 +548,6 @@ "rejectionDetails": "تفاصيل الرفض", "part": "جزء", "creationDate": "تاريخ الإنشاء", - "transferType": "نوع النقل" + "transferType": "نوع النقل", + "createdBy": "تم الإنشاء بواسطة" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 70c91225..2bd2e511 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -548,5 +548,6 @@ "since": "Since", "rejectionDetails": "Rejection Details", "part": "Part", - "creationDate": "Creation Date" + "creationDate": "Creation Date", + "createdBy": "Created BY" } \ No newline at end of file diff --git a/lib/models/device/device_transfer.dart b/lib/models/device/device_transfer.dart index b850cd53..3886b9a5 100644 --- a/lib/models/device/device_transfer.dart +++ b/lib/models/device/device_transfer.dart @@ -1,6 +1,3 @@ -import 'package:flutter/src/widgets/framework.dart'; -import 'package:fluttertoast/fluttertoast.dart'; -import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/new_models/assistant_employee.dart'; @@ -49,6 +46,7 @@ class DeviceTransfer { this.receiverEngSignature, this.receiverAttachments, this.assetTransferAttachments, + this.assetTransferContactPersons, this.attachments, this.assetNumber, this.assetName, @@ -134,6 +132,12 @@ class DeviceTransfer { assetTransferAttachments?.add(AssetTransferAttachment.fromJson(v)); }); } + if (json['assetTransferContactPersons'] != null) { + assetTransferContactPersons = []; + json['assetTransferContactPersons'].forEach((v) { + assetTransferContactPersons?.add(AssetTransferContactPerson.fromJson(v)); + }); + } receiverAssignedEmployeeId = json['receiverAssignedEmployeeId']; receiverMachineStatusId = json['receiverMachineStatusId']; receiverMachineStatusValue = json['receiverMachineStatusValue']; @@ -299,9 +303,8 @@ class DeviceTransfer { List? timerModelList = []; List? assistantEmployees; List? assetTransferAssistantEmployeesSender; - List? assetTransferAssistantEmployeesReceiver; - + List? assetTransferContactPersons; AssetTransferAssistantEmployees? modelAssistantEmployees; TimerModel? tbsTimer = TimerModel(); @@ -693,32 +696,33 @@ class DeviceTransfer { manufacturerName = assetTransfer.manufacturerName; senderVisitTimers = assetTransfer.senderVisitTimers; receiverVisitTimers = assetTransfer.receiverVisitTimers; - assetTransferAttachments=assetTransfer.assetTransferAttachments; + assetTransferAttachments = assetTransfer.assetTransferAttachments; assetTransferAssistantEmployeesReceiver = assetTransfer.assetTransferAssistantEmployeesReceiver; assetTransferAssistantEmployeesSender = assetTransfer.assetTransferAssistantEmployeesSender; senderMachineStatusValue = assetTransfer.senderMachineStatusValue; receiverMachineStatusValue = assetTransfer.receiverMachineStatusValue; + assetTransferContactPersons = assetTransfer.assetTransferContactPersons; } - // - // Future validate(BuildContext context) async { - // if (assetId == null) { - // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.device}"); - // return false; - // } else if (destSiteId == null) { - // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.destinationSite}"); - // return false; - // } else if (destBuildingId == null) { - // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.building}"); - // return false; - // } else if (destFloorId == null) { - // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.floor}"); - // return false; - // } else if (destDepartmentId == null) { - // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.department}"); - // return false; - // } - // return true; - // } +// +// Future validate(BuildContext context) async { +// if (assetId == null) { +// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.device}"); +// return false; +// } else if (destSiteId == null) { +// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.destinationSite}"); +// return false; +// } else if (destBuildingId == null) { +// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.building}"); +// return false; +// } else if (destFloorId == null) { +// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.floor}"); +// return false; +// } else if (destDepartmentId == null) { +// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.department}"); +// return false; +// } +// return true; +// } } class AssetTransferAssistantEmployees { @@ -759,3 +763,47 @@ class AssetTransferAssistantEmployees { return data; } } + +class AssetTransferContactPerson { + int? id; + String? employeeId; + String? employeeNumber; + String? employeeName; + String? email; + String? mobileNo; + String? extension; + + AssetTransferContactPerson({ + this.id, + this.employeeId, + this.employeeNumber, + this.employeeName, + this.email, + this.mobileNo, + this.extension, + }); + + factory AssetTransferContactPerson.fromJson(Map json) { + return AssetTransferContactPerson( + id: json['id'], + employeeId: json['employeeId'], + employeeNumber: json['employeeNumber'], + employeeName: json['employeeName'], + email: json['email'], + mobileNo: json['mobileNo'], + extension: json['extension'], + ); + } + + Map toJson() { + return { + 'id': id, + 'employeeId': employeeId, + 'employeeNumber': employeeNumber, + 'employeeName': employeeName, + 'email': email, + 'mobileNo': mobileNo, + 'extension': extension, + }; + } +} diff --git a/lib/views/pages/device_transfer/device_transfer_details.dart b/lib/views/pages/device_transfer/device_transfer_details.dart index 858c4b93..e001cddd 100644 --- a/lib/views/pages/device_transfer/device_transfer_details.dart +++ b/lib/views/pages/device_transfer/device_transfer_details.dart @@ -79,6 +79,7 @@ class _DeviceTransferDetailsState extends State { ), _buildTextWidget('${context.translation.requestNo} : ${_model?.transferCode ?? ""}'), _buildTextWidget('${context.translation.transferType} : ${_model?.transferType?.name ?? ""}'), + const Divider().defaultStyle(context), Text( "Asset Info".addTranslation, @@ -91,16 +92,7 @@ class _DeviceTransferDetailsState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Divider().defaultStyle(context), - Text( - "Contact Info".addTranslation, - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - if (_model?.receiverEndUserName != null) _buildTextWidget('${context.translation.receiverName} : ${_model?.receiverEndUserName ?? ""}'), - infoText(label: context.translation.employeeId, value: _model?.employeeId), - infoText(label: context.translation.name, value: _model?.name), - // infoText(label: context.translation.telephone, value: _model?.te), - + _contactInfo(), if ((_model?.comment ?? "").isNotEmpty) ...[ const Divider().defaultStyle(context), Text( @@ -197,14 +189,13 @@ class _DeviceTransferDetailsState extends State { ); } - _buildTextWidget(String text) { return text.bodyText(context); } _internalRequestDetailsCard({StatusLabel? statusLabel}) { bool isCurrentEngineerEligibleForEdit = _model?.senderAssignedEmployeeId == _userProvider!.user?.userID; - bool isCurrentRequestEditAble = (!(_model?.senderMachineStatusValue==3)); + bool isCurrentRequestEditAble = (!(_model?.senderMachineStatusValue == 3)); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -216,17 +207,16 @@ class _DeviceTransferDetailsState extends State { children: [ statusLabel ?? Container(), if (statusLabel != null) 8.height, - ], ), if ((_userProvider!.user?.type == UsersTypes.engineer)) if (isCurrentEngineerEligibleForEdit && isCurrentRequestEditAble) - "edit".toSvgAsset(height: 40, width: 40).onPress(() async { - bool isReload = (await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeviceTransfer(model: _model!, isSender: true)))) as bool; - if (isReload ?? false) { - setState(() {}); - } - }), + "edit".toSvgAsset(height: 40, width: 40).onPress(() async { + bool isReload = (await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeviceTransfer(model: _model!, isSender: true)))) as bool; + if (isReload ?? false) { + setState(() {}); + } + }), ], ), context.translation.details.heading5(context), @@ -237,14 +227,14 @@ class _DeviceTransferDetailsState extends State { infoText(label: "Receiver Building".addTranslation, value: _model?.destBuildingName), infoText(label: "Receiver Floor".addTranslation, value: _model?.destFloorName), infoText(label: "Receiver Department".addTranslation, value: _model?.destDepartmentName), - if (_model!.comment != null && _model!.comment!.isNotEmpty) ...[ + if (_model!.senderComment != null && _model!.senderComment!.isNotEmpty) ...[ 8.height, const Divider().defaultStyle(context), Text( "Technical Comments".addTranslation, style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ), - _buildTextWidget(_model?.comment ?? ''), + _buildTextWidget(_model?.senderComment ?? ''), ] ], ).toShadowContainer(context); @@ -253,8 +243,7 @@ class _DeviceTransferDetailsState extends State { _buildCard({required String site, String? building, String? dept, String? floor, required String comment, required bool isSender, StatusLabel? statusLabel}) { bool isCurrentEngineerEligibleForEdit = isSender ? _model?.senderAssignedEmployeeId == _userProvider!.user?.userID : _model?.receiverAssignedEmployeeId == _userProvider!.user?.userID; - bool isCurrentRequestClosed = - isSender ? ((_model?.senderMachineStatusValue==3)) : ((_model?.receiverMachineStatusValue==3)); + bool isCurrentRequestClosed = isSender ? ((_model?.senderMachineStatusValue == 3)) : ((_model?.receiverMachineStatusValue == 3)); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -302,6 +291,42 @@ class _DeviceTransferDetailsState extends State { ).toShadowContainer(context); } + Widget _contactInfo() { + if (_model?.assetTransferContactPersons != null && _model!.assetTransferContactPersons!.isNotEmpty) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider().defaultStyle(context), + Text( + "Contact Info".addTranslation, + style: AppTextStyles.heading6.copyWith( + color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, + ), + ), + ..._model!.assetTransferContactPersons!.asMap().entries.map((entry) { + final index = entry.key; + final person = entry.value; + final isLast = index == _model!.assetTransferContactPersons!.length - 1; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 8), + infoText(label: context.translation.employeeId, value: person.employeeNumber), + infoText(label: context.translation.name, value: person.employeeName), + infoText(label: context.translation.email, value: person.email), + infoText(label: context.translation.phoneNumber, value: person.mobileNo), + infoText(label: context.translation.extensionNo, value: person.extension), + if (!isLast && _model!.assetTransferContactPersons!.length > 1) const Divider().defaultStyle(context), + ], + ); + }).toList(), + ], + ); + } + return const SizedBox(); + } + Widget infoText({ String? label, String? value, diff --git a/pubspec.lock b/pubspec.lock index 4546b9fd..81272515 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1305,10 +1305,10 @@ packages: dependency: "direct main" description: name: record_mp3_plus - sha256: bf0b3f3ed96227a289ddf71605eb5370e5d43b8a2c17429ec55e60ace03d76e9 + sha256: "654e2eb4ef028c1eaf73b981e9e2abd3756c61b0ee88dc6bc60416c474fbce5d" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" rive: dependency: "direct main" description: