bug fixes mentioned on excel sheet and tested with backend

design_3.0_latest
WaseemAbbasi22 10 months ago
parent 4954549594
commit ab91baf216

@ -96,11 +96,29 @@ class PartsProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
page = categoriesListJson.map((part) => SparePart.fromJson(part)).toList();
page = categoriesListJson.map((part) => SparePart.fromJson(part,false)).toList();
}
return page;
} catch (error) {
return [];
}
}
// Implement this only for spare part request for now show and search on display name ....
Future<List<SparePart>> getPartsListByDisplayName({num? assetId, String? displayName}) async {
late Response response;
try {
response = await ApiManager.instance.post(URLs.getPartNumber, body: {"displayName": displayName, });
List<SparePart> page = [];
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
page = categoriesListJson.map((part) => SparePart.fromJson(part,true)).toList();
}
return page;
} catch (error) {
return [];
}
}
}

@ -22,6 +22,14 @@ class PpmProvider extends ChangeNotifier {
PlanPreventiveVisit? _planPreventiveVisit;
late int _totalTabs = 4;
TabController? tabController;
bool _isReadOnly = false;
bool get isReadOnly => _isReadOnly;
set isReadOnly(bool value) {
_isReadOnly = value;
notifyListeners();
}
int get totalTabs => _totalTabs;
@ -155,6 +163,11 @@ class PpmProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
ppmPlanAttachments = [];
planPreventiveVisit = PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]);
if(planPreventiveVisit?.visitStatus?.value! == 1 || planPreventiveVisit?.visitStatus?.value == 3){
isReadOnly =true;
}else{
isReadOnly =false;
}
isLoading = false;
notifyListeners();
return planPreventiveVisit;

@ -55,8 +55,8 @@ extension WidgetExtensions on Widget {
Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this);
Widget handlePopScope(BuildContext _cxt, VoidCallback onSave) {
return PopScope(
Widget handlePopScope(BuildContext _cxt, VoidCallback onSave,) {
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, result) {
if (didPop) {

@ -783,136 +783,136 @@ class PreventiveVisitSuppliers {
}
}
class Supplier {
int? id;
String? suppliername;
String? name;
String? website;
String? email;
String? code;
int? suppNo;
String? suppStatusId;
String? cityId;
String? person;
String? comment;
String? zipcode;
String? contact;
List<String>? telephones;
List<String>? faxes;
List<String>? addresses;
List<String>? attachments;
List<SuppPersons>? suppPersons;
List<String>? suppTCodes;
Supplier(
{this.id,
this.suppliername,
this.name,
this.website,
this.email,
this.code,
this.suppNo,
this.suppStatusId,
this.cityId,
this.person,
this.comment,
this.zipcode,
this.contact,
this.telephones,
this.faxes,
this.addresses,
this.attachments,
this.suppPersons,
this.suppTCodes});
Supplier.fromJson(Map<String, dynamic> json) {
id = json['id'];
suppliername = json['suppliername'];
name = json['name'];
website = json['website'];
email = json['email'];
code = json['code'];
suppNo = json['suppNo'];
suppStatusId = json['suppStatusId'];
cityId = json['cityId'];
person = json['person'];
comment = json['comment'];
zipcode = json['zipcode'];
contact = json['contact'];
if (json['telephones'] != null) {
telephones = <String>[];
json['telephones'].forEach((v) {
telephones!.add(v);
});
}
if (json['faxes'] != null) {
faxes = <String>[];
json['faxes'].forEach((v) {
faxes!.add(v);
});
}
if (json['addresses'] != null) {
addresses = <String>[];
json['addresses'].forEach((v) {
addresses!.add(v);
});
}
if (json['attachments'] != null) {
attachments = <String>[];
json['attachments'].forEach((v) {
attachments!.add(v);
});
}
if (json['suppPersons'] != null) {
suppPersons = <SuppPersons>[];
json['suppPersons'].forEach((v) {
suppPersons!.add(SuppPersons.fromJson(v));
});
}
if (json['suppTCodes'] != null) {
suppTCodes = <String>[];
json['suppTCodes'].forEach((v) {
suppTCodes!.add(v);
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['suppliername'] = suppliername;
data['name'] = name;
data['website'] = website;
data['email'] = email;
data['code'] = code;
data['suppNo'] = suppNo;
data['suppStatusId'] = suppStatusId;
data['cityId'] = cityId;
data['person'] = person;
data['comment'] = comment;
data['zipcode'] = zipcode;
data['contact'] = contact;
if (telephones != null) {
data['telephones'] = telephones!.map((v) => v).toList();
}
if (faxes != null) {
data['faxes'] = faxes!.map((v) => v).toList();
}
if (addresses != null) {
data['addresses'] = addresses!.map((v) => v).toList();
}
if (attachments != null) {
data['attachments'] = attachments!.map((v) => v).toList();
}
if (suppPersons != null) {
data['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList();
}
if (suppTCodes != null) {
data['suppTCodes'] = suppTCodes!.map((v) => v).toList();
}
return data;
}
}
// class Supplier {
// int? id;
// String? suppliername;
// String? name;
// String? website;
// String? email;
// String? code;
// int? suppNo;
// String? suppStatusId;
// String? cityId;
// String? person;
// String? comment;
// String? zipcode;
// String? contact;
// List<String>? telephones;
// List<String>? faxes;
// List<String>? addresses;
// List<String>? attachments;
// List<SuppPersons>? suppPersons;
// List<String>? suppTCodes;
//
// Supplier(
// {this.id,
// this.suppliername,
// this.name,
// this.website,
// this.email,
// this.code,
// this.suppNo,
// this.suppStatusId,
// this.cityId,
// this.person,
// this.comment,
// this.zipcode,
// this.contact,
// this.telephones,
// this.faxes,
// this.addresses,
// this.attachments,
// this.suppPersons,
// this.suppTCodes});
//
// Supplier.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// suppliername = json['suppliername'];
// name = json['name'];
// website = json['website'];
// email = json['email'];
// code = json['code'];
// suppNo = json['suppNo'];
// suppStatusId = json['suppStatusId'];
// cityId = json['cityId'];
// person = json['person'];
// comment = json['comment'];
// zipcode = json['zipcode'];
// contact = json['contact'];
// if (json['telephones'] != null) {
// telephones = <String>[];
// json['telephones'].forEach((v) {
// telephones!.add(v);
// });
// }
// if (json['faxes'] != null) {
// faxes = <String>[];
// json['faxes'].forEach((v) {
// faxes!.add(v);
// });
// }
// if (json['addresses'] != null) {
// addresses = <String>[];
// json['addresses'].forEach((v) {
// addresses!.add(v);
// });
// }
// if (json['attachments'] != null) {
// attachments = <String>[];
// json['attachments'].forEach((v) {
// attachments!.add(v);
// });
// }
// if (json['suppPersons'] != null) {
// suppPersons = <SuppPersons>[];
// json['suppPersons'].forEach((v) {
// suppPersons!.add(SuppPersons.fromJson(v));
// });
// }
// if (json['suppTCodes'] != null) {
// suppTCodes = <String>[];
// json['suppTCodes'].forEach((v) {
// suppTCodes!.add(v);
// });
// }
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = <String, dynamic>{};
// data['id'] = id;
// data['suppliername'] = suppliername;
// data['name'] = name;
// data['website'] = website;
// data['email'] = email;
// data['code'] = code;
// data['suppNo'] = suppNo;
// data['suppStatusId'] = suppStatusId;
// data['cityId'] = cityId;
// data['person'] = person;
// data['comment'] = comment;
// data['zipcode'] = zipcode;
// data['contact'] = contact;
// if (telephones != null) {
// data['telephones'] = telephones!.map((v) => v).toList();
// }
// if (faxes != null) {
// data['faxes'] = faxes!.map((v) => v).toList();
// }
// if (addresses != null) {
// data['addresses'] = addresses!.map((v) => v).toList();
// }
// if (attachments != null) {
// data['attachments'] = attachments!.map((v) => v).toList();
// }
// if (suppPersons != null) {
// data['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList();
// }
// if (suppTCodes != null) {
// data['suppTCodes'] = suppTCodes!.map((v) => v).toList();
// }
// return data;
// }
// }
// class SuppPersons {
// int? id;

@ -5,7 +5,7 @@ class SparePartsWorkOrders extends Base {
SparePartsWorkOrders.fromJson(dynamic json) {
id = json['id'];
sparePart = json['sparePart'] != null ? SparePart.fromJson(json['sparePart']) : null;
sparePart = json['sparePart'] != null ? SparePart.fromJson(json['sparePart'],true) : null;
qty = json['qty'];
returnQty = json['returnQty'];
@ -40,33 +40,37 @@ class SparePart extends Base {
this.partNo,
this.partName,
this.oracleCode,
this.displayName,
this.assetId,
}) : super(identifier: id?.toString(), name: partName);
SparePart.fromJson(dynamic json) {
SparePart.fromJson(dynamic json,bool ?isDisplayName) {
id = json['id'];
identifier = id?.toString();
partNo = json['partNo'];
partName = json['partName'];
displayName = json['displayName'];
oracleCode = json['oracleCode'];
name = partName;
name = isDisplayName!=null&&isDisplayName?displayName: partName;
assetId = json['assetId'];
}
num? id;
String? partNo;
String? partName;
String? displayName;
String? oracleCode;
num? assetId;
SparePart copyWith({num? id, String? partNo, String? partName, num? assetId,String?oracleCode}) =>
SparePart(id: id ?? this.id,oracleCode: oracleCode?? this.oracleCode, partNo: partNo ?? this.partNo, partName: partName ?? this.partName, assetId: assetId ?? this.assetId);
SparePart copyWith({num? id, String? partNo, String? partName, num? assetId,String?oracleCode,String ?displayName}) =>
SparePart(id: id ?? this.id,oracleCode: oracleCode?? this.oracleCode, partNo: partNo ?? this.partNo, partName: partName ?? this.partName, assetId: assetId ?? this.assetId,displayName: displayName??this.displayName);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['partNo'] = partNo;
map['partName'] = partName;
map['displayName'] = displayName;
map['oracleCode'] = oracleCode;
map['assetId'] = assetId;
return map;

@ -100,7 +100,7 @@ class PpmItemView extends StatelessWidget {
8.height,
(requestDetails?.nameOfType ?? context.translation.ppmRequest).heading5(context),
8.height,
'${context.translation.assetName}: ${requestDetails!.assetName}'.bodyText(context),
'${context.translation.assetName}: ${requestDetails!.assetName}'.bodyText(context),
'${context.translation.assetNumber}: ${requestDetails!.assetNo}'.bodyText(context),
'${context.translation.assetSN}: ${requestDetails!.assetSN}'.bodyText(context),
// '${context.translation.code}: ${request.code}'.bodyText(context),

@ -126,7 +126,7 @@ class _ServiceRequestDetailViewState extends State<ServiceRequestDetailView> {
radius: 4,
label:'${workOrder.since} days',
textColor: AppColor.neutral50,
backgroundColor: AppColor.orange80,
backgroundColor: AppColor.orange30,
),
],
1.width.expanded,

@ -80,7 +80,7 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
_isLoading = true;
_files = _requestDetailProvider?.sparePartHelperModel?.sparePartAttachments?.map((e) => MultiFilesPickerModel(e.id!, File(e.name!))).toList() ?? [];
setState(() {});
_spareParts = await _partsProvider!.getPartsList(assetId: _requestDetailProvider?.currentWorkOrder?.data?.asset?.id);
_spareParts = await _partsProvider!.getPartsListByDisplayName(assetId: _requestDetailProvider?.currentWorkOrder?.data?.asset?.id);
_isLoading = false;
setState(() {});

@ -106,7 +106,7 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
],
).toShadowContainer(context).paddingAll(16),
).expanded,
if (userProvider!.user!.type == UsersTypes.engineer && (planPreventiveVisit.visitStatus!.id! != 270 && planPreventiveVisit.visitStatus!.id! != 269))
if (userProvider!.user!.type == UsersTypes.engineer && (!ppmProvider.isReadOnly))...[
AppFilledButton(
onPressed: () async {
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit)));
@ -114,6 +114,16 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
},
label: context.translation.updateWorkOrder,
).paddingAll(16)
]
else ...[
AppFilledButton(
onPressed: () async {
await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit)));
getVisitData();
},
label: context.translation.viewDetails,
).paddingAll(16)
]
]);
}),
),

@ -57,6 +57,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
required PlanRecurrentMedicalTaskRoomTabAttributes model,
required BuildContext context,
}) {
bool status = (model.attribute == null || model.attributeValue == null)
? true
: model.attribute != null
@ -65,6 +66,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
: false
: false;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,

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

@ -65,7 +65,6 @@ class _RecurrentWorkOrderViewState extends State<RecurrentWorkOrderView> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RecurrentTaskInfoWidget(model: requestProvider.recurrentWoData),
// 8.height,
requestProvider.recurrentWoData!.planRecurrentMedicalTaskRooms!.isNotEmpty
? Column(
children: [
@ -77,7 +76,7 @@ class _RecurrentWorkOrderViewState extends State<RecurrentWorkOrderView> {
],
).paddingAll(12),
).paddingOnly(bottom: 85),
if (requestProvider.recurrentWoData?.status?.id != 270) ...[
if (requestProvider.recurrentWoData?.status?.value != 1) ...[
FooterActionButton.footerContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,

@ -30,7 +30,8 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
int totalTabs = Provider.of<PpmProvider>(context, listen: false).totalTabs;
final ppmProvider = Provider.of<PpmProvider>(context, listen: false);
int totalTabs = ppmProvider.totalTabs;
int currentIndex = totalTabs == 4 ? 2 : 1;
return ListView.separated(
itemCount: widget.models!.length + 1,
@ -38,27 +39,30 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
separatorBuilder: (cxt, index) => 16.height,
itemBuilder: (context, index) {
if (index == widget.models!.length) {
return AppFilledButton(
label: "Add More Calibration Tools".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.asset?.id == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.assetNumber}");
return;
return Visibility(
visible: !ppmProvider.isReadOnly,
child: AppFilledButton(
label: "Add More Calibration Tools".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.asset?.id == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.assetNumber}");
return;
}
if (widget.models!.last.calibrationDateOfTesters == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.date}");
return;
}
}
if (widget.models!.last.calibrationDateOfTesters == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.date}");
return;
}
}
widget.models!.add(PreventiveVisitCalibrations(id: 0));
setState(() {});
},
widget.models!.add(PreventiveVisitCalibrations(id: 0));
setState(() {});
},
),
);
}
PreventiveVisitCalibrations model = widget.models![index];
@ -69,48 +73,51 @@ class _PpmCalibrationToolsFormState extends State<PpmCalibrationToolsForm> {
borderRadius: BorderRadius.circular(20),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(index == 0 ? "$currentIndex /$totalTabs . Calibration Tools" : "").heading5(context),
"trash".toSvgAsset(height: 20, width: 15).onPress(() {
widget.models!.remove(model);
child: IgnorePointer(
ignoring:ppmProvider.isReadOnly,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(index == 0 ? "$currentIndex /$totalTabs . Calibration Tools" : "").heading5(context),
"trash".toSvgAsset(height: 20, width: 15).onPress(() {
widget.models!.remove(model);
setState(() {});
}),
],
),
16.height,
CalibrationToolAssetPicker(
initialValue: model.asset?.id == null ? null : Lookup(id: model.asset?.id?.toInt(), name: model.asset?.assetNumber ?? ""),
hospitalId: userProvider.user!.clientId,
onPick: (asset) {
model.asset = Asset(id: asset.id, assetNumber: asset.assetNumber, assetSerialNo: asset.assetSerialNo);
setState(() {});
},
),
12.height,
if (model.asset?.assetNumber != null)
Text("Asset Number: ${model.asset?.assetNumber?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
// if (model.assetName != null) Text("Asset Name: ${model.assetName?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.asset?.assetSerialNo != null)
Text("Asset Serial No: ${model.asset?.assetSerialNo?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
12.height,
ADatePicker(
label: context.translation.calibrationDate,
date: DateTime.tryParse(model.calibrationDateOfTesters ?? ""),
from: DateTime.now().subtract(const Duration(days: 90)),
backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral100,
withBorder: false,
hideShadow: true,
onDatePicker: (date) {
model.calibrationDateOfTesters = date.toIso8601String();
setState(() {});
}),
],
),
16.height,
CalibrationToolAssetPicker(
initialValue: model.asset?.id == null ? null : Lookup(id: model.asset?.id?.toInt(), name: model.asset?.assetNumber ?? ""),
hospitalId: userProvider.user!.clientId,
onPick: (asset) {
model.asset = Asset(id: asset.id, assetNumber: asset.assetNumber, assetSerialNo: asset.assetSerialNo);
setState(() {});
},
),
12.height,
if (model.asset?.assetNumber != null)
Text("Asset Number: ${model.asset?.assetNumber?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
// if (model.assetName != null) Text("Asset Name: ${model.assetName?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
if (model.asset?.assetSerialNo != null)
Text("Asset Serial No: ${model.asset?.assetSerialNo?.cleanupWhitespace.capitalizeFirstOfEach}", style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120)),
12.height,
ADatePicker(
label: context.translation.calibrationDate,
date: DateTime.tryParse(model.calibrationDateOfTesters ?? ""),
from: DateTime.now().subtract(const Duration(days: 90)),
backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral100,
withBorder: false,
hideShadow: true,
onDatePicker: (date) {
model.calibrationDateOfTesters = date.toIso8601String();
setState(() {});
},
),
],
},
),
],
),
),
);
},

@ -237,6 +237,8 @@
// }
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/ppm_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
@ -289,20 +291,23 @@ class _PpmExternalDetailsFormState extends State<PpmExternalDetailsForm> {
@override
Widget build(BuildContext context) {
print("widget.models!.length:${widget.models!.length}");
final ppmProvider = Provider.of<PpmProvider>(context, listen: false);
return ListView.builder(
itemCount: widget.models!.length + 1,
padding: const EdgeInsets.all(16),
itemBuilder: (context, index) {
if (index == widget.models!.length) {
return AppFilledButton(
label: "Add More External Details".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: _addNewEntry,
return Visibility(
visible: !ppmProvider.isReadOnly,
child: AppFilledButton(
label: "Add More External Details".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: _addNewEntry,
),
);
}
// return !isLoading
@ -336,10 +341,12 @@ class ExternalDetailItem extends StatefulWidget {
class _ExternalDetailItemState extends State<ExternalDetailItem> {
TextEditingController? controller;
PpmProvider? _ppmProvider;
@override
void initState() {
controller = TextEditingController(text: widget.model.workingHours != null ? widget.model.workingHours.toString() : '');
_ppmProvider= Provider.of<PpmProvider>(context,listen:false);
super.initState();
}
@ -353,148 +360,151 @@ class _ExternalDetailItemState extends State<ExternalDetailItem> {
borderRadius: BorderRadius.circular(20),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(widget.index == 0 ? "1 /4 . External Details" : "").heading5(context),
Container(
height: 32,
width: 32,
padding: const EdgeInsets.all(6),
child: "trash".toSvgAsset(height: 20, width: 20),
).onPress(() {
widget.onRemove();
}),
],
),
16.height,
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
context: context,
title: context.translation.supplier,
initialValue: widget.model.supplier,
backgroundColor: AppColor.neutral100,
showAsBottomSheet: true,
showShadow: false,
onSelect: (supplier) {
if (supplier != null) {
setState(() {
widget.model.supplier = supplier;
});
}
},
),
8.height,
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
context: context,
title: context.translation.supplierEngineer,
enabled: widget.model.supplier != null,
backgroundColor: AppColor.neutral100,
initialValue: widget.model.suppPerson,
staticData: widget.model.supplier?.suppPersons,
showAsBottomSheet: true,
showShadow: false,
onSelect: (suppPerson) {
if (suppPerson != null) {
widget.model.suppPerson = suppPerson;
}
},
),
8.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
ADatePicker(
label: context.translation.startTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.model.startDateTime,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
setState(() {
widget.model.startDateTime = selectedDateTime;
});
widget.model.endDateTime = null;
controller?.clear();
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: widget.model.startDateTime,
endTime: widget.model.endDateTime,
workingHoursController: controller!,
updateModel: (hours) {
widget.model.workingHours = hours;
},
);
}
child: IgnorePointer(
ignoring: _ppmProvider!.isReadOnly,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(widget.index == 0 ? "1 /4 . External Details" : "").heading5(context),
Container(
height: 32,
width: 32,
padding: const EdgeInsets.all(6),
child: "trash".toSvgAsset(height: 20, width: 20),
).onPress(() {
widget.onRemove();
}),
],
),
16.height,
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
context: context,
title: context.translation.supplier,
initialValue: widget.model.supplier,
backgroundColor: AppColor.neutral100,
showAsBottomSheet: true,
showShadow: false,
onSelect: (supplier) {
if (supplier != null) {
setState(() {
widget.model.supplier = supplier;
});
},
).expanded,
8.width,
ADatePicker(
label: context.translation.endTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.model.endDateTime,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
if (widget.model.startDateTime != null && selectedDateTime.isBefore(widget.model.startDateTime!)) {
"End Date time must be greater than start date".showToast;
return;
}
},
),
8.height,
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
context: context,
title: context.translation.supplierEngineer,
enabled: widget.model.supplier != null,
backgroundColor: AppColor.neutral100,
initialValue: widget.model.suppPerson,
staticData: widget.model.supplier?.suppPersons,
showAsBottomSheet: true,
showShadow: false,
onSelect: (suppPerson) {
if (suppPerson != null) {
widget.model.suppPerson = suppPerson;
}
},
),
8.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
ADatePicker(
label: context.translation.startTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.model.startDateTime,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
setState(() {
widget.model.startDateTime = selectedDateTime;
});
widget.model.endDateTime = null;
controller?.clear();
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: widget.model.startDateTime,
endTime: widget.model.endDateTime,
workingHoursController: controller!,
updateModel: (hours) {
widget.model.workingHours = hours;
},
);
}
setState(() {
widget.model.endDateTime = selectedDateTime;
});
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: widget.model.startDateTime,
endTime: widget.model.endDateTime,
workingHoursController: controller!,
updateModel: (hours) {
widget.model.workingHours = hours;
},
);
}
});
},
).expanded,
],
),
8.height,
AppTextFormField(
labelText: context.translation.workingHours,
backgroundColor: AppColor.neutral80,
controller: controller,
textAlign: TextAlign.center,
enable: false,
showShadow: false,
style: Theme.of(context).textTheme.titleMedium,
),
8.height,
],
});
},
).expanded,
8.width,
ADatePicker(
label: context.translation.endTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.model.endDateTime,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
if (widget.model.startDateTime != null && selectedDateTime.isBefore(widget.model.startDateTime!)) {
"End Date time must be greater than start date".showToast;
return;
}
setState(() {
widget.model.endDateTime = selectedDateTime;
});
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: widget.model.startDateTime,
endTime: widget.model.endDateTime,
workingHoursController: controller!,
updateModel: (hours) {
widget.model.workingHours = hours;
},
);
}
});
},
).expanded,
],
),
8.height,
AppTextFormField(
labelText: context.translation.workingHours,
backgroundColor: AppColor.neutral80,
controller: controller,
textAlign: TextAlign.center,
enable: false,
showShadow: false,
style: Theme.of(context).textTheme.titleMedium,
),
8.height,
],
),
),
);
}

@ -32,6 +32,7 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
@override
Widget build(BuildContext context) {
int totalTabs = Provider.of<PpmProvider>(context, listen: false).totalTabs;
final ppmProvider = Provider.of<PpmProvider>(context, listen: false);
int currentIndex = totalTabs == 4 ? 4 : 3;
List<PreventiveVisitChecklists>? list = widget.checkList ?? [];
return (list.isEmpty)
@ -42,68 +43,71 @@ class _PpmPmChecklistFormState extends State<PpmPmChecklistForm> {
shrinkWrap: true,
separatorBuilder: (cxt, index) => 12.height,
itemBuilder: (context, index) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (index == 0) ...[
"$currentIndex /$totalTabs . PM Checklist".heading5(context),
16.height,
return IgnorePointer(
ignoring: ppmProvider.isReadOnly,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (index == 0) ...[
"$currentIndex /$totalTabs . PM Checklist".heading5(context),
16.height,
],
AppTextFormField(
labelText: "Task".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].instructionText?.text ?? "",
enable: false,
showShadow: false,
makeMultiLinesNull: true,
enableColor: AppColor.neutral100,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
// backgroundColor: context.isDark ? AppColor.neutral50 : null,
onChange: (text) {
list[index].taskComment = text;
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
context: context,
showShadow: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
initialValue: list[index].taskStatus?.id == null ? null : Lookup(id: list[index].taskStatus?.id?.toInt(), name: list[index].taskStatus?.name),
title: context.translation.taskStatus,
onSelect: (value) {
if (value != null) {
list[index].taskStatus = Lookup(id: value.id, name: value.name, value: value.value);
}
},
),
8.height,
AppTextFormField(
labelText: context.translation.measuredValue,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].measuredValue ?? "",
// enable: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
showShadow: false,
onChange: (text) {
list[index].measuredValue = text;
},
),
8.height,
AppTextFormField(
labelText: "Task Comment".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].taskComment ?? "",
textInputType: TextInputType.multiline,
makeMultiLinesNull: true,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
showShadow: false,
onChange: (text) {
list[index].taskComment = text;
},
),
],
AppTextFormField(
labelText: "Task".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].instructionText?.text ?? "",
enable: false,
showShadow: false,
makeMultiLinesNull: true,
enableColor: AppColor.neutral100,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
// backgroundColor: context.isDark ? AppColor.neutral50 : null,
onChange: (text) {
list[index].taskComment = text;
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmChecklistStatusProvider>(
context: context,
showShadow: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
initialValue: list[index].taskStatus?.id == null ? null : Lookup(id: list[index].taskStatus?.id?.toInt(), name: list[index].taskStatus?.name),
title: context.translation.taskStatus,
onSelect: (value) {
if (value != null) {
list[index].taskStatus = Lookup(id: value.id, name: value.name, value: value.value);
}
},
),
8.height,
AppTextFormField(
labelText: context.translation.measuredValue,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].measuredValue ?? "",
// enable: false,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
showShadow: false,
onChange: (text) {
list[index].measuredValue = text;
},
),
8.height,
AppTextFormField(
labelText: "Task Comment".addTranslation,
labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500),
initialValue: list[index].taskComment ?? "",
textInputType: TextInputType.multiline,
makeMultiLinesNull: true,
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral100,
showShadow: false,
onChange: (text) {
list[index].taskComment = text;
},
),
],
).toShadowContainer(context, showShadow: false, borderRadius: 20);
).toShadowContainer(context, showShadow: false, borderRadius: 20),
);
},
);
}

@ -26,7 +26,8 @@ class PpmPMKitsForm extends StatefulWidget {
class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
@override
Widget build(BuildContext context) {
int totalTabs = Provider.of<PpmProvider>(context, listen: false).totalTabs;
final ppmProvider = Provider.of<PpmProvider>(context, listen: false);
int totalTabs = ppmProvider.totalTabs;
int currentIndex = totalTabs == 4 ? 3 : 2;
return ListView.builder(
itemCount: widget.models!.length + 1,
@ -34,27 +35,30 @@ class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
itemBuilder: (context, index) {
if (index == widget.models!.length) {
return AppFilledButton(
label: "Add More PM Kits".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.partCatalogItem?.partNumber == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partNumber}");
return;
return Visibility(
visible: !ppmProvider.isReadOnly,
child: AppFilledButton(
label: "Add More PM Kits".addTranslation,
maxWidth: true,
textColor: AppColor.black10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
showIcon: true,
onPressed: () async {
if (widget.models?.isNotEmpty ?? false) {
if (widget.models!.last.partCatalogItem?.partNumber == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partNumber}");
return;
}
if (widget.models!.last.partCatalogItem?.partName == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partName}");
return;
}
}
if (widget.models!.last.partCatalogItem?.partName == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partName}");
return;
}
}
widget.models!.add(PreventiveVisitKits(id: 0));
setState(() {});
},
widget.models!.add(PreventiveVisitKits(id: 0));
setState(() {});
},
),
);
}
final model = widget.models![index];
@ -66,47 +70,50 @@ class _PpmPMKitsFormState extends State<PpmPMKitsForm> {
borderRadius: BorderRadius.circular(20),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(index == 0 ? "$currentIndex /$totalTabs . PM Kits" : "").heading5(context),
Container(
height: 32,
width: 32,
padding: const EdgeInsets.all(6),
child: "trash".toSvgAsset(height: 20, width: 20),
).onPress(() {
widget.models!.remove(model);
child: IgnorePointer(
ignoring: ppmProvider.isReadOnly,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(index == 0 ? "$currentIndex /$totalTabs . PM Kits" : "").heading5(context),
Container(
height: 32,
width: 32,
padding: const EdgeInsets.all(6),
child: "trash".toSvgAsset(height: 20, width: 20),
).onPress(() {
widget.models!.remove(model);
setState(() {});
}),
],
),
16.height,
AutoCompletePartsField(
assetId: widget.assetId,
clearAfterPick: false,
byName: true,
initialValue: model.partCatalogItem?.partName ?? "",
onPick: (part) {
model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode);
setState(() {});
},
),
8.height,
AutoCompletePartsField(
assetId: widget.assetId,
clearAfterPick: false,
byName: false,
initialValue: model.partCatalogItem?.partNumber ?? "",
onPick: (part) {
model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode);
setState(() {});
}),
],
),
16.height,
AutoCompletePartsField(
assetId: widget.assetId,
clearAfterPick: false,
byName: true,
initialValue: model.partCatalogItem?.partName ?? "",
onPick: (part) {
model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode);
setState(() {});
},
),
8.height,
AutoCompletePartsField(
assetId: widget.assetId,
clearAfterPick: false,
byName: false,
initialValue: model.partCatalogItem?.partNumber ?? "",
onPick: (part) {
model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode);
setState(() {});
},
),
],
},
),
],
),
),
);
},

@ -79,9 +79,12 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
@override
void initState() {
ppmProvider = Provider.of<PpmProvider>(context, listen: false);
_planPreventiveVisit = widget.planPreventiveVisit;
initTabs(_planPreventiveVisit.typeOfService);
// WidgetsBinding.instance.addPostFrameCallback((_) {
initTabs(_planPreventiveVisit.typeOfService);
// });
super.initState();
}
@ -112,7 +115,7 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
backgroundColor: AppColor.neutral110,
appBar: DefaultAppBar(
title: context.translation.preventiveMaintenance,
onWillPopScope: () {
onWillPopScope:ppmProvider.isReadOnly?null: () {
_onSubmit(status: 0);
},
),
@ -186,8 +189,8 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
children: [
if (tabIndex == 1) ...[
AppFilledButton(
buttonColor: _tabController!.index == 0 ? null:AppColor.background(context),
textColor: _tabController!.index == 0 ? null: AppColor.blueStatus(context),
buttonColor: _tabController!.index == 0 ? null : AppColor.background(context),
textColor: _tabController!.index == 0 ? null : AppColor.blueStatus(context),
showBorder: true,
disableButton: _tabController!.index == 0,
onPressed: () {
@ -202,30 +205,47 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
).expanded,
8.width,
],
AppFilledButton(
buttonColor: AppColor.white60,
textColor: AppColor.neutral50,
onPressed: () {
_onSubmit(status: 0);
},
label: context.translation.save,
).expanded,
8.width,
AppFilledButton(
onPressed: () {
if (tabIndex == 0) {
_onSubmit(status: 1);
return;
}
if (ppmProvider.totalTabs == _tabController!.index + 1) {
_onSubmit(status: 1);
} else {
_tabController?.animateTo(_tabController!.index + 1);
setState(() {});
}
},
label: tabIndex == 0 ? "Complete".addTranslation : ((ppmProvider.totalTabs == _tabController!.index + 1) ? "Complete".addTranslation : context.translation.next),
).expanded,
if (!ppmProvider.isReadOnly) ...[
AppFilledButton(
buttonColor: AppColor.white60,
textColor: AppColor.neutral50,
onPressed: () {
_onSubmit(status: 0);
},
label: context.translation.save,
).expanded,
8.width,
AppFilledButton(
onPressed: () {
if (tabIndex == 0) {
_onSubmit(status: 1);
return;
}
if (ppmProvider.totalTabs == _tabController!.index + 1) {
_onSubmit(status: 1);
} else {
_tabController?.animateTo(_tabController!.index + 1);
setState(() {});
}
},
label: tabIndex == 0 ? "Complete".addTranslation : ((ppmProvider.totalTabs == _tabController!.index + 1) ? "Complete".addTranslation : context.translation.next),
).expanded,
] else ...[
Visibility(
visible: tabIndex != 0,
child: AppFilledButton(
onPressed: () {
if(ppmProvider.totalTabs == _tabController!.index + 1){
Navigator.pop(context);
return;
}
_tabController?.animateTo(_tabController!.index + 1);
setState(() {});
},
label:ppmProvider.totalTabs == _tabController!.index + 1? context.translation.close: context.translation.next,
).expanded,
),
]
],
).toShadowContainer(context, showShadow: false, borderRadius: 0),
],

@ -6,8 +6,15 @@ import 'package:test_sa/controllers/providers/api/ppm_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/models/device/model_definition.dart';
import 'package:test_sa/models/device/supplier.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/department.dart';
import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/room_model.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/providers/ppm_asset_availability_provider.dart';
@ -59,232 +66,238 @@ class _WoInfoFormState extends State<WoInfoForm> {
totalWorkingHours = totalWorkingHours;
return Consumer<PpmProvider>(builder: (context, ppmProvider, child) {
return ListView(
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.planPreventiveVisit.visitStatus != null)
StatusLabel(
label: widget.planPreventiveVisit.visitStatus?.name,
textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
),
8.height,
widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10),
2.height,
'${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120),
//need to add in translation it's suggestion from ahmed..
'Work Order Number: ${widget.planPreventiveVisit.visitNo}'.bodyText2(context).custom(color: AppColor.neutral120),
'${context.translation.creationDate}: ${widget.planPreventiveVisit.creationDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120),
'${context.translation.closedDate}: ${widget.planPreventiveVisit.closedDate != null ? widget.planPreventiveVisit.closedDate?.toMonthYearFormat : '-'}'
.bodyText2(context)
.custom(color: AppColor.neutral120),
'${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate != null ? 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 ?? ""} days'.bodyText2(context).custom(color: AppColor.neutral120),
],
).toShadowContainer(context),
12.height,
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10),
"info_icon".toSvgAsset(height: 17, width: 17).onPress(
() {
// There is only limited information for asset is returned from backend to show all info need to return the whole model from backend...
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (BuildContext context) => _buildAssetDetailBottomSheet(context),
);
},
)
],
),
2.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),
],
).toShadowContainer(context),
IgnorePointer(
ignoring: ppmProvider.isReadOnly,
child: Column(
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.planPreventiveVisit.visitStatus != null)
StatusLabel(
label: widget.planPreventiveVisit.visitStatus?.name,
textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
),
8.height,
widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10),
2.height,
'${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120),
//need to add in translation it's suggestion from ahmed..
'Work Order Number: ${widget.planPreventiveVisit.visitNo}'.bodyText2(context).custom(color: AppColor.neutral120),
'${context.translation.creationDate}: ${widget.planPreventiveVisit.creationDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120),
'${context.translation.closedDate}: ${widget.planPreventiveVisit.closedDate != null ? widget.planPreventiveVisit.closedDate?.toMonthYearFormat : '-'}'
.bodyText2(context)
.custom(color: AppColor.neutral120),
// SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
// context: context,
// 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) {
// "Status cannot be change to ${value?.name}.".addTranslation.showToast;
// setState(() {});
// return;
// }
//
// if (value != null) {
// widget.planPreventiveVisit.visitStatus?.name = value.name;
// widget.planPreventiveVisit.visitStatus?.id = value.id;
// }
// },
// ),
'${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate != null ? 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 ?? ""} days'.bodyText2(context).custom(color: AppColor.neutral120),
],
).toShadowContainer(context),
12.height,
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10),
"info_icon".toSvgAsset(height: 17, width: 17).onPress(
() {
// There is only limited information for asset is returned from backend to show all info need to return the whole model from backend...
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (BuildContext context) => _buildAssetDetailBottomSheet(context),
);
},
)
],
),
2.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),
],
).toShadowContainer(context),
// 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,
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
//TODO Ahmed need to provide look up value....
// SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
// context: context,
// 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) {
// "Status cannot be change to ${value?.name}.".addTranslation.showToast;
// setState(() {});
// return;
// }
//
// if (value != null) {
// widget.planPreventiveVisit.visitStatus?.name = value.name;
// widget.planPreventiveVisit.visitStatus?.id = value.id;
// }
// },
// ),
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
context: context,
showShadow: false,
initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id),
title: context.translation.pmTestResult,
backgroundColor: AppColor.neutral100,
onSelect: (value) {
if (value != null) {
widget.planPreventiveVisit.taskStatus = value;
}
},
),
8.height,
ADatePicker(
label: context.translation.actualVisit,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.planPreventiveVisit.acutalDateOfVisit,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
setState(() {
widget.planPreventiveVisit.acutalDateOfVisit = selectedDateTime;
});
}
});
},
),
// SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
// context: context,
// backgroundColor: AppColor.neutral100,
// initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
// title: context.translation.actualVisit,
// onSelect: (value) {
// if (value != null) {
// widget.planPreventiveVisit.safety = value;
// // widget.planPreventiveVisit.safety?.id = value.id;
// // widget.planPreventiveVisit.safety?.name = 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,
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
context: context,
showShadow: false,
initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id),
title: context.translation.pmTestResult,
backgroundColor: AppColor.neutral100,
onSelect: (value) {
if (value != null) {
widget.planPreventiveVisit.taskStatus = value;
}
},
),
8.height,
ADatePicker(
label: context.translation.actualVisit,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: widget.planPreventiveVisit.acutalDateOfVisit,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
setState(() {
widget.planPreventiveVisit.acutalDateOfVisit = selectedDateTime;
});
}
});
},
),
// SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
// context: context,
// backgroundColor: AppColor.neutral100,
// initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
// title: context.translation.actualVisit,
// onSelect: (value) {
// if (value != null) {
// widget.planPreventiveVisit.safety = value;
// // widget.planPreventiveVisit.safety?.id = value.id;
// // widget.planPreventiveVisit.safety?.name = value.name;
// }
// },
// ),
8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
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.planPreventiveVisit.safety = value;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
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.planPreventiveVisit.assetAvailability = value;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
initialValue: widget.planPreventiveVisit.typeOfService == null
? null
: Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()),
title: context.translation.typeOfPm,
onSelect: (value) {
if (value != null) {
widget.planPreventiveVisit.typeOfService = value;
if (widget.planPreventiveVisit.typeOfService?.id == 66) {
ppmProvider.totalTabs = 4;
} else {
ppmProvider.totalTabs = 3;
}
widget.onTypeOfServiceChange!(value);
}
},
),
8.height,
_timerWidget(context, totalWorkingHours),
8.height,
AppTextFormField(
labelText: context.translation.comment,
backgroundColor: AppColor.neutral100,
showShadow: false,
initialValue: (widget.planPreventiveVisit.comments ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
onChange: (value) {
widget.planPreventiveVisit.comments = value;
},
),
16.height,
MultiFilesPicker(
label: context.translation.attachments,
files: ppmProvider.ppmPlanAttachments,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
),
],
).toShadowContainer(context),
8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
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.planPreventiveVisit.safety = value;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
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.planPreventiveVisit.assetAvailability = value;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
context: context,
backgroundColor: AppColor.neutral100,
showShadow: false,
initialValue: widget.planPreventiveVisit.typeOfService == null
? null
: Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()),
title: context.translation.typeOfPm,
onSelect: (value) {
if (value != null) {
widget.planPreventiveVisit.typeOfService = value;
if (widget.planPreventiveVisit.typeOfService?.id == 66) {
ppmProvider.totalTabs = 4;
} else {
ppmProvider.totalTabs = 3;
}
widget.onTypeOfServiceChange!(value);
}
},
),
8.height,
_timerWidget(context, totalWorkingHours),
8.height,
AppTextFormField(
labelText: context.translation.comment,
backgroundColor: AppColor.neutral100,
showShadow: false,
initialValue: (widget.planPreventiveVisit.comments ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
onChange: (value) {
widget.planPreventiveVisit.comments = value;
},
),
16.height,
MultiFilesPicker(
label: context.translation.attachments,
files: ppmProvider.ppmPlanAttachments,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
),
],
).toShadowContainer(context),
],
),
),
//TODO need to check this also...
// ESignature(
// title: context.translation.nurseSignature,
@ -311,8 +324,18 @@ class _WoInfoFormState extends State<WoInfoForm> {
_buildAssetDetailBottomSheet(BuildContext context) {
PlanPreventiveVisit model = widget.planPreventiveVisit;
Asset asset = Asset(id: model.asset?.id, assetSerialNo: model.asset?.assetSerialNo, assetNumber: model.asset?.assetNumber);
Asset asset = Asset(
id: model.asset?.id,
assetSerialNo: model.asset?.assetSerialNo,
assetNumber: model.asset?.assetNumber,
building: Building(name: model.buildingName),
floor: Floor(name: model.floorName),
site: Site(custName: model.siteName),
supplier: Supplier(suppliername: model.supplierName),
modelDefinition: ModelDefinition(modelName: model.model, manufacturerName: model.manufacturer),
room: Rooms(value: int.tryParse(model.roomName??'')),
department: Department(departmentName: model.departmentName),
);
return AssetDetailBottomSheet(asset);
}

Loading…
Cancel
Save