ppm issues fixed & code formatting
parent
df9fa59f1b
commit
7200efcbca
@ -1,122 +1,122 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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/user.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
import 'package:test_sa/models/visits/visits_group.dart';
|
||||
import 'package:test_sa/models/visits/visits_search.dart';
|
||||
|
||||
class PreventiveMaintenanceVisitsProvider extends ChangeNotifier {
|
||||
// number of items call in each request
|
||||
final pageItemNumber = 10;
|
||||
|
||||
//reset provider data
|
||||
void reset() {
|
||||
visits = null;
|
||||
nextPage = true;
|
||||
stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int stateCode;
|
||||
|
||||
// true if there is next page in product list and false if not
|
||||
bool nextPage = true;
|
||||
|
||||
// list of user requests
|
||||
List<Visit> visits;
|
||||
|
||||
// when requests in-process _loading = true
|
||||
// done _loading = true
|
||||
// failed _loading = false
|
||||
bool isLoading;
|
||||
|
||||
VisitsSearch visitsSearch = VisitsSearch();
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getVisits({
|
||||
@required String host,
|
||||
@required User user,
|
||||
// VisitsSearch visitsSearch,
|
||||
}) async {
|
||||
if (isLoading == true) return -2;
|
||||
isLoading = true;
|
||||
Response response;
|
||||
//userId = 397.toString(); // testing id to view data
|
||||
try {
|
||||
response = await get(
|
||||
Uri.parse(
|
||||
"${host + URLs.getPreventiveMaintenanceVisits}?uid=${user.id}&token=${user.token}&page=${(visits?.length ?? 0) ~/ pageItemNumber}${visitsSearch?.toMap()}",
|
||||
),
|
||||
headers: {"Content-Type": "application/json; charset=utf-8"});
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List requestsListJson = json.decode(utf8.decode(response.bodyBytes));
|
||||
List<Visit> _visits = requestsListJson.map((request) => Visit.fromJson(request)).toList();
|
||||
visits ??= [];
|
||||
visits.addAll(_visits);
|
||||
if (_visits.length == pageItemNumber) {
|
||||
nextPage = true;
|
||||
} else {
|
||||
nextPage = false;
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> updateGroupOfVisits({
|
||||
@required String host,
|
||||
@required User user,
|
||||
VisitsGroup group,
|
||||
}) async {
|
||||
Response response;
|
||||
Map<String, String> body = group.toJson();
|
||||
// body["token"] = user.token ?? "";
|
||||
// body["uid"] = user.id;
|
||||
//userId = 397.toString(); // testing id to view data
|
||||
try {
|
||||
response = await ApiManager.instance.put(URLs.updatePreventiveMaintenanceVisits, body: body);
|
||||
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
// group.visits.forEach((visit) {
|
||||
// visit.status = group.status;
|
||||
// visit.actualDate = group.date.toString().split(" ").first;
|
||||
// });
|
||||
group.visits.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// 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/user.dart';
|
||||
// import 'package:test_sa/models/visits/ppm.dart';
|
||||
// import 'package:test_sa/models/visits/ppm_search.dart';
|
||||
// import 'package:test_sa/models/visits/visits_group.dart';
|
||||
//
|
||||
// class PreventiveMaintenanceVisitsProvider extends ChangeNotifier {
|
||||
// // number of items call in each request
|
||||
// final pageItemNumber = 10;
|
||||
//
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// visits = null;
|
||||
// nextPage = true;
|
||||
// stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int stateCode;
|
||||
//
|
||||
// // true if there is next page in product list and false if not
|
||||
// bool nextPage = true;
|
||||
//
|
||||
// // list of user requests
|
||||
// List<Visit> visits;
|
||||
//
|
||||
// // when requests in-process _loading = true
|
||||
// // done _loading = true
|
||||
// // failed _loading = false
|
||||
// bool isLoading;
|
||||
//
|
||||
// VisitsSearch visitsSearch = VisitsSearch();
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getVisits({
|
||||
// @required String host,
|
||||
// @required User user,
|
||||
// // VisitsSearch visitsSearch,
|
||||
// }) async {
|
||||
// if (isLoading == true) return -2;
|
||||
// isLoading = true;
|
||||
// Response response;
|
||||
// //userId = 397.toString(); // testing id to view data
|
||||
// try {
|
||||
// response = await get(
|
||||
// Uri.parse(
|
||||
// "${host + URLs.getPreventiveMaintenanceVisits}?uid=${user.id}&token=${user.token}&page=${(visits?.length ?? 0) ~/ pageItemNumber}${visitsSearch?.toMap()}",
|
||||
// ),
|
||||
// headers: {"Content-Type": "application/json; charset=utf-8"});
|
||||
// } catch (error) {
|
||||
// isLoading = false;
|
||||
// stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List requestsListJson = json.decode(utf8.decode(response.bodyBytes));
|
||||
// List<Visit> _visits = requestsListJson.map((request) => Visit.fromJson(request)).toList();
|
||||
// visits ??= [];
|
||||
// visits.addAll(_visits);
|
||||
// if (_visits.length == pageItemNumber) {
|
||||
// nextPage = true;
|
||||
// } else {
|
||||
// nextPage = false;
|
||||
// }
|
||||
// }
|
||||
// isLoading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> updateGroupOfVisits({
|
||||
// @required String host,
|
||||
// @required User user,
|
||||
// VisitsGroup group,
|
||||
// }) async {
|
||||
// Response response;
|
||||
// Map<String, String> body = group.toJson();
|
||||
// // body["token"] = user.token ?? "";
|
||||
// // body["uid"] = user.id;
|
||||
// //userId = 397.toString(); // testing id to view data
|
||||
// try {
|
||||
// response = await ApiManager.instance.put(URLs.updatePreventiveMaintenanceVisits, body: body);
|
||||
//
|
||||
// stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// // group.visits.forEach((visit) {
|
||||
// // visit.status = group.status;
|
||||
// // visit.actualDate = group.date.toString().split(" ").first;
|
||||
// // });
|
||||
// group.ppms.clear();
|
||||
// notifyListeners();
|
||||
// }
|
||||
//
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// isLoading = false;
|
||||
// stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class CalibrationTool {
|
||||
int id;
|
||||
Lookup assetsNumber;
|
||||
DateTime dataOfTesting;
|
||||
|
||||
CalibrationTool({
|
||||
this.id,
|
||||
this.assetsNumber,
|
||||
this.dataOfTesting,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap(int visitId) {
|
||||
return {
|
||||
"id": id ?? 0,
|
||||
"visitId": visitId,
|
||||
if (assetsNumber != null) 'assetId': (assetsNumber?.id).toString(),
|
||||
if (dataOfTesting != null) 'calibrationDateOfTesters': dataOfTesting.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory CalibrationTool.fromMap(Map<String, dynamic> map) {
|
||||
return CalibrationTool(
|
||||
assetsNumber: Lookup(id: map["assetId"], name: map['assetNumber']),
|
||||
dataOfTesting: DateTime.tryParse(map['calibrationDateOfTesters'] ?? ""),
|
||||
);
|
||||
}
|
||||
|
||||
CalibrationTool copyWith({
|
||||
Lookup assetsNumber,
|
||||
DateTime dataOfTesting,
|
||||
}) {
|
||||
return CalibrationTool(
|
||||
id: id,
|
||||
assetsNumber: assetsNumber ?? this.assetsNumber,
|
||||
dataOfTesting: dataOfTesting ?? this.dataOfTesting,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class Contact {
|
||||
Lookup title;
|
||||
Lookup contactPerson;
|
||||
String job;
|
||||
String email;
|
||||
String telephone;
|
||||
String landLine;
|
||||
|
||||
Contact({this.title, this.contactPerson, this.job, this.email, this.telephone, this.landLine});
|
||||
|
||||
Map<String, String> toMap() {
|
||||
return {
|
||||
if (title != null) 'title': title.id.toString(),
|
||||
if (contactPerson != null) 'contactPerson': contactPerson.id.toString(),
|
||||
if (job != null) 'job': job,
|
||||
if (email != null) 'email': email,
|
||||
if (telephone != null) 'telephone': telephone,
|
||||
if (landLine != null) 'landLine': landLine,
|
||||
};
|
||||
}
|
||||
|
||||
factory Contact.fromMap(Map<String, dynamic> map) {
|
||||
return Contact(
|
||||
title: map['title'] as Lookup,
|
||||
contactPerson: map['contactPerson'] as Lookup,
|
||||
job: map['job'] as String,
|
||||
email: map['email'] as String,
|
||||
telephone: map['telephone'] as String,
|
||||
landLine: map['landLine'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class ContactTitle extends Lookup {
|
||||
ContactTitle({int id, String label}) : super(id: id, name: label);
|
||||
|
||||
factory ContactTitle.fromMap(Map<String, dynamic> parsedJson) {
|
||||
return ContactTitle(
|
||||
label: parsedJson["value"],
|
||||
id: parsedJson["id"],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class ContactTitle extends Lookup {
|
||||
ContactTitle({int id, String label}) : super(id: id, name: label);
|
||||
|
||||
factory ContactTitle.fromMap(Map<String, dynamic> parsedJson) {
|
||||
return ContactTitle(
|
||||
label: parsedJson["value"],
|
||||
id: parsedJson["id"],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,203 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/pantry/calibration_tools.dart';
|
||||
import 'package:test_sa/models/pantry/pm_kit.dart';
|
||||
import 'package:test_sa/models/pantry/ppm_check_list.dart';
|
||||
import 'package:test_sa/models/timer_model.dart';
|
||||
|
||||
class Pentry {
|
||||
Lookup ppmVisitStatus;
|
||||
Lookup status;
|
||||
TimerModel timer;
|
||||
DateTime actualVisitDate;
|
||||
DateTime expectedVisitDate;
|
||||
String travelingHours;
|
||||
String image;
|
||||
List<File> files = [];
|
||||
|
||||
// List<Contact> contacts;
|
||||
List<PPMCheckList> ppmCheckLists;
|
||||
List<CalibrationTool> calibrationTools;
|
||||
List<PMKit> pmKits;
|
||||
String signatureNurse;
|
||||
String signatureEngineer;
|
||||
Uint8List localNurseSignature;
|
||||
Uint8List localEngineerSignature;
|
||||
|
||||
Pentry(
|
||||
{this.travelingHours,
|
||||
this.timer,
|
||||
this.status,
|
||||
this.ppmVisitStatus,
|
||||
this.actualVisitDate,
|
||||
this.expectedVisitDate,
|
||||
this.image,
|
||||
this.files,
|
||||
// this.contacts,
|
||||
this.ppmCheckLists,
|
||||
this.calibrationTools,
|
||||
this.pmKits,
|
||||
this.signatureNurse,
|
||||
this.signatureEngineer,
|
||||
this.localNurseSignature,
|
||||
this.localEngineerSignature});
|
||||
|
||||
Future<bool> validate() async {
|
||||
if (ppmVisitStatus == null) {
|
||||
await Fluttertoast.showToast(msg: "PPM Visit Status is Required");
|
||||
return false;
|
||||
}
|
||||
if (actualVisitDate == null) {
|
||||
await Fluttertoast.showToast(msg: "Actual visit date is Required");
|
||||
return false;
|
||||
}
|
||||
if (expectedVisitDate == null) {
|
||||
await Fluttertoast.showToast(msg: "Expected visit date is Required");
|
||||
return false;
|
||||
}
|
||||
if (timer?.startAt == null) {
|
||||
await Fluttertoast.showToast(msg: "Working Hours Required");
|
||||
return false;
|
||||
}
|
||||
if (timer?.endAt == null) {
|
||||
await Fluttertoast.showToast(msg: "Please Stop The Timer");
|
||||
return false;
|
||||
}
|
||||
if (status?.id == null) {
|
||||
await Fluttertoast.showToast(msg: "Device Status is Required");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap(int visitId) {
|
||||
Map<String, dynamic> map = {};
|
||||
map["visitStatusId"] = ppmVisitStatus?.id;
|
||||
if (status != null) map["deviceStatusId"] = status?.id;
|
||||
if (travelingHours != null) map["travelingHours"] = travelingHours;
|
||||
//if(imageFile != null) map["file_attachement"] = base64Encode(imageFile.readAsBytesSync());
|
||||
map["actualDate"] = actualVisitDate.toIso8601String();
|
||||
map["expectedDate"] = expectedVisitDate.toIso8601String();
|
||||
if (timer != null) {
|
||||
map["startDate"] = timer.startAt.toIso8601String();
|
||||
map["endDate"] = timer.endAt?.toIso8601String() ?? DateTime.now().toIso8601String();
|
||||
map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
|
||||
}
|
||||
if (files?.isNotEmpty ?? false) {
|
||||
map["vAttachments"] = files.map((file) => {"attachmentName": _isLocalUrl(file.path) ? (file.path.split("/").last + "|" + base64Encode(file.readAsBytesSync())) : file.path}).toList();
|
||||
}
|
||||
map["travelingHours"] = travelingHours;
|
||||
// if(contacts?.isNotEmpty == true) {
|
||||
// for(int i = 0;i<contacts.length;i++){
|
||||
// contacts[i].toMap().forEach((key, value) {
|
||||
// body["contacts[$i].$key"] = value;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
map["vChecklists"] = ppmCheckLists.map((e) => e.toMap(visitId)).toList();
|
||||
map["vCalibrationTools"] = calibrationTools.map((e) => e.toMap(visitId)).toList();
|
||||
map["vKits"] = pmKits.map((e) => e.toMap(visitId)).toList();
|
||||
map["nurseSignature"] = signatureNurse; //"${DateTime.now().toIso8601String()}.png|$signatureNurse";
|
||||
map["engSignature"] = signatureEngineer; //"${DateTime.now().toIso8601String()}.png|$signatureEngineer";
|
||||
return map;
|
||||
}
|
||||
|
||||
bool _isLocalUrl(String url) {
|
||||
if (url?.isEmpty != false) return false;
|
||||
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
|
||||
}
|
||||
|
||||
factory Pentry.fromMap(Map<String, dynamic> map) {
|
||||
// List<Contact> contacts = [];
|
||||
// if(map['contacts'] != null){
|
||||
// contacts =(map['contacts'] as List<dynamic>)
|
||||
// .map((e) => Contact.fromMap(e as Map<String, dynamic>))
|
||||
// .toList();
|
||||
// }
|
||||
|
||||
List<PMKit> pmKits = [];
|
||||
if (map['vKits'] != null) {
|
||||
pmKits = (map['vKits'] as List<dynamic>).map((e) => PMKit.fromMap(e as Map<String, dynamic>)).toList();
|
||||
}
|
||||
List<String> files = [];
|
||||
if (map["vAttachments"] != null) if (map["vAttachments"] is List) {
|
||||
List list = map["vAttachments"];
|
||||
list.removeWhere((element) => (element["attachmentURL"]?.toString() ?? "").isEmpty);
|
||||
files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList();
|
||||
}
|
||||
List<PPMCheckList> ppmCheckLists = [];
|
||||
if (map['vChecklists'] != null) {
|
||||
ppmCheckLists = (map['vChecklists'] as List<dynamic>).map((e) => PPMCheckList.fromMap(e as Map<String, dynamic>)).toList();
|
||||
}
|
||||
|
||||
List<CalibrationTool> calibrationTools = [];
|
||||
if (map['vCalibrationTools'] != null) {
|
||||
calibrationTools = (map['vCalibrationTools'] as List<dynamic>).map((e) => CalibrationTool.fromMap(e as Map<String, dynamic>)).toList();
|
||||
}
|
||||
return Pentry(
|
||||
status: Lookup(id: map["deviceStatusId"], name: map["deviceStatusName"]),
|
||||
ppmVisitStatus: Lookup(id: map["visitStatusId"], name: map["visitStatusName"]),
|
||||
actualVisitDate: DateTime.tryParse(map["actualDate"] ?? ""),
|
||||
expectedVisitDate: DateTime.tryParse(map["expectedDate"] ?? ""),
|
||||
travelingHours: map["travelingHours"],
|
||||
timer: TimerModel(
|
||||
startAt: DateTime.tryParse(map["startDate"] ?? ""),
|
||||
endAt: DateTime.tryParse(map["endDate"] ?? ""),
|
||||
durationInSecond: (int.tryParse(map["workingHours"] ?? "") ?? 0) * 60 * 60,
|
||||
),
|
||||
// contacts: contacts,
|
||||
ppmCheckLists: ppmCheckLists,
|
||||
calibrationTools: calibrationTools,
|
||||
pmKits: pmKits,
|
||||
files: files?.map((e) {
|
||||
return File(e);
|
||||
})?.toList() ??
|
||||
[],
|
||||
signatureNurse: URLs.getFileUrl(map["nurseSignature"]),
|
||||
signatureEngineer: URLs.getFileUrl(map["engSignature"]),
|
||||
);
|
||||
}
|
||||
|
||||
Pentry copyWith({
|
||||
Lookup ppmVisitStatus,
|
||||
Lookup status,
|
||||
TimerModel timer,
|
||||
DateTime actualVisitDate,
|
||||
DateTime expectedVisitDate,
|
||||
String travelingHours,
|
||||
String image,
|
||||
List<File> files,
|
||||
List<PPMCheckList> ppmCheckLists,
|
||||
List<CalibrationTool> calibrationTools,
|
||||
List<PMKit> pmKits,
|
||||
String signatureNurse,
|
||||
String signatureEngineer,
|
||||
}) {
|
||||
return Pentry(
|
||||
ppmVisitStatus: ppmVisitStatus ?? this.ppmVisitStatus,
|
||||
status: status ?? this.status,
|
||||
timer: timer ?? this.timer,
|
||||
actualVisitDate: actualVisitDate ?? this.actualVisitDate,
|
||||
expectedVisitDate: expectedVisitDate ?? this.expectedVisitDate,
|
||||
travelingHours: travelingHours ?? this.travelingHours,
|
||||
image: image ?? this.image,
|
||||
files: files ?? this.files,
|
||||
ppmCheckLists: ppmCheckLists ?? this.ppmCheckLists?.map((e) => e.copyWith())?.toList(),
|
||||
calibrationTools: calibrationTools ?? this.calibrationTools?.map((e) => e.copyWith())?.toList(),
|
||||
pmKits: pmKits ?? this.pmKits.map((e) => e.copyWith()).toList(),
|
||||
signatureNurse: signatureNurse ?? this.signatureNurse,
|
||||
signatureEngineer: signatureEngineer ?? this.signatureEngineer);
|
||||
}
|
||||
|
||||
void clearEmptyObjects() {
|
||||
ppmCheckLists.removeWhere((element) => (element?.title?.isEmpty ?? true) && (element?.comment?.isEmpty ?? true) && (element?.measuredValue?.isEmpty ?? true) && element.status == null);
|
||||
calibrationTools.removeWhere((element) => (element?.assetsNumber == null) && (element?.dataOfTesting == null));
|
||||
pmKits.removeWhere((element) => (element?.itemCode == null));
|
||||
}
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class PMKit {
|
||||
int id;
|
||||
Lookup itemCode;
|
||||
String itemName;
|
||||
String preparationTimeFrame;
|
||||
String kitFrequencyDemand;
|
||||
String availability;
|
||||
String quantityNeeded;
|
||||
String quantityReserved;
|
||||
|
||||
PMKit({this.id, this.itemCode, this.itemName, this.preparationTimeFrame, this.kitFrequencyDemand, this.availability, this.quantityNeeded, this.quantityReserved});
|
||||
|
||||
Map<String, dynamic> toMap(int visitId) {
|
||||
return {
|
||||
"id": id ?? 0,
|
||||
"visitId": visitId,
|
||||
if (itemCode != null) 'partCatalogItemId': (itemCode?.id),
|
||||
if (itemName != null) 'itemName': itemName,
|
||||
// if(preparationTimeFrame != null) 'preparationTimeFrame': preparationTimeFrame,
|
||||
// if(kitFrequencyDemand != null) 'kitFrequencyDemand': kitFrequencyDemand,
|
||||
// if(availability != null) 'availability': availability,
|
||||
if (quantityNeeded != null) 'quantityNeeded': quantityNeeded,
|
||||
// if(quantityReserved != null) 'quantityReserved': quantityReserved,
|
||||
};
|
||||
}
|
||||
|
||||
factory PMKit.fromMap(Map<String, dynamic> map) {
|
||||
return PMKit(
|
||||
id: map['id'],
|
||||
itemCode: Lookup(id: map['partCatalogItemId'], name: map["partNumber"]),
|
||||
itemName: map['itemName'] as String,
|
||||
preparationTimeFrame: map['preparationTimeFrame'] as String,
|
||||
kitFrequencyDemand: map['kitFrequencyDemand'] as String,
|
||||
availability: map['availability'] as String,
|
||||
quantityNeeded: map['quantityNeeded'] as String,
|
||||
quantityReserved: map['quantityReserved'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
PMKit copyWith({
|
||||
int id,
|
||||
Lookup itemCode,
|
||||
String itemName,
|
||||
String preparationTimeFrame,
|
||||
String kitFrequencyDemand,
|
||||
String availability,
|
||||
String quantityNeeded,
|
||||
String quantityReserved,
|
||||
}) {
|
||||
return PMKit(
|
||||
id: id ?? this.id,
|
||||
itemCode: itemCode ?? this.itemCode,
|
||||
itemName: itemName ?? this.itemName,
|
||||
preparationTimeFrame: preparationTimeFrame ?? this.preparationTimeFrame,
|
||||
kitFrequencyDemand: kitFrequencyDemand ?? this.kitFrequencyDemand,
|
||||
availability: availability ?? this.availability,
|
||||
quantityNeeded: quantityNeeded ?? this.quantityNeeded,
|
||||
quantityReserved: quantityReserved ?? this.quantityReserved,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class PPMCheckList {
|
||||
int id;
|
||||
Lookup status;
|
||||
String title;
|
||||
String comment;
|
||||
String measuredValue;
|
||||
|
||||
PPMCheckList({
|
||||
this.id,
|
||||
this.title,
|
||||
this.status,
|
||||
this.comment,
|
||||
this.measuredValue,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap(int visitId) {
|
||||
return {
|
||||
'id': id ?? 0,
|
||||
"visitId": visitId,
|
||||
if (status != null) 'taskStatusId': status?.id,
|
||||
if (title != null) 'task': title,
|
||||
if (comment != null) 'taskComment': comment,
|
||||
if (measuredValue != null) 'measuredValue': measuredValue,
|
||||
};
|
||||
}
|
||||
|
||||
factory PPMCheckList.fromMap(Map<String, dynamic> map) {
|
||||
return PPMCheckList(
|
||||
id: map['id'] as int,
|
||||
status: Lookup(id: map["taskStatusId"], name: map["taskStatusName"]),
|
||||
title: map['task'] as String,
|
||||
comment: map['taskComment'] as String,
|
||||
measuredValue: map['measuredValue'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
PPMCheckList copyWith({
|
||||
int id,
|
||||
Lookup status,
|
||||
String title,
|
||||
String comment,
|
||||
String measuredValue,
|
||||
}) {
|
||||
return PPMCheckList(
|
||||
id: id ?? this.id,
|
||||
status: status ?? this.status,
|
||||
title: title ?? this.title,
|
||||
comment: comment ?? this.comment,
|
||||
measuredValue: measuredValue ?? this.measuredValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,603 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_attachment.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_calibration_tools.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_check_list.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_contacts.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_kit.dart';
|
||||
import 'package:test_sa/models/timer_model.dart';
|
||||
|
||||
class Ppm {
|
||||
Ppm({
|
||||
this.id,
|
||||
this.ppmScheduleId,
|
||||
this.assetId,
|
||||
this.jobSheetNo,
|
||||
this.assignedEmployeeId,
|
||||
this.expectedDate,
|
||||
this.actualDate,
|
||||
this.nextDate,
|
||||
this.forwardToId,
|
||||
this.maintenanceContractId,
|
||||
this.typeOfServiceId,
|
||||
this.executionTimeFrameId,
|
||||
this.externalEngineer,
|
||||
this.telephone,
|
||||
this.groupLeaderReviewId,
|
||||
this.timePeriodId,
|
||||
this.assignedToId,
|
||||
this.vCalibrationTools,
|
||||
this.vKits,
|
||||
this.vContacts,
|
||||
this.vChecklists,
|
||||
this.files,
|
||||
this.visitStatusId,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.workingHours,
|
||||
this.travelingHours,
|
||||
this.deviceStatusId,
|
||||
this.comments,
|
||||
this.workPerformed,
|
||||
this.supplierId,
|
||||
this.suppPersonId,
|
||||
this.suppStartDate,
|
||||
this.suppEndDate,
|
||||
this.suppWorkingHours,
|
||||
this.taskStatusId,
|
||||
this.engSignature,
|
||||
this.nurseSignature,
|
||||
this.safetyId,
|
||||
this.assetAvailabilityId,
|
||||
this.assetAvailabilityName,
|
||||
this.assetName,
|
||||
this.assetNumber,
|
||||
this.assetSerialNo,
|
||||
this.assetSupplierId,
|
||||
this.assetSupplierName,
|
||||
this.assignedEmployeeName,
|
||||
this.assignedToName,
|
||||
this.contractNumber,
|
||||
this.createdOn,
|
||||
this.departmentId,
|
||||
this.departmentName,
|
||||
this.deviceStatusName,
|
||||
this.dueDate,
|
||||
this.executionTimeFrameName,
|
||||
this.forwardToName,
|
||||
this.groupLeaderReviewName,
|
||||
this.manufacturerId,
|
||||
this.manufacturerName,
|
||||
this.modelId,
|
||||
this.modelName,
|
||||
this.modifiedOn,
|
||||
bool notified,
|
||||
this.planCode,
|
||||
this.planNo,
|
||||
this.ppmId,
|
||||
this.ppmScheduleCode,
|
||||
this.ppmScheduleNo,
|
||||
this.ppmSupplierId,
|
||||
this.ppmSupplierName,
|
||||
this.safetyName,
|
||||
this.siteId,
|
||||
this.siteName,
|
||||
this.supplierName,
|
||||
this.suppPerson,
|
||||
this.taskStatusName,
|
||||
this.timePeriodName,
|
||||
this.timePeriodValue,
|
||||
this.typeOfServiceName,
|
||||
this.visitCode,
|
||||
this.visitNo,
|
||||
this.visitStatusName,
|
||||
this.warrantyEndDate,
|
||||
});
|
||||
|
||||
Ppm.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
ppmScheduleId = json['ppmScheduleId'];
|
||||
assetId = json['assetId'];
|
||||
jobSheetNo = json['jobSheetNo'];
|
||||
assignedEmployeeId = json['assignedEmployeeId'];
|
||||
expectedDate = json['expectedDate'];
|
||||
actualDate = json['actualDate'];
|
||||
nextDate = json['nextDate'];
|
||||
forwardToId = json['forwardToId'];
|
||||
maintenanceContractId = json['maintenanceContractId'];
|
||||
typeOfServiceId = json['typeOfServiceId'];
|
||||
executionTimeFrameId = json['executionTimeFrameId'];
|
||||
externalEngineer = json['externalEngineer'];
|
||||
telephone = json['telephone'];
|
||||
groupLeaderReviewId = json['groupLeaderReviewId'];
|
||||
timePeriodId = json['timePeriodId'];
|
||||
assignedToId = json['assignedToId'];
|
||||
if (json['vCalibrationTools'] != null) {
|
||||
vCalibrationTools = [];
|
||||
json['vCalibrationTools'].forEach((v) {
|
||||
vCalibrationTools.add(PpmCalibrationTools.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['vKits'] != null) {
|
||||
vKits = [];
|
||||
json['vKits'].forEach((v) {
|
||||
vKits.add(PpmKits.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['vContacts'] != null) {
|
||||
vContacts = [];
|
||||
json['vContacts'].forEach((v) {
|
||||
vContacts.add(PpmContacts.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['vChecklists'] != null) {
|
||||
vChecklists = [];
|
||||
json['vChecklists'].forEach((v) {
|
||||
vChecklists.add(PpmChecklists.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['vAttachments'] != null) {
|
||||
files = [];
|
||||
json['vAttachments'].forEach((v) {
|
||||
files.add(PpmAttachments.fromJson(v));
|
||||
});
|
||||
}
|
||||
visitStatusId = json['visitStatusId'];
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
workingHours = json['workingHours'];
|
||||
try {
|
||||
tbsTimer = TimerModel(startAt: DateTime.tryParse(startDate ?? ""), endAt: DateTime.tryParse(endDate ?? ""));
|
||||
if (tbsTimer.endAt != null && tbsTimer.startAt != null) {
|
||||
tbsTimer.durationInSecond = (tbsTimer.endAt.difference(tbsTimer.startAt))?.inSeconds;
|
||||
workingHours = (((tbsTimer.durationInSecond ?? 0) / 60) / 60).toStringAsFixed(2);
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
travelingHours = json['travelingHours'];
|
||||
deviceStatusId = json['deviceStatusId'];
|
||||
comments = json['comments'];
|
||||
workPerformed = json['workPerformed'];
|
||||
supplierId = json['supplierId'];
|
||||
suppPersonId = json['suppPersonId'];
|
||||
suppStartDate = json['suppStartDate'];
|
||||
suppEndDate = json['suppEndDate'];
|
||||
suppWorkingHours = json['suppWorkingHours'];
|
||||
taskStatusId = json['taskStatusId'];
|
||||
engSignature = json['engSignature'];
|
||||
nurseSignature = json['nurseSignature'];
|
||||
safetyId = json['safetyId'];
|
||||
assetAvailabilityId = json['assetAvailabilityId'];
|
||||
assetAvailabilityName = json['assetAvailabilityName'];
|
||||
assetName = json['assetName'];
|
||||
assetNumber = json['assetNumber'];
|
||||
assetSerialNo = json['assetSerialNo'];
|
||||
assetSupplierId = json['assetSupplierId'];
|
||||
assetSupplierName = json['assetSupplierName'];
|
||||
assignedEmployeeName = json['assignedEmployeeName'];
|
||||
assignedToName = json['assignedToName'];
|
||||
createdOn = json['createdOn'];
|
||||
departmentId = json['departmentId'];
|
||||
departmentName = json['departmentName'];
|
||||
deviceStatusName = json['deviceStatusName'];
|
||||
dueDate = json['dueDate'];
|
||||
executionTimeFrameName = json['executionTimeFrameName'];
|
||||
forwardToName = json['forwardToName'];
|
||||
manufacturerId = json['manufacturerId'];
|
||||
manufacturerName = json['manufacturerName'];
|
||||
modifiedOn = json['modifiedOn'];
|
||||
notified = json['notified'];
|
||||
planCode = json['planCode'];
|
||||
planNo = json['planNo'];
|
||||
ppmId = json['ppmId'];
|
||||
ppmScheduleCode = json['ppmScheduleCode'];
|
||||
ppmScheduleNo = json['ppmScheduleNo'];
|
||||
ppmSupplierId = json['ppmSupplierId'];
|
||||
ppmSupplierName = json['ppmSupplierName'];
|
||||
safetyName = json['safetyName'];
|
||||
siteId = json['siteId'];
|
||||
siteName = json['siteName'];
|
||||
supplierName = json['supplierName'];
|
||||
suppPerson = json['suppPerson'];
|
||||
taskStatusName = json['taskStatusName'];
|
||||
timePeriodName = json['timePeriodName'];
|
||||
timePeriodValue = json['timePeriodValue'];
|
||||
typeOfServiceName = json['typeOfServiceName'];
|
||||
visitCode = json['visitCode'];
|
||||
visitNo = json['visitNo'];
|
||||
visitStatusName = json['visitStatusName'];
|
||||
warrantyEndDate = json['warrantyEndDate'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num ppmScheduleId;
|
||||
num assetId;
|
||||
String jobSheetNo;
|
||||
String assignedEmployeeId;
|
||||
String expectedDate;
|
||||
String actualDate;
|
||||
String nextDate;
|
||||
String forwardToId;
|
||||
num maintenanceContractId;
|
||||
num typeOfServiceId;
|
||||
num executionTimeFrameId;
|
||||
String externalEngineer;
|
||||
String telephone;
|
||||
num groupLeaderReviewId;
|
||||
num timePeriodId;
|
||||
num assignedToId;
|
||||
List<PpmCalibrationTools> vCalibrationTools;
|
||||
List<PpmKits> vKits;
|
||||
List<PpmContacts> vContacts;
|
||||
List<PpmChecklists> vChecklists;
|
||||
List<PpmAttachments> files;
|
||||
num visitStatusId;
|
||||
String startDate;
|
||||
String endDate;
|
||||
String workingHours;
|
||||
String travelingHours;
|
||||
num deviceStatusId;
|
||||
String comments;
|
||||
String workPerformed;
|
||||
num supplierId;
|
||||
num suppPersonId;
|
||||
String suppStartDate;
|
||||
String suppEndDate;
|
||||
String suppWorkingHours;
|
||||
num taskStatusId;
|
||||
String engSignature;
|
||||
String nurseSignature;
|
||||
num safetyId;
|
||||
num assetAvailabilityId;
|
||||
String assetAvailabilityName;
|
||||
String assetName;
|
||||
String assetNumber;
|
||||
String assetSerialNo;
|
||||
num assetSupplierId;
|
||||
String assetSupplierName;
|
||||
String assignedEmployeeName;
|
||||
String assignedToName;
|
||||
String contractNumber;
|
||||
String createdOn;
|
||||
num departmentId;
|
||||
String departmentName;
|
||||
String deviceStatusName;
|
||||
String dueDate;
|
||||
String executionTimeFrameName;
|
||||
String forwardToName;
|
||||
String groupLeaderReviewName;
|
||||
num manufacturerId;
|
||||
String manufacturerName;
|
||||
num modelId;
|
||||
String modelName;
|
||||
String modifiedOn;
|
||||
bool notified;
|
||||
String planCode;
|
||||
num planNo;
|
||||
num ppmId;
|
||||
String ppmScheduleCode;
|
||||
num ppmScheduleNo;
|
||||
num ppmSupplierId;
|
||||
String ppmSupplierName;
|
||||
String safetyName;
|
||||
num siteId;
|
||||
String siteName;
|
||||
String supplierName;
|
||||
String suppPerson;
|
||||
String taskStatusName;
|
||||
String timePeriodName;
|
||||
num timePeriodValue;
|
||||
String typeOfServiceName;
|
||||
String visitCode;
|
||||
num visitNo;
|
||||
String visitStatusName;
|
||||
String warrantyEndDate;
|
||||
TimerModel tbsTimer = TimerModel();
|
||||
Uint8List localNurseSignature;
|
||||
Uint8List localEngineerSignature;
|
||||
|
||||
Ppm copyWith({
|
||||
num id,
|
||||
num ppmScheduleId,
|
||||
num assetId,
|
||||
String jobSheetNo,
|
||||
String assignedEmployeeId,
|
||||
String expectedDate,
|
||||
String actualDate,
|
||||
String nextDate,
|
||||
String forwardToId,
|
||||
num maintenanceContractId,
|
||||
num typeOfServiceId,
|
||||
num executionTimeFrameId,
|
||||
String externalEngineer,
|
||||
String telephone,
|
||||
num groupLeaderReviewId,
|
||||
num timePeriodId,
|
||||
num assignedToId,
|
||||
List<PpmCalibrationTools> vCalibrationTools,
|
||||
List<PpmKits> vKits,
|
||||
List<PpmContacts> vContacts,
|
||||
List<PpmChecklists> vChecklists,
|
||||
List<PpmAttachments> files,
|
||||
num visitStatusId,
|
||||
String startDate,
|
||||
String endDate,
|
||||
String workingHours,
|
||||
String travelingHours,
|
||||
num deviceStatusId,
|
||||
String comments,
|
||||
String workPerformed,
|
||||
num supplierId,
|
||||
num suppPersonId,
|
||||
String suppStartDate,
|
||||
String suppEndDate,
|
||||
String suppWorkingHours,
|
||||
num taskStatusId,
|
||||
String engSignature,
|
||||
String nurseSignature,
|
||||
num safetyId,
|
||||
num assetAvailabilityId,
|
||||
String assetAvailabilityName,
|
||||
String assetName,
|
||||
String assetNumber,
|
||||
String assetSerialNo,
|
||||
num assetSupplierId,
|
||||
String assetSupplierName,
|
||||
String assignedEmployeeName,
|
||||
String assignedToName,
|
||||
String contractNumber,
|
||||
String createdOn,
|
||||
num departmentId,
|
||||
String departmentName,
|
||||
String deviceStatusName,
|
||||
String dueDate,
|
||||
String executionTimeFrameName,
|
||||
String forwardToName,
|
||||
String groupLeaderReviewName,
|
||||
num manufacturerId,
|
||||
String manufacturerName,
|
||||
num modelId,
|
||||
String modelName,
|
||||
String modifiedOn,
|
||||
bool notified,
|
||||
String planCode,
|
||||
num planNo,
|
||||
num ppmId,
|
||||
String ppmScheduleCode,
|
||||
num ppmScheduleNo,
|
||||
num ppmSupplierId,
|
||||
String ppmSupplierName,
|
||||
String safetyName,
|
||||
num siteId,
|
||||
String siteName,
|
||||
String supplierName,
|
||||
String suppPerson,
|
||||
String taskStatusName,
|
||||
String timePeriodName,
|
||||
num timePeriodValue,
|
||||
String typeOfServiceName,
|
||||
String visitCode,
|
||||
num visitNo,
|
||||
String visitStatusName,
|
||||
String warrantyEndDate,
|
||||
TimerModel tbsTimer,
|
||||
}) =>
|
||||
Ppm(
|
||||
id: id ?? this.id,
|
||||
ppmScheduleId: ppmScheduleId ?? this.ppmScheduleId,
|
||||
assetId: assetId ?? this.assetId,
|
||||
jobSheetNo: jobSheetNo ?? this.jobSheetNo,
|
||||
assignedEmployeeId: assignedEmployeeId ?? this.assignedEmployeeId,
|
||||
expectedDate: expectedDate ?? this.expectedDate,
|
||||
actualDate: actualDate ?? this.actualDate,
|
||||
nextDate: nextDate ?? this.nextDate,
|
||||
forwardToId: forwardToId ?? this.forwardToId,
|
||||
maintenanceContractId: maintenanceContractId ?? this.maintenanceContractId,
|
||||
typeOfServiceId: typeOfServiceId ?? this.typeOfServiceId,
|
||||
executionTimeFrameId: executionTimeFrameId ?? this.executionTimeFrameId,
|
||||
externalEngineer: externalEngineer ?? this.externalEngineer,
|
||||
telephone: telephone ?? this.telephone,
|
||||
groupLeaderReviewId: groupLeaderReviewId ?? this.groupLeaderReviewId,
|
||||
timePeriodId: timePeriodId ?? this.timePeriodId,
|
||||
assignedToId: assignedToId ?? this.assignedToId,
|
||||
vCalibrationTools: vCalibrationTools ?? this.vCalibrationTools,
|
||||
vKits: vKits ?? this.vKits,
|
||||
vContacts: vContacts ?? this.vContacts,
|
||||
vChecklists: vChecklists ?? this.vChecklists,
|
||||
files: files ?? this.files,
|
||||
visitStatusId: visitStatusId ?? this.visitStatusId,
|
||||
startDate: startDate ?? this.startDate,
|
||||
endDate: endDate ?? this.endDate,
|
||||
workingHours: workingHours ?? this.workingHours,
|
||||
travelingHours: travelingHours ?? this.travelingHours,
|
||||
deviceStatusId: deviceStatusId ?? this.deviceStatusId,
|
||||
comments: comments ?? this.comments,
|
||||
workPerformed: workPerformed ?? this.workPerformed,
|
||||
supplierId: supplierId ?? this.supplierId,
|
||||
suppPersonId: suppPersonId ?? this.suppPersonId,
|
||||
suppStartDate: suppStartDate ?? this.suppStartDate,
|
||||
suppEndDate: suppEndDate ?? this.suppEndDate,
|
||||
suppWorkingHours: suppWorkingHours ?? this.suppWorkingHours,
|
||||
taskStatusId: taskStatusId ?? this.taskStatusId,
|
||||
engSignature: engSignature ?? this.engSignature,
|
||||
nurseSignature: nurseSignature ?? this.nurseSignature,
|
||||
safetyId: safetyId ?? this.safetyId,
|
||||
assetAvailabilityId: assetAvailabilityId ?? this.assetAvailabilityId,
|
||||
assetAvailabilityName: assetAvailabilityName ?? this.assetAvailabilityName,
|
||||
assetName: assetName ?? this.assetName,
|
||||
assetNumber: assetNumber ?? this.assetNumber,
|
||||
assetSerialNo: assetSerialNo ?? this.assetSerialNo,
|
||||
assetSupplierId: assetSupplierId ?? this.assetSupplierId,
|
||||
assetSupplierName: assetSupplierName ?? this.assetSupplierName,
|
||||
assignedEmployeeName: assignedEmployeeName ?? this.assignedEmployeeName,
|
||||
assignedToName: assignedToName ?? this.assignedToName,
|
||||
createdOn: createdOn ?? this.createdOn,
|
||||
departmentId: departmentId ?? this.departmentId,
|
||||
departmentName: departmentName ?? this.departmentName,
|
||||
deviceStatusName: deviceStatusName ?? this.deviceStatusName,
|
||||
dueDate: dueDate ?? this.dueDate,
|
||||
executionTimeFrameName: executionTimeFrameName ?? this.executionTimeFrameName,
|
||||
forwardToName: forwardToName ?? this.forwardToName,
|
||||
manufacturerId: manufacturerId ?? this.manufacturerId,
|
||||
manufacturerName: manufacturerName ?? this.manufacturerName,
|
||||
modifiedOn: modifiedOn ?? this.modifiedOn,
|
||||
notified: notified ?? this.notified,
|
||||
planCode: planCode ?? this.planCode,
|
||||
planNo: planNo ?? this.planNo,
|
||||
ppmId: ppmId ?? this.ppmId,
|
||||
ppmScheduleCode: ppmScheduleCode ?? this.ppmScheduleCode,
|
||||
ppmScheduleNo: ppmScheduleNo ?? this.ppmScheduleNo,
|
||||
ppmSupplierId: ppmSupplierId ?? this.ppmSupplierId,
|
||||
ppmSupplierName: ppmSupplierName ?? this.ppmSupplierName,
|
||||
safetyName: safetyName ?? this.safetyName,
|
||||
siteId: siteId ?? this.siteId,
|
||||
siteName: siteName ?? this.siteName,
|
||||
supplierName: supplierName ?? this.supplierName,
|
||||
suppPerson: suppPerson ?? this.suppPerson,
|
||||
taskStatusName: taskStatusName ?? this.taskStatusName,
|
||||
timePeriodName: timePeriodName ?? this.timePeriodName,
|
||||
timePeriodValue: timePeriodValue ?? this.timePeriodValue,
|
||||
typeOfServiceName: typeOfServiceName ?? this.typeOfServiceName,
|
||||
visitCode: visitCode ?? this.visitCode,
|
||||
visitNo: visitNo ?? this.visitNo,
|
||||
visitStatusName: visitStatusName ?? this.visitStatusName,
|
||||
warrantyEndDate: warrantyEndDate ?? this.warrantyEndDate,
|
||||
)..tbsTimer = tbsTimer ?? this.tbsTimer;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['ppmScheduleId'] = ppmScheduleId;
|
||||
map['assetId'] = assetId;
|
||||
map['jobSheetNo'] = jobSheetNo;
|
||||
map['assignedEmployeeId'] = assignedEmployeeId;
|
||||
map['expectedDate'] = expectedDate;
|
||||
map['actualDate'] = actualDate;
|
||||
map['nextDate'] = nextDate;
|
||||
map['forwardToId'] = forwardToId;
|
||||
map['maintenanceContractId'] = maintenanceContractId;
|
||||
map['typeOfServiceId'] = typeOfServiceId;
|
||||
map['executionTimeFrameId'] = executionTimeFrameId;
|
||||
map['externalEngineer'] = externalEngineer;
|
||||
map['telephone'] = telephone;
|
||||
map['groupLeaderReviewId'] = groupLeaderReviewId;
|
||||
map['timePeriodId'] = timePeriodId;
|
||||
map['assignedToId'] = assignedToId;
|
||||
if (vCalibrationTools != null) {
|
||||
map['vCalibrationTools'] = vCalibrationTools.map((v) => v.copyWith(visitId: id).toJson()).toList();
|
||||
}
|
||||
if (vKits != null) {
|
||||
map['vKits'] = vKits.map((v) => v.copyWith(visitId: id).toJson()).toList();
|
||||
}
|
||||
if (vContacts != null) {
|
||||
map['vContacts'] = vContacts.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (vChecklists != null) {
|
||||
map['vChecklists'] = vChecklists.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (files?.isNotEmpty ?? false) {
|
||||
map["vAttachments"] = files
|
||||
.map((file) =>
|
||||
{"attachmentName": _isLocalUrl(file.attachmentName) ? ("${file.attachmentName.split("/").last}|${base64Encode(File(file.attachmentName).readAsBytesSync())}") : file.attachmentName})
|
||||
.toList();
|
||||
}
|
||||
map['visitStatusId'] = visitStatusId;
|
||||
map['startDate'] = tbsTimer?.startAt?.toIso8601String();
|
||||
map['endDate'] = tbsTimer?.endAt?.toIso8601String();
|
||||
map['workingHours'] = ((tbsTimer?.durationInSecond ?? 0) / 60 / 60).toStringAsFixed(5);
|
||||
map['travelingHours'] = travelingHours;
|
||||
map['deviceStatusId'] = deviceStatusId;
|
||||
map['comments'] = comments;
|
||||
map['workPerformed'] = workPerformed;
|
||||
map['supplierId'] = supplierId;
|
||||
map['suppPersonId'] = suppPersonId;
|
||||
map['suppStartDate'] = suppStartDate;
|
||||
map['suppEndDate'] = suppEndDate;
|
||||
map['suppWorkingHours'] = suppWorkingHours;
|
||||
map['taskStatusId'] = taskStatusId;
|
||||
map['engSignature'] = engSignature;
|
||||
map['nurseSignature'] = nurseSignature;
|
||||
map['safetyId'] = safetyId;
|
||||
map['assetAvailabilityId'] = assetAvailabilityId;
|
||||
map['assetAvailabilityName'] = assetAvailabilityName;
|
||||
map['assetName'] = assetName;
|
||||
map['assetNumber'] = assetNumber;
|
||||
map['assetSerialNo'] = assetSerialNo;
|
||||
map['assetSupplierId'] = assetSupplierId;
|
||||
map['assetSupplierName'] = assetSupplierName;
|
||||
map['assignedEmployeeName'] = assignedEmployeeName;
|
||||
map['assignedToName'] = assignedToName;
|
||||
map['createdOn'] = createdOn;
|
||||
map['departmentId'] = departmentId;
|
||||
map['departmentName'] = departmentName;
|
||||
map['deviceStatusName'] = deviceStatusName;
|
||||
map['dueDate'] = dueDate;
|
||||
map['executionTimeFrameName'] = executionTimeFrameName;
|
||||
map['forwardToName'] = forwardToName;
|
||||
map['manufacturerId'] = manufacturerId;
|
||||
map['manufacturerName'] = manufacturerName;
|
||||
map['modifiedOn'] = modifiedOn;
|
||||
map['notified'] = notified;
|
||||
map['planCode'] = planCode;
|
||||
map['planNo'] = planNo;
|
||||
map['ppmId'] = ppmId;
|
||||
map['ppmScheduleCode'] = ppmScheduleCode;
|
||||
map['ppmScheduleNo'] = ppmScheduleNo;
|
||||
map['ppmSupplierId'] = ppmSupplierId;
|
||||
map['ppmSupplierName'] = ppmSupplierName;
|
||||
map['safetyName'] = safetyName;
|
||||
map['siteId'] = siteId;
|
||||
map['siteName'] = siteName;
|
||||
map['supplierName'] = supplierName;
|
||||
map['suppPerson'] = suppPerson;
|
||||
map['taskStatusName'] = taskStatusName;
|
||||
map['timePeriodName'] = timePeriodName;
|
||||
map['timePeriodValue'] = timePeriodValue;
|
||||
map['typeOfServiceName'] = typeOfServiceName;
|
||||
map['visitCode'] = visitCode;
|
||||
map['visitNo'] = visitNo;
|
||||
map['visitStatusName'] = visitStatusName;
|
||||
map['warrantyEndDate'] = warrantyEndDate;
|
||||
return map;
|
||||
}
|
||||
|
||||
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 (deviceStatusId == null || visitStatusId == null) {
|
||||
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.status}");
|
||||
return false;
|
||||
}
|
||||
if (actualDate == 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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
class PpmAttachments {
|
||||
PpmAttachments({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.attachmentName,
|
||||
this.attachmentURL,
|
||||
});
|
||||
|
||||
PpmAttachments.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
attachmentName = json['attachmentName'];
|
||||
attachmentName = json['attachmentURL'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num visitId;
|
||||
String attachmentName;
|
||||
String attachmentURL;
|
||||
|
||||
PpmAttachments copyWith({
|
||||
num id,
|
||||
num visitId,
|
||||
String attachmentName,
|
||||
String attachmentURL,
|
||||
}) =>
|
||||
PpmAttachments(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
attachmentName: attachmentName ?? this.attachmentName,
|
||||
attachmentURL: attachmentURL ?? this.attachmentURL,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['attachmentName'] = attachmentName;
|
||||
map['attachmentURL'] = attachmentURL;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
class PpmCalibrationTools {
|
||||
PpmCalibrationTools({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.assetId,
|
||||
this.calibrationDateOfTesters,
|
||||
this.assetSerialNo,
|
||||
this.assetName,
|
||||
this.assetNumber,
|
||||
});
|
||||
|
||||
PpmCalibrationTools.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
assetId = json['assetId'];
|
||||
calibrationDateOfTesters = json['calibrationDateOfTesters'];
|
||||
assetSerialNo = json['assetSerialNo'];
|
||||
assetName = json['assetName'];
|
||||
assetNumber = json['assetNumber'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num visitId;
|
||||
num assetId;
|
||||
String calibrationDateOfTesters;
|
||||
String assetSerialNo;
|
||||
String assetName;
|
||||
String assetNumber;
|
||||
|
||||
PpmCalibrationTools copyWith({
|
||||
num id,
|
||||
num visitId,
|
||||
num assetId,
|
||||
String calibrationDateOfTesters,
|
||||
String assetSerialNo,
|
||||
String assetName,
|
||||
String assetNumber,
|
||||
}) =>
|
||||
PpmCalibrationTools(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
assetId: assetId ?? this.assetId,
|
||||
calibrationDateOfTesters: calibrationDateOfTesters ?? this.calibrationDateOfTesters,
|
||||
assetSerialNo: assetSerialNo ?? this.assetSerialNo,
|
||||
assetName: assetName ?? this.assetName,
|
||||
assetNumber: assetNumber ?? this.assetNumber,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['assetId'] = assetId;
|
||||
map['calibrationDateOfTesters'] = calibrationDateOfTesters;
|
||||
map['assetSerialNo'] = assetSerialNo;
|
||||
map['assetName'] = assetName;
|
||||
map['assetNumber'] = assetNumber;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
class PpmChecklists {
|
||||
PpmChecklists({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.task,
|
||||
this.taskStatusId,
|
||||
this.taskComment,
|
||||
this.measuredValue,
|
||||
this.taskStatusName,
|
||||
});
|
||||
|
||||
PpmChecklists.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
task = json['task'];
|
||||
taskStatusId = json['taskStatusId'];
|
||||
taskStatusName = json['taskStatusName'];
|
||||
taskComment = json['taskComment'];
|
||||
measuredValue = json['measuredValue'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num visitId;
|
||||
String task;
|
||||
num taskStatusId;
|
||||
String taskComment;
|
||||
String measuredValue;
|
||||
String taskStatusName;
|
||||
|
||||
PpmChecklists copyWith({
|
||||
num id,
|
||||
num visitId,
|
||||
String task,
|
||||
num taskStatusId,
|
||||
String taskComment,
|
||||
String measuredValue,
|
||||
String taskStatusName,
|
||||
}) =>
|
||||
PpmChecklists(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
task: task ?? this.task,
|
||||
taskStatusId: taskStatusId ?? this.taskStatusId,
|
||||
taskComment: taskComment ?? this.taskComment,
|
||||
measuredValue: measuredValue ?? this.measuredValue,
|
||||
taskStatusName: taskStatusName ?? this.taskStatusName,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['task'] = task;
|
||||
map['taskStatusId'] = taskStatusId;
|
||||
map['taskComment'] = taskComment;
|
||||
map['measuredValue'] = measuredValue;
|
||||
map['taskStatusName'] = taskStatusName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
class PpmContacts {
|
||||
PpmContacts({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.title,
|
||||
this.person,
|
||||
this.job,
|
||||
this.email,
|
||||
this.telephone,
|
||||
this.landLine,
|
||||
});
|
||||
|
||||
PpmContacts.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
title = json['title'];
|
||||
person = json['person'];
|
||||
job = json['job'];
|
||||
email = json['email'];
|
||||
telephone = json['telephone'];
|
||||
landLine = json['landLine'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num visitId;
|
||||
String title;
|
||||
String person;
|
||||
String job;
|
||||
String email;
|
||||
String telephone;
|
||||
String landLine;
|
||||
|
||||
PpmContacts copyWith({
|
||||
num id,
|
||||
num visitId,
|
||||
String title,
|
||||
String person,
|
||||
String job,
|
||||
String email,
|
||||
String telephone,
|
||||
String landLine,
|
||||
}) =>
|
||||
PpmContacts(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
title: title ?? this.title,
|
||||
person: person ?? this.person,
|
||||
job: job ?? this.job,
|
||||
email: email ?? this.email,
|
||||
telephone: telephone ?? this.telephone,
|
||||
landLine: landLine ?? this.landLine,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['title'] = title;
|
||||
map['person'] = person;
|
||||
map['job'] = job;
|
||||
map['email'] = email;
|
||||
map['telephone'] = telephone;
|
||||
map['landLine'] = landLine;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
class PpmKits {
|
||||
PpmKits({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.partCatalogItemId,
|
||||
this.partNumber,
|
||||
this.oracleCode,
|
||||
this.partName,
|
||||
this.partName2,
|
||||
});
|
||||
|
||||
PpmKits.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
partCatalogItemId = json['partCatalogItemId'];
|
||||
partNumber = json['partNumber'];
|
||||
oracleCode = json['oracleCode'];
|
||||
partName = json['partName'];
|
||||
partName2 = json['partName2'];
|
||||
}
|
||||
|
||||
num id;
|
||||
num visitId;
|
||||
num partCatalogItemId;
|
||||
String partNumber;
|
||||
String oracleCode;
|
||||
String partName;
|
||||
String partName2;
|
||||
|
||||
PpmKits copyWith({
|
||||
num id,
|
||||
num visitId,
|
||||
num partCatalogItemId,
|
||||
String partNumber,
|
||||
String oracleCode,
|
||||
String partName,
|
||||
String partName2,
|
||||
}) =>
|
||||
PpmKits(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
partCatalogItemId: partCatalogItemId ?? this.partCatalogItemId,
|
||||
partNumber: partNumber ?? this.partNumber,
|
||||
oracleCode: oracleCode ?? this.oracleCode,
|
||||
partName: partName ?? this.partName,
|
||||
partName2: partName2 ?? this.partName2,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['partCatalogItemId'] = partCatalogItemId;
|
||||
map['partNumber'] = partNumber;
|
||||
map['oracleCode'] = oracleCode;
|
||||
map['partName'] = partName;
|
||||
map['partName2'] = partName2;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,202 @@
|
||||
import '../device/asset_by_id_model.dart';
|
||||
|
||||
class PpmSearch {
|
||||
PpmSearch({
|
||||
this.pageSize,
|
||||
this.pageNumber,
|
||||
this.id,
|
||||
this.assetId,
|
||||
this.modelId,
|
||||
this.ppmId,
|
||||
this.ppmScheduleId,
|
||||
this.classification,
|
||||
this.visitStatusId,
|
||||
this.deviceStatusId,
|
||||
this.groupLeaderReviewId,
|
||||
this.assignedEmployeeId,
|
||||
this.hasAssignedEmployee,
|
||||
this.assignedToId,
|
||||
this.expectedDateFrom,
|
||||
this.expectedDateTo,
|
||||
this.actualDateFrom,
|
||||
this.actualDateTo,
|
||||
this.siteId,
|
||||
this.jobSheetNo,
|
||||
this.typeOfServiceId,
|
||||
this.planNumber,
|
||||
this.notified,
|
||||
this.mostRecent,
|
||||
this.assetGroup,
|
||||
this.buildingId,
|
||||
this.floorId,
|
||||
this.roomId,
|
||||
this.departmentId,
|
||||
this.assetName,
|
||||
});
|
||||
|
||||
PpmSearch.fromJson(dynamic json) {
|
||||
pageSize = json['pageSize'];
|
||||
pageNumber = json['pageNumber'];
|
||||
id = json['id'];
|
||||
assetId = json['assetId'];
|
||||
modelId = json['modelId'];
|
||||
ppmId = json['ppmId'];
|
||||
ppmScheduleId = json['ppmScheduleId'];
|
||||
classification = json['classification'];
|
||||
visitStatusId = json['visitStatusId'];
|
||||
deviceStatusId = json['deviceStatusId'];
|
||||
groupLeaderReviewId = json['groupLeaderReviewId'];
|
||||
assignedEmployeeId = json['assignedEmployeeId'];
|
||||
hasAssignedEmployee = json['hasAssignedEmployee'];
|
||||
assignedToId = json['assignedToId'];
|
||||
expectedDateFrom = json['expectedDateFrom'];
|
||||
expectedDateTo = json['expectedDateTo'];
|
||||
actualDateFrom = json['actualDateFrom'];
|
||||
actualDateTo = json['actualDateTo'];
|
||||
siteId = json['siteId'];
|
||||
jobSheetNo = json['jobSheetNo'];
|
||||
typeOfServiceId = json['typeOfServiceId'];
|
||||
planNumber = json['planNumber'];
|
||||
notified = json['notified'];
|
||||
mostRecent = json['mostRecent'];
|
||||
assetGroup = json['assetGroup'] != null ? AssetGroup.fromJson(json['assetGroup']) : null;
|
||||
buildingId = json['buildingId'];
|
||||
floorId = json['floorId'];
|
||||
roomId = json['roomId'];
|
||||
departmentId = json['departmentId'];
|
||||
assetName = json['assetName'];
|
||||
}
|
||||
|
||||
num pageSize;
|
||||
num pageNumber;
|
||||
num id;
|
||||
num assetId;
|
||||
num modelId;
|
||||
num ppmId;
|
||||
num ppmScheduleId;
|
||||
num classification;
|
||||
num visitStatusId;
|
||||
num deviceStatusId;
|
||||
num groupLeaderReviewId;
|
||||
String assignedEmployeeId;
|
||||
bool hasAssignedEmployee;
|
||||
num assignedToId;
|
||||
String expectedDateFrom;
|
||||
String expectedDateTo;
|
||||
String actualDateFrom;
|
||||
String actualDateTo;
|
||||
num siteId;
|
||||
String jobSheetNo;
|
||||
num typeOfServiceId;
|
||||
num planNumber;
|
||||
bool notified;
|
||||
bool mostRecent;
|
||||
AssetGroup assetGroup;
|
||||
num buildingId;
|
||||
num floorId;
|
||||
num roomId;
|
||||
num departmentId;
|
||||
String assetName;
|
||||
|
||||
PpmSearch copyWith({
|
||||
num pageSize,
|
||||
num pageNumber,
|
||||
num id,
|
||||
num assetId,
|
||||
num modelId,
|
||||
num ppmId,
|
||||
num ppmScheduleId,
|
||||
num classification,
|
||||
num visitStatusId,
|
||||
num deviceStatusId,
|
||||
num groupLeaderReviewId,
|
||||
String assignedEmployeeId,
|
||||
bool hasAssignedEmployee,
|
||||
num assignedToId,
|
||||
String expectedDateFrom,
|
||||
String expectedDateTo,
|
||||
String actualDateFrom,
|
||||
String actualDateTo,
|
||||
num siteId,
|
||||
String jobSheetNo,
|
||||
num typeOfServiceId,
|
||||
num planNumber,
|
||||
bool notified,
|
||||
bool mostRecent,
|
||||
AssetGroup assetGroup,
|
||||
num buildingId,
|
||||
num floorId,
|
||||
num roomId,
|
||||
num departmentId,
|
||||
String assetName,
|
||||
}) =>
|
||||
PpmSearch(
|
||||
pageSize: pageSize ?? this.pageSize,
|
||||
pageNumber: pageNumber ?? this.pageNumber,
|
||||
id: id ?? this.id,
|
||||
assetId: assetId ?? this.assetId,
|
||||
modelId: modelId ?? this.modelId,
|
||||
ppmId: ppmId ?? this.ppmId,
|
||||
ppmScheduleId: ppmScheduleId ?? this.ppmScheduleId,
|
||||
classification: classification ?? this.classification,
|
||||
visitStatusId: visitStatusId ?? this.visitStatusId,
|
||||
deviceStatusId: deviceStatusId ?? this.deviceStatusId,
|
||||
groupLeaderReviewId: groupLeaderReviewId ?? this.groupLeaderReviewId,
|
||||
assignedEmployeeId: assignedEmployeeId ?? this.assignedEmployeeId,
|
||||
hasAssignedEmployee: hasAssignedEmployee ?? this.hasAssignedEmployee,
|
||||
assignedToId: assignedToId ?? this.assignedToId,
|
||||
expectedDateFrom: expectedDateFrom ?? this.expectedDateFrom,
|
||||
expectedDateTo: expectedDateTo ?? this.expectedDateTo,
|
||||
actualDateFrom: actualDateFrom ?? this.actualDateFrom,
|
||||
actualDateTo: actualDateTo ?? this.actualDateTo,
|
||||
siteId: siteId ?? this.siteId,
|
||||
jobSheetNo: jobSheetNo ?? this.jobSheetNo,
|
||||
typeOfServiceId: typeOfServiceId ?? this.typeOfServiceId,
|
||||
planNumber: planNumber ?? this.planNumber,
|
||||
notified: notified ?? this.notified,
|
||||
mostRecent: mostRecent ?? this.mostRecent,
|
||||
assetGroup: assetGroup ?? this.assetGroup,
|
||||
buildingId: buildingId ?? this.buildingId,
|
||||
floorId: floorId ?? this.floorId,
|
||||
roomId: roomId ?? this.roomId,
|
||||
departmentId: departmentId ?? this.departmentId,
|
||||
assetName: assetName ?? this.assetName,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['pageSize'] = pageSize;
|
||||
map['pageNumber'] = pageNumber;
|
||||
map['id'] = id;
|
||||
map['assetId'] = assetId;
|
||||
map['modelId'] = modelId;
|
||||
map['ppmId'] = ppmId;
|
||||
map['ppmScheduleId'] = ppmScheduleId;
|
||||
map['classification'] = classification;
|
||||
map['visitStatusId'] = visitStatusId;
|
||||
map['deviceStatusId'] = deviceStatusId;
|
||||
map['groupLeaderReviewId'] = groupLeaderReviewId;
|
||||
map['assignedEmployeeId'] = assignedEmployeeId;
|
||||
map['hasAssignedEmployee'] = hasAssignedEmployee;
|
||||
map['assignedToId'] = assignedToId;
|
||||
map['expectedDateFrom'] = expectedDateFrom;
|
||||
map['expectedDateTo'] = expectedDateTo;
|
||||
map['actualDateFrom'] = actualDateFrom;
|
||||
map['actualDateTo'] = actualDateTo;
|
||||
map['siteId'] = siteId;
|
||||
map['jobSheetNo'] = jobSheetNo;
|
||||
map['typeOfServiceId'] = typeOfServiceId;
|
||||
map['planNumber'] = planNumber;
|
||||
map['notified'] = notified;
|
||||
map['mostRecent'] = mostRecent;
|
||||
if (assetGroup != null) {
|
||||
map['assetGroup'] = assetGroup.toJson();
|
||||
}
|
||||
map['buildingId'] = buildingId;
|
||||
map['floorId'] = floorId;
|
||||
map['roomId'] = roomId;
|
||||
map['departmentId'] = departmentId;
|
||||
map['assetName'] = assetName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/pantry/pentry.dart';
|
||||
|
||||
class Visit {
|
||||
int id;
|
||||
String serialNumber;
|
||||
String expectDate;
|
||||
String actualDate;
|
||||
String createdOn;
|
||||
int hospitalId;
|
||||
String hospitalName;
|
||||
int deviceId;
|
||||
int ppmScheduleId;
|
||||
String deviceSerialNumber;
|
||||
String deviceArabicName;
|
||||
String deviceEnglishName;
|
||||
String employId;
|
||||
String employName;
|
||||
String modelAndBrand;
|
||||
Pentry pentry;
|
||||
Lookup status;
|
||||
String assignTo;
|
||||
String deviceNumber;
|
||||
List<String> images;
|
||||
|
||||
Visit({
|
||||
this.id,
|
||||
this.ppmScheduleId,
|
||||
this.serialNumber,
|
||||
this.hospitalId,
|
||||
this.hospitalName,
|
||||
this.deviceId,
|
||||
this.deviceSerialNumber,
|
||||
this.deviceArabicName,
|
||||
this.deviceEnglishName,
|
||||
this.employId,
|
||||
this.employName,
|
||||
this.expectDate,
|
||||
this.actualDate,
|
||||
this.status,
|
||||
this.modelAndBrand,
|
||||
this.pentry,
|
||||
this.images,
|
||||
this.assignTo,
|
||||
this.deviceNumber,
|
||||
this.createdOn,
|
||||
});
|
||||
|
||||
factory Visit.fromJson(Map<String, dynamic> parsedJson) {
|
||||
List<String> images = [];
|
||||
if (parsedJson["vAttachments"] is List) {
|
||||
List list = parsedJson["vAttachments"];
|
||||
images = list.map((e) {
|
||||
return URLs.getFileUrl(e["attachmentURL"].toString());
|
||||
}).toList();
|
||||
}
|
||||
return Visit(
|
||||
id: parsedJson["id"],
|
||||
serialNumber: parsedJson["visitCode"],
|
||||
ppmScheduleId: parsedJson["ppmScheduleId"],
|
||||
hospitalId: parsedJson["siteId"],
|
||||
deviceNumber: parsedJson["assetNumber"],
|
||||
hospitalName: parsedJson["siteName"],
|
||||
deviceId: parsedJson["assetId"],
|
||||
deviceSerialNumber: parsedJson["assetSerialNo"],
|
||||
deviceEnglishName: parsedJson["assetName"],
|
||||
deviceArabicName: parsedJson["assetName"],
|
||||
employId: parsedJson["assignedEmployeeId"].toString(),
|
||||
employName: parsedJson["assignedEmployeeName"],
|
||||
expectDate: parsedJson["expectedDate"].toString().split("T").first,
|
||||
actualDate: parsedJson["actualDate"].toString().split("T").first,
|
||||
modelAndBrand: "${parsedJson["modelName"]} / ${parsedJson["manufacturerName"]}",
|
||||
// contactStatus: parsedJson["contactStatus"],
|
||||
images: images,
|
||||
status: Lookup(
|
||||
id: parsedJson["visitStatusId"], // actual value (0,1,2)
|
||||
name: parsedJson["visitStatusName"] // text value
|
||||
),
|
||||
assignTo: parsedJson["assignedToName"],
|
||||
pentry: Pentry.fromMap(parsedJson),
|
||||
createdOn: parsedJson['createdOn'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
import 'package:test_sa/models/engineer.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
|
||||
class VisitsGroup {
|
||||
// String userId;
|
||||
// String workingHours;
|
||||
// String travelingHours;
|
||||
// String jobSheetNumber;
|
||||
// String image;
|
||||
// Lookup status;
|
||||
// Lookup taskStatus;
|
||||
// DateTime date;
|
||||
Engineer engineer;
|
||||
List<Visit> visits;
|
||||
|
||||
VisitsGroup({
|
||||
// this.userId,
|
||||
// this.status,
|
||||
// this.date,
|
||||
// this.jobSheetNumber,
|
||||
// this.travelingHours,
|
||||
// this.workingHours,
|
||||
this.visits,
|
||||
this.engineer,
|
||||
// this.image,
|
||||
// this.taskStatus,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> jsonObject = {};
|
||||
jsonObject["ids"] = visits.map((e) => e.id).toList();
|
||||
jsonObject["assignedEmployeeId"] = engineer?.id;
|
||||
// if(status != null) jsonObject["taskStatusId"] = status.id.toString();
|
||||
// if(date != null) jsonObject["actualDate"] = date.toIso8601String();
|
||||
// if(jobSheetNumber != null && jobSheetNumber.isNotEmpty)
|
||||
// jsonObject["jobSheetNo"] = jobSheetNumber;
|
||||
// if(travelingHours != null && travelingHours.isNotEmpty)
|
||||
// jsonObject["travelingHours"] = travelingHours;
|
||||
// if(workingHours != null && workingHours.isNotEmpty)
|
||||
// jsonObject["workingHours"] = workingHours;
|
||||
// if(image != null) jsonObject["image"] = image;
|
||||
// if(taskStatus != null) jsonObject["task_status"] = taskStatus.id.toString();
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class VisitsSearch {
|
||||
String deviceSerialNumber;
|
||||
String deviceName;
|
||||
String deviceNumber;
|
||||
Hospital hospital;
|
||||
String brand;
|
||||
Lookup model;
|
||||
Lookup contactStatus;
|
||||
DateTime expectedDateFrom;
|
||||
DateTime expectedDateTo;
|
||||
DateTime actualDateFrom;
|
||||
DateTime actualDateTo;
|
||||
Lookup statusValue;
|
||||
bool mostRecent;
|
||||
|
||||
VisitsSearch({
|
||||
this.deviceSerialNumber,
|
||||
this.statusValue,
|
||||
this.brand,
|
||||
this.hospital,
|
||||
this.actualDateTo,
|
||||
this.actualDateFrom,
|
||||
this.model,
|
||||
this.contactStatus,
|
||||
this.expectedDateFrom,
|
||||
this.expectedDateTo,
|
||||
this.deviceNumber,
|
||||
this.deviceName,
|
||||
this.mostRecent = true,
|
||||
});
|
||||
|
||||
fromSearch(VisitsSearch newSearch) {
|
||||
deviceSerialNumber = newSearch.deviceSerialNumber;
|
||||
brand = newSearch.brand;
|
||||
hospital = newSearch.hospital;
|
||||
actualDateTo = newSearch.actualDateTo;
|
||||
actualDateFrom = newSearch.actualDateFrom;
|
||||
model = newSearch.model;
|
||||
contactStatus = newSearch.contactStatus;
|
||||
expectedDateFrom = newSearch.expectedDateFrom;
|
||||
expectedDateTo = newSearch.expectedDateTo;
|
||||
statusValue = newSearch.statusValue;
|
||||
mostRecent = newSearch.mostRecent;
|
||||
deviceNumber = newSearch.deviceNumber;
|
||||
deviceName = newSearch.deviceName;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
Map<String, dynamic> _search = {};
|
||||
if (deviceSerialNumber != null && deviceSerialNumber.isNotEmpty) {
|
||||
_search["assetId"] = deviceSerialNumber;
|
||||
}
|
||||
|
||||
if (hospital != null) {
|
||||
_search["siteId"] = hospital.id;
|
||||
}
|
||||
|
||||
if (mostRecent != null) {
|
||||
_search["mostRecent"] = mostRecent;
|
||||
}
|
||||
|
||||
if (brand != null && brand.isNotEmpty) {
|
||||
// todo get new key
|
||||
_search[""] = brand;
|
||||
}
|
||||
|
||||
if (model != null) {
|
||||
_search["modelId"] = model.id;
|
||||
}
|
||||
|
||||
if (expectedDateFrom != null) {
|
||||
_search["expectedDateFrom"] = expectedDateFrom.toIso8601String();
|
||||
}
|
||||
|
||||
if (expectedDateTo != null) {
|
||||
_search["expectedDateTo"] = expectedDateTo.toIso8601String();
|
||||
}
|
||||
|
||||
if (actualDateFrom != null) {
|
||||
_search["actualDateFrom"] = actualDateFrom.toIso8601String();
|
||||
}
|
||||
|
||||
if (actualDateTo != null) {
|
||||
_search["actualDateTo"] = actualDateTo.toIso8601String();
|
||||
}
|
||||
|
||||
if (statusValue != null) {
|
||||
_search["visitStatusId"] = statusValue.id;
|
||||
}
|
||||
|
||||
if (contactStatus != null) {
|
||||
_search["assignedToId"] = contactStatus.id;
|
||||
}
|
||||
return _search;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import 'loading_list_notifier.dart';
|
||||
|
||||
class PpmChecklistStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading ?? false) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/ppm_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
|
||||
import '../../../../models/ppm/ppm.dart';
|
||||
import '../../../widgets/loaders/lazy_loading.dart';
|
||||
import '../../../widgets/loaders/no_item_found.dart';
|
||||
import '../../../widgets/ppm/ppm_item.dart';
|
||||
|
||||
class PpmPage extends StatefulWidget {
|
||||
static const String id = "/ppm_page";
|
||||
|
||||
const PpmPage({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PpmPageState createState() => _PpmPageState();
|
||||
}
|
||||
|
||||
class _PpmPageState extends State<PpmPage> with TickerProviderStateMixin {
|
||||
PpmProvider _visitsProvider;
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_visitsProvider = Provider.of<PpmProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
|
||||
body: SafeArea(
|
||||
child: LoadingManager(
|
||||
isLoading: _visitsProvider.isLoading,
|
||||
isFailedLoading: _visitsProvider.ppms == null,
|
||||
stateCode: _visitsProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
_visitsProvider.reset();
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
);
|
||||
},
|
||||
child: _visitsProvider.ppms.isEmpty
|
||||
? NoItemFound(message: context.translation.noVisitsFound)
|
||||
: LazyLoading(
|
||||
nextPage: _visitsProvider.nextPage,
|
||||
onLazyLoad: () async {
|
||||
await _visitsProvider.getVisits(user: _userProvider.user, host: _settingProvider.host);
|
||||
},
|
||||
child: ListView.builder(
|
||||
itemCount: _visitsProvider.ppms.length,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
itemBuilder: (context, itemIndex) {
|
||||
Ppm ppm = _visitsProvider.ppms[itemIndex];
|
||||
return Padding(padding: const EdgeInsets.only(bottom: 8.0), child: PpmItem(ppm: ppm));
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/ppm/ppm.dart';
|
||||
|
||||
class FutureEditPpm extends StatefulWidget {
|
||||
final Ppm ppm;
|
||||
|
||||
const FutureEditPpm({Key key, this.ppm}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FutureEditPpm> createState() => _FutureEditPpmState();
|
||||
}
|
||||
|
||||
class _FutureEditPpmState extends State<FutureEditPpm> {
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
//String requestId = ModalRoute.of(context).settings.arguments;
|
||||
|
||||
// return Scaffold(
|
||||
// body: FutureBuilder<Pentry>(
|
||||
// future: RegularVisitsProvider().getPentry(user: _userProvider.user, host: _settingProvider.host, id: widget.ppm.id),
|
||||
// builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot) {
|
||||
// if (snapshot.hasError) {
|
||||
// return FailedLoading(
|
||||
// message: context.translation.failedToCompleteRequest,
|
||||
// onReload: () {
|
||||
// setState(() {});
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// if (snapshot.hasData) {
|
||||
// return EditPentry(
|
||||
// pentry: snapshot.data,
|
||||
// ppm: widget.ppm,
|
||||
// );
|
||||
// }
|
||||
// return const Center(child: ALoading());
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/regular_visits_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/pantry/pentry.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
import 'package:test_sa/views/pages/user/visits/pantry/edit_pentry.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
|
||||
|
||||
class FutureEditPentry extends StatefulWidget {
|
||||
final Visit visit;
|
||||
|
||||
const FutureEditPentry({Key key, this.visit}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FutureEditPentry> createState() => _FutureEditPentryState();
|
||||
}
|
||||
|
||||
class _FutureEditPentryState extends State<FutureEditPentry> {
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
//String requestId = ModalRoute.of(context).settings.arguments;
|
||||
|
||||
return Scaffold(
|
||||
body: FutureBuilder<Pentry>(
|
||||
future: RegularVisitsProvider().getPentry(user: _userProvider.user, host: _settingProvider.host, id: widget.visit.id),
|
||||
builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return FailedLoading(
|
||||
message: context.translation.failedToCompleteRequest,
|
||||
onReload: () {
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
return EditPentry(
|
||||
pentry: snapshot.data,
|
||||
visit: widget.visit,
|
||||
);
|
||||
}
|
||||
return const Center(child: ALoading());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
|
||||
import 'package:test_sa/controllers/providers/api/preventive_maintenance_visits_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/visits/visits_group.dart';
|
||||
import 'package:test_sa/models/visits/visits_search.dart';
|
||||
import 'package:test_sa/views/pages/user/visits/update_visits_group_sheet.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/search/visits_search_bar.dart';
|
||||
import 'package:test_sa/views/widgets/visits/visits_list.dart';
|
||||
|
||||
class PreventiveMaintenanceVisitsPage extends StatefulWidget {
|
||||
static final String id = "/preventive-maintenance-visits";
|
||||
|
||||
@override
|
||||
_PreventiveMaintenanceVisitsPageState createState() => _PreventiveMaintenanceVisitsPageState();
|
||||
}
|
||||
|
||||
class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceVisitsPage> with TickerProviderStateMixin {
|
||||
PreventiveMaintenanceVisitsProvider _visitsProvider;
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_visitsProvider = Provider.of<PreventiveMaintenanceVisitsProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: LoadingManager(
|
||||
isLoading: _visitsProvider.isLoading,
|
||||
isFailedLoading: _visitsProvider.visits == null,
|
||||
stateCode: _visitsProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
//_visitsProvider.visitsSearch = VisitsSearch();
|
||||
_visitsProvider.reset();
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
//visitsSearch: _visitsSearch
|
||||
);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
// color: AColors.primaryColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
ABackButton(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
context.translation.preventiveMaintenance,
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
||||
),
|
||||
),
|
||||
),
|
||||
AIconButton(
|
||||
iconData: Icons.search,
|
||||
// color: AColors.secondaryColor,
|
||||
buttonSize: 42,
|
||||
// backgroundColor: AColors.white,
|
||||
onPressed: () async {
|
||||
VisitsSearch _temp = await showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return VisitsSearchDialog(
|
||||
initialSearchValue: _visitsProvider.visitsSearch,
|
||||
);
|
||||
});
|
||||
if (_temp != null) {
|
||||
_visitsProvider.visitsSearch = _temp;
|
||||
_visitsProvider.reset();
|
||||
setState(() {});
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
//visitsSearch: _visitsSearch
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: _visitsProvider.visitsSearch.toMap().isNotEmpty,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: AButton(
|
||||
text: context.translation.clearSearch,
|
||||
onPressed: () {
|
||||
_visitsProvider.visitsSearch = VisitsSearch();
|
||||
_visitsProvider.reset();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: VisitsList(
|
||||
nextPage: _visitsProvider.nextPage,
|
||||
onLazyLoad: () async {
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
//visitsSearch: _visitsSearch
|
||||
);
|
||||
},
|
||||
onEditGroup: (visits) async {
|
||||
VisitsGroup _group = await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return UpdateVisitsGroupSheet(
|
||||
visits: visits,
|
||||
title: context.translation.updatePreventiveMaintenance,
|
||||
);
|
||||
},
|
||||
) as VisitsGroup;
|
||||
if (_group != null) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(context.translation.updatingDots),
|
||||
content: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
},
|
||||
);
|
||||
int status = await _visitsProvider.updateGroupOfVisits(user: _userProvider.user, host: _settingProvider.host, group: _group);
|
||||
Navigator.of(context).pop();
|
||||
if (status >= 200 && status < 300) {
|
||||
Fluttertoast.showToast(
|
||||
msg: context.translation.preventiveMaintenanceUpdatedSuccessfully,
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation),
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
visits: _visitsProvider.visits,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,225 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
|
||||
import 'package:test_sa/controllers/providers/api/regular_visits_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/visits/visits_group.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/views/pages/user/visits/update_visits_group_sheet.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/visits/visits_list.dart';
|
||||
|
||||
class RegularVisitsPage extends StatefulWidget {
|
||||
static final String id = "/Regular-visits";
|
||||
|
||||
@override
|
||||
_RegularVisitsPageState createState() => _RegularVisitsPageState();
|
||||
}
|
||||
|
||||
class _RegularVisitsPageState extends State<RegularVisitsPage> with TickerProviderStateMixin {
|
||||
RegularVisitsProvider _visitsProvider;
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
bool _expandedSearch = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_visitsProvider = Provider.of<RegularVisitsProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
|
||||
body: SafeArea(
|
||||
child: LoadingManager(
|
||||
isLoading: _visitsProvider.isLoading,
|
||||
isFailedLoading: _visitsProvider.visits == null,
|
||||
stateCode: _visitsProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
_visitsProvider.reset();
|
||||
//_visitsProvider.visitsSearch = VisitsSearch();
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
);
|
||||
},
|
||||
child: VisitsList(
|
||||
nextPage: _visitsProvider.nextPage,
|
||||
onLazyLoad: () async {
|
||||
await _visitsProvider.getVisits(
|
||||
user: _userProvider.user,
|
||||
host: _settingProvider.host,
|
||||
);
|
||||
},
|
||||
onEditGroup: (visits) async {
|
||||
VisitsGroup group = await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return UpdateVisitsGroupSheet(
|
||||
visits: visits,
|
||||
title: context.translation.updateRegularVisits,
|
||||
);
|
||||
},
|
||||
) as VisitsGroup;
|
||||
if (group != null) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(context.translation.updatingDots),
|
||||
content: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
},
|
||||
);
|
||||
int status = await _visitsProvider.updateGroupOfVisits(user: _userProvider.user, host: _settingProvider.host, group: group);
|
||||
Navigator.of(context).pop();
|
||||
if (status >= 200 && status < 300) {
|
||||
Fluttertoast.showToast(
|
||||
msg: context.translation.preventiveMaintenanceUpdatedSuccessfully,
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation),
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
visits: _visitsProvider.visits,
|
||||
),
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// Column(
|
||||
// children: [
|
||||
// Container(
|
||||
// color: AColors.primaryColor,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// ABackButton(),
|
||||
// Expanded(
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// context.translation.preventiveMaintenance,
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// AnimatedSwitcher(
|
||||
// duration: Duration(milliseconds: 400),
|
||||
// child: AIconButton(
|
||||
// key: ValueKey(_expandedSearch),
|
||||
// iconData: _expandedSearch ? Icons.keyboard_arrow_up : Icons.search,
|
||||
// color: AColors.secondaryColor,
|
||||
// buttonSize: 42,
|
||||
// backgroundColor: AColors.white,
|
||||
// onPressed: () async {
|
||||
// VisitsSearch _temp = await showModalBottomSheet(
|
||||
// context: context,
|
||||
// isScrollControlled: true,
|
||||
// builder: (context) {
|
||||
// return VisitsSearchDialog(
|
||||
// initialSearchValue: _visitsProvider.visitsSearch,
|
||||
// );
|
||||
// });
|
||||
// if (_temp != null) {
|
||||
// _visitsProvider.visitsSearch.fromSearch(_temp);
|
||||
// _visitsProvider.reset();
|
||||
// setState(() {});
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: 16,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: (_visitsProvider.visitsSearch.toMap()..remove("mostRecent")).isNotEmpty,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: AButton(
|
||||
// text: context.translation.clearSearch,
|
||||
// onPressed: () {
|
||||
// _visitsProvider.visitsSearch = VisitsSearch();
|
||||
// _visitsProvider.reset();
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: VisitsList(
|
||||
// nextPage: _visitsProvider.nextPage,
|
||||
// onLazyLoad: () async {
|
||||
// await _visitsProvider.getVisits(
|
||||
// user: _userProvider.user,
|
||||
// host: _settingProvider.host,
|
||||
// );
|
||||
// },
|
||||
// onEditGroup: (visits) async {
|
||||
// VisitsGroup _group = await showModalBottomSheet(
|
||||
// isScrollControlled: true,
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return UpdateVisitsGroupSheet(
|
||||
// visits: visits,
|
||||
// title: context.translation.updateRegularVisits,
|
||||
// );
|
||||
// },
|
||||
// ) as VisitsGroup;
|
||||
// if (_group != null) {
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// barrierDismissible: false,
|
||||
// builder: (BuildContext context) {
|
||||
// return CupertinoAlertDialog(
|
||||
// title: Text(context.translation.updatingDots),
|
||||
// content: Center(child: CircularProgressIndicator()),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// int status = await _visitsProvider.updateGroupOfVisits(user: _userProvider.user, host: _settingProvider.host, group: _group);
|
||||
// Navigator.of(context).pop();
|
||||
// if (status >= 200 && status < 300) {
|
||||
// Fluttertoast.showToast(
|
||||
// msg: context.translation.preventiveMaintenanceUpdatedSuccessfully,
|
||||
// toastLength: Toast.LENGTH_LONG,
|
||||
// gravity: ToastGravity.BOTTOM,
|
||||
// );
|
||||
// } else {
|
||||
// Fluttertoast.showToast(
|
||||
// msg: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation),
|
||||
// toastLength: Toast.LENGTH_LONG,
|
||||
// gravity: ToastGravity.BOTTOM,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// visits: _visitsProvider.visits,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,242 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
import 'package:test_sa/models/visits/visits_group.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/status/employee/engineers_mune.dart';
|
||||
import 'package:test_sa/views/widgets/visits/visit_status.dart';
|
||||
|
||||
class UpdateVisitsGroupSheet extends StatefulWidget {
|
||||
final List<Visit> visits;
|
||||
final String title;
|
||||
|
||||
const UpdateVisitsGroupSheet({Key key, this.visits, this.title}) : super(key: key);
|
||||
|
||||
@override
|
||||
_UpdateVisitsGroupSheetState createState() => _UpdateVisitsGroupSheetState();
|
||||
}
|
||||
|
||||
class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
|
||||
// List<Lookup> status = [
|
||||
// Lookup(name: "Done", id: 0,),
|
||||
// Lookup(name: "Not Yet", id: 1),
|
||||
// Lookup(name: "On Hold", id: 2,),
|
||||
// ];
|
||||
//
|
||||
// List<Lookup> taskStatus = [
|
||||
// Lookup(name: "Passed", id: 0,),
|
||||
// Lookup(name: "Failed", id: 1),
|
||||
// ];
|
||||
VisitsGroup _group = VisitsGroup();
|
||||
|
||||
// File _image;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_group.visits = widget.visits;
|
||||
//_group.date = DateTime.now();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.0 * AppStyle.getScaleFactor(context),
|
||||
vertical: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.title ?? context.translation.updateVisitsGroup,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
EngineersMenu(
|
||||
initialValue: _group.engineer,
|
||||
onSelect: (engineer) {
|
||||
_group.engineer = engineer;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// AOneImagePicker(
|
||||
// image: _image,
|
||||
// onPick: (image){
|
||||
// _image =image;
|
||||
// _group.image = base64Encode(image.readAsBytesSync());
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 12 * AppStyle.getScaleFactor(context),),
|
||||
// ATextFormField(
|
||||
// initialValue: _group.jobSheetNumber,
|
||||
// hintText: _subtitle.jobSheetNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// onSaved: (value){
|
||||
// _group.jobSheetNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
||||
// ATextFormField(
|
||||
// initialValue: _group.workingHours,
|
||||
// hintText: _subtitle.workingHours,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// onSaved: (value){
|
||||
// _group.workingHours = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
||||
// ATextFormField(
|
||||
// initialValue: _group.travelingHours,
|
||||
// hintText: _subtitle.travelingHours,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// onSaved: (value){
|
||||
// _group.travelingHours = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// "${_subtitle.date} :",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// ADatePicker(
|
||||
// date: _group.date ?? DateTime.now(),
|
||||
// onDatePicker: (date){
|
||||
// _group.date = date;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// // SizedBox(height: 8 * AStyling.getScaleFactor(context),),
|
||||
// Text(
|
||||
// "${_subtitle.status} :",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
||||
// Center(
|
||||
// child: Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// status.length,
|
||||
// (index) {
|
||||
// bool isSelected = _group.status == status[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected)
|
||||
// _group.status = null;
|
||||
// else
|
||||
// _group.status = status[index];
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: status[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// "${_subtitle.taskStatus} :",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
||||
// Center(
|
||||
// child: Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// taskStatus.length,
|
||||
// (index) {
|
||||
// bool isSelected = _group.taskStatus == taskStatus[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected)
|
||||
// _group.taskStatus = null;
|
||||
// else
|
||||
// _group.taskStatus = taskStatus[index];
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: taskStatus[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: widget.visits.length,
|
||||
itemBuilder: (context, index) {
|
||||
Visit visit = widget.visits[index];
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
margin: EdgeInsets.symmetric(vertical: 4),
|
||||
// decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [AppStyle.boxShadow]),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${context.translation.sn}: " + visit.deviceSerialNumber ?? context.translation.noSerialNumberFound,
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
VisitStatusLabel(
|
||||
visit: visit,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
AButton(
|
||||
text: context.translation.update,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(_group);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,334 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_search.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
|
||||
import '../switch_button.dart';
|
||||
|
||||
class PpmSearchDialog extends StatefulWidget {
|
||||
final PpmSearch initialSearchValue;
|
||||
final bool expandedSearch;
|
||||
final Function(PpmSearch) onSearch;
|
||||
|
||||
const PpmSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PpmSearchDialogState createState() => _PpmSearchDialogState();
|
||||
}
|
||||
|
||||
class _PpmSearchDialogState extends State<PpmSearchDialog> with TickerProviderStateMixin {
|
||||
PpmSearch _search;
|
||||
List<Lookup> status = [
|
||||
Lookup(
|
||||
name: "Done",
|
||||
id: 0,
|
||||
),
|
||||
Lookup(name: "Not Yet", id: 1),
|
||||
Lookup(
|
||||
name: "On Hold",
|
||||
id: 2,
|
||||
),
|
||||
];
|
||||
|
||||
List<Lookup> contactStatus = [
|
||||
// Lookup(name: "Hospital Employee", value: "H",),
|
||||
// Lookup(name: "Under Warranty", value: "CW"),
|
||||
// Lookup(name: "Under Maintenance Contract", value: "CC",),
|
||||
];
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_search = PpmSearch();
|
||||
|
||||
/// todo : working
|
||||
// _search.fromSearch(widget.initialSearchValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime today = DateTime.now();
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
// shrinkWrap: true,
|
||||
// physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.search,
|
||||
onPressed: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
ASwitchButton(
|
||||
title: "Most Recent",
|
||||
value: _search.mostRecent ?? false,
|
||||
onChange: (value) {
|
||||
_search.mostRecent = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceNumber,
|
||||
// hintText: context.translation.assetNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceName,
|
||||
// hintText: context.translation.assetName,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceName = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceSerialNumber,
|
||||
// hintText: context.translation.serialNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceSerialNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// HospitalAutoCompleteField(
|
||||
// initialValue: _search.hospital?.name,
|
||||
// // onSave: (value){
|
||||
// // _search.hospital = value;
|
||||
// // },
|
||||
// onSearch: (value) {
|
||||
// _search.hospital = value;
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// // SizedBox(height: 8.0 * AppStyle.getScaleFactor(context),),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.brand,
|
||||
// // hintText: _subtitle.brand,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: (){
|
||||
// // if(!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value){
|
||||
// // _search.brand = value;
|
||||
// // },
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// AutoCompleteModelField(
|
||||
// initialValue: _search.model,
|
||||
// onPick: (lookup) {
|
||||
// _search.model = lookup;
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.model,
|
||||
// // hintText: _subtitle.model,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: (){
|
||||
// // if(!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value){
|
||||
// // _search.model = value;
|
||||
// // },
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.status),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// PentryVisitsStatusMenu(
|
||||
// initialValue: _search.statusValue,
|
||||
// onSelect: (status) {
|
||||
// _search.statusValue = status;
|
||||
// },
|
||||
// ),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// status.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.statusValue == status[index].id;
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.statusValue = null;
|
||||
// } else {
|
||||
// _search.statusValue = status[index].id;
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: status[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.contactStatus),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// AssignedToMenu(
|
||||
// initialValue: _search.contactStatus,
|
||||
// onSelect: (status) {
|
||||
// _search.contactStatus = status;
|
||||
// },
|
||||
// ),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// contactStatus.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.contactStatus == contactStatus[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.contactStatus = null;
|
||||
// } else {
|
||||
// _search.contactStatus = contactStatus[index];
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: contactStatus[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.actualDate),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// FromToDateBar(
|
||||
// from: _search.actualDateFrom,
|
||||
// to: _search.actualDateTo,
|
||||
// onPickFrom: (date) {
|
||||
// _search.actualDateFrom = date;
|
||||
// },
|
||||
// onPickTo: (date) {
|
||||
// _search.actualDateTo = date;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.expectDate),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// FromToDateBar(
|
||||
// from: _search.expectedDateFrom ?? DateTime(today.year, today.month, 1),
|
||||
// to: _search.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
|
||||
// onPickFrom: (date) {
|
||||
// _search.expectedDateFrom = date;
|
||||
// },
|
||||
// onPickTo: (date) {
|
||||
// _search.expectedDateTo = date;
|
||||
// },
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: _search.toMap().isNotEmpty,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// child: AButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// text: context.translation.clearSearch,
|
||||
// onPressed: () {
|
||||
// _search = VisitsSearch();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,339 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/visits/visits_search.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/date_and_time/from_to_date_bar.dart';
|
||||
import 'package:test_sa/views/widgets/equipment/auto_complete_models_field.dart';
|
||||
import 'package:test_sa/views/widgets/hospitals/hospital_auto_complete_field.dart';
|
||||
import 'package:test_sa/views/widgets/status/employee/assigned_to_mune.dart';
|
||||
import 'package:test_sa/views/widgets/status/pentry/pentry_visit_status_mune.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
|
||||
import '../app_text_form_field.dart';
|
||||
import '../switch_button.dart';
|
||||
|
||||
class VisitsSearchDialog extends StatefulWidget {
|
||||
final VisitsSearch initialSearchValue;
|
||||
final bool expandedSearch;
|
||||
final Function(VisitsSearch) onSearch;
|
||||
|
||||
const VisitsSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
_VisitsSearchDialogState createState() => _VisitsSearchDialogState();
|
||||
}
|
||||
|
||||
class _VisitsSearchDialogState extends State<VisitsSearchDialog> with TickerProviderStateMixin {
|
||||
VisitsSearch _search;
|
||||
List<Lookup> status = [
|
||||
Lookup(
|
||||
name: "Done",
|
||||
id: 0,
|
||||
),
|
||||
Lookup(name: "Not Yet", id: 1),
|
||||
Lookup(
|
||||
name: "On Hold",
|
||||
id: 2,
|
||||
),
|
||||
];
|
||||
|
||||
List<Lookup> contactStatus = [
|
||||
// Lookup(name: "Hospital Employee", value: "H",),
|
||||
// Lookup(name: "Under Warranty", value: "CW"),
|
||||
// Lookup(name: "Under Maintenance Contract", value: "CC",),
|
||||
];
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_search = VisitsSearch();
|
||||
_search.fromSearch(widget.initialSearchValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime today = DateTime.now();
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
// shrinkWrap: true,
|
||||
// physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.search,
|
||||
onPressed: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
ASwitchButton(
|
||||
title: "Most Recent",
|
||||
value: _search.mostRecent ?? false,
|
||||
onChange: (value) {
|
||||
_search.mostRecent = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceNumber,
|
||||
hintText: context.translation.assetNumber,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceNumber = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceName,
|
||||
hintText: context.translation.assetName,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceName = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceSerialNumber,
|
||||
hintText: context.translation.serialNumber,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceSerialNumber = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
HospitalAutoCompleteField(
|
||||
initialValue: _search.hospital?.name,
|
||||
// onSave: (value){
|
||||
// _search.hospital = value;
|
||||
// },
|
||||
onSearch: (value) {
|
||||
_search.hospital = value;
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
),
|
||||
// SizedBox(height: 8.0 * AppStyle.getScaleFactor(context),),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.brand,
|
||||
// hintText: _subtitle.brand,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: (){
|
||||
// if(!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value){
|
||||
// _search.brand = value;
|
||||
// },
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
AutoCompleteModelField(
|
||||
initialValue: _search.model,
|
||||
onPick: (lookup) {
|
||||
_search.model = lookup;
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.model,
|
||||
// hintText: _subtitle.model,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: (){
|
||||
// if(!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value){
|
||||
// _search.model = value;
|
||||
// },
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.status),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
PentryVisitsStatusMenu(
|
||||
initialValue: _search.statusValue,
|
||||
onSelect: (status) {
|
||||
_search.statusValue = status;
|
||||
},
|
||||
),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// status.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.statusValue == status[index].id;
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.statusValue = null;
|
||||
// } else {
|
||||
// _search.statusValue = status[index].id;
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: status[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.contactStatus),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
AssignedToMenu(
|
||||
initialValue: _search.contactStatus,
|
||||
onSelect: (status) {
|
||||
_search.contactStatus = status;
|
||||
},
|
||||
),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// contactStatus.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.contactStatus == contactStatus[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.contactStatus = null;
|
||||
// } else {
|
||||
// _search.contactStatus = contactStatus[index];
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: contactStatus[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.actualDate),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
FromToDateBar(
|
||||
from: _search.actualDateFrom,
|
||||
to: _search.actualDateTo,
|
||||
onPickFrom: (date) {
|
||||
_search.actualDateFrom = date;
|
||||
},
|
||||
onPickTo: (date) {
|
||||
_search.actualDateTo = date;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.expectDate),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
FromToDateBar(
|
||||
from: _search.expectedDateFrom ?? DateTime(today.year, today.month, 1),
|
||||
to: _search.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
|
||||
onPickFrom: (date) {
|
||||
_search.expectedDateFrom = date;
|
||||
},
|
||||
onPickTo: (date) {
|
||||
_search.expectedDateTo = date;
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: _search.toMap().isNotEmpty,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: AButton(
|
||||
padding: EdgeInsets.zero,
|
||||
text: context.translation.clearSearch,
|
||||
onPressed: () {
|
||||
_search = VisitsSearch();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class VisitStatusLabel extends StatelessWidget {
|
||||
final Visit visit;
|
||||
|
||||
const VisitStatusLabel({Key key, this.visit}) : super(key: key);
|
||||
|
||||
// Color getStatusColor() {
|
||||
// switch (visit.status.id) {
|
||||
// case 0:
|
||||
// return AColors.green;
|
||||
// case 1:
|
||||
// return AColors.grey;
|
||||
// case 2:
|
||||
// return AColors.grey;
|
||||
// default:
|
||||
// return AColors.grey;
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 2, horizontal: 8),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(/*color: getStatusColor(),*/ borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [AppStyle.boxShadow]),
|
||||
child: Text(
|
||||
visit.status.name == null || visit.status.name.isEmpty ? "no status" : visit.status.name,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: getStatusColor().computeLuminance() > 0.5 ? AColors.black : Colors.white,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/visits/visit.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
||||
import 'package:test_sa/views/widgets/visits/visit_item.dart';
|
||||
|
||||
import '../../../controllers/providers/api/user_provider.dart';
|
||||
|
||||
class VisitsList extends StatefulWidget {
|
||||
final List<Visit> visits;
|
||||
final bool nextPage;
|
||||
final Future<void> Function() onLazyLoad;
|
||||
final Function(List<Visit>) onEditGroup;
|
||||
|
||||
const VisitsList({Key key, this.visits, this.nextPage, this.onLazyLoad, this.onEditGroup}) : super(key: key);
|
||||
|
||||
@override
|
||||
_VisitsListState createState() => _VisitsListState();
|
||||
}
|
||||
|
||||
class _VisitsListState extends State<VisitsList> {
|
||||
final List<Visit> _selectedVisits = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_selectedVisits.clear();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserProvider userProvider = Provider.of<UserProvider>(context);
|
||||
if (widget.visits.isEmpty) {
|
||||
return NoItemFound(message: context.translation.noVisitsFound);
|
||||
}
|
||||
return Stack(
|
||||
children: [
|
||||
LazyLoading(
|
||||
nextPage: widget.nextPage,
|
||||
onLazyLoad: widget.onLazyLoad,
|
||||
child: ListView.builder(
|
||||
itemCount: widget.visits.length,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
itemBuilder: (context, itemIndex) {
|
||||
Visit visit = widget.visits[itemIndex];
|
||||
// bool isSelected = _selectedVisits.contains(visit);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: VisitItem(visit: visit),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Align(
|
||||
// alignment: Alignment.bottomLeft,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.all(8.0 * AppStyle.getScaleFactor(context)),
|
||||
// child: AnimatedSwitcher(
|
||||
// duration: const Duration(milliseconds: 400),
|
||||
// child: Visibility(
|
||||
// key: ValueKey(_selectedVisits.isNotEmpty),
|
||||
// visible: _selectedVisits.isNotEmpty,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// FloatingActionButton(
|
||||
// heroTag: "cancel",
|
||||
// child: const Icon(Icons.cancel),
|
||||
// onPressed: () {
|
||||
// _selectedVisits.clear();
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// FloatingActionButton(
|
||||
// heroTag: "edit",
|
||||
// child: const Icon(Icons.edit),
|
||||
// onPressed: () {
|
||||
// if (!widget.visits.contains(_selectedVisits.first)) {
|
||||
// _selectedVisits.clear();
|
||||
// setState(() {});
|
||||
// return;
|
||||
// }
|
||||
// widget.onEditGroup(_selectedVisits);
|
||||
// //_selectedVisits.clear();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue