Recurrent Work Order Complete ready to test

design_3.0_latest
WaseemAbbasi22 9 months ago
parent 28b30d9fa8
commit b67e6dea11

@ -133,6 +133,23 @@ class PpmProvider extends ChangeNotifier {
// } // }
} }
Future<int> updateRecurrentWo({required int status,required PlanPreventiveVisit planPreventiveVisit}) async {
isLoading = true;
Response response;
try {
response = await ApiManager.instance.post(URLs.updateRecurrentPlanUrl, body: planPreventiveVisit.toJson(status: status));
stateCode = response.statusCode;
isLoading = false;
notifyListeners();
return response.statusCode;
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
Future<int> updateVisitByEngineer(BuildContext context, {required User user, required Ppm ppm}) async { Future<int> updateVisitByEngineer(BuildContext context, {required User user, required Ppm ppm}) async {
try { try {
ppm.visitTimers?.add( ppm.visitTimers?.add(

@ -530,13 +530,20 @@
"createdDate": "تاريخ الإنشاء", "createdDate": "تاريخ الإنشاء",
"employeeId": "رقم الموظف", "employeeId": "رقم الموظف",
"extensionNo": "رقم التمديد", "extensionNo": "رقم التمديد",
"checkIn": "تسجيل الدخول", "checkIn": "تسجيل الدخول",
"pmWo": "أمر العمل الوقائي", "pmWo": "أمر العمل الوقائي",
"taskNo": "رقم المهمة", "taskNo": "رقم المهمة",
"assignEngineer": "تعيين مهندس", "assignEngineer": "تعيين مهندس",
"scheduledDate": "التاريخ المجدول", "scheduledDate": "التاريخ المجدول",
"complete": "اكتمل", "complete": "اكتمل",
"recurrentWo": "أمر العمل المتكرر" "recurrentWo": "أمر العمل المتكرر",
"fail": "فشل",
"pass": "نجاح",
"pmPlanNo": "رقم خطة الصيانة الوقائية",
"nextPmDate": "تاريخ الصيانة الوقائية التالي",
"executionTimeFrame": "إطار زمني للتنفيذ",
"pmTestResult": "نتيجة اختبار الصيانة الوقائية",
"actualVisit": "الزيارة الفعلية",
"typeOfPm": "نوع الصيانة الوقائية"
} }

@ -539,5 +539,13 @@
"complete": "Complete", "complete": "Complete",
"createdDate": "Created Date", "createdDate": "Created Date",
"employeeId": "Employee ID", "employeeId": "Employee ID",
"extensionNo": "Extension No" "extensionNo": "Extension No",
"fail": "FAIL",
"pass": "PASS",
"pmPlanNo": "PM Plan No",
"nextPmDate": "Next PM Date",
"executionTimeFrame": "Execution Time Frame",
"pmTestResult": "PM Test Result",
"actualVisit": "Actual Visit",
"typeOfPm": "Type of PM"
} }

@ -146,74 +146,89 @@ class PlanPreventiveVisit {
if (json['preventiveVisitSuppliers'] != null) { if (json['preventiveVisitSuppliers'] != null) {
preventiveVisitSuppliers = <PreventiveVisitSuppliers>[]; preventiveVisitSuppliers = <PreventiveVisitSuppliers>[];
json['preventiveVisitSuppliers'].forEach((v) { json['preventiveVisitSuppliers'].forEach((v) {
preventiveVisitSuppliers!.add(new PreventiveVisitSuppliers.fromJson(v)); preventiveVisitSuppliers!.add( PreventiveVisitSuppliers.fromJson(v));
}); });
} }
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson({required int status}) {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
data['visitNo'] = this.visitNo; data['acutalDateOfVisit'] = acutalDateOfVisit;
if (this.asset != null) { data['statusValue'] = status;
data['asset'] = this.asset!.toJson(); data['typeOfServiceId'] = typeOfService?.id;
} data['visitStatusValue'] = visitStatus?.value;
data['planNo'] = this.planNo; data['travelingHours'] = travelingHours;
data['planName'] = this.planName; data['comments'] = comments;
data['nextPMDate'] = this.nextPMDate; data['taskStatusId'] = taskStatus?.id;
data['assetName'] = this.assetName; data['deviceStatusId'] = deviceStatus?.id;
data['model'] = this.model; data['assetAvailabilityId'] = assetAvailability?.id;
data['manufacturer'] = this.manufacturer; data['safetyId'] = safety?.id;
data['supplierName'] = this.supplierName; data['engSignature'] = engSignature;
data['siteName'] = this.siteName; data['nurseSignature'] = nurseSignature;
data['buildingName'] = this.buildingName; //
data['floorName'] = this.floorName; // if (asset != null) {
data['departmentName'] = this.departmentName; // data['asset'] = asset!.toJson();
data['roomName'] = this.roomName; // }
data['fromDate'] = this.fromDate; // data['visitNo'] = visitNo;
data['toDate'] = this.toDate; // data['planNo'] = planNo;
if (this.assignedEmployee != null) { // data['planName'] = planName;
data['assignedEmployee'] = this.assignedEmployee!.toJson(); // data['nextPMDate'] = nextPMDate;
} // data['assetName'] = assetName;
data['acutalDateOfVisit'] = this.acutalDateOfVisit; // data['model'] = model;
if (this.typeOfService != null) { // data['manufacturer'] = manufacturer;
data['typeOfService'] = this.typeOfService!.toJson(); // data['supplierName'] = supplierName;
} // data['siteName'] = siteName;
if (this.visitStatus != null) { // data['buildingName'] = buildingName;
data['visitStatus'] = this.visitStatus!.toJson(); // data['floorName'] = floorName;
} // data['departmentName'] = departmentName;
data['travelingHours'] = this.travelingHours; // data['roomName'] = roomName;
data['comments'] = this.comments; // data['fromDate'] = fromDate;
data['executionTimeFrame'] = this.executionTimeFrame; // data['toDate'] = toDate;
if (this.taskStatus != null) { // if (assignedEmployee != null) {
data['taskStatus'] = this.taskStatus!.toJson(); // data['assignedEmployee'] = assignedEmployee!.toJson();
} // }
if (this.deviceStatus != null) { // data['acutalDateOfVisit'] = acutalDateOfVisit;
data['deviceStatus'] = this.deviceStatus!.toJson(); // if (typeOfService != null) {
} // data['typeOfService'] = typeOfService!.toJson();
data['assetAvailability'] = this.assetAvailability; // }
if (this.safety != null) { // if (visitStatus != null) {
data['safety'] = this.safety!.toJson(); // data['visitStatus'] = visitStatus!.toJson();
} // }
data['engSignature'] = this.engSignature; // data['travelingHours'] = travelingHours;
data['nurseSignature'] = this.nurseSignature; // data['comments'] = comments;
if (this.preventiveVisitAttachments != null) { // data['executionTimeFrame'] = executionTimeFrame;
data['preventiveVisitAttachments'] = this.preventiveVisitAttachments!.map((v) => v.toJson()).toList(); // if (taskStatus != null) {
} // data['taskStatus'] = taskStatus!.toJson();
if (this.preventiveVisitCalibrations != null) { // }
data['preventiveVisitCalibrations'] = this.preventiveVisitCalibrations!.map((v) => v.toJson()).toList(); // if (deviceStatus != null) {
} // data['deviceStatus'] = deviceStatus!.toJson();
if (this.preventiveVisitChecklists != null) { // }
data['preventiveVisitChecklists'] = this.preventiveVisitChecklists!.map((v) => v.toJson()).toList(); // data['assetAvailability'] = assetAvailability;
} // if (safety != null) {
if (this.preventiveVisitKits != null) { // data['safety'] = safety!.toJson();
data['preventiveVisitKits'] = this.preventiveVisitKits!.map((v) => v.toJson()).toList(); // }
} // data['engSignature'] = engSignature;
if (this.preventiveVisitTimers != null) { // data['nurseSignature'] = nurseSignature;
data['preventiveVisitTimers'] = this.preventiveVisitTimers!.map((v) => v.toJson()).toList();
}
if (this.preventiveVisitSuppliers != null) { if (preventiveVisitAttachments != null) {
data['preventiveVisitSuppliers'] = this.preventiveVisitSuppliers!.map((v) => v.toJson()).toList(); data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toJson()).toList();
}
if (preventiveVisitCalibrations != null) {
data['preventiveVisitCalibrations'] = preventiveVisitCalibrations!.map((v) => v.toJson()).toList();
}
if (preventiveVisitChecklists != null) {
data['preventiveVisitChecklists'] = preventiveVisitChecklists!.map((v) => v.toJson()).toList();
}
if (preventiveVisitKits != null) {
data['preventiveVisitKits'] = preventiveVisitKits!.map((v) => v.toJson()).toList();
}
if (preventiveVisitTimers != null) {
data['preventiveVisitTimers'] = preventiveVisitTimers!.map((v) => v.toJson()).toList();
}
if (preventiveVisitSuppliers != null) {
data['preventiveVisitSuppliers'] = preventiveVisitSuppliers!.map((v) => v.toJson()).toList();
} }
return data; return data;
} }
@ -687,9 +702,9 @@ class PreventiveVisitAttachments {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
data['attachmentName'] = this.attachmentName; data['attachmentName'] = attachmentName;
return data; return data;
} }
} }
@ -703,24 +718,24 @@ class PreventiveVisitCalibrations {
PreventiveVisitCalibrations.fromJson(Map<String, dynamic> json) { PreventiveVisitCalibrations.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null; asset = json['asset'] != null ? Asset.fromJson(json['asset']) : null;
calibrationDateOfTesters = json['calibrationDateOfTesters']; calibrationDateOfTesters = json['calibrationDateOfTesters'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
if (this.asset != null) { if (asset != null) {
data['asset'] = this.asset!.toJson(); data['asset'] = asset!.toJson();
} }
data['calibrationDateOfTesters'] = this.calibrationDateOfTesters; data['calibrationDateOfTesters'] = calibrationDateOfTesters;
return data; return data;
} }
} }
class PreventiveVisitSuppliers { class PreventiveVisitSuppliers {
int? id; int? id;
Supplier? supplier; SupplierDetails? supplier;
SuppPersons? suppPerson; SuppPersons? suppPerson;
String? startDateTime; String? startDateTime;
String? endDateTime; String? endDateTime;
@ -730,25 +745,25 @@ class PreventiveVisitSuppliers {
PreventiveVisitSuppliers.fromJson(Map<String, dynamic> json) { PreventiveVisitSuppliers.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
supplier = json['supplier'] != null ? new Supplier.fromJson(json['supplier']) : null; supplier = json['supplier'] != null ? SupplierDetails.fromJson(json['supplier']) : null;
suppPerson = json['suppPerson'] != null ? new SuppPersons.fromJson(json['suppPerson']) : null; suppPerson = json['suppPerson'] != null ? SuppPersons.fromJson(json['suppPerson']) : null;
startDateTime = json['startDateTime']; startDateTime = json['startDateTime'];
endDateTime = json['endDateTime']; endDateTime = json['endDateTime'];
workingHours = json['workingHours']; workingHours = json['workingHours'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
if (this.supplier != null) { if (supplier != null) {
data['supplier'] = this.supplier!.toJson(); data['supplier'] = supplier!.toJson();
} }
if (this.suppPerson != null) { if (suppPerson != null) {
data['suppPerson'] = this.suppPerson!.toJson(); data['suppPerson'] = suppPerson!.toJson();
} }
data['startDateTime'] = this.startDateTime; data['startDateTime'] = startDateTime;
data['endDateTime'] = this.endDateTime; data['endDateTime'] = endDateTime;
data['workingHours'] = this.workingHours; data['workingHours'] = workingHours;
return data; return data;
} }
} }
@ -848,37 +863,37 @@ class Supplier {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
data['suppliername'] = this.suppliername; data['suppliername'] = suppliername;
data['name'] = this.name; data['name'] = name;
data['website'] = this.website; data['website'] = website;
data['email'] = this.email; data['email'] = email;
data['code'] = this.code; data['code'] = code;
data['suppNo'] = this.suppNo; data['suppNo'] = suppNo;
data['suppStatusId'] = this.suppStatusId; data['suppStatusId'] = suppStatusId;
data['cityId'] = this.cityId; data['cityId'] = cityId;
data['person'] = this.person; data['person'] = person;
data['comment'] = this.comment; data['comment'] = comment;
data['zipcode'] = this.zipcode; data['zipcode'] = zipcode;
data['contact'] = this.contact; data['contact'] = contact;
if (this.telephones != null) { if (telephones != null) {
data['telephones'] = this.telephones!.map((v) => v).toList(); data['telephones'] = telephones!.map((v) => v).toList();
} }
if (this.faxes != null) { if (faxes != null) {
data['faxes'] = this.faxes!.map((v) => v).toList(); data['faxes'] = faxes!.map((v) => v).toList();
} }
if (this.addresses != null) { if (addresses != null) {
data['addresses'] = this.addresses!.map((v) => v).toList(); data['addresses'] = addresses!.map((v) => v).toList();
} }
if (this.attachments != null) { if (attachments != null) {
data['attachments'] = this.attachments!.map((v) => v).toList(); data['attachments'] = attachments!.map((v) => v).toList();
} }
if (this.suppPersons != null) { if (suppPersons != null) {
data['suppPersons'] = this.suppPersons!.map((v) => v.toJson()).toList(); data['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList();
} }
if (this.suppTCodes != null) { if (suppTCodes != null) {
data['suppTCodes'] = this.suppTCodes!.map((v) => v).toList(); data['suppTCodes'] = suppTCodes!.map((v) => v).toList();
} }
return data; return data;
} }
@ -922,7 +937,7 @@ class PreventiveVisitKits {
int? id; int? id;
PartCatalogItem? partCatalogItem; PartCatalogItem? partCatalogItem;
PreventiveVisitKits({this.id, this.partCatalogItem}); PreventiveVisitKits({this.id, partCatalogItem});
PreventiveVisitKits.fromJson(Map<String, dynamic> json) { PreventiveVisitKits.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@ -931,9 +946,9 @@ class PreventiveVisitKits {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id; data['id'] = id;
if (this.partCatalogItem != null) { if (partCatalogItem != null) {
data['partCatalogItem'] = this.partCatalogItem!.toJson(); data['partCatalogItem'] = partCatalogItem!.toJson();
} }
return data; return data;
} }
@ -955,11 +970,11 @@ class PartCatalogItem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = this.id; data['id'] = id;
data['partName'] = this.partName; data['partName'] = partName;
data['partNumber'] = this.partNumber; data['partNumber'] = partNumber;
data['oracleCode'] = this.oracleCode; data['oracleCode'] = oracleCode;
return data; return data;
} }
} }

@ -46,6 +46,7 @@ class AppColor {
static const Color white50 = Color(0xffECECEC); static const Color white50 = Color(0xffECECEC);
static const Color white60 = Color(0xffEFEFEF); static const Color white60 = Color(0xffEFEFEF);
static const Color white70 = Color(0xffF1F1F1); static const Color white70 = Color(0xffF1F1F1);
static const Color white80 = Color(0xffF2F4FA);
static const Color white936 = Color(0xff212936); static const Color white936 = Color(0xff212936);
//black //black
@ -55,6 +56,7 @@ class AppColor {
static const Color black1E = Color(0xff1E1F20); static const Color black1E = Color(0xff1E1F20);
//red //red
static const Color red20 = Color(0xfff2c5ca);
static const Color red30 = Color(0xffF63939); static const Color red30 = Color(0xffF63939);
static const Color red40 = Color(0xffFFDBDC); static const Color red40 = Color(0xffFFDBDC);
static const Color red50 = Color(0xffD02127); static const Color red50 = Color(0xffD02127);
@ -69,6 +71,7 @@ class AppColor {
static const Color green60 = Color(0xff065E38); static const Color green60 = Color(0xff065E38);
static const Color green70 = Color(0xff54C166); static const Color green70 = Color(0xff54C166);
static const Color green15 = Color(0xff157D14); static const Color green15 = Color(0xff157D14);
static const Color green20 = Color(0xffcde6e1);
//orange //orange
static const Color orange30 = Color(0xffFDE19B); static const Color orange30 = Color(0xffFDE19B);

@ -44,7 +44,6 @@ class _MyRequestsPageState extends State<MyRequestsPage> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
_provider!.getAllRequests(context); _provider!.getAllRequests(context);
}); });
} }
return Scaffold( return Scaffold(

@ -107,7 +107,7 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
AppFilledButton( AppFilledButton(
onPressed: () async { onPressed: () async {
//TODO remove after testing.. //TODO remove after testing..
// await Navigator.of(context).push(MaterialPageRoute(builder: (_) => RecurrentWorkOrderView( request: widget.request)));
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request))); await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request)));
// setState(() {}); // setState(() {});
}, },

@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/dashboard_latest/dashboard_view.dart'; import 'package:test_sa/dashboard_latest/dashboard_view.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
@ -8,6 +9,7 @@ import 'package:test_sa/models/enums/recurrent_task_inspection_data_type.dart';
import 'package:test_sa/models/ppm/recurrent_wo.dart'; import 'package:test_sa/models/ppm/recurrent_wo.dart';
import 'package:test_sa/new_views/app_style/app_color.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'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:toggle_switch/toggle_switch.dart';
class RoomInspectionCard extends StatefulWidget { class RoomInspectionCard extends StatefulWidget {
final PlanRecurrentMedicalTaskRoomTabs? inspectionModel; final PlanRecurrentMedicalTaskRoomTabs? inspectionModel;
@ -19,8 +21,7 @@ class RoomInspectionCard extends StatefulWidget {
} }
class _RoomInspectionCardState extends State<RoomInspectionCard> { class _RoomInspectionCardState extends State<RoomInspectionCard> {
late List<bool> inspectionValues; int selectedIndex =0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -60,7 +61,6 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
], ],
).toShadowContainer(context).paddingOnly(top: 12); ).toShadowContainer(context).paddingOnly(top: 12);
} }
Widget inspectionStatusRadioWidget({ Widget inspectionStatusRadioWidget({
required int index, required int index,
required PlanRecurrentMedicalTaskRoomTabAttributes model, required PlanRecurrentMedicalTaskRoomTabAttributes model,
@ -68,10 +68,9 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
}) { }) {
bool status = model.attribute != null bool status = model.attribute != null
? model.attributeValue == 'true' ? model.attributeValue == 'true'
? true ? true
: false : false
: false; : false;
String statusString = status ? 'Pass' : 'Fail';
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -80,29 +79,121 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500), SizedBox(
statusString.bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500), width: 220.toScreenWidth,
child: Text(
model.attribute!.name!,
overflow: TextOverflow.ellipsis,
maxLines: 1, // Ensures text is limited to one line before ellipsis
),
),
(status ? 'Pass' : 'Fail').bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500),
], ],
), ),
SizedBox( GestureDetector(
height: 24.toScreenHeight, onTap: () {
width: 41.toScreenWidth, setState(() {
child: CupertinoSwitch( status = !status;
thumbColor: status ? AppColor.green50 : AppColor.red30, model.attributeValue = status.toString();
activeColor: AppColor.green30, });
trackColor: AppColor.red80, },
value: status, child: Container(
onChanged: (state) { width: 99.toScreenWidth,
setState(() { height: 30.toScreenHeight,
model.attributeValue = state; padding: EdgeInsetsDirectional.all(4.toScreenHeight),
status = state; decoration: BoxDecoration(
}); color:AppColor.white80,
}, borderRadius: BorderRadius.circular(5),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
buildToggleOption(
label: "PASS",
isActive: status,
activeColor: AppColor.green20,
inactiveColor: Colors.transparent,
textColor: status ? AppColor.green50 :AppColor.black20,
),
buildToggleOption(
label: "FAIL",
isActive: !status,
activeColor: AppColor.red20,
inactiveColor: Colors.transparent,
textColor: status ? AppColor.black20 : AppColor.red30,
),
],
),
), ),
) ),
], ],
).paddingOnly(bottom: 12); ).paddingOnly(bottom: 12);
} }
Widget buildToggleOption({
required String label,
required bool isActive,
required Color activeColor,
required Color inactiveColor,
required Color textColor,
}) {
return Container(
width: 44.toScreenWidth,
height: 22.toScreenHeight,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isActive ? activeColor : inactiveColor,
borderRadius: BorderRadius.circular(3),
),
child: label.bodyText2(context).custom(color: textColor),
);
}
// Widget inspectionStatusRadioWidget({
// required int index,
// required PlanRecurrentMedicalTaskRoomTabAttributes model,
// required BuildContext context,
// }) {
//
// bool status = model.attribute != null
// ? model.attributeValue == 'true'
// ? true
// : false
// : false;
// String statusString = status ? 'Pass' : 'Fail';
// List<String> state = ['PASS','FAIL'];
//
// return Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500),
// statusString.bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500),
// ],
// ),
//
// SizedBox(
// height: 24.toScreenHeight,
// width: 41.toScreenWidth,
// child: CupertinoSwitch(
// thumbColor: status ? AppColor.green50 : AppColor.red30,
// activeColor: AppColor.green30,
// trackColor: AppColor.red80,
// value: status,
// onChanged: (state) {
// setState(() {
// model.attributeValue = state.toString();
// status = state;
// });
// },
// ),
// )
// ],
// ).paddingOnly(bottom: 12);
// }
Widget inspectionStatusNumberWidget({ Widget inspectionStatusNumberWidget({
required int index, required int index,
@ -113,7 +204,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
borderRadius: BorderRadius.circular(4), // Optional: Slight rounding borderRadius: BorderRadius.circular(4), // Optional: Slight rounding
borderSide: const BorderSide( borderSide: const BorderSide(
color: AppColor.white70, // Border color color: AppColor.white70, // Border color
width: 1, // 1px border width: 0, // 1px border
), ),
); );
return Row( return Row(
@ -128,9 +219,9 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth), contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth),
filled: true, filled: true,
fillColor: AppColor.neutral100, fillColor: AppColor.neutral100,
constraints: const BoxConstraints( constraints: BoxConstraints(
maxHeight: 30, maxWidth: 99.toScreenWidth,
maxWidth: 50, maxHeight: 30.toScreenHeight,
), ),
border: border, border: border,
enabledBorder: border, enabledBorder: border,
@ -144,3 +235,66 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
).paddingOnly(bottom: 12); ).paddingOnly(bottom: 12);
} }
} }
// // I need it here ....
// Container(
// padding: EdgeInsets.all(6.toScreenHeight),
// // height: 57.toScreenHeight,
// // width: 120.toScreenWidth,
// decoration: BoxDecoration(
// color: context.isDark ? AppColor.neutral50 : AppColor.white80,
// borderRadius: BorderRadius.circular(10),
// ),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// // mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: state.asMap().entries.map((task) {
// final int index = task.key;
// final String label = task.value;
// return GestureDetector(
// onTap: () {
// setState(() {
// selectedIndex = index;
// });
// },
// child: Container(
// // margin: EdgeInsets.only(right: 8.toScreenWidth),
// height: 49.toScreenHeight,
// padding: EdgeInsets.symmetric(
// // vertical: 20.toScreenHeight,
// horizontal: 15.toScreenWidth,
// ),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : status ? AppColor.green20 : AppColor.red20) : Colors.transparent,
// // color: status ? AppColor.green20 : AppColor.red20,
// borderRadius: BorderRadius.circular(7),
// ),
// child: label.bodyText2(context).custom(
// // color: status?AppColor.green50:AppColor.red30,
// color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : status ? AppColor.green50 : AppColor.red30) : AppColor.black20,
// ),
// ),
// );
// }).toList(),
// ),
// ),
// // ToggleSwitch(
// // minWidth: 41.toScreenWidth,
// // minHeight: 50.toScreenHeight,
// // fontSize: 12.0,
// // initialLabelIndex: 1,
// // activeBgColor: [Colors.green],
// // activeFgColor: Colors.white,
// // inactiveBgColor: Colors.grey,
// // inactiveFgColor: Colors.grey[900],
// // totalSwitches: 2,
// // labels: ['PASS', 'FAIL'],
// // onToggle: (index) {
// // print('switched to: $index');
// // },
// // ),

@ -10,7 +10,8 @@ import 'package:test_sa/views/widgets/loaders/app_loading.dart';
class RoomTabsWidget extends StatefulWidget { class RoomTabsWidget extends StatefulWidget {
final RecurrentWoData? model; final RecurrentWoData? model;
const RoomTabsWidget({Key? key,required this.model}) : super(key: key);
const RoomTabsWidget({Key? key, required this.model}) : super(key: key);
@override @override
State<RoomTabsWidget> createState() => _RoomTabsWidgetState(); State<RoomTabsWidget> createState() => _RoomTabsWidgetState();
@ -36,9 +37,9 @@ class _RoomTabsWidgetState extends State<RoomTabsWidget> {
child: ListView( child: ListView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
// mainAxisAlignment: MainAxisAlignment.spaceAround, // mainAxisAlignment: MainAxisAlignment.spaceAround,
children: widget.model!.planRecurrentMedicalTaskRooms!.asMap().entries.map((entry) { children: widget.model!.planRecurrentMedicalTaskRooms!.asMap().entries.map((task) {
final int index = entry.key; final int index = task.key;
final String label = entry.value.room!.roomId!; final String label = task.value.room!.roomId!;
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
@ -61,11 +62,11 @@ class _RoomTabsWidgetState extends State<RoomTabsWidget> {
), ),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent, color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent,
borderRadius: BorderRadius.circular(7), borderRadius: BorderRadius.circular(7),
), ),
child: label.bodyText(context).custom( child: label.bodyText(context).custom(
color:AppColor.white936, color: AppColor.white936,
), ),
), ),
); );
@ -73,7 +74,7 @@ class _RoomTabsWidgetState extends State<RoomTabsWidget> {
), ),
), ),
isLoading isLoading
? SizedBox(height: 120.toScreenHeight, child: const ALoading().center) ? const ALoading().paddingOnly(top: 150)
: ListView( : ListView(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),

@ -76,7 +76,7 @@ class RecurrentTaskInfoWidget extends StatelessWidget {
label: context.translation.timer, label: context.translation.timer,
timer: snapshot.recurrentWoData?.recurrentWoTimerModel, timer: snapshot.recurrentWoData?.recurrentWoTimerModel,
width: double.infinity, width: double.infinity,
enabled: snapshot.recurrentWoData?.recurrentWoTimerModel?.endAt == null, // enabled: snapshot.recurrentWoData?.recurrentWoTimerModel?.endAt == null,
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColor.neutral100, color: AppColor.neutral100,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),

@ -55,7 +55,7 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
void initState() { void initState() {
_ppm = widget.ppm; _ppm = widget.ppm;
_planPreventiveVisit = widget.planPreventiveVisit; _planPreventiveVisit = widget.planPreventiveVisit;
_tabController = TabController(length: 4, vsync: this); _tabController = TabController(length: 3, vsync: this);
super.initState(); super.initState();
} }
@ -122,7 +122,7 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
controller: _tabController, controller: _tabController,
children: [ children: [
PpmExternalDetailsForm(models: []), // PpmExternalDetailsForm(models: []),
PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations), PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations),
PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits,assetId: _planPreventiveVisit.asset?.id), PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits,assetId: _planPreventiveVisit.asset?.id),

@ -2,14 +2,18 @@ import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart'; import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/models/service_request/supplier_details.dart'; import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/providers/ppm_asset_availability_provider.dart'; import 'package:test_sa/providers/ppm_asset_availability_provider.dart';
import 'package:test_sa/providers/ppm_electrical_safety_provider.dart'; import 'package:test_sa/providers/ppm_electrical_safety_provider.dart';
import 'package:test_sa/providers/ppm_service_provider.dart';
import 'package:test_sa/providers/ppm_task_status_provider.dart'; import 'package:test_sa/providers/ppm_task_status_provider.dart';
import 'package:test_sa/providers/work_order/vendor_provider.dart'; import 'package:test_sa/providers/work_order/vendor_provider.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../../../models/lookup.dart'; import '../../../../../models/lookup.dart';
import '../../../../../new_views/common_widgets/app_text_form_field.dart'; import '../../../../../new_views/common_widgets/app_text_form_field.dart';
@ -32,6 +36,17 @@ class _WoInfoFormState extends State<WoInfoForm> {
SupplierDetails? initialSupplier; SupplierDetails? initialSupplier;
SuppPersons? _suppPerson; SuppPersons? _suppPerson;
@override
void initState() {
// TODO need to use model attributes directly no need to assign to new variable. when confirm from backend we need one or multiple suppliers.
if (widget.planPreventiveVisit.preventiveVisitSuppliers != null && widget.planPreventiveVisit.preventiveVisitSuppliers!.isNotEmpty) {
initialSupplier = SupplierDetails.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier?.toJson());
_suppPerson = SuppPersons.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].suppPerson?.toJson());
}
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// widget.planPreventiveVisit ??= []; // widget.planPreventiveVisit ??= [];
@ -45,65 +60,62 @@ class _WoInfoFormState extends State<WoInfoForm> {
return ListView( return ListView(
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16), padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
children: [ children: [
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>( Column(
context: context, mainAxisSize: MainAxisSize.min,
initialValue: crossAxisAlignment: CrossAxisAlignment.start,
widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()), children: [
title: context.translation.ppmVisit, if (widget.planPreventiveVisit.visitStatus != null)
onSelect: (value) { StatusLabel(
if (value?.value == 4) { label: widget.planPreventiveVisit.visitStatus?.name,
"Status cannot be change to ${value?.name}.".addTranslation.showToast; textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
setState(() {}); backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
return; ),
} 8.height,
widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10),
if (value != null) { 2.height,
widget.planPreventiveVisit.visitStatus?.name = value.name; '${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120),
widget.planPreventiveVisit.visitStatus?.id = value.id; '${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120),
} '${context.translation.assignEngineer}: ${widget.planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120),
}, '${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120),
), ],
8.height, ).toShadowContainer(context),
if (totalWorkingHours > 0.0) ...[ 12.height,
Container( Column(
height: 56.toScreenHeight, mainAxisSize: MainAxisSize.min,
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), crossAxisAlignment: CrossAxisAlignment.start,
alignment: Alignment.centerLeft, children: [
decoration: BoxDecoration( Row(
color: context.isDark ? AppColor.neutral40 : AppColor.background(context), mainAxisAlignment: MainAxisAlignment.spaceBetween,
borderRadius: BorderRadius.circular(10),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10),
"Total Working Time", "info_icon".toSvgAsset(height: 17, width: 17),
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
),
Text(
" ${formatDuration(totalWorkingHours.round())}",
style: Theme.of(context).textTheme.bodyMedium,
),
], ],
), ),
), 2.height,
8.height, '${context.translation.assetNo}: ${widget.planPreventiveVisit.asset?.assetNumber}'.bodyText2(context).custom(color: AppColor.neutral120),
], '${context.translation.model}: ${widget.planPreventiveVisit.model}'.bodyText2(context).custom(color: AppColor.neutral120),
AppTimer( ],
label: context.translation.timer, ).toShadowContainer(context),
timer: widget.planPreventiveVisit.tbsTimer,
enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null, // SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
timerProgress: (isRunning) { // context: context,
print("timerProgress:$isRunning"); // initialValue:
}, // widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()),
onChange: (timer) async { // title: context.translation.ppmVisit,
widget.planPreventiveVisit.tbsTimer = timer; // onSelect: (value) {
return true; // if (value?.value == 4) {
}, // "Status cannot be change to ${value?.name}.".addTranslation.showToast;
), // setState(() {});
8.height, // return;
// }
//
// if (value != null) {
// widget.planPreventiveVisit.visitStatus?.name = value.name;
// widget.planPreventiveVisit.visitStatus?.id = value.id;
// }
// },
// ),
// SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>( // SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
// context: context, // context: context,
// initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()), // initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()),
@ -141,6 +153,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
} }
}, },
), ),
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>( SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context, context: context,
@ -154,27 +167,69 @@ class _WoInfoFormState extends State<WoInfoForm> {
}, },
), ),
8.height, 8.height,
// SingleItemDropDownMenu<Lookup, PpmServiceProvider>( SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
// context: context, context: context,
// initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId?.toInt()), initialValue:
// title: context.translation.serviceType, widget.planPreventiveVisit.typeOfService == null ? null : Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()),
// onSelect: (value) { title: context.translation.serviceType,
// if (value != null) { onSelect: (value) {
// widget.model.typeOfServiceId = value.id; if (value != null) {
// widget.model.typeOfServiceName = value.name; widget.planPreventiveVisit.typeOfService?.id = value.id;
// widget.planPreventiveVisit.typeOfService?.name = value.name;
// widget.model.supplierId = null; //TODO check this why make all values null..
// widget.model.supplierName = null;
// initialSupplier = null; // widget.planPreventiveVisit?.preventiveVisitSuppliers?. = null;
// _suppPerson = null; // widget.model.supplierName = null;
// widget.model.suppPersonId = null; // initialSupplier = null;
// widget.model.suppPerson = null; // _suppPerson = null;
// // widget.model.suppPersonId = null;
// setState(() {}); // widget.model.suppPerson = null;
// }
// }, setState(() {});
// ), }
},
),
8.height,
AppTimer(
label: context.translation.timer,
timer: widget.planPreventiveVisit.tbsTimer,
enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null,
timerProgress: (isRunning) {
print("timerProgress:$isRunning");
},
onChange: (timer) async {
widget.planPreventiveVisit.tbsTimer = timer;
return true;
},
),
8.height, 8.height,
if (totalWorkingHours > 0.0) ...[
Container(
height: 56.toScreenHeight,
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
color: context.isDark ? AppColor.neutral40 : AppColor.background(context),
borderRadius: BorderRadius.circular(10),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Total Working Time",
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
),
Text(
" ${formatDuration(totalWorkingHours.round())}",
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
8.height,
],
if (widget.planPreventiveVisit.typeOfService?.id == 66) ...[ if (widget.planPreventiveVisit.typeOfService?.id == 66) ...[
SingleItemDropDownMenu<SupplierDetails, VendorProvider>( SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
context: context, context: context,
@ -183,6 +238,9 @@ class _WoInfoFormState extends State<WoInfoForm> {
showAsBottomSheet: true, showAsBottomSheet: true,
onSelect: (supplier) { onSelect: (supplier) {
if (supplier != null) { if (supplier != null) {
initialSupplier = supplier;
print('supplier dtails is ${supplier.toJson()}');
// widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier=supplier;
// widget.model.supplierId = supplier.id; // widget.model.supplierId = supplier.id;
// widget.model.supplierName = supplier.name; // widget.model.supplierName = supplier.name;
// initialSupplier = supplier; // initialSupplier = supplier;
@ -213,15 +271,16 @@ class _WoInfoFormState extends State<WoInfoForm> {
8.height, 8.height,
// AppTextFormField( // AppTextFormField(
// labelText: "Telephone", // labelText: "Telephone",
// initialValue: (widget.planPreventiveVisit.telephone ?? "").toString(), // initialValue: (initialSupplier?.telephones?[0].telephone ?? "").toString(),
// textAlign: TextAlign.center, // textAlign: TextAlign.center,
// style: Theme.of(context).textTheme.titleMedium, // style: Theme.of(context).textTheme.titleMedium,
// textInputType: TextInputType.number, // textInputType: TextInputType.number,
// onChange: (value) { // onChange: (value) {
// widget.model.telephone = value; // initialSupplier?.telephones?[0].telephone = value;
// }, // },
// ), // ),
// 8.height, 8.height,
//TODO implement this after feedback from backend.
// AppTimer( // AppTimer(
// label: "External Supplier Timer", // label: "External Supplier Timer",
// timer: widget.model.externalEngineerTimer, // timer: widget.model.externalEngineerTimer,
@ -234,7 +293,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
// return true; // return true;
// }, // },
// ), // ),
8.height, // 8.height,
], ],
ADatePicker( ADatePicker(
label: context.translation.actualVisitDate, label: context.translation.actualVisitDate,

@ -1562,6 +1562,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.4" version: "0.9.4"
toggle_switch:
dependency: "direct main"
description:
name: toggle_switch
sha256: dca04512d7c23ed320d6c5ede1211a404f177d54d353bf785b07d15546a86ce5
url: "https://pub.dev"
source: hosted
version: "2.3.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

@ -93,6 +93,7 @@ dependencies:
wifi_iot: ^0.3.19+1 wifi_iot: ^0.3.19+1
just_audio: ^0.9.30 just_audio: ^0.9.30
safe_device: ^1.1.9 safe_device: ^1.1.9
toggle_switch: ^2.3.0
local_auth_darwin: any local_auth_darwin: any
dev_dependencies: dev_dependencies:

Loading…
Cancel
Save