Compare commits

...

34 Commits

Author SHA1 Message Date
Sikander Saleem 7c6443185d v1.9.6+56 uploaded 3 weeks ago
WaseemAbbasi22 f9f1728abf document type improvements 3 weeks ago
WaseemAbbasi22 bce5691b13 improvements 3 weeks ago
WaseemAbbasi22 08d8bd9304 attachment parameter fixes for sparepart request 3 weeks ago
Sikander Saleem 50df0fb5b8 merge conflict resolve 3 weeks ago
Sikander Saleem 7490544084 Merge branch 'refs/heads/main_production' into main_production_attahment_type
# Conflicts:
#	lib/controllers/api_routes/urls.dart
#	lib/models/helper_data_models/spare_part/activity_spare_part_model.dart
#	lib/models/plan_preventive_visit/plan_preventive_visit_model.dart
#	lib/modules/cm_module/views/forms/spare_part/spare_part_request.dart
3 weeks ago
Sikander Saleem a9000de678 v1.9.5+55 uploaded on stores 4 weeks ago
Sikander Saleem 4218acb4b8 improvement 4 weeks ago
Sikander Saleem 494d9ba8d7 get site by user id replace in asset filters 4 weeks ago
Sikander Saleem 2ab2abd693 site are changed as per organization 4 weeks ago
Sikander Saleem e4a09fed1f improvement 4 weeks ago
Sikander Saleem 072953a3a7 role name added 4 weeks ago
WaseemAbbasi22 85bcc1a0ea Fixed bug ATOMS-2248 2 months ago
Sikander Saleem fa254ca73b improvement 2 months ago
Sikander Saleem 709b8a699b bug 2247 fixed 2 months ago
WaseemAbbasi22 4bdb5c2da3 improvements 2 months ago
Sikander Saleem e1f52b9925 improvement 2 months ago
Sikander Saleem 4ca6862f3b apk provided to QA 2 months ago
Sikander Saleem 3eb1088b94 Merge branch 'refs/heads/main_production' into main_production_attahment_type 2 months ago
Sikander Saleem fac7b92711 improvement. 2 months ago
Sikander Saleem a01f40e20d code merged from main production. 2 months ago
Sikander Saleem 3ebb1d7fab Merge branch 'refs/heads/main_production' into main_production_attahment_type
# Conflicts:
#	lib/main.dart
#	lib/modules/asset_delivery_module/helper_function.dart
#	lib/modules/asset_delivery_module/pages/attachment_view.dart
#	lib/modules/demo_module/demo_request_item_view.dart
#	lib/modules/incident_module/incident_detail_page.dart
2 months ago
Sikander Saleem f3722e3671 improvements 2 months ago
WaseemAbbasi22 2304700fb8 final fixes 2 months ago
WaseemAbbasi22 9f76874217 improvements 2 months ago
WaseemAbbasi22 55f39fadbc improvements 2 months ago
WaseemAbbasi22 448a85522a bug fixes 2 months ago
WaseemAbbasi22 dd644732c9 bug fixes 3 months ago
WaseemAbbasi22 56322d8db3 Add Document Type Lookup for each module 3 months ago
WaseemAbbasi22 392136dbe4 Document library CR completed ready for test 3 months ago
Sikander Saleem 1d4ed83a4b asset open to details screen 3 months ago
Sikander Saleem 9fbb2efa55 improvements 3 months ago
Sikander Saleem 3412345a4a improvements 3 months ago
WaseemAbbasi22 63d4c79a73 document library CR implementation 3 months ago

@ -1,15 +1,15 @@
class URLs {
URLs._();
static const String appReleaseBuildNumber = "54";
static const String appReleaseBuildNumber = "56";
static const host1 = "https://atomsm.hmg.com"; // production url
// static const host1 = "https://atomsmdev.hmg.com"; // local DEV url
// static const host1 = "https://atomsmuat.hmg.com"; // local UAT url
static final String _baseUrl = "$_host/mobile"; // host local UAT
// static final String _baseUrl = "$_host/mobile"; // host local UAT
// static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis
// static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM
static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM
// static final String _baseUrl = "$_host/v4/mobile"; // v4 for Demo module
// static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation
// static final String _baseUrl = "$_host/v6/mobile"; // for asset delivery module
@ -69,6 +69,7 @@ class URLs {
static get getDepartmentsBySites => "$_baseUrl/Customer/GetDepartmentsBySites"; // post get departments by sites
static getUserSites(String userId) => "$_baseUrl/Customer/GetSitesForUser?userId=$userId"; // get user's current sites
static getSitesNotAccessibleForUser(String userId) => "$_baseUrl/Customer/GetSitesNotAccessibleForUser?userId=$userId"; // get user's current sites
static get getCustomersAutoCompleteSameOrg => "$_baseUrl/Customer/GetCustomersAutoCompleteSameOrg"; // get user's current sites
// static get login => "$_baseUrl/MobileAuth/LoginIntegration"; // mobile login
static get register => "$_baseUrl/handle/create/user"; // post
@ -328,6 +329,8 @@ class URLs {
static get genderLookup => "$_baseUrl/Lookups/GetLookup?lookupEnum=3065";
static get getDemoDocumentTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=4106";
// static get getAttachmentTypesLookup => "$_baseUrl/Lookups/GetLookup?lookupEnum=4021";
static get getAttachmentTypesLookup => "$_baseUrl/Lookups/GetLookup";
static get getClassificationTypeLookup => "$_baseUrl/Lookups/GetLookup?lookupEnum=450";
@ -392,6 +395,8 @@ class URLs {
static get updateDeviceTransfer => "$_baseUrl/AssetTransfer/UpdateEngineerAssetTransferNew"; // get
static get assetTransferAssignEngineerToHimself => "$_baseUrl/AssetTransfer/AssignEngineerToHimself"; // get
static get assetTransferEngineerReject => "$_baseUrl/AssetTransfer/EngineerReject"; // get
static get assetDocumentHistory => "$_baseUrl/DocumentLibrary/SearchDocuments";
// employee
static get getEmployees => "$_baseUrl/Lookups/GetLookup?lookupEnum=33"; // get

@ -153,6 +153,7 @@ class DeviceTransferProvider extends ChangeNotifier {
Response response;
try {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
log('payload: ${model.toCreateAssetTransferJson()}');
response = await ApiManager.instance.post(URLs.createAssetTransferRequest, body: model.toCreateAssetTransferJson());
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {

@ -31,6 +31,7 @@ class AssetProvider extends ChangeNotifier {
final pageItemNumber = 10;
final searchPageItemNumber = 10;
final documentPageItemNumber = 20;
bool nextPage = true;
@ -257,4 +258,40 @@ class AssetProvider extends ChangeNotifier {
return false;
}
}
Future<({List<GenericAttachmentModel> documents, int totalRows})> getAssetDocumentHistory({
required int assetId,
int pageNumber = 1,
}) async {
Response response;
List<GenericAttachmentModel> documents = [];
try {
var body = {
"pageSize": documentPageItemNumber,
"pageNumber": pageNumber,
"assetIds": [assetId],
};
response = await ApiManager.instance.post(URLs.assetDocumentHistory, body: body);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
final jsonData = json.decode(response.body);
List attachmentJson = jsonData["data"] ?? [];
int totalRows = jsonData["totalRows"] ?? 0;
documents = attachmentJson
.map<GenericAttachmentModel>((request) =>
GenericAttachmentModel.fromAssetDocumentJson(request))
.toList();
nextPage = documents.length < totalRows;
return (documents: documents, totalRows: totalRows);
}
return (documents: documents, totalRows: 0);
} catch (e) {
log('Error in getAssetDocumentHistory: $e');
return (documents: documents, totalRows: 0);
}
}
}

@ -56,7 +56,7 @@ class DashBoardProvider extends ChangeNotifier {
// Helper method to check if a tab index is UnAssigned
bool isUnassignedTab(int index) {
if (index >= 0 && index < tabs.length) {
return tabs[index].requestType == RequestTypeEnum.unassigned;
return tabs[index].requestType == RequestStatusEnum.unassigned;
}
return false;
}
@ -64,7 +64,7 @@ class DashBoardProvider extends ChangeNotifier {
// Helper method to get the UnAssigned tab index (returns -1 if not found)
int getUnassignedTabIndex() {
for (int i = 0; i < tabs.length; i++) {
if (tabs[i].requestType == RequestTypeEnum.unassigned) {
if (tabs[i].requestType == RequestStatusEnum.unassigned) {
return i;
}
}
@ -111,25 +111,25 @@ class DashBoardProvider extends ChangeNotifier {
DD.DashboardDetail? get requestDetailList => _requestDetailList;
int getStatusCount(RequestTypeEnum requestType) {
int getStatusCount(RequestStatusEnum requestType) {
switch (requestType) {
case RequestTypeEnum.unassigned:
case RequestStatusEnum.unassigned:
return dashboardCount?.data?.countUnAssigned ?? 0;
case RequestTypeEnum.open:
case RequestStatusEnum.open:
return dashboardCount?.data?.countOpen ?? 0;
case RequestTypeEnum.inProgress:
case RequestStatusEnum.inProgress:
return dashboardCount?.data?.countInprogress ?? 0;
case RequestTypeEnum.completed:
case RequestStatusEnum.completed:
return dashboardCount?.data?.countComplete ?? 0;
case RequestTypeEnum.pendingAcknowledgment:
case RequestStatusEnum.pendingAcknowledgment:
return dashboardCount?.data?.countAcknowledge ?? 0;
case RequestTypeEnum.canceled:
case RequestStatusEnum.canceled:
return dashboardCount?.data?.countCanceled ?? 0;
case RequestTypeEnum.closed:
case RequestStatusEnum.closed:
return dashboardCount?.data?.countClose ?? 0;
case RequestTypeEnum.overdue:
case RequestStatusEnum.overdue:
return dashboardCount?.data?.countOverdue ?? 0;
case RequestTypeEnum.highPriority:
case RequestStatusEnum.highPriority:
return dashboardCount?.data?.countHighPriority ?? 0;
default:
return 0;
@ -310,30 +310,30 @@ class DashBoardProvider extends ChangeNotifier {
}
// Status categories (Open, InProgress, Completed, Closed)
if (!tab.isHighPriority && !tab.isOverDue && tab.requestType != RequestTypeEnum.unassigned) {
if (!tab.isHighPriority && !tab.isOverDue && tab.requestType != RequestStatusEnum.unassigned) {
// Map requestType to status value
switch (tab.requestType) {
case RequestTypeEnum.open:
case RequestStatusEnum.open:
if (!statusTransaction.contains(1)) statusTransaction.add(1);
break;
case RequestTypeEnum.inProgress:
case RequestStatusEnum.inProgress:
if (!statusTransaction.contains(2)) statusTransaction.add(2);
break;
case RequestTypeEnum.completed:
case RequestStatusEnum.completed:
if (!statusTransaction.contains(4)) statusTransaction.add(4);
break;
case RequestTypeEnum.closed:
case RequestStatusEnum.closed:
if (!statusTransaction.contains(4)) statusTransaction.add(4);
break;
case RequestTypeEnum.canceled:
case RequestStatusEnum.canceled:
if (!statusTransaction.contains(5)) statusTransaction.add(5);
break;
case RequestTypeEnum.pendingAcknowledgment:
case RequestStatusEnum.pendingAcknowledgment:
if (!statusTransaction.contains(4)) statusTransaction.add(4);
break;
case RequestTypeEnum.unassigned:
case RequestTypeEnum.highPriority:
case RequestTypeEnum.overdue:
case RequestStatusEnum.unassigned:
case RequestStatusEnum.highPriority:
case RequestStatusEnum.overdue:
// These are handled separately above
break;
}
@ -556,7 +556,7 @@ class CategoryTabs {
String label;
int tag;
int id;
RequestTypeEnum requestType;
RequestStatusEnum requestType;
String icon;
Color iconColor;
bool isHighPriority;
@ -568,12 +568,12 @@ class CategoryTabs {
List<CategoryTabs> tabs = [];
if (userType == UsersTypes.engineer) {
// Order: 1-UnAssigned, 2-HighPriority, 3-Overdue, 4-Open, 5-InProgress, 6-Completed
tabs.add(CategoryTabs(label: 'UnAssigned', tag: 1, id: 1, requestType: RequestTypeEnum.unassigned, icon: "dashboard/unassigned", iconColor: AppColor.unassignedStatus(context)));
tabs.add(CategoryTabs(label: context.translation.highPriority, tag: 3, id: 4, requestType: RequestTypeEnum.highPriority, icon: "high_priority", iconColor: AppColor.red30, isHighPriority: true));
tabs.add(CategoryTabs(label: context.translation.overdue, tag: 3, id: 4, requestType: RequestTypeEnum.overdue, icon: "overdue", iconColor: AppColor.yellowIcon(context), isOverDue: true));
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestTypeEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestTypeEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Completed', tag: 3, id: 4, requestType: RequestTypeEnum.completed, icon: "complete_request", iconColor: AppColor.completedColor));
tabs.add(CategoryTabs(label: 'UnAssigned', tag: 1, id: 1, requestType: RequestStatusEnum.unassigned, icon: "dashboard/unassigned", iconColor: AppColor.unassignedStatus(context)));
tabs.add(CategoryTabs(label: context.translation.highPriority, tag: 3, id: 4, requestType: RequestStatusEnum.highPriority, icon: "high_priority", iconColor: AppColor.red30, isHighPriority: true));
tabs.add(CategoryTabs(label: context.translation.overdue, tag: 3, id: 4, requestType: RequestStatusEnum.overdue, icon: "overdue", iconColor: AppColor.yellowIcon(context), isOverDue: true));
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestStatusEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestStatusEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Completed', tag: 3, id: 4, requestType: RequestStatusEnum.completed, icon: "complete_request", iconColor: AppColor.completedColor));
return tabs;
}
@ -584,29 +584,29 @@ class CategoryTabs {
// tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 2));
// tabs.add(CategoryTabs(label: 'Completed', tag: 4, id: 3));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 2, requestType: RequestTypeEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Completed', tag: 4, id: 3, requestType: RequestTypeEnum.completed, icon: "complete_request", iconColor: AppColor.completedColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 2, requestType: RequestStatusEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Completed', tag: 4, id: 3, requestType: RequestStatusEnum.completed, icon: "complete_request", iconColor: AppColor.completedColor));
return tabs;
}
if (userType == UsersTypes.qualityUser) {
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestTypeEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestTypeEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Closed', tag: 3, id: 4, requestType: RequestTypeEnum.closed, icon: "complete_request", iconColor: AppColor.completedColor));
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestStatusEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestStatusEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Closed', tag: 3, id: 4, requestType: RequestStatusEnum.closed, icon: "complete_request", iconColor: AppColor.completedColor));
return tabs;
}
if (userType == UsersTypes.commissioningEngineer) {
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestTypeEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestTypeEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Closed', tag: 3, id: 4, requestType: RequestTypeEnum.closed, icon: "complete_request", iconColor: AppColor.completedColor));
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestStatusEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestStatusEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Closed', tag: 3, id: 4, requestType: RequestStatusEnum.closed, icon: "complete_request", iconColor: AppColor.completedColor));
return tabs;
}
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestTypeEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestTypeEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
tabs.add(CategoryTabs(label: 'Open', tag: 1, id: 2, requestType: RequestStatusEnum.open, icon: "dashboard/open_icon", iconColor: AppColor.openColor));
tabs.add(CategoryTabs(label: 'In Progress', tag: 2, id: 3, requestType: RequestStatusEnum.inProgress, icon: "dashboard/inprogress_icon", iconColor: AppColor.primary10));
// tabs.add(CategoryTabs(label: 'Pending Acknowledgement', tag: 3, id: 1, requestType: RequestTypeEnum.pendingAcknowledgment, icon: "complete_request", iconColor: AppColor.overdueColor));
tabs.add(CategoryTabs(label: 'Acknowledgement', tag: 4, id: 1, requestType: RequestTypeEnum.pendingAcknowledgment, icon: "complete_request", iconColor: AppColor.overdueColor));
tabs.add(CategoryTabs(label: 'Canceled', tag: 6, id: 4, requestType: RequestTypeEnum.canceled, icon: "dashboard/unassigned", iconColor: AppColor.red30));
tabs.add(CategoryTabs(label: 'Acknowledgement', tag: 4, id: 1, requestType: RequestStatusEnum.pendingAcknowledgment, icon: "complete_request", iconColor: AppColor.overdueColor));
tabs.add(CategoryTabs(label: 'Canceled', tag: 6, id: 4, requestType: RequestStatusEnum.canceled, icon: "dashboard/unassigned", iconColor: AppColor.red30));
return tabs;
}
}

@ -147,29 +147,29 @@ class _DashboardViewState extends State<DashboardView> {
}
// Status categories
if (!tab.isHighPriority && !tab.isOverDue && tab.requestType != RequestTypeEnum.unassigned) {
if (!tab.isHighPriority && !tab.isOverDue && tab.requestType != RequestStatusEnum.unassigned) {
switch (tab.requestType) {
case RequestTypeEnum.open:
case RequestStatusEnum.open:
if (!statusTransaction.contains(1)) statusTransaction.add(1);
break;
case RequestTypeEnum.inProgress:
case RequestStatusEnum.inProgress:
if (!statusTransaction.contains(2)) statusTransaction.add(2);
break;
case RequestTypeEnum.completed:
case RequestStatusEnum.completed:
if (!statusTransaction.contains(4)) statusTransaction.add(4);
break;
case RequestTypeEnum.closed:
case RequestStatusEnum.closed:
if (!statusTransaction.contains(4)) statusTransaction.add(4);
break;
case RequestTypeEnum.canceled:
case RequestStatusEnum.canceled:
if (!statusTransaction.contains(5)) statusTransaction.add(5);
break;
case RequestTypeEnum.pendingAcknowledgment:
case RequestStatusEnum.pendingAcknowledgment:
if (!statusTransaction.contains(3)) statusTransaction.add(3);
break;
case RequestTypeEnum.unassigned:
case RequestTypeEnum.highPriority:
case RequestTypeEnum.overdue:
case RequestStatusEnum.unassigned:
case RequestStatusEnum.highPriority:
case RequestStatusEnum.overdue:
break;
}
}

@ -142,18 +142,19 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
children: [
Text(
snapshot.user?.username ?? "",
maxLines: 2,
style: AppTextStyles.heading6.copyWith(color: AppColor.headingTextColor(context), fontSize: context.isTablet() ? 14 : null),
),
Text(
snapshot.user?.type?.name.toCamelCase ?? "",
style: AppTextStyles.bodyText.copyWith(color: AppColor.lightTextColor(context), fontSize: context.isTablet() ? 12 : null),
),
// Text(
// snapshot.user?.roleName ?? "",
// style: AppTextStyles.bodyText.copyWith(color: AppColor.lightTextColor(context), fontSize: context.isTablet() ? 12 : null),
// ),
],
),
),
),
),
const Spacer(),
// const Spacer(),
// Action icons with right-to-left fade animation
SlideTransition(
position: _rightSlideAnimation,

@ -380,7 +380,7 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
});
// Check if this is UnAssigned tab (index 0 for engineer)
bool isUnassignedTab = tabs[index].requestType == RequestTypeEnum.unassigned;
bool isUnassignedTab = tabs[index].requestType == RequestStatusEnum.unassigned;
// Update selection state
requestsProvider.currentListIndex = index;

@ -46,24 +46,24 @@ class RequestsFragment extends StatelessWidget {
List<Widget> listItems = [];
if (context.userProvider.isNurse) {
listItems = [
requestType(data.dashboardCount?.data?.countOpen ?? 0, "dashboard/open_icon", context.translation.open, context, data.isLoading, RequestTypeEnum.open, AppColor.openColor),
requestType(data.dashboardCount?.data?.countInprogress ?? 0, "dashboard/inprogress_icon", context.translation.inProgress, context, data.isLoading, RequestTypeEnum.inProgress,
requestType(data.dashboardCount?.data?.countOpen ?? 0, "dashboard/open_icon", context.translation.open, context, data.isLoading, RequestStatusEnum.open, AppColor.openColor),
requestType(data.dashboardCount?.data?.countInprogress ?? 0, "dashboard/inprogress_icon", context.translation.inProgress, context, data.isLoading, RequestStatusEnum.inProgress,
AppColor.primary10),
requestType(
data.dashboardCount?.data?.countAcknowledge ?? 0, "complete_request", "Acknowledgement", context, data.isLoading, RequestTypeEnum.pendingAcknowledgment, AppColor.overdueColor),
requestType(data.dashboardCount?.data?.countCanceled ?? 0, "dashboard/unassigned", "Canceled", context, data.isLoading, RequestTypeEnum.canceled, AppColor.red30),
data.dashboardCount?.data?.countAcknowledge ?? 0, "complete_request", "Acknowledgement", context, data.isLoading, RequestStatusEnum.pendingAcknowledgment, AppColor.overdueColor),
requestType(data.dashboardCount?.data?.countCanceled ?? 0, "dashboard/unassigned", "Canceled", context, data.isLoading, RequestStatusEnum.canceled, AppColor.red30),
];
} else {
listItems = [
requestType(
data.dashboardCount?.data?.countUnAssigned ?? 0, "dashboard/unassigned", "UnAssigned", context, data.isLoading, RequestTypeEnum.unassigned, AppColor.unassignedStatus(context)),
requestType(data.dashboardCount?.data?.countOpen ?? 0, "dashboard/open_icon", context.translation.open, context, data.isLoading, RequestTypeEnum.open, AppColor.openColor),
requestType(data.dashboardCount?.data?.countInprogress ?? 0, "dashboard/inprogress_icon", context.translation.inProgress, context, data.isLoading, RequestTypeEnum.inProgress,
data.dashboardCount?.data?.countUnAssigned ?? 0, "dashboard/unassigned", "UnAssigned", context, data.isLoading, RequestStatusEnum.unassigned, AppColor.unassignedStatus(context)),
requestType(data.dashboardCount?.data?.countOpen ?? 0, "dashboard/open_icon", context.translation.open, context, data.isLoading, RequestStatusEnum.open, AppColor.openColor),
requestType(data.dashboardCount?.data?.countInprogress ?? 0, "dashboard/inprogress_icon", context.translation.inProgress, context, data.isLoading, RequestStatusEnum.inProgress,
AppColor.primary10),
requestType(
data.dashboardCount?.data?.countComplete ?? 0, "complete_request", context.translation.completed, context, data.isLoading, RequestTypeEnum.completed, AppColor.completedColor),
requestType(data.dashboardCount?.data?.countOverdue ?? 0, "overdue", context.translation.overdue, context, data.isLoading, RequestTypeEnum.overdue, AppColor.yellowIcon(context)),
requestType(data.dashboardCount?.data?.countHighPriority ?? 0, "high_priority", context.translation.highPriority, context, data.isLoading, RequestTypeEnum.highPriority, AppColor.red30),
data.dashboardCount?.data?.countComplete ?? 0, "complete_request", context.translation.completed, context, data.isLoading, RequestStatusEnum.completed, AppColor.completedColor),
requestType(data.dashboardCount?.data?.countOverdue ?? 0, "overdue", context.translation.overdue, context, data.isLoading, RequestStatusEnum.overdue, AppColor.yellowIcon(context)),
requestType(data.dashboardCount?.data?.countHighPriority ?? 0, "high_priority", context.translation.highPriority, context, data.isLoading, RequestStatusEnum.highPriority, AppColor.red30),
];
}
@ -77,7 +77,7 @@ class RequestsFragment extends StatelessWidget {
});
}
Widget requestType(int value, String icon, String title, BuildContext context, bool isLoading, RequestTypeEnum requestType, Color iconColor) {
Widget requestType(int value, String icon, String title, BuildContext context, bool isLoading, RequestStatusEnum requestType, Color iconColor) {
return CustomBadge(
value: isLoading ? 0 : value,
positionR: -4,

@ -197,7 +197,7 @@ enum AssetDeliveryStageEnum {
other,
}
enum RequestTypeEnum {
enum RequestStatusEnum {
unassigned,
open,
inProgress,

@ -7,9 +7,12 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:google_api_availability/google_api_availability.dart';
import 'package:haptic_feedback/haptic_feedback.dart';
import 'package:http/http.dart' as http;
import 'package:nfc_manager/nfc_manager.dart';
import 'package:nfc_manager/nfc_manager_android.dart' show NfcAAndroid, NfcBAndroid;
import 'package:nfc_manager/nfc_manager_ios.dart' show MiFareIos, Iso15693Ios;
import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
import 'package:test_sa/views/widgets/dialogs/confirm_dialog.dart';
@ -193,6 +196,73 @@ class Utils {
);
}
static Future<File?> downloadFile(
String url, {
bool autoOpen = true,
bool showToast = true,
String? authToken,
String? fileName,
}) async {
final client = http.Client();
try {
if (showToast) {
Utils.showToast("Downloading file...", longDuration: false);
}
fileName ??= url.split('/').last.split('?').first;
if (!fileName.contains('.')) {
fileName = 'downloaded_file_${DateTime.now().millisecondsSinceEpoch}.jpg';
}
final request = http.Request('GET', Uri.parse(url));
if (authToken != null) {
request.headers['Authorization'] = 'Bearer $authToken';
}
request.followRedirects = false;
final streamedResponse = await client.send(request);
File? file;
final dir = await getTemporaryDirectory();
if (streamedResponse.statusCode == 302) {
final redirectUrl = streamedResponse.headers['location'];
if (redirectUrl == null) {
throw Exception('302 Redirect missing Location header');
}
final headers = authToken != null ? {'Authorization': 'Bearer $authToken'} : <String, String>{};
final fileResponse = await http.get(Uri.parse(redirectUrl), headers: headers);
if (fileResponse.statusCode == 200) {
file = File('${dir.path}/$fileName');
await file.writeAsBytes(fileResponse.bodyBytes);
} else {
throw Exception('Download from redirect failed: ${fileResponse.statusCode}');
}
}
else if (streamedResponse.statusCode == 200) {
file = File('${dir.path}/$fileName');
await file.writeAsBytes(await streamedResponse.stream.toBytes());
}
else {
throw Exception('Download failed with status: ${streamedResponse.statusCode}');
}
if (showToast) {
Utils.showToast("File downloaded successfully", longDuration: false);
}
if (autoOpen) {
await OpenFile.open(file.path);
}
return file;
} catch (ex) {
if (showToast) {
Utils.showToast("Download failed: ${ex.toString()}");
}
return null;
} finally {
client.close();
}
}
static bool isLocalFile(String path) {
if (path.isEmpty) return false;
return path.startsWith("/") || path.startsWith("file://") || (path.length > 1 && path.substring(1).startsWith(':\\'));
}
//
// static Widget getNoDataWidget(BuildContext context) {
// return Column(

@ -69,6 +69,7 @@ import 'package:test_sa/modules/applicationDemo/providers/application_demo_reque
import 'package:test_sa/modules/applicationDemo/screens/application_demo_request_form_screen.dart';
import 'package:test_sa/modules/tm_module/gas_refill/create_gas_refill_request.dart';
import 'package:test_sa/modules/tm_module/gas_refill/update_gas_refill_request.dart';
import 'package:test_sa/modules/traf_module/create_traf_request_page.dart';
import 'package:test_sa/modules/traf_module/traf_request_provider.dart';
import 'package:test_sa/new_views/app_style/app_themes.dart';
import 'package:test_sa/new_views/pages/help_center_page.dart';
@ -148,7 +149,6 @@ import 'modules/tm_module/device_transfer/device_filter_screen.dart';
import 'modules/tm_module/device_transfer/device_search_screen.dart';
import 'modules/tm_module/tasks/create_task_view.dart';
import 'modules/tm_module/gas_refill/gas_refill_request_form.dart';
import 'modules/traf_module/create_traf_request_page.dart';
import 'modules/traf_module/update_traf_request_page.dart';
import 'providers/lookups/classification_lookup_provider.dart';
import 'providers/lookups/customer_lookup_provider.dart';
@ -258,6 +258,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => EndUserStatusLookupProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => EndUserRejectionReasonLookupProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => AttachmentTypeLookupProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => AttachmentTypeLookupProviderLatest(), lazy: true),
ChangeNotifierProvider(create: (_) => DemoPeriodLookupProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => DemoDocumentLookupProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => IncidentStatusLookupProvider(), lazy: true),
@ -357,6 +358,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => DepartmentProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => DepartmentBySitesProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => SiteProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => SameOrgSiteProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => MappedSiteProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => MedicalDepartmentProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => FlowMedicalDepartmentProvider(), lazy: true),

@ -55,7 +55,7 @@ class AssetByIdModel {
String? comment;
bool? isEnabled;
String? tagCode;
List<AssetAttachment>? assetAttachments;
List<GenericAttachmentModel>? assetAttachments;
String? retirementTypeName;
String? retirementStatusName;
String? retirementDate;
@ -198,9 +198,9 @@ class AssetByIdModel {
isEnabled = json['isEnabled'];
tagCode = json['tagCode'];
if (json['assetAttachments'] != null) {
assetAttachments = <AssetAttachment>[];
assetAttachments = <GenericAttachmentModel>[];
json['assetAttachments'].forEach((v) {
assetAttachments!.add(AssetAttachment.fromJson(v));
assetAttachments!.add(GenericAttachmentModel.fromAssetJson(v));
});
}
retirementTypeName = json['retirementTypeName'];
@ -298,7 +298,7 @@ class AssetByIdModel {
data['isEnabled'] = isEnabled;
data['tagCode'] = tagCode;
if (assetAttachments != null) {
data['assetAttachments'] = assetAttachments!.map((v) => v).toList();
data['assetAttachments'] = assetAttachments!.map((v) => v.toAssetJson()).toList();
}
data['retirementTypeName'] = retirementTypeName;
data['retirementStatusName'] = retirementStatusName;

@ -1,30 +1,39 @@
class AssetTransferAttachment {
AssetTransferAttachment({
this.id,
this.attachmentName,
});
AssetTransferAttachment.fromJson(dynamic json) {
id = json['id'];
attachmentName = json['attachmentName'];
}
num? id; // Now nullable
String? attachmentName; // Now nullable
AssetTransferAttachment copyWith({
num? id, // Parameter is now nullable
String? attachmentName, // Parameter is now nullable
}) =>
AssetTransferAttachment(
id: id ?? this.id,
attachmentName: attachmentName ?? this.attachmentName,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['attachmentName'] = attachmentName;
return map;
}
}
//TODO: need to remove this class
// import 'package:test_sa/models/lookup.dart';
//
// class AssetTransferAttachment {
// AssetTransferAttachment({
// this.id,
// this.attachmentName,
// this.documentType,
//
// });
//
// AssetTransferAttachment.fromJson(dynamic json) {
// id = json['id'];
// attachmentName = json['attachmentName'];
// }
//
// num? id; // Now nullable
// String? attachmentName; // Now nullable
// Lookup ? documentType;
//
// AssetTransferAttachment copyWith({
// num? id, // Parameter is now nullable
// String? attachmentName, // Parameter is now nullable
// Lookup? documentType, // Parameter is now nullable
// }) =>
// AssetTransferAttachment(
// id: id ?? this.id,
// attachmentName: attachmentName ?? this.attachmentName,
// documentType: documentType ?? this.documentType,
// );
//
// Map<String, dynamic> toJson() {
// final map = <String, dynamic>{};
// map['id'] = id;
// map['attachmentName'] = attachmentName;
// map['documentTypeId'] = documentType?.id;
// return map;
// }
// }

@ -1,4 +1,5 @@
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
@ -95,7 +96,6 @@ class DeviceTransfer {
this.assistantEmployList,
this.assetTransferAssistantEmployeesReceiver,
this.assetTransferAssistantEmployeesSender,
this.statusValue,
});
@ -130,13 +130,13 @@ class DeviceTransfer {
if (json['senderAttachments'] != null) {
senderAttachments = [];
json['senderAttachments'].forEach((v) {
senderAttachments!.add(AssetTransferAttachment.fromJson(v));
senderAttachments!.add(GenericAttachmentModel.fromAssetTransferJson(v));
});
}
if (json['assetTransferAttachments'] != null) {
assetTransferAttachments = [];
json['assetTransferAttachments'].forEach((v) {
assetTransferAttachments?.add(AssetTransferAttachment.fromJson(v));
assetTransferAttachments?.add(GenericAttachmentModel.fromAssetTransferJson(v));
});
}
if (json['assetTransferContactPersons'] != null) {
@ -198,7 +198,7 @@ class DeviceTransfer {
if (json['receiverAttachments'] != null) {
receiverAttachments = [];
json['receiverAttachments'].forEach((v) {
receiverAttachments!.add(AssetTransferAttachment.fromJson(v));
receiverAttachments!.add(GenericAttachmentModel.fromAssetTransferJson(v));
});
}
assetNumber = json['assetNumber'];
@ -270,9 +270,9 @@ class DeviceTransfer {
String? senderWorkingHours;
String? senderTravelingHours;
String? senderEngSignature;
List<AssetTransferAttachment>? senderAttachments;
List<AssetTransferAttachment>? attachments;
List<AssetTransferAttachment>? assetTransferAttachments;
List<GenericAttachmentModel>? senderAttachments;
List<GenericAttachmentModel>? attachments;
List<GenericAttachmentModel>? assetTransferAttachments;
String? receiverAssignedEmployeeId;
String? receiverAssignedEmployeeNumber;
num? receiverMachineStatusId;
@ -283,7 +283,7 @@ class DeviceTransfer {
String? receiverWorkingHours;
String? receiverTravelingHours;
String? receiverEngSignature;
List<AssetTransferAttachment>? receiverAttachments;
List<GenericAttachmentModel>? receiverAttachments;
num? supplierId;
String? supplierName;
String? destSiteName;
@ -314,11 +314,11 @@ class DeviceTransfer {
List<VisitTimers>? assetTransferEngineerTimers;
List<TimerModel>? timerModelList = [];
List<AssistantEmployees>? assistantEmployees;
List<AssetTransferAssistantEmployees>? assetTransferAssistantEmployeesSender=[];
List<AssetTransferAssistantEmployees>? assetTransferAssistantEmployeesReceiver=[];
List<AssetTransferAssistantEmployees>? assetTransferAssistantEmployeesSender = [];
List<AssetTransferAssistantEmployees>? assetTransferAssistantEmployeesReceiver = [];
List<AssetTransferContactPerson>? assetTransferContactPersons;
AssetTransferAssistantEmployees? modelAssistantEmployees;
List<AssetTransferAssistantEmployees>? assistantEmployList=[];
List<AssetTransferAssistantEmployees>? assistantEmployList = [];
TimerModel? tbsTimer = TimerModel();
TimerModel? deviceTimePicker;
@ -349,7 +349,7 @@ class DeviceTransfer {
String? senderWorkingHours,
String? senderTravelingHours,
String? senderEngSignature,
List<AssetTransferAttachment>? senderAttachments,
List<GenericAttachmentModel>? senderAttachments,
String? receiverAssignedEmployeeId,
String? receiverAssignedEmployeeNumber,
num? receiverMachineStatusId,
@ -359,7 +359,7 @@ class DeviceTransfer {
String? receiverWorkingHours,
String? receiverTravelingHours,
String? receiverEngSignature,
List<AssetTransferAttachment>? receiverAttachments,
List<GenericAttachmentModel>? receiverAttachments,
num? supplierId,
String? supplierName,
String? destSiteName,
@ -472,7 +472,7 @@ class DeviceTransfer {
senderVisitTimers: senderVisitTimers ?? this.senderVisitTimers,
receiverVisitTimers: receiverVisitTimers ?? this.receiverVisitTimers,
tbsTimer: tbsTimer ?? this.tbsTimer,
assistantEmployList: assistantEmployList??this.assistantEmployList,
assistantEmployList: assistantEmployList ?? this.assistantEmployList,
deviceTimePicker: deviceTimePicker ?? this.deviceTimePicker,
manufacturerName: manufacturerName ?? this.manufacturerName);
@ -510,7 +510,7 @@ class DeviceTransfer {
map['assetTransferReceiverTimers'] = receiverVisitTimers!.map((v) => v.toJson()).toList();
}
if (senderAttachments != null) {
map['senderAttachments'] = senderAttachments!.map((v) => v.toJson()).toList();
map['senderAttachments'] = senderAttachments!.map((v) => v.toAssetTransferJson()).toList();
}
map['receiverAssignedEmployeeId'] = receiverAssignedEmployeeId;
map['receiverAssignedEmployeeNumber'] = receiverAssignedEmployeeNumber;
@ -522,7 +522,7 @@ class DeviceTransfer {
map['receiverTravelingHours'] = receiverTravelingHours;
map['receiverEngSignature'] = receiverEngSignature;
if (receiverAttachments != null) {
map['receiverAttachments'] = receiverAttachments!.map((v) => v.toJson()).toList();
map['receiverAttachments'] = receiverAttachments?.map((v) => v.toAssetTransferJson() ?? {}).toList();
}
map["supplierId"] = supplierId;
map["supplierName"] = supplierName;
@ -571,7 +571,7 @@ class DeviceTransfer {
map['destRoomId'] = destRoomId;
map['comment'] = comment;
if (attachments != null) {
map['attachments'] = attachments!.map((v) => v.toJson()).toList();
map['attachments'] = attachments!.map((v) => v.toAssetTransferJson()).toList();
}
return map;
}
@ -586,7 +586,7 @@ class DeviceTransfer {
map['assetTransferAssistantEmployees'] = modelAssistantEmployees;
map['assetTransferEngineerTimers'] = assetTransferEngineerTimers;
if (attachments != null) {
map['attachments'] = attachments!.map((v) => v.toJson()).toList();
map['attachments'] = attachments!.map((v) => v.toAssetTransferJson()).toList();
}
if (assetTransferEngineerTimers != null) {
map['assetTransferEngineerTimers'] = assetTransferEngineerTimers!.map((v) => v.toJson()).toList();
@ -634,7 +634,7 @@ class DeviceTransfer {
map['senderTravelingHours'] = senderTravelingHours;
map['senderEngSignature'] = senderEngSignature;
if (senderAttachments != null) {
map['senderAttachments'] = senderAttachments!.map((v) => v.toJson()).toList();
map['senderAttachments'] = senderAttachments!.map((v) => v.toAssetTransferJson()).toList();
}
if (senderVisitTimers != null) {
map['assetTransferSenderTimers'] = senderVisitTimers!.map((v) => v.toJson()).toList();
@ -652,7 +652,7 @@ class DeviceTransfer {
map['receiverTravelingHours'] = receiverTravelingHours;
map['receiverEngSignature'] = receiverEngSignature;
if (receiverAttachments != null) {
map['receiverAttachments'] = receiverAttachments!.map((v) => v.toJson()).toList();
map['receiverAttachments'] = receiverAttachments!.map((v) => v.toAssetTransferJson() ?? {}).toList();
}
return map;
}

@ -0,0 +1,213 @@
enum RequestAttachmentTypeEnum {
correctiveMaintenance, // 1
gasRefill, // 2
transferAsset, // 3
preventiveMaintenance, // 4
recurrentWo, // 5
taskRequest, // 6
recallAndAlert, // 7
assetInventory, // 8
assessmentOfNeedAndTechnology, // 9
equipmentInternalAudit, // 10
systemInternalAudit, // 11
loanEquipment, // 12
assetDelivery, // 13
medicalGasInspection, // 14
demo, // 15
incidents, // 16
sparePartActivity, // 17
updateDeliveryNotes, // 18
traf,//19
ppmSparePartActivity// 20
}
extension RequestAttachmentTypeEnumExtension on RequestAttachmentTypeEnum {
int get id {
switch (this) {
case RequestAttachmentTypeEnum.correctiveMaintenance:
return 1;
case RequestAttachmentTypeEnum.gasRefill:
return 2;
case RequestAttachmentTypeEnum.transferAsset:
return 3;
case RequestAttachmentTypeEnum.preventiveMaintenance:
return 4;
case RequestAttachmentTypeEnum.recurrentWo:
return 5;
case RequestAttachmentTypeEnum.taskRequest:
return 6;
case RequestAttachmentTypeEnum.recallAndAlert:
return 7;
case RequestAttachmentTypeEnum.assetInventory:
return 8;
case RequestAttachmentTypeEnum.assessmentOfNeedAndTechnology:
return 9;
case RequestAttachmentTypeEnum.equipmentInternalAudit:
return 10;
case RequestAttachmentTypeEnum.systemInternalAudit:
return 11;
case RequestAttachmentTypeEnum.loanEquipment:
return 12;
case RequestAttachmentTypeEnum.assetDelivery:
return 13;
case RequestAttachmentTypeEnum.medicalGasInspection:
return 14;
case RequestAttachmentTypeEnum.demo:
return 15;
case RequestAttachmentTypeEnum.incidents:
return 16;
case RequestAttachmentTypeEnum.sparePartActivity:
return 17;
case RequestAttachmentTypeEnum.updateDeliveryNotes:
return 18;
case RequestAttachmentTypeEnum.traf:
return 19;
case RequestAttachmentTypeEnum.ppmSparePartActivity:
return 20;
}
}
int get lookupEnumId {
switch (this) {
///values with 0 we need to check with backend team for the correct lookupEnumId
case RequestAttachmentTypeEnum.correctiveMaintenance:
return 40305;
case RequestAttachmentTypeEnum.gasRefill:
return 40307;
case RequestAttachmentTypeEnum.transferAsset:
return 40304;
case RequestAttachmentTypeEnum.preventiveMaintenance:
return 40313;
case RequestAttachmentTypeEnum.recurrentWo:
return 40314;
case RequestAttachmentTypeEnum.taskRequest:
return 40317;
case RequestAttachmentTypeEnum.recallAndAlert:
return 40316;
case RequestAttachmentTypeEnum.assetInventory:
return 40303;
case RequestAttachmentTypeEnum.assessmentOfNeedAndTechnology:
return 40319;
case RequestAttachmentTypeEnum.equipmentInternalAudit:
return 40323;
case RequestAttachmentTypeEnum.systemInternalAudit:
return 40322;
case RequestAttachmentTypeEnum.loanEquipment:
return 3053;
case RequestAttachmentTypeEnum.assetDelivery:
return 5009;
case RequestAttachmentTypeEnum.medicalGasInspection:
return 3012;
case RequestAttachmentTypeEnum.demo:
return 4106;
case RequestAttachmentTypeEnum.incidents:
return 40308;
case RequestAttachmentTypeEnum.sparePartActivity:
return 40321;
case RequestAttachmentTypeEnum.ppmSparePartActivity:
return 4021;
case RequestAttachmentTypeEnum.updateDeliveryNotes:
return 40309;
case RequestAttachmentTypeEnum.traf:
return 40319;
}
}
// String getName(BuildContext context) {
// switch (this) {
// case RequestTypeEnum.correctiveMaintenance:
// return context.translation.correctiveMaintenance;
// case RequestTypeEnum.gasRefill:
// return context.translation.gasRefill;
// case RequestTypeEnum.transferAsset:
// return context.translation.transferAsset;
// case RequestTypeEnum.preventiveMaintenance:
// return context.translation.preventiveMaintenance;
// case RequestTypeEnum.recurrentWo:
// return context.translation.recurrentWo;
// case RequestTypeEnum.taskRequest:
// return context.translation.taskRequest;
// case RequestTypeEnum.recallAndAlert:
// return 'Recall and Alert';
// case RequestTypeEnum.assetInventory:
// return 'Asset Inventory';
// case RequestTypeEnum.assessmentOfNeedAndTechnology:
// return 'Assessment of Need & Technology';
// case RequestTypeEnum.equipmentInternalAudit:
// return 'Equipment Internal Audit';
// case RequestTypeEnum.systemInternalAudit:
// return 'System Internal Audit';
// case RequestTypeEnum.loanEquipment:
// return 'Loan Equipment';
// case RequestTypeEnum.assetDelivery:
// return 'Asset Delivery';
// case RequestTypeEnum.medicalGasInspection:
// return 'Medical Gas Inspection';
// case RequestTypeEnum.demo:
// return 'Demo';
// case RequestTypeEnum.incidents:
// return 'Incidents';
// case RequestTypeEnum.sparePartActivity:
// return 'Spare Part Activity';
// case RequestTypeEnum.updateDeliveryNotes:
// return 'Update Delivery Notes';
// case RequestTypeEnum.traf:
// return 'Traf';
// }
// }
static RequestAttachmentTypeEnum? fromId(int? id) {
if (id == null) return null;
switch (id) {
case 1:
return RequestAttachmentTypeEnum.correctiveMaintenance;
case 2:
return RequestAttachmentTypeEnum.gasRefill;
case 3:
return RequestAttachmentTypeEnum.transferAsset;
case 4:
return RequestAttachmentTypeEnum.preventiveMaintenance;
case 5:
return RequestAttachmentTypeEnum.recurrentWo;
case 6:
return RequestAttachmentTypeEnum.taskRequest;
case 7:
return RequestAttachmentTypeEnum.recallAndAlert;
case 8:
return RequestAttachmentTypeEnum.assetInventory;
case 9:
return RequestAttachmentTypeEnum.assessmentOfNeedAndTechnology;
case 10:
return RequestAttachmentTypeEnum.equipmentInternalAudit;
case 11:
return RequestAttachmentTypeEnum.systemInternalAudit;
case 12:
return RequestAttachmentTypeEnum.loanEquipment;
case 13:
return RequestAttachmentTypeEnum.assetDelivery;
case 14:
return RequestAttachmentTypeEnum.medicalGasInspection;
case 15:
return RequestAttachmentTypeEnum.demo;
case 16:
return RequestAttachmentTypeEnum.incidents;
case 17:
return RequestAttachmentTypeEnum.sparePartActivity;
case 18:
return RequestAttachmentTypeEnum.updateDeliveryNotes;
case 19:
return RequestAttachmentTypeEnum.traf;
case 20:
return RequestAttachmentTypeEnum.ppmSparePartActivity;
default:
return null;
}
}
// static String getNameFromId(int id, BuildContext context) {
// final requestType = fromId(id);
// return requestType?.getName(context) ?? "Type $id";
// }
static int? getLookupEnumIdFromId(int? id) {
final requestType = fromId(id);
return requestType?.lookupEnumId;
}
}

@ -1,33 +1,358 @@
import 'dart:io';
import 'dart:developer';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
class GenericAttachmentModel {
GenericAttachmentModel({this.id, this.name, this.originalName, this.createdBy, this.documentTypeId});
GenericAttachmentModel({
this.id,
this.name,
this.module,
this.subModule,
this.uploadedBy,
this.originalName,
this.createdBy,
this.documentType,
this.attachmentDescription,
this.attachmentURL,
this.moduleReferenceId,
this.attachmentTypeId,
this.createdDate,
this.modifiedBy,
this.modifiedDate,
this.supplierId,
});
int? id;
String? name;
String? module;
String? subModule;
String? uploadedBy;
String? createdBy;
String? originalName;
Lookup? documentTypeId;
Lookup? documentType;
String? attachmentDescription;
String? attachmentURL;
num? moduleReferenceId;
num? attachmentTypeId;
String? createdDate;
String? modifiedBy;
String? modifiedDate;
num? supplierId;
GenericAttachmentModel.fromJson(Map<String, dynamic> json, {bool convertToLink = false}) {
id = json['id'];
name = json['name'] ?? json['imageName'];
name = json['name'] ?? json['attachmentName'] ?? json['imageName'];
createdBy = json['createdBy'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
originalName = json['originalName'] ?? json['imageOriginalName'];
if (convertToLink) {
name = URLs.getFileUrl(name);
}
}
GenericAttachmentModel.fromAssetDocumentJson(Map<String, dynamic> json, {bool convertToLink = false}) {
id = json['id'];
name = json['attachmentName'] ?? json['name'] ?? json['imageName'];
module = json['module'];
subModule = json['subModule'];
createdBy = json['createdBy'];
createdDate = json['createdDate'];
uploadedBy = json['uploadedBy'];
originalName = json['originalName'] ?? json['imageOriginalName'];
documentType = json['attachmentType'] != null ? Lookup(name: json['attachmentType'], id: 0) : null;
if (convertToLink && name != null) {
name = URLs.getFileUrl(name);
}
}
GenericAttachmentModel.fromWorkOrderJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
createdBy = json['createdBy'];
}
GenericAttachmentModel.fromLoanJson(Map<String, dynamic> json) {
id = json['id']?.toInt();
name = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
moduleReferenceId = json['loanId'];
attachmentTypeId = json['loanAttachmentTypeId'];
}
GenericAttachmentModel.fromLoanDetailJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
moduleReferenceId = json['loanId'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
attachmentTypeId = json['loanAttachmentTypeId'];
createdBy = json['createdBy'];
createdDate = json['createdDate'];
modifiedBy = json['modifiedBy'];
modifiedDate = json['modifiedDate'];
}
GenericAttachmentModel.fromPpmJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'] ?? json['name'];
moduleReferenceId = json['visitId'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
attachmentURL = json['attachmentURL'];
}
GenericAttachmentModel.fromSupplierJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'] ?? json['name'];
supplierId = json['supplierId'];
moduleReferenceId = json['visitId'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
attachmentURL = json['attachmentURL'];
}
GenericAttachmentModel.fromGasRefillJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
moduleReferenceId = json['gasRefillId'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
}
GenericAttachmentModel.fromIncidentJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
moduleReferenceId = json['incidentId'];
attachmentDescription = json['attachmentDescription'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
GenericAttachmentModel.fromAssetTransferJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
GenericAttachmentModel.fromDemoJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
originalName = json['originalName'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
moduleReferenceId = json['demoRequestId'];
}
GenericAttachmentModel.fromInternalAuditJson(Map<String, dynamic> json) {
id = json['id'];
name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
originalName = json['originalName'];
createdBy = json['createdBy'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
GenericAttachmentModel.fromPreventiveVisitJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
GenericAttachmentModel.fromAssetJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
attachmentURL = json['attachmentURL'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
originalName = json['originalName'];
}
GenericAttachmentModel.fromAssetInventoryJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
attachmentURL = json['attachmentURL'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
originalName = json['originalName'];
}
GenericAttachmentModel.fromTrafJson(Map<String, dynamic> json) {
id = json['id'];
moduleReferenceId = json['trafId'];
name = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
moduleReferenceId = json['trafId'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['createdBy'] = createdBy;
data['originalName'] = originalName;
data['documentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toSparePartJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['createdBy'] = createdBy;
data['originalName'] = originalName;
data['attachmentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toWorkOrderJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['createdBy'] = createdBy;
///TODO need to keep same variable for document type in backend for all modules, currently it is different for different modules
if (documentType != null) {
data['attachmentTypeId'] = documentType?.id;
}
return data;
}
Map<String, dynamic> toLoanJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['loanId'] = moduleReferenceId;
data['loanAttachmentTypeId'] = documentType?.id;
// data['documentTypeId'] = documentType?.id;
data['attachmentDescription'] = attachmentDescription;
return data;
}
Map<String, dynamic> toLoanDetailJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['loanId'] = moduleReferenceId;
data['loanAttachmentTypeId'] = attachmentTypeId;
data['attachmentDescription'] = attachmentDescription;
data['createdBy'] = createdBy;
data['createdDate'] = createdDate;
data['documentTypeId'] = documentType?.id;
data['modifiedBy'] = modifiedBy;
data['modifiedDate'] = modifiedDate;
return data;
}
Map<String, dynamic> toGasRefillJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['gasRefillId'] = moduleReferenceId;
data['attachmentName'] = name;
data['documentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toIncidentJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['incidentId'] = moduleReferenceId;
data['attachmentTypeId'] = documentType?.id;
data['attachmentDescription'] = attachmentDescription;
return data;
}
Map<String, dynamic> toAssetTransferJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['attachmentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toDemoJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['demoRequestId'] = moduleReferenceId;
data['originalName'] = originalName;
if (documentType != null) {
data['documentTypeId'] = documentType?.id;
}
return data;
}
Map<String, dynamic> toInternalAuditJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['originalName'] = originalName;
data['attachmentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toPreventiveVisitJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['attachmentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toAssetJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['attachmentURL'] = attachmentURL;
data['documentTypeId'] = documentType?.id;
data['originalName'] = originalName;
return data;
}
Map<String, dynamic> toAssetDeliveryJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['attachmentTypeId'] = documentType?.id;
data['originalName'] = originalName;
data['createdBy'] = createdBy;
return data;
}
Map<String, dynamic> toInventoryJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['Name'] = name;
data['attachmentURL'] = attachmentURL;
data['attachmentTypeId'] = documentType?.id;
data['originalName'] = originalName;
return data;
}
Map<String, dynamic> toTrafJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['trafId'] = moduleReferenceId;
data['attachmentName'] = name;
data['attachmentTypeId'] = documentType?.id;
return data;
}
Map<String, dynamic> toSupplierJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['supplierId'] = supplierId;
data['documentTypeId'] = documentType?.id;
data['attachmentName'] = name;
data['attachmentURL'] = attachmentURL;
return data;
}
Map<String, dynamic> toTaskJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['createdBy'] = createdBy;
data['originalName'] = originalName;
data['attachmentTypeId'] = documentType?.id;
return data;
}
}

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
class AssetRetiredHelperModel {
@ -5,7 +6,7 @@ class AssetRetiredHelperModel {
int? workOrderId;
Lookup? retirmentReason;
String? retirementComment;
List<ActivityAssetToBeRetiredAttachments>?
List<GenericAttachmentModel>?
activityAssetToBeRetiredAttachments=[];
AssetRetiredHelperModel(
@ -30,14 +31,3 @@ class AssetRetiredHelperModel {
}
}
class ActivityAssetToBeRetiredAttachments {
int? id;
String? name;
ActivityAssetToBeRetiredAttachments({this.id, this.name});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
return data;
}
}

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/spare_parts.dart';
@ -13,8 +14,7 @@ class SparePartHelperModel {
num? installQty;
num? returnQty;
String? comment;
List<SparePartAttachments> sparePartAttachments;
List<GenericAttachmentModel>? sparePartAttachments;
SparePartHelperModel({
this.id,
@ -28,7 +28,7 @@ class SparePartHelperModel {
this.activityStatusId,
this.activityStatus,
this.comment,
List<SparePartAttachments>? sparePartAttachments,
List<GenericAttachmentModel>? sparePartAttachments,
}) : sparePartAttachments = sparePartAttachments ?? [];
Map<String, dynamic> toJson() {
@ -43,29 +43,12 @@ class SparePartHelperModel {
data['activityStatusId'] = activityStatus?.id;
}
data['comment'] = comment;
if (sparePartAttachments.isNotEmpty) {
data['acitiySparePartAttachments'] = sparePartAttachments!.map((v) => v.toJson()).toList();
if (sparePartAttachments != null) {
data['acitiySparePartAttachments'] = sparePartAttachments!.map((v) => v?.toSparePartJson() ?? {}).toList();
}
return data;
}
//{
// "id": 0,
// "planPreventiveVisitId": 0,
// "partCatalogItemId": 0,
// "quantity": 0,
// "comment": "string",
// "acitiySparePartAttachments": [
// {
// "id": 0,
// "name": "string",
// "originalName": "string",
// "attachmentTypeId": 0,
// "attachmentName": "string",
// "attachmentURL": "string"
// }
// ]
// }
Map<String, dynamic> toPMJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
@ -75,28 +58,9 @@ class SparePartHelperModel {
data['comment'] = comment;
data['installQty'] = installQty;
data['returnQty'] = returnQty;
if (sparePartAttachments.isNotEmpty) {
data['acitiySparePartAttachments'] = sparePartAttachments!.map((v) => v.toJson()).toList();
if (sparePartAttachments?.isNotEmpty ?? false) {
data['acitiySparePartAttachments'] = sparePartAttachments!.map((v) => v.toSparePartJson()).toList();
}
return data;
}
}
class SparePartAttachments {
int? id;
String? name;
SparePartAttachments({this.id, this.name});
SparePartAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
return data;
}
}

@ -1,4 +1,5 @@
import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import '../../new_models/work_order_detail_model.dart';
@ -24,7 +25,7 @@ class WorkOrderHelperModel {
int? problemDescriptionId;
String? comments;
String? voiceNote;
List<WorkOrderAttachments>? workOrderAttachments;
List<GenericAttachmentModel>? workOrderAttachments;
WorkOrderHelperModel({this.assetId, this.equipmentStatusId, this.priorityId, this.problemDescriptionId, this.comments, this.voiceNote, this.workOrderAttachments});
@ -37,42 +38,21 @@ class WorkOrderHelperModel {
data['comments'] = comments;
data['voiceNote'] = voiceNote;
if (workOrderAttachments != null) {
data['workOrderAttachments'] = workOrderAttachments!.map((v) => v.toJson()).toList();
data['workOrderAttachments'] = workOrderAttachments!.map((v) => v.toWorkOrderJson()).toList();
}
return data;
}
Map<String, dynamic> toUploadAttachmentJson(int? workOrderId, List<WorkOrderAttachments>? workOrderAttachments) {
Map<String, dynamic> toUploadAttachmentJson(int? workOrderId, List<GenericAttachmentModel>? workOrderAttachments) {
final Map<String, dynamic> data = <String, dynamic>{};
data['workOrderId'] = workOrderId;
if (workOrderAttachments != null) {
data['workOrderAttachments'] = workOrderAttachments!.map((v) => v.toJson()).toList();
data['workOrderAttachments'] = workOrderAttachments.map((v) => v.toWorkOrderJson()).toList();
}
return data;
}
}
class WorkOrderAttachments {
WorkOrderAttachments({this.id, this.name,this.createdBy});
int? id;
String? name;
String ?createdBy;
WorkOrderAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
createdBy = json['createdBy'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['createdBy'] = createdBy;
return data;
}
}
class EngineerUpdateWorkOrderHelperModel {
int? workOrderId;
Lookup? equipmentStatus;
@ -173,10 +153,20 @@ class WorkOrderCostModel {
String? mrNo;
num? exchangeCost;
WorkOrderCostModel({this.workOrderId, this.sparePartCost, this.labourCost, this.travelCost, this.qAmount, this.poNo, this.prNo,this.mrNo,this.exchangeCost});
WorkOrderCostModel({this.workOrderId, this.sparePartCost, this.labourCost, this.travelCost, this.qAmount, this.poNo, this.prNo, this.mrNo, this.exchangeCost});
Map<String, dynamic> toJson() {
return {'workOrderId': workOrderId, 'sparePartCost': sparePartCost, 'laborCost': labourCost, 'travelCost': travelCost, 'qAmount': qAmount, 'prNo': prNo, 'poNo': poNo,'mrNo':mrNo,'exchangeCost':exchangeCost};
return {
'workOrderId': workOrderId,
'sparePartCost': sparePartCost,
'laborCost': labourCost,
'travelCost': travelCost,
'qAmount': qAmount,
'prNo': prNo,
'poNo': poNo,
'mrNo': mrNo,
'exchangeCost': exchangeCost
};
}
Map<String, dynamic> toPMCostJson() {
return {'planPreventiveVisitId': workOrderId, 'sparePartCost': sparePartCost, 'laborCost': labourCost, 'travelCost': travelCost, 'qAmount': qAmount, 'prNo': prNo, 'poNo': poNo,'mrNo':mrNo,'exchangeCost':exchangeCost};

@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assigned_employee.dart';
import 'package:test_sa/models/new_models/building.dart';
@ -87,7 +88,7 @@ class GasRefillModel {
TimerModel? gasRefillTimePicker;
List<TimerModel>? timerModelList = [];
List<GasRefillTimer>? gasRefillTimers = [];
List<GasRefillAttachments>? gasRefillAttachments;
List<GenericAttachmentModel>? gasRefillAttachments;
List<GasRefillContactPerson>? gasRefillContactPerson;
int? statusValue;
@ -115,9 +116,9 @@ class GasRefillModel {
workingHours = json['gasRefillTimers'].fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item['endDate']).difference(DateTime.parse(item['startDate'])).inSeconds) ?? 0;
}
if (json['gasRefillAttachments'] != null) {
gasRefillAttachments = <GasRefillAttachments>[];
gasRefillAttachments = <GenericAttachmentModel>[];
json['gasRefillAttachments'].forEach((v) {
gasRefillAttachments!.add(GasRefillAttachments.fromJson(v));
gasRefillAttachments!.add(GenericAttachmentModel.fromGasRefillJson(v));
});
}
if (json['gasRefillContactPerson'] != null) {
@ -127,24 +128,6 @@ class GasRefillModel {
});
}
// try {
// final DateTime? sd = DateTime.tryParse(startDate ?? "");
// final DateTime? st = DateTime.tryParse(startTime ?? "");
// final DateTime? ed = DateTime.tryParse(endDate ?? "");
// final DateTime? et = DateTime.tryParse(endTime ?? "");
// timer = TimerModel(
// startAt: st == null ? sd : sd?.add(Duration(hours: st.hour, minutes: st.minute, seconds: st.second)), // Handle potential null 'sd'
// endAt: et == null ? ed : ed?.add(Duration(hours: et.hour, minutes: et.minute, seconds: et.second)), // Handle potential null 'ed'
// );
// if (timer!.endAt != null && timer!.startAt != null) {
// // Use '!' since timer could be null after initialization
// timer!.durationInSecond = (timer!.endAt!.difference(timer!.startAt!)).inSeconds;
// workingHours = (((timer!.durationInSecond ?? 0) / 60) / 60);
// }
// } catch (e) {
// print(e);
// }
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
site = json['site'] != null ? Site.fromJson(json['site']) : null;
@ -188,7 +171,7 @@ class GasRefillModel {
map['comment'] = comment;
if (gasRefillAttachments != null) {
map['gasRefillAttachments'] = gasRefillAttachments?.map((v) => v.toJson()).toList();
map['gasRefillAttachments'] = gasRefillAttachments?.map((v) => v.toGasRefillJson() ?? {}).toList();
}
//older code.....
@ -241,8 +224,8 @@ class GasRefillModel {
if (gasRefillTimers != null) {
map['gasRefillTimers'] = gasRefillTimers?.map((v) => v.toJson()).toList();
}
if (gasRefillAttachments != null) {
map['gasRefillAttachments'] = gasRefillAttachments?.map((v) => v.toJson()).toList();
if (gasRefillContactPerson != null) {
map['gasRefillContactPerson'] = gasRefillContactPerson?.map((v) => v?.toJson() ?? {}).toList();
}
return map;
@ -454,27 +437,30 @@ class GasRefillTimer {
}
}
class GasRefillAttachments {
int? id;
num? gasRefillId;
String? attachmentName;
GasRefillAttachments({this.id, this.attachmentName, this.gasRefillId});
GasRefillAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
gasRefillId = json['gasRefillId'];
attachmentName = json['attachmentName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['gasRefillId'] = gasRefillId;
data['attachmentName'] = attachmentName;
return data;
}
}
// class GasRefillAttachments {
// int? id;
// num? gasRefillId;
// String? attachmentName;
// Lookup ? documentType;
//
// GasRefillAttachments({this.id, this.attachmentName,this.documentType, this.gasRefillId});
//
// GasRefillAttachments.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// gasRefillId = json['gasRefillId'];
// attachmentName = json['attachmentName'];
// documentType = json['documentType'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = <String, dynamic>{};
// data['id'] = id;
// data['gasRefillId'] = gasRefillId;
// data['attachmentName'] = attachmentName;
// data['documentTypeId'] = documentType?.id;
// return data;
// }
// }
class GasRefillContactPerson {
int? id;

@ -1,6 +1,7 @@
import 'dart:typed_data';
import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
import 'package:test_sa/models/new_models/building.dart';
@ -63,7 +64,7 @@ class TaskData {
Department? department;
Rooms? room;
String? callComment;
List<TaskJobAttachment>? taskJobAttachments;
List<GenericAttachmentModel>? taskJobAttachments;
TaskContactUser? assignedEngineer;
List<TaskJobAssistantEmployees>? taskJobAssistantEmployees = [];
TaskJobAssistantEmployees? modelAssistantEmployees;
@ -146,18 +147,18 @@ class TaskData {
});
}
if (json['attachments'] != null) {
taskJobAttachments = <TaskJobAttachment>[];
taskJobAttachments = <GenericAttachmentModel>[];
json['attachments'].forEach((v) {
taskJobAttachments!.add(TaskJobAttachment.fromJson(v));
taskJobAttachments!.add(GenericAttachmentModel.fromJson(v));
});
}
taskType = json['taskType'] != null ? TaskTypeModel.fromJson(json['taskType']) : null;
taskJobStatus = json['taskJobStatus'] != null ? TaskJobStatus.fromJson(json['taskJobStatus']) : null;
callComment = json['callComment'];
if (json['taskJobAttachments'] != null) {
taskJobAttachments = <TaskJobAttachment>[];
taskJobAttachments = <GenericAttachmentModel>[];
json['taskJobAttachments'].forEach((v) {
taskJobAttachments!.add(TaskJobAttachment.fromJson(v));
taskJobAttachments!.add(GenericAttachmentModel.fromJson(v));
});
}
assignedEngineer = json['assignedEngineer'] != null ? TaskContactUser.fromJson(json['assignedEngineer']) : null;
@ -283,7 +284,7 @@ class TaskData {
data['callComment'] = callComment;
if (taskJobAttachments != null) {
data['taskJobAttachments'] = taskJobAttachments!.map((e) => e.toJson()).toList();
data['taskJobAttachments'] = taskJobAttachments!.map((e) => e.toTaskJson()).toList();
}
if (assignedEngineer != null) {
@ -368,7 +369,7 @@ class TaskData {
data['taskJobActivityEngineerTimers'] = taskJobActivityEngineerTimers!.map((v) => v.toJson()).toList();
}
if (taskJobAttachments != null) {
data['attachments'] = taskJobAttachments!.map((v) => v.toJson()).toList();
data['attachments'] = taskJobAttachments!.map((v) => v.toTaskJson()).toList();
}
data['installationBuildingId'] = building?.id;
data['installationFloorId'] = floor?.id;
@ -567,26 +568,6 @@ class TaskJobStatus {
};
}
class TaskJobAttachment {
final int? id;
final String? name;
String? createdBy;
TaskJobAttachment({this.id, this.name, this.createdBy});
factory TaskJobAttachment.fromJson(Map<String, dynamic> json) => TaskJobAttachment(
id: json['id'],
name: json['name'],
createdBy: json['createdBy'],
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'createdBy': createdBy,
};
}
class TaskJobAssistantEmployees {
DateTime? startDate;
int? id;
@ -755,7 +736,7 @@ class AddTaskModel {
TaskEvaluatorUser? taskEvaluatorUser;
String? alertNo;
String? estimationDeliveryDate;
List<TaskJobAttachment>? attachments;
List<GenericAttachmentModel>? attachments;
String? reasonOfFSCA;
String? correctiveActionDescription;
@ -800,7 +781,7 @@ class AddTaskModel {
'reasonOfFSCA': reasonOfFSCA,
'correctiveActionDescription': correctiveActionDescription,
'evaluatorUserId': taskEvaluatorUser?.userId,
'attachments': attachments?.map((x) => x.toJson()).toList(),
'attachments': attachments?.map((x) => x.toTaskJson()).toList(),
};
}

@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
import 'package:test_sa/models/lookup.dart';
@ -146,7 +147,7 @@ class WorkOrderData {
Lookup? problemDescription;
String? comments;
String? voiceNote;
List<WorkOrderAttachments> workOrderAttachments;
List<GenericAttachmentModel> workOrderAttachments;
String? returnToService;
Lookup? serviceType;
Lookup? failureReasone;
@ -232,7 +233,7 @@ class WorkOrderData {
comments: json["comments"],
voiceNote: json["voiceNote"],
edd: json["edd"],
workOrderAttachments: json["workOrderAttachments"] == null ? [] : List.from(json['workOrderAttachments']).map((e) => WorkOrderAttachments.fromJson(e)).toList(),
workOrderAttachments: json["workOrderAttachments"] == null ? [] : List.from(json['workOrderAttachments']).map((e) => GenericAttachmentModel.fromWorkOrderJson(e)).toList(),
returnToService: json["returnToService"],
serviceType: json["serviceType"] == null ? null : Lookup.fromJson(json["serviceType"]),
failureReasone: json["failureReasone"] == null ? null : Lookup.fromJson(json["failureReasone"]),
@ -286,7 +287,7 @@ class WorkOrderData {
"edd": edd,
'mrNo': mrNo,
'exchangeCost': exchangeCost,
"workOrderAttachments": workOrderAttachments.map((e) => e.toJson()).toList(),
"workOrderAttachments": workOrderAttachments.map((e) => e.toWorkOrderJson() ?? {}).toList(),
"returnToService": returnToService,
"serviceType": serviceType?.toJson(),
"failureReasone": failureReasone?.toJson(),
@ -503,7 +504,7 @@ class ActivitySparePart {
double? installQty;
double? returnQty;
String? comment;
List<SparePartAttachments>? acitiySparePartAttachments;
List<GenericAttachmentModel>? acitiySparePartAttachments;
ActivitySparePart({this.id, this.partCatalogItem, this.quantity, this.installQty, this.returnQty, this.comment, this.acitiySparePartAttachments});
@ -515,9 +516,9 @@ class ActivitySparePart {
returnQty = json['returnQty'];
comment = json['comment'];
if (json['acitiySparePartAttachments'] != null) {
acitiySparePartAttachments = <SparePartAttachments>[];
acitiySparePartAttachments = <GenericAttachmentModel>[];
json['acitiySparePartAttachments'].forEach((v) {
acitiySparePartAttachments!.add(SparePartAttachments.fromJson(v));
acitiySparePartAttachments!.add(GenericAttachmentModel.fromJson(v));
});
}
}
@ -533,7 +534,7 @@ class ActivitySparePart {
data['returnQty'] = returnQty;
data['comment'] = comment;
if (acitiySparePartAttachments != null) {
data['acitiySparePartAttachments'] = acitiySparePartAttachments!.map((v) => v.toJson()).toList();
data['acitiySparePartAttachments'] = acitiySparePartAttachments!.map((v) => v?.toJson() ?? {}).toList();
}
return data;
}

@ -5,6 +5,7 @@ import 'package:flutter/widgets.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/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
@ -44,7 +45,7 @@ class PlanPreventiveVisit {
Lookup? safety;
String? engSignature;
String? nurseSignature;
List<PreventiveVisitAttachments>? preventiveVisitAttachments;
List<GenericAttachmentModel>? preventiveVisitAttachments;
List<File>? attachments = [];
List<PreventiveVisitCalibrations>? preventiveVisitCalibrations;
List<PreventiveVisitChecklists>? preventiveVisitChecklists;
@ -64,7 +65,6 @@ class PlanPreventiveVisit {
List<TimerModel>? timerModelList = [];
TimerModel? ppMTimePicker;
PlanPreventiveVisit(
{this.id,
this.visitNo,
@ -108,14 +108,14 @@ class PlanPreventiveVisit {
this.timerModelList,
this.ppMTimePicker,
this.activities,
this.labourCost,
this.sparePartCost,
this.travelCost,
this.qAmount,
this.prNo,
this.poNo,
this.mrNo,
this.exchangeCost,
this.labourCost,
this.sparePartCost,
this.travelCost,
this.qAmount,
this.prNo,
this.poNo,
this.mrNo,
this.exchangeCost,
this.preventiveVisitSuppliers});
PlanPreventiveVisit.fromJson(Map<String, dynamic> json) {
@ -152,18 +152,18 @@ class PlanPreventiveVisit {
safety = json['safety'] != null ? Lookup.fromJson(json['safety']) : null;
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
travelCost= json['travelCost'];
sparePartCost= json['sparePartCost'];
labourCost =json['laborCost'];
qAmount= json['qAmount'];
prNo= json['prNo'];
poNo= json['poNo'];
mrNo= json['mrNo'];
exchangeCost= json['exchangeCost'];
travelCost = json['travelCost'];
sparePartCost = json['sparePartCost'];
labourCost = json['laborCost'];
qAmount = json['qAmount'];
prNo = json['prNo'];
poNo = json['poNo'];
mrNo = json['mrNo'];
exchangeCost = json['exchangeCost'];
if (json['preventiveVisitAttachments'] != null) {
preventiveVisitAttachments = <PreventiveVisitAttachments>[];
preventiveVisitAttachments = <GenericAttachmentModel>[];
json['preventiveVisitAttachments'].forEach((v) {
preventiveVisitAttachments!.add(PreventiveVisitAttachments.fromJson(v));
preventiveVisitAttachments!.add(GenericAttachmentModel.fromPreventiveVisitJson(v));
});
}
if (json['preventiveVisitCalibrations'] != null) {
@ -220,7 +220,7 @@ class PlanPreventiveVisit {
data['nurseSignature'] = nurseSignature;
if (preventiveVisitAttachments != null) {
data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toJson()).toList();
data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toPreventiveVisitJson()).toList();
}
if (preventiveVisitCalibrations != null) {
data['preventiveVisitCalibrations'] = preventiveVisitCalibrations!.map((v) => v.toJson()).toList();
@ -252,10 +252,6 @@ class PlanPreventiveVisit {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.actualDate}");
return false;
}
// if (expectedDate == null) {
// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.visitDate}");
// return false;
// }
if (tbsTimer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
@ -265,11 +261,6 @@ class PlanPreventiveVisit {
return false;
}
// if (externalEngineerTimer?.startAt != null && externalEngineerTimer?.endAt == null) {
// await Fluttertoast.showToast(msg: "Please Stop External Engineer Timer");
// return false;
// }
return true;
}
@ -330,9 +321,6 @@ class PreventiveVisitChecklists {
data['taskStatusId'] = taskStatus?.id;
data['taskComment'] = taskComment;
data['measuredValue'] = measuredValue;
// if (instructionText != null) {
// data['instructionText'] = instructionText!.toJson();
// }
return data;
}
}
@ -381,25 +369,6 @@ class PreventiveVisitTimers {
}
}
class PreventiveVisitAttachments {
int? id;
String? attachmentName;
PreventiveVisitAttachments({this.id, this.attachmentName});
PreventiveVisitAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
attachmentName = json['attachmentName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = attachmentName;
return data;
}
}
class PreventiveVisitCalibrations {
num? id;
Asset? asset;
@ -417,7 +386,6 @@ class PreventiveVisitCalibrations {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
if (asset != null) {
// data['asset'] = asset!.toJson();
data['assetId'] = asset?.id;
}
data['calibrationDateOfTesters'] = calibrationDateOfTesters;
@ -449,11 +417,9 @@ class PreventiveVisitSuppliers {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
if (supplier != null) {
// data['supplier'] = supplier!.toJson();
data['supplierId'] = supplier?.id;
}
if (suppPerson != null) {
// data['suppPerson'] = suppPerson!.toJson();
data['suppPersonId'] = suppPerson?.id;
}
data['startDateTime'] = startDateTime?.toIso8601String();
@ -520,7 +486,7 @@ class PMSparePartActivityModel {
String? comment;
dynamic price;
List<SparePartAttachments> activitySparePartPPMAttachments;
List<GenericAttachmentModel> activitySparePartPPMAttachments;
PMSparePartActivityModel({
this.id,
@ -531,7 +497,7 @@ class PMSparePartActivityModel {
this.returnQty,
this.comment,
this.price,
List<SparePartAttachments>? activitySparePartPPMAttachments,
List<GenericAttachmentModel>? activitySparePartPPMAttachments,
}) : activitySparePartPPMAttachments = activitySparePartPPMAttachments ?? [];
PMSparePartActivityModel.fromJson(Map<String, dynamic> json) : activitySparePartPPMAttachments = [] {
@ -549,13 +515,9 @@ class PMSparePartActivityModel {
price = json['price'];
// Handle typo in API response: "acitiySparePartPPMAttachments" instead of "activitySparePartPPMAttachments"
final attachmentsKey = json.containsKey('acitiySparePartPPMAttachments')
? 'acitiySparePartPPMAttachments'
: 'activitySparePartPPMAttachments';
activitySparePartPPMAttachments = json[attachmentsKey] == null
? []
: List.from(json[attachmentsKey]).map((e) => SparePartAttachments.fromJson(e)).toList();
final attachmentsKey = json.containsKey('acitiySparePartPPMAttachments') ? 'acitiySparePartPPMAttachments' : 'activitySparePartPPMAttachments';
activitySparePartPPMAttachments = json[attachmentsKey] == null ? [] : List.from(json[attachmentsKey]).map((e) => GenericAttachmentModel.fromJson(e)).toList();
}
Map<String, dynamic> toJson() {

@ -5,6 +5,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/ppm/ppm_attachment.dart';
import 'package:test_sa/models/ppm/ppm_calibration_tools.dart';
import 'package:test_sa/models/ppm/ppm_check_list.dart';
@ -173,7 +174,7 @@ class Ppm {
if (json['vAttachments'] != null) {
files = [];
json['vAttachments'].forEach((v) {
files!.add(PpmAttachments.fromJson(v));
files!.add(GenericAttachmentModel.fromPpmJson(v));
});
}
visitStatusId = json['visitStatusId'];
@ -286,7 +287,7 @@ class Ppm {
List<PpmKits>? vKits;
List<PpmContacts>? vContacts;
List<PpmChecklists>? vChecklists;
List<PpmAttachments>? files;
List<GenericAttachmentModel>? files;
num? visitStatusId;
List<VisitTimers>? visitTimers;
@ -380,7 +381,7 @@ class Ppm {
List<PpmKits>? vKits,
List<PpmContacts>? vContacts,
List<PpmChecklists>? vChecklists,
List<PpmAttachments>? files,
List<GenericAttachmentModel>? files,
num? visitStatusId,
List<VisitTimers>? visitTimers,
String? startDate,
@ -574,7 +575,7 @@ class Ppm {
if (files?.isNotEmpty ?? false) {
map["vAttachments"] = files!
.map((file) =>
{"attachmentName": _isLocalUrl(file.attachmentName!) ? ("${file.attachmentName!.split("/").last}|${base64Encode(File(file.attachmentName!).readAsBytesSync())}") : file.attachmentName})
{"attachmentName": _isLocalUrl(file.name!) ? ("${file.name!.split("/").last}|${base64Encode(File(file.name!).readAsBytesSync())}") : file.name})
.toList();
}
map['visitStatusId'] = visitStatusId;

@ -1,40 +1,42 @@
class PpmAttachments {
PpmAttachments({
this.id,
this.visitId,
this.attachmentName,
this.attachmentURL,
});
//TODO need to delete this
PpmAttachments.fromJson(dynamic json) {
id = json['id'];
visitId = json['visitId'];
attachmentName = json['attachmentName'] ?? json['attachmentURL']; // Handle potential null and prioritize'attachmentName'
}
num? id; // Now nullable
num? visitId; // Now nullable
String? attachmentName; // Now nullable
String? attachmentURL; // Now nullable
PpmAttachments copyWith({
num? id,
num? visitId,
String? attachmentName,
String? attachmentURL,
}) =>
PpmAttachments(
id: id ?? this.id,
visitId: visitId ?? this.visitId,
attachmentName: attachmentName ?? this.attachmentName,attachmentURL: attachmentURL ?? this.attachmentURL,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['visitId'] = visitId;
map['attachmentName'] = attachmentName;
map['attachmentURL'] = attachmentURL;
return map;
}
}
// class PpmAttachments {
// PpmAttachments({
// this.id,
// this.visitId,
// this.attachmentName,
// this.attachmentURL,
// });
//
// PpmAttachments.fromJson(dynamic json) {
// id = json['id'];
// visitId = json['visitId'];
// attachmentName = json['attachmentName'] ?? json['attachmentURL']; // Handle potential null and prioritize'attachmentName'
// }
//
// num? id; // Now nullable
// num? visitId; // Now nullable
// String? attachmentName; // Now nullable
// String? attachmentURL; // Now nullable
//
// PpmAttachments copyWith({
// num? id,
// num? visitId,
// String? attachmentName,
// String? attachmentURL,
// }) =>
// PpmAttachments(
// id: id ?? this.id,
// visitId: visitId ?? this.visitId,
// attachmentName: attachmentName ?? this.attachmentName,attachmentURL: attachmentURL ?? this.attachmentURL,
// );
//
// Map<String, dynamic> toJson() {
// final map = <String, dynamic>{};
// map['id'] = id;
// map['visitId'] = visitId;
// map['attachmentName'] = attachmentName;
// map['attachmentURL'] = attachmentURL;
// return map;
// }
// }

@ -1,6 +1,7 @@
import 'dart:typed_data';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/service_report.dart';
import 'package:test_sa/models/service_request/spare_parts.dart';
@ -10,7 +11,6 @@ import 'package:test_sa/models/service_request/wo_call_request.dart';
import 'package:test_sa/models/service_request/wo_parent.dart';
import 'package:test_sa/models/timer_model.dart';
import '../../attachment.dart';
import '../fault_description.dart';
import '../new_models/assigned_employee.dart';
import '../new_models/assistant_employee.dart';
@ -41,12 +41,12 @@ class SearchWorkOrder {
this.travelingHours,
this.travelingExpenses,
this.faultDescription,
this.sparePartsWorkOrders,
this.reviewComment,
this.comment,
this.attachmentsWorkOrder,
this.equipmentStatus,
this.suppEngineerWorkOrders,
this.sparePartsWorkOrders,
this.reviewComment,
this.comment,
List<GenericAttachmentModel>? attachmentsWorkOrder,
this.equipmentStatus,
this.suppEngineerWorkOrders,
this.engSignature,
this.nurseSignature,
this.woParentDto,
@ -106,7 +106,7 @@ class SearchWorkOrder {
if (json['attachmentsWorkOrder'] != null) {
attachmentsWorkOrder = [];
json['attachmentsWorkOrder'].forEach((v) {
attachmentsWorkOrder!.add(Attachment.fromJson(v));
attachmentsWorkOrder!.add(GenericAttachmentModel.fromJson(v));
});
}
equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
@ -155,8 +155,8 @@ class SearchWorkOrder {
sparePartsWorkOrders = (wo.sparePartsWorkOrders ?? sparePartsWorkOrders)?.map((e) => SparePartsWorkOrders.fromJson(e.toJson() ?? {})).toList() ?? [];
reviewComment = wo.reviewComment ?? reviewComment;
comment = wo.comment ?? comment;
attachmentsWorkOrder = (wo.attachmentsWorkOrder ?? attachmentsWorkOrder)?.map((e) => Attachment.fromJson(e.toJson() ?? {})).toList() ?? [];
equipmentStatus = Lookup.fromJson((wo.equipmentStatus ?? equipmentStatus)?.toJson() ?? {});
attachmentsWorkOrder = (wo.attachmentsWorkOrder ?? attachmentsWorkOrder)?.map((e) => GenericAttachmentModel.fromJson(e?.toJson() ?? {})).toList() ?? [];
equipmentStatus = wo.equipmentStatus ?? equipmentStatus;
suppEngineerWorkOrders = (wo.suppEngineerWorkOrders ?? suppEngineerWorkOrders)?.map((e) => SuppEngineerWorkOrders.fromJson(e.toJson() ?? {})).toList() ?? [];
engSignature = wo.engSignature ?? engSignature;
nurseSignature = wo.nurseSignature ?? nurseSignature;
@ -191,7 +191,7 @@ class SearchWorkOrder {
List<SparePartsWorkOrders>? sparePartsWorkOrders;
String? reviewComment;
String? comment;
List<Attachment>? attachmentsWorkOrder;
List<GenericAttachmentModel>? attachmentsWorkOrder;
Lookup? equipmentStatus;
List<SuppEngineerWorkOrders>? suppEngineerWorkOrders;
String? engSignature;
@ -233,7 +233,7 @@ class SearchWorkOrder {
List<SparePartsWorkOrders>? sparePartsWorkOrders,
String? reviewComment,
String? comment,
List<Attachment>? attachmentsWorkOrder,
List<GenericAttachmentModel>? attachmentsWorkOrder,
Lookup? equipmentStatus,
List<SuppEngineerWorkOrders>? suppEngineerWorkOrders,
String? engSignature,

@ -5,6 +5,7 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/spare_parts.dart';
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
@ -13,7 +14,6 @@ import 'package:test_sa/models/service_request/wo_call_request.dart';
import 'package:test_sa/models/service_request/wo_parent.dart';
import 'package:test_sa/models/timer_model.dart';
import '../../attachment.dart';
import '../device/asset.dart';
import '../fault_description.dart';
import '../new_models/assigned_employee.dart';
@ -118,7 +118,7 @@ class ServiceReport {
attachmentsWorkOrder = [];
json['attachmentsWorkOrder'].forEach((v) {
v["name"] = URLs.getFileUrl(v["name"]);
attachmentsWorkOrder!.add(Attachment.fromJson(v));
attachmentsWorkOrder!.add(GenericAttachmentModel.fromJson(v));
});
}
equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
@ -163,7 +163,7 @@ class ServiceReport {
List<SparePartsWorkOrders>? sparePartsWorkOrders;
String? reviewComment;
String? comment;
List<Attachment>? attachmentsWorkOrder;
List<GenericAttachmentModel>? attachmentsWorkOrder;
Lookup? equipmentStatus;
List<SuppEngineerWorkOrders>? suppEngineerWorkOrders;
String? engSignature;
@ -204,7 +204,7 @@ class ServiceReport {
List<SparePartsWorkOrders>? sparePartsWorkOrders,
String? reviewComment,
String? comment,
List<Attachment>? attachmentsWorkOrder,
List<GenericAttachmentModel>? attachmentsWorkOrder,
Lookup? equipmentStatus,
List<SuppEngineerWorkOrders>? suppEngineerWorkOrders,
String? engSignature,
@ -311,7 +311,7 @@ class ServiceReport {
map['reviewComment'] = reviewComment;
map['comment'] = comment;
if (attachmentsWorkOrder != null) {
map['attachmentsWorkOrder'] = attachmentsWorkOrder!.map((v) => {"name": v.name!.getFileName}).toList();
map['attachmentsWorkOrder'] = attachmentsWorkOrder!.where((v) => v?.name != null).map((v) => {"name": v!.name!.getFileName}).toList();
}
if (equipmentStatus != null) {
map['equipmentStatus'] = equipmentStatus!.toJson();

@ -1,4 +1,5 @@
import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
class SupplierDetails extends Base {
SupplierDetails({
@ -60,7 +61,7 @@ class SupplierDetails extends Base {
if (json['attachments'] != null) {
attachments = [];
json['attachments'].forEach((v) {
attachments!.add(Attachments.fromJson(v));
attachments!.add(GenericAttachmentModel.fromSupplierJson(v));
});
}
if (json['suppPersons'] != null) {
@ -93,7 +94,7 @@ class SupplierDetails extends Base {
List<Telephones>? telephones;
List<Faxes>? faxes;
List<Addresses>? addresses;
List<Attachments>? attachments;
List<GenericAttachmentModel>? attachments;
List<SuppPersons>? suppPersons;
List<SuppTCodes>? suppTCodes;
@ -114,7 +115,7 @@ class SupplierDetails extends Base {
List<Telephones>? telephones,
List<Faxes>? faxes,
List<Addresses>? addresses,
List<Attachments>? attachments,
List<GenericAttachmentModel>? attachments,
List<SuppPersons>? suppPersons,
List<SuppTCodes>? suppTCodes,
}) =>
@ -165,7 +166,7 @@ class SupplierDetails extends Base {
map['addresses'] = addresses!.map((v) => v.toJson()).toList();
}
if (attachments != null) {
map['attachments'] = attachments!.map((v) => v.toJson()).toList();
map['attachments'] = attachments!.map((v) => v.toSupplierJson()).toList();
}
if (suppPersons != null) {
map['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList();
@ -283,48 +284,48 @@ class SuppPersons extends Base {
}
}
class Attachments {
Attachments({
this.id,
this.supplierId,
this.attachmentName,
this.attachmentURL,
});
Attachments.fromJson(dynamic json) {
id = json['id'];
supplierId = json['supplierId'];
attachmentName = json['attachmentName'];
attachmentURL = json['attachmentURL'];
}
num? id;
num? supplierId;
String? attachmentName;
String? attachmentURL;
Attachments copyWith({
num? id,
num? supplierId,
String? attachmentName,
String? attachmentURL,
}) =>
Attachments(
id: id ?? this.id,
supplierId: supplierId ?? this.supplierId,
attachmentName: attachmentName ?? this.attachmentName,
attachmentURL: attachmentURL ?? this.attachmentURL,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['supplierId'] = supplierId;
map['attachmentName'] = attachmentName;
map['attachmentURL'] = attachmentURL;
return map;
}
}
// class Attachments {
// Attachments({
// this.id,
// this.supplierId,
// this.attachmentName,
// this.attachmentURL,
// });
//
// Attachments.fromJson(dynamic json) {
// id = json['id'];
// supplierId = json['supplierId'];
// attachmentName = json['attachmentName'];
// attachmentURL = json['attachmentURL'];
// }
//
// num? id;
// num? supplierId;
// String? attachmentName;
// String? attachmentURL;
//
// Attachments copyWith({
// num? id,
// num? supplierId,
// String? attachmentName,
// String? attachmentURL,
// }) =>
// Attachments(
// id: id ?? this.id,
// supplierId: supplierId ?? this.supplierId,
// attachmentName: attachmentName ?? this.attachmentName,
// attachmentURL: attachmentURL ?? this.attachmentURL,
// );
//
// Map<String, dynamic> toJson() {
// final map = <String, dynamic>{};
// map['id'] = id;
// map['supplierId'] = supplierId;
// map['attachmentName'] = attachmentName;
// map['attachmentURL'] = attachmentURL;
// return map;
// }
// }
class Addresses {
Addresses({

@ -100,6 +100,8 @@ class User {
return {"username": userName, "password": password, "fireBaseToken": FirebaseNotificationManger?.token ?? "", "notificationType": notificationType};
}
String get roleName => userRoles?.first.name ?? "";
UsersTypes? get type {
switch (userRoles?.first.value) {
case "R-6":

@ -35,6 +35,7 @@ class HelperFunction {
builder: (context) => AssetDeliveryAttachmentView(
tableItemId: deliveryTableItemId,
attachmentType: result!.value,
documentType: Lookup(id: result.id, value: result.value, name: result.name),
// viewOnly: viewOnly,
attachmentList: list,
)));

@ -9,7 +9,9 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
@ -19,11 +21,14 @@ import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/widgets/images/files_list.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
class AssetDeliveryAttachmentView extends StatefulWidget {
final int? tableItemId;
final int? attachmentType;
final Lookup? documentType;
// bool viewOnly = false;
final List<GenericAttachmentModel> attachmentList;
@ -32,6 +37,7 @@ class AssetDeliveryAttachmentView extends StatefulWidget {
required this.attachmentList,
// this.viewOnly = false,
this.attachmentType,
this.documentType,
this.tableItemId,
});
@ -73,22 +79,21 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
Navigator.pop(context);
},
),
body:
// widget.attachmentList.isEmpty
// ? const NoDataFound().center
// :
Column(
body: Column(
children: [
Flexible(
fit: FlexFit.loose,
fit: FlexFit.loose, // ✅ expands only as much as needed
child: Column(
children: [
// widget.attachmentType == 5 && !widget.viewOnly
widget.attachmentType == 5 //only add the attachment for current
? AttachmentPicker(
label: context.translation.attachments,
showTypeDropdown: false,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
buttonColor: AppColor.primary10,
documentType: widget.documentType,
onlyImages: false,
showAsListView: true,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
@ -100,7 +105,19 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
)
: _attachments.isNotEmpty
? FilesList(images: _attachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []).toShadowContainer(
? FilesList(
showAsListView: true,
types: _attachments.map((doc) {
final attachmentType = doc.documentType?.name ?? '';
return attachmentType.isNotEmpty ? attachmentType : 'Asset Guide';
}).toList(),
images: _attachments
.map(
(e) => URLs.getFileUrl(e.name ?? '') ?? '',
)
.toList() ??
[])
.toShadowContainer(
context,
borderRadius: 20,
padding: 12,
@ -126,13 +143,13 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
}
Future<void> _onSavePressed() async {
final List<GenericAttachmentModel> attachmentPayload = _attachments.map((item) {
final List<Map<String, dynamic>> attachmentPayload = _attachments.map((item) {
final String name = CMRequestUtils.isLocalUrl(item.name ?? '') ? '${item.name?.split("/").last}|${base64Encode(File(item.name!).readAsBytesSync())}' : item.name ?? '';
return GenericAttachmentModel(
id: item.id ?? 0,
name: name,
);
documentType: widget.documentType,
).toAssetDeliveryJson();
}).toList();
showDialog(

@ -1,10 +1,13 @@
import 'dart:convert';
import 'dart:developer';
import 'package:http/http.dart';
import 'package:test_sa/controllers/api_routes/api_manager.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
///TODO need to remove this after verifying we need to use the same for all modules ..
class AttachmentTypeLookupProvider extends LoadingListNotifier<Lookup> {
@override
Future getData({int? id}) async {
@ -31,3 +34,41 @@ class AttachmentTypeLookupProvider extends LoadingListNotifier<Lookup> {
}
}
}
class AttachmentTypeLookupProviderLatest extends LoadingListNotifier<Lookup> {
@override
Future getData({int? id}) async {
if (loading == true) return -2;
loading = true;
notifyListeners();
int? lookupEnum = RequestAttachmentTypeEnumExtension.getLookupEnumIdFromId(id);
if (lookupEnum == null) {
log('Invalid request type id: $id');
loading = false;
stateCode = -1;
notifyListeners();
return -1;
}
try {
log('Request type id: $id, Lookup enum: $lookupEnum');
Response response = await ApiManager.instance.get(
'${URLs.getAttachmentTypesLookup}?lookupEnum=$lookupEnum',
useCache: true,
enableToastMessage: false,
);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
List categoriesListJson = json.decode(response.body)["data"];
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
}
loading = false;
notifyListeners();
return response.statusCode;
} catch (error) {
loading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -1,5 +1,7 @@
import 'dart:developer';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/room_model.dart';
@ -106,7 +108,7 @@ class AssetInventoryModel {
Department? department;
Rooms? room;
SupplierDetails? supplier;
List<AssetInventoryDetailAssetAttachments> assetInventoryDetailAssetAttachments = [];
List<GenericAttachmentModel> assetInventoryDetailAssetAttachments = [];
AssetInventoryModel({
this.id,
@ -195,10 +197,10 @@ class AssetInventoryModel {
photo = json['photo'];
photoOriginName = json['photoOriginName'];
remarks = json['remarks'];
if (json['assetTransferAttachments'] != null) {
if (json['assetInventoryDetailAssetAttachments'] != null) {
assetInventoryDetailAssetAttachments = [];
json['assetInventoryDetailAssetAttachments'].forEach((v) {
assetInventoryDetailAssetAttachments.add(AssetInventoryDetailAssetAttachments.fromJson(v));
assetInventoryDetailAssetAttachments.add(GenericAttachmentModel.fromAssetInventoryJson(v));
});
}
@ -240,9 +242,7 @@ class AssetInventoryModel {
'newSupplierName': newSupplierName,
'photo': photo,
'remarks': remarks,
'assetInventoryDetailAssetAttachments': assetInventoryDetailAssetAttachments != null
? assetInventoryDetailAssetAttachments!.map((v) => v.toJson()).toList()
: [],
'assetInventoryDetailAssetAttachments': assetInventoryDetailAssetAttachments.map((v) => v.toInventoryJson() ?? {}).toList(),
};
}
@ -307,39 +307,3 @@ class AssetInventoryModel {
}
class AssetInventoryDetailAssetAttachments {
AssetInventoryDetailAssetAttachments({
this.id,
this.name,
this.originalName,
});
AssetInventoryDetailAssetAttachments.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
originalName = json['originalName'];
}
num? id;
String? name;
String? originalName;
AssetInventoryDetailAssetAttachments copyWith({
num? id, // Parameter is now nullable
String? name, // Parameter is now nullable
String? originalName, // Parameter is now nullable
}) =>
AssetInventoryDetailAssetAttachments(
id: id ?? this.id,
name: name??this.name,
originalName: originalName??this.originalName,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['originalName'] = originalName;
return map;
}
}

@ -43,11 +43,9 @@ class SessionModel {
statusName = json['statusName'];
startDate = json['startDate'];
endDate = json['endDate'];
if (json['assetInventorySites'] != null) {
assetInventorySites = (json['assetInventorySites'] as List).map((e) => Site.fromJson(e)).toList();
}
if (json['assetInventoryAssignedEmployee'] != null) {
assetInventoryAssignedEmployee = (json['assetInventoryAssignedEmployee'] as List).map((e) => AssetInventoryAssignedEmployee.fromJson(e)).toList();
}

@ -11,6 +11,7 @@ import 'package:test_sa/modules/asset_inventory_module/models/asset_inventory_mo
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
///TODO We are not showing attachment here we need to check this with backend team and flow .
class AssetDetailCardView extends StatelessWidget {
AssetInventoryModel assetInventoryModel;
VoidCallback onDeletePress;

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/asset_inventory_module/models/asset_inventory_model.dart';
import 'package:test_sa/modules/asset_inventory_module/pages/search_asset_view.dart';
@ -23,6 +24,7 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/equipment/asset_picker.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker_item.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../new_views/common_widgets/app_filled_button.dart';
import '../../../new_views/common_widgets/default_app_bar.dart';
@ -294,14 +296,12 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
classificationWidget(label: _scannedAssetModel?.status),
],
12.height,
Text(
'Attachments'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.white936),
),
12.height,
AttachmentPicker(
moduleId: RequestAttachmentTypeEnum.assetInventory.id,
label: context.translation.attachFiles,
attachment: attachments,
showAsListView: true,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -406,7 +406,7 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
// try {
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_scannedAssetModel?.assetInventoryDetailAssetAttachments.add(AssetInventoryDetailAssetAttachments(id: item.id, name: fileName));
_scannedAssetModel?.assetInventoryDetailAssetAttachments.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
// // } catch (error) {
// // print(error);

@ -300,6 +300,7 @@ class OneTimeTaskPreviewScreen extends StatelessWidget {
InfoHeader16Widget(
'Attachments',
),
4.height,
FilesList(
images: taskData.attachments!.map((attachment) => URLs.getFileUrl(attachment.name ?? '') ?? '').toList(),
showAsListView: true,

@ -260,15 +260,15 @@ class CMDetailProvider extends ChangeNotifier {
}
//upload workorder attachment by engineer..
Future addWorkOrderAttachment({required int woId, required List<GenericAttachmentModel> attachments, required List<WorkOrderAttachments> otherAttachment}) async {
Future addWorkOrderAttachment({required int woId, required List<GenericAttachmentModel> attachments, required List<GenericAttachmentModel> otherAttachment}) async {
try {
List<WorkOrderAttachments> woAttachments = [];
List<GenericAttachmentModel> woAttachments = [];
if (otherAttachment.isNotEmpty) {
woAttachments.addAll(otherAttachment);
}
for (var file in attachments) {
String fileName = CMRequestUtils.isLocalUrl(file.name ?? '') ? ("${file.name ?? ''.split("/").last}|${base64Encode(File(file.name ?? '').readAsBytesSync())}") : file.name ?? '';
woAttachments.add(WorkOrderAttachments(id: file.id, name: fileName, createdBy: file.createdBy));
woAttachments.add(GenericAttachmentModel(id: file.id, name: fileName, createdBy: file.createdBy, documentType: file.documentType));
}
isLoading = true;

@ -12,6 +12,7 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
@ -157,6 +158,8 @@ class _CreateCMRequestState extends State<CreateCMRequest> with TickerProviderSt
24.height,
AttachmentPicker(
label: context.translation.attachImage,
moduleId: RequestAttachmentTypeEnum.correctiveMaintenance.id,
showAsListView: true,
attachment: _deviceImages,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -350,10 +353,10 @@ class _CreateCMRequestState extends State<CreateCMRequest> with TickerProviderSt
_serviceRequest.audio = "${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}";
}
}
List<WorkOrderAttachments> attachement = [];
List<GenericAttachmentModel> attachement = [];
for (var item in _deviceImages) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
attachement.add(WorkOrderAttachments(id: 0, name: fileName));
attachement.add(GenericAttachmentModel(id: 0, name: fileName, documentType: item.documentType));
}
_requestDetailProvider.workOrderHelperModel = WorkOrderHelperModel(
assetId: _serviceRequest.device?.id,

@ -4,9 +4,11 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/controllers/providers/api/user_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';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/maintenance_request/activity_maintenance_model.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
@ -172,7 +174,20 @@ class _ActivitiesListViewState extends State<ActivitiesListView> {
if (activity.activitySparePart?.acitiySparePartAttachments?.isNotEmpty ?? false) ...[
2.height,
const Divider().defaultStyle(context),
FilesList(images: activity.activitySparePart!.acitiySparePartAttachments!.map((toElement) => URLs.getFileUrl(toElement.name!)!).toList()),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: activity.activitySparePart!.acitiySparePartAttachments!
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: activity.activitySparePart!.acitiySparePartAttachments!
.whereType<GenericAttachmentModel>()
.where((e) => e.name != null)
.map((toElement) => URLs.getFileUrl(toElement.name!)!)
.toList()),
],
],
).toShadowContainer(context, showShadow: false).onPress(() {
@ -216,7 +231,6 @@ class _ActivitiesListViewState extends State<ActivitiesListView> {
),
],
),
if (showActionButtons)
Row(
crossAxisAlignment: CrossAxisAlignment.start,

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
@ -8,6 +10,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/enums/work_order_next_step.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
@ -41,7 +44,7 @@ class ServiceRequestDetailView extends StatefulWidget {
class _ServiceRequestDetailViewState extends State<ServiceRequestDetailView> {
List<GenericAttachmentModel> _userAttachments = [];
List<WorkOrderAttachments> _attachments = [];
List<GenericAttachmentModel> _attachments = [];
@override
void initState() {
@ -53,13 +56,15 @@ class _ServiceRequestDetailViewState extends State<ServiceRequestDetailView> {
UserProvider userProvider = Provider.of<UserProvider>(context, listen: false);
return Consumer<CMDetailProvider>(builder: (pContext, requestProvider, _) {
if (userProvider.user?.type == UsersTypes.engineer) {
// _userAttachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => File(e.name ?? '')).toList() ?? [];
_userAttachments =
requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == userProvider.user?.userID).map((e) => GenericAttachmentModel.fromJson(e.toJson())).toList() ?? [];
_attachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy != userProvider.user?.userID).toList() ?? [];
_userAttachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.createdBy == userProvider.user?.userID)
.map((e) => GenericAttachmentModel(id: e.id, name: e.name, createdBy: e.createdBy, documentType: e.documentType))
.toList() ??
[];
_attachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.whereType<GenericAttachmentModel>().where((e) => e.createdBy != userProvider.user?.userID).toList() ?? [];
} else {
//show only nurse attachments
_attachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == userProvider.user?.userID).toList() ?? [];
_attachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.whereType<GenericAttachmentModel>().where((e) => e.createdBy == userProvider.user?.userID).toList() ?? [];
}
bool showInitialVisitCard = requestProvider.currentWorkOrder?.data?.needAVisitDateTime != null &&
@ -261,26 +266,50 @@ class _ServiceRequestDetailViewState extends State<ServiceRequestDetailView> {
if (_attachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!) ?? '').toList()),
4.height,
FilesList(
showAsListView: true,
images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!) ?? '').toList(),
types: _attachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
),
],
if (!requestProvider.isReadOnlyRequest && workOrder.nextStep?.workOrderNextStepEnum == WorkOrderNextStepEnum.activity) ...[
const Divider().defaultStyle(context),
AttachmentPicker(
label: context.translation.attachments,
showAsListView: true,
attachment: _userAttachments,
moduleId: RequestAttachmentTypeEnum.correctiveMaintenance.id,
buttonColor: AppColor.primary10,
onlyImages: false,
// showAsGrid: true,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
onChange: (attachment) {
requestProvider.addWorkOrderAttachment(woId: workOrder.requestId!, attachments: attachment, otherAttachment: _attachments);
requestProvider.addWorkOrderAttachment(
woId: workOrder.requestId!,
attachments: attachment,
otherAttachment: _attachments,
);
},
),
],
] else ...[
if (_attachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
FilesList(images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!)!).toList()),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!)!).toList(),
showAsListView: true,
types: _attachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
),
],
//handle nurse case..
],

@ -7,6 +7,7 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/asset_retired/asset_retired_model.dart';
import 'package:test_sa/models/lookup.dart';
@ -106,9 +107,11 @@ class _AssetRetiredState extends State<AssetRetired> with TickerProviderStateMix
AttachmentPicker(
label: context.translation.attachFiles,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
showAsListView: true,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
buttonColor: AppColor.black10,
// buttonColor: AppColor.black10,
),
],
).paddingOnly(start: 13, end: 13, top: 14, bottom: 16),
@ -125,7 +128,8 @@ class _AssetRetiredState extends State<AssetRetired> with TickerProviderStateMix
for (var item in _attachments) {
String fileName =
CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
requestDetailProvider.assetRetiredHelperModel?.activityAssetToBeRetiredAttachments?.add(ActivityAssetToBeRetiredAttachments(id: item.id, name: fileName));
requestDetailProvider.assetRetiredHelperModel?.activityAssetToBeRetiredAttachments
?.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
int status = await requestDetailProvider.createActivityAssetToBeRetired();
if (status == 200) {

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/lookup.dart';
@ -308,6 +309,8 @@ class _SparePartRequestState extends State<SparePartRequest> {
),
AttachmentPicker(
label: context.translation.attachQuotation,
showAsListView: true,
moduleId: widget.fromCm?RequestAttachmentTypeEnum.sparePartActivity.id:RequestAttachmentTypeEnum.ppmSparePartActivity.id,
attachment: _attachments,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
buttonColor: AppColor.primary10,
@ -343,7 +346,8 @@ class _SparePartRequestState extends State<SparePartRequest> {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
model?.sparePartAttachments?.add(
SparePartAttachments(id: item.id, name: fileName),
GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType),
// SparePartAttachments(id: item.id, name: fileName),
);
}

@ -13,6 +13,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
@ -25,7 +26,6 @@ import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
import 'package:test_sa/modules/demo_module/provider/demo_period_lookup_provider.dart';
import 'package:test_sa/modules/demo_module/provider/demo_provider.dart';
import 'package:test_sa/modules/loan_module/models/loan_form_model.dart';
@ -495,36 +495,37 @@ class _CreateDemoRequestPageState extends State<CreateDemoRequestPage> with Tick
List<Widget> attachmentSection() {
return [
InfoHeader16Widget('Attachments'.addTranslation),
SingleItemDropDownMenu<Lookup, DemoDocumentLookupProvider>(
context: context,
height: 56.toScreenHeight,
title: "Document Type",
initialValue: demoDocumentLookup,
showShadow: false,
validator: (value) {
if (value == null) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
showAsBottomSheet: true,
onSelect: (value) {
demoDocumentLookup = value;
setState(() {});
},
),
// SingleItemDropDownMenu<Lookup, DemoDocumentLookupProvider>(
// context: context,
// height: 56.toScreenHeight,
// title: "Document Type",
// initialValue: demoDocumentLookup,
// showShadow: false,
// validator: (value) {
// if (value == null) return "Mandatory";
// return null;
// },
// backgroundColor: AppColor.fieldBgColor(context),
// showAsBottomSheet: true,
// onSelect: (value) {
// demoDocumentLookup = value;
// setState(() {});
// },
// ),
AttachmentPicker(
label: context.translation.attachments,
attachment: _attachments,
buttonColor: AppColor.primary10.withOpacity(demoDocumentLookup != null ? 1 : .4),
onlyImages: false,
enabled: demoDocumentLookup != null,
documentType: demoDocumentLookup,
// enabled: demoDocumentLookup != null,
// documentType: demoDocumentLookup,
showAsListView: true,
buttonIcon: 'image-plus'.toSvgAsset(color: (AppColor.primary10).withOpacity(demoDocumentLookup != null ? 1 : .4)),
onChange: (attachments) {
_attachments = attachments;
setState(() {});
},
moduleId: RequestAttachmentTypeEnum.demo.id,
buttonIcon: 'image-plus'.toSvgAsset(color: (AppColor.primary10)),
// onChange: (attachments) {
// _attachments = attachments;
// setState(() {});
// },
),
];
}
@ -537,7 +538,12 @@ class _CreateDemoRequestPageState extends State<CreateDemoRequestPage> with Tick
_demoFormModel.demoAttachment = [];
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_demoFormModel.demoAttachment?.add(DemoAttachments(id: 0, attachmentName: fileName, demoRequestId: 0, documentTypeId: item.documentTypeId!.id!));
_demoFormModel.demoAttachment?.add(GenericAttachmentModel(
id: 0,
name: fileName,
moduleReferenceId: 0,
documentType: item.documentType,
));
}
Utils.showLoading(context);
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);

@ -3,7 +3,9 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/views/widgets/images/files_list.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import '../../controllers/api_routes/urls.dart';
import '../../extensions/text_extensions.dart';
@ -53,14 +55,19 @@ class DemoActivitiesPage extends StatelessWidget {
12.height,
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
Text(
"Attachments".addTranslation,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e ?? '') ?? '').toList() ?? []),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: allAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e ?? '') ?? '').toList()),
],
],
).toShadowContainer(context, borderRadius: 14, backgroundColor: Color(0xffF4F8FC), showShadow: false),
).toShadowContainer(context, borderRadius: 14, backgroundColor: const Color(0xffF4F8FC), showShadow: false),
16.height,
Column(
crossAxisAlignment: CrossAxisAlignment.start,

@ -6,6 +6,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/demo_request_step.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
import 'package:test_sa/models/module_permissions_model.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
@ -91,8 +92,8 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
if (snapshot.connectionState == ConnectionState.waiting) return CircularProgressIndicator(color: AppColor.loadingColor(context)).center;
if (snapshot.data == null) return const NoDataFound().center;
List<DemoAttachments> allAttachments = snapshot.data!.demoAttachments! ?? [];
List<DemoAttachments> suppAttachments = snapshot.data!.supplierDemoAttachments! ?? [];
List<GenericAttachmentModel> allAttachments = snapshot.data!.demoAttachments! ?? [];
List<GenericAttachmentModel> suppAttachments = snapshot.data!.supplierDemoAttachments! ?? [];
DemoRequestModel demoData = snapshot.data!;
@ -125,18 +126,20 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments"),
4.height,
FilesList(
showAsListView: true,
images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList(),
types: allAttachments.map((e) => e.documentType?.name ?? '').toList()),
],
if (suppAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Supplier Attachments"),
4.height,
FilesList(
showAsListView: true,
images: suppAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList(),
types: suppAttachments.map((e) => e.documentType?.name ?? '').toList()),
images: suppAttachments.whereType<GenericAttachmentModel>().map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList(),
types: suppAttachments.whereType<GenericAttachmentModel>().map((e) => e.documentType?.name ?? '').toList()),
],
],
).toShadowContainer(context, padding: 12),

@ -6,7 +6,7 @@ import 'package:test_sa/providers/loading_list_notifier.dart';
import '../../controllers/api_routes/api_manager.dart';
import '../../controllers/api_routes/urls.dart';
import '../../models/lookup.dart';
///TODO need to remove this when we have real api for demo document types lookup
class DemoDocumentLookupProvider extends LoadingListNotifier<Lookup> {
@override
Future getData({int? id}) async {
@ -36,3 +36,4 @@ class DemoDocumentLookupProvider extends LoadingListNotifier<Lookup> {
}
}
}

@ -1,31 +1,33 @@
import 'package:test_sa/models/lookup.dart';
//TODO : need to remove this class
class DemoAttachments {
int? id;
num? demoRequestId;
num? documentTypeId;
Lookup? documentType;
String? attachmentName;
String? originalName;
DemoAttachments({this.id, this.documentTypeId, this.documentType, this.attachmentName, this.demoRequestId, this.originalName});
DemoAttachments.fromJson(dynamic json) {
id = json['id'];
documentTypeId = json['documentTypeId'];
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
demoRequestId = json['demoRequestId'];
attachmentName = json['attachmentName'];
originalName = json['originalName'];
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['documentTypeId'] = documentTypeId;
map['attachmentName'] = attachmentName;
map['demoRequestId'] = demoRequestId;
map['originalName'] = originalName;
return map;
}
}
// import 'package:test_sa/models/lookup.dart';
//
// class DemoAttachments {
// int? id;
// num? demoRequestId;
// Lookup? documentType;
// String? attachmentName;
// String? originalName;
//
// DemoAttachments({this.id, this.documentType, this.attachmentName, this.demoRequestId, this.originalName});
//
// DemoAttachments.fromJson(dynamic json) {
// id = json['id'];
// documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
// demoRequestId = json['demoRequestId'];
// attachmentName = json['attachmentName'];
// originalName = json['originalName'];
// }
//
// Map<String, dynamic> toJson() {
// final map = <String, dynamic>{};
// map['id'] = id;
// if(documentType!=null){
// map['documentTypeId'] = documentType?.id;
// }
// map['attachmentName'] = attachmentName;
// map['demoRequestId'] = demoRequestId;
// map['originalName'] = originalName;
// return map;
// }
// }

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/floor.dart';
@ -32,7 +33,7 @@ class DemoFormModel {
Rooms? room;
SuppEngineerWorkOrders? supEngineer;
SupplierDetails? vendor;
List<DemoAttachments>? demoAttachment;
List<GenericAttachmentModel>? demoAttachment;
bool demoEaluationAcknowledge;
bool acknowledgeNotEquipment;
@ -87,34 +88,7 @@ class DemoFormModel {
"demoEaluationAcknowledge": demoEaluationAcknowledge,
"acknowledgeNotEquipment": acknowledgeNotEquipment,
"demoAttachments":
// [
// {
// "id": 3,
// // "documentType": {
// // "id": 7748,
// // "name": "February",
// // "value": 2
// // },
// "documentTypeId": 7748,
// "attachmentName": "6c9f50b0-1c92-4ae9-ae64-7c284c61ea72.jpg",
// "originalName": "scaled_d245df97-1289-4d0c-92a0-569abedfb0db8154518103327960943.jpg",
// "demoRequestId": 3
// },
// {
// "id": 4,
// // "documentType": {
// // "id": 7748,
// // "name": "February",
// // "value": 2
// // },
// "documentTypeId": 7748,
// "attachmentName": "346e04f6-0f9b-4004-ad85-4cdbf8318f7c.jpg",
// "originalName": "scaled_85790b6c-7b16-46e6-891c-11c316d5897a2973693360957767376.jpg",
// "demoRequestId": 3
// }
// ]
demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
demoAttachment != null ? demoAttachment!.map((v) => v.toDemoJson()).toList() : [],
};
}
@ -123,7 +97,7 @@ class DemoFormModel {
"id": id,
"supplierId": vendor?.id,
"suppPersonId": supEngineer?.id,
"demoAttachments": demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
"demoAttachments": demoAttachment != null ? demoAttachment!.whereType<GenericAttachmentModel>().map((v) => v.toDemoJson()).toList() : [],
};
}
}

@ -1,8 +1,8 @@
import 'package:test_sa/models/device/asset_by_id_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
class DemoRequestModel {
@ -29,8 +29,8 @@ class DemoRequestModel {
SuppEngineerWorkOrders? suppPerson;
Lookup? status;
Lookup? endUserStatus;
List<DemoAttachments>? demoAttachments;
List<DemoAttachments>? supplierDemoAttachments;
List<GenericAttachmentModel>? demoAttachments;
List<GenericAttachmentModel>? supplierDemoAttachments;
dynamic demoAsset;
dynamic demoInstallationTaskJob;
dynamic demoPullOutTaskJob;
@ -96,8 +96,8 @@ class DemoRequestModel {
suppPerson = json['suppPerson'] != null ? (SuppEngineerWorkOrders.fromJson(json['suppPerson'])) : null;
status = json['status'] != null ? (Lookup.fromJson(json['status'])) : null;
endUserStatus = json['endUserStatus'] != null ? (Lookup.fromJson(json['endUserStatus'])) : null;
demoAttachments = json['demoAttachments'] != null ? (json['demoAttachments'] as List).map((e) => DemoAttachments.fromJson(e)).toList() : null;
supplierDemoAttachments = json['supplierDemoAttachments'] != null ? (json['supplierDemoAttachments'] as List).map((e) => DemoAttachments.fromJson(e)).toList() : null;
demoAttachments = json['demoAttachments'] != null ? (json['demoAttachments'] as List).map((e) => GenericAttachmentModel.fromDemoJson(e)).toList() : null;
supplierDemoAttachments = json['supplierDemoAttachments'] != null ? (json['supplierDemoAttachments'] as List).map((e) => GenericAttachmentModel.fromDemoJson(e)).toList() : null;
demoAsset = json['demoAsset'];
demoInstallationTaskJob = json['demoInstallationTaskJob'];
demoPullOutTaskJob = json['demoPullOutTaskJob'];
@ -124,8 +124,8 @@ class DemoRequestModel {
"demoPeriodId": demoPeriod?.id,
"supplierId": supplier?.id,
"suppPersonId": suppPerson?.id,
"demoAttachments": demoAttachments != null ? demoAttachments!.map((v) => v.toJson()).toList() : [],
"supplierDemoAttachments": supplierDemoAttachments != null ? supplierDemoAttachments!.map((v) => v.toJson()).toList() : [],
"demoAttachments": demoAttachments != null ? demoAttachments!.whereType<GenericAttachmentModel>().map((v) => v.toDemoJson()).toList() : [],
"supplierDemoAttachments": supplierDemoAttachments != null ? supplierDemoAttachments!.whereType<GenericAttachmentModel>().map((v) => v.toDemoJson()).toList() : [],
};
}
}

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
@ -20,7 +21,6 @@ import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
import 'package:test_sa/modules/demo_module/models/demo_request_model.dart';
import 'package:test_sa/modules/demo_module/provider/demo_period_lookup_provider.dart';
import 'package:test_sa/modules/demo_module/provider/demo_provider.dart';
@ -161,9 +161,9 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
attachments.clear();
if (widget.dataModel.demoAttachments?.isNotEmpty ?? false) {
for (final item in widget.dataModel.demoAttachments!) {
if ((item.attachmentName ?? '').isNotEmpty) {
if ((item.name ?? '').isNotEmpty) {
attachments.add(
GenericAttachmentModel(name: item.attachmentName, id: item.id ?? 0, originalName: item.originalName, documentTypeId: item.documentType),
GenericAttachmentModel(name: item.name, id: item.id ?? 0, originalName: item.originalName, documentType: item.documentType),
);
}
}
@ -201,33 +201,34 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
16.height,
"Attachments".bodyText(context).custom(color: AppColor.black10),
8.height,
SingleItemDropDownMenu<Lookup, DemoDocumentLookupProvider>(
context: context,
height: 56.toScreenHeight,
title: "Document Type",
initialValue: demoDocumentLookup,
showShadow: false,
validator: (value) {
if (value == null) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
showAsBottomSheet: true,
onSelect: (value) {
demoDocumentLookup = value;
setState(() {});
},
),
16.height,
///Need to confirm we can use same lookup..
// SingleItemDropDownMenu<Lookup, DemoDocumentLookupProvider>(
// context: context,
// height: 56.toScreenHeight,
// title: "Document Type",
// initialValue: demoDocumentLookup,
// showShadow: false,
// validator: (value) {
// if (value == null) return "Mandatory";
// return null;
// },
// backgroundColor: AppColor.fieldBgColor(context),
// showAsBottomSheet: true,
// onSelect: (value) {
// demoDocumentLookup = value;
// setState(() {});
// },
// ),
// 16.height,
AttachmentPicker(
label: context.translation.attachments,
attachment: attachments,
buttonColor: AppColor.black10.withOpacity(demoDocumentLookup != null ? 1 : .4),
onlyImages: false,
documentType: demoDocumentLookup,
enabled: demoDocumentLookup != null,
moduleId: RequestAttachmentTypeEnum.demo.id,
showAsListView: true,
buttonIcon: 'image-plus'.toSvgAsset(color: (AppColor.primary10).withOpacity(demoDocumentLookup != null ? 1 : .4)),
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
),
],
).toShadowContainer(context, borderRadius: 20),
@ -615,7 +616,13 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
//Todo need to pass attachmentType id as well.
_demoFormModel.demoAttachment?.add(DemoAttachments(id: item.id, demoRequestId: _demoFormModel.id ?? 0, attachmentName: fileName,originalName: fileName, documentTypeId: item.documentTypeId!.id));
_demoFormModel.demoAttachment?.add(GenericAttachmentModel(
id: item.id,
name: fileName,
originalName: fileName,
moduleReferenceId: _demoFormModel.id ?? 0,
documentType: item.documentType,
));
}
Utils.showLoading(context);
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
@ -41,7 +42,6 @@ import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import '../../models/new_models/department.dart';
import '../../new_views/swipe_module/dialoge/info_dialog.dart';
import 'flow_medical_department_provider.dart';
import 'incident_attachment_model.dart';
class CreateIncidentRequestPage extends StatefulWidget {
static const String id = "/create-incident";
@ -172,6 +172,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
label: context.translation.attachments,
attachment: attachments,
buttonColor: AppColor.black10,
moduleId: RequestAttachmentTypeEnum.incidents.id,
onlyImages: false,
showAsListView: true,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -694,16 +695,16 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
payload["occurrenceDate"] = occurrenceDate!.toIso8601String();
_formKey.currentState!.save();
List<IncidentAttachments> attachmentList = [];
List<GenericAttachmentModel> attachmentList = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
attachmentList.add(IncidentAttachments(id: 0, attachmentName: fileName, incidentId: 0));
attachmentList.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: 0,documentType: item.documentType));
}
Utils.showLoading(context);
IncidentProvider incidentProvider = Provider.of<IncidentProvider>(context, listen: false);
payload["incidentAttachments"] = attachmentList.map((v) => v.toJson()).toList();
payload["incidentAttachments"] = attachmentList.map((v) => v.toIncidentJson()).toList();
bool isSuccess = await incidentProvider.addIncidentRequest(payload);
Utils.hideLoading(context);
if (isSuccess) {

@ -1,24 +1,26 @@
class IncidentAttachments {
num? id;
num? incidentId;
String? attachmentName;
String? attachmentDescription;
//TODO : need to delete this
IncidentAttachments({this.id, this.attachmentName, this.incidentId, this.attachmentDescription});
IncidentAttachments.fromJson(dynamic json) {
id = json['id'];
incidentId = json['incidentId'];
attachmentName = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['attachmentName'] = attachmentName;
map['incidentId'] = incidentId;
map['attachmentDescription'] = attachmentDescription;
return map;
}
}
// class IncidentAttachments {
// num? id;
// num? incidentId;
// String? attachmentName;
// String? attachmentDescription;
//
// IncidentAttachments({this.id, this.attachmentName, this.incidentId, this.attachmentDescription});
//
// IncidentAttachments.fromJson(dynamic json) {
// id = json['id'];
// incidentId = json['incidentId'];
// attachmentName = json['attachmentName'];
// attachmentDescription = json['attachmentDescription'];
// }
//
// Map<String, dynamic> toJson() {
// final map = <String, dynamic>{};
// map['id'] = id;
// map['attachmentName'] = attachmentName;
// map['incidentId'] = incidentId;
// map['attachmentDescription'] = attachmentDescription;
// return map;
// }
// }

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/incident_module/incident_attachment_model.dart';
class IncidentDataModel {
@ -73,7 +74,7 @@ class IncidentDataModel {
String? approvalSignature;
String? occurrenceDate;
String? createdDate;
List<IncidentAttachments>? incidentAttachments;
List<GenericAttachmentModel>? incidentAttachments;
int? workOrderId;
String? workOrderNo;
@ -230,9 +231,9 @@ class IncidentDataModel {
workOrderId = json['workOrderId'];
workOrderNo = json['workOrderNo'];
if (json['incidentAttachments'] != null) {
incidentAttachments = <IncidentAttachments>[];
incidentAttachments = <GenericAttachmentModel>[];
json['incidentAttachments'].forEach((v) {
incidentAttachments!.add(IncidentAttachments.fromJson(v));
incidentAttachments!.add(GenericAttachmentModel.fromIncidentJson(v));
});
}
}
@ -314,7 +315,7 @@ class IncidentDataModel {
data['workOrderId'] = this.workOrderId;
data['workOrderNo'] = this.workOrderNo;
if (this.incidentAttachments != null) {
data['incidentAttachments'] = this.incidentAttachments!.map((v) => v.toJson()).toList();
data['incidentAttachments'] = this.incidentAttachments!.map((v) => v.toIncidentJson()).toList();
}
return data;
}

@ -9,6 +9,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cm_module/cm_detail_page.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/incident_module/incident_attachment_model.dart';
@ -40,44 +41,51 @@ class IncidentDetailPage extends StatelessWidget {
if (snapshot.connectionState == ConnectionState.waiting) return CircularProgressIndicator(color: AppColor.loadingColor(context)).center;
if (snapshot.data == null) return const NoDataFound().center;
List<IncidentAttachments> allAttachments = snapshot.data!.incidentAttachments!;
List<GenericAttachmentModel> allAttachments = (snapshot.data!.incidentAttachments ?? []).whereType<GenericAttachmentModel>().toList();
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StatusLabel(
label: snapshot.data!.incidentStatusName!,
textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.incidentStatusName!),
backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.incidentStatusName!),
),
1.width.expanded,
InfoDateWidget(snapshot.data!.createdDate?.toString() ?? ""),
],
),
// 12.height,
...requesterDetails(context, snapshot.data!),
const Divider().defaultStyle(context),
...requestDetails(context, snapshot.data!),
if (snapshot.data!.ovrTicketNumber?.isNotEmpty ?? false) ovrInformation(context, snapshot.data!.ovrTicketNumber!),
const Divider().defaultStyle(context),
...assetDetails(context, snapshot.data!),
const Divider().defaultStyle(context),
...personInvolvedDetails(context, snapshot.data!),
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StatusLabel(
label: snapshot.data!.incidentStatusName!,
textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.incidentStatusName!),
backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.incidentStatusName!),
),
1.width.expanded,
InfoDateWidget(snapshot.data!.createdDate?.toString() ?? ""),
],
),
// 12.height,
...requesterDetails(context, snapshot.data!),
const Divider().defaultStyle(context),
...requestDetails(context, snapshot.data!),
if (snapshot.data!.ovrTicketNumber?.isNotEmpty ?? false) ovrInformation(context, snapshot.data!.ovrTicketNumber!),
const Divider().defaultStyle(context),
...assetDetails(context, snapshot.data!),
const Divider().defaultStyle(context),
...personInvolvedDetails(context, snapshot.data!),
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: allAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
).toShadowContainer(context),
);
}),
));
],
).toShadowContainer(context),
);
})));
}
List<Widget> requestDetails(BuildContext context, IncidentDataModel incidentData) {

@ -1,4 +1,4 @@
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
class EngineerData {
int? id;
@ -9,7 +9,7 @@ class EngineerData {
bool? isComplete;
int? statusId;
int? requestId;
List<InternalAuditAttachments>? attachments;
List<GenericAttachmentModel>? attachments;
EngineerData({
this.id,
@ -32,7 +32,7 @@ class EngineerData {
isComplete = json['isComplete'];
statusId = json['statusId'];
requestId = json['requestId'];
attachments = json['attachments'] != null ? (json['attachments'] as List).map((e) => InternalAuditAttachments.fromJson(e)).toList() : [];
attachments = json['attachments'] != null ? (json['attachments'] as List).map((e) => GenericAttachmentModel.fromInternalAuditJson(e)).toList() : [];
}
Map<String, dynamic> toJson() {
@ -46,7 +46,7 @@ class EngineerData {
data['statusId'] = statusId;
data['requestId'] = requestId;
if (attachments != null) {
data['attachments'] = attachments!.map((e) => e.toJson()).toList();
data['attachments'] = attachments!.whereType<GenericAttachmentModel>().map((e) => e.toInternalAuditJson()).toList();
}
return data;
}

@ -1,6 +1,5 @@
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/engineer_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_timer_model.dart';
class EquipmentInternalAuditDataModel {
@ -15,7 +14,7 @@ class EquipmentInternalAuditDataModel {
dynamic manufacture;
String? remarks;
List<EquipmentsFinding>? equipmentsFindings;
List<InternalAuditAttachments>? attachments;
List<GenericAttachmentModel>? attachments;
EngineerData? engineerData;
@ -54,7 +53,7 @@ class EquipmentInternalAuditDataModel {
}
attachments = json['attachments'] != null
? (json['attachments'] as List)
.map((e) => InternalAuditAttachments.fromJson(e))
.map((e) => GenericAttachmentModel.fromInternalAuditJson(e))
.where((e) => e.name != null) // optional filter if you want to skip null names
.toList()
: [];
@ -86,7 +85,9 @@ class EquipmentInternalAuditDataModel {
data['equipmentsFindings'] =
equipmentsFindings!.map((v) => v.toJson()).toList();
}
data['attachments'] = attachments;
if (attachments != null) {
data['attachments'] = attachments!.whereType<GenericAttachmentModel>().map((v) => v.toInternalAuditJson()).toList();
}
if (engineerData != null) data['engineerData'] = engineerData!.toJson();
return data;
}

@ -5,7 +5,7 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
class EquipmentInternalAuditFormModel {
int? id=0;
@ -14,7 +14,7 @@ class EquipmentInternalAuditFormModel {
String? woOrderNo;
List<String>? devicePhotos;
List<Lookup> findings =[];
List<InternalAuditAttachments> attachments = [];
List<GenericAttachmentModel> attachments = [];
String? remarks;
Asset? device;
EquipmentInternalAuditFormModel({
@ -32,7 +32,7 @@ class EquipmentInternalAuditFormModel {
'assetId': device?.id,
'auditorId': auditorId,
'findings': findings.map((e) => {'findingId': e.value}).toList(),
'attachments': attachments.map((e) => e.toJson()).toList(),
'attachments': attachments.whereType<GenericAttachmentModel>().map((e) => e.toInternalAuditJson()).toList(),
'remarks': remarks,
};
}

@ -1,26 +1,32 @@
import 'dart:developer';
class InternalAuditAttachments {
InternalAuditAttachments({this.id, this.originalName, this.name, this.createdBy});
int? id;
String? name;
String? originalName;
String? createdBy;
InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
originalName = json['originalName'];
createdBy = json['createdBy'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['originalName'] = originalName;
// data['createdBy'] = createdBy;
return data;
}
}
//TODO : need to remove this class.
// import 'dart:developer';
//
// import 'package:test_sa/models/lookup.dart';
//
// class InternalAuditAttachments {
// InternalAuditAttachments({this.id, this.originalName, this.name, this.createdBy,this.documentType});
//
// int? id;
// String? name;
// String? originalName;
// String? createdBy;
// Lookup ? documentType;
//
// InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
// originalName = json['originalName'];
// createdBy = json['createdBy'];
// documentType =json['documentType'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = <String, dynamic>{};
// data['id'] = id;
// data['name'] = name;
// data['originalName'] = originalName;
// data['documentTypeId'] = documentType?.id;
// // data['createdBy'] = createdBy;
// return data;
// }
// }

@ -1,6 +1,6 @@
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/internal_audit_module/models/engineer_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_form_model.dart';
class SystemInternalAuditDataModel {
@ -19,7 +19,7 @@ class SystemInternalAuditDataModel {
String? createdDate;
String? modifiedBy;
String? modifiedDate;
List<InternalAuditAttachments>? attachments;
List<GenericAttachmentModel>? attachments;
EngineerData? engineerData;
SystemInternalAuditDataModel({
@ -60,7 +60,7 @@ class SystemInternalAuditDataModel {
modifiedDate = json['modifiedDate'];
attachments = json['attachments'] != null
? (json['attachments'] as List)
.map((e) => InternalAuditAttachments.fromJson(e))
.map((e) => GenericAttachmentModel.fromInternalAuditJson(e))
.where((e) => e.name != null) // optional filter if you want to skip null names
.toList()
: [];
@ -84,6 +84,9 @@ class SystemInternalAuditDataModel {
data['createdDate'] = createdDate;
data['modifiedBy'] = modifiedBy;
data['modifiedDate'] = modifiedDate;
if (attachments != null) {
data['attachments'] = attachments!.whereType<GenericAttachmentModel>().map((v) => v.toInternalAuditJson()).toList();
}
if (engineerData != null) data['engineerData'] = engineerData!.toJson();
return data;
}

@ -1,7 +1,7 @@
import 'dart:developer';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
class SystemInternalAuditFormModel {
int? id;
@ -13,7 +13,7 @@ class SystemInternalAuditFormModel {
int? correctiveMaintenanceId;
int? planPreventiveVisitId;
int? assetTransferId;
List<InternalAuditAttachments>? attachments = [];
List<GenericAttachmentModel>? attachments = [];
int? taskJobId;
int? taskAlertJobId;
int? gasRefillId;
@ -56,7 +56,7 @@ class SystemInternalAuditFormModel {
'gasRefillId': gasRefillId,
'planRecurrentTaskId': planRecurrentTaskId,
'statusId': statusId,
'attachments': attachments?.map((e) => e.toJson()).toList(),
'attachments': attachments?.whereType<GenericAttachmentModel>().map((e) => e.toInternalAuditJson()).toList(),
};
}
}

@ -1,5 +1,5 @@
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_timer_model.dart';
class AuditFormModel {
@ -10,7 +10,7 @@ class AuditFormModel {
DateTime? startTime;
DateTime? endTime;
double? totalHours;
List<InternalAuditAttachments>? attachments;
List<GenericAttachmentModel>? attachments;
bool? isComplete;
TimerModel? auditTimerModel = TimerModel();
List<InternalAuditTimerModel>? auditTimers = [];
@ -40,7 +40,7 @@ class AuditFormModel {
endTime = json['endTime'] != null ? DateTime.tryParse(json['endTime']) : null;
totalHours = json['totalHours']?.toDouble();
if (json['attachments'] != null) {
attachments = (json['attachments'] as List).map((e) => InternalAuditAttachments.fromJson(e)).toList();
attachments = (json['attachments'] as List).map((e) => GenericAttachmentModel.fromInternalAuditJson(e)).toList();
}
isComplete = json['isComplete'];
}
@ -54,7 +54,7 @@ class AuditFormModel {
'endTime': endTime?.toIso8601String(),
// 'auditTimer': auditTimers,
'totalHours': totalHours,
'attachments': attachments?.map((e) => e.toJson()).toList(),
'attachments': attachments?.whereType<GenericAttachmentModel>().map((e) => e.toInternalAuditJson()).toList(),
'isComplete': isComplete,
};
}

@ -8,12 +8,13 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/equipment_internal_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_checklist_provider.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
@ -119,6 +120,8 @@ class _CreateEquipmentInternalAuditFormState extends State<CreateEquipmentIntern
AttachmentPicker(
label: context.translation.attachments,
attachment: _attachments,
showAsListView: true,
moduleId: RequestAttachmentTypeEnum.equipmentInternalAudit.id,
buttonColor: AppColor.primary10,
onlyImages: false,
onChange: (value) {},
@ -144,7 +147,11 @@ class _CreateEquipmentInternalAuditFormState extends State<CreateEquipmentIntern
_equipmentinternalAuditModel.attachments = [];
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_equipmentinternalAuditModel.attachments.add(InternalAuditAttachments(id: item.id, name: fileName));
_equipmentinternalAuditModel.attachments.add(GenericAttachmentModel(
id: item.id,
name: fileName,
documentType: item.documentType,
));
}
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
_equipmentinternalAuditModel.auditorId = context.userProvider.user?.userID;

@ -10,7 +10,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/equipment_internal_audit_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
@ -41,7 +41,7 @@ class _EquipmentInternalAuditDetailPageState extends State<EquipmentInternalAudi
bool isWoType = true;
EquipmentInternalAuditDataModel? model;
late InternalAuditProvider _internalAuditProvider;
List<InternalAuditAttachments> allAttachments = [];
List<GenericAttachmentModel> allAttachments = [];
@override
void initState() {
@ -56,8 +56,8 @@ class _EquipmentInternalAuditDetailPageState extends State<EquipmentInternalAudi
model = await _internalAuditProvider.getEquipmentInternalAuditById(widget.auditId);
allAttachments.clear();
allAttachments = [
...(model?.attachments ?? []),
...(model?.engineerData?.attachments ?? []),
...(model?.attachments?.whereType<GenericAttachmentModel>() ?? []),
...(model?.engineerData?.attachments?.whereType<GenericAttachmentModel>() ?? []),
];
}
@ -118,17 +118,24 @@ class _EquipmentInternalAuditDetailPageState extends State<EquipmentInternalAudi
if (model?.remarks?.isNotEmpty ?? false) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Remarks"),
Text(model!.remarks??'',style: AppTextStyles.bodyText2.copyWith(color: AppColor.lightTextColor(context)),),
Text(
model!.remarks ?? '',
style: AppTextStyles.bodyText2.copyWith(color: AppColor.lightTextColor(context)),
),
8.height,
],
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
Text(
"Attachments".addTranslation,
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
8.height,
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: allAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
],
).paddingAll(0).toShadowContainer(context),

@ -10,14 +10,14 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_timer_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/update_audit_form_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/equipment_internal_audit_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/update_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -26,6 +26,7 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/new_views/common_widgets/working_time_tile.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/total_working_time_detail_bottomsheet.dart';
@ -62,7 +63,7 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
formModel.requestId = widget.model?.id;
formModel.id = widget.model?.id;
formModel.debrief = widget.model?.engineerData?.debrief;
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
_attachments = widget.model?.engineerData?.attachments?.whereType<GenericAttachmentModel>().map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name ?? '')).toList() ?? [];
calculateWorkingTime();
}
@ -129,9 +130,10 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name?.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
formModel.attachments!.add(
InternalAuditAttachments(
GenericAttachmentModel(
id: item.id,
originalName: fileName,
documentType: item.documentType,
name: fileName,
),
);
@ -221,6 +223,8 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
AttachmentPicker(
label: 'Upload Attachment',
attachment: _attachments,
showAsListView: true,
moduleId: RequestAttachmentTypeEnum.equipmentInternalAudit.id,
buttonColor: AppColor.primary10,
onlyImages: false,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),

@ -9,13 +9,14 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/equipment_internal_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/system_audit_work_order_auto_complete_field.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_checklist_provider.dart';
@ -152,6 +153,8 @@ class _CreateSystemInternalAuditFormState extends State<CreateSystemInternalAudi
16.height,
AttachmentPicker(
label: context.translation.attachments,
showAsListView: true,
moduleId: RequestAttachmentTypeEnum.systemInternalAudit.id,
attachment: _attachments,
buttonColor: AppColor.primary10,
onlyImages: false,
@ -178,10 +181,14 @@ class _CreateSystemInternalAuditFormState extends State<CreateSystemInternalAudi
InternalAuditProvider internalAuditProvider = Provider.of<InternalAuditProvider>(context, listen: false);
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
_model.attachments=[];
_model.attachments = [];
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_model.attachments?.add(InternalAuditAttachments(id: item.id, name: fileName));
_model.attachments?.add(GenericAttachmentModel(
id: item.id,
name: fileName,
documentType: item.documentType,
));
}
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
_model.auditorId = context.userProvider.user?.userID;

@ -9,7 +9,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/update_system_internal_audit_page.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
@ -39,7 +39,7 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
bool isWoType = true;
SystemInternalAuditDataModel? model;
late InternalAuditProvider _internalAuditProvider;
List<InternalAuditAttachments> allAttachments = [];
List<GenericAttachmentModel> allAttachments = [];
@override
void initState() {
@ -54,8 +54,8 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
model = await _internalAuditProvider.getInternalSystemAuditById(widget.auditId);
allAttachments.clear();
allAttachments = [
...(model?.attachments ?? []),
...(model?.engineerData?.attachments ?? []),
...(model?.attachments?.whereType<GenericAttachmentModel>() ?? []),
...(model?.engineerData?.attachments?.whereType<GenericAttachmentModel>() ?? []),
];
}
@ -86,19 +86,19 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
StatusLabel(
label: model!.status!.name,
id: model!.status!.value,
label: model?.status?.name,
id: model?.status?.value,
radius: 4,
textColor: AppColor.getRequestStatusTextColorByName(
context,
model!.status!.name,
model?.status?.name,
),
backgroundColor: AppColor.getRequestStatusColorByName(
context,
model!.status!.name,
model?.status?.name,
),
),
InfoDateWidget(model!.createdDate?.toString() ?? ""),
InfoDateWidget(model?.createdDate?.toString() ?? ""),
],
),
8.height,
@ -117,7 +117,15 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
8.height,
FilesList(
showAsListView: true,
types: allAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
],
).paddingAll(0).toShadowContainer(context),

@ -10,14 +10,13 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_timer_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/update_audit_form_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -62,7 +61,7 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
formModel.requestId = widget.model?.id;
formModel.id = widget.model?.id;
formModel.debrief = widget.model?.engineerData?.debrief;
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
_attachments = widget.model?.engineerData?.attachments?.whereType<GenericAttachmentModel>().map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name ?? '')).toList() ?? [];
calculateWorkingTime();
}
@ -130,8 +129,9 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name?.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
formModel.attachments!.add(
InternalAuditAttachments(
GenericAttachmentModel(
id: item.id,
documentType: item.documentType,
// originalName: fileName,
name: fileName,
),
@ -211,7 +211,9 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
16.height,
AttachmentPicker(
label: 'Upload Attachment',
showAsListView: true,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.systemInternalAudit.id,
buttonColor: AppColor.primary10,
onlyImages: false,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),

@ -1,39 +1,40 @@
class LoanAttachmentModel {
int? loanId;
String? attachmentName;
int? loanAttachmentTypeId;
String? attachmentDescription;
int? id;
String? createdBy;
String? createdDate;
String? modifiedBy;
String? modifiedDate;
LoanAttachmentModel({this.loanId, this.attachmentName, this.loanAttachmentTypeId, this.attachmentDescription, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate});
LoanAttachmentModel.fromJson(Map<String, dynamic> json) {
loanId = json['loanId'];
attachmentName = json['attachmentName'];
loanAttachmentTypeId = json['loanAttachmentTypeId'];
attachmentDescription = json['attachmentDescription'];
id = json['id'];
createdBy = json['createdBy'];
createdDate = json['createdDate'];
modifiedBy = json['modifiedBy'];
modifiedDate = json['modifiedDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['loanId'] = this.loanId;
data['attachmentName'] = this.attachmentName;
data['loanAttachmentTypeId'] = this.loanAttachmentTypeId;
data['attachmentDescription'] = this.attachmentDescription;
data['id'] = this.id;
data['createdBy'] = this.createdBy;
data['createdDate'] = this.createdDate;
data['modifiedBy'] = this.modifiedBy;
data['modifiedDate'] = this.modifiedDate;
return data;
}
}
//TODO need to delete this .
// class LoanAttachmentModel {
// int? loanId;
// String? attachmentName;
// int? loanAttachmentTypeId;
// String? attachmentDescription;
// int? id;
// String? createdBy;
// String? createdDate;
// String? modifiedBy;
// String? modifiedDate;
//
// LoanAttachmentModel({this.loanId, this.attachmentName, this.loanAttachmentTypeId, this.attachmentDescription, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate});
//
// LoanAttachmentModel.fromJson(Map<String, dynamic> json) {
// loanId = json['loanId'];
// attachmentName = json['attachmentName'];
// loanAttachmentTypeId = json['loanAttachmentTypeId'];
// attachmentDescription = json['attachmentDescription'];
// id = json['id'];
// createdBy = json['createdBy'];
// createdDate = json['createdDate'];
// modifiedBy = json['modifiedBy'];
// modifiedDate = json['modifiedDate'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['loanId'] = this.loanId;
// data['attachmentName'] = this.attachmentName;
// data['loanAttachmentTypeId'] = this.loanAttachmentTypeId;
// data['attachmentDescription'] = this.attachmentDescription;
// data['id'] = this.id;
// data['createdBy'] = this.createdBy;
// data['createdDate'] = this.createdDate;
// data['modifiedBy'] = this.modifiedBy;
// data['modifiedDate'] = this.modifiedDate;
// return data;
// }
// }

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/mapped_sites.dart';
import 'package:test_sa/models/new_models/site.dart';
@ -24,7 +25,7 @@ class LoanFormModel {
SupplierDetails? supplier;
SuppEngineerWorkOrders? supEngineer;
MedicalDepartmentModel? department;
List<LoanAttachments>? loanAttachment;
List<GenericAttachmentModel>? loanAttachment;
MappedSite? mappedSite;
TrafDepartment? mappedDepartment;
@ -51,40 +52,6 @@ class LoanFormModel {
this.mappedDepartment,
});
//{
// "id": 0,
// "employeeId": "fa29a9de-1337-4729-b823-68c6ecffdd33",
// "requestorUserID": "fa29a9de-1337-4729-b823-68c6ecffdd33",
// "employeeName": "engineer-dev",
// "employeeEmail": "Engineer_Dev@yahoo.com",
// "positionName": "High",
// "requesterExtensionNumber": "7726",
// "requesterContactNumber": "72132197",
// "siteId": 1,
// "departmentId": 5,
// "loanTypeId": 6448,
// "doctorName": "Doctor A",
// "doctorContact": "0561432451",
// "doctorEmail": "doctor@test.com",
// "itemDescription": "Test item",
// "requestDescription": "Test request",
// "loanPeriodId": 6453,
// "assetId": null,
// "assetNumber": "",
// "assetName": "",
// "assetSerialNumber": "",
// "model": "Model A",
// "manufacturer": "Siemens",
// "vendorName": "Vendor A",
// "vendorRepName": "Vendor Rep A",
// "vendorContact": "0561432455",
// "vendorEmail": "vendor@test.com",
// "loanStatusId": 1,
// "loanAttachments": [],
// "submittedAt": "2025-11-13T12:11:12.673Z",
// "updatedAt": null,
// "cMWOItemId": null
// }
Map<String, dynamic> toJson() {
return {
@ -103,50 +70,10 @@ class LoanFormModel {
"vendorContact": vendorNumber,
"vendorEmail": vendorEmail,
"isNewVendor": isNewVendor,
// 'siteId': site?.id,
'siteId': mappedSite?.id,
// 'departmentId': department?.id,
'departmentId': mappedDepartment?.id,
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [],
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toLoanJson()).toList() : [],
};
}
}
class LoanAttachments {
num? id;
num? loanAttachmentTypeId;
num? loanId;
String? attachmentName;
String? attachmentDescription;
LoanAttachments({this.id, this.loanAttachmentTypeId, this.attachmentName, this.loanId, this.attachmentDescription});
LoanAttachments.fromJson(dynamic json) {
id = json['id'];
loanAttachmentTypeId = json['loanAttachmentTypeId'];
loanId = json['loanId'];
attachmentName = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
}
// LoanAttachments copyWith({
// num? id, // Parameter is now nullable
// String? name, // Parameter is now nullable
// String? originalName, // Parameter is now nullable
// }) =>
// LoanAttachments(
// id: id ?? this.id,
// name: name ?? this.name,
// originalName: originalName ?? this.originalName,
// );
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loanAttachmentTypeId'] = loanAttachmentTypeId;
map['attachmentName'] = attachmentName;
map['loanId'] = loanId;
map['attachmentDescription'] = attachmentDescription;
return map;
}
}

@ -1,14 +1,14 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/loan_module/models/loan_form_model.dart';
class LoanInstallationPullOutFormModel {
String? snNo;
DateTime? date;
Uint8List? signature;
List<LoanAttachments>? loanAttachment;
List<GenericAttachmentModel>? loanAttachment;
TimerModel? timerModel = TimerModel();
DateTime? startTime;
DateTime? endTime;
@ -32,13 +32,11 @@ class LoanInstallationPullOutFormModel {
});
Map<String, dynamic> toJson() {
//Need to check payload parm they need
return {
// 'snNo': snNo,
'serialNumber': snNo,
'installationDate': date?.toIso8601String(),
'pulloutDate': date?.toIso8601String(),
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [],
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toLoanJson()).toList() : [],
"installationSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
"signature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
"pulloutSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
@ -53,16 +51,11 @@ class LoanInstallationPullOutFormModel {
}
Map<String, dynamic> toInstallationJson() {
//Need to check payload parm they need
return {
// 'snNo': snNo,
'serialNumber': snNo,
'installationDate': date?.toIso8601String(),
// 'pulloutDate': date?.toIso8601String(),
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [],
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toLoanJson()).toList() : [],
"installationSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
// "signature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
// "pulloutSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
'startTime': startTime?.toIso8601String(),
'endTime': endTime?.toIso8601String(),
'totalHours': totalHours,
@ -74,15 +67,10 @@ class LoanInstallationPullOutFormModel {
}
Map<String, dynamic> toPulloutJson() {
//Need to check payload parm they need
return {
// 'snNo': snNo,
'serialNumber': snNo,
// 'installationDate': date?.toIso8601String(),
'pulloutDate': date?.toIso8601String(),
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [],
// "installationSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
// "signature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toLoanJson()).toList() : [],
"pulloutSignature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
'startTime': startTime?.toIso8601String(),
'endTime': endTime?.toIso8601String(),

@ -1,3 +1,4 @@
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'loan_attachment_model.dart';
@ -34,7 +35,7 @@ class LoanRequestModel {
String? vendorRepName;
String? vendorContact;
String? vendorEmail;
List<LoanAttachmentModel>? loanAttachments;
List<GenericAttachmentModel>? loanAttachments;
int? loanStatusId;
String? loanStatusName;
int? loanStatusValue;
@ -154,11 +155,11 @@ class LoanRequestModel {
vendorRepName = json['vendorRepName'];
vendorContact = json['vendorContact'];
vendorEmail = json['vendorEmail'];
loanAttachments = <LoanAttachmentModel>[];
loanAttachments = <GenericAttachmentModel>[];
if (json['loanAttachments'] != null) {
loanAttachments = <LoanAttachmentModel>[];
loanAttachments = <GenericAttachmentModel>[];
json['loanAttachments'].forEach((v) {
loanAttachments!.add(new LoanAttachmentModel.fromJson(v));
loanAttachments!.add(GenericAttachmentModel.fromLoanDetailJson(v));
});
}
loanStatusId = json['loanStatusId'];
@ -222,8 +223,8 @@ class LoanRequestModel {
data['vendorRepName'] = this.vendorRepName;
data['vendorContact'] = this.vendorContact;
data['vendorEmail'] = this.vendorEmail;
if (this.loanAttachments != null) {
data['loanAttachments'] = this.loanAttachments!.map((v) => v.toJson()).toList();
if (loanAttachments != null) {
data['loanAttachments'] = loanAttachments!.map((v) => v.toLoanDetailJson()).toList();
}
data['loanStatusId'] = this.loanStatusId;
data['loanStatusName'] = this.loanStatusName;

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/mapped_sites.dart';
@ -155,6 +156,7 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
AttachmentPicker(
label: context.translation.attachments,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.loanEquipment.id,
onlyImages: false,
showAsListView: true,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -627,7 +629,7 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
_loanFormModel.loanAttachment = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_loanFormModel.loanAttachment?.add(LoanAttachments(id: 0, attachmentName: fileName, loanId: 0));
_loanFormModel.loanAttachment?.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: 0,documentType: item.documentType));
}
Utils.showLoading(context);
LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
@ -166,6 +167,7 @@ class _InstallationFormViewState extends State<InstallationFormView> {
attachment: _attachments,
buttonColor: AppColor.primary10,
onlyImages: false,
moduleId: RequestAttachmentTypeEnum.loanEquipment.id,
showAsListView: true,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),
onChange: (attachments) {
@ -209,7 +211,7 @@ class _InstallationFormViewState extends State<InstallationFormView> {
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_formData.loanAttachment!.add(LoanAttachments(id: 0, attachmentName: fileName, loanId: widget.loanData?.id));
_formData.loanAttachment!.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: widget.loanData?.id, documentType: item.documentType));
}
Utils.showLoading(context);
_formData.loanStatusId = widget.loanData?.loanStatusValue;

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
@ -169,6 +170,7 @@ class _InstallationPullOutFormViewState extends State<InstallationPullOutFormVie
label: context.translation.attachments,
attachment: _attachments,
buttonColor: AppColor.primary10,
moduleId: RequestAttachmentTypeEnum.loanEquipment.id,
onlyImages: false,
showAsListView: true,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),
@ -217,7 +219,7 @@ class _InstallationPullOutFormViewState extends State<InstallationPullOutFormVie
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_formData.loanAttachment!.add(LoanAttachments(id: 0, attachmentName: fileName, loanId: widget.loanData?.id));
_formData.loanAttachment!.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: widget.loanData?.id));
}
Utils.showLoading(context);
LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);

@ -83,8 +83,8 @@ class InstallationDetailsView extends StatelessWidget {
"Uploads Phase 2 docs".addTranslation,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
8.height,
FilesList(showAsListView: true, images: loanData.loanAttachments?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
4.height,
FilesList(showAsListView: true, images: loanData.loanAttachments?.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
],
).toShadowContainer(context, borderRadius: 20),

@ -6,6 +6,8 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/loan_module/provider/loan_provider.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/loan_module/models/loan_attachment_model.dart';
@ -59,7 +61,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
if (snapshot.connectionState == ConnectionState.waiting) return CircularProgressIndicator(color: AppColor.loadingColor(context)).center;
if (snapshot.data == null) return const NoDataFound().center;
List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
List<GenericAttachmentModel> allAttachments = (snapshot.data!.loanAttachments ?? []).whereType<GenericAttachmentModel>().toList();
return Column(children: [
ListView(
@ -95,7 +97,15 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
4.height,
FilesList(
showAsListView: true,
types: allAttachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
],
).toShadowContainer(context)

@ -6,6 +6,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/medical_gas_inspection/create_medical_gas_request_page.dart';
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
@ -103,7 +104,15 @@ class _MedicalGasInspectionDetailPageState extends State<MedicalGasInspectionDet
if (model!.deliveryNoteAttachmentDto.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: model!.deliveryNoteAttachmentDto.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
4.height,
FilesList(
showAsListView: true,
types: model!.deliveryNoteAttachmentDto
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: model!.deliveryNoteAttachmentDto.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
],
],
).toShadowContainer(context,),

@ -55,7 +55,7 @@ class MedicalGasFormModel {
'siteId': site?.id,
'supplierId': supplier?.id,
'isSubmitted': isSubmitted,
'gasRequestDetailDtos': gasRequestDetail?.map((e) => e.toJson()).toList(),
'gasRequestDetailDtos': gasRequestDetail != null ? gasRequestDetail?.map((e) => e.toJson()).toList() : [],
};
}
}
@ -81,7 +81,7 @@ class MedicalGasFormDetailModel {
return {
'id': id,
'medicalGasAttributeId': medicalGasAttributeId,
'requestedQuantity': requestedQuantity??0,
'requestedQuantity': requestedQuantity ?? 0,
};
}
}

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
@ -72,7 +73,7 @@ class _UpdateDeliveryNotesState extends State<UpdateDeliveryNotes> {
deliveryNoteNumber: dataModel.deliveryNote);
if (dataModel.deliveryNoteAttachmentDto.isNotEmpty) {
_attachments.addAll(dataModel.deliveryNoteAttachmentDto.map((e) => GenericAttachmentModel(id: e.id, name: e.name)).toList());
_attachments.addAll(dataModel.deliveryNoteAttachmentDto.map((e) => GenericAttachmentModel(id: e.id, documentType: e.documentType, name: e.name)).toList());
}
//Need to Confirm this condition
// selectedItemList = dataModel.requestDetailDtos.where((item) => item.deliveredQuantity != null && item.deliveredQuantity! > 0).toList();
@ -230,8 +231,9 @@ class _UpdateDeliveryNotesState extends State<UpdateDeliveryNotes> {
AttachmentPicker(
label: 'Upload Attachment',
attachment: _attachments,
showAsListView: true,
buttonColor: AppColor.primary10,
// showAsListView: true,
moduleId: RequestAttachmentTypeEnum.updateDeliveryNotes.id,
onlyImages: false,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),
),
@ -350,7 +352,7 @@ class _UpdateDeliveryNotesState extends State<UpdateDeliveryNotes> {
try {
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
formModel.attachments.add(GenericAttachmentModel(id: item.id, name: fileName));
formModel.attachments.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
} catch (error) {
print(error);

@ -8,10 +8,10 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_data_model.dart';
import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart';
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/update_system_internal_audit_page.dart';
@ -203,6 +203,7 @@ class _UpdateMedicalGasInspectionPageState extends State<UpdateMedicalGasInspect
buttonColor: AppColor.primary10,
showAsListView: true,
onlyImages: false,
moduleId: RequestAttachmentTypeEnum.medicalGasInspection.id,
buttonIcon: 'attachment_icon'.toSvgAsset(color: AppColor.primary10),
),
16.height,

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
@ -8,6 +10,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/service_request/spare_parts.dart';
@ -185,7 +188,13 @@ class _PmActivitiesListViewState extends State<PmActivitiesListView> {
],
if (activity.activitySparePartPPMAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
FilesList(images: activity.activitySparePartPPMAttachments.map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList()),
FilesList(
types: activity.activitySparePartPPMAttachments!
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: activity.activitySparePartPPMAttachments.map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList(), showAsListView: true),
],
],
).toShadowContainer(context, showShadow: false).onPress(() {

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
@ -51,7 +52,11 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
ppmProvider.planPreventiveVisit?.preventiveVisitAttachments = [];
for (var item in ppmProvider.ppmPlanAttachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
ppmProvider.planPreventiveVisit?.preventiveVisitAttachments?.add(PreventiveVisitAttachments(id: item.id, attachmentName: fileName));
ppmProvider.planPreventiveVisit?.preventiveVisitAttachments?.add(GenericAttachmentModel(
id: item.id,
name: fileName,
documentType: item.documentType,
));
}
ppmProvider.planPreventiveVisit?.preventiveVisitTimers = ppmProvider.planPreventiveVisit?.preventiveVisitTimers ?? [];

@ -1,3 +1,4 @@
import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
@ -12,6 +13,7 @@ import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/device/model_definition.dart';
import 'package:test_sa/models/device/supplier.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
import 'package:test_sa/models/lookup.dart';
@ -34,6 +36,7 @@ import 'package:test_sa/providers/ppm_task_status_provider.dart';
import 'package:test_sa/views/widgets/bottom_sheets/asset_detail_bottom_sheet.dart';
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
import 'package:test_sa/views/widgets/date_and_time/time_picker.dart';
import 'package:test_sa/views/widgets/equipment/asset_detail_page.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
@ -63,7 +66,10 @@ class _WoInfoFormState extends State<WoInfoForm> {
calculateWorkingTime();
if (widget.planPreventiveVisit.preventiveVisitAttachments != null && widget.planPreventiveVisit.preventiveVisitAttachments!.isNotEmpty) {
ppmProvider.ppmPlanAttachments = [];
ppmProvider.ppmPlanAttachments.addAll(widget.planPreventiveVisit.preventiveVisitAttachments!.map((e) => GenericAttachmentModel(id: e.id, name: e.attachmentName!)).toList());
ppmProvider.ppmPlanAttachments.addAll(widget.planPreventiveVisit.preventiveVisitAttachments!
.whereType<GenericAttachmentModel>()
.map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '', documentType: e.documentType))
.toList());
}
});
@ -96,10 +102,15 @@ class _WoInfoFormState extends State<WoInfoForm> {
@override
Widget build(BuildContext context) {
// double totalWorkingHours =
// widget.planPreventiveVisit.preventiveVisitTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
return Consumer<PpmProvider>(builder: (context, ppmProvider, child) {
ppmProvider.ppmPlanAttachments.forEach((e){
log('attachemnt type ${e.documentType}');
});
return ListView(
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
children: [
@ -158,23 +169,9 @@ class _WoInfoFormState extends State<WoInfoForm> {
children: [
InfoHeader16Widget(widget.planPreventiveVisit.assetName ?? '').expanded,
// widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.headingTextColor(context)).expanded,
"info_icon".toSvgAsset(height: 17, width: 17).onPress(
() {
// There is only limited information for asset is returned from backend to show all info need to return the whole model from backend...
showModalBottomSheet(
context: context,
backgroundColor: AppColor.bottomSheetColor(context),
isScrollControlled: true,
// shape: const RoundedRectangleBorder(
// borderRadius: BorderRadius.vertical(
// top: Radius.circular(20),
// ),
// ),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (BuildContext context) => _buildAssetDetailBottomSheet(context),
);
},
)
const Icon(Icons.open_in_new_rounded, color: AppColor.primary10, size: 20).onPress(() {
Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: widget.planPreventiveVisit.asset!.id);
}),
],
),
// 2.height,
@ -345,7 +342,9 @@ class _WoInfoFormState extends State<WoInfoForm> {
),
AttachmentPicker(
label: context.translation.attachments,
showAsListView: true,
attachment: ppmProvider.ppmPlanAttachments,
moduleId: RequestAttachmentTypeEnum.preventiveMaintenance.id,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),

@ -107,6 +107,24 @@ class SiteRequestProvider extends ChangeNotifier {
);
}
/// Fetches user's current sites for Change/Remove Site operations
Future<List<SiteRequestSiteModel>> getSitesByUserId(String userId) async {
List<SiteRequestSiteModel> usersSite = [];
try {
Response response = await ApiManager.instance.post(URLs.getUserSites(userId), body: {},showToast: false);
if (response.statusCode >= 200 && response.statusCode < 300) {
List categoriesListJson = json.decode(response.body)["data"];
usersSite = categoriesListJson
.map((item) => SiteRequestSiteModel(
id: item['siteId']?.toString() ?? '',
name: item['siteName'] ?? '',
))
.toList();
}
} catch (ex) {}
return usersSite;
}
/// Fetches user's current sites for Change/Remove Site operations
Future<int> fetchUserCurrentSites(String userId) async {
if (_loading) return -2;
@ -125,6 +143,7 @@ class SiteRequestProvider extends ChangeNotifier {
errorMessage: 'Failed to fetch user sites',
);
}
Future<int> fetchUserFilteredSites(String userId) async {
if (_loading) return -2;
return _performApiCall(
@ -141,7 +160,6 @@ class SiteRequestProvider extends ChangeNotifier {
},
errorMessage: 'Failed to fetch user sites',
);
}
/// Submits a site request to the server

@ -13,6 +13,7 @@ import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/device/asset_transfer_attachment.dart';
import 'package:test_sa/models/device/device_transfer.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/new_models/department.dart';
@ -74,10 +75,10 @@ class _CreateDeviceTransferRequestState extends State<CreateDeviceTransferReques
return;
}
_formKey.currentState!.save();
List<AssetTransferAttachment> attachement = [];
List<GenericAttachmentModel> attachement = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
attachement.add(AssetTransferAttachment(id: item.id, attachmentName: fileName));
attachement.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
_transferModel.attachments = attachement;
@ -155,8 +156,9 @@ class _CreateDeviceTransferRequestState extends State<CreateDeviceTransferReques
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SingleItemDropDownMenu<Site, SiteProvider>(
SingleItemDropDownMenu<Site, SameOrgSiteProvider>(
context: context,
requestById: context.userProvider.user?.clientId,
title: context.translation.site,
initialValue: _assetDestination.site,
disableValue: isInternal ? null : _pickedAsset?.site,
@ -245,7 +247,9 @@ class _CreateDeviceTransferRequestState extends State<CreateDeviceTransferReques
23.height,
AttachmentPicker(
label: context.translation.attachImage,
showAsListView: true,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.transferAsset.id,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),

@ -5,17 +5,17 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/site_request_module/models/dropdown_models.dart';
import 'package:test_sa/modules/site_request_module/providers/site_request_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/multiple_item_drop_down_menu.dart';
import 'package:test_sa/providers/department_provider.dart';
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
import 'package:test_sa/views/widgets/equipment/asset_status_buttons.dart';
import '../../../models/device/asset_search.dart';
import '../../../new_views/common_widgets/app_lazy_loading.dart';
import '../../../new_views/common_widgets/default_app_bar.dart';
@ -33,11 +33,13 @@ class DeviceFilterScreen extends StatefulWidget {
class _DeviceFilterScreenState extends State<DeviceFilterScreen> {
late DeviceSearch filter;
Lookup? _commissioningStatus;
List<Site> _selectedSites = [];
List<SiteRequestSiteModel> _selectedSites = [];
List<Lookup> _selectedDepartments = [];
String? startDate, endDate;
bool loading = false;
List<SiteRequestSiteModel> userSites = [];
@override
void initState() {
filter = widget.data ?? DeviceSearch();
@ -47,11 +49,15 @@ class _DeviceFilterScreenState extends State<DeviceFilterScreen> {
startDate = filter.supplyDateFrom;
endDate = filter.supplyDateTo;
_commissioningStatus = filter.assetStatus;
final departmentProvider = Provider.of<DepartmentProvider>(context, listen: false);
final siteProvider = Provider.of<SiteProvider>(context, listen: false);
Utils.showLoading(context);
if (departmentProvider.items.isEmpty ?? true) await departmentProvider.getData();
if (siteProvider.items.isEmpty ?? true) await siteProvider.getData();
if (userSites.isEmpty) {
userSites = await Provider.of<SiteRequestProvider>(context, listen: false).getSitesByUserId(context.userProvider.user?.userID ?? "");
}
await Future.delayed(const Duration(milliseconds: 100));
Utils.hideLoading(context);
// Initialize selected departments from filter
if (filter.departments != null && filter.departments!.isNotEmpty) {
_selectedDepartments = [];
@ -70,11 +76,11 @@ class _DeviceFilterScreenState extends State<DeviceFilterScreen> {
if (filter.sites != null && filter.sites!.isNotEmpty) {
_selectedSites = [];
for (var siteName in filter.sites!) {
final match = siteProvider.items.firstWhere(
final match = userSites.firstWhere(
(site) => site.name == siteName,
orElse: () => Site(),
orElse: () => SiteRequestSiteModel(id: '', name: ''),
);
if (match.id != null) {
if (match.identifier != null) {
_selectedSites.add(match);
}
}
@ -117,14 +123,15 @@ class _DeviceFilterScreenState extends State<DeviceFilterScreen> {
ListView(
padding: const EdgeInsets.all(16),
children: [
AssetStatusButtons(
initialValue: _commissioningStatus,
onSelect: (value) {
if (value != null) {
_commissioningStatus = value;
}
},
),
// AssetStatusButtons(
// initialValue: _commissioningStatus,
// onSelect: (value) {
// if (value != null) {
// _commissioningStatus = value;
// }
// },
// ),
context.translation.filter.heading5(context).custom(color: AppColor.textStyleColor(context)),
16.height,
MultipleItemDropDownMenu<Lookup, DepartmentProvider>(
context: context,
@ -145,11 +152,12 @@ class _DeviceFilterScreenState extends State<DeviceFilterScreen> {
},
),
12.height,
MultipleItemDropDownMenu<Site, SiteProvider>(
MultipleItemDropDownMenu<SiteRequestSiteModel, NullableLoadingProvider>(
context: context,
title: context.translation.bySite,
initialValue: _selectedSites,
showAsBottomSheet: true,
staticData: userSites,
// backgroundColor: AppColor.fieldBgColor(context),
backgroundColor: context.isDark ? AppColor.neutral60 : Colors.white,
showShadow: true,

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/device_transfer.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cx_module/chat/chat_widget.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/widgets/bottom_sheets/rejection_reason_bottom_sheet.dart';
@ -64,8 +65,8 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
if (snapshot.connectionState == ConnectionState.waiting) {
return const ALoading();
} else {
_model = snapshot.data as DeviceTransfer?;
_attachments = _model?.assetTransferAttachments?.map((e) => File(e.attachmentName ?? '')).toList() ?? [];
_model = snapshot.data;
_attachments = _model?.assetTransferAttachments?.map((e) => File(e.name ?? '')).toList() ?? [];
return _model != null
? Form(
key: _formKey,
@ -75,6 +76,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
stateCode: 200,
onRefresh: () async {},
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: [
Column(
@ -121,12 +123,22 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
if (_attachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: _model?.assetTransferAttachments?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
4.height,
FilesList(
showAsListView: true,
types: _model?.assetTransferAttachments != null
? _model!.assetTransferAttachments!
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList()
: [],
images: _model?.assetTransferAttachments?.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
]
],
),
],
).toShadowContainer(context, padding: 16),
).toShadowContainer(context),
8.height,
if (_model?.transferType?.value == 1) ...[
_internalRequestDetailsCard()
@ -171,7 +183,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
),
],
],
).paddingAll(16),
),
),
),
)

@ -13,6 +13,7 @@ import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset_transfer_attachment.dart';
import 'package:test_sa/models/device/device_transfer.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/new_models/assigned_employee.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
@ -116,11 +117,14 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
_formModel.assetTransferEngineerTimers = _formModel.receiverVisitTimers;
}
try {
_formModel.assetTransferAttachments ??= [];
List<GenericAttachmentModel> newAttachments = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_formModel.assetTransferAttachments!.add(AssetTransferAttachment(id: item.id, attachmentName: fileName));
_formModel.attachments = _formModel.assetTransferAttachments;
newAttachments.add(GenericAttachmentModel(id: item.id, documentType: item.documentType, name: fileName));
}
_formModel.assetTransferAttachments = [...?_formModel.assetTransferAttachments, ...newAttachments];
_formModel.attachments = _formModel.assetTransferAttachments;
} catch (error) {
print(error);
}
@ -204,7 +208,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
@override
void initState() {
_formModel.fromDetails(widget.model);
attachments = widget.model.assetTransferAttachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt()??0, name: e.attachmentName!)).toList() ?? [];
attachments = widget.model.assetTransferAttachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt()??0, name: e.name!)).toList() ?? [];
calculateWorkingTime();
super.initState();
}
@ -293,6 +297,8 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
8.height,
AttachmentPicker(
label: context.translation.attachFiles,
showAsListView: true,
moduleId: RequestAttachmentTypeEnum.transferAsset.id,
attachment: attachments,
buttonColor: AppColor.black10,
onlyImages: false,

@ -3,14 +3,19 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_comments.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart';
import 'package:test_sa/controllers/providers/api/user_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';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/new_models/gas_refill_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/modules/cx_module/chat/chat_widget.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -92,7 +97,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
return const ALoading();
} else if (snap.hasData) {
_model = snap.data as GasRefillModel;
_attachments = _model.gasRefillAttachments?.map((e) => File(e.attachmentName ?? '')).toList() ?? [];
_attachments = _model.gasRefillAttachments?.whereType<GenericAttachmentModel>().map((e) => File(e.name ?? '')).toList() ?? [];
isDataUpdated = false;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -233,7 +238,11 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
if (_attachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: _model.gasRefillAttachments?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
4.height,
FilesList(
showAsListView: true,
types: _model.gasRefillAttachments?.whereType<GenericAttachmentModel>().where((e) => e.documentType != null && e.documentType!.name != null).map((toElement) => toElement.documentType!.name!).toList() ?? [],
images: _model.gasRefillAttachments?.whereType<GenericAttachmentModel>().where((e) => e.name != null).map((e) => URLs.getFileUrl(e.name!) ?? '').toList() ?? []),
],
],
).expanded,

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
@ -216,7 +217,9 @@ class _GasRefillRequestFormState extends State<GasRefillRequestForm> {
8.height,
AttachmentPicker(
label: context.translation.attachFiles,
showAsListView: true,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.gasRefill.id,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -238,7 +241,7 @@ class _GasRefillRequestFormState extends State<GasRefillRequestForm> {
_gasModel.gasRefillAttachments = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_gasModel.gasRefillAttachments?.add(GasRefillAttachments(id: item.id, gasRefillId: _gasModel.id ?? 0, attachmentName: fileName));
_gasModel.gasRefillAttachments?.add(GenericAttachmentModel(id: item.id, moduleReferenceId: _gasModel.id ?? 0, name: fileName, documentType: item.documentType));
}
await _gasRefillProvider?.addGasRefillRequest(
context: context,

@ -11,6 +11,7 @@ import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/timer_model.dart';
@ -86,7 +87,7 @@ class _UpdateGasRefillRequestState extends State<UpdateGasRefillRequest> {
} catch (ex) {}
}
if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) {
_attachments.addAll(_formModel.gasRefillAttachments!.map((e) => GenericAttachmentModel(id: e.id, name: e.attachmentName!)).toList());
_attachments.addAll(_formModel.gasRefillAttachments!.whereType<GenericAttachmentModel>().where((e) => e.id != null && e.name != null).map((e) => GenericAttachmentModel(id: e.id, name: e.name, documentType: e.documentType)).toList());
}
}
@ -182,7 +183,7 @@ class _UpdateGasRefillRequestState extends State<UpdateGasRefillRequest> {
_formModel.gasRefillAttachments = [];
for (var item in _attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_formModel.gasRefillAttachments?.add(GasRefillAttachments(id: item.id, gasRefillId: _formModel.id ?? 0, attachmentName: fileName));
_formModel.gasRefillAttachments?.add(GenericAttachmentModel(id: item.id, moduleReferenceId: _formModel.id ?? 0, name: fileName, documentType: item.documentType));
}
await _gasRefillProvider?.updateGasRefill(status: status, model: _formModel).then((success) {
@ -292,6 +293,8 @@ class _UpdateGasRefillRequestState extends State<UpdateGasRefillRequest> {
AttachmentPicker(
label: context.translation.attachFiles,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.gasRefill.id,
showAsListView: true,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),

@ -5,10 +5,12 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/enum_extensions.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
@ -44,7 +46,7 @@ class CreateTaskView extends StatefulWidget {
}
class _CreateTaskViewState extends State<CreateTaskView> with TickerProviderStateMixin {
final List<GenericAttachmentModel> attachments = [];
List<GenericAttachmentModel> attachments = [];
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
List<Asset> _deviceList = [];
@ -58,7 +60,9 @@ class _CreateTaskViewState extends State<CreateTaskView> with TickerProviderStat
void initState() {
// TODO: implement initState
super.initState();
Provider.of<TaskTypeProvider>(context, listen: false).reset();
// WidgetsBinding.instance.addPostFrameCallback((_) {
Provider.of<TaskTypeProvider>(context, listen: false).reset();
// });
}
@override
@ -116,14 +120,11 @@ class _CreateTaskViewState extends State<CreateTaskView> with TickerProviderStat
AttachmentPicker(
label: context.translation.attachImage,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.taskRequest.id,
buttonColor: AppColor.black10,
showAsListView: true,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
//verify this if not required delete this ..
onChange: (attachments) {
attachments = attachments;
setState(() {});
},
),
],
).toShadowContainer(context).paddingAll(16),
@ -457,7 +458,7 @@ class _CreateTaskViewState extends State<CreateTaskView> with TickerProviderStat
}
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_addTaskModel?.attachments?.add(TaskJobAttachment(id: item.id, name: fileName));
_addTaskModel?.attachments?.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
TaskRequestProvider taskRequestProvider = Provider.of<TaskRequestProvider>(context, listen: false);
await taskRequestProvider.addTask(context: context, task: _addTaskModel!);

@ -9,6 +9,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/new_models/task_request/task_request_model.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
@ -159,7 +160,11 @@ class _TaskRequestDetailsViewState extends State<TaskRequestDetailsView> {
if (taskProvider.taskRequestModel?.taskJobAttachments?.isNotEmpty ?? false) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
FilesList(images: taskProvider.taskRequestModel!.taskJobAttachments!.map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList()),
4.height,
FilesList(
showAsListView: true,
types: taskProvider.taskRequestModel!.taskJobAttachments!.whereType<GenericAttachmentModel>().where((e) => e.name != null).map((toElement) => toElement.documentType?.name ?? '').toList(),
images: taskProvider.taskRequestModel!.taskJobAttachments!.whereType<GenericAttachmentModel>().where((e) => e.name != null).map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList()),
],
buildTechnicalComments(taskModel: taskModel),
],

@ -15,6 +15,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
@ -63,7 +64,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
List<GenericAttachmentModel> attachments = [];
List<TaskJobAttachment> otherAttachments = [];
List<GenericAttachmentModel> otherAttachments = [];
bool installationType = true;
String comments = '';
List<TimerHistoryModel> timerList = [];
@ -87,8 +88,8 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
_taskProvider?.refresh();
calculateWorkingTime(helperModel: taskModel!);
if (taskModel.taskJobAttachments != null) {
attachments = taskModel.taskJobAttachments!.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '')).toList();
otherAttachments = taskModel.taskJobAttachments?.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? [];
attachments = taskModel.taskJobAttachments!.whereType<GenericAttachmentModel>().where((e) => e.createdBy == _userProvider.user?.userID && e.id != null).map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '',documentType: e.documentType)).toList();
otherAttachments = taskModel.taskJobAttachments!.whereType<GenericAttachmentModel>().where((e) => e.createdBy != _userProvider.user?.userID).toList();
}
}
@ -191,7 +192,9 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
20.height,
AttachmentPicker(
label: context.translation.attachFiles,
showAsListView: true,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.taskRequest.id,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -254,13 +257,13 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
if (validate(model: taskModel)) {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
List<TaskJobAttachment> taskAttachment = [];
List<GenericAttachmentModel> taskAttachment = [];
if (otherAttachments.isNotEmpty) {
taskAttachment.addAll(otherAttachments);
}
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
taskAttachment.add(TaskJobAttachment(id: item.id, name: fileName));
taskAttachment.add(GenericAttachmentModel(id: item.id, name: fileName,documentType: item.documentType));
}
taskModel.taskJobAttachments = taskAttachment;
taskModel.taskJobActivityEngineerTimers = [];

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/traf_customer.dart';
@ -516,7 +517,9 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
12.height,
AttachmentPicker(
label: context.translation.attachFiles,
showAsListView: true,
attachment: attachments,
moduleId: RequestAttachmentTypeEnum.traf.id,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
@ -622,7 +625,7 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
trafRequest?.attachments!.add(
Attachments(id: 0, trafId: 0, attachmentName: fileName),
GenericAttachmentModel(id: 0, moduleReferenceId: 0, name: fileName, documentType: item.documentType),
);
}

@ -10,6 +10,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/traf_module/traf_request_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
@ -63,7 +64,7 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
if (isLoading) return const ALoading();
TrafRequestProvider trafProvider = Provider.of<TrafRequestProvider>(context, listen: false);
if (trafProvider.trafRequestDataModel?.attachments != null) {
_attachments = trafProvider.trafRequestDataModel!.attachments!.map((e) => File(URLs.getFileUrl(e.attachmentName ?? '') ?? '')).toList();
_attachments = trafProvider.trafRequestDataModel!.attachments!.whereType<GenericAttachmentModel>().map((e) => File(URLs.getFileUrl(e.name ?? '') ?? '')).toList();
}
return trafProvider.trafRequestDataModel == null
? const NoDataFound().center
@ -150,13 +151,17 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
],
if (_attachments.isNotEmpty) ...[
4.height,
Text(
// todo @waseem conver to header
"Attachments".addTranslation,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
// 8.height,
FilesList(images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList() ?? []),
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: data.attachments
?.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList() ??
[],
images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList()),
],
],
).toShadowContainer(context);

@ -1,3 +1,6 @@
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
class TrafRequestModel {
List<TrafRequestDataModel>? trafRequestDataModel;
int? totalRows;
@ -92,7 +95,7 @@ class TrafRequestDataModel {
String? isCombinationName;
String? usedWithCombination;
String? comment;
List<Attachments>? attachments;
List<GenericAttachmentModel>? attachments;
bool? isFromMobile;
int? isBudgetId;
String? isBudgetName;
@ -309,9 +312,9 @@ class TrafRequestDataModel {
comment = json['comment'];
isFromMobile = json['isFromMobile'];
if (json['attachments'] != null) {
attachments = <Attachments>[];
attachments = <GenericAttachmentModel>[];
json['attachments'].forEach((v) {
attachments!.add(new Attachments.fromJson(v));
attachments!.add(GenericAttachmentModel.fromTrafJson(v));
});
}
isBudgetId = json['isBudgetId'];
@ -426,8 +429,8 @@ class TrafRequestDataModel {
data['usedWithCombination'] = this.usedWithCombination;
data['comment'] = this.comment;
data['isFromMobile'] = this.isFromMobile;
if (this.attachments != null) {
data['attachments'] = this.attachments!.map((v) => v.toJson()).toList();
if (attachments != null) {
data['attachments'] = attachments!.map((v) => v.toTrafJson()).toList();
} else {
data['attachments'] = [];
}
@ -536,7 +539,7 @@ class TrafRequestDataModel {
data['isBudgetId'] = isBudgetId;
data['attachments'] =
attachments?.map((v) => v.toJson()).toList() ?? [];
attachments?.map((v) => v.toTrafJson() ?? {}).toList() ?? [];
return data;
}
@ -632,25 +635,28 @@ class Departments {
return data;
}
}
class Attachments {
int? id;
int? trafId;
String? attachmentName;
Attachments({this.id, this.trafId, this.attachmentName});
Attachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
trafId = json['trafId'];
attachmentName = json['attachmentName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['trafId'] = this.trafId;
data['attachmentName'] = this.attachmentName;
return data;
}
}
//TODO need to remove this
// class Attachments {
// int? id;
// int? trafId;
// String? attachmentName;
// Lookup ? documentType;
//
// Attachments({this.id, this.trafId, this.attachmentName,this.documentType});
//
// Attachments.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// trafId = json['trafId'];
// attachmentName = json['attachmentName'];
// documentType = json['documentType'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['trafId'] = this.trafId;
// data['attachmentName'] = this.attachmentName;
// data['documentTypeId'] = this.documentType?.id;
// return data;
// }
// }

@ -7,6 +7,7 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
@ -58,7 +59,7 @@ class _UpdateTrafRequestPageState extends State<UpdateTrafRequestPage> {
Provider.of<RecommendationLookupProvider>(context, listen: false).reset();
trafRequestProvider = Provider.of<TrafRequestProvider>(context, listen: false);
trafRequest = trafRequestProvider.trafRequestDataModel!;
attachments = trafRequest.attachments?.map((item) => GenericAttachmentModel(id: item.id, name: item.attachmentName)).toList() ?? [];
attachments = trafRequest.attachments?.whereType<GenericAttachmentModel>().map((item) => GenericAttachmentModel(id: item.id, name: item.name ?? '')).toList() ?? [];
}
@override
@ -212,6 +213,8 @@ class _UpdateTrafRequestPageState extends State<UpdateTrafRequestPage> {
12.height,
AttachmentPicker(
label: context.translation.attachFiles,
showAsListView: true,
moduleId: RequestAttachmentTypeEnum.traf.id,
attachment: attachments,
buttonColor: AppColor.black10,
onlyImages: false,
@ -233,7 +236,7 @@ class _UpdateTrafRequestPageState extends State<UpdateTrafRequestPage> {
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
trafRequest.attachments!.add(
Attachments(id: item.id, trafId: item.id, attachmentName: fileName),
GenericAttachmentModel(id: item.id, moduleReferenceId: item.id, name: fileName, documentType: item.documentType),
);
}
}

@ -106,6 +106,7 @@ class _CreateRequestTypeBottomSheetState extends State<CreateRequestTypeBottomSh
icon: requestList[index].icon,
label: requestList[index].title,
onTap: () {
log('route name is ${requestList[index].routeName}');
Navigator.pushReplacementNamed(context, requestList[index].routeName);
},
),

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save