Compare commits
2 Commits
789522b79b
...
c2068544db
| Author | SHA1 | Date |
|---|---|---|
|
|
c2068544db | 3 weeks ago |
|
|
7dd8fff34e | 3 weeks ago |
@ -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';
|
||||
|
||||
class CostCenterModel {
|
||||
int? id;
|
||||
int? assetDeliveryExternalDetailId;
|
||||
Lookup? costCenter;
|
||||
String? acceptedBy;
|
||||
String? costCenterName;
|
||||
DateTime? acceptanceDate;
|
||||
String? acceptedByEmail;
|
||||
String? acceptedBySignature;
|
||||
double? quantity;
|
||||
|
||||
CostCenterModel({
|
||||
this.id,
|
||||
this.assetDeliveryExternalDetailId,
|
||||
this.costCenter,
|
||||
this.acceptedBy,
|
||||
this.costCenterName,
|
||||
this.acceptanceDate,
|
||||
this.acceptedByEmail,
|
||||
this.acceptedBySignature,
|
||||
this.quantity,
|
||||
});
|
||||
|
||||
CostCenterModel.fromJson(Map<String, dynamic> json) {
|
||||
costCenter = json['costCenter'] != null
|
||||
? Lookup.fromJson(json['costCenter'])
|
||||
: null;
|
||||
quantity = json['quantity'];
|
||||
costCenterName = json['costCenter'] ?? json['costCenterName'];
|
||||
acceptanceDate = json['acceptanceDate'] != null ? DateTime.tryParse(json['acceptanceDate']) : null;
|
||||
acceptedBySignature = json['acceptedBySignature'];
|
||||
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() {
|
||||
final Map<String, dynamic> data = {};
|
||||
if (costCenter != null) {
|
||||
data['costCenter'] = costCenter!.toJson();
|
||||
}
|
||||
data['quantity'] = quantity;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,295 @@
|
||||
|
||||
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/generic_attachment_model.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/site.dart';
|
||||
import 'package:test_sa/models/new_models/task_request/task_type_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_form_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_supplier_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/item_type_provider.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/medical_gas_inspection_provider.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/medical_gas_supplier_provider.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/order_type_provider.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/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/gas_request_providers/site_provider.dart';
|
||||
import '../../../../../../new_views/common_widgets/default_app_bar.dart';
|
||||
|
||||
class CreateMedicalGasRequestPage extends StatefulWidget {
|
||||
static const String id = "/create-medical-gas";
|
||||
final MedicalGasDataModel? dataModel;
|
||||
|
||||
CreateMedicalGasRequestPage({Key? key, this.dataModel}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CreateMedicalGasRequestPageState createState() => _CreateMedicalGasRequestPageState();
|
||||
}
|
||||
|
||||
class _CreateMedicalGasRequestPageState extends State<CreateMedicalGasRequestPage> with TickerProviderStateMixin {
|
||||
final List<GenericAttachmentModel> attachments = [];
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
TaskType? selectedType;
|
||||
MedicalGasFormModel _medicalGasFormModel = MedicalGasFormModel();
|
||||
MedicalGasSupplierModel? medicalGasInfo;
|
||||
late MedicalGasInspectionProvider medicalGasInspectionProvider;
|
||||
bool isGasInfoLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Provider.of<MedicalGasSupplierProvider>(context, listen: false).reset();
|
||||
medicalGasInspectionProvider = Provider.of<MedicalGasInspectionProvider>(context, listen: false);
|
||||
_populateFormData();
|
||||
}
|
||||
|
||||
_populateFormData() {
|
||||
if (widget.dataModel != null) {
|
||||
MedicalGasDataModel dataModel = widget.dataModel!;
|
||||
_medicalGasFormModel = MedicalGasFormModel(
|
||||
id: dataModel.id,
|
||||
orderType: Lookup(id: dataModel.requestOrderTypeId, name: dataModel.requestOrderType),
|
||||
itemType: Lookup(id: dataModel.itemTypeId, name: dataModel.itemType),
|
||||
site: Site(id: dataModel.siteId, custName: dataModel.site),
|
||||
supplier: MedicalGasSupplierModel(id: dataModel.supplierId, supplier: dataModel.supplier),
|
||||
);
|
||||
List<AttributeInfo> attributeInfo = [];
|
||||
dataModel.requestDetailDtos.forEach((v) {
|
||||
attributeInfo.add(AttributeInfo.fromJson(v.toJson()));
|
||||
});
|
||||
medicalGasInfo = MedicalGasSupplierModel(
|
||||
supplierContact: dataModel.contact,
|
||||
supplierEmail: dataModel.email,
|
||||
attributeInfo: attributeInfo,
|
||||
);
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: DefaultAppBar(title: 'Medical Gas Inspection'.addTranslation),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SingleItemDropDownMenu<Lookup, MedicalGasOrderTypeProvider>(
|
||||
context: context,
|
||||
title: "Order Type",
|
||||
validator: (value) {
|
||||
if (value == null) return "Mandatory";
|
||||
return null;
|
||||
},
|
||||
initialValue: _medicalGasFormModel.orderType,
|
||||
showShadow: false,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
showAsBottomSheet: true,
|
||||
onSelect: (value) {
|
||||
_medicalGasFormModel.orderType = value;
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, MedicalGasItemTypeProvider>(
|
||||
context: context,
|
||||
title: "Item Type",
|
||||
validator: (value) {
|
||||
if (value == null) return "Mandatory";
|
||||
return null;
|
||||
},
|
||||
initialValue: _medicalGasFormModel.itemType,
|
||||
showShadow: false,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
showAsBottomSheet: true,
|
||||
onSelect: (value) {
|
||||
_medicalGasFormModel.itemType = value;
|
||||
setState(() {});
|
||||
setGasInfo();
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Site, SiteProvider>(
|
||||
context: context,
|
||||
title: context.translation.site,
|
||||
initialValue: _medicalGasFormModel.site,
|
||||
showShadow: false,
|
||||
validator: (value) {
|
||||
if (value == null) return "Please select a site";
|
||||
return null;
|
||||
},
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
showAsBottomSheet: true,
|
||||
onSelect: (value) {
|
||||
_medicalGasFormModel.site = value;
|
||||
setState(() {});
|
||||
setGasInfo();
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
// 8.height,
|
||||
// SingleItemDropDownMenu<MedicalDepartmentModel, MedicalDepartmentProvider>(
|
||||
// context: context,
|
||||
// title: context.translation.department,
|
||||
// showShadow: false,
|
||||
// validator: (value) {
|
||||
// if (value == null) return "Please select a department";
|
||||
// return null;
|
||||
// },
|
||||
// showAsBottomSheet: true,
|
||||
// initialValue: _medicalGasFormModel.department,
|
||||
// requestById: context.userProvider.user?.clientId,
|
||||
// backgroundColor: AppColor.fieldBgColor(context),
|
||||
// onSelect: (value) {
|
||||
// _medicalGasFormModel.department = value;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// 8.height,
|
||||
SingleItemDropDownMenu<MedicalGasSupplierModel, MedicalGasSupplierProvider>(
|
||||
context: context,
|
||||
title: context.translation.supplier,
|
||||
initialValue: _medicalGasFormModel.supplier,
|
||||
showAsBottomSheet: true,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
showShadow: false,
|
||||
onSelect: (value) {
|
||||
setState(() {
|
||||
_medicalGasFormModel.supplier = value;
|
||||
});
|
||||
setGasInfo();
|
||||
},
|
||||
),
|
||||
|
||||
if (medicalGasInfo != null) medicalGasInfoWidget(),
|
||||
],
|
||||
).toShadowContainer(context, borderRadius: 20),
|
||||
).expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: Row(
|
||||
children: [
|
||||
AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: 'Save'.addTranslation,
|
||||
onPressed: () {
|
||||
_update(isSubmitted: false);
|
||||
},
|
||||
// buttonColor: AppColor.primary10,
|
||||
).expanded,
|
||||
8.width,
|
||||
AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: 'Submit'.addTranslation,
|
||||
onPressed: () {
|
||||
_update(isSubmitted: true);
|
||||
},
|
||||
// buttonColor: AppColor.primary10,
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void setGasInfo() async {
|
||||
if (_medicalGasFormModel.itemType != null && _medicalGasFormModel.site != null && _medicalGasFormModel.supplier != null) {
|
||||
setState(() {
|
||||
isGasInfoLoading = true;
|
||||
});
|
||||
medicalGasInfo =
|
||||
await medicalGasInspectionProvider.getMedicalGasInfo(itemTypeId: _medicalGasFormModel.itemType!.id, supplierId: _medicalGasFormModel.supplier!.id, siteId: _medicalGasFormModel.site!.id);
|
||||
setState(() {
|
||||
isGasInfoLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget medicalGasInfoWidget() {
|
||||
return isGasInfoLoading
|
||||
? const CircularProgressIndicator(color: AppColor.primary10).center
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
8.height,
|
||||
'Supplier Contact: ${medicalGasInfo?.supplierContact ?? "-"}'.bodyText(context).custom(color: AppColor.black10),
|
||||
8.height,
|
||||
'Supplier Email: ${medicalGasInfo?.supplierEmail ?? "-"}'.bodyText(context).custom(color: AppColor.black10),
|
||||
8.height,
|
||||
'Items'.addTranslation.bodyText(context).custom(color: AppColor.textColor(context)),
|
||||
8.height,
|
||||
// MedicalGasItemsListView(
|
||||
// itemsList: medicalGasInfo?.attributeInfo ?? [],
|
||||
// ),
|
||||
if (medicalGasInfo!.attributeInfo!.isNotEmpty)
|
||||
ListView.separated(
|
||||
separatorBuilder: (_, __) => 12.height,
|
||||
itemCount: medicalGasInfo!.attributeInfo!.length,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
AttributeInfo model = medicalGasInfo!.attributeInfo![index];
|
||||
return AppTextFormField(
|
||||
labelText: model.itemName,
|
||||
hintText: 'Enter Quantity'.addTranslation,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
initialValue: model.requestedQuantity != null ? model.requestedQuantity.toString() : '',
|
||||
textAlign: TextAlign.center,
|
||||
enable: true,
|
||||
textInputType: TextInputType.number,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
model.requestedQuantity = int.tryParse(value);
|
||||
}
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _update({bool isSubmitted = false}) async {
|
||||
if (medicalGasInfo != null && medicalGasInfo!.attributeInfo!.isNotEmpty) {
|
||||
_medicalGasFormModel.gasRequestDetail = [];
|
||||
for (var item in medicalGasInfo!.attributeInfo!) {
|
||||
_medicalGasFormModel.gasRequestDetail?.add(MedicalGasFormDetailModel(
|
||||
id: widget.dataModel != null ? item.id : 0,
|
||||
medicalGasAttributeId: item.medicalGasAttributeId ?? item.id,
|
||||
requestedQuantity: item.requestedQuantity,
|
||||
));
|
||||
}
|
||||
}
|
||||
_medicalGasFormModel.isSubmitted = isSubmitted;
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
await medicalGasInspectionProvider.saveMedicalGas(model: _medicalGasFormModel).then((status) async {
|
||||
Navigator.pop(context);
|
||||
if (status) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,152 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.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/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/create_medical_gas_request_page.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/medical_gas_inspection_provider.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/update_delivery_notes_page.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';
|
||||
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
class MedicalGasInspectionDetailPage extends StatefulWidget {
|
||||
static const String id = "/medical-gas-inspection-detail-page";
|
||||
final int inspectionId;
|
||||
final String? prority;
|
||||
|
||||
MedicalGasInspectionDetailPage({Key? key, required this.inspectionId, this.prority}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MedicalGasInspectionDetailPage> createState() => _MedicalGasInspectionDetailPageState();
|
||||
}
|
||||
|
||||
class _MedicalGasInspectionDetailPageState extends State<MedicalGasInspectionDetailPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadData();
|
||||
});
|
||||
}
|
||||
|
||||
MedicalGasDataModel? model;
|
||||
bool _isLoading = true;
|
||||
|
||||
Future<void> _loadData() async {
|
||||
final result = await context.read<MedicalGasInspectionProvider>().getMedicalGasById(requestId: widget.inspectionId);
|
||||
setState(() {
|
||||
model = result;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Request Details"),
|
||||
body: SafeArea(
|
||||
child: _isLoading
|
||||
? SizedBox.expand(child: const CircularProgressIndicator(color: AppColor.primary10).center)
|
||||
: model == null
|
||||
? const NoDataFound().center
|
||||
: Column(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
//Need to return the status form api backend
|
||||
Row(
|
||||
children: [
|
||||
if (widget.prority != null) ...[
|
||||
StatusLabel(
|
||||
label: widget.prority,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, widget.prority),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.prority),
|
||||
),
|
||||
8.width,
|
||||
],
|
||||
StatusLabel(
|
||||
label: model?.requestStatus?.name,
|
||||
textColor: AppColor.getHistoryLogStatusTextColorByName(model?.requestStatus?.name ?? ''),
|
||||
backgroundColor: AppColor.getHistoryLogStatusColorByName(model?.requestStatus?.name ?? ''),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(model!.requestedDate!.toServiceRequestCardFormat,
|
||||
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50))
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
'${context.translation.requestNo}: ${model?.requestNumber ?? '-'}'.bodyText(context),
|
||||
'Order Type: ${model?.requestOrderType ?? '-'}'.bodyText(context),
|
||||
'Item Type: ${model?.itemType ?? '-'}'.bodyText(context),
|
||||
'Site: ${model?.site ?? '-'}'.bodyText(context),
|
||||
'Supplier Name: ${model?.supplier ?? '-'}'.bodyText(context),
|
||||
'Supplier Contact: ${model?.contact ?? '-'}'.bodyText(context),
|
||||
'Supplier Email: ${model?.email ?? '-'}'.bodyText(context),
|
||||
if (model!.deliveryNoteAttachmentDto.isNotEmpty) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Attachments".addTranslation,
|
||||
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
FilesList(images: model!.deliveryNoteAttachmentDto.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
|
||||
],
|
||||
],
|
||||
).toShadowContainer(context, padding: 12),
|
||||
],
|
||||
).expanded,
|
||||
if (model?.requestStatus?.value != null && model!.requestStatus!.value! < 3)
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: model?.isSubmitted == true ? "Upload Delivery Note" : 'Update',
|
||||
onPressed: () async {
|
||||
if (model?.isSubmitted == true) {
|
||||
bool? isRefresh = await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeliveryNotes(dataModel: model)));
|
||||
if (isRefresh == true) {
|
||||
_loadData();
|
||||
}
|
||||
return;
|
||||
}
|
||||
bool? isRefresh = await Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => CreateMedicalGasRequestPage(
|
||||
dataModel: model,
|
||||
)));
|
||||
if (isRefresh == true) {
|
||||
_loadData();
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget labelValueText(BuildContext context, String label, String? value) {
|
||||
if (value == null || value.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
'$label: $value',
|
||||
style: AppTextStyles.bodyText.copyWith(
|
||||
color: context.isDark ? AppColor.neutral30 : AppColor.neutral120,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
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/models/all_requests_and_count_model.dart';
|
||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/medical_gas_inspection_detail_page.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
class MedicalGasInspectionItemView extends StatelessWidget {
|
||||
final Data? requestData;
|
||||
final RequestsDetails? requestDetails;
|
||||
final bool showShadow;
|
||||
|
||||
const MedicalGasInspectionItemView({Key? key, this.requestData, this.requestDetails, this.showShadow = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (requestData != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (requestData!.priorityName != null) ...[
|
||||
StatusLabel(
|
||||
label: requestData!.priorityName!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestData!.priorityName!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestData!.priorityName!),
|
||||
),
|
||||
8.width,
|
||||
],
|
||||
StatusLabel(
|
||||
label: requestData!.statusName!,
|
||||
textColor: AppColor.getHistoryLogStatusTextColorByName(requestData!.statusName!),
|
||||
backgroundColor: AppColor.getHistoryLogStatusColorByName(requestData!.statusName!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(requestData!.transactionDate!.toServiceRequestCardFormat,
|
||||
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
||||
],
|
||||
),
|
||||
(requestData?.typeTransaction ?? 'Medical Gas Request').heading5(context),
|
||||
infoWidget(label: 'Request Number'.addTranslation, value: requestData?.requestNo ?? '-', context: context),
|
||||
infoWidget(label: 'Request Type'.addTranslation, value: requestData?.requestType ?? '-', context: context),
|
||||
// infoWidget(label: 'Site'.addTranslation, value: requestData?.si ?? '-', context: context),
|
||||
// infoWidget(label: 'Gas Type'.addTranslation, value: requestDetails?.gasType ?? '-', context: context),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
||||
),
|
||||
4.width,
|
||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => MedicalGasInspectionDetailPage(
|
||||
inspectionId: requestData!.id!,
|
||||
prority: requestData?.priorityName,
|
||||
)));
|
||||
});
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (requestDetails!.priority != null) ...[
|
||||
StatusLabel(
|
||||
label: requestDetails!.priority!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails!.priority!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails!.priority!),
|
||||
),
|
||||
8.width,
|
||||
],
|
||||
StatusLabel(
|
||||
label: requestDetails!.status!,
|
||||
textColor: AppColor.getHistoryLogStatusTextColorByName(requestDetails!.status!),
|
||||
backgroundColor: AppColor.getHistoryLogStatusColorByName(requestDetails!.status!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(requestDetails!.date!.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
||||
],
|
||||
),
|
||||
(requestDetails?.nameOfType ?? 'Medical Gas Request').heading5(context),
|
||||
infoWidget(label: 'Request Number'.addTranslation, value: requestDetails?.requestNo ?? '-', context: context),
|
||||
infoWidget(label: 'Request Type'.addTranslation, value: requestDetails?.requestType ?? '-', context: context),
|
||||
infoWidget(label: 'Site'.addTranslation, value: requestDetails?.site ?? '-', context: context),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
||||
),
|
||||
4.width,
|
||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => MedicalGasInspectionDetailPage(
|
||||
inspectionId: requestDetails!.id!,
|
||||
prority: requestDetails?.priority,
|
||||
)));
|
||||
});
|
||||
}
|
||||
|
||||
Widget infoWidget({required String label, String? value, required BuildContext context}) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
return '$label: $value'.bodyText(context);
|
||||
}
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
// 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/enum_extensions.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/cost_center_model.dart';
|
||||
// import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
||||
// import 'package:test_sa/modules/asset_delivery_module/provider/cost_center_provider.dart';
|
||||
// import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
// import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_supplier_model.dart';
|
||||
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
// import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
// import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
||||
// import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||
// import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
// import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
||||
//
|
||||
// class MedicalGasItemsListView extends StatelessWidget {
|
||||
// final List<AttributeInfo> itemsList;
|
||||
//
|
||||
// MedicalGasItemsListView({
|
||||
// super.key,
|
||||
// required this.itemsList,
|
||||
// });
|
||||
//
|
||||
// late AssetDeliveryProvider assetDeliveryProvider;
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// // return ListView.separated(
|
||||
// // separatorBuilder: (_, __) => 12.height,
|
||||
// // itemCount: itemsList.length,
|
||||
// // shrinkWrap: true,
|
||||
// // itemBuilder: (context, index) {
|
||||
// // AttributeInfo model = itemsList[index];
|
||||
// // return AppTextFormField(
|
||||
// // labelText: model.itemName,
|
||||
// // hintText: 'Enter Quantity'.addTranslation,
|
||||
// // backgroundColor: AppColor.fieldBgColor(context),
|
||||
// // initialValue: model.requestedQuantity != null ? model.requestedQuantity.toString() : '',
|
||||
// // textAlign: TextAlign.center,
|
||||
// // enable: true,
|
||||
// // textInputType: TextInputType.number,
|
||||
// // labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
// // showShadow: false,
|
||||
// // onChange: (value) {
|
||||
// // if (value.isNotEmpty) {
|
||||
// // model.requestedQuantity = int.tryParse(value);
|
||||
// // }
|
||||
// // },
|
||||
// // style: Theme.of(context).textTheme.titleMedium,
|
||||
// // );
|
||||
// // },
|
||||
// // );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // class ItemCard extends StatelessWidget {
|
||||
// // final AttributeInfo model;
|
||||
// // final int index;
|
||||
// //
|
||||
// // const ItemCard({
|
||||
// // super.key,
|
||||
// // required this.model,
|
||||
// // required this.index,
|
||||
// // });
|
||||
// //
|
||||
// // @override
|
||||
// // Widget build(BuildContext context) {
|
||||
// // return AppTextFormField(
|
||||
// // labelText: model.itemName,
|
||||
// // hintText: 'Enter Quantity'.addTranslation,
|
||||
// // backgroundColor: AppColor.fieldBgColor(context),
|
||||
// // initialValue: model.requestedQuantity != null ? model.requestedQuantity.toString() : '',
|
||||
// // textAlign: TextAlign.center,
|
||||
// // enable: true,
|
||||
// // textInputType: TextInputType.number,
|
||||
// // labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
// // showShadow: false,
|
||||
// // onChange: (value) {
|
||||
// // if (value.isNotEmpty) {
|
||||
// // model.requestedQuantity = int.tryParse(value);
|
||||
// // }
|
||||
// // },
|
||||
// // style: Theme.of(context).textTheme.titleMedium,
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
@ -0,0 +1,92 @@
|
||||
import 'package:test_sa/models/generic_attachment_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
|
||||
|
||||
class DeliveryNotesFormModel {
|
||||
int? id;
|
||||
DateTime? deliveredDate;
|
||||
String? deliveryNoteNumber;
|
||||
bool? isPressureChecked;
|
||||
bool? isInspectedGasLeak;
|
||||
bool? isSubmitted;
|
||||
|
||||
List<GasDeliveredQuantityModel> gasDeliveredQuantityDtos = [];
|
||||
List<MedicalGasRequestDetailModel> deliveredItemList = [];
|
||||
List<GenericAttachmentModel> attachments = [];
|
||||
|
||||
DeliveryNotesFormModel({
|
||||
this.id,
|
||||
this.deliveredDate,
|
||||
this.deliveryNoteNumber,
|
||||
this.isPressureChecked,
|
||||
this.isInspectedGasLeak,
|
||||
this.isSubmitted,
|
||||
List<GasDeliveredQuantityModel>? gasDeliveredQuantityDtos,
|
||||
List<MedicalGasRequestDetailModel>? deliveredItemList,
|
||||
List<GenericAttachmentModel>? attachments,
|
||||
}) {
|
||||
this.gasDeliveredQuantityDtos = gasDeliveredQuantityDtos ?? [];
|
||||
this.deliveredItemList = deliveredItemList ?? [];
|
||||
this.attachments = attachments ?? [];
|
||||
}
|
||||
|
||||
DeliveryNotesFormModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
deliveredDate = json['deliveredDate'] != null ? DateTime.parse(json['deliveredDate']) : null;
|
||||
deliveryNoteNumber = json['deliveryNoteNumber'];
|
||||
isPressureChecked = json['isPressureChecked'];
|
||||
isInspectedGasLeak = json['isInspectedGasLeak'];
|
||||
isSubmitted = json['isSubmitted'];
|
||||
if (json['gasDeliveredQuantityDtos'] != null) {
|
||||
gasDeliveredQuantityDtos = [];
|
||||
json['gasDeliveredQuantityDtos'].forEach((v) {
|
||||
gasDeliveredQuantityDtos.add(GasDeliveredQuantityModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
if (json['cUMedicalGasDeliveryNoteAttachmentDtos'] != null) {
|
||||
attachments = [];
|
||||
json['cUMedicalGasDeliveryNoteAttachmentDtos'].forEach((v) {
|
||||
attachments.add(GenericAttachmentModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'deliveredDate': deliveredDate?.toIso8601String(),
|
||||
'deliveryNoteNumber': deliveryNoteNumber,
|
||||
'isPressureChecked': isPressureChecked,
|
||||
'isInspectedGasLeak': isInspectedGasLeak,
|
||||
'isSubmitted': isSubmitted,
|
||||
'gasDeliveredQuantityDtos': gasDeliveredQuantityDtos.map((e) => e.toJson()).toList(),
|
||||
'cUMedicalGasDeliveryNoteAttachmentDtos': attachments.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class GasDeliveredQuantityModel {
|
||||
int? id;
|
||||
num? medicalGasAttributeId;
|
||||
num? deliveredQuantity;
|
||||
|
||||
GasDeliveredQuantityModel({
|
||||
this.id,
|
||||
this.medicalGasAttributeId,
|
||||
this.deliveredQuantity,
|
||||
});
|
||||
|
||||
GasDeliveredQuantityModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
medicalGasAttributeId = json['medicalGasAttributeId'];
|
||||
deliveredQuantity = json['deliveredQuantity'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'medicalGasAttributeId': medicalGasAttributeId,
|
||||
'deliveredQuantity': deliveredQuantity,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
import 'package:test_sa/models/base.dart';
|
||||
import 'package:test_sa/models/generic_attachment_model.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class MedicalGasDataModel {
|
||||
int? id;
|
||||
String? requestNumber;
|
||||
String? requestedBy;
|
||||
String? requestedDate;
|
||||
int? requestOrderTypeId;
|
||||
String? requestOrderType;
|
||||
int? itemTypeId;
|
||||
String? itemType;
|
||||
int? siteId;
|
||||
String? site;
|
||||
int? supplierId;
|
||||
String? supplier;
|
||||
String? contact;
|
||||
String? email;
|
||||
bool? isSubmitted;
|
||||
String? requestOrderStatus;
|
||||
bool? isPressureChecked;
|
||||
bool? isInspectedGasLeak;
|
||||
Lookup? requestStatus;
|
||||
DateTime? deliveredDate;
|
||||
String? deliveryNote;
|
||||
|
||||
/// ✅ non-nullable lists
|
||||
List<MedicalGasRequestDetailModel> requestDetailDtos = [];
|
||||
List<GenericAttachmentModel> deliveryNoteAttachmentDto = [];
|
||||
|
||||
MedicalGasDataModel({
|
||||
this.id,
|
||||
this.requestNumber,
|
||||
this.requestedBy,
|
||||
this.requestedDate,
|
||||
this.requestOrderTypeId,
|
||||
this.requestOrderType,
|
||||
this.itemTypeId,
|
||||
this.itemType,
|
||||
this.siteId,
|
||||
this.site,
|
||||
this.requestStatus,
|
||||
this.supplierId,
|
||||
this.supplier,
|
||||
this.contact,
|
||||
this.email,
|
||||
this.isSubmitted,
|
||||
this.requestOrderStatus,
|
||||
this.isPressureChecked,
|
||||
this.isInspectedGasLeak,
|
||||
this.deliveredDate,
|
||||
this.deliveryNote,
|
||||
List<MedicalGasRequestDetailModel>? requestDetailDtos,
|
||||
List<GenericAttachmentModel>? deliveryNoteAttachmentDto,
|
||||
}) {
|
||||
this.requestDetailDtos = requestDetailDtos ?? [];
|
||||
this.deliveryNoteAttachmentDto = deliveryNoteAttachmentDto ?? [];
|
||||
}
|
||||
|
||||
MedicalGasDataModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
requestNumber = json['requestNumber'];
|
||||
requestedBy = json['requestedBy'];
|
||||
requestedDate = json['requestedDate'];
|
||||
requestOrderTypeId = json['requestOrderTypeId'];
|
||||
requestOrderType = json['requestOrderType'];
|
||||
itemTypeId = json['itemTypeId'];
|
||||
itemType = json['itemType'];
|
||||
siteId = json['siteId'];
|
||||
site = json['site'];
|
||||
supplierId = json['supplierId'];
|
||||
supplier = json['supplier'];
|
||||
contact = json['contact'];
|
||||
email = json['email'];
|
||||
isSubmitted = json['isSubmitted'];
|
||||
deliveryNote = json['deliveryNote'];
|
||||
requestOrderStatus = json['requestOrderStatus'];
|
||||
isPressureChecked = json['isPressureChecked'];
|
||||
isInspectedGasLeak = json['isInspectedGasLeak'];
|
||||
deliveredDate = json['deliveredDate'] != null ? DateTime.parse(json['deliveredDate']) : null;
|
||||
requestStatus = json['requestOrderStatusDto'] != null ? Lookup.fromJson(json['requestOrderStatusDto']) : null;
|
||||
if (json['requestDetailDtos'] != null) {
|
||||
requestDetailDtos = [];
|
||||
json['requestDetailDtos'].forEach((v) {
|
||||
requestDetailDtos.add(MedicalGasRequestDetailModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
if (json['deliveryNoteAttachmentDto'] != null) {
|
||||
deliveryNoteAttachmentDto = [];
|
||||
json['deliveryNoteAttachmentDto'].forEach((v) {
|
||||
deliveryNoteAttachmentDto.add(GenericAttachmentModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'requestNumber': requestNumber,
|
||||
'requestedBy': requestedBy,
|
||||
'requestedDate': requestedDate,
|
||||
'requestOrderTypeId': requestOrderTypeId,
|
||||
'requestOrderType': requestOrderType,
|
||||
'itemTypeId': itemTypeId,
|
||||
'itemType': itemType,
|
||||
'siteId': siteId,
|
||||
'site': site,
|
||||
'supplierId': supplierId,
|
||||
'deliveryNote': deliveryNote,
|
||||
'supplier': supplier,
|
||||
'contact': contact,
|
||||
'email': email,
|
||||
'isSubmitted': isSubmitted,
|
||||
'requestOrderStatus': requestOrderStatus,
|
||||
'isPressureChecked': isPressureChecked,
|
||||
'isInspectedGasLeak': isInspectedGasLeak,
|
||||
'deliveredDate': deliveredDate?.toIso8601String(),
|
||||
'requestDetailDtos': requestDetailDtos.map((e) => e.toJson()).toList(),
|
||||
'requestOrderStatusDto': requestStatus?.toJson(),
|
||||
'deliveryNoteAttachmentDto': deliveryNoteAttachmentDto.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class MedicalGasRequestDetailModel extends Base {
|
||||
int? id;
|
||||
int? medicalGasAttributeId;
|
||||
String? itemName;
|
||||
String? oracleName;
|
||||
String? oracleCode;
|
||||
num? requestedQuantity;
|
||||
num? deliveredQuantity;
|
||||
|
||||
MedicalGasRequestDetailModel({
|
||||
this.id,
|
||||
this.medicalGasAttributeId,
|
||||
this.itemName,
|
||||
this.oracleName,
|
||||
this.oracleCode,
|
||||
this.requestedQuantity,
|
||||
this.deliveredQuantity,
|
||||
}) : super(identifier: id?.toString(), name: itemName);
|
||||
|
||||
MedicalGasRequestDetailModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
medicalGasAttributeId = json['medicalGasAttributeId'];
|
||||
itemName = json['itemName'];
|
||||
identifier = id.toString();
|
||||
name = itemName;
|
||||
oracleName = json['oracleName'];
|
||||
oracleCode = json['oracleCode'];
|
||||
requestedQuantity = json['requestedQuantity'];
|
||||
deliveredQuantity = json['deliveredQuantity'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'medicalGasAttributeId': medicalGasAttributeId,
|
||||
'itemName': itemName,
|
||||
'oracleName': oracleName,
|
||||
'oracleCode': oracleCode,
|
||||
'requestedQuantity': requestedQuantity,
|
||||
'deliveredQuantity': deliveredQuantity,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/site.dart';
|
||||
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_supplier_model.dart';
|
||||
|
||||
class MedicalGasFormModel {
|
||||
int? id;
|
||||
int? requestOrderTypeId;
|
||||
Lookup? orderType;
|
||||
Lookup? itemType;
|
||||
int? itemTypeId;
|
||||
int? siteId;
|
||||
Site? site;
|
||||
MedicalDepartmentModel? department;
|
||||
MedicalGasSupplierModel? supplier;
|
||||
int? supplierId;
|
||||
bool? isSubmitted;
|
||||
List<MedicalGasFormDetailModel>? gasRequestDetail;
|
||||
|
||||
MedicalGasFormModel({
|
||||
this.id,
|
||||
this.requestOrderTypeId,
|
||||
this.itemTypeId,
|
||||
this.siteId,
|
||||
this.supplierId,
|
||||
this.supplier,
|
||||
this.isSubmitted,
|
||||
this.orderType,
|
||||
this.itemType,
|
||||
this.site,
|
||||
this.department,
|
||||
this.gasRequestDetail,
|
||||
});
|
||||
|
||||
MedicalGasFormModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
requestOrderTypeId = json['requestOrderTypeId'];
|
||||
itemTypeId = json['itemTypeId'];
|
||||
siteId = json['siteId'];
|
||||
supplierId = json['supplierId'];
|
||||
isSubmitted = json['isSubmitted'];
|
||||
if (json['gasRequestDetailDtos'] != null) {
|
||||
gasRequestDetail = [];
|
||||
json['gasRequestDetailDtos'].forEach((v) {
|
||||
gasRequestDetail!.add(MedicalGasFormDetailModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id ?? 0,
|
||||
'requestOrderTypeId': orderType?.id,
|
||||
'itemTypeId': itemType?.id,
|
||||
'siteId': site?.id,
|
||||
'supplierId': supplier?.id,
|
||||
'isSubmitted': isSubmitted,
|
||||
'gasRequestDetailDtos': gasRequestDetail?.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class MedicalGasFormDetailModel {
|
||||
int? id;
|
||||
int? medicalGasAttributeId;
|
||||
num? requestedQuantity;
|
||||
|
||||
MedicalGasFormDetailModel({
|
||||
this.id,
|
||||
this.medicalGasAttributeId,
|
||||
this.requestedQuantity,
|
||||
});
|
||||
|
||||
MedicalGasFormDetailModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
medicalGasAttributeId = json['medicalGasAttributeId'];
|
||||
requestedQuantity = json['requestedQuantity'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'medicalGasAttributeId': medicalGasAttributeId,
|
||||
'requestedQuantity': requestedQuantity??0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
|
||||
|
||||
import 'package:test_sa/models/base.dart';
|
||||
|
||||
class MedicalGasSupplierModel extends Base {
|
||||
int? id;
|
||||
String? supplier;
|
||||
String? supplierEmail;
|
||||
String? supplierContact;
|
||||
List<AttributeInfo>? attributeInfo;
|
||||
|
||||
MedicalGasSupplierModel({this.id, this.supplier, this.supplierContact, this.supplierEmail, this.attributeInfo}) : super(identifier: id?.toString() ?? '', name: supplier);
|
||||
|
||||
MedicalGasSupplierModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
identifier = id?.toString() ?? '';
|
||||
supplier = json['supplier'];
|
||||
name=supplier;
|
||||
supplierEmail = json['supplierEmail'];
|
||||
supplierContact = json['supplierContact'];
|
||||
if (json['attributeInfoDtos'] != null) {
|
||||
attributeInfo = [];
|
||||
json['attributeInfoDtos'].forEach((v) {
|
||||
attributeInfo!.add(AttributeInfo.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'supplier': supplier,
|
||||
'supplierEmail': supplierEmail,
|
||||
'supplierContact': supplierContact,
|
||||
'attributeInfoDtos': attributeInfo?.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AttributeInfo {
|
||||
int? id;
|
||||
int? medicalGasAttributeId;
|
||||
num? requestedQuantity;
|
||||
String? itemName;
|
||||
String? oracleName;
|
||||
String? oracleCode;
|
||||
|
||||
AttributeInfo({this.id, this.medicalGasAttributeId, this.requestedQuantity, this.itemName, this.oracleName, this.oracleCode});
|
||||
|
||||
AttributeInfo.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
medicalGasAttributeId = json['medicalGasAttributeId'];
|
||||
requestedQuantity = json['requestedQuantity'];
|
||||
itemName = json['itemName'];
|
||||
oracleName = json['oracleName'];
|
||||
oracleCode = json['oracleCode'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
//{
|
||||
// "id": 0,
|
||||
// "medicalGasAttributeId": 0,
|
||||
// "requestedQuantity": 0
|
||||
// }
|
||||
return {
|
||||
'id': id,
|
||||
'medicalGasAttributeId': medicalGasAttributeId,
|
||||
'requestedQuantity': requestedQuantity,
|
||||
// 'oracleCode': oracleCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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 MedicalGasItemTypeProvider 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.itemTypeLookUp);
|
||||
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,119 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/delivery_notes_form_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_form_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_supplier_model.dart';
|
||||
|
||||
class MedicalGasInspectionProvider extends ChangeNotifier {
|
||||
final pageItemNumber = 10;
|
||||
final searchPageItemNumber = 10;
|
||||
int pageNo = 1;
|
||||
|
||||
void reset() {
|
||||
pageNo = 1;
|
||||
stateCode = null;
|
||||
}
|
||||
|
||||
int? stateCode;
|
||||
bool isDetailLoading = false;
|
||||
bool nextPage = false;
|
||||
bool isLoading = false;
|
||||
bool isGasInfoLoading = false;
|
||||
|
||||
Future<MedicalGasDataModel?> getMedicalGasById({int? requestId}) async {
|
||||
MedicalGasDataModel? assetDeliveryDataModel = MedicalGasDataModel();
|
||||
|
||||
try {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
final response = await ApiManager.instance.get(URLs.getMedicalGasById + "?medicalGasRequestId=$requestId");
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
assetDeliveryDataModel = MedicalGasDataModel.fromJson(json.decode(response.body)["data"]);
|
||||
} else {
|
||||
assetDeliveryDataModel = null;
|
||||
}
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return assetDeliveryDataModel;
|
||||
} catch (e) {
|
||||
log("getMedicalGas details [error] : $e");
|
||||
isLoading = false;
|
||||
assetDeliveryDataModel = null;
|
||||
notifyListeners();
|
||||
return assetDeliveryDataModel;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> saveMedicalGas({
|
||||
required MedicalGasFormModel model,
|
||||
}) async {
|
||||
isLoading = true;
|
||||
try {
|
||||
final response = await ApiManager.instance.post(URLs.addMedicalGasRequest, body: model.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<MedicalGasSupplierModel?> getMedicalGasInfo({int? supplierId, int? itemTypeId, num? siteId}) async {
|
||||
MedicalGasSupplierModel? supplierInfo;
|
||||
Map<String, dynamic> payload = {"supplierId": supplierId, "itemTypeId": itemTypeId, "siteId": siteId};
|
||||
try {
|
||||
isGasInfoLoading = true;
|
||||
notifyListeners();
|
||||
final response = await ApiManager.instance.post("${URLs.getMedicalGasInfoBySupplier}", body: payload);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
final jsonData = json.decode(response.body)["data"];
|
||||
supplierInfo = MedicalGasSupplierModel.fromJson(jsonData);
|
||||
}
|
||||
isGasInfoLoading = false;
|
||||
notifyListeners();
|
||||
return supplierInfo;
|
||||
} catch (e) {
|
||||
log("get Supplier List [error] : $e");
|
||||
isGasInfoLoading = false;
|
||||
notifyListeners();
|
||||
return supplierInfo;
|
||||
}
|
||||
}
|
||||
Future<bool> updatedDeliveryNotes({
|
||||
required DeliveryNotesFormModel model,
|
||||
}) async {
|
||||
isLoading = true;
|
||||
try {
|
||||
final response = await ApiManager.instance.post(URLs.updateDeliveryNote, body: model.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
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/medical_gas_inspection/models/medical_gas_supplier_model.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
class MedicalGasSupplierProvider extends LoadingListNotifier<MedicalGasSupplierModel> {
|
||||
@override
|
||||
Future getData({int? id}) async {
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getMedicalGasSupplierList);
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
items = listJson.map((supplier) => MedicalGasSupplierModel.fromJson(supplier)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
}
|
||||
@ -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 MedicalGasOrderTypeProvider 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.orderTypeLookUp);
|
||||
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,288 @@
|
||||
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/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/delivery_notes_form_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_data_model.dart';
|
||||
import 'package:test_sa/modules/medical_gas_inspection/providers/medical_gas_inspection_provider.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/multiple_item_drop_down_menu.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
||||
|
||||
class UpdateDeliveryNotes extends StatefulWidget {
|
||||
final MedicalGasDataModel? dataModel;
|
||||
|
||||
UpdateDeliveryNotes({Key? key, required this.dataModel}) : super(key: key);
|
||||
|
||||
@override
|
||||
_UpdateDeliveryNotesState createState() {
|
||||
return _UpdateDeliveryNotesState();
|
||||
}
|
||||
}
|
||||
|
||||
class _UpdateDeliveryNotesState extends State<UpdateDeliveryNotes> {
|
||||
DeliveryNotesFormModel formModel = DeliveryNotesFormModel();
|
||||
late MedicalGasInspectionProvider medicalGasInspectionProvider;
|
||||
bool pressureTestAcknowledgement = false;
|
||||
bool leakTestAcknowledgement = false;
|
||||
List<MedicalGasRequestDetailModel> selectedItemList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
medicalGasInspectionProvider = Provider.of<MedicalGasInspectionProvider>(context, listen: false);
|
||||
_populateFormData();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
_populateFormData() {
|
||||
if (widget.dataModel != null) {
|
||||
MedicalGasDataModel dataModel = widget.dataModel!;
|
||||
formModel = DeliveryNotesFormModel(
|
||||
id: dataModel.id,
|
||||
deliveredItemList: dataModel.requestDetailDtos,
|
||||
isInspectedGasLeak: dataModel.isInspectedGasLeak,
|
||||
isPressureChecked: dataModel.isPressureChecked,
|
||||
deliveredDate: dataModel.deliveredDate,
|
||||
attachments: dataModel.deliveryNoteAttachmentDto,
|
||||
isSubmitted: dataModel.isSubmitted,
|
||||
deliveryNoteNumber: dataModel.deliveryNote);
|
||||
//Need to Confirm this condition
|
||||
selectedItemList = dataModel.requestDetailDtos.where((item) => item.deliveredQuantity != null && item.deliveredQuantity! > 0).toList();
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(
|
||||
title: "Upload Delivery Note",
|
||||
// onWillPopScope: () {
|
||||
// _update(context: context);
|
||||
// },
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ADatePicker(
|
||||
label: "Delivered Date",
|
||||
hideShadow: true,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
from: DateTime.now().subtract(const Duration(days: 365 * 3)),
|
||||
date: formModel.deliveredDate,
|
||||
formatDateWithTime: true,
|
||||
onDatePicker: (selectedDate) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
if (selectedTime != null) {
|
||||
formModel.deliveredDate = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
16.height,
|
||||
MultipleItemDropDownMenu<MedicalGasRequestDetailModel, NullableLoadingProvider>(
|
||||
context: context,
|
||||
showAsBottomSheet: true,
|
||||
backgroundColor: AppColor.neutral100,
|
||||
showShadow: false,
|
||||
showCancel: true,
|
||||
requestById: context.userProvider.user?.clientId,
|
||||
title: 'Delivered Items'.addTranslation,
|
||||
staticData: formModel.deliveredItemList,
|
||||
initialValue: selectedItemList,
|
||||
onSelect: (value) {
|
||||
if ((value ?? []).isNotEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
selectedItemList = value ?? [];
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
if (selectedItemList.isNotEmpty) ...[
|
||||
8.height,
|
||||
ListView.separated(
|
||||
separatorBuilder: (_, __) => 12.height,
|
||||
itemCount: selectedItemList.length,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
MedicalGasRequestDetailModel model = selectedItemList[index];
|
||||
return AppTextFormField(
|
||||
labelText: '${model.name} (Req Qty =${model.requestedQuantity})',
|
||||
hintText: 'Enter Delivered Quantity'.addTranslation,
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
initialValue: model.deliveredQuantity != null ? model.deliveredQuantity?.toInt().toString() : '',
|
||||
textAlign: TextAlign.center,
|
||||
enable: true,
|
||||
textInputType: TextInputType.number,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
showShadow: false,
|
||||
onChange: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
model.deliveredQuantity = double.tryParse(value);
|
||||
}
|
||||
},
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
16.height,
|
||||
AppTextFormField(
|
||||
initialValue: formModel.deliveryNoteNumber,
|
||||
labelText: "Delivery Notes",
|
||||
validator: (value) {
|
||||
if ((value ?? "").isEmpty) return "Mandatory";
|
||||
return null;
|
||||
},
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||
showShadow: false,
|
||||
textInputType: TextInputType.multiline,
|
||||
makeMultiLinesNull: true,
|
||||
onChange: (value) {
|
||||
formModel.deliveryNoteNumber = value;
|
||||
},
|
||||
),
|
||||
16.height,
|
||||
AttachmentPicker(
|
||||
label: 'Upload Attachment',
|
||||
attachment: formModel.attachments,
|
||||
buttonColor: AppColor.primary10,
|
||||
// showAsListView: true,
|
||||
onlyImages: false,
|
||||
buttonIcon: 'attachment_icon'.toSvgAsset(
|
||||
color: AppColor.primary10,
|
||||
),
|
||||
),
|
||||
16.height,
|
||||
//should create a reusable widget.
|
||||
Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: formModel.isPressureChecked,
|
||||
visualDensity: const VisualDensity(horizontal: -4.0, vertical: -4.0),
|
||||
activeColor: AppColor.blueStatus(context),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
formModel.isPressureChecked = value!;
|
||||
});
|
||||
}),
|
||||
12.width,
|
||||
"I Acknowledge that the received medical gases cylinders have been tested for pressure."
|
||||
.addTranslation
|
||||
.bodyText(context)
|
||||
.custom(color: context.isDark ? AppColor.primary50 : AppColor.neutral120)
|
||||
.expanded,
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: formModel.isInspectedGasLeak,
|
||||
visualDensity: const VisualDensity(horizontal: -4.0, vertical: -4.0),
|
||||
activeColor: AppColor.blueStatus(context),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
formModel.isInspectedGasLeak = value!;
|
||||
});
|
||||
}),
|
||||
12.width,
|
||||
"I Acknowledge that the received medical gases cylinders have been inspected for leak test."
|
||||
.addTranslation
|
||||
.bodyText(context)
|
||||
.custom(color: context.isDark ? AppColor.primary50 : AppColor.neutral120)
|
||||
.expanded,
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, padding: 12),
|
||||
],
|
||||
).expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: Row(
|
||||
children: [
|
||||
AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: 'Save'.addTranslation,
|
||||
onPressed: () {
|
||||
_update(context: context);
|
||||
},
|
||||
// buttonColor: AppColor.primary10,
|
||||
).expanded,
|
||||
8.width,
|
||||
AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: 'Submit'.addTranslation,
|
||||
onPressed: () {
|
||||
_update(context: context, isSubmitted: true);
|
||||
},
|
||||
// buttonColor: AppColor.primary10,
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
// .handlePopScope(
|
||||
// cxt: context,
|
||||
// onSave: () {
|
||||
// _update(context: context);
|
||||
// });
|
||||
}
|
||||
|
||||
void _update({required BuildContext context, bool isSubmitted = false}) async {
|
||||
formModel.gasDeliveredQuantityDtos = [];
|
||||
formModel.isSubmitted = isSubmitted;
|
||||
for (var item in selectedItemList) {
|
||||
formModel.gasDeliveredQuantityDtos.add(GasDeliveredQuantityModel(
|
||||
id: widget.dataModel != null ? item.id : 0,
|
||||
medicalGasAttributeId: item.medicalGasAttributeId ?? item.id,
|
||||
deliveredQuantity: item.deliveredQuantity,
|
||||
));
|
||||
}
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
await medicalGasInspectionProvider.updatedDeliveryNotes(model: formModel).then((status) async {
|
||||
Navigator.pop(context);
|
||||
if (status) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue