Merge branch 'refs/heads/main_production' into main_production_copilot
# Conflicts: # lib/controllers/api_routes/urls.dart # lib/controllers/providers/api/devices_provider.dart # lib/modules/medical_gas_inspection/models/medical_gas_form_model.dart # lib/views/widgets/images/multi_image_picker.dartmain_production_copilot
commit
a79d38610f
@ -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;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -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,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,273 +1,216 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
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/helper_data_models/workorder/work_order_helper_models.dart';
|
||||
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/cm_detail_provider.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.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/app_lazy_loading.dart';
|
||||
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/providers/service_request_providers/equipment_status_provider.dart';
|
||||
|
||||
class CostDetailFormScreen extends StatefulWidget {
|
||||
static const String id = "/cost-detail-form-screen";
|
||||
bool isEdit = false;
|
||||
final WorkOrderCostModel? model;
|
||||
final dynamic provider; // CMDetailProvider or PpmProvider
|
||||
|
||||
CostDetailFormScreen({Key? key, required this.isEdit}) : super(key: key);
|
||||
const CostDetailFormScreen({
|
||||
Key? key,
|
||||
required this.model,
|
||||
required this.provider,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CostDetailFormScreenState createState() => _CostDetailFormScreenState();
|
||||
}
|
||||
|
||||
class _CostDetailFormScreenState extends State<CostDetailFormScreen> with TickerProviderStateMixin {
|
||||
CMDetailProvider? _requestDetailProvider;
|
||||
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
class _CostDetailFormScreenState extends State<CostDetailFormScreen> {
|
||||
late WorkOrderCostModel _localModel;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void assignValues() {
|
||||
// ServiceRequestDetailProvider requestDetailProvider = Provider.of<ServiceRequestDetailProvider>(context, listen: false);
|
||||
// _requestDetailProvider = Provider.of<ServiceRequestDetailProvider>(context, listen: false);
|
||||
WorkOrderData currentWorkOrderData = _requestDetailProvider!.currentWorkOrder!.data!;
|
||||
_requestDetailProvider!.workOrderCostModel = WorkOrderCostModel(
|
||||
workOrderId: currentWorkOrderData.requestId,
|
||||
labourCost: currentWorkOrderData.labourCost,
|
||||
sparePartCost: currentWorkOrderData.sparePartCost,
|
||||
travelCost: currentWorkOrderData.travelCost,
|
||||
qAmount: currentWorkOrderData.qAmount,
|
||||
prNo: currentWorkOrderData.prNo,
|
||||
poNo: currentWorkOrderData.poNo,
|
||||
mrNo: currentWorkOrderData.mrNo,
|
||||
exchangeCost: currentWorkOrderData.exchangeCost,
|
||||
_localModel = WorkOrderCostModel(
|
||||
workOrderId: widget.model?.workOrderId,
|
||||
labourCost: widget.model?.labourCost,
|
||||
sparePartCost: widget.model?.sparePartCost,
|
||||
travelCost: widget.model?.travelCost,
|
||||
qAmount: widget.model?.qAmount,
|
||||
prNo: widget.model?.prNo,
|
||||
poNo: widget.model?.poNo,
|
||||
mrNo: widget.model?.mrNo,
|
||||
exchangeCost: widget.model?.exchangeCost,
|
||||
);
|
||||
log('Initialized Cost Model: ${_localModel.toJson()}');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_requestDetailProvider == null) {
|
||||
_requestDetailProvider = Provider.of<CMDetailProvider>(context, listen: false);
|
||||
assignValues();
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: const DefaultAppBar(title: "Cost Details"),
|
||||
body: Consumer<CMDetailProvider>(builder: (context, CMDetailProvider requestDetailProvider, child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppTextFormField(
|
||||
labelText: "Spare Part Cost",
|
||||
backgroundColor: AppColor.neutral100,
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.sparePartCost?.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
enable: false,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
textInputType: TextInputType.number,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.sparePartCost = num.parse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.labourCost?.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
labelText: "Labor Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.labourCost = num.parse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Travel Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.travelCost?.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.travelCost = num.parse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Quot Amount",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.qAmount?.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.qAmount = num.parse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "PR No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.prNo,
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.prNo = value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "PO No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.poNo,
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.poNo = value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "MR No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.mrNo,
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.mrNo = value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Exchange Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: requestDetailProvider.workOrderCostModel?.exchangeCost != null ? requestDetailProvider.workOrderCostModel?.exchangeCost.toString() : '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
requestDetailProvider.workOrderCostModel?.exchangeCost = num.parse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context).paddingAll(16),
|
||||
).expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
label: "Update Cost Details",
|
||||
buttonColor: AppColor.primary10,
|
||||
onPressed: () async {
|
||||
if (validateForm(requestDetailProvider: requestDetailProvider)) {
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
await requestDetailProvider.engineerUpdateCost().then((success) {
|
||||
Navigator.pop(context);
|
||||
if (success) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
body: ListenableBuilder(
|
||||
listenable: widget.provider,
|
||||
builder: (context, child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppTextFormField(
|
||||
labelText: "Spare Part Cost",
|
||||
backgroundColor: AppColor.neutral100,
|
||||
initialValue: _localModel.sparePartCost?.toString() ?? '0',
|
||||
textAlign: TextAlign.center,
|
||||
enable: false,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
textInputType: TextInputType.number,
|
||||
showShadow: false,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
initialValue: _localModel.labourCost?.toString() ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
labelText: "Labor Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.labourCost = num.tryParse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Travel Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.travelCost?.toString() ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.travelCost = num.tryParse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Quot Amount",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.qAmount?.toString() ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.qAmount = num.tryParse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "PR No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.prNo ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: TextInputType.text,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.prNo = value.isEmpty ? null : value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "PO No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.poNo ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: TextInputType.text,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.poNo = value.isEmpty ? null : value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "MR No",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.mrNo ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: TextInputType.text,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.mrNo = value.isEmpty ? null : value;
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: "Exchange Cost",
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
initialValue: _localModel.exchangeCost?.toString() ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true),
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
_localModel.exchangeCost = num.tryParse(value);
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context).paddingAll(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
label: "Update Cost Details",
|
||||
buttonColor: AppColor.primary10,
|
||||
onPressed: () => _onSubmit(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool validateForm({required CMDetailProvider requestDetailProvider}) {
|
||||
bool isValid = true;
|
||||
if (!widget.isEdit) {
|
||||
return true;
|
||||
}
|
||||
// if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus != null) {
|
||||
// if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.value == 1 || requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.value == 2) {
|
||||
// if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.returnToService == null) {
|
||||
// Fluttertoast.showToast(msg: "Return to service is required ", toastLength: Toast.LENGTH_LONG);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return isValid;
|
||||
}
|
||||
Future<void> _onSubmit() async {
|
||||
widget.provider.workOrderCostModel = _localModel;
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const AppLazyLoading(),
|
||||
);
|
||||
|
||||
Widget assetStatusWidget({required BuildContext context, required EngineerUpdateWorkOrderHelperModel workOrderData}) {
|
||||
return Consumer<EquipmentStatusProvider>(builder: (cxt, snapshot, _) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
context.translation.assetStatus.bodyText(context).custom(color: AppColor.black20),
|
||||
8.height,
|
||||
Wrap(
|
||||
runSpacing: 8,
|
||||
spacing: 8,
|
||||
children: [
|
||||
for (var element in snapshot.items)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: Radio(
|
||||
value: element,
|
||||
activeColor: Colors.red,
|
||||
fillColor: WidgetStateColor.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) return AppColor.primary10;
|
||||
return AppColor.neutral130;
|
||||
}),
|
||||
groupValue: workOrderData.equipmentStatus,
|
||||
onChanged: (state) {
|
||||
setState(() {
|
||||
workOrderData.equipmentStatus = element;
|
||||
});
|
||||
}),
|
||||
),
|
||||
8.width,
|
||||
Text(element.name ?? '', style: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral120)),
|
||||
],
|
||||
)
|
||||
],
|
||||
).toShimmer(isShow: snapshot.loading, context: context),
|
||||
],
|
||||
);
|
||||
});
|
||||
try {
|
||||
final success = await widget.provider.engineerUpdateCost();
|
||||
|
||||
if (mounted) Navigator.pop(context); // Close loading
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) Navigator.pop(context);
|
||||
log('Error updating cost: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,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,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,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;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -0,0 +1,237 @@
|
||||
import 'dart:developer';
|
||||
|
||||
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/ppm_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/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';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/forms/spare_part/spare_part_request.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/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/item_views/info_text_widget.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
class PmActivitiesListView extends StatefulWidget {
|
||||
static const String id = "/activities-list";
|
||||
|
||||
const PmActivitiesListView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PmActivitiesListViewState createState() {
|
||||
return _PmActivitiesListViewState();
|
||||
}
|
||||
}
|
||||
|
||||
class _PmActivitiesListViewState extends State<PmActivitiesListView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
List<PMSparePartActivityModel> activities = [];
|
||||
|
||||
bool disableNewActivity = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserProvider userProvider = Provider.of<UserProvider>(context);
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Spare Part Requests"),
|
||||
body: Consumer<PpmProvider>(builder: (context, PpmProvider pmProvider, child) {
|
||||
activities = pmProvider.planPreventiveVisit?.activities ?? [];
|
||||
if (activities.isNotEmpty && (activities.last.activityStatus!.value == 14 || activities.last.activityStatus!.value == 19)) {
|
||||
disableNewActivity = true;
|
||||
} else {
|
||||
disableNewActivity = false;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
(activities.isEmpty)
|
||||
? NoDataFound(message: context.translation.noDataFound).center.expanded
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: activities.length,
|
||||
separatorBuilder: (czt, index) => 12.height,
|
||||
itemBuilder: (context, index) {
|
||||
return sparePartActivityCard(pmProvider: pmProvider, userProvider: userProvider, context: context, activity: activities[index]);
|
||||
},
|
||||
).expanded,
|
||||
if (userProvider.user!.type == UsersTypes.engineer && (pmProvider.planPreventiveVisit?.visitStatus?.value != 5 && pmProvider.planPreventiveVisit?.visitStatus?.value != 3))
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
label: "Create Spare Part Request",
|
||||
maxWidth: true,
|
||||
buttonColor: AppColor.primary10,
|
||||
loading: pmProvider.isLoading,
|
||||
disableButton: disableNewActivity,
|
||||
onPressed: () async {
|
||||
final model = SparePartHelperModel(
|
||||
id: 0,
|
||||
pmVisitId: pmProvider.planPreventiveVisit?.id,
|
||||
);
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SparePartRequest(
|
||||
model: model,
|
||||
provider: pmProvider,
|
||||
fromCm: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
))
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget sparePartActivityCard({required PpmProvider pmProvider, required UserProvider userProvider, required BuildContext context, required PMSparePartActivityModel activity}) {
|
||||
bool showActionButtons = userProvider.user!.userID == pmProvider.planPreventiveVisit?.assignedEmployee?.userId &&
|
||||
userProvider.user!.type == UsersTypes.engineer &&
|
||||
pmProvider.planPreventiveVisit?.visitStatus?.value != 5 &&
|
||||
pmProvider.planPreventiveVisit?.visitStatus?.value != 3;
|
||||
|
||||
bool canDelete = showActionButtons && activity.activityStatus?.value == 1;
|
||||
bool canEdit = showActionButtons && (canDelete || activity.activityStatus!.value! == 3);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
StatusLabel(
|
||||
label: activity.activityStatus?.name,
|
||||
textColor: AppColor.white10,
|
||||
backgroundColor: AppColor.primary10,
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: 12,
|
||||
children: [
|
||||
if (canEdit)
|
||||
"edit_icon".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).onPress(() {
|
||||
editSparePartRequest(context: context, pmProvider: pmProvider, activity: activity);
|
||||
}),
|
||||
if (canDelete)
|
||||
"delete_icon".toSvgAsset(height: 24, width: 24).onPress(() async {
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
int status = await pmProvider.deleteActivitySparePart(id: activity.id!);
|
||||
if (status == 200) {
|
||||
await pmProvider.getPlanPreventiveVisitById((int.tryParse(pmProvider.planPreventiveVisit?.id ?? '')) as int);
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
6.height,
|
||||
InfoTextWidget(
|
||||
label: context.translation.partName,
|
||||
value: activity.partCatalogItem?.partName,
|
||||
),
|
||||
InfoTextWidget(
|
||||
label: context.translation.partNo,
|
||||
value: activity.partCatalogItem?.partNumber,
|
||||
),
|
||||
InfoTextWidget(
|
||||
label: context.translation.oracleCode,
|
||||
value: activity.partCatalogItem?.oracleCode,
|
||||
),
|
||||
if (activity.quantity != null && activity.quantity! > 0)
|
||||
InfoTextWidget(
|
||||
label: context.translation.quantity,
|
||||
value: activity.quantity.toString(),
|
||||
),
|
||||
if (activity.installQty != null && activity.installQty! > 0)
|
||||
InfoTextWidget(
|
||||
label: context.translation.installedQty,
|
||||
value: activity.installQty.toString(),
|
||||
),
|
||||
if (activity.returnQty != null && activity.returnQty! > 0)
|
||||
InfoTextWidget(
|
||||
label: context.translation.returnQty,
|
||||
value: activity.returnQty.toString(),
|
||||
),
|
||||
if (activity.comment?.isNotEmpty ?? false) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
InfoTextLabelWidget(label: activity.comment ?? ""),
|
||||
],
|
||||
if (activity.activitySparePartPPMAttachments.isNotEmpty) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
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(() {
|
||||
if (showActionButtons) return;
|
||||
if (pmProvider.isReadOnlyRequest) {
|
||||
editSparePartRequest(context: context, pmProvider: pmProvider, activity: activity);
|
||||
} else if (userProvider.user!.userID == pmProvider.planPreventiveVisit?.assignedEmployee?.userId) {
|
||||
pmProvider.isReadOnlyRequest = true;
|
||||
editSparePartRequest(context: context, pmProvider: pmProvider, activity: activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void editSparePartRequest({required BuildContext context, required PpmProvider pmProvider, required PMSparePartActivityModel activity}) async {
|
||||
final model = SparePartHelperModel(
|
||||
id: activity.id,
|
||||
pmVisitId: pmProvider.planPreventiveVisit?.id,
|
||||
comment: activity.comment,
|
||||
sparePartAttachments: activity.activitySparePartPPMAttachments,
|
||||
activityStatus: activity.activityStatus,
|
||||
sparePart: SparePart(
|
||||
id: activity.partCatalogItem?.id,
|
||||
partName: activity.partCatalogItem?.partName,
|
||||
partNo: activity.partCatalogItem?.partNumber,
|
||||
oracleCode: activity.partCatalogItem?.oracleCode,
|
||||
),
|
||||
quantity: activity.quantity,
|
||||
installQty: activity.installQty,
|
||||
returnQty: activity.returnQty,
|
||||
activityStatusId: activity.activityStatus?.id,
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => SparePartRequest(
|
||||
model: model,
|
||||
provider: pmProvider,
|
||||
fromCm: false, // This is PM, not CM
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue