asset delivery modules completed
parent
789522b79b
commit
7dd8fff34e
@ -1,345 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
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';
|
|
||||||
import 'package:test_sa/models/new_models/site.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
||||||
import '../../../models/new_models/department.dart';
|
|
||||||
|
|
||||||
class AssetInventoryResponse {
|
|
||||||
num? totalRows;
|
|
||||||
num? count;
|
|
||||||
String? message;
|
|
||||||
String? title;
|
|
||||||
String? innerMessage;
|
|
||||||
num? responseCode;
|
|
||||||
bool? isSuccess;
|
|
||||||
List<AssetInventoryModel>? assetList;
|
|
||||||
|
|
||||||
AssetInventoryResponse({
|
|
||||||
this.totalRows,
|
|
||||||
this.count,
|
|
||||||
this.message,
|
|
||||||
this.title,
|
|
||||||
this.innerMessage,
|
|
||||||
this.responseCode,
|
|
||||||
this.isSuccess,
|
|
||||||
this.assetList,
|
|
||||||
});
|
|
||||||
|
|
||||||
AssetInventoryResponse.fromJson(Map<String, dynamic> json) {
|
|
||||||
totalRows = json['totalRows'];
|
|
||||||
count = json['count'];
|
|
||||||
message = json['message'];
|
|
||||||
title = json['title'];
|
|
||||||
innerMessage = json['innerMessage'];
|
|
||||||
responseCode = json['responseCode'];
|
|
||||||
isSuccess = json['isSuccess'];
|
|
||||||
if (json['data'] != null) {
|
|
||||||
assetList = (json['data'] as List).map((item) => AssetInventoryModel.fromJson(item)).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'totalRows': totalRows,
|
|
||||||
'count': count,
|
|
||||||
'message': message,
|
|
||||||
'title': title,
|
|
||||||
'innerMessage': innerMessage,
|
|
||||||
'responseCode': responseCode,
|
|
||||||
'isSuccess': isSuccess,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AssetInventoryModel {
|
|
||||||
num? id;
|
|
||||||
num? assetId;
|
|
||||||
String? transactionDate;
|
|
||||||
String? assetNumber;
|
|
||||||
String? serialNo;
|
|
||||||
String? assetName;
|
|
||||||
num? assetNameId;
|
|
||||||
String? model;
|
|
||||||
String? manufacturer;
|
|
||||||
String? supplierName;
|
|
||||||
String? siteName;
|
|
||||||
String? buildingName;
|
|
||||||
String? floorName;
|
|
||||||
String? departmentName;
|
|
||||||
String? roomName;
|
|
||||||
num? statusId;
|
|
||||||
String? status;
|
|
||||||
num? statusValue;
|
|
||||||
num? statusByAdminId;
|
|
||||||
String? statusByAdmin;
|
|
||||||
num? statusByAdminValue;
|
|
||||||
bool? isNotRegistered;
|
|
||||||
num? sessionId;
|
|
||||||
num? assetImportId;
|
|
||||||
num? siteId;
|
|
||||||
num? supplierId;
|
|
||||||
num? buildingId;
|
|
||||||
num? floorId;
|
|
||||||
num? departmentId;
|
|
||||||
num? roomId;
|
|
||||||
String? newAssetNumber;
|
|
||||||
String? newSerialNo;
|
|
||||||
num? newAssetNameId;
|
|
||||||
String? newAssetNameText;
|
|
||||||
num? newModelId;
|
|
||||||
String? newModelName;
|
|
||||||
num? manufacturerId;
|
|
||||||
num? modelId;
|
|
||||||
num? newManufacturerId;
|
|
||||||
String? newManufacturerName;
|
|
||||||
num? newSupplierId;
|
|
||||||
String? newSupplierName;
|
|
||||||
String? photo;
|
|
||||||
String? photoOriginName;
|
|
||||||
String? remarks;
|
|
||||||
Site? site;
|
|
||||||
Building? building;
|
|
||||||
Floor? floor;
|
|
||||||
Department? department;
|
|
||||||
Rooms? room;
|
|
||||||
SupplierDetails? supplier;
|
|
||||||
List<AssetInventoryDetailAssetAttachments> assetInventoryDetailAssetAttachments = [];
|
|
||||||
|
|
||||||
AssetInventoryModel({
|
|
||||||
this.id,
|
|
||||||
this.sessionId,
|
|
||||||
this.assetId,
|
|
||||||
this.transactionDate,
|
|
||||||
this.assetNumber,
|
|
||||||
this.assetNameId,
|
|
||||||
this.serialNo,
|
|
||||||
this.assetName,
|
|
||||||
this.model,
|
|
||||||
this.manufacturer,
|
|
||||||
this.supplierName,
|
|
||||||
this.siteName,
|
|
||||||
this.buildingName,
|
|
||||||
this.floorName,
|
|
||||||
this.departmentName,
|
|
||||||
this.roomName,
|
|
||||||
this.statusId,
|
|
||||||
this.status,
|
|
||||||
this.statusValue,
|
|
||||||
this.statusByAdminId,
|
|
||||||
this.statusByAdmin,
|
|
||||||
this.statusByAdminValue,
|
|
||||||
this.isNotRegistered,
|
|
||||||
this.assetImportId,
|
|
||||||
this.siteId,
|
|
||||||
this.buildingId,
|
|
||||||
this.floorId,
|
|
||||||
this.departmentId,
|
|
||||||
this.supplierId,
|
|
||||||
this.roomId,
|
|
||||||
this.newAssetNumber,
|
|
||||||
this.manufacturerId,
|
|
||||||
this.newSerialNo,
|
|
||||||
this.newAssetNameId,
|
|
||||||
this.newAssetNameText,
|
|
||||||
this.newModelId,
|
|
||||||
this.modelId,
|
|
||||||
this.newModelName,
|
|
||||||
this.newManufacturerId,
|
|
||||||
this.newManufacturerName,
|
|
||||||
this.newSupplierId,
|
|
||||||
this.newSupplierName,
|
|
||||||
this.photo,
|
|
||||||
this.photoOriginName,
|
|
||||||
this.remarks,
|
|
||||||
this.site,
|
|
||||||
this.department,
|
|
||||||
this.building,
|
|
||||||
this.floor,
|
|
||||||
this.room,
|
|
||||||
this.supplier,
|
|
||||||
this.assetInventoryDetailAssetAttachments = const [],
|
|
||||||
});
|
|
||||||
|
|
||||||
AssetInventoryModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
assetId = json['assetId'];
|
|
||||||
transactionDate = json['transactionDate'];
|
|
||||||
assetNumber = json['assetNumber'];
|
|
||||||
assetNameId = json['assetNameId'];
|
|
||||||
serialNo = json['serialNo'];
|
|
||||||
assetName = json['assetName'];
|
|
||||||
model = json['model'] ?? json['modelName'];
|
|
||||||
manufacturer = json['manufacturer'] ?? json['manufacturerName'];
|
|
||||||
supplierName = json['supplierName'];
|
|
||||||
siteName = json['site'] ?? json['siteName'];
|
|
||||||
buildingName = json['building'] ?? json['buildingName'];
|
|
||||||
floorName = json['floor'] ?? json['floorName'];
|
|
||||||
departmentName = json['department'] ?? json['departmentName'];
|
|
||||||
roomName = json['room'] ?? json['roomName'];
|
|
||||||
statusId = json['statusId'];
|
|
||||||
status = json['status'] ?? json['classification'];
|
|
||||||
statusValue = json['statusValue'];
|
|
||||||
isNotRegistered = json['isNotRegistered'];
|
|
||||||
sessionId = json['sessionId'];
|
|
||||||
assetImportId = json['assetImportId']??json['id'];
|
|
||||||
siteId = json['siteId'];
|
|
||||||
buildingId = json['buildingId'];
|
|
||||||
floorId = json['floorId'];
|
|
||||||
supplierId = json['supplierId'];
|
|
||||||
departmentId = json['departmentId'];
|
|
||||||
roomId = json['roomId'];
|
|
||||||
modelId = json['modelId'];
|
|
||||||
photo = json['photo'];
|
|
||||||
photoOriginName = json['photoOriginName'];
|
|
||||||
remarks = json['remarks'];
|
|
||||||
if (json['assetTransferAttachments'] != null) {
|
|
||||||
assetInventoryDetailAssetAttachments = [];
|
|
||||||
json['assetInventoryDetailAssetAttachments'].forEach((v) {
|
|
||||||
assetInventoryDetailAssetAttachments.add(AssetInventoryDetailAssetAttachments.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//new data..
|
|
||||||
// newAssetNumber = json['newAssetNumber'] ?? json['assetNumber'];
|
|
||||||
// manufacturerId = json['manufacturerId'] ?? json['manufacturerId'];
|
|
||||||
// newSerialNo = json['newSerialNo'] ?? json['serialNo'];
|
|
||||||
// newAssetNameId = json['newAssetNameId'] ?? json['assetNameId'];
|
|
||||||
// newAssetNameText = json['newAssetNameText'] ?? json['assetNameText'];
|
|
||||||
// newModelId = json['newModelId'] ?? json['modelId'];
|
|
||||||
// newModelName = json['newModelName'] ?? json['modelName'];
|
|
||||||
// newManufacturerId = json['newManufacturerId'] ?? json['manufacturerId'];
|
|
||||||
// newManufacturerName = json['newManufacturerName'] ?? json['manufacturerName'];
|
|
||||||
// newSupplierId = json['newSupplierId'] ?? json['supplierId'];
|
|
||||||
// newSupplierName = json['newSupplierName'] ?? json['supplierName'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'isNotRegistered': isNotRegistered,
|
|
||||||
'sessionId': sessionId,
|
|
||||||
'assetImportId': assetImportId,
|
|
||||||
'transactionDate': transactionDate,
|
|
||||||
'assetId': assetId,
|
|
||||||
'siteId': siteId,
|
|
||||||
'buildingId': buildingId,
|
|
||||||
'floorId': floorId,
|
|
||||||
'departmentId': departmentId,
|
|
||||||
'roomId': roomId,
|
|
||||||
'newSerialNo': newSerialNo,
|
|
||||||
'newAssetNameId': newAssetNameId,
|
|
||||||
'newAssetNameText': newAssetNameText,
|
|
||||||
'newAssetNumber': newAssetNumber,
|
|
||||||
'newModelId': newModelId,
|
|
||||||
'newModelName': newModelName,
|
|
||||||
'newManufacturerId': newManufacturerId,
|
|
||||||
'newManufacturerName': newManufacturerName,
|
|
||||||
'newSupplierId': newSupplierId,
|
|
||||||
'newSupplierName': newSupplierName,
|
|
||||||
'photo': photo,
|
|
||||||
'remarks': remarks,
|
|
||||||
'assetInventoryDetailAssetAttachments': assetInventoryDetailAssetAttachments != null
|
|
||||||
? assetInventoryDetailAssetAttachments!.map((v) => v.toJson()).toList()
|
|
||||||
: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetInventoryModel mergeWith(AssetInventoryModel? other) {
|
|
||||||
if (other == null) return this;
|
|
||||||
|
|
||||||
return AssetInventoryModel(
|
|
||||||
id: id ?? other.id,
|
|
||||||
assetId: assetId ?? other.assetId,
|
|
||||||
transactionDate: transactionDate ?? other.transactionDate,
|
|
||||||
assetNumber: assetNumber ?? other.assetNumber,
|
|
||||||
serialNo: serialNo ?? other.serialNo,
|
|
||||||
assetName: assetName ?? other.assetName,
|
|
||||||
assetNameId: assetNameId ?? other.assetNameId,
|
|
||||||
model: model ?? other.model,
|
|
||||||
manufacturer: manufacturer ?? other.manufacturer,
|
|
||||||
supplierName: supplierName ?? other.supplierName,
|
|
||||||
siteName: siteName ?? other.siteName,
|
|
||||||
buildingName: buildingName ?? other.buildingName,
|
|
||||||
floorName: floorName ?? other.floorName,
|
|
||||||
departmentName: departmentName ?? other.departmentName,
|
|
||||||
roomName: roomName ?? other.roomName,
|
|
||||||
statusId: statusId ?? other.statusId,
|
|
||||||
status: status ?? other.status,
|
|
||||||
statusValue: statusValue ?? other.statusValue,
|
|
||||||
statusByAdminId: statusByAdminId ?? other.statusByAdminId,
|
|
||||||
statusByAdmin: statusByAdmin ?? other.statusByAdmin,
|
|
||||||
statusByAdminValue: statusByAdminValue ?? other.statusByAdminValue,
|
|
||||||
isNotRegistered: isNotRegistered ?? other.isNotRegistered,
|
|
||||||
sessionId: sessionId ?? other.sessionId,
|
|
||||||
assetImportId: assetImportId ?? other.assetImportId,
|
|
||||||
siteId: siteId ?? other.siteId,
|
|
||||||
supplierId: supplierId ?? other.supplierId,
|
|
||||||
buildingId: buildingId ?? other.buildingId,
|
|
||||||
floorId: floorId ?? other.floorId,
|
|
||||||
departmentId: departmentId ?? other.departmentId,
|
|
||||||
roomId: roomId ?? other.roomId,
|
|
||||||
newAssetNumber: newAssetNumber ?? other.newAssetNumber,
|
|
||||||
newSerialNo: newSerialNo ?? other.newSerialNo,
|
|
||||||
newAssetNameId: newAssetNameId ?? other.newAssetNameId,
|
|
||||||
newAssetNameText: newAssetNameText ?? other.newAssetNameText,
|
|
||||||
newModelId: newModelId ?? other.newModelId,
|
|
||||||
newModelName: newModelName ?? other.newModelName,
|
|
||||||
manufacturerId: manufacturerId ?? other.manufacturerId,
|
|
||||||
modelId: modelId ?? other.modelId,
|
|
||||||
newManufacturerId: newManufacturerId ?? other.newManufacturerId,
|
|
||||||
newManufacturerName: newManufacturerName ?? other.newManufacturerName,
|
|
||||||
newSupplierId: newSupplierId ?? other.newSupplierId,
|
|
||||||
newSupplierName: newSupplierName ?? other.newSupplierName,
|
|
||||||
photo: photo ?? other.photo,
|
|
||||||
photoOriginName: photoOriginName ?? other.photoOriginName,
|
|
||||||
remarks: remarks ?? other.remarks,
|
|
||||||
site: site ?? other.site,
|
|
||||||
building: building ?? other.building,
|
|
||||||
floor: floor ?? other.floor,
|
|
||||||
department: department ?? other.department,
|
|
||||||
room: room ?? other.room,
|
|
||||||
supplier: supplier ?? other.supplier,
|
|
||||||
assetInventoryDetailAssetAttachments: assetInventoryDetailAssetAttachments??other.assetInventoryDetailAssetAttachments,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +1,62 @@
|
|||||||
import 'package:test_sa/models/lookup.dart';
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
|
||||||
class CostCenterModel {
|
class CostCenterModel {
|
||||||
|
int? id;
|
||||||
|
int? assetDeliveryExternalDetailId;
|
||||||
Lookup? costCenter;
|
Lookup? costCenter;
|
||||||
|
String? acceptedBy;
|
||||||
|
String? costCenterName;
|
||||||
|
DateTime? acceptanceDate;
|
||||||
|
String? acceptedByEmail;
|
||||||
|
String? acceptedBySignature;
|
||||||
double? quantity;
|
double? quantity;
|
||||||
|
|
||||||
CostCenterModel({
|
CostCenterModel({
|
||||||
|
this.id,
|
||||||
|
this.assetDeliveryExternalDetailId,
|
||||||
this.costCenter,
|
this.costCenter,
|
||||||
|
this.acceptedBy,
|
||||||
|
this.costCenterName,
|
||||||
|
this.acceptanceDate,
|
||||||
|
this.acceptedByEmail,
|
||||||
|
this.acceptedBySignature,
|
||||||
this.quantity,
|
this.quantity,
|
||||||
});
|
});
|
||||||
|
|
||||||
CostCenterModel.fromJson(Map<String, dynamic> json) {
|
CostCenterModel.fromJson(Map<String, dynamic> json) {
|
||||||
costCenter = json['costCenter'] != null
|
costCenterName = json['costCenter'] ?? json['costCenterName'];
|
||||||
? Lookup.fromJson(json['costCenter'])
|
acceptanceDate = json['acceptanceDate'] != null ? DateTime.tryParse(json['acceptanceDate']) : null;
|
||||||
: null;
|
acceptedBySignature = json['acceptedBySignature'];
|
||||||
quantity = json['quantity'];
|
acceptedByEmail = json['acceptedByEmail'];
|
||||||
|
quantity = json['qty'] ?? json['costCenterQty'];
|
||||||
|
acceptedBy = json['acceptedBy'];
|
||||||
|
costCenter = json['costCenter'] != null ? Lookup(name: json['costCenter']) : null;
|
||||||
|
id = json['id'] ?? json['costCenterId'];
|
||||||
|
assetDeliveryExternalDetailId = json['assetDeliveryExternalDetailId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = {};
|
final Map<String, dynamic> data = {};
|
||||||
if (costCenter != null) {
|
|
||||||
data['costCenter'] = costCenter!.toJson();
|
data['id'] = id ?? 0;
|
||||||
|
data['qty'] = quantity;
|
||||||
|
// data['costCenter'] = costCenter;
|
||||||
|
// data['acceptedBy'] = acceptedBy;
|
||||||
|
// data['acceptanceDate'] = acceptanceDate;
|
||||||
|
// data['acceptedByEmail'] = acceptedByEmail;
|
||||||
|
// data['acceptedBySignature'] = acceptedBySignature;
|
||||||
|
data['costCenter'] = costCenterName;
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
data['quantity'] = quantity;
|
|
||||||
|
Map<String, dynamic> toEndUserAcceptanceFormJson() {
|
||||||
|
final Map<String, dynamic> data = {};
|
||||||
|
data['assetDeliveryExternalDeliveryId'] = assetDeliveryExternalDetailId;
|
||||||
|
data['costCenterName'] = costCenterName;
|
||||||
|
data['acceptedBy'] = acceptedBy;
|
||||||
|
data['acceptanceDate'] = acceptanceDate?.toIso8601String();
|
||||||
|
data['acceptedByEmail'] = acceptedByEmail;
|
||||||
|
data['acceptedBySignature'] = acceptedBySignature;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
class DeliveryInspectionFormModel {
|
||||||
|
int? assetDeliveryExternalDeliveryId;
|
||||||
|
String? deliveryInspectionInspectedBy;
|
||||||
|
DateTime? deliveryInspectionInspectedDateFrom;
|
||||||
|
DateTime? deliveryInspectionInspectedDateTo;
|
||||||
|
num? totalTime;
|
||||||
|
String? deliveryInspectionApprovedBy;
|
||||||
|
|
||||||
|
DeliveryInspectionFormModel({
|
||||||
|
this.assetDeliveryExternalDeliveryId,
|
||||||
|
this.deliveryInspectionInspectedBy,
|
||||||
|
this.deliveryInspectionInspectedDateFrom,
|
||||||
|
this.deliveryInspectionInspectedDateTo,
|
||||||
|
this.totalTime,
|
||||||
|
this.deliveryInspectionApprovedBy,
|
||||||
|
});
|
||||||
|
|
||||||
|
DeliveryInspectionFormModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
assetDeliveryExternalDeliveryId = json['assetDeliveryExternalDeliveryId'];
|
||||||
|
deliveryInspectionInspectedBy = json['deliveryInspectionInspectedBy'];
|
||||||
|
deliveryInspectionInspectedDateFrom = json['deliveryInspectionInspectedDateFrom']!=null?DateTime.tryParse(json['deliveryInspectionInspectedDateFrom']):null;
|
||||||
|
deliveryInspectionInspectedDateTo = json['deliveryInspectionInspectedDateTo']!=null?DateTime.tryParse(json['deliveryInspectionInspectedDateTo']):null;
|
||||||
|
totalTime = json['totalTime'];
|
||||||
|
deliveryInspectionApprovedBy = json['deliveryInspectionApprovedBy'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'assetDeliveryExternalDeliveryId': assetDeliveryExternalDeliveryId,
|
||||||
|
'deliveryInspectionInspectedBy': deliveryInspectionInspectedBy,
|
||||||
|
'deliveryInspectionInspectedDateFrom': deliveryInspectionInspectedDateFrom?.toIso8601String(),
|
||||||
|
'deliveryInspectionInspectedDateTo': deliveryInspectionInspectedDateTo?.toIso8601String(),
|
||||||
|
'totalTime': totalTime,
|
||||||
|
'deliveryInspectionApprovedBy': deliveryInspectionApprovedBy,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
class DeliveryLineModel {
|
||||||
|
int? id;
|
||||||
|
int? assetDeliveryInternalDetailId;
|
||||||
|
String? itemNumber;
|
||||||
|
String? itemDescription;
|
||||||
|
num? qty;
|
||||||
|
num? remainingQty;
|
||||||
|
num? usingQtyInThisDelivery;
|
||||||
|
num? unitPrice;
|
||||||
|
num? total;
|
||||||
|
String? unitOfMeasure;
|
||||||
|
String? lineType;
|
||||||
|
String? itemCategory;
|
||||||
|
|
||||||
|
DeliveryLineModel({
|
||||||
|
this.id,
|
||||||
|
this.assetDeliveryInternalDetailId,
|
||||||
|
this.itemNumber,
|
||||||
|
this.itemDescription,
|
||||||
|
this.qty,
|
||||||
|
this.remainingQty,
|
||||||
|
this.usingQtyInThisDelivery,
|
||||||
|
this.unitPrice,
|
||||||
|
this.total,
|
||||||
|
this.unitOfMeasure,
|
||||||
|
this.lineType,
|
||||||
|
this.itemCategory,
|
||||||
|
});
|
||||||
|
|
||||||
|
DeliveryLineModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetDeliveryInternalDetailId = json['assetDeliveryInternalDetailId'];
|
||||||
|
itemNumber = json['itemNumber'];
|
||||||
|
itemDescription = json['itemDescription'];
|
||||||
|
qty = json['qty'];
|
||||||
|
remainingQty = json['remainingQty'];
|
||||||
|
usingQtyInThisDelivery = json['usingQtyInThisDelivery'];
|
||||||
|
unitPrice = json['unitPrice'];
|
||||||
|
total = json['total'];
|
||||||
|
unitOfMeasure = json['unitOfMeasure'];
|
||||||
|
lineType = json['lineType'];
|
||||||
|
itemCategory = json['itemCategory'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'assetDeliveryInternalDetailId': assetDeliveryInternalDetailId,
|
||||||
|
'itemNumber': itemNumber,
|
||||||
|
'itemDescription': itemDescription,
|
||||||
|
'qty': qty,
|
||||||
|
'remainingQty': remainingQty,
|
||||||
|
'usingQtyInThisDelivery': usingQtyInThisDelivery,
|
||||||
|
'unitPrice': unitPrice,
|
||||||
|
'total': total,
|
||||||
|
'unitOfMeasure': unitOfMeasure,
|
||||||
|
'lineType': lineType,
|
||||||
|
'itemCategory': itemCategory,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
|
||||||
|
class EndUserAssetDetailsModel {
|
||||||
|
int? id;
|
||||||
|
int? typeId;
|
||||||
|
int? assetDeliveryExternalDeliveryId;
|
||||||
|
String? type;
|
||||||
|
String? itemNumber;
|
||||||
|
String? costCenterName;
|
||||||
|
Lookup? status;
|
||||||
|
Lookup? rejectionReason;
|
||||||
|
String? description;
|
||||||
|
double? receivedQty;
|
||||||
|
num? rejectedQty;
|
||||||
|
String? assetNumber;
|
||||||
|
String? serialNo;
|
||||||
|
String? assetType;
|
||||||
|
String? replacedAssetNo;
|
||||||
|
|
||||||
|
EndUserAssetDetailsModel(
|
||||||
|
{this.costCenterName,
|
||||||
|
this.rejectedQty,
|
||||||
|
this.description,
|
||||||
|
this.id,
|
||||||
|
this.typeId,
|
||||||
|
this.status,
|
||||||
|
this.rejectionReason,
|
||||||
|
this.assetType,
|
||||||
|
this.assetNumber,
|
||||||
|
this.serialNo,
|
||||||
|
this.itemNumber,
|
||||||
|
this.type,
|
||||||
|
this.receivedQty,
|
||||||
|
this.replacedAssetNo,
|
||||||
|
this.assetDeliveryExternalDeliveryId});
|
||||||
|
|
||||||
|
EndUserAssetDetailsModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
typeId = json['typeId'];
|
||||||
|
type = json['type'];
|
||||||
|
itemNumber = json['itemNumber'];
|
||||||
|
status = json['status'] != null ? Lookup.fromJson(json['status']) : null;
|
||||||
|
rejectionReason = json['rejectReason'] != null ? Lookup.fromJson(json['rejectReason']) : null;
|
||||||
|
description = json['description'];
|
||||||
|
receivedQty = json['receivedQty'];
|
||||||
|
rejectedQty = json['rejectedQty'];
|
||||||
|
assetNumber = json['assetNumber'];
|
||||||
|
serialNo = json['serialNo'];
|
||||||
|
assetType = json['assetType'];
|
||||||
|
replacedAssetNo = json['replacedAssetNo'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = {};
|
||||||
|
data['id'] = id;
|
||||||
|
data['assetDeliveryExternalDeliveryId'] = assetDeliveryExternalDeliveryId;
|
||||||
|
data['costCenterName'] = costCenterName;
|
||||||
|
data['typeId'] = typeId;
|
||||||
|
data['type'] = type;
|
||||||
|
data['itemNumber'] = itemNumber;
|
||||||
|
data['statusId'] = status?.id;
|
||||||
|
// data['status'] = status;
|
||||||
|
// data['rejectionReason'] = rejectionReason;
|
||||||
|
data['rejectReasonId'] = rejectionReason?.id;
|
||||||
|
data['description'] = description;
|
||||||
|
data['receivedQty'] = receivedQty;
|
||||||
|
data['rejectedQty'] = rejectedQty;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
||||||
|
|
||||||
|
class AssetDeliveryHistoryModel {
|
||||||
|
WorkOrderAssignedEmployee? user;
|
||||||
|
Lookup? status;
|
||||||
|
DateTime? createdDate;
|
||||||
|
String ?timeDifference;
|
||||||
|
|
||||||
|
AssetDeliveryHistoryModel({
|
||||||
|
this.user,
|
||||||
|
this.status,
|
||||||
|
this.createdDate,
|
||||||
|
this.timeDifference,
|
||||||
|
});
|
||||||
|
|
||||||
|
AssetDeliveryHistoryModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
user = json['user'] != null ? WorkOrderAssignedEmployee.fromJson(json['user']) : null;
|
||||||
|
status = json['status'] != null ? Lookup.fromJson(json['status']) : null;
|
||||||
|
createdDate = json['createdDate'] != null ? DateTime.tryParse(json['createdDate']) : null;
|
||||||
|
timeDifference = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
if (user != null) {
|
||||||
|
data['user'] = user!.toJson();
|
||||||
|
}
|
||||||
|
if (status != null) {
|
||||||
|
data['status'] = status!.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
class OracleUserModel {
|
||||||
|
String? employeeNumber;
|
||||||
|
String? fullName;
|
||||||
|
String? job;
|
||||||
|
String? employeeMobileNumber;
|
||||||
|
String? employeeExtensionNumber;
|
||||||
|
String? employeeEmail;
|
||||||
|
|
||||||
|
OracleUserModel({
|
||||||
|
this.employeeNumber,
|
||||||
|
this.fullName,
|
||||||
|
this.job,
|
||||||
|
this.employeeMobileNumber,
|
||||||
|
this.employeeExtensionNumber,
|
||||||
|
this.employeeEmail,
|
||||||
|
});
|
||||||
|
|
||||||
|
OracleUserModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
employeeNumber = json['employeeNumber'];
|
||||||
|
fullName = json['fullName'];
|
||||||
|
job = json['job'];
|
||||||
|
employeeMobileNumber = json['employeeMobileNumber'];
|
||||||
|
employeeExtensionNumber = json['employeeExtensionNumber'];
|
||||||
|
employeeEmail = json['employeeEmail'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,234 +0,0 @@
|
|||||||
import 'package:test_sa/models/new_models/site.dart';
|
|
||||||
|
|
||||||
class SessionModel {
|
|
||||||
int? id;
|
|
||||||
String? createdDate;
|
|
||||||
String? sessionName;
|
|
||||||
int? sessionTypeId;
|
|
||||||
int? sessionTypeValue;
|
|
||||||
String? sessionTypeName;
|
|
||||||
int? statusId;
|
|
||||||
String? statusName;
|
|
||||||
String? startDate;
|
|
||||||
String? endDate;
|
|
||||||
List<Site> assetInventorySites = [];
|
|
||||||
List<AssetInventoryAssignedEmployee> assetInventoryAssignedEmployee = [];
|
|
||||||
|
|
||||||
SessionModel({
|
|
||||||
this.id,
|
|
||||||
this.sessionName,
|
|
||||||
this.createdDate,
|
|
||||||
this.sessionTypeId,
|
|
||||||
this.sessionTypeValue,
|
|
||||||
this.sessionTypeName,
|
|
||||||
this.statusId,
|
|
||||||
this.statusName,
|
|
||||||
this.startDate,
|
|
||||||
this.endDate,
|
|
||||||
List<Site>? assetInventorySites,
|
|
||||||
List<AssetInventoryAssignedEmployee>? assetInventoryAssignedEmployee,
|
|
||||||
}) {
|
|
||||||
this.assetInventorySites = assetInventorySites ?? [];
|
|
||||||
this.assetInventoryAssignedEmployee = assetInventoryAssignedEmployee ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
SessionModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
sessionName = json['sessionName'];
|
|
||||||
sessionTypeId = json['sessionTypeId'];
|
|
||||||
sessionTypeValue = json['sessionTypeValue'];
|
|
||||||
sessionTypeName = json['sessionTypeName'];
|
|
||||||
statusId = json['statusId'];
|
|
||||||
createdDate = json['createdDate'];
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final map = <String, dynamic>{};
|
|
||||||
map['id'] = id;
|
|
||||||
map['sessionName'] = sessionName;
|
|
||||||
map['sessionTypeId'] = sessionTypeId;
|
|
||||||
map['sessionTypeValue'] = sessionTypeValue;
|
|
||||||
map['sessionTypeName'] = sessionTypeName;
|
|
||||||
map['statusId'] = statusId;
|
|
||||||
map['statusName'] = statusName;
|
|
||||||
map['createdDate'] = createdDate;
|
|
||||||
map['startDate'] = startDate;
|
|
||||||
map['endDate'] = endDate;
|
|
||||||
map['assetInventorySites'] = assetInventorySites.map((e) => e.toJson()).toList();
|
|
||||||
map['assetInventoryAssignedEmployee'] = assetInventoryAssignedEmployee.map((e) => e.toJson()).toList();
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// class AssetInventorySite {
|
|
||||||
// int? siteId;
|
|
||||||
// String? siteName;
|
|
||||||
// List<AssetInventoryBuilding> assetInventoryBuildings = [];
|
|
||||||
//
|
|
||||||
// AssetInventorySite({
|
|
||||||
// this.siteId,
|
|
||||||
// this.siteName,
|
|
||||||
// List<AssetInventoryBuilding>? assetInventoryBuildings,
|
|
||||||
// }) {
|
|
||||||
// this.assetInventoryBuildings = assetInventoryBuildings ?? [];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// AssetInventorySite.fromJson(Map<String, dynamic> json) {
|
|
||||||
// siteId = json['siteId'];
|
|
||||||
// siteName = json['siteName'];
|
|
||||||
//
|
|
||||||
// if (json['assetInventoryBuildings'] != null) {
|
|
||||||
// assetInventoryBuildings = (json['assetInventoryBuildings'] as List).map((e) => AssetInventoryBuilding.fromJson(e)).toList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Map<String, dynamic> toJson() {
|
|
||||||
// final map = <String, dynamic>{};
|
|
||||||
// map['siteId'] = siteId;
|
|
||||||
// map['siteName'] = siteName;
|
|
||||||
// map['assetInventoryBuildings'] = assetInventoryBuildings.map((e) => e.toJson()).toList();
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class AssetInventoryBuilding {
|
|
||||||
// int? buildingId;
|
|
||||||
// String? buildingName;
|
|
||||||
// List<AssetInventoryFloor> assetInventoryFloors = [];
|
|
||||||
//
|
|
||||||
// AssetInventoryBuilding({
|
|
||||||
// this.buildingId,
|
|
||||||
// this.buildingName,
|
|
||||||
// List<AssetInventoryFloor>? assetInventoryFloors,
|
|
||||||
// }) {
|
|
||||||
// this.assetInventoryFloors = assetInventoryFloors ?? [];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// AssetInventoryBuilding.fromJson(Map<String, dynamic> json) {
|
|
||||||
// buildingId = json['buildingId'];
|
|
||||||
// buildingName = json['buildingName'];
|
|
||||||
//
|
|
||||||
// if (json['assetInventoryFloors'] != null) {
|
|
||||||
// assetInventoryFloors = (json['assetInventoryFloors'] as List).map((e) => AssetInventoryFloor.fromJson(e)).toList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Map<String, dynamic> toJson() {
|
|
||||||
// final map = <String, dynamic>{};
|
|
||||||
// map['buildingId'] = buildingId;
|
|
||||||
// map['buildingName'] = buildingName;
|
|
||||||
// map['assetInventoryFloors'] = assetInventoryFloors.map((e) => e.toJson()).toList();
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class AssetInventoryFloor {
|
|
||||||
// int? floorId;
|
|
||||||
// String? floorName;
|
|
||||||
// List<AssetInventoryDepartment> assetInventoryDepartments = [];
|
|
||||||
//
|
|
||||||
// AssetInventoryFloor({
|
|
||||||
// this.floorId,
|
|
||||||
// this.floorName,
|
|
||||||
// List<AssetInventoryDepartment>? assetInventoryDepartments,
|
|
||||||
// }) {
|
|
||||||
// this.assetInventoryDepartments = assetInventoryDepartments ?? [];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// AssetInventoryFloor.fromJson(Map<String, dynamic> json) {
|
|
||||||
// floorId = json['floorId'];
|
|
||||||
// floorName = json['floorName'];
|
|
||||||
//
|
|
||||||
// if (json['assetInventoryDepartments'] != null) {
|
|
||||||
// assetInventoryDepartments = (json['assetInventoryDepartments'] as List).map((e) => AssetInventoryDepartment.fromJson(e)).toList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Map<String, dynamic> toJson() {
|
|
||||||
// final map = <String, dynamic>{};
|
|
||||||
// map['floorId'] = floorId;
|
|
||||||
// map['floorName'] = floorName;
|
|
||||||
// map['assetInventoryDepartments'] = assetInventoryDepartments.map((e) => e.toJson()).toList();
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class AssetInventoryDepartment {
|
|
||||||
// int? departmentId;
|
|
||||||
// String? departmentName;
|
|
||||||
// List<AssetInventoryRoom> assetInventoryRooms = [];
|
|
||||||
//
|
|
||||||
// AssetInventoryDepartment({
|
|
||||||
// this.departmentId,
|
|
||||||
// this.departmentName,
|
|
||||||
// List<AssetInventoryRoom>? assetInventoryRooms,
|
|
||||||
// }) {
|
|
||||||
// this.assetInventoryRooms = assetInventoryRooms ?? [];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// AssetInventoryDepartment.fromJson(Map<String, dynamic> json) {
|
|
||||||
// departmentId = json['departmentId'];
|
|
||||||
// departmentName = json['departmentName'];
|
|
||||||
//
|
|
||||||
// if (json['assetInventoryRooms'] != null) {
|
|
||||||
// assetInventoryRooms = (json['assetInventoryRooms'] as List).map((e) => AssetInventoryRoom.fromJson(e)).toList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Map<String, dynamic> toJson() {
|
|
||||||
// final map = <String, dynamic>{};
|
|
||||||
// map['departmentId'] = departmentId;
|
|
||||||
// map['departmentName'] = departmentName;
|
|
||||||
// map['assetInventoryRooms'] = assetInventoryRooms.map((e) => e.toJson()).toList();
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class AssetInventoryRoom {
|
|
||||||
// int? roomId;
|
|
||||||
// String? roomName;
|
|
||||||
//
|
|
||||||
// AssetInventoryRoom({this.roomId, this.roomName});
|
|
||||||
//
|
|
||||||
// AssetInventoryRoom.fromJson(Map<String, dynamic> json) {
|
|
||||||
// roomId = json['roomId'];
|
|
||||||
// roomName = json['roomName'];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Map<String, dynamic> toJson() {
|
|
||||||
// final map = <String, dynamic>{};
|
|
||||||
// map['roomId'] = roomId;
|
|
||||||
// map['roomName'] = roomName;
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
class AssetInventoryAssignedEmployee {
|
|
||||||
String? assignedEngineerId;
|
|
||||||
String? assignedEngineerName;
|
|
||||||
|
|
||||||
AssetInventoryAssignedEmployee({this.assignedEngineerId, this.assignedEngineerName});
|
|
||||||
|
|
||||||
AssetInventoryAssignedEmployee.fromJson(Map<String, dynamic> json) {
|
|
||||||
assignedEngineerId = json['assignedEngineerId'];
|
|
||||||
assignedEngineerName = json['assignedEngineerName'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final map = <String, dynamic>{};
|
|
||||||
map['assignedEngineerId'] = assignedEngineerId;
|
|
||||||
map['assignedEngineerName'] = assignedEngineerName;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
class TechnicalInspectionAssetBasicInfoModel {
|
||||||
|
int? id;
|
||||||
|
String? assetNumber;
|
||||||
|
String? assetType;
|
||||||
|
String? assetOrigin;
|
||||||
|
String? assetName;
|
||||||
|
String? model;
|
||||||
|
String? manufacturer;
|
||||||
|
String? site;
|
||||||
|
String? building;
|
||||||
|
String? floor;
|
||||||
|
String? department;
|
||||||
|
String? room;
|
||||||
|
|
||||||
|
TechnicalInspectionAssetBasicInfoModel({
|
||||||
|
this.id,
|
||||||
|
this.assetNumber,
|
||||||
|
this.assetType,
|
||||||
|
this.assetOrigin,
|
||||||
|
this.assetName,
|
||||||
|
this.model,
|
||||||
|
this.manufacturer,
|
||||||
|
this.site,
|
||||||
|
this.building,
|
||||||
|
this.floor,
|
||||||
|
this.department,
|
||||||
|
this.room,
|
||||||
|
});
|
||||||
|
|
||||||
|
TechnicalInspectionAssetBasicInfoModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetNumber = json['assetNumber'];
|
||||||
|
assetType = json['assetType'];
|
||||||
|
assetOrigin = json['assetOrigin'];
|
||||||
|
assetName = json['assetName'];
|
||||||
|
model = json['model'];
|
||||||
|
manufacturer = json['manufacturer'];
|
||||||
|
site = json['site'];
|
||||||
|
building = json['building'];
|
||||||
|
floor = json['floor'];
|
||||||
|
department = json['department'];
|
||||||
|
room = json['room'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'assetNumber': assetNumber,
|
||||||
|
'assetType': assetType,
|
||||||
|
'assetOrigin': assetOrigin,
|
||||||
|
'assetName': assetName,
|
||||||
|
'model': model,
|
||||||
|
'manufacturer': manufacturer,
|
||||||
|
'site': site,
|
||||||
|
'building': building,
|
||||||
|
'floor': floor,
|
||||||
|
'department': department,
|
||||||
|
'room': room,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,215 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:test_sa/models/device/supplier.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';
|
||||||
|
import 'package:test_sa/models/new_models/site.dart';
|
||||||
|
|
||||||
|
import '../../../models/device/model_definition.dart';
|
||||||
|
import '../../../models/new_models/department.dart';
|
||||||
|
|
||||||
|
class TechnicalInspectionAssetModel {
|
||||||
|
num? id;
|
||||||
|
num? tableItemId;
|
||||||
|
num? lineId;
|
||||||
|
num? assetDeliveryInternalDetailAssetId;
|
||||||
|
num? assetDeliveryInternalDetailAssetChildId;
|
||||||
|
num? costCenterId;
|
||||||
|
String? assetNumber;
|
||||||
|
String? status;
|
||||||
|
Lookup? assetOrigin;
|
||||||
|
Lookup? replacedAsset;
|
||||||
|
AssetModelDefination? modelDefinition;
|
||||||
|
Supplier? supplier;
|
||||||
|
Lookup? assetType; // Now nullable
|
||||||
|
Site? site; // Now nullable
|
||||||
|
Building? building; // Now nullable
|
||||||
|
Floor? floor; // Now nullable
|
||||||
|
Department? department; // Now nullable
|
||||||
|
Rooms? room;
|
||||||
|
String? serialNo;
|
||||||
|
String? systemId;
|
||||||
|
DateTime? installationDate;
|
||||||
|
List<TechnicalInspectionAssetModel>? childAssetList;
|
||||||
|
bool? flagphysicalInspection;
|
||||||
|
bool? flagFunctionPerformance;
|
||||||
|
bool? flagGroundingResistance;
|
||||||
|
bool? flagChassiss;
|
||||||
|
bool? flagLeadsLeakage;
|
||||||
|
bool? flagAlert;
|
||||||
|
|
||||||
|
TechnicalInspectionAssetModel({
|
||||||
|
this.id,
|
||||||
|
this.assetDeliveryInternalDetailAssetId,
|
||||||
|
this.assetDeliveryInternalDetailAssetChildId,
|
||||||
|
this.tableItemId,
|
||||||
|
this.status,
|
||||||
|
this.lineId,
|
||||||
|
this.costCenterId,
|
||||||
|
this.assetNumber,
|
||||||
|
this.assetOrigin,
|
||||||
|
this.assetType,
|
||||||
|
this.replacedAsset,
|
||||||
|
this.modelDefinition,
|
||||||
|
this.supplier,
|
||||||
|
this.site,
|
||||||
|
this.building,
|
||||||
|
this.floor,
|
||||||
|
this.department,
|
||||||
|
this.room,
|
||||||
|
this.serialNo,
|
||||||
|
this.systemId,
|
||||||
|
this.installationDate,
|
||||||
|
this.childAssetList,
|
||||||
|
this.flagphysicalInspection,
|
||||||
|
this.flagFunctionPerformance,
|
||||||
|
this.flagGroundingResistance,
|
||||||
|
this.flagChassiss,
|
||||||
|
this.flagLeadsLeakage,
|
||||||
|
this.flagAlert,
|
||||||
|
});
|
||||||
|
|
||||||
|
TechnicalInspectionAssetModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetDeliveryInternalDetailAssetId = json['assetDeliveryInternalDetailAssetId'];
|
||||||
|
assetDeliveryInternalDetailAssetChildId = json['assetDeliveryInternalDetailAssetChildId'];
|
||||||
|
assetNumber = json['assetNumber'];
|
||||||
|
assetOrigin = json['assetOrigin'] != null ? Lookup.fromJson(json['assetOrigin']) : null;
|
||||||
|
replacedAsset = json['replacedAsset'] != null ? Lookup.fromJson(json['replacedAsset']) : null;
|
||||||
|
modelDefinition = json['modelDefinition'] != null ? AssetModelDefination.fromJson(json['modelDefinition']) : null;
|
||||||
|
supplier = json['supplier'] != null ? Supplier.fromJson(json['supplier']) : null;
|
||||||
|
assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
|
||||||
|
site = json['site'] != null ? Site.fromJson(json['site']) : null;
|
||||||
|
building = json['building'] != null ? Building.fromJson(json['building']) : null;
|
||||||
|
floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
|
||||||
|
department = json['department'] != null ? Department.fromJson(json['department']) : null;
|
||||||
|
room = json['room'] != null ? Rooms.fromJson(json['room']) : null;
|
||||||
|
serialNo = json['serialNo'];
|
||||||
|
systemId = json['systemId'];
|
||||||
|
installationDate = json['installationDate'] != null ? DateTime.tryParse(json['installationDate']) : null;
|
||||||
|
childAssetList =
|
||||||
|
json['assetDeliveryInternalDetailAssetChild'] != null ? (json['assetDeliveryInternalDetailAssetChild'] as List).map((e) => TechnicalInspectionAssetModel.fromJson(e)).toList() : [];
|
||||||
|
//Need to keep one parm from backend
|
||||||
|
// childAssetList = json['assetDeliveryExternalDeliveryLineTechnicalInspectionItemChild'] != null
|
||||||
|
// ? (json['assetDeliveryExternalDeliveryLineTechnicalInspectionItemChild'] as List).map((e) => TechnicalInspectionAssetModel.fromJson(e)).toList()
|
||||||
|
// : [];
|
||||||
|
flagphysicalInspection = json['flagphysicalInspection'];
|
||||||
|
flagFunctionPerformance = json['flagFunctionPerformance'];
|
||||||
|
flagGroundingResistance = json['flagGroundingResistance'];
|
||||||
|
flagChassiss = json['flagChassiss'];
|
||||||
|
flagLeadsLeakage = json['flagLeadsLeakage'];
|
||||||
|
flagAlert = json['flagAlert'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = {};
|
||||||
|
data['id'] = id;
|
||||||
|
data['assetDeliveryInternalDetailAssetId'] = assetDeliveryInternalDetailAssetId;
|
||||||
|
data['assetDeliveryExternalDeliveryId'] = tableItemId;
|
||||||
|
data['assetDeliveryExternalDetailId'] = lineId;
|
||||||
|
data['costCenterId'] = costCenterId;
|
||||||
|
data['assetNumber'] = assetNumber;
|
||||||
|
data['assetOriginId'] = assetOrigin?.id;
|
||||||
|
data['assetTypeId'] = assetType?.id;
|
||||||
|
data['replacedAssetId'] = replacedAsset?.id;
|
||||||
|
data['modelDefinitionId'] = modelDefinition?.modelDefinitionId;
|
||||||
|
data['supplierId'] = supplier?.id;
|
||||||
|
data['siteId'] = site?.id;
|
||||||
|
data['buildingId'] = building?.id;
|
||||||
|
data['floorId'] = floor?.id;
|
||||||
|
data['departmentId'] = department?.id;
|
||||||
|
data['roomId'] = room?.id;
|
||||||
|
data['serialNo'] = serialNo;
|
||||||
|
data['systemId'] = systemId;
|
||||||
|
data['installationDate'] = installationDate?.toIso8601String();
|
||||||
|
data['assetDeliveryInternalDetailAssetChild'] = childAssetList?.map((e) => e.toChildJson()).toList();
|
||||||
|
data['flagphysicalInspection'] = flagphysicalInspection;
|
||||||
|
data['flagFunctionPerformance'] = flagFunctionPerformance;
|
||||||
|
data['flagGroundingResistance'] = flagGroundingResistance;
|
||||||
|
data['flagChassiss'] = flagChassiss;
|
||||||
|
data['flagLeadsLeakage'] = flagLeadsLeakage;
|
||||||
|
data['flagAlert'] = flagAlert;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toChildJson() {
|
||||||
|
final Map<String, dynamic> data = {};
|
||||||
|
data['id'] = id;
|
||||||
|
data['assetDeliveryInternalDetailAssetChildId'] = assetDeliveryInternalDetailAssetChildId;
|
||||||
|
data['assetNumber'] = assetNumber;
|
||||||
|
data['assetOriginId'] = assetOrigin?.id;
|
||||||
|
data['assetTypeId'] = assetType?.id;
|
||||||
|
data['replacedAssetId'] = replacedAsset?.id;
|
||||||
|
data['modelDefinitionId'] = modelDefinition?.modelDefinitionId;
|
||||||
|
data['supplierId'] = supplier?.id;
|
||||||
|
data['siteId'] = site?.id;
|
||||||
|
data['buildingId'] = building?.id;
|
||||||
|
data['floorId'] = floor?.id;
|
||||||
|
data['departmentId'] = department?.id;
|
||||||
|
data['roomId'] = room?.id;
|
||||||
|
data['serialNo'] = serialNo;
|
||||||
|
data['systemId'] = systemId;
|
||||||
|
data['installationDate'] = installationDate?.toIso8601String();
|
||||||
|
data['flagphysicalInspection'] = flagphysicalInspection;
|
||||||
|
data['flagFunctionPerformance'] = flagFunctionPerformance;
|
||||||
|
data['flagGroundingResistance'] = flagGroundingResistance;
|
||||||
|
data['flagChassiss'] = flagChassiss;
|
||||||
|
data['flagLeadsLeakage'] = flagLeadsLeakage;
|
||||||
|
data['flagAlert'] = flagAlert;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InspectionChecklistItem {
|
||||||
|
String? title;
|
||||||
|
String? value;
|
||||||
|
String? status; // "PASS" or "FAIL"
|
||||||
|
|
||||||
|
InspectionChecklistItem({this.title, this.status, this.value});
|
||||||
|
|
||||||
|
InspectionChecklistItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
title = json['title'];
|
||||||
|
value = json['value'];
|
||||||
|
status = json['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'title': title,
|
||||||
|
'value': value,
|
||||||
|
'status': status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AssetModelDefination {
|
||||||
|
int? modelDefinitionId;
|
||||||
|
String? assetName;
|
||||||
|
String? model;
|
||||||
|
String? manufacturer;
|
||||||
|
|
||||||
|
AssetModelDefination({
|
||||||
|
this.modelDefinitionId,
|
||||||
|
this.assetName,
|
||||||
|
this.model,
|
||||||
|
this.manufacturer,
|
||||||
|
});
|
||||||
|
|
||||||
|
AssetModelDefination.fromJson(Map<String, dynamic> json) {
|
||||||
|
modelDefinitionId = json['modelDefinitionId'];
|
||||||
|
assetName = json['assetName'];
|
||||||
|
model = json['model'];
|
||||||
|
manufacturer = json['manufacturer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['modelDefinitionId'] = modelDefinitionId;
|
||||||
|
data['assetName'] = assetName;
|
||||||
|
data['model'] = model;
|
||||||
|
data['manufacturer'] = manufacturer;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/cost_center_model.dart';
|
||||||
|
|
||||||
|
class TechnicalInspectionFormModel {
|
||||||
|
Lookup? powerSupplyType;
|
||||||
|
num? powerReading;
|
||||||
|
num? maxCurrent;
|
||||||
|
num? voltage;
|
||||||
|
num? frequency;
|
||||||
|
List<CostCenterModel>? costCenters;
|
||||||
|
int? tableItemId;
|
||||||
|
int? lineId;
|
||||||
|
|
||||||
|
TechnicalInspectionFormModel({
|
||||||
|
this.powerSupplyType,
|
||||||
|
this.powerReading,
|
||||||
|
this.maxCurrent,
|
||||||
|
this.voltage,
|
||||||
|
this.frequency,
|
||||||
|
this.costCenters,
|
||||||
|
this.lineId,
|
||||||
|
this.tableItemId,
|
||||||
|
});
|
||||||
|
|
||||||
|
TechnicalInspectionFormModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
powerSupplyType = json["powerSupplyType"] == null ? null : Lookup.fromJson(json["powerSupplyType"]);
|
||||||
|
powerReading = json['powerReading'];
|
||||||
|
maxCurrent = json['maxCurrent'];
|
||||||
|
voltage = json['voltage'];
|
||||||
|
frequency = json['frequency'];
|
||||||
|
if (json['costCenters'] != null) {
|
||||||
|
costCenters = <CostCenterModel>[];
|
||||||
|
json['costCenters'].forEach((v) {
|
||||||
|
costCenters!.add(CostCenterModel.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = {};
|
||||||
|
data['powerSupplyTypeId'] = powerSupplyType?.id;
|
||||||
|
data['assetDeliveryExternalDeliveryId'] = tableItemId;
|
||||||
|
data['assetDeliveryExternalDetailId'] = lineId;
|
||||||
|
data['powerReading'] = powerReading;
|
||||||
|
data['maxCurrent'] = maxCurrent;
|
||||||
|
data['voltage'] = voltage;
|
||||||
|
data['frequency'] = frequency;
|
||||||
|
// data['costCenters'] = costCenters != null ? costCenters!.map((v) => v.toJson()).toList() : [];
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
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/string_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/text_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/history_log_view.dart';
|
|
||||||
import 'package:test_sa/modules/cm_module/cm_detail_provider.dart';
|
|
||||||
import 'package:test_sa/modules/cx_module/chat/chat_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';
|
|
||||||
|
|
||||||
class AssetDeliveryDetailPage extends StatefulWidget {
|
|
||||||
final int requestId;
|
|
||||||
|
|
||||||
AssetDeliveryDetailPage({Key? key, required this.requestId}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_AssetDeliveryDetailPageState createState() {
|
|
||||||
return _AssetDeliveryDetailPageState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AssetDeliveryDetailPageState extends State<AssetDeliveryDetailPage> {
|
|
||||||
late CMDetailProvider _requestProvider;
|
|
||||||
|
|
||||||
static const int moduleId = 1;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
Provider.of<ChatProvider>(context, listen: false).reset();
|
|
||||||
getInitialData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getInitialData() async {
|
|
||||||
///Replace with data ...
|
|
||||||
// _requestProvider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
||||||
// await _requestProvider.getWorkOrderById(id: widget.requestId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
appBar: DefaultAppBar(
|
|
||||||
///Title should be change with view change
|
|
||||||
title: 'Delivery Inspection'.addTranslation,
|
|
||||||
onBackPress: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
body: DefaultTabController(
|
|
||||||
length: 2,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, top: 12.toScreenHeight),
|
|
||||||
decoration: BoxDecoration(color: context.isDark ? AppColor.neutral50 : AppColor.white10, borderRadius: BorderRadius.circular(10)),
|
|
||||||
child: TabBar(
|
|
||||||
//controller: _tabController,
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight, horizontal: 4.toScreenWidth),
|
|
||||||
labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
|
|
||||||
unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
|
|
||||||
unselectedLabelStyle: AppTextStyles.bodyText,
|
|
||||||
labelStyle: AppTextStyles.bodyText,
|
|
||||||
indicatorPadding: EdgeInsets.zero,
|
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
|
||||||
dividerColor: Colors.transparent,
|
|
||||||
indicator: BoxDecoration(color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, borderRadius: BorderRadius.circular(7)),
|
|
||||||
onTap: (index) {
|
|
||||||
// setState(() {});
|
|
||||||
},
|
|
||||||
tabs: [
|
|
||||||
Tab(text: context.translation.details, height: 57.toScreenHeight),
|
|
||||||
Tab(text: context.translation.historyLogs, height: 57.toScreenHeight),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TabBarView(
|
|
||||||
children: [
|
|
||||||
DeliveryInspectionFormView(),
|
|
||||||
const AssetDeliveryHistoryLogView(),
|
|
||||||
],
|
|
||||||
).expanded,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
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/generic_attachment_model.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';
|
||||||
|
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/multi_image_picker.dart';
|
||||||
|
|
||||||
|
class AssetDeliveryAttachmentView extends StatefulWidget {
|
||||||
|
///Need to check which parm need here.
|
||||||
|
final int? lineId;
|
||||||
|
final int? tableItemId;
|
||||||
|
final int? requestId;
|
||||||
|
final bool? isHmg;
|
||||||
|
|
||||||
|
const AssetDeliveryAttachmentView({
|
||||||
|
super.key,
|
||||||
|
this.lineId,
|
||||||
|
this.requestId,
|
||||||
|
this.tableItemId,
|
||||||
|
this.isHmg,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AssetDeliveryAttachmentView> createState() => _AssetDeliveryAttachmentViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentView> {
|
||||||
|
List<GenericAttachmentModel> _attachments = [];
|
||||||
|
bool isLoading = false;
|
||||||
|
late AssetDeliveryProvider assetDeliveryProvider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
getInitialData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getInitialData() async {
|
||||||
|
///get previoues Attachment from Apis.
|
||||||
|
isLoading = true;
|
||||||
|
setState(() {});
|
||||||
|
_attachments = await assetDeliveryProvider.getAttachments(tableItemId: widget.tableItemId);
|
||||||
|
isLoading = false;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
appBar: DefaultAppBar(
|
||||||
|
title: 'Attachments'.addTranslation,
|
||||||
|
onBackPress: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
body: isLoading
|
||||||
|
? const CircularProgressIndicator(color: AppColor.primary10).center
|
||||||
|
: Column(
|
||||||
|
children: [
|
||||||
|
AttachmentPicker(
|
||||||
|
label: context.translation.attachments,
|
||||||
|
attachment: _attachments,
|
||||||
|
buttonColor: AppColor.primary10,
|
||||||
|
onlyImages: false,
|
||||||
|
// showAsGrid: true,
|
||||||
|
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
|
||||||
|
onChange: (attachment) {},
|
||||||
|
)
|
||||||
|
.toShadowContainer(
|
||||||
|
context,
|
||||||
|
borderRadius: 20,
|
||||||
|
padding: 12,
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
)
|
||||||
|
.expanded,
|
||||||
|
FooterActionButton.footerContainer(
|
||||||
|
context: context,
|
||||||
|
child: AppFilledButton(
|
||||||
|
buttonColor: AppColor.primary10,
|
||||||
|
label: 'Save'.addTranslation,
|
||||||
|
maxWidth: true,
|
||||||
|
onPressed: () async {
|
||||||
|
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(GenericAttachmentModel(id: item.id ?? 0, name: fileName));
|
||||||
|
}
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
Map<String,dynamic> payLoad ={
|
||||||
|
'assetDeliveryExternalDeliveryId': widget.tableItemId,
|
||||||
|
'attachments':attachement,
|
||||||
|
};
|
||||||
|
await assetDeliveryProvider.saveAttachment(payload:payLoad).then((status) async {
|
||||||
|
Navigator.pop(context);
|
||||||
|
if (status) {
|
||||||
|
///Need to verify need to stay on this page and refresh or go back..
|
||||||
|
Navigator.pop(context);
|
||||||
|
// assetDeliveryProvider.getDeliveryLinesListById(
|
||||||
|
// itemId: widget.tableItemId,
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
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/modules/asset_delivery_module/models/oracle_user_model.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_text_style.dart';
|
||||||
|
import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
|
|
||||||
|
class OracleUserAutoCompleteField extends StatefulWidget {
|
||||||
|
final String initialValue;
|
||||||
|
final String label;
|
||||||
|
final bool clearAfterPick;
|
||||||
|
final Function(OracleUserModel) onPick;
|
||||||
|
final Function(String)? onChanged;
|
||||||
|
|
||||||
|
const OracleUserAutoCompleteField({Key? key, required this.initialValue, required this.label, required this.onPick, this.clearAfterPick = true, this.onChanged}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AutoCompletePartsFieldState createState() => _AutoCompletePartsFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AutoCompletePartsFieldState extends State<OracleUserAutoCompleteField> {
|
||||||
|
AssetDeliveryProvider? assetDeliveryProvider;
|
||||||
|
late TextEditingController _controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_controller = TextEditingController(text: widget.initialValue);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant OracleUserAutoCompleteField oldWidget) {
|
||||||
|
if (widget.initialValue != oldWidget.initialValue) {
|
||||||
|
_controller = TextEditingController(text: widget.initialValue);
|
||||||
|
}
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
assetDeliveryProvider ??= Provider.of<AssetDeliveryProvider>(context);
|
||||||
|
final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.background(context),
|
||||||
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||||
|
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||||
|
),
|
||||||
|
child: Autocomplete<OracleUserModel>(
|
||||||
|
optionsBuilder: (TextEditingValue textEditingValue) async {
|
||||||
|
if (textEditingValue.text.isEmpty) {
|
||||||
|
return const Iterable<OracleUserModel>.empty();
|
||||||
|
}
|
||||||
|
return await assetDeliveryProvider!.getOracleUserAutoCompleteDetails(query: textEditingValue.text);
|
||||||
|
},
|
||||||
|
displayStringForOption: (OracleUserModel option) => option.fullName ?? "",
|
||||||
|
fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) {
|
||||||
|
return TextField(
|
||||||
|
controller: _controller,
|
||||||
|
focusNode: fieldFocusNode,
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.black10),
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: border,
|
||||||
|
disabledBorder: border,
|
||||||
|
focusedBorder: border,
|
||||||
|
enabledBorder: border,
|
||||||
|
errorBorder: border,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
suffixIconConstraints: const BoxConstraints(minWidth: 0),
|
||||||
|
filled: true,
|
||||||
|
fillColor: AppColor.fieldBgColor(context),
|
||||||
|
errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
|
||||||
|
floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
|
||||||
|
labelText: widget.label,
|
||||||
|
labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.textColor(context)),
|
||||||
|
),
|
||||||
|
textInputAction: TextInputAction.search,
|
||||||
|
onChanged: (text) {
|
||||||
|
if (widget.onChanged != null) {
|
||||||
|
widget.onChanged!(text);
|
||||||
|
fieldTextEditingController.text = text;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSubmitted: (String value) {
|
||||||
|
onFieldSubmitted();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onSelected: (OracleUserModel selection) {
|
||||||
|
if (widget.clearAfterPick) {
|
||||||
|
_controller.clear();
|
||||||
|
} else {
|
||||||
|
_controller.text = selection.fullName ?? '';
|
||||||
|
}
|
||||||
|
widget.onPick(selection);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,171 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_advanced_switch/flutter_advanced_switch.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:test_sa/common_widgets/lookup_autocomplete_field.dart';
|
|
||||||
import 'package:test_sa/controllers/providers/api/all_requests_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/device/asset.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/pages/asset_delivery_line_card_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_cost_center_card_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_parent_asset_list_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/update_child_asset_view.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';
|
|
||||||
import 'package:test_sa/modules/asset_inventory_module/provider/asset_inventory_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';
|
|
||||||
import 'package:test_sa/new_views/app_style/app_color.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/single_item_drop_down_menu.dart';
|
|
||||||
import 'package:test_sa/providers/service_request_providers/last_situation_provider.dart';
|
|
||||||
import 'package:test_sa/providers/service_request_providers/reject_reason_provider.dart';
|
|
||||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
||||||
import 'package:test_sa/views/widgets/e_signature/e_signature.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/requests/request_status.dart';
|
|
||||||
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
||||||
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
|
||||||
|
|
||||||
class EndUserAcceptanceFormView extends StatefulWidget {
|
|
||||||
EndUserAcceptanceFormView({
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<EndUserAcceptanceFormView> createState() => _EndUserAcceptanceFormViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _EndUserAcceptanceFormViewState extends State<EndUserAcceptanceFormView> {
|
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
||||||
bool viewOnly = false;
|
|
||||||
Uint8List? newSignature;
|
|
||||||
String? endUserSignature;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
key: _scaffoldKey,
|
|
||||||
appBar: DefaultAppBar(
|
|
||||||
title: 'Item Details'.addTranslation,
|
|
||||||
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
||||||
),
|
|
||||||
body: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SingleItemDropDownMenu<Lookup, LastSituationProvider>(
|
|
||||||
context: context,
|
|
||||||
height: 56.toScreenHeight,
|
|
||||||
title: 'Status'.addTranslation,
|
|
||||||
titleTextColor: AppColor.neutral120,
|
|
||||||
showShadow: false,
|
|
||||||
// backgroundColor: AppColor.neutral100,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
// initialValue: requestDetailProvider.activityMaintenanceHelperModel?.activityStatus,
|
|
||||||
onSelect: (status) {
|
|
||||||
if (status != null) {
|
|
||||||
// requestDetailProvider.activityMaintenanceHelperModel?.activityStatus = status;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Lookup, RejectReasonProvider>(
|
|
||||||
context: context,
|
|
||||||
height: 56.toScreenHeight,
|
|
||||||
title: 'Rejection Reason '.addTranslation,
|
|
||||||
titleTextColor: AppColor.neutral120,
|
|
||||||
showShadow: false,
|
|
||||||
// backgroundColor: AppColor.neutral100,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
// initialValue: requestDetailProvider.activityMaintenanceHelperModel?.activityStatus,
|
|
||||||
onSelect: (status) {
|
|
||||||
if (status != null) {
|
|
||||||
// requestDetailProvider.activityMaintenanceHelperModel?.activityStatus = status;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
initialValue: '',
|
|
||||||
labelText: 'Description'.addTranslation,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showShadow: false,
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
||||||
alignLabelWithHint: true,
|
|
||||||
textInputType: TextInputType.multiline,
|
|
||||||
onChange: (value) {},
|
|
||||||
onSaved: (value) {},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
ESignature(
|
|
||||||
title: 'End User Signature',
|
|
||||||
oldSignature: '',
|
|
||||||
newSignature: newSignature,
|
|
||||||
backgroundColor: AppColor.neutral100,
|
|
||||||
showShadow: false,
|
|
||||||
onChange: (signature) {
|
|
||||||
if (signature.isEmpty) return;
|
|
||||||
setState(() {
|
|
||||||
newSignature = signature;
|
|
||||||
endUserSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSaved: (signature) {
|
|
||||||
if (signature == null || signature.isEmpty) return;
|
|
||||||
setState(() {
|
|
||||||
newSignature = signature;
|
|
||||||
endUserSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).toShadowContainer(context, borderRadius: 20, padding: 12))
|
|
||||||
.expanded,
|
|
||||||
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
///Need to check which details show here...
|
|
||||||
|
|
||||||
void _saveTap() async {
|
|
||||||
AssetInventoryProvider assetInventoryProvider = Provider.of<AssetInventoryProvider>(context, listen: false);
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
import 'package:flutter/material.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/modules/asset_delivery_module/models/end_user_asset_details_model.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||||
|
|
||||||
|
class EndUserAssetDetailCard extends StatelessWidget {
|
||||||
|
EndUserAssetDetailsModel assetModel;
|
||||||
|
bool isViewOnly;
|
||||||
|
VoidCallback? editPress;
|
||||||
|
|
||||||
|
EndUserAssetDetailCard({
|
||||||
|
super.key,
|
||||||
|
required this.isViewOnly,
|
||||||
|
required this.assetModel,
|
||||||
|
this.editPress,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
assetModel.status != null
|
||||||
|
? StatusLabel(
|
||||||
|
label: assetModel.status?.name,
|
||||||
|
radius: 4,
|
||||||
|
textColor: getAssetStatusColor(context: context, status: assetModel.status?.name ?? '', isBackground: false),
|
||||||
|
backgroundColor: getAssetStatusColor(context: context, status: assetModel.status?.name ?? ''),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
if (!isViewOnly)
|
||||||
|
'edit_icon'.toSvgAsset().onPress(() {
|
||||||
|
if (editPress != null) {
|
||||||
|
editPress!();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
if (assetModel.type == 'Accessory') ...[
|
||||||
|
Text(
|
||||||
|
'Type: ${assetModel.type ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Item Number: ${assetModel.itemNumber ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Received Quantity: ${assetModel.receivedQty ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Rejection Reason: ${assetModel.rejectionReason?.name ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Rejected Quantity: ${assetModel.rejectedQty ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Description: ${assetModel.description ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
|
Text(
|
||||||
|
'Type: ${assetModel.type ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Item Number: ${assetModel.itemNumber ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Asset Number: ${assetModel.assetNumber ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Serial No: ${assetModel.serialNo ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Replaced Asset No: ${assetModel.replacedAssetNo ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Rejection Reason: ${assetModel.rejectionReason?.name ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Description: ${assetModel.description ?? '-'}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
).toShadowContainer(context, borderRadius: 20, padding: 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getAssetStatusColor({required BuildContext context, required String status, bool? isBackground = true}) {
|
||||||
|
switch (status) {
|
||||||
|
case 'Accept':
|
||||||
|
return isBackground! ? AppColor.green70.withOpacity(0.4) : AppColor.green15;
|
||||||
|
case 'Reject':
|
||||||
|
return isBackground! ? AppColor.red30.withOpacity(0.4) : AppColor.red30;
|
||||||
|
default:
|
||||||
|
return Colors.blueGrey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
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/string_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/text_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/end_user_asset_details_model.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/provider/end_user_rejection_reason_lookup_provider.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/provider/end_user_status_lookup_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_lazy_loading.dart';
|
||||||
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||||
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
||||||
|
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
||||||
|
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
||||||
|
|
||||||
|
class UpdateEndUserAssetDetailsView extends StatefulWidget {
|
||||||
|
EndUserAssetDetailsModel? assetDetailsModel;
|
||||||
|
String? costCenterName;
|
||||||
|
int? tableId;
|
||||||
|
|
||||||
|
UpdateEndUserAssetDetailsView({Key? key, this.assetDetailsModel, this.costCenterName, this.tableId}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<UpdateEndUserAssetDetailsView> createState() => _UpdateEndUserAssetDetailsViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpdateEndUserAssetDetailsViewState extends State<UpdateEndUserAssetDetailsView> {
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
bool viewOnly = false;
|
||||||
|
late AssetDeliveryProvider assetDeliveryProvider;
|
||||||
|
EndUserAssetDetailsModel model = EndUserAssetDetailsModel();
|
||||||
|
late TextEditingController quantityController;
|
||||||
|
late TextEditingController descriptionController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
quantityController = TextEditingController();
|
||||||
|
descriptionController = TextEditingController();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
getInitialData();
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getInitialData() async {
|
||||||
|
assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
|
||||||
|
if (widget.assetDetailsModel != null) {
|
||||||
|
model = EndUserAssetDetailsModel.fromJson(widget.assetDetailsModel!.toJson());
|
||||||
|
model.costCenterName = widget.costCenterName;
|
||||||
|
model.assetDeliveryExternalDeliveryId = widget.tableId;
|
||||||
|
model.status = widget.assetDetailsModel?.status;
|
||||||
|
model.rejectionReason = widget.assetDetailsModel?.rejectionReason;
|
||||||
|
}
|
||||||
|
quantityController.text = model.rejectedQty != null ? model.rejectedQty.toString() : '';
|
||||||
|
descriptionController.text = model.description ?? '';
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
key: _scaffoldKey,
|
||||||
|
appBar: DefaultAppBar(
|
||||||
|
title: 'Item Details'.addTranslation,
|
||||||
|
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SingleItemDropDownMenu<Lookup, EndUserStatusLookupProvider>(
|
||||||
|
context: context,
|
||||||
|
height: 56.toScreenHeight,
|
||||||
|
title: 'Status'.addTranslation,
|
||||||
|
titleTextColor: AppColor.neutral120,
|
||||||
|
showShadow: false,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
showAsBottomSheet: true,
|
||||||
|
initialValue: model.status,
|
||||||
|
onSelect: (status) {
|
||||||
|
if (status != null) {
|
||||||
|
model.status = status;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
SingleItemDropDownMenu<Lookup, EndUserRejectionReasonLookupProvider>(
|
||||||
|
context: context,
|
||||||
|
height: 56.toScreenHeight,
|
||||||
|
title: 'Rejection Reason '.addTranslation,
|
||||||
|
titleTextColor: AppColor.neutral120,
|
||||||
|
showShadow: false,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
showAsBottomSheet: true,
|
||||||
|
initialValue: model.rejectionReason,
|
||||||
|
onSelect: (reason) {
|
||||||
|
if (reason != null) {
|
||||||
|
model.rejectionReason = reason;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
if (model.type == 'Accessory') ...[
|
||||||
|
AppTextFormField(
|
||||||
|
labelText: 'Rejected Quantity'.addTranslation,
|
||||||
|
controller: quantityController,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
textInputType: TextInputType.number,
|
||||||
|
showShadow: false,
|
||||||
|
onChange: (value) {
|
||||||
|
if (value.isNotEmpty) {
|
||||||
|
model.rejectedQty = model.rejectedQty = num.tryParse(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
],
|
||||||
|
AppTextFormField(
|
||||||
|
controller: descriptionController,
|
||||||
|
labelText: 'Description'.addTranslation,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
showShadow: false,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
alignLabelWithHint: true,
|
||||||
|
textInputType: TextInputType.multiline,
|
||||||
|
onChange: (value) {
|
||||||
|
model.description = value;
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
model.description = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
],
|
||||||
|
).toShadowContainer(context, borderRadius: 20, padding: 12))
|
||||||
|
.expanded,
|
||||||
|
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Need to check which details show here...
|
||||||
|
|
||||||
|
void _saveTap() async {
|
||||||
|
_formKey.currentState!.save();
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
await assetDeliveryProvider.saveEndUserAssetDataData(model: model).then((status) async {
|
||||||
|
Navigator.pop(context);
|
||||||
|
if (status) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,317 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.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/string_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/text_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/cost_center_model.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/end_user_asset_details_model.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_asset_detail_card.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/oracle_user_autocomplete_field.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/update_end_user_asset_details_view.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_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_lazy_loading.dart';
|
||||||
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||||
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||||
|
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
|
||||||
|
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
||||||
|
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
||||||
|
|
||||||
|
class UpdateEndUserCostCenterDetailsView extends StatefulWidget {
|
||||||
|
int? tableItemId;
|
||||||
|
CostCenterModel? costCenterModel;
|
||||||
|
bool? isHmg;
|
||||||
|
|
||||||
|
UpdateEndUserCostCenterDetailsView({
|
||||||
|
Key? key,
|
||||||
|
this.tableItemId,
|
||||||
|
this.costCenterModel,
|
||||||
|
this.isHmg,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<UpdateEndUserCostCenterDetailsView> createState() => _UpdateEndUserCostCenterDetailsViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpdateEndUserCostCenterDetailsViewState extends State<UpdateEndUserCostCenterDetailsView> {
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
bool viewOnly = false;
|
||||||
|
CostCenterModel model = CostCenterModel();
|
||||||
|
List<EndUserAssetDetailsModel> assetList = [];
|
||||||
|
late AssetDeliveryProvider assetDeliveryProvider;
|
||||||
|
Uint8List? newSignature;
|
||||||
|
String? endUserSignature;
|
||||||
|
bool isLoading = false;
|
||||||
|
late TextEditingController acceptedByController;
|
||||||
|
late TextEditingController acceptedByEmailController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
acceptedByController = TextEditingController();
|
||||||
|
acceptedByEmailController = TextEditingController();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
getInitialData();
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getInitialData() async {
|
||||||
|
assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
|
||||||
|
|
||||||
|
if (widget.costCenterModel != null) {
|
||||||
|
model = CostCenterModel.fromJson(widget.costCenterModel!.toEndUserAcceptanceFormJson());
|
||||||
|
_fillControllers();
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
assetList = await assetDeliveryProvider.getEndUserAssetList(tableItemId: widget.tableItemId, costCenterName: widget.costCenterModel?.costCenterName);
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _fillControllers() {
|
||||||
|
acceptedByController.text = model.acceptedBy ?? '';
|
||||||
|
acceptedByEmailController.text = model.acceptedByEmail ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
acceptedByController.dispose();
|
||||||
|
acceptedByEmailController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
key: _scaffoldKey,
|
||||||
|
appBar: DefaultAppBar(
|
||||||
|
title: 'End-User Acceptance'.addTranslation,
|
||||||
|
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
inspectionDetailsForm(),
|
||||||
|
8.height,
|
||||||
|
const Divider().defaultStyle(context),
|
||||||
|
|
||||||
|
///Need to implement later as discuss with Ahmed.
|
||||||
|
// Text(
|
||||||
|
// "Acceptance Form",
|
||||||
|
// style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
||||||
|
// ),
|
||||||
|
// 6.height,
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
// 'warning_icon'.toSvgAsset(height: 16, width: 16),
|
||||||
|
// 6.width,
|
||||||
|
// Text(
|
||||||
|
// 'Review the acceptance form'.addTranslation,
|
||||||
|
// style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
||||||
|
// ),
|
||||||
|
// 6.width,
|
||||||
|
// 'web_link_icon'.toSvgAsset(height: 20, width: 20),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
16.height,
|
||||||
|
Text(
|
||||||
|
"Items",
|
||||||
|
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
endUserAssetList(context),
|
||||||
|
],
|
||||||
|
).toShadowContainer(context, borderRadius: 20, padding: 12))
|
||||||
|
.expanded,
|
||||||
|
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget endUserAssetList(BuildContext context) {
|
||||||
|
return isLoading
|
||||||
|
? const CircularProgressIndicator(color: AppColor.primary10).center
|
||||||
|
: ListView.separated(
|
||||||
|
itemCount: assetList.length,
|
||||||
|
separatorBuilder: (_, __) => 8.height,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (listContext, itemIndex) {
|
||||||
|
EndUserAssetDetailsModel model = assetList[itemIndex];
|
||||||
|
return EndUserAssetDetailCard(
|
||||||
|
assetModel: model,
|
||||||
|
isViewOnly: viewOnly,
|
||||||
|
editPress: () async {
|
||||||
|
bool isRefresh = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => UpdateEndUserAssetDetailsView(
|
||||||
|
assetDetailsModel: model,
|
||||||
|
costCenterName: widget.costCenterModel?.costCenterName,
|
||||||
|
tableId: widget.tableItemId,
|
||||||
|
)));
|
||||||
|
if (isRefresh) {
|
||||||
|
getInitialData();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget inspectionDetailsForm() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
ADatePicker(
|
||||||
|
label: 'Accepted Date'.addTranslation,
|
||||||
|
hideShadow: true,
|
||||||
|
height: 56.toScreenHeight,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
date: model.acceptanceDate,
|
||||||
|
from: DateTime(DateTime.now().year, 1, 1),
|
||||||
|
formatDateWithTime: true,
|
||||||
|
onDatePicker: (selectedDate) {
|
||||||
|
showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
builder: (BuildContext context, Widget? child) {
|
||||||
|
final ThemeData currentTheme = Theme.of(context);
|
||||||
|
return Theme(
|
||||||
|
data: currentTheme.copyWith(
|
||||||
|
timePickerTheme: TimePickerThemeData(
|
||||||
|
dialHandColor: AppColor.primary10,
|
||||||
|
dialBackgroundColor: Colors.grey.withOpacity(0.1),
|
||||||
|
hourMinuteColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.grey.withOpacity(0.1)),
|
||||||
|
dayPeriodColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.transparent),
|
||||||
|
dayPeriodTextColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? Colors.white : AppColor.primary10),
|
||||||
|
dayPeriodBorderSide: BorderSide(color: Colors.grey.withOpacity(0.2)),
|
||||||
|
entryModeIconColor: AppColor.primary10,
|
||||||
|
),
|
||||||
|
textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: AppColor.primary10)),
|
||||||
|
),
|
||||||
|
child: child!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((selectedTime) {
|
||||||
|
if (selectedTime != null) {
|
||||||
|
model.acceptanceDate = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
if (widget.isHmg == true) ...[
|
||||||
|
OracleUserAutoCompleteField(
|
||||||
|
clearAfterPick: false,
|
||||||
|
initialValue: model.acceptedBy ?? '',
|
||||||
|
label: 'Accepted By'.addTranslation,
|
||||||
|
onPick: (value) {
|
||||||
|
model.acceptedBy = value.fullName;
|
||||||
|
model.acceptedByEmail = value.employeeEmail;
|
||||||
|
acceptedByEmailController.text = value.employeeEmail ?? '';
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
AppTextFormField(
|
||||||
|
labelText: 'Accepted By Email'.addTranslation,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
controller: acceptedByEmailController,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
showShadow: false,
|
||||||
|
enable: false,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
|
AppTextFormField(
|
||||||
|
labelText: 'Accepted By'.addTranslation,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
controller: acceptedByController,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
showShadow: false,
|
||||||
|
onChange: (value) {
|
||||||
|
model.acceptedBy = value;
|
||||||
|
},
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
AppTextFormField(
|
||||||
|
labelText: 'Accepted By Email'.addTranslation,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
controller: acceptedByEmailController,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
showShadow: false,
|
||||||
|
onChange: (value) {
|
||||||
|
model.acceptedByEmail = value;
|
||||||
|
},
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
8.height,
|
||||||
|
ESignature(
|
||||||
|
title: 'End User Signature',
|
||||||
|
oldSignature: model.acceptedBySignature,
|
||||||
|
newSignature: newSignature,
|
||||||
|
backgroundColor: AppColor.neutral100,
|
||||||
|
showShadow: false,
|
||||||
|
onChange: (signature) {
|
||||||
|
log('onChange called.');
|
||||||
|
updateSignature(signature: signature);
|
||||||
|
},
|
||||||
|
onSaved: (signature) {
|
||||||
|
log('onSaved called.');
|
||||||
|
updateSignature(signature: signature);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateSignature({Uint8List? signature}) {
|
||||||
|
if (signature == null || signature.isEmpty) {
|
||||||
|
model.acceptedBySignature = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
newSignature = signature;
|
||||||
|
model.acceptedBySignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _saveTap() async {
|
||||||
|
_formKey.currentState!.save();
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
model.assetDeliveryExternalDetailId = widget.tableItemId;
|
||||||
|
await assetDeliveryProvider.saveEndUserFormData(model: model).then((status) async {
|
||||||
|
Navigator.pop(context);
|
||||||
|
if (status) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,220 +0,0 @@
|
|||||||
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/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/lookup.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/end_user_acceptance/end_user_acceptance_form_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart';
|
|
||||||
import 'package:test_sa/modules/asset_inventory_module/provider/asset_inventory_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/single_item_drop_down_menu.dart';
|
|
||||||
import 'package:test_sa/providers/service_request_providers/last_situation_provider.dart';
|
|
||||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
||||||
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
||||||
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
|
||||||
|
|
||||||
class UpdateEndUserCostCenterView extends StatefulWidget {
|
|
||||||
UpdateEndUserCostCenterView({
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<UpdateEndUserCostCenterView> createState() => _UpdateEndUserCostCenterViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _UpdateEndUserCostCenterViewState extends State<UpdateEndUserCostCenterView> {
|
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
||||||
bool viewOnly = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
key: _scaffoldKey,
|
|
||||||
appBar: DefaultAppBar(
|
|
||||||
title: 'End-User Acceptance'.addTranslation,
|
|
||||||
titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
||||||
),
|
|
||||||
body: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
inspectionDetailsForm(),
|
|
||||||
8.height,
|
|
||||||
const Divider().defaultStyle(context),
|
|
||||||
Text(
|
|
||||||
"Acceptance Form",
|
|
||||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
|
||||||
),
|
|
||||||
6.height,
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
'warning_icon'.toSvgAsset(height: 16, width: 16),
|
|
||||||
6.width,
|
|
||||||
Text(
|
|
||||||
'Review the acceptance form'.addTranslation,
|
|
||||||
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
|
||||||
),
|
|
||||||
6.width,
|
|
||||||
'web_link_icon'.toSvgAsset(height: 20, width: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
16.height,
|
|
||||||
assetList(context),
|
|
||||||
],
|
|
||||||
).toShadowContainer(context, borderRadius: 20, padding: 12))
|
|
||||||
.expanded,
|
|
||||||
FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _viewHistoryTap)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget assetList(BuildContext context) {
|
|
||||||
final assetDeliveryTableList = ['abc', 'def', 'ghi', 'fhg', 'hjhh'];
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Asset",
|
|
||||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
ListView.separated(
|
|
||||||
itemCount: assetDeliveryTableList.length,
|
|
||||||
separatorBuilder: (_, __) => 8.height,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (listContext, itemIndex) {
|
|
||||||
return TechnicalInspectionAssetCard(
|
|
||||||
assetModel: Asset(),
|
|
||||||
isViewOnly: viewOnly,
|
|
||||||
ischild: true,
|
|
||||||
editPress: () {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => EndUserAcceptanceFormView()));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget inspectionDetailsForm() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
ADatePicker(
|
|
||||||
label: 'Accepted Date'.addTranslation,
|
|
||||||
hideShadow: true,
|
|
||||||
height: 56.toScreenHeight,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
// date: _pickerStartAt,
|
|
||||||
// from: widget.pickerFromDate,
|
|
||||||
formatDateWithTime: true,
|
|
||||||
onDatePicker: (selectedDate) {
|
|
||||||
showTimePicker(
|
|
||||||
context: context,
|
|
||||||
initialTime: TimeOfDay.now(),
|
|
||||||
builder: (BuildContext context, Widget? child) {
|
|
||||||
final ThemeData currentTheme = Theme.of(context);
|
|
||||||
return Theme(
|
|
||||||
data: currentTheme.copyWith(
|
|
||||||
timePickerTheme: TimePickerThemeData(
|
|
||||||
dialHandColor: AppColor.primary10,
|
|
||||||
dialBackgroundColor: Colors.grey.withOpacity(0.1),
|
|
||||||
hourMinuteColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.grey.withOpacity(0.1)),
|
|
||||||
dayPeriodColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.transparent),
|
|
||||||
dayPeriodTextColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? Colors.white : AppColor.primary10),
|
|
||||||
dayPeriodBorderSide: BorderSide(color: Colors.grey.withOpacity(0.2)),
|
|
||||||
entryModeIconColor: AppColor.primary10,
|
|
||||||
),
|
|
||||||
textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: AppColor.primary10)),
|
|
||||||
),
|
|
||||||
child: child!,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).then((selectedTime) {
|
|
||||||
if (selectedTime != null) {
|
|
||||||
// _pickerStartAt = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
|
||||||
// if (widget.pickerFromDate != null && _pickerStartAt!.isBefore(widget.pickerFromDate!)) {
|
|
||||||
// "Start time is before the request time.".showToast;
|
|
||||||
// _pickerStartAt = null;
|
|
||||||
// selectedTime = null;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (_pickerStartAt!.isAfter(DateTime.now())) {
|
|
||||||
// "Start time is after than current time".showToast;
|
|
||||||
// _pickerStartAt = null;
|
|
||||||
// selectedTime = null;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Lookup, LastSituationProvider>(
|
|
||||||
context: context,
|
|
||||||
height: 56.toScreenHeight,
|
|
||||||
title: 'Approved by'.addTranslation,
|
|
||||||
showShadow: false,
|
|
||||||
titleTextColor: AppColor.neutral120,
|
|
||||||
// backgroundColor: AppColor.neutral100,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
// initialValue: requestDetailProvider.activityMaintenanceHelperModel?.activityStatus,
|
|
||||||
onSelect: (status) {
|
|
||||||
if (status != null) {
|
|
||||||
// requestDetailProvider.activityMaintenanceHelperModel?.activityStatus = status;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _viewHistoryTap() async {
|
|
||||||
AssetInventoryProvider assetInventoryProvider = Provider.of<AssetInventoryProvider>(context, listen: false);
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cancelTap() async {
|
|
||||||
AssetInventoryProvider assetInventoryProvider = Provider.of<AssetInventoryProvider>(context, listen: false);
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _nextTap() async {
|
|
||||||
AssetInventoryProvider assetInventoryProvider = Provider.of<AssetInventoryProvider>(context, listen: false);
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _changeStatusTap() async {
|
|
||||||
AssetInventoryProvider assetInventoryProvider = Provider.of<AssetInventoryProvider>(context, listen: false);
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/technical_inspection_asset_model.dart';
|
||||||
|
|
||||||
|
class AssetDeliveryUtils{
|
||||||
|
///This is static list for now if change in future backend provide Api as discuss with backend team
|
||||||
|
static List<InspectionChecklistItem> inspectionChecklist = [
|
||||||
|
InspectionChecklistItem(title: 'Physical Inspection As Per Manufacturer Instructions', value: 'flagphysicalInspection'),
|
||||||
|
InspectionChecklistItem(title: 'Functional Performance As Per Results Of Manufacturer Recommended Check List', value: 'flagFunctionPerformance'),
|
||||||
|
InspectionChecklistItem(title: 'Grounding Resistance: Ω', value: 'flagGroundingResistance'),
|
||||||
|
InspectionChecklistItem(title: 'Chassis Leakage Current: µA', value: 'flagChassiss'),
|
||||||
|
InspectionChecklistItem(title: 'Leads Leakage Current: µA', value: 'flagLeadsLeakage'),
|
||||||
|
InspectionChecklistItem(title: 'This Device Is Not Subject To Any Alert Or Recall Until The Date Of Preparation Of This Inspection Form', value: 'flagAlert'),
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,194 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/devices_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/widget_extensions.dart';
|
||||||
|
import 'package:test_sa/models/device/asset.dart';
|
||||||
|
import 'package:test_sa/models/device/asset_search.dart';
|
||||||
|
import 'package:test_sa/models/device/model_definition.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/models/technical_inpection_asset_model.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.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/custom_app_bar.dart';
|
||||||
|
import 'package:test_sa/views/widgets/equipment/asset_item_listview.dart';
|
||||||
|
import 'package:test_sa/views/widgets/horizontal_list_widget.dart';
|
||||||
|
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
||||||
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||||
|
|
||||||
|
class TechnicalInspectionSearchAssetView extends StatefulWidget {
|
||||||
|
/// add on route
|
||||||
|
static const String id = "search_asset_view";
|
||||||
|
final int? lineId;
|
||||||
|
|
||||||
|
const TechnicalInspectionSearchAssetView({
|
||||||
|
Key? key,
|
||||||
|
this.lineId,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TechnicalInspectionSearchAssetView> createState() => _TechnicalInspectionSearchAssetViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TechnicalInspectionSearchAssetViewState extends State<TechnicalInspectionSearchAssetView> {
|
||||||
|
int _selectedIndex = 0;
|
||||||
|
DeviceSearch? search;
|
||||||
|
late TextEditingController _searchController;
|
||||||
|
late AssetProvider _deviceProvider;
|
||||||
|
|
||||||
|
//check for this list if not need remove
|
||||||
|
final List<TechnicalInspectionAssetBasicInfoModel> _searchableList = [];
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
bool _isFirst = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_searchController = TextEditingController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_searchController.dispose();
|
||||||
|
_deviceProvider.searchReset();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<String> searchBy = [
|
||||||
|
context.translation.assetName,
|
||||||
|
context.translation.assetNumber,
|
||||||
|
'model'.addTranslation,
|
||||||
|
'manufacturer'.addTranslation,
|
||||||
|
// 'assetType'.addTranslation,
|
||||||
|
// 'assetOrigin'.addTranslation,
|
||||||
|
];
|
||||||
|
|
||||||
|
_deviceProvider = Provider.of<AssetProvider>(context, listen: false);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: context.translation.searchAsset,
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
HorizontalListWidget(
|
||||||
|
list: searchBy,
|
||||||
|
callBackFunction: (index) {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
).paddingOnly(top: 16, bottom: 0),
|
||||||
|
Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: AppTextFormField(
|
||||||
|
controller: _searchController,
|
||||||
|
textInputAction: TextInputAction.search,
|
||||||
|
labelText: "${context.translation.searchBy} ${searchBy[_selectedIndex]}",
|
||||||
|
onAction: _search,
|
||||||
|
onChange: (text) {
|
||||||
|
_searchController.text = text;
|
||||||
|
_searchController.selection = TextSelection.fromPosition(TextPosition(offset: _searchController.text.length));
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
setState(() {
|
||||||
|
search = DeviceSearch();
|
||||||
|
});
|
||||||
|
_setValue(value);
|
||||||
|
},
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
onPressed: _searchController.text.isNotEmpty ? _search : null,
|
||||||
|
color: AppColor.neutral20,
|
||||||
|
).paddingOnly(end: 0),
|
||||||
|
).paddingOnly(top: 16, start: 16, end: 16, bottom: 8)),
|
||||||
|
Expanded(
|
||||||
|
child: _searchableList.isEmpty
|
||||||
|
? _isFirst
|
||||||
|
? const SizedBox()
|
||||||
|
: NoDataFound(message: context.translation.noDeviceFound)
|
||||||
|
: LazyLoading(
|
||||||
|
nextPage: _deviceProvider.nextPage,
|
||||||
|
onLazyLoad: () async {
|
||||||
|
if (_searchController.text.isNotEmpty) {
|
||||||
|
await _deviceProvider.getAssetsForAssetDelivery(search: search, lineId: widget.lineId, isSearchBy: true);
|
||||||
|
setState(() {
|
||||||
|
_searchableList.clear();
|
||||||
|
_searchableList.addAll(_deviceProvider.technicalInspectionAsset);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: ListView.separated(
|
||||||
|
itemCount: _searchableList.length,
|
||||||
|
separatorBuilder: (listContext, itemIndex) => 8.height,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
itemBuilder: (listContext, itemIndex) {
|
||||||
|
return AssetItemListView(
|
||||||
|
device: Asset(
|
||||||
|
id: _searchableList[itemIndex].id,
|
||||||
|
assetNumber: _searchableList[itemIndex].assetNumber,
|
||||||
|
assetSerialNo: _searchableList[itemIndex].assetNumber,
|
||||||
|
modelDefinition: ModelDefinition(assetName: _searchableList[itemIndex].assetName, modelName: _searchableList[itemIndex].model),
|
||||||
|
),
|
||||||
|
onPressed: (device) {
|
||||||
|
Navigator.of(context).pop(device);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _search({bool loadMore = false}) async {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
_formKey.currentState?.save();
|
||||||
|
_searchableList.clear();
|
||||||
|
_deviceProvider.technicalInspectionAsset.clear();
|
||||||
|
setState(() {});
|
||||||
|
_deviceProvider.searchReset();
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
await _deviceProvider.getAssetsForAssetDelivery(
|
||||||
|
search: search,
|
||||||
|
lineId: widget.lineId,
|
||||||
|
isSearchBy: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_searchableList.clear();
|
||||||
|
_searchableList.addAll(_deviceProvider.technicalInspectionAsset);
|
||||||
|
_isFirst = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
_setValue(String? value) {
|
||||||
|
search ??= DeviceSearch();
|
||||||
|
switch (_selectedIndex) {
|
||||||
|
case 0:
|
||||||
|
search!.assetName = value;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
search!.assetNo = value;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
search!.model = value;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
search!.manufacturer = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,137 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.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/modules/asset_delivery_module/models/technical_inspection_asset_model.dart';
|
||||||
|
import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/asset_delivery_utils.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/default_app_bar.dart';
|
||||||
|
|
||||||
|
class InspectionChecklistBottomSheet extends StatefulWidget {
|
||||||
|
final List<InspectionChecklistItem>? initialValues;
|
||||||
|
|
||||||
|
const InspectionChecklistBottomSheet({super.key, this.initialValues});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<InspectionChecklistBottomSheet> createState() =>
|
||||||
|
_InspectionChecklistBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InspectionChecklistBottomSheetState
|
||||||
|
extends State<InspectionChecklistBottomSheet> {
|
||||||
|
late List<InspectionChecklistItem> checklist;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
/// Create local copy (no shared mutation)
|
||||||
|
checklist = AssetDeliveryUtils.inspectionChecklist
|
||||||
|
.map((e) => InspectionChecklistItem(title: e.title))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
/// Apply initial values only if provided
|
||||||
|
if (widget.initialValues != null && widget.initialValues!.isNotEmpty) {
|
||||||
|
for (final item in checklist) {
|
||||||
|
final matched = widget.initialValues!.firstWhere(
|
||||||
|
(e) => e.title == item.title,
|
||||||
|
orElse: () => InspectionChecklistItem(),
|
||||||
|
);
|
||||||
|
item.status = matched.status; // null-safe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateStatus(int index, String value) {
|
||||||
|
setState(() {
|
||||||
|
checklist[index].status = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<InspectionChecklistItem> get selectedValues =>
|
||||||
|
checklist.where((e) => e.status != null).toList();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColor.white10,
|
||||||
|
appBar: DefaultAppBar(
|
||||||
|
title: 'Asset Check List'.addTranslation,
|
||||||
|
showBackButton: false,
|
||||||
|
titleStyle: AppTextStyles.heading3.copyWith(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: context.isDark
|
||||||
|
? AppColor.neutral30
|
||||||
|
: AppColor.neutral50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
12.height,
|
||||||
|
ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: checklist.length,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final item = checklist[index];
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item.title ?? '',
|
||||||
|
style: AppTextStyles.heading6.copyWith(
|
||||||
|
color: context.isDark
|
||||||
|
? AppColor.neutral30
|
||||||
|
: AppColor.black10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: RadioListTile<String>(
|
||||||
|
title: const Text('Pass'),
|
||||||
|
value: 'PASS',
|
||||||
|
groupValue: item.status,
|
||||||
|
onChanged: (v) =>
|
||||||
|
updateStatus(index, v!),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: RadioListTile<String>(
|
||||||
|
title: const Text('Fail'),
|
||||||
|
value: 'FAIL',
|
||||||
|
groupValue: item.status,
|
||||||
|
onChanged: (v) =>
|
||||||
|
updateStatus(index, v!),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).expanded,
|
||||||
|
FooterActionButton.footerContainer(
|
||||||
|
context: context,
|
||||||
|
child: AppFilledButton(
|
||||||
|
buttonColor: AppColor.primary10,
|
||||||
|
label: 'Save'.addTranslation,
|
||||||
|
maxWidth: true,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, selectedValues);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
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/lookup.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
class CostCenterProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future<void> getData({int? id}) async {
|
||||||
|
if (loading) return;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
final response = await ApiManager.instance.get(
|
||||||
|
URLs.getCostCenterToPo + "?assetDeliveryExternalMasterId=$id",
|
||||||
|
);
|
||||||
|
stateCode = response.statusCode;
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
final List list = json.decode(response.body)['data'];
|
||||||
|
final Set<String> seenNames = {};
|
||||||
|
int index = 0;
|
||||||
|
items =
|
||||||
|
list.where((e) => e is Map && e['name'] != null && e['name'].toString().trim().isNotEmpty).map((e) => e['name'].toString().trim()).where((name) => seenNames.add(name)).map<Lookup>((name) {
|
||||||
|
final lookup = Lookup(
|
||||||
|
id: index,
|
||||||
|
value: index + 1,
|
||||||
|
name: name,
|
||||||
|
);
|
||||||
|
index++;
|
||||||
|
return lookup;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
log('getData error', error: e, stackTrace: s);
|
||||||
|
stateCode = -1;
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
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/lookup.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
class EndUserRejectionReasonLookupProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getData({int? id}) async {
|
||||||
|
if (loading == true) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.endUserRejectionReasonLookup);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
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/lookup.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
class EndUserStatusLookupProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getData({int? id}) async {
|
||||||
|
if (loading == true) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.endUserStatusLookup);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
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/lookup.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
class PowerSupplyTypeProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getData({int? id}) async {
|
||||||
|
if (loading == true) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.powerSupplyTypeLookUp);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue