@ -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 ) ;
}