ppm data model upgraded.

design_3.0_latest
Sikander Saleem 9 months ago
parent c5d3eead2d
commit 28b30d9fa8

@ -100,6 +100,7 @@ class PpmProvider extends ChangeNotifier {
notifyListeners();
return response.statusCode;
}
//
// Future<Ppm?> getPpmById(num id) async {
// // Return type is nullable
@ -123,16 +124,8 @@ class PpmProvider extends ChangeNotifier {
Future<PlanPreventiveVisit?> getPlanPreventiveVisitById(int id) async {
// try {
Response response = await ApiManager.instance.get(URLs.getPlanPreventiveVisitById + "?planPreventiveVisitId=$id");
if (response.statusCode >= 200 && response.statusCode < 300) {
return PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]);
// List requestsListJson = json.decode(response.body)["data"];
// List<Ppm> visits = requestsListJson.map((request) => Ppm.fromJson(request)).toList();
// return visits.firstWhere((element) => id == element.id, orElse: null); // Handle case where no element is found
}
return null;
// } catch (error) {

@ -2,6 +2,7 @@ import 'package:flutter/widgets.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/models/timer_model.dart';
class PlanPreventiveVisit {
@ -24,23 +25,23 @@ class PlanPreventiveVisit {
String? toDate;
AssignedEmployee? assignedEmployee;
String? acutalDateOfVisit;
TypeOfService? typeOfService;
VisitStatus? visitStatus;
String? travelingHours;
Lookup? typeOfService;
Lookup? visitStatus;
num? travelingHours;
String? comments;
int? executionTimeFrame;
Lookup? taskStatus;
String? deviceStatus;
Lookup? deviceStatus;
Lookup? assetAvailability;
Lookup? safety;
String? engSignature;
String? nurseSignature;
List<PreventiveVisitChecklists>? preventiveVisitAttachments;
List<PreventiveVisitChecklists>? preventiveVisitCalibrations;
List<PreventiveVisitAttachments>? preventiveVisitAttachments;
List<PreventiveVisitCalibrations>? preventiveVisitCalibrations;
List<PreventiveVisitChecklists>? preventiveVisitChecklists;
List<PreventiveVisitChecklists>? preventiveVisitKits;
List<PreventiveVisitKits>? preventiveVisitKits;
List<PreventiveVisitTimers>? preventiveVisitTimers;
List<PreventiveVisitChecklists>? preventiveVisitSuppliers;
List<PreventiveVisitSuppliers>? preventiveVisitSuppliers;
TimerModel? tbsTimer = TimerModel();
PlanPreventiveVisit(
@ -101,27 +102,27 @@ class PlanPreventiveVisit {
toDate = json['toDate'];
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
acutalDateOfVisit = json['acutalDateOfVisit'];
typeOfService = json['typeOfService'] != null ? new TypeOfService.fromJson(json['typeOfService']) : null;
visitStatus = json['visitStatus'] != null ? new VisitStatus.fromJson(json['visitStatus']) : null;
typeOfService = json['typeOfService'] != null ? new Lookup.fromJson(json['typeOfService']) : null;
visitStatus = json['visitStatus'] != null ? new Lookup.fromJson(json['visitStatus']) : null;
travelingHours = json['travelingHours'];
comments = json['comments'];
executionTimeFrame = json['executionTimeFrame'];
taskStatus = json['taskStatus'];
deviceStatus = json['deviceStatus'];
taskStatus = json['taskStatus'] != null ? new Lookup.fromJson(json['taskStatus']) : null;
deviceStatus = json['deviceStatus'] != null ? new Lookup.fromJson(json['deviceStatus']) : null;
assetAvailability = json['assetAvailability'];
safety = json['safety'];
safety = json['safety'] != null ? new Lookup.fromJson(json['safety']) : null;
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
if (json['preventiveVisitAttachments'] != null) {
preventiveVisitAttachments = <PreventiveVisitChecklists>[];
preventiveVisitAttachments = <PreventiveVisitAttachments>[];
json['preventiveVisitAttachments'].forEach((v) {
preventiveVisitAttachments!.add(PreventiveVisitChecklists.fromJson(v));
preventiveVisitAttachments!.add(new PreventiveVisitAttachments.fromJson(v));
});
}
if (json['preventiveVisitCalibrations'] != null) {
preventiveVisitCalibrations = <PreventiveVisitChecklists>[];
preventiveVisitCalibrations = <PreventiveVisitCalibrations>[];
json['preventiveVisitCalibrations'].forEach((v) {
preventiveVisitCalibrations!.add(new PreventiveVisitChecklists.fromJson(v));
preventiveVisitCalibrations!.add(new PreventiveVisitCalibrations.fromJson(v));
});
}
if (json['preventiveVisitChecklists'] != null) {
@ -131,9 +132,9 @@ class PlanPreventiveVisit {
});
}
if (json['preventiveVisitKits'] != null) {
preventiveVisitKits = <PreventiveVisitChecklists>[];
preventiveVisitKits = <PreventiveVisitKits>[];
json['preventiveVisitKits'].forEach((v) {
preventiveVisitKits!.add(new PreventiveVisitChecklists.fromJson(v));
preventiveVisitKits!.add(new PreventiveVisitKits.fromJson(v));
});
}
if (json['preventiveVisitTimers'] != null) {
@ -143,9 +144,9 @@ class PlanPreventiveVisit {
});
}
if (json['preventiveVisitSuppliers'] != null) {
preventiveVisitSuppliers = <PreventiveVisitChecklists>[];
preventiveVisitSuppliers = <PreventiveVisitSuppliers>[];
json['preventiveVisitSuppliers'].forEach((v) {
preventiveVisitSuppliers!.add(new PreventiveVisitChecklists.fromJson(v));
preventiveVisitSuppliers!.add(new PreventiveVisitSuppliers.fromJson(v));
});
}
}
@ -184,10 +185,16 @@ class PlanPreventiveVisit {
data['travelingHours'] = this.travelingHours;
data['comments'] = this.comments;
data['executionTimeFrame'] = this.executionTimeFrame;
data['taskStatus'] = this.taskStatus;
data['deviceStatus'] = this.deviceStatus;
if (this.taskStatus != null) {
data['taskStatus'] = this.taskStatus!.toJson();
}
if (this.deviceStatus != null) {
data['deviceStatus'] = this.deviceStatus!.toJson();
}
data['assetAvailability'] = this.assetAvailability;
data['safety'] = this.safety;
if (this.safety != null) {
data['safety'] = this.safety!.toJson();
}
data['engSignature'] = this.engSignature;
data['nurseSignature'] = this.nurseSignature;
if (this.preventiveVisitAttachments != null) {
@ -252,8 +259,256 @@ class PlanPreventiveVisit {
}
}
// class PlanPreventiveVisit {
// String? id;
// String? visitNo;
// Asset? asset;
// String? planNo;
// String? planName;
// String? nextPMDate;
// String? assetName;
// String? model;
// String? manufacturer;
// String? supplierName;
// String? siteName;
// String? buildingName;
// String? floorName;
// String? departmentName;
// String? roomName;
// String? fromDate;
// String? toDate;
// AssignedEmployee? assignedEmployee;
// String? acutalDateOfVisit;
// TypeOfService? typeOfService;
// VisitStatus? visitStatus;
// String? travelingHours;
// String? comments;
// int? executionTimeFrame;
// Lookup? taskStatus;
// String? deviceStatus;
// Lookup? assetAvailability;
// Lookup? safety;
// String? engSignature;
// String? nurseSignature;
// List<PreventiveVisitChecklists>? preventiveVisitAttachments;
// List<PreventiveVisitChecklists>? preventiveVisitCalibrations;
// List<PreventiveVisitChecklists>? preventiveVisitChecklists;
// List<PreventiveVisitChecklists>? preventiveVisitKits;
// List<PreventiveVisitTimers>? preventiveVisitTimers;
// List<PreventiveVisitChecklists>? preventiveVisitSuppliers;
// TimerModel? tbsTimer = TimerModel();
//
// PlanPreventiveVisit(
// {this.id,
// this.visitNo,
// this.asset,
// this.planNo,
// this.planName,
// this.nextPMDate,
// this.assetName,
// this.model,
// this.manufacturer,
// this.supplierName,
// this.siteName,
// this.buildingName,
// this.floorName,
// this.departmentName,
// this.roomName,
// this.fromDate,
// this.toDate,
// this.assignedEmployee,
// this.acutalDateOfVisit,
// this.typeOfService,
// this.visitStatus,
// this.travelingHours,
// this.comments,
// this.executionTimeFrame,
// this.taskStatus,
// this.deviceStatus,
// this.assetAvailability,
// this.safety,
// this.engSignature,
// this.nurseSignature,
// this.preventiveVisitAttachments,
// this.preventiveVisitCalibrations,
// this.preventiveVisitChecklists,
// this.preventiveVisitKits,
// this.preventiveVisitTimers,
// this.preventiveVisitSuppliers});
//
// PlanPreventiveVisit.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// visitNo = json['visitNo'];
// asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
// planNo = json['planNo'];
// planName = json['planName'];
// nextPMDate = json['nextPMDate'];
// assetName = json['assetName'];
// model = json['model'];
// manufacturer = json['manufacturer'];
// supplierName = json['supplierName'];
// siteName = json['siteName'];
// buildingName = json['buildingName'];
// floorName = json['floorName'];
// departmentName = json['departmentName'];
// roomName = json['roomName'];
// fromDate = json['fromDate'];
// toDate = json['toDate'];
// assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
// acutalDateOfVisit = json['acutalDateOfVisit'];
// typeOfService = json['typeOfService'] != null ? new TypeOfService.fromJson(json['typeOfService']) : null;
// visitStatus = json['visitStatus'] != null ? new VisitStatus.fromJson(json['visitStatus']) : null;
// travelingHours = json['travelingHours'];
// comments = json['comments'];
// executionTimeFrame = json['executionTimeFrame'];
// taskStatus = json['taskStatus'];
// deviceStatus = json['deviceStatus'];
// assetAvailability = json['assetAvailability'];
// safety = json['safety'];
// engSignature = json['engSignature'];
// nurseSignature = json['nurseSignature'];
// if (json['preventiveVisitAttachments'] != null) {
// preventiveVisitAttachments = <PreventiveVisitChecklists>[];
// json['preventiveVisitAttachments'].forEach((v) {
// preventiveVisitAttachments!.add(PreventiveVisitChecklists.fromJson(v));
// });
// }
// if (json['preventiveVisitCalibrations'] != null) {
// preventiveVisitCalibrations = <PreventiveVisitChecklists>[];
// json['preventiveVisitCalibrations'].forEach((v) {
// preventiveVisitCalibrations!.add(new PreventiveVisitChecklists.fromJson(v));
// });
// }
// if (json['preventiveVisitChecklists'] != null) {
// preventiveVisitChecklists = <PreventiveVisitChecklists>[];
// json['preventiveVisitChecklists'].forEach((v) {
// preventiveVisitChecklists!.add(new PreventiveVisitChecklists.fromJson(v));
// });
// }
// if (json['preventiveVisitKits'] != null) {
// preventiveVisitKits = <PreventiveVisitChecklists>[];
// json['preventiveVisitKits'].forEach((v) {
// preventiveVisitKits!.add(new PreventiveVisitChecklists.fromJson(v));
// });
// }
// if (json['preventiveVisitTimers'] != null) {
// preventiveVisitTimers = <PreventiveVisitTimers>[];
// json['preventiveVisitTimers'].forEach((v) {
// preventiveVisitTimers!.add(new PreventiveVisitTimers.fromJson(v));
// });
// }
// if (json['preventiveVisitSuppliers'] != null) {
// preventiveVisitSuppliers = <PreventiveVisitChecklists>[];
// json['preventiveVisitSuppliers'].forEach((v) {
// preventiveVisitSuppliers!.add(new PreventiveVisitChecklists.fromJson(v));
// });
// }
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['visitNo'] = this.visitNo;
// if (this.asset != null) {
// data['asset'] = this.asset!.toJson();
// }
// data['planNo'] = this.planNo;
// data['planName'] = this.planName;
// data['nextPMDate'] = this.nextPMDate;
// data['assetName'] = this.assetName;
// data['model'] = this.model;
// data['manufacturer'] = this.manufacturer;
// data['supplierName'] = this.supplierName;
// data['siteName'] = this.siteName;
// data['buildingName'] = this.buildingName;
// data['floorName'] = this.floorName;
// data['departmentName'] = this.departmentName;
// data['roomName'] = this.roomName;
// data['fromDate'] = this.fromDate;
// data['toDate'] = this.toDate;
// if (this.assignedEmployee != null) {
// data['assignedEmployee'] = this.assignedEmployee!.toJson();
// }
// data['acutalDateOfVisit'] = this.acutalDateOfVisit;
// if (this.typeOfService != null) {
// data['typeOfService'] = this.typeOfService!.toJson();
// }
// if (this.visitStatus != null) {
// data['visitStatus'] = this.visitStatus!.toJson();
// }
// data['travelingHours'] = this.travelingHours;
// data['comments'] = this.comments;
// data['executionTimeFrame'] = this.executionTimeFrame;
// data['taskStatus'] = this.taskStatus;
// data['deviceStatus'] = this.deviceStatus;
// data['assetAvailability'] = this.assetAvailability;
// data['safety'] = this.safety;
// data['engSignature'] = this.engSignature;
// data['nurseSignature'] = this.nurseSignature;
// if (this.preventiveVisitAttachments != null) {
// data['preventiveVisitAttachments'] = this.preventiveVisitAttachments!.map((v) => v.toJson()).toList();
// }
// if (this.preventiveVisitCalibrations != null) {
// data['preventiveVisitCalibrations'] = this.preventiveVisitCalibrations!.map((v) => v.toJson()).toList();
// }
// if (this.preventiveVisitChecklists != null) {
// data['preventiveVisitChecklists'] = this.preventiveVisitChecklists!.map((v) => v.toJson()).toList();
// }
// if (this.preventiveVisitKits != null) {
// data['preventiveVisitKits'] = this.preventiveVisitKits!.map((v) => v.toJson()).toList();
// }
// if (this.preventiveVisitTimers != null) {
// data['preventiveVisitTimers'] = this.preventiveVisitTimers!.map((v) => v.toJson()).toList();
// }
// if (this.preventiveVisitSuppliers != null) {
// data['preventiveVisitSuppliers'] = this.preventiveVisitSuppliers!.map((v) => v.toJson()).toList();
// }
// return data;
// }
//
// bool _isLocalUrl(String url) {
// if (url.isEmpty != false) return false;
// return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
// }
//
// Future<bool> validate(BuildContext context) async {
// if (visitStatus?.id == null) {
// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.status}");
// return false;
// }
// if (acutalDateOfVisit == null) {
// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.actualDate}");
// return false;
// }
// // if (expectedDate == null) {
// // await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.visitDate}");
// // return false;
// // }
// if (tbsTimer?.startAt == null) {
// await Fluttertoast.showToast(msg: "Working Hours Required");
// return false;
// }
// if (tbsTimer?.endAt == null) {
// await Fluttertoast.showToast(msg: "Please Stop The Timer");
// return false;
// }
//
// // if (externalEngineerTimer?.startAt != null && externalEngineerTimer?.endAt == null) {
// // await Fluttertoast.showToast(msg: "Please Stop External Engineer Timer");
// // return false;
// // }
//
// return true;
// }
//
// void removeEmptyObjects() {
// // if (vCalibrationTools?.isNotEmpty ?? false) vCalibrationTools!.removeWhere((element) => element.assetId == null && element.calibrationDateOfTesters == null);
// // if (vKits?.isNotEmpty ?? false) vKits!.removeWhere((element) => element.partName == null && element.partNumber == null);
// }
// }
class Asset {
int? id;
num? id;
String? assetNumber;
String? assetSerialNo;
@ -302,53 +557,53 @@ class AssignedEmployee {
}
}
class TypeOfService {
int? id;
String? name;
int? value;
TypeOfService({this.id, this.name, this.value});
TypeOfService.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
return data;
}
}
class VisitStatus {
int? id;
String? name;
int? value;
VisitStatus({this.id, this.name, this.value});
VisitStatus.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
return data;
}
}
// class Lookup {
// int? id;
// String? name;
// int? value;
//
// Lookup({this.id, this.name, this.value});
//
// Lookup.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// name = json['name'];
// value = json['value'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['name'] = this.name;
// data['value'] = this.value;
// return data;
// }
// }
// class VisitStatus {
// int? id;
// String? name;
// int? value;
//
// VisitStatus({this.id, this.name, this.value});
//
// VisitStatus.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// name = json['name'];
// value = json['value'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['name'] = this.name;
// data['value'] = this.value;
// return data;
// }
// }
class PreventiveVisitChecklists {
int? id;
String? taskStatus;
Lookup? taskStatus;
String? taskComment;
String? measuredValue;
InstructionText? instructionText;
@ -357,16 +612,16 @@ class PreventiveVisitChecklists {
PreventiveVisitChecklists.fromJson(Map<String, dynamic> json) {
id = json['id'];
taskStatus = json['taskStatus'];
taskStatus = json['taskStatus'] != null ? Lookup.fromJson(json['taskStatus']) : null;
taskComment = json['taskComment'];
measuredValue = json['measuredValue'];
instructionText = json['instructionText'] != null ? new InstructionText.fromJson(json['instructionText']) : null;
instructionText = json['instructionText'] != null ? InstructionText.fromJson(json['instructionText']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['taskStatus'] = this.taskStatus;
data['taskStatus'] = this.taskStatus?.toJson();
data['taskComment'] = this.taskComment;
data['measuredValue'] = this.measuredValue;
if (this.instructionText != null) {
@ -419,3 +674,292 @@ class PreventiveVisitTimers {
return data;
}
}
class PreventiveVisitAttachments {
int? id;
String? attachmentName;
PreventiveVisitAttachments({this.id, this.attachmentName});
PreventiveVisitAttachments.fromJson(Map<String, dynamic> json) {
id = json['id'];
attachmentName = json['attachmentName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['attachmentName'] = this.attachmentName;
return data;
}
}
class PreventiveVisitCalibrations {
num? id;
Asset? asset;
String? calibrationDateOfTesters;
PreventiveVisitCalibrations({this.id, this.asset, this.calibrationDateOfTesters});
PreventiveVisitCalibrations.fromJson(Map<String, dynamic> json) {
id = json['id'];
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
calibrationDateOfTesters = json['calibrationDateOfTesters'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
if (this.asset != null) {
data['asset'] = this.asset!.toJson();
}
data['calibrationDateOfTesters'] = this.calibrationDateOfTesters;
return data;
}
}
class PreventiveVisitSuppliers {
int? id;
Supplier? supplier;
SuppPersons? suppPerson;
String? startDateTime;
String? endDateTime;
num? workingHours;
PreventiveVisitSuppliers({this.id, this.supplier, this.suppPerson, this.startDateTime, this.endDateTime, this.workingHours});
PreventiveVisitSuppliers.fromJson(Map<String, dynamic> json) {
id = json['id'];
supplier = json['supplier'] != null ? new Supplier.fromJson(json['supplier']) : null;
suppPerson = json['suppPerson'] != null ? new SuppPersons.fromJson(json['suppPerson']) : null;
startDateTime = json['startDateTime'];
endDateTime = json['endDateTime'];
workingHours = json['workingHours'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
if (this.supplier != null) {
data['supplier'] = this.supplier!.toJson();
}
if (this.suppPerson != null) {
data['suppPerson'] = this.suppPerson!.toJson();
}
data['startDateTime'] = this.startDateTime;
data['endDateTime'] = this.endDateTime;
data['workingHours'] = this.workingHours;
return data;
}
}
class Supplier {
int? id;
String? suppliername;
String? name;
String? website;
String? email;
String? code;
int? suppNo;
String? suppStatusId;
String? cityId;
String? person;
String? comment;
String? zipcode;
String? contact;
List<String>? telephones;
List<String>? faxes;
List<String>? addresses;
List<String>? attachments;
List<SuppPersons>? suppPersons;
List<String>? suppTCodes;
Supplier(
{this.id,
this.suppliername,
this.name,
this.website,
this.email,
this.code,
this.suppNo,
this.suppStatusId,
this.cityId,
this.person,
this.comment,
this.zipcode,
this.contact,
this.telephones,
this.faxes,
this.addresses,
this.attachments,
this.suppPersons,
this.suppTCodes});
Supplier.fromJson(Map<String, dynamic> json) {
id = json['id'];
suppliername = json['suppliername'];
name = json['name'];
website = json['website'];
email = json['email'];
code = json['code'];
suppNo = json['suppNo'];
suppStatusId = json['suppStatusId'];
cityId = json['cityId'];
person = json['person'];
comment = json['comment'];
zipcode = json['zipcode'];
contact = json['contact'];
if (json['telephones'] != null) {
telephones = <String>[];
json['telephones'].forEach((v) {
telephones!.add(v);
});
}
if (json['faxes'] != null) {
faxes = <String>[];
json['faxes'].forEach((v) {
faxes!.add(v);
});
}
if (json['addresses'] != null) {
addresses = <String>[];
json['addresses'].forEach((v) {
addresses!.add(v);
});
}
if (json['attachments'] != null) {
attachments = <String>[];
json['attachments'].forEach((v) {
attachments!.add(v);
});
}
if (json['suppPersons'] != null) {
suppPersons = <SuppPersons>[];
json['suppPersons'].forEach((v) {
suppPersons!.add(new SuppPersons.fromJson(v));
});
}
if (json['suppTCodes'] != null) {
suppTCodes = <String>[];
json['suppTCodes'].forEach((v) {
suppTCodes!.add(v);
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['suppliername'] = this.suppliername;
data['name'] = this.name;
data['website'] = this.website;
data['email'] = this.email;
data['code'] = this.code;
data['suppNo'] = this.suppNo;
data['suppStatusId'] = this.suppStatusId;
data['cityId'] = this.cityId;
data['person'] = this.person;
data['comment'] = this.comment;
data['zipcode'] = this.zipcode;
data['contact'] = this.contact;
if (this.telephones != null) {
data['telephones'] = this.telephones!.map((v) => v).toList();
}
if (this.faxes != null) {
data['faxes'] = this.faxes!.map((v) => v).toList();
}
if (this.addresses != null) {
data['addresses'] = this.addresses!.map((v) => v).toList();
}
if (this.attachments != null) {
data['attachments'] = this.attachments!.map((v) => v).toList();
}
if (this.suppPersons != null) {
data['suppPersons'] = this.suppPersons!.map((v) => v.toJson()).toList();
}
if (this.suppTCodes != null) {
data['suppTCodes'] = this.suppTCodes!.map((v) => v).toList();
}
return data;
}
}
// class SuppPersons {
// int? id;
// int? supplierId;
// String? personName;
// int? personRoleId;
// String? contact;
// String? externalEngCode;
// String? email;
//
// SuppPersons({this.id, this.supplierId, this.personName, this.personRoleId, this.contact, this.externalEngCode, this.email});
//
// SuppPersons.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// supplierId = json['supplierId'];
// personName = json['personName'];
// personRoleId = json['personRoleId'];
// contact = json['contact'];
// externalEngCode = json['externalEngCode'];
// email = json['email'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['supplierId'] = this.supplierId;
// data['personName'] = this.personName;
// data['personRoleId'] = this.personRoleId;
// data['contact'] = this.contact;
// data['externalEngCode'] = this.externalEngCode;
// data['email'] = this.email;
// return data;
// }
// }
class PreventiveVisitKits {
int? id;
PartCatalogItem? partCatalogItem;
PreventiveVisitKits({this.id, this.partCatalogItem});
PreventiveVisitKits.fromJson(Map<String, dynamic> json) {
id = json['id'];
partCatalogItem = json['partCatalogItem'] != null ? new PartCatalogItem.fromJson(json['partCatalogItem']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
if (this.partCatalogItem != null) {
data['partCatalogItem'] = this.partCatalogItem!.toJson();
}
return data;
}
}
class PartCatalogItem {
num? id;
String? partName;
String? partNumber;
String? oracleCode;
PartCatalogItem({this.id, this.partName, this.partNumber, this.oracleCode});
PartCatalogItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
partName = json['partName'];
partNumber = json['partNumber'];
oracleCode = json['oracleCode'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['partName'] = this.partName;
data['partNumber'] = this.partNumber;
data['oracleCode'] = this.oracleCode;
return data;
}
}

@ -50,7 +50,7 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
Widget build(BuildContext context) {
userProvider ??= Provider.of<UserProvider>(context, listen: false);
ppmProvider ??= Provider.of<PpmProvider>(context, listen: false);
ppmProvider!.getPlanPreventiveVisitById(widget.request.id!);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
body: SafeArea(
@ -61,7 +61,6 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
return const ALoading();
} else if (snap.hasData) {
PlanPreventiveVisit planPreventiveVisit = snap.data as PlanPreventiveVisit;
return Column(children: [
SingleChildScrollView(
child: Column(
@ -109,7 +108,7 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
onPressed: () async {
//TODO remove after testing..
// await Navigator.of(context).push(MaterialPageRoute(builder: (_) => RecurrentWorkOrderView( request: widget.request)));
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request)));
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request)));
// setState(() {});
},
label: context.translation.updateRequest,

@ -8,7 +8,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/ppm/ppm_calibration_tools.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/widgets/pentry/calibration_tool_asset_picker.dart';
@ -16,9 +16,9 @@ import '../../../../../new_views/app_style/app_color.dart';
import '../../../../widgets/date_and_time/date_picker.dart';
class PpmCalibrationToolsForm extends StatefulWidget {
final List<PpmCalibrationTools>? models;
List<PreventiveVisitCalibrations>? models;
const PpmCalibrationToolsForm({Key? key, this.models = const <PpmCalibrationTools>[]}) : super(key: key);
PpmCalibrationToolsForm({Key? key, this.models = const <PreventiveVisitCalibrations>[]}) : super(key: key);
@override
State<PpmCalibrationToolsForm> createState() => _PpmCalibrationToolsFormState();
@ -43,7 +43,7 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.assetId == null) {
if (widget.models!.last.asset?.id == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.assetNumber}");
return;
}
@ -52,12 +52,12 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
return;
}
}
widget.models!.add(PpmCalibrationTools(id: 0));
widget.models!.add(PreventiveVisitCalibrations(id: 0));
setState(() {});
},
);
}
final PpmCalibrationTools model = widget.models![index];
PreventiveVisitCalibrations model = widget.models![index];
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
@ -80,21 +80,19 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
),
16.height,
CalibrationToolAssetPicker(
initialValue: model.assetId == null ? null : Lookup(id: model.assetId?.toInt(), name: model.assetNumber ?? ""),
initialValue: model.asset?.id == null ? null : Lookup(id: model.asset?.id?.toInt(), name: model.asset?.assetNumber ?? ""),
hospitalId: userProvider.user!.clientId,
onPick: (asset) {
model.assetNumber = asset.assetNumber;
model.assetId = asset.id;
model.assetSerialNo = asset.assetSerialNo;
model.assetName = asset.modelDefinition?.assetName;
model.asset = Asset(id: asset.id, assetNumber: asset.assetNumber, assetSerialNo: asset.assetSerialNo);
setState(() {});
},
),
12.height,
if (model.assetNumber != null) Text("Asset Number: ${model.assetNumber?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.assetName != null) Text("Asset Name: ${model.assetName?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.assetSerialNo != null)
Text("Asset Serial No: ${model.assetSerialNo?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.asset?.assetNumber != null)
Text("Asset Number: ${model.asset?.assetNumber?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
// if (model.assetName != null) Text("Asset Name: ${model.assetName?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.asset?.assetSerialNo != null)
Text("Asset Serial No: ${model.asset?.assetSerialNo?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
12.height,
ADatePicker(
label: context.translation.calibrationDate,

@ -35,10 +35,11 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
List<PreventiveVisitChecklists>? list = widget.checkList ?? [];
return (list.isEmpty)
? const NoDataFound().center
: ListView.builder(
: ListView.separated(
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
itemCount: list.length,
shrinkWrap: true,
separatorBuilder: (cxt, index) => 12.height,
itemBuilder: (context, index) {
return Column(
mainAxisSize: MainAxisSize.min,
@ -51,7 +52,7 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
AppTextFormField(
labelText: "Task".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
// initialValue: (list[index].instructionText == null ? (list[index].task ?? "") : (list[index].instructionText!.text ?? "")),
initialValue: list[index].instructionText?.text ?? "",
enable: false,
showShadow: false,
enableColor: AppColor.neutral100,
@ -62,19 +63,18 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
},
),
8.height,
// SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
// context: context,
// showShadow: false,
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
// initialValue: list[index].taskStatusId == null ? null : Lookup(id: list[index].taskStatusId!.toInt(), name: list[index].taskStatusName),
// title: context.translation.taskStatus,
// onSelect: (value) {
// if (value != null) {
// list[index].taskStatusId = value.id;
// list[index].taskStatusName = value.name;
// }
// },
// ),
SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
context: context,
showShadow: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
initialValue: list[index].taskStatus?.id == null ? null : Lookup(id: list[index].taskStatus?.id?.toInt(), name: list[index].taskStatus?.name),
title: context.translation.taskStatus,
onSelect: (value) {
if (value != null) {
list[index].taskStatus = Lookup(id: value.id, name: value.name, value: value.value);
}
},
),
8.height,
AppTextFormField(
labelText: context.translation.measuredValue,

@ -5,17 +5,17 @@ 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/ppm/ppm_kit.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import '../../../../../new_views/app_style/app_color.dart';
import '../../../../../new_views/common_widgets/app_filled_button.dart';
import '../../../../widgets/parts/auto_complete_parts_field.dart';
class PpmPMKitsForm extends StatefulWidget {
final List<PpmKits>? models;
final List<PreventiveVisitKits>? models;
final num? assetId;
const PpmPMKitsForm({Key? key, this.models = const <PpmKits>[], this.assetId}) : super(key: key);
const PpmPMKitsForm({Key? key, this.models = const <PreventiveVisitKits>[], this.assetId}) : super(key: key);
@override
State<PpmPMKitsForm> createState() => _PpmPMKitsFormState();
@ -39,16 +39,16 @@ class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.partNumber == null) {
if (widget.models!.last.partCatalogItem?.partNumber == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partNumber}");
return;
}
if (widget.models!.last.partName == null) {
if (widget.models!.last.partCatalogItem?.partName == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partName}");
return;
}
}
widget.models!.add(PpmKits(id: 0));
widget.models!.add(PreventiveVisitKits(id: 0));
setState(() {});
},
);
@ -80,11 +80,9 @@ class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
assetId: widget.assetId,
clearAfterPick: false,
byName: true,
initialValue: model.partName ?? "",
initialValue: model.partCatalogItem?.partName ?? "",
onPick: (part) {
model.partCatalogItemId = part.sparePart?.id;
model.partNumber = part.sparePart?.partNo;
model.partName = part.sparePart?.partName;
model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode);
setState(() {});
},
),
@ -93,11 +91,11 @@ class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
assetId: widget.assetId,
clearAfterPick: false,
byName: false,
initialValue: model.partNumber ?? "",
initialValue: model.partCatalogItem?.partNumber ?? "",
onPick: (part) {
model.partCatalogItemId = part.sparePart?.id;
model.partNumber = part.sparePart?.partNo;
model.partName = part.sparePart?.partName;
model.partCatalogItem?.id = part.sparePart?.id;
model.partCatalogItem?.partNumber = part.sparePart?.partNo;
model.partCatalogItem?.partName = part.sparePart?.partName;
setState(() {});
},
),

@ -123,8 +123,8 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
controller: _tabController,
children: [
PpmExternalDetailsForm(models: []),
PpmCalibrationToolsForm(models: []),
PpmPMKitsForm(),
PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations),
PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits,assetId: _planPreventiveVisit.asset?.id),
// PpmExternalDetailsForm(models: _ppm.vCalibrationTools),
// PpmCalibrationToolsForm(models: _ppm.vCalibrationTools),

@ -1,29 +1,21 @@
import 'dart:convert';
import 'dart:io';
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/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm_attachment.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/providers/ppm_asset_availability_provider.dart';
import 'package:test_sa/providers/ppm_electrical_safety_provider.dart';
import 'package:test_sa/providers/ppm_service_provider.dart';
import 'package:test_sa/providers/ppm_task_status_provider.dart';
import 'package:test_sa/providers/work_order/vendor_provider.dart';
import '../../../../../models/lookup.dart';
import '../../../../../new_views/common_widgets/app_text_form_field.dart';
import '../../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../../../providers/ppm_device_status_provider.dart';
import '../../../../../providers/ppm_visit_status_provider.dart';
import '../../../../widgets/date_and_time/date_picker.dart';
import '../../../../widgets/e_signature/e_signature.dart';
import '../../../../widgets/images/multi_image_picker.dart';
import '../../../../widgets/timer/app_timer.dart';
class WoInfoForm extends StatefulWidget {
@ -138,7 +130,9 @@ class _WoInfoFormState extends State<WoInfoForm> {
8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context,
initialValue: widget.planPreventiveVisit.assetAvailability == null ? null : Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id),
initialValue: widget.planPreventiveVisit.assetAvailability == null
? null
: Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id),
title: "Asset Availability",
onSelect: (value) {
if (value != null) {
@ -275,7 +269,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.number,
onChange: (value) {
widget.planPreventiveVisit.travelingHours = value;
widget.planPreventiveVisit.travelingHours = int.parse(value);
},
),
8.height,

Loading…
Cancel
Save