ppm model improvement.

design_3.0_latest
Sikander Saleem 9 months ago
parent 0a8b3314ce
commit 2cd5777f55

@ -108,6 +108,9 @@ class URLs {
static get getRegularVisits => "$_baseUrl/Visit/GetVisits"; // get
static get updateRegularVisits => "$_baseUrl/Visit/UpdateVisits"; // get
static get getPlanPreventiveVisitById => "$_baseUrl/PlanPreventiveVisit/GetPlanPreventiveVisitById"; // get
static get updateVisitByEngineer => "$_baseUrl/PlanPreventiveVisit/UpdateVisitByEngineer"; // get
static get getSingleServiceRequest => "$_baseUrl/return/call/information"; // get
static get getSuppliersAutoComplete => "$_baseUrl/Supplier/GetSuppliersAutoComplete";

@ -7,6 +7,7 @@ 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/extensions/context_extension.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm.dart';
import 'package:test_sa/models/ppm/ppm_search.dart';
import 'package:test_sa/models/user.dart';
@ -99,23 +100,72 @@ class PpmProvider extends ChangeNotifier {
notifyListeners();
return response.statusCode;
}
Future<Ppm?> getPpmById(num id) async {
// Return type is nullable
try {
visitsSearch.id = id;
visitsSearch.pageNumber = 1;
visitsSearch.pageSize = 3;
Response response = await ApiManager.instance.post(URLs.getRegularVisits, body: visitsSearch.toJson());
//
// Future<Ppm?> getPpmById(num id) async {
// // Return type is nullable
// try {
// visitsSearch.id = id;
// visitsSearch.pageNumber = 1;
// visitsSearch.pageSize = 3;
// Response response = await ApiManager.instance.post(URLs.getRegularVisits, body: visitsSearch.toJson());
//
// if (response.statusCode >= 200 && response.statusCode < 300) {
// List requestsListJson = json.decode(response.body)["data"];
// List<Ppm> visits = requestsListJson.map((request) => Ppm.fromJson(request)).toList();
// return visits.firstWhere((element) => id == element.id, orElse: null); // Handle case where no element is found
// }
// return null;
// } catch (error) {
// return null;
// }
// }
Future<PlanPreventiveVisit?> getPlanPreventiveVisitById(int id) async {
// try {
Response response = await ApiManager.instance.get(URLs.getPlanPreventiveVisitById + "?planPreventiveVisitId=$id");
if (response.statusCode >= 200 && response.statusCode < 300) {
List requestsListJson = json.decode(response.body)["data"];
List<Ppm> visits = requestsListJson.map((request) => Ppm.fromJson(request)).toList();
return visits.firstWhere((element) => id == element.id, orElse: null); // Handle case where no element is found
return PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]);
// List requestsListJson = json.decode(response.body)["data"];
// List<Ppm> visits = requestsListJson.map((request) => Ppm.fromJson(request)).toList();
// return visits.firstWhere((element) => id == element.id, orElse: null); // Handle case where no element is found
}
return null;
// } catch (error) {
// return null;
// }
}
Future<int> updateVisitByEngineer(BuildContext context, {required User user, required Ppm ppm}) async {
try {
ppm.visitTimers?.add(
VisitTimers(
id: 0,
startDateTime: ppm.tbsTimer?.startAt!.toIso8601String(), // Handle potential null
endDateTime: ppm.tbsTimer?.endAt?.toIso8601String(), // Handle potential null
workingHours: ((ppm.tbsTimer?.durationInSecond ?? 0) / 60 / 60),
),
);
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
late Response response; // Using 'late' for initialization later
Map<String, dynamic> body = ppm.copyWith(assignedEmployeeId: user.userName, tbsTimer: ppm.tbsTimer).toJson();
response = await ApiManager.instance.put(URLs.updateVisitByEngineer, body: body);
if (response.statusCode >= 200 && response.statusCode < 300) {
reset(); //visit.status = pentry.ppmVisitStatus;
notifyListeners();
Fluttertoast.showToast(msg: context.translation.successfulRequestMessage);
Navigator.of(context).pop();
} else {
Fluttertoast.showToast(msg: "${context.translation.failedToCompleteRequest} ${jsonDecode(response.body)["message"]}");
}
Navigator.of(context).pop();
return response.statusCode;
} catch (error) {
return null;
return -1;
}
}

@ -0,0 +1,421 @@
import 'package:flutter/widgets.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/timer_model.dart';
class PlanPreventiveVisit {
String? id;
String? visitNo;
Asset? asset;
String? planNo;
String? planName;
String? nextPMDate;
String? assetName;
String? model;
String? manufacturer;
String? supplierName;
String? siteName;
String? buildingName;
String? floorName;
String? departmentName;
String? roomName;
String? fromDate;
String? toDate;
AssignedEmployee? assignedEmployee;
String? acutalDateOfVisit;
TypeOfService? typeOfService;
VisitStatus? visitStatus;
String? travelingHours;
String? comments;
int? executionTimeFrame;
Lookup? taskStatus;
String? deviceStatus;
Lookup? assetAvailability;
Lookup? safety;
String? engSignature;
String? nurseSignature;
List<PreventiveVisitChecklists>? preventiveVisitAttachments;
List<PreventiveVisitChecklists>? preventiveVisitCalibrations;
List<PreventiveVisitChecklists>? preventiveVisitChecklists;
List<PreventiveVisitChecklists>? preventiveVisitKits;
List<PreventiveVisitTimers>? preventiveVisitTimers;
List<PreventiveVisitChecklists>? preventiveVisitSuppliers;
TimerModel? tbsTimer = TimerModel();
PlanPreventiveVisit(
{this.id,
this.visitNo,
this.asset,
this.planNo,
this.planName,
this.nextPMDate,
this.assetName,
this.model,
this.manufacturer,
this.supplierName,
this.siteName,
this.buildingName,
this.floorName,
this.departmentName,
this.roomName,
this.fromDate,
this.toDate,
this.assignedEmployee,
this.acutalDateOfVisit,
this.typeOfService,
this.visitStatus,
this.travelingHours,
this.comments,
this.executionTimeFrame,
this.taskStatus,
this.deviceStatus,
this.assetAvailability,
this.safety,
this.engSignature,
this.nurseSignature,
this.preventiveVisitAttachments,
this.preventiveVisitCalibrations,
this.preventiveVisitChecklists,
this.preventiveVisitKits,
this.preventiveVisitTimers,
this.preventiveVisitSuppliers});
PlanPreventiveVisit.fromJson(Map<String, dynamic> json) {
id = json['id'];
visitNo = json['visitNo'];
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
planNo = json['planNo'];
planName = json['planName'];
nextPMDate = json['nextPMDate'];
assetName = json['assetName'];
model = json['model'];
manufacturer = json['manufacturer'];
supplierName = json['supplierName'];
siteName = json['siteName'];
buildingName = json['buildingName'];
floorName = json['floorName'];
departmentName = json['departmentName'];
roomName = json['roomName'];
fromDate = json['fromDate'];
toDate = json['toDate'];
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
acutalDateOfVisit = json['acutalDateOfVisit'];
typeOfService = json['typeOfService'] != null ? new TypeOfService.fromJson(json['typeOfService']) : null;
visitStatus = json['visitStatus'] != null ? new VisitStatus.fromJson(json['visitStatus']) : null;
travelingHours = json['travelingHours'];
comments = json['comments'];
executionTimeFrame = json['executionTimeFrame'];
taskStatus = json['taskStatus'];
deviceStatus = json['deviceStatus'];
assetAvailability = json['assetAvailability'];
safety = json['safety'];
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
if (json['preventiveVisitAttachments'] != null) {
preventiveVisitAttachments = <PreventiveVisitChecklists>[];
json['preventiveVisitAttachments'].forEach((v) {
preventiveVisitAttachments!.add(PreventiveVisitChecklists.fromJson(v));
});
}
if (json['preventiveVisitCalibrations'] != null) {
preventiveVisitCalibrations = <PreventiveVisitChecklists>[];
json['preventiveVisitCalibrations'].forEach((v) {
preventiveVisitCalibrations!.add(new PreventiveVisitChecklists.fromJson(v));
});
}
if (json['preventiveVisitChecklists'] != null) {
preventiveVisitChecklists = <PreventiveVisitChecklists>[];
json['preventiveVisitChecklists'].forEach((v) {
preventiveVisitChecklists!.add(new PreventiveVisitChecklists.fromJson(v));
});
}
if (json['preventiveVisitKits'] != null) {
preventiveVisitKits = <PreventiveVisitChecklists>[];
json['preventiveVisitKits'].forEach((v) {
preventiveVisitKits!.add(new PreventiveVisitChecklists.fromJson(v));
});
}
if (json['preventiveVisitTimers'] != null) {
preventiveVisitTimers = <PreventiveVisitTimers>[];
json['preventiveVisitTimers'].forEach((v) {
preventiveVisitTimers!.add(new PreventiveVisitTimers.fromJson(v));
});
}
if (json['preventiveVisitSuppliers'] != null) {
preventiveVisitSuppliers = <PreventiveVisitChecklists>[];
json['preventiveVisitSuppliers'].forEach((v) {
preventiveVisitSuppliers!.add(new PreventiveVisitChecklists.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['visitNo'] = this.visitNo;
if (this.asset != null) {
data['asset'] = this.asset!.toJson();
}
data['planNo'] = this.planNo;
data['planName'] = this.planName;
data['nextPMDate'] = this.nextPMDate;
data['assetName'] = this.assetName;
data['model'] = this.model;
data['manufacturer'] = this.manufacturer;
data['supplierName'] = this.supplierName;
data['siteName'] = this.siteName;
data['buildingName'] = this.buildingName;
data['floorName'] = this.floorName;
data['departmentName'] = this.departmentName;
data['roomName'] = this.roomName;
data['fromDate'] = this.fromDate;
data['toDate'] = this.toDate;
if (this.assignedEmployee != null) {
data['assignedEmployee'] = this.assignedEmployee!.toJson();
}
data['acutalDateOfVisit'] = this.acutalDateOfVisit;
if (this.typeOfService != null) {
data['typeOfService'] = this.typeOfService!.toJson();
}
if (this.visitStatus != null) {
data['visitStatus'] = this.visitStatus!.toJson();
}
data['travelingHours'] = this.travelingHours;
data['comments'] = this.comments;
data['executionTimeFrame'] = this.executionTimeFrame;
data['taskStatus'] = this.taskStatus;
data['deviceStatus'] = this.deviceStatus;
data['assetAvailability'] = this.assetAvailability;
data['safety'] = this.safety;
data['engSignature'] = this.engSignature;
data['nurseSignature'] = this.nurseSignature;
if (this.preventiveVisitAttachments != null) {
data['preventiveVisitAttachments'] = this.preventiveVisitAttachments!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitCalibrations != null) {
data['preventiveVisitCalibrations'] = this.preventiveVisitCalibrations!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitChecklists != null) {
data['preventiveVisitChecklists'] = this.preventiveVisitChecklists!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitKits != null) {
data['preventiveVisitKits'] = this.preventiveVisitKits!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitTimers != null) {
data['preventiveVisitTimers'] = this.preventiveVisitTimers!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitSuppliers != null) {
data['preventiveVisitSuppliers'] = this.preventiveVisitSuppliers!.map((v) => v.toJson()).toList();
}
return data;
}
bool _isLocalUrl(String url) {
if (url.isEmpty != false) return false;
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
}
Future<bool> validate(BuildContext context) async {
if (visitStatus?.id == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.status}");
return false;
}
if (acutalDateOfVisit == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.actualDate}");
return false;
}
// if (expectedDate == null) {
// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.visitDate}");
// return false;
// }
if (tbsTimer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
}
if (tbsTimer?.endAt == null) {
await Fluttertoast.showToast(msg: "Please Stop The Timer");
return false;
}
// if (externalEngineerTimer?.startAt != null && externalEngineerTimer?.endAt == null) {
// await Fluttertoast.showToast(msg: "Please Stop External Engineer Timer");
// return false;
// }
return true;
}
void removeEmptyObjects() {
// if (vCalibrationTools?.isNotEmpty ?? false) vCalibrationTools!.removeWhere((element) => element.assetId == null && element.calibrationDateOfTesters == null);
// if (vKits?.isNotEmpty ?? false) vKits!.removeWhere((element) => element.partName == null && element.partNumber == null);
}
}
class Asset {
int? id;
String? assetNumber;
String? assetSerialNo;
Asset({this.id, this.assetNumber, this.assetSerialNo});
Asset.fromJson(Map<String, dynamic> json) {
id = json['id'];
assetNumber = json['assetNumber'];
assetSerialNo = json['assetSerialNo'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['assetNumber'] = this.assetNumber;
data['assetSerialNo'] = this.assetSerialNo;
return data;
}
}
class AssignedEmployee {
String? userId;
String? userName;
String? email;
String? employeeId;
int? languageId;
AssignedEmployee({this.userId, this.userName, this.email, this.employeeId, this.languageId});
AssignedEmployee.fromJson(Map<String, dynamic> json) {
userId = json['userId'];
userName = json['userName'];
email = json['email'];
employeeId = json['employeeId'];
languageId = json['languageId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['userId'] = this.userId;
data['userName'] = this.userName;
data['email'] = this.email;
data['employeeId'] = this.employeeId;
data['languageId'] = this.languageId;
return data;
}
}
class TypeOfService {
int? id;
String? name;
int? value;
TypeOfService({this.id, this.name, this.value});
TypeOfService.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
return data;
}
}
class VisitStatus {
int? id;
String? name;
int? value;
VisitStatus({this.id, this.name, this.value});
VisitStatus.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
return data;
}
}
class PreventiveVisitChecklists {
int? id;
String? taskStatus;
String? taskComment;
String? measuredValue;
InstructionText? instructionText;
PreventiveVisitChecklists({this.id, this.taskStatus, this.taskComment, this.measuredValue, this.instructionText});
PreventiveVisitChecklists.fromJson(Map<String, dynamic> json) {
id = json['id'];
taskStatus = json['taskStatus'];
taskComment = json['taskComment'];
measuredValue = json['measuredValue'];
instructionText = json['instructionText'] != null ? new InstructionText.fromJson(json['instructionText']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['taskStatus'] = this.taskStatus;
data['taskComment'] = this.taskComment;
data['measuredValue'] = this.measuredValue;
if (this.instructionText != null) {
data['instructionText'] = this.instructionText!.toJson();
}
return data;
}
}
class InstructionText {
int? id;
String? text;
InstructionText({this.id, this.text});
InstructionText.fromJson(Map<String, dynamic> json) {
id = json['id'];
text = json['text'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['text'] = this.text;
return data;
}
}
class PreventiveVisitTimers {
int? id;
String? startDateTime;
String? endDateTime;
double? workingHours;
PreventiveVisitTimers({this.id, this.startDateTime, this.endDateTime, this.workingHours});
PreventiveVisitTimers.fromJson(Map<String, dynamic> json) {
id = json['id'];
startDateTime = json['startDateTime'];
endDateTime = json['endDateTime'];
workingHours = json['workingHours'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['startDateTime'] = startDateTime;
data['endDateTime'] = endDateTime;
data['workingHours'] = workingHours;
return data;
}
}

@ -7,15 +7,14 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/recurrent_work_order_view.dart';
import 'package:test_sa/views/pages/user/ppm/update_ppm/update_ppm.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
import '../../../../controllers/providers/api/user_provider.dart';
import '../../../../models/enums/user_types.dart';
import '../../../../models/ppm/ppm.dart';
import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/app_filled_button.dart';
import '../../../widgets/requests/request_status.dart';
@ -56,12 +55,12 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
body: SafeArea(
child: FutureBuilder(
future: ppmProvider!.getPpmById(widget.request.id!),
future: ppmProvider!.getPlanPreventiveVisitById(widget.request.id!),
builder: (context, snap) {
if (snap.connectionState == ConnectionState.waiting) {
return const ALoading();
} else if (snap.hasData) {
Ppm ppm = snap.data as Ppm;
PlanPreventiveVisit planPreventiveVisit = snap.data as PlanPreventiveVisit;
return Column(children: [
SingleChildScrollView(
@ -78,47 +77,46 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
),
if (widget.request.priority != null) 8.width,
StatusLabel(
label: ppm.visitStatusName,
id: ppm.visitStatusId!.toInt(),
textColor: AppColor.getRequestStatusTextColorByName(context, ppm.visitStatusName!),
backgroundColor: AppColor.getRequestStatusColorByName(context, ppm.visitStatusName!),
label: planPreventiveVisit.visitStatus!.name!,
id: planPreventiveVisit.visitStatus!.id!,
textColor: AppColor.getRequestStatusTextColorByName(context, planPreventiveVisit.visitStatus!.name!),
backgroundColor: AppColor.getRequestStatusColorByName(context, planPreventiveVisit.visitStatus!.name!),
),
1.width.expanded,
],
),
8.height,
ppm.assetName!.heading5(context),
planPreventiveVisit.assetName!.cleanupWhitespace.capitalizeFirstOfEach.heading5(context),
8.height,
'${context.translation.assetNumber}: ${ppm.assetNumber}'.bodyText(context),
'${context.translation.assetSN}: ${ppm.assetSerialNo}'.bodyText(context),
'${context.translation.requestNo}: ${ppm.visitCode}'.bodyText(context),
'${context.translation.assetNumber}: ${planPreventiveVisit.asset!.assetNumber}'.bodyText(context),
'${context.translation.assetSN}: ${planPreventiveVisit.asset!.assetSerialNo}'.bodyText(context),
'${context.translation.requestNo}: ${planPreventiveVisit.visitNo}'.bodyText(context),
const Divider().defaultStyle(context),
'${context.translation.expectDate}: ${ppm.expectedDate?.toAssetDetailsFormat ?? ""}'.bodyText(context),
'${context.translation.actualDate}: ${ppm.actualDate?.toAssetDetailsFormat ?? ""}'.bodyText(context),
// '${context.translation.expectDate}: ${planPreventiveVisit.expectedDate?.toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha,
'${context.translation.actualDate}: ${planPreventiveVisit.acutalDateOfVisit?.toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha,
const Divider().defaultStyle(context),
'${context.translation.assignedTo}: ${ppm.assignedToName ?? ""}'.bodyText(context),
'${context.translation.engineerName}: ${ppm.assignedEmployeeName ?? ""}'.bodyText(context),
'${context.translation.site}: ${ppm.siteName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.building}: ${ppm.buildingName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.floor}: ${ppm.floorName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.department}: ${ppm.departmentName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.room}: ${(ppm.roomName ?? "").cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.engineerName}: ${planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText(context), //todo @baha,
'${context.translation.site}: ${planPreventiveVisit.siteName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha,
'${context.translation.building}: ${planPreventiveVisit.buildingName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha,
'${context.translation.floor}: ${planPreventiveVisit.floorName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha,
'${context.translation.department}: ${planPreventiveVisit.departmentName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha,
'${context.translation.room}: ${(planPreventiveVisit.roomName ?? "").cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha,
],
).toShadowContainer(context).paddingAll(16),
).expanded,
if (userProvider!.user!.type == UsersTypes.engineer && (ppm.visitStatusId != 270 && ppm.visitStatusId != 269))
if (userProvider!.user!.type == UsersTypes.engineer && (planPreventiveVisit.visitStatus!.id! != 270 && planPreventiveVisit.visitStatus!.id! != 269))
AppFilledButton(
onPressed: () async {
//TODO remove after testing..
// await Navigator.of(context).push(MaterialPageRoute(builder: (_) => RecurrentWorkOrderView( request: widget.request)));
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: ppm, details: widget.request)));
setState(() {});
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request)));
// setState(() {});
},
label: context.translation.updateRequest,
).paddingAll(16)
]);
}
return NoDataFound(message: context.translation.noDataFound);
return NoDataFound(message: context.translation.noDataFound).center;
}),
),
);

@ -3,21 +3,15 @@ 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/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/ppm/ppm.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/service_request_latest/utilities/service_request_utils.dart';
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/asset_info_widget.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
class RecurrentWorkOrderView extends StatefulWidget {
static const String id = "/visit-details";
@ -58,14 +52,14 @@ class _RecurrentWorkOrderViewState extends State<RecurrentWorkOrderView> {
appBar: DefaultAppBar(title: context.translation.recurrentWo),
body: SafeArea(
child: FutureBuilder(
future: ppmProvider!.getPpmById(widget.request.id!),
future: ppmProvider!.getPlanPreventiveVisitById(widget.request.id!),
builder: (context, snap) {
if (snap.connectionState == ConnectionState.waiting) {
return const ALoading();
} else if (snap.hasData) {
Ppm ppm = snap.data as Ppm;
return Column(children: [
AssetInfoWidget(model: DummyModel(widget.request, ppm, timerModel, totalWorkingHours)),
AssetInfoWidget(model: DummyModel(widget.request, ppm, timerModel, totalWorkingHours)),
]).paddingAll(12);
}
return NoDataFound(message: context.translation.noDataFound);
@ -73,14 +67,13 @@ class _RecurrentWorkOrderViewState extends State<RecurrentWorkOrderView> {
),
);
}
}
class RoomTabs {
String label;
int tag;
int id;
//
RoomTabs({
required this.label,
@ -91,11 +84,11 @@ class RoomTabs {
static List<RoomTabs> getTabs({required UsersTypes userType, required BuildContext context}) {
List<RoomTabs> tabs = [];
tabs.add(RoomTabs(label: 'Upcoming', tag: 0, id: 0));
tabs.add(RoomTabs(label: 'UnAssigned Open', tag: 1, id: 1));
tabs.add(RoomTabs(label: 'Assigned Open', tag: 1, id: 2));
tabs.add(RoomTabs(label: 'In Progress', tag: 2, id: 3));
tabs.add(RoomTabs(label: 'Completed', tag: 3, id: 4));
return tabs;
tabs.add(RoomTabs(label: 'Upcoming', tag: 0, id: 0));
tabs.add(RoomTabs(label: 'UnAssigned Open', tag: 1, id: 1));
tabs.add(RoomTabs(label: 'Assigned Open', tag: 1, id: 2));
tabs.add(RoomTabs(label: 'In Progress', tag: 2, id: 3));
tabs.add(RoomTabs(label: 'Completed', tag: 3, id: 4));
return tabs;
}
}

@ -7,6 +7,7 @@ import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm_check_list.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
@ -16,8 +17,9 @@ import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
class PpmPmChecklistForm extends StatefulWidget {
final List<PpmChecklists>? models;
final List<PreventiveVisitChecklists>? checkList;
const PpmPmChecklistForm({Key? key, this.models}) : super(key: key);
const PpmPmChecklistForm({Key? key, this.models, this.checkList}) : super(key: key);
@override
State<PpmPmChecklistForm> createState() => _PpmPmChecklistFormState();
@ -30,7 +32,7 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
@override
Widget build(BuildContext context) {
SettingProvider settingProvider = Provider.of<SettingProvider>(context, listen: false);
List<PpmChecklists>? list = widget.models ?? [];
List<PreventiveVisitChecklists>? list = widget.checkList ?? [];
return (list.isEmpty)
? const NoDataFound().center
: ListView.builder(
@ -49,7 +51,7 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
AppTextFormField(
labelText: "Task".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: (list[index].instructionTextId == null ? (list[index].task ?? "") : (list[index].text ?? "")),
// initialValue: (list[index].instructionText == null ? (list[index].task ?? "") : (list[index].instructionText!.text ?? "")),
enable: false,
showShadow: false,
enableColor: AppColor.neutral100,
@ -60,19 +62,19 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
context: context,
showShadow: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
initialValue: list[index].taskStatusId == null ? null : Lookup(id: list[index].taskStatusId!.toInt(), name: list[index].taskStatusName),
title: context.translation.taskStatus,
onSelect: (value) {
if (value != null) {
list[index].taskStatusId = value.id;
list[index].taskStatusName = value.name;
}
},
),
// SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
// context: context,
// showShadow: false,
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
// initialValue: list[index].taskStatusId == null ? null : Lookup(id: list[index].taskStatusId!.toInt(), name: list[index].taskStatusName),
// title: context.translation.taskStatus,
// onSelect: (value) {
// if (value != null) {
// list[index].taskStatusId = value.id;
// list[index].taskStatusName = value.name;
// }
// },
// ),
8.height,
AppTextFormField(
labelText: context.translation.measuredValue,

@ -7,6 +7,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -20,10 +21,11 @@ import 'ppm_pm_kits_form.dart';
import 'wo_info_form.dart';
class UpdatePpm extends StatefulWidget {
final Ppm ppm;
final Ppm? ppm;
final PlanPreventiveVisit planPreventiveVisit;
final RequestsDetails? details;
const UpdatePpm({Key? key, required this.ppm, this.details}) : super(key: key);
const UpdatePpm({Key? key, this.ppm, required this.planPreventiveVisit, this.details}) : super(key: key);
@override
State<UpdatePpm> createState() => _UpdatePpmState();
@ -32,23 +34,27 @@ class UpdatePpm extends StatefulWidget {
class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMixin {
late UserProvider _userProvider;
late PpmProvider _regularVisitsProvider;
late Ppm _ppm;
Ppm? _ppm;
late PlanPreventiveVisit _planPreventiveVisit;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
late TabController _tabController;
_onSubmit() async {
if (!(await _ppm.validate(context))) {
setState(() {});
return;
}
_ppm.removeEmptyObjects();
await _regularVisitsProvider.updatePentry(context, user: _userProvider.user!, ppm: widget.ppm);
// if (!(await _ppm.validate(context))) {
// setState(() {});
// return;
// }
// _ppm.removeEmptyObjects();
// await _regularVisitsProvider.updatePentry(context, user: _userProvider.user!, ppm: widget.ppm);
}
@override
void initState() {
_ppm = widget.ppm;
_planPreventiveVisit = widget.planPreventiveVisit;
_tabController = TabController(length: 4, vsync: this);
super.initState();
}
@ -111,15 +117,19 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
),
TabBarView(
children: [
WoInfoForm(model: _ppm),
WoInfoForm(planPreventiveVisit: _planPreventiveVisit),
TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
PpmExternalDetailsForm(models: _ppm.vCalibrationTools),
PpmCalibrationToolsForm(models: _ppm.vCalibrationTools),
PpmPMKitsForm(models: _ppm.vKits, assetId: widget.ppm.assetId),
PpmPmChecklistForm(models: _ppm.vChecklists),
PpmExternalDetailsForm(models: []),
PpmCalibrationToolsForm(models: []),
PpmPMKitsForm(),
// PpmExternalDetailsForm(models: _ppm.vCalibrationTools),
// PpmCalibrationToolsForm(models: _ppm.vCalibrationTools),
// PpmPMKitsForm(models: _ppm.vKits, assetId: widget.ppm.assetId),
PpmPmChecklistForm(checkList: _planPreventiveVisit.preventiveVisitChecklists),
],
)
],

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/models/ppm/ppm.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/ppm/ppm_attachment.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
@ -27,9 +27,10 @@ import '../../../../widgets/images/multi_image_picker.dart';
import '../../../../widgets/timer/app_timer.dart';
class WoInfoForm extends StatefulWidget {
final Ppm model;
// final Ppm model;
final PlanPreventiveVisit planPreventiveVisit;
const WoInfoForm({Key? key, required this.model}) : super(key: key);
const WoInfoForm({Key? key, required this.planPreventiveVisit}) : super(key: key);
@override
State<WoInfoForm> createState() => _WoInfoFormState();
@ -41,10 +42,11 @@ class _WoInfoFormState extends State<WoInfoForm> {
@override
Widget build(BuildContext context) {
widget.model.files ??= [];
widget.model.files = (widget.model.files ?? []).where((element) => element.attachmentName?.isNotEmpty ?? false).toList();
// widget.planPreventiveVisit ??= [];
// widget.planPreventiveVisit.files = (widget.model.files ?? []).where((element) => element.attachmentName?.isNotEmpty ?? false).toList();
double totalWorkingHours = widget.model.visitTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
double totalWorkingHours =
widget.planPreventiveVisit.preventiveVisitTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
totalWorkingHours = totalWorkingHours;
@ -53,7 +55,8 @@ class _WoInfoFormState extends State<WoInfoForm> {
children: [
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
context: context,
initialValue: widget.model.visitStatusId == null ? null : Lookup(name: widget.model.visitStatusName ?? "", id: widget.model.visitStatusId?.toInt()),
initialValue:
widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()),
title: context.translation.ppmVisit,
onSelect: (value) {
if (value?.value == 4) {
@ -63,8 +66,8 @@ class _WoInfoFormState extends State<WoInfoForm> {
}
if (value != null) {
widget.model.visitStatusName = value.name;
widget.model.visitStatusId = value.id;
widget.planPreventiveVisit.visitStatus?.name = value.name;
widget.planPreventiveVisit.visitStatus?.id = value.id;
}
},
),
@ -98,87 +101,87 @@ class _WoInfoFormState extends State<WoInfoForm> {
],
AppTimer(
label: context.translation.timer,
timer: widget.model.tbsTimer,
enabled: widget.model.tbsTimer?.endAt == null,
timer: widget.planPreventiveVisit.tbsTimer,
enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null,
timerProgress: (isRunning) {
print("timerProgress:$isRunning");
},
onChange: (timer) async {
widget.model.tbsTimer = timer;
widget.planPreventiveVisit.tbsTimer = timer;
return true;
},
),
8.height,
SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
context: context,
initialValue: widget.model.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()),
title: context.translation.deviceStatus,
onSelect: (value) {
if (value != null) {
widget.model.deviceStatusId = value.id;
widget.model.deviceStatusName = value.name;
}
},
),
// SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
// context: context,
// initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()),
// title: context.translation.deviceStatus,
// onSelect: (value) {
// if (value != null) {
// widget.planPreventiveVisit.deviceStatusId = value.id;
// widget.planPreventiveVisit.deviceStatusName = value.name;
// }
// },
// ),
8.height,
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
context: context,
initialValue: widget.model.taskStatusId == null ? null : Lookup(name: widget.model.taskStatusName ?? "", id: widget.model.taskStatusId?.toInt()),
initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id),
title: context.translation.taskStatus,
onSelect: (value) {
if (value != null) {
widget.model.taskStatusId = value.id;
widget.model.taskStatusName = value.name;
widget.planPreventiveVisit.taskStatus?.id = value.id;
widget.planPreventiveVisit.taskStatus?.name = value.name;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context,
initialValue: widget.model.assetAvailabilityId == null ? null : Lookup(name: widget.model.assetAvailabilityName ?? "", id: widget.model.assetAvailabilityId?.toInt()),
initialValue: widget.planPreventiveVisit.assetAvailability == null ? null : Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id),
title: "Asset Availability",
onSelect: (value) {
if (value != null) {
widget.model.assetAvailabilityId = value.id;
widget.model.assetAvailabilityName = value.name;
widget.planPreventiveVisit.assetAvailability?.id = value.id;
widget.planPreventiveVisit.assetAvailability?.name = value.name;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context,
initialValue: widget.model.safetyId == null ? null : Lookup(name: widget.model.safetyName ?? "", id: widget.model.safetyId?.toInt()),
initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
title: "Electrical Safety",
onSelect: (value) {
if (value != null) {
widget.model.safetyId = value.id;
widget.model.safetyName = value.name;
widget.planPreventiveVisit.safety?.id = value.id;
widget.planPreventiveVisit.safety?.name = value.name;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
context: context,
initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId?.toInt()),
title: context.translation.serviceType,
onSelect: (value) {
if (value != null) {
widget.model.typeOfServiceId = value.id;
widget.model.typeOfServiceName = value.name;
widget.model.supplierId = null;
widget.model.supplierName = null;
initialSupplier = null;
_suppPerson = null;
widget.model.suppPersonId = null;
widget.model.suppPerson = null;
setState(() {});
}
},
),
// SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
// context: context,
// initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId?.toInt()),
// title: context.translation.serviceType,
// onSelect: (value) {
// if (value != null) {
// widget.model.typeOfServiceId = value.id;
// widget.model.typeOfServiceName = value.name;
//
// widget.model.supplierId = null;
// widget.model.supplierName = null;
// initialSupplier = null;
// _suppPerson = null;
// widget.model.suppPersonId = null;
// widget.model.suppPerson = null;
//
// setState(() {});
// }
// },
// ),
8.height,
if (widget.model.typeOfServiceId == 66) ...[
if (widget.planPreventiveVisit.typeOfService?.id == 66) ...[
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
context: context,
title: context.translation.supplier,
@ -186,13 +189,13 @@ class _WoInfoFormState extends State<WoInfoForm> {
showAsBottomSheet: true,
onSelect: (supplier) {
if (supplier != null) {
widget.model.supplierId = supplier.id;
widget.model.supplierName = supplier.name;
initialSupplier = supplier;
_suppPerson = null;
widget.model.suppPersonId = null;
widget.model.suppPerson = null;
setState(() {});
// widget.model.supplierId = supplier.id;
// widget.model.supplierName = supplier.name;
// initialSupplier = supplier;
// _suppPerson = null;
// widget.model.suppPersonId = null;
// widget.model.suppPerson = null;
// setState(() {});
}
},
),
@ -206,113 +209,113 @@ class _WoInfoFormState extends State<WoInfoForm> {
showAsBottomSheet: true,
onSelect: (suppPerson) {
if (suppPerson != null) {
_suppPerson = suppPerson;
widget.model.suppPersonId = suppPerson.id;
widget.model.suppPerson = suppPerson.name;
setState(() {});
// _suppPerson = suppPerson;
// widget.model.suppPersonId = suppPerson.id;
// widget.model.suppPerson = suppPerson.name;
// setState(() {});
}
},
),
8.height,
AppTextFormField(
labelText: "Telephone",
initialValue: (widget.model.telephone ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.number,
onChange: (value) {
widget.model.telephone = value;
},
),
8.height,
AppTimer(
label: "External Supplier Timer",
timer: widget.model.externalEngineerTimer,
enabled: widget.model.externalEngineerTimer?.endAt == null,
timerProgress: (isRunning) {
print("timerProgress:$isRunning");
},
onChange: (timer) async {
widget.model.externalEngineerTimer = timer;
return true;
},
),
// AppTextFormField(
// labelText: "Telephone",
// initialValue: (widget.planPreventiveVisit.telephone ?? "").toString(),
// textAlign: TextAlign.center,
// style: Theme.of(context).textTheme.titleMedium,
// textInputType: TextInputType.number,
// onChange: (value) {
// widget.model.telephone = value;
// },
// ),
// 8.height,
// AppTimer(
// label: "External Supplier Timer",
// timer: widget.model.externalEngineerTimer,
// enabled: widget.model.externalEngineerTimer?.endAt == null,
// timerProgress: (isRunning) {
// print("timerProgress:$isRunning");
// },
// onChange: (timer) async {
// widget.model.externalEngineerTimer = timer;
// return true;
// },
// ),
8.height,
],
ADatePicker(
label: context.translation.actualVisitDate,
date: DateTime.tryParse(widget.model.actualDate ?? ""),
date: DateTime.tryParse(widget.planPreventiveVisit.acutalDateOfVisit ?? ""),
from: DateTime.now().subtract(const Duration(days: 30)),
onDatePicker: (date) {
if (date.isBefore(DateTime.parse(widget.model.expectedDate!))) {
"Actual visit date must be greater then expected date".showToast;
return;
}
widget.model.actualDate = date.toIso8601String();
setState(() {});
// if (date.isBefore(DateTime.parse(widget.planPreventiveVisit.expectedDate!))) {
// "Actual visit date must be greater then expected date".showToast;
// return;
// }
//
// widget.model.actualDate = date.toIso8601String();
// setState(() {});
},
),
8.height,
ADatePicker(
label: context.translation.expectedVisitDate,
date: DateTime.tryParse(widget.model.nextDate ?? ""),
from: DateTime.now().subtract(const Duration(days: 30)),
enable: false,
onDatePicker: (date) {
widget.model.nextDate = date.toIso8601String();
setState(() {});
},
),
// ADatePicker(
// label: context.translation.expectedVisitDate,
// date: DateTime.tryParse(widget.model.nextDate ?? ""),
// from: DateTime.now().subtract(const Duration(days: 30)),
// enable: false,
// onDatePicker: (date) {
// widget.model.nextDate = date.toIso8601String();
// setState(() {});
// },
// ),
8.height,
AppTextFormField(
labelText: context.translation.travelingHours,
initialValue: (widget.model.travelingHours ?? "").toString(),
initialValue: (widget.planPreventiveVisit.travelingHours ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.number,
onChange: (value) {
widget.model.travelingHours = value;
widget.planPreventiveVisit.travelingHours = value;
},
),
8.height,
MultiFilesPicker(
label: context.translation.attachImage,
files: widget.model.files!.map((e) => File(e.attachmentName!)).toList(),
onChange: (files) {
widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
},
),
// MultiFilesPicker(
// label: context.translation.attachImage,
// files: widget.model.files!.map((e) => File(e.attachmentName!)).toList(),
// onChange: (files) {
// widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
// },
// ),
8.height,
AppTextFormField(
labelText: context.translation.comments,
initialValue: (widget.model.comments ?? "").toString(),
initialValue: (widget.planPreventiveVisit.comments ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
onChange: (value) {
widget.model.comments = value;
widget.planPreventiveVisit.comments = value;
},
),
8.height,
ESignature(
title: context.translation.nurseSignature,
oldSignature: widget.model.nurseSignature,
newSignature: widget.model.localNurseSignature,
onChange: (signature) {
widget.model.localNurseSignature = signature;
widget.model.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
// ESignature(
// title: context.translation.nurseSignature,
// oldSignature: widget.planPreventiveVisit.nurseSignature,
// newSignature: widget.planPreventiveVisit.localNurseSignature,
// onChange: (signature) {
// widget.planPreventiveVisit.localNurseSignature = signature;
// widget.planPreventiveVisit.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// },
// ),
8.height,
ESignature(
title: context.translation.engSign,
oldSignature: widget.model.engSignature,
newSignature: widget.model.localEngineerSignature,
onChange: (signature) {
widget.model.localEngineerSignature = signature;
widget.model.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
// ESignature(
// title: context.translation.engSign,
// oldSignature: widget.planPreventiveVisit.engSignature,
// newSignature: widget.planPreventiveVisit.localEngineerSignature,
// onChange: (signature) {
// widget.planPreventiveVisit.localEngineerSignature = signature;
// widget.planPreventiveVisit.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// },
// ),
],
);
}

@ -76,7 +76,7 @@ class PpmItem extends StatelessWidget {
children: [
if (userProvider.user!.type == UsersTypes.engineer && (ppm.deviceStatusId != 270 || ppm.deviceStatusId != 269))
"edit".toSvgAsset(height: 48, width: 48).onPress(() {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: ppm, details: request)));
// Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: ppm, details: request, planPreventiveVisit: null,)));
}),
if (userProvider.user!.type == UsersTypes.engineer && (ppm.deviceStatusId != 270 || ppm.deviceStatusId != 269)) 8.height,
Text(

Loading…
Cancel
Save