diff --git a/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart new file mode 100644 index 0000000..ecd13a9 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart @@ -0,0 +1,27 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_classification.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_classification_event.dart'; +part 'land_classification_state.dart'; + +class LandClassificationBloc + extends Bloc { + LandClassificationBloc() : super(LandClassificationInitial()) { + List landClassification = []; + on((event, emit) async { + landClassification = + await SQLServices.instance.readAllLandClassification(); + + emit(LandClassificationLoaded(landClassification: landClassification)); + }); + on((event, emit) async { + await SQLServices.instance.createLandClassification(LandClassification( + id: event.id, + classificationCode: event.classificationCode, + description: event.description)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_event.dart b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_event.dart new file mode 100644 index 0000000..0a07ffe --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_event.dart @@ -0,0 +1,34 @@ +part of 'land_classification_bloc.dart'; + +class LandClassificationEvent extends Equatable { + const LandClassificationEvent(); + + @override + List get props => []; +} + +class AddLandClassification extends LandClassificationEvent { + final int id; + final String classificationCode; + final String description; + + const AddLandClassification({ + required this.id, + required this.classificationCode, + required this.description, + }); + + @override + List get props => [ + id, + classificationCode, + description, + ]; +} + +class LoadLandClassification extends LandClassificationEvent { + const LoadLandClassification(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_state.dart b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_state.dart new file mode 100644 index 0000000..52d8921 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_classification/land_classification_state.dart @@ -0,0 +1,18 @@ +part of 'land_classification_bloc.dart'; + +class LandClassificationState extends Equatable { + const LandClassificationState(); + + @override + List get props => []; +} + +class LandClassificationInitial extends LandClassificationState {} + +class LandClassificationLoaded extends LandClassificationState { + final List landClassification; + + const LandClassificationLoaded({required this.landClassification}); + @override + List get props => [landClassification]; +} diff --git a/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart new file mode 100644 index 0000000..bf884b3 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart @@ -0,0 +1,39 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_subclassification.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_subclassification_event.dart'; +part 'land_subclassification_state.dart'; + +class LandSubclassificationBloc + extends Bloc { + LandSubclassificationBloc() : super(LandSubclassificationInitial()) { + List landSubClassification = []; + on((event, emit) async { + landSubClassification = + await SQLServices.instance.readAllLandSubClassification(); + + emit(LandSubClassificationLoaded( + landSubClassification: landSubClassification)); + }); + on((event, emit) async { + landSubClassification = await SQLServices.instance + .readSpecificLandSubClassification(event.cityCode, event.classCode); + + emit(LandSubClassificationLoaded( + landSubClassification: landSubClassification)); + }); + on((event, emit) async { + await SQLServices.instance.createLandSubClassification( + LandSubClassification( + id: event.id, + classificationId: event.classificationId, + cityCode: event.cityCode, + subclassCode: event.subclassCode, + subclassDescription: event.subclassDescription, + baseUnitMarketval: event.baseUnitMarketval)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_event.dart b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_event.dart new file mode 100644 index 0000000..ff1c2c0 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_event.dart @@ -0,0 +1,54 @@ +part of 'land_subclassification_bloc.dart'; + +class LandSubclassificationEvent extends Equatable { + const LandSubclassificationEvent(); + + @override + List get props => []; +} + +class AddLandSubClassification extends LandSubclassificationEvent { + final int id; + final int classificationId; + final String cityCode; + final String subclassCode; + final String subclassDescription; + final String baseUnitMarketval; + + const AddLandSubClassification({ + required this.id, + required this.classificationId, + required this.cityCode, + required this.subclassCode, + required this.subclassDescription, + required this.baseUnitMarketval, + }); + + @override + List get props => [ + id, + classificationId, + cityCode, + subclassCode, + subclassDescription, + baseUnitMarketval, + ]; +} + +class LoadLandSubClassification extends LandSubclassificationEvent { + const LoadLandSubClassification(); + + @override + List get props => []; +} + +class LoadSpecificLandSubClassification extends LandSubclassificationEvent { + final String cityCode; + final int classCode; + + const LoadSpecificLandSubClassification( + {required this.cityCode, required this.classCode}); + + @override + List get props => [cityCode, classCode]; +} diff --git a/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_state.dart b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_state.dart new file mode 100644 index 0000000..69cadc8 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_state.dart @@ -0,0 +1,18 @@ +part of 'land_subclassification_bloc.dart'; + +class LandSubclassificationState extends Equatable { + const LandSubclassificationState(); + + @override + List get props => []; +} + +class LandSubclassificationInitial extends LandSubclassificationState {} + +class LandSubClassificationLoaded extends LandSubclassificationState { + final List landSubClassification; + + const LandSubClassificationLoaded({required this.landSubClassification}); + @override + List get props => [landSubClassification]; +} diff --git a/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart new file mode 100644 index 0000000..33eac50 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart @@ -0,0 +1,27 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/trees_improvements.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'trees_improvements_event.dart'; +part 'trees_improvements_state.dart'; + +class TreesImprovementsBloc + extends Bloc { + TreesImprovementsBloc() : super(TreesImprovementsInitial()) { + List treesImprovements = []; + on((event, emit) async { + treesImprovements = await SQLServices.instance.readAllTreesImprovements(); + + emit(TreesImprovementsLoaded(treesImprovements: treesImprovements)); + }); + on((event, emit) async { + await SQLServices.instance.createTreesImprovements(TreesImprovements( + id: event.id, + improvement: event.improvement, + pricePerTree: event.pricePerTree, + subclassCode: event.subclassCode)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_event.dart b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_event.dart new file mode 100644 index 0000000..8d2dfa9 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_event.dart @@ -0,0 +1,37 @@ +part of 'trees_improvements_bloc.dart'; + +class TreesImprovementsEvent extends Equatable { + const TreesImprovementsEvent(); + + @override + List get props => []; +} + +class AddTreesImprovements extends TreesImprovementsEvent { + final int id; + final String improvement; + final String pricePerTree; + final dynamic subclassCode; + + const AddTreesImprovements({ + required this.id, + required this.improvement, + required this.pricePerTree, + required this.subclassCode, + }); + + @override + List get props => [ + id, + improvement, + pricePerTree, + subclassCode, + ]; +} + +class LoadTreesImprovements extends TreesImprovementsEvent { + const LoadTreesImprovements(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_state.dart b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_state.dart new file mode 100644 index 0000000..9d9209c --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_state.dart @@ -0,0 +1,18 @@ +part of 'trees_improvements_bloc.dart'; + +class TreesImprovementsState extends Equatable { + const TreesImprovementsState(); + + @override + List get props => []; +} + +class TreesImprovementsInitial extends TreesImprovementsState {} + +class TreesImprovementsLoaded extends TreesImprovementsState { + final List treesImprovements; + + const TreesImprovementsLoaded({required this.treesImprovements}); + @override + List get props => [treesImprovements]; +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart new file mode 100644 index 0000000..82a4f61 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart @@ -0,0 +1,27 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/type_of_location.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'type_of_location_event.dart'; +part 'type_of_location_state.dart'; + +class TypeOfLocationBloc + extends Bloc { + TypeOfLocationBloc() : super(TypeOfLocationInitial()) { + List typeOfLocation = []; + on((event, emit) async { + typeOfLocation = await SQLServices.instance.readAllTypeOfLocation(); + + emit(TypeOfLocationLoaded(typeOfLocation: typeOfLocation)); + }); + on((event, emit) async { + await SQLServices.instance.createTypeOfLocation(TypeOfLocation( + id: event.id, + distanceKm: event.distanceKm, + allRoadTypes: event.allRoadTypes, + localTradingCenter: event.localTradingCenter)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_event.dart b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_event.dart new file mode 100644 index 0000000..c25637e --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_event.dart @@ -0,0 +1,37 @@ +part of 'type_of_location_bloc.dart'; + +class TypeOfLocationEvent extends Equatable { + const TypeOfLocationEvent(); + + @override + List get props => []; +} + +class AddTypeOfLocation extends TypeOfLocationEvent { + final int id; + final String distanceKm; + final String allRoadTypes; + final String localTradingCenter; + + const AddTypeOfLocation({ + required this.id, + required this.distanceKm, + required this.allRoadTypes, + required this.localTradingCenter, + }); + + @override + List get props => [ + id, + distanceKm, + allRoadTypes, + localTradingCenter, + ]; +} + +class LoadTypeOfLocation extends TypeOfLocationEvent { + const LoadTypeOfLocation(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_state.dart b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_state.dart new file mode 100644 index 0000000..9e0884b --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_location/type_of_location_state.dart @@ -0,0 +1,18 @@ +part of 'type_of_location_bloc.dart'; + +class TypeOfLocationState extends Equatable { + const TypeOfLocationState(); + + @override + List get props => []; +} + +class TypeOfLocationInitial extends TypeOfLocationState {} + +class TypeOfLocationLoaded extends TypeOfLocationState { + final List typeOfLocation; + + const TypeOfLocationLoaded({required this.typeOfLocation}); + @override + List get props => [typeOfLocation]; +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart new file mode 100644 index 0000000..565a92c --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart @@ -0,0 +1,26 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/type_of_road.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'type_of_road_event.dart'; +part 'type_of_road_state.dart'; + +class TypeOfRoadBloc extends Bloc { + TypeOfRoadBloc() : super(TypeOfRoadInitial()) { + List typeOfRoad = []; + on((event, emit) async { + typeOfRoad = await SQLServices.instance.readAllTypeOfRoad(); + + emit(TypeOfRoadLoaded(typeOfRoad: typeOfRoad)); + }); + on((event, emit) async { + await SQLServices.instance.createTypeOfRoad(TypeOfRoad( + id: event.id, + roadType: event.roadType, + deduction: event.deduction, + )); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_event.dart b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_event.dart new file mode 100644 index 0000000..54731f8 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_event.dart @@ -0,0 +1,34 @@ +part of 'type_of_road_bloc.dart'; + +class TypeOfRoadEvent extends Equatable { + const TypeOfRoadEvent(); + + @override + List get props => []; +} + +class AddTypeOfRoad extends TypeOfRoadEvent { + final int id; + final String roadType; + final String deduction; + + const AddTypeOfRoad({ + required this.id, + required this.roadType, + required this.deduction, + }); + + @override + List get props => [ + id, + roadType, + deduction, + ]; +} + +class LoadTypeOfRoad extends TypeOfRoadEvent { + const LoadTypeOfRoad(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_state.dart b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_state.dart new file mode 100644 index 0000000..6f389f1 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/type_of_road/type_of_road_state.dart @@ -0,0 +1,18 @@ +part of 'type_of_road_bloc.dart'; + +class TypeOfRoadState extends Equatable { + const TypeOfRoadState(); + + @override + List get props => []; +} + +class TypeOfRoadInitial extends TypeOfRoadState {} + +class TypeOfRoadLoaded extends TypeOfRoadState { + final List typeOfRoad; + + const TypeOfRoadLoaded({required this.typeOfRoad}); + @override + List get props => [typeOfRoad]; +} diff --git a/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart new file mode 100644 index 0000000..be4159f --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart @@ -0,0 +1,31 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_value_adjustment.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'value_adjustments_event.dart'; +part 'value_adjustments_state.dart'; + +class ValueAdjustmentsBloc + extends Bloc { + ValueAdjustmentsBloc() : super(ValueAdjustmentsInitial()) { + List valueAdjustments = []; + on((event, emit) async { + valueAdjustments = await SQLServices.instance.readAllValueAdjustments(); + + emit(ValueAdjustmentsLoaded(valueAdjustments: valueAdjustments)); + }); + on((event, emit) async { + await SQLServices.instance.createValueAdjustments(ValueAdjustments( + id: event.id, + landapprDetailsId: event.landapprDetailsId, + baseMarketval: event.baseMarketval, + adjustmentFactors: event.adjustmentFactors, + adjustment: event.adjustment, + valueAdjustment: event.valueAdjustment, + marketValue: event.marketValue, + )); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_event.dart b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_event.dart new file mode 100644 index 0000000..196818f --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_event.dart @@ -0,0 +1,46 @@ +part of 'value_adjustments_bloc.dart'; + +class ValueAdjustmentsEvent extends Equatable { + const ValueAdjustmentsEvent(); + + @override + List get props => []; +} + +class AddValueAdjustments extends ValueAdjustmentsEvent { + final int id; + final int landapprDetailsId; + final String baseMarketval; + final String adjustmentFactors; + final String adjustment; + final String valueAdjustment; + final String marketValue; + + const AddValueAdjustments({ + required this.id, + required this.landapprDetailsId, + required this.baseMarketval, + required this.adjustmentFactors, + required this.adjustment, + required this.valueAdjustment, + required this.marketValue, + }); + + @override + List get props => [ + id, + landapprDetailsId, + baseMarketval, + adjustmentFactors, + adjustment, + valueAdjustment, + marketValue, + ]; +} + +class LoadValueAdjustments extends ValueAdjustmentsEvent { + const LoadValueAdjustments(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_state.dart b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_state.dart new file mode 100644 index 0000000..a61fcb4 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_state.dart @@ -0,0 +1,18 @@ +part of 'value_adjustments_bloc.dart'; + +class ValueAdjustmentsState extends Equatable { + const ValueAdjustmentsState(); + + @override + List get props => []; +} + +class ValueAdjustmentsInitial extends ValueAdjustmentsState {} + +class ValueAdjustmentsLoaded extends ValueAdjustmentsState { + final List valueAdjustments; + + const ValueAdjustmentsLoaded({required this.valueAdjustments}); + @override + List get props => [valueAdjustments]; +} diff --git a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart index 8565830..b154cc4 100644 --- a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart @@ -27,10 +27,9 @@ class AdditionalItemsOfflineBloc await SQLServices.instance.getAdditionalItems(event.id); if (result.isNotEmpty) { - List locationList = - result.map((map) => AdditionalItems.fromJson(map)).toList(); + addItems = result.map((map) => AdditionalItems.fromJson(map)).toList(); - emit(AdditionalItemsLoaded(addItem: locationList)); + emit(AdditionalItemsLoaded(addItem: addItems)); } else { print('No data found.'); } @@ -74,5 +73,11 @@ class AdditionalItemsOfflineBloc addItems = await SQLServices.instance.readAdditionalItems(); emit(AdditionalItemsLoaded(addItem: addItems)); }); + on((event, emit) async { + addItems + .removeWhere(((AdditionalItems element) => element.id == event.id)); + await SQLServices.instance.deleteAdditionalItems(id: event.id); + emit(const AdditionalItemsDeletedState(success: true)); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart index 4c5142e..75e9a6c 100644 --- a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart +++ b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart @@ -30,6 +30,10 @@ class AddAdditionalItems extends AdditionalItemsOfflineEvent { final int id; final int bldgapprDetailsId; final int classId; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; final String className; final String structType; final dynamic unitValue; @@ -49,6 +53,10 @@ class AddAdditionalItems extends AdditionalItemsOfflineEvent { required this.id, required this.bldgapprDetailsId, required this.classId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, required this.className, required this.structType, required this.unitValue, @@ -70,6 +78,10 @@ class AddAdditionalItems extends AdditionalItemsOfflineEvent { id, bldgapprDetailsId, classId, + assessedById, + assessedByName, + dateCreated, + dateModified, className, structType, unitValue, diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart index e151994..076bca4 100644 --- a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart @@ -31,5 +31,27 @@ class BldgAppraisalOfflineBloc totalArea: event.totalArea, actualUse: event.actualUse)); }); + on((event, emit) async { + List> result = + await SQLServices.instance.getBldgAppraisal(event.id); + + if (result.isNotEmpty) { + List appraisalList = + result.map((map) => PropertyAppraisal.fromJson2(map)).toList(); + + // Choose a specific element from locationList + PropertyAppraisal firstAppraisal = appraisalList + .first; // You can change this to select a specific item + + print('appraisal test result'); + print(firstAppraisal.toJson()); + emit(SpecificBldgAppraisalLoaded(appraisal: firstAppraisal)); + } else { + print('No data found.'); + } + }); + on((event, emit) async { + await SQLServices.instance.updateAppraisal(event.id, event.appraisal); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart index 6541288..9f4a1ae 100644 --- a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart @@ -12,8 +12,8 @@ class AddBldgAppraisal extends BldgAppraisalOfflineEvent { final int bldgapprDetailsId; final String assessedById; final String assessedByName; - final DateTime dateCreated; - final DateTime dateModified; + final String dateCreated; + final String dateModified; final String unitconstructCost; final String buildingCore; final String unitconstructSubtotal; @@ -66,3 +66,21 @@ class AddBldgAppraisal extends BldgAppraisalOfflineEvent { actualUse ]; } + +class FetchSingleBldgAppraisal extends BldgAppraisalOfflineEvent { + final int id; + const FetchSingleBldgAppraisal({required this.id}); + + @override + List get props => [id]; +} + +class UpdateAppraisal extends BldgAppraisalOfflineEvent { + final PropertyAppraisal appraisal; + final int id; + + const UpdateAppraisal({required this.id, required this.appraisal}); + + @override + List get props => [id, appraisal]; +} diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart index 07df647..0b3b3c7 100644 --- a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart @@ -27,3 +27,11 @@ class LoadSpecificBldgAppraisalOffline extends BldgAppraisalOfflineState { @override List get props => [appraisal]; } + +class SpecificBldgAppraisalLoaded extends BldgAppraisalOfflineState { + final PropertyAppraisal appraisal; + + const SpecificBldgAppraisalLoaded({required this.appraisal}); + @override + List get props => [appraisal]; +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart index a88fa3b..01af52e 100644 --- a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart @@ -21,8 +21,8 @@ class BldgAssessmentOfflineBloc assessedValue: event.assessedValue, taxable: event.taxable, exempt: event.exempt, - qtr: event.qtr, - yr: event.yr, + qtr: event.qtr.toString(), + yr: event.yr.toString(), appraisedbyName: event.appraisedbyName, appraisedbyDate: event.appraisedbyDate, recommendapprName: event.recommendapprName, @@ -34,5 +34,27 @@ class BldgAssessmentOfflineBloc entryDateAssessment: event.entryDateAssessment, entryDateBy: event.entryDateBy)); }); + on((event, emit) async { + List> result = + await SQLServices.instance.getBldgAssessment(event.id); + + if (result.isNotEmpty) { + List assessmentList = + result.map((map) => PropertyAssessment.fromJson2(map)).toList(); + + // Choose a specific element from locationList + PropertyAssessment firstAssessment = assessmentList + .first; // You can change this to select a specific item + + print('assessment test result'); + print(firstAssessment.toJson()); + emit(SpecificBldgAssessmentLoaded(assessment: firstAssessment)); + } else { + print('No data found.'); + } + }); + on((event, emit) async { + await SQLServices.instance.updateAssessment(event.id, event.assessment); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart index 6049057..35faeaf 100644 --- a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart @@ -10,28 +10,36 @@ class BldgAssessmentOfflineEvent extends Equatable { class AddBldgAssessment extends BldgAssessmentOfflineEvent { final int id; final int bldgapprDetailsId; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; final String actualUse; final String marketValue; final String assessmentLevel; final String assessedValue; - final bool taxable; - final bool exempt; + final String taxable; + final String exempt; final int qtr; final int yr; final String appraisedbyName; - final DateTime appraisedbyDate; + final String appraisedbyDate; final String recommendapprName; - final DateTime recommendapprDate; + final String recommendapprDate; final String approvedbyName; final String memoranda; final String swornstatementNo; - final DateTime dateReceived; - final DateTime entryDateAssessment; + final String dateReceived; + final String entryDateAssessment; final String entryDateBy; const AddBldgAssessment({ required this.id, required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, required this.actualUse, required this.marketValue, required this.assessmentLevel, @@ -56,6 +64,10 @@ class AddBldgAssessment extends BldgAssessmentOfflineEvent { List get props => [ id, bldgapprDetailsId, + assessedById, + assessedByName, + dateCreated, + dateModified, actualUse, marketValue, assessmentLevel, @@ -76,3 +88,21 @@ class AddBldgAssessment extends BldgAssessmentOfflineEvent { entryDateBy, ]; } + +class FetchSingleBldgAssessment extends BldgAssessmentOfflineEvent { + final int id; + const FetchSingleBldgAssessment({required this.id}); + + @override + List get props => [id]; +} + +class UpdateBldgAssessment extends BldgAssessmentOfflineEvent { + final PropertyAssessment assessment; + final int id; + + UpdateBldgAssessment({required this.id, required this.assessment}); + + @override + List get props => [id, assessment]; +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart index ba0f778..5a411ea 100644 --- a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart @@ -27,3 +27,11 @@ class LoadSpecificBldgAssessmentOffline extends BldgAssessmentOfflineState { @override List get props => [assessment]; } + +class SpecificBldgAssessmentLoaded extends BldgAssessmentOfflineState { + final PropertyAssessment assessment; + + const SpecificBldgAssessmentLoaded({required this.assessment}); + @override + List get props => [assessment]; +} diff --git a/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart new file mode 100644 index 0000000..25ec7cc --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart @@ -0,0 +1,66 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/building_and_structure.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'building_and_structure_event.dart'; +part 'building_and_structure_state.dart'; + +class BuildingAndStructureBloc + extends Bloc { + BuildingAndStructureBloc() : super(BuildingAndStructureOfflineInitial()) { + List bldgAndStructure = []; + on((event, emit) async { + emit(BuildingAndStructureOfflineInitial()); + try { + emit(BuildingAndStructureLoaded(bldgAndStructure: bldgAndStructure)); + } catch (e) { + emit(BuildingAndStructureErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(BuildingAndStructureOfflineInitial()); + List> result = + await SQLServices.instance.getBuildingAndStructure(event.id); + + if (result.isNotEmpty) { + bldgAndStructure = + result.map((map) => BldgAndStructure.fromJson(map)).toList(); + + emit(BuildingAndStructureLoaded(bldgAndStructure: bldgAndStructure)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + BldgAndStructure item = await SQLServices.instance + .createBuildingAndStructure(event.bldgAndStructure); + + print(item.toJson()); + + bldgAndStructure.add(item); + + emit(BuildingAndStructureLoaded(bldgAndStructure: bldgAndStructure)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowBldgAndStructuresScreen()); + }); + on((event, emit) async { + bldgAndStructure = await SQLServices.instance.readBuildingAndStructure(); + emit(BuildingAndStructureLoaded(bldgAndStructure: bldgAndStructure)); + }); + on((event, emit) async { + bldgAndStructure + .removeWhere(((BldgAndStructure element) => element.id == event.id)); + await SQLServices.instance.deleteBuildingAndStructure(id: event.id); + emit(const BuildingAndStructureDeletedState(success: true)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_event.dart b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_event.dart new file mode 100644 index 0000000..5d5799a --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_event.dart @@ -0,0 +1,68 @@ +part of 'building_and_structure_bloc.dart'; + +class BuildingAndStructureEvent extends Equatable { + const BuildingAndStructureEvent(); + + @override + List get props => []; +} + +class LoadBuildingAndStructure extends BuildingAndStructureEvent { + final List bldgAndStructure; + + const LoadBuildingAndStructure( + {this.bldgAndStructure = const []}); + + @override + List get props => [bldgAndStructure]; +} + +class LoadBuildingAndStructureEdit extends BuildingAndStructureEvent { + final List bldgAndStructure; + final int? id; + + const LoadBuildingAndStructureEdit({required this.bldgAndStructure, this.id}); + + @override + List get props => [bldgAndStructure]; +} + +class AddBuildingAndStructure extends BuildingAndStructureEvent { + final BldgAndStructure bldgAndStructure; + + const AddBuildingAndStructure({required this.bldgAndStructure}); + + @override + List get props => [bldgAndStructure]; +} + +class UpdateBuildingAndStructure extends BuildingAndStructureEvent { + final BldgAndStructure addItems; + const UpdateBuildingAndStructure({required this.addItems}); + @override + List get props => [addItems]; +} + +class FetchBuildingAndStructure extends BuildingAndStructureEvent { + const FetchBuildingAndStructure(); + + @override + List get props => []; +} + +class FetchSpecificBuildingAndStructure extends BuildingAndStructureEvent { + final int id; + const FetchSpecificBuildingAndStructure({required this.id}); + + @override + List get props => [id]; +} + +class DeleteBuildingAndStructure extends BuildingAndStructureEvent { + final int id; + const DeleteBuildingAndStructure({required this.id}); + @override + List get props => [id]; +} + +class ShowBuildingAndStructure extends BuildingAndStructureEvent {} diff --git a/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_state.dart b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_state.dart new file mode 100644 index 0000000..4917c66 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_state.dart @@ -0,0 +1,46 @@ +part of 'building_and_structure_bloc.dart'; + +class BuildingAndStructureState extends Equatable { + const BuildingAndStructureState(); + + @override + List get props => []; +} + +class BuildingAndStructureOfflineInitial extends BuildingAndStructureState { + @override + List get props => []; +} + +class BuildingAndStructureLoaded extends BuildingAndStructureState { + final List bldgAndStructure; + + const BuildingAndStructureLoaded({required this.bldgAndStructure}); + @override + List get props => [bldgAndStructure]; +} + +class LoadSpecificBuildingAndStructure extends BuildingAndStructureState { + final BldgAndStructure bldgAndStructure; + + const LoadSpecificBuildingAndStructure({required this.bldgAndStructure}); + @override + List get props => [bldgAndStructure]; +} + +class ShowBldgAndStructuresScreen extends BuildingAndStructureState {} + +class BuildingAndStructureErrorState extends BuildingAndStructureState { + const BuildingAndStructureErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class BuildingAndStructureDeletedState extends BuildingAndStructureState { + final bool success; + const BuildingAndStructureDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart index 1765217..79d3947 100644 --- a/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart @@ -34,7 +34,8 @@ class GeneralDescriptionBloc area4Thfloor: event.area4Thfloor, totalFloorArea: event.totalFloorArea, floorSketch: event.floorSketch, - actualUse: event.actualUse)); + actualUse: event.actualUse, + unitValue: event.unitValue)); }); on((event, emit) async { List> result = @@ -55,5 +56,9 @@ class GeneralDescriptionBloc print('No data found.'); } }); + on((event, emit) async { + await SQLServices.instance + .updateGeneralDescription(event.id, event.gendesc); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart index 5551f79..b35f5bc 100644 --- a/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart @@ -12,6 +12,8 @@ class AddGendesc extends GeneralDescriptionEvent { final int bldgapprDetailsId; final String assessedById; final String assessedByName; + final String dateCreated; + final String dateModified; final String bldgKind; final String strucType; final String bldgPermit; @@ -30,31 +32,34 @@ class AddGendesc extends GeneralDescriptionEvent { final String totalFloorArea; final dynamic floorSketch; final String actualUse; + final String unitValue; - const AddGendesc({ - required this.id, - required this.bldgapprDetailsId, - required this.assessedById, - required this.assessedByName, - required this.bldgKind, - required this.strucType, - required this.bldgPermit, - required this.dateIssued, - required this.cct, - required this.certCompletionIssued, - required this.certOccupancyIssued, - required this.dateCompleted, - required this.dateOccupied, - required this.bldgAge, - required this.noStoreys, - required this.area1Stfloor, - required this.area2Ndfloor, - required this.area3Rdfloor, - required this.area4Thfloor, - required this.totalFloorArea, - required this.floorSketch, - required this.actualUse, - }); + const AddGendesc( + {required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.bldgKind, + required this.strucType, + required this.bldgPermit, + required this.dateIssued, + required this.cct, + required this.certCompletionIssued, + required this.certOccupancyIssued, + required this.dateCompleted, + required this.dateOccupied, + required this.bldgAge, + required this.noStoreys, + required this.area1Stfloor, + required this.area2Ndfloor, + required this.area3Rdfloor, + required this.area4Thfloor, + required this.totalFloorArea, + required this.floorSketch, + required this.actualUse, + required this.unitValue}); @override List get props => [ @@ -62,6 +67,8 @@ class AddGendesc extends GeneralDescriptionEvent { bldgapprDetailsId, assessedById, assessedByName, + dateCreated, + dateModified, bldgKind, strucType, bldgPermit, @@ -80,6 +87,7 @@ class AddGendesc extends GeneralDescriptionEvent { totalFloorArea, floorSketch, actualUse, + unitValue ]; } @@ -90,3 +98,13 @@ class FetchSingleGeneralDescription extends GeneralDescriptionEvent { @override List get props => [id]; } + +class UpdateGeneralDescription extends GeneralDescriptionEvent { + final GeneralDesc gendesc; + final int id; + + UpdateGeneralDescription({required this.id, required this.gendesc}); + + @override + List get props => [id, gendesc]; +} diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart index acbc897..b11f6d9 100644 --- a/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart @@ -70,6 +70,10 @@ class LandrefLocationBloc } }); + on((event, emit) async { + await SQLServices.instance.updateLandRef(event.id, event.landRef); + }); + // on((event, emit) async { // await PropertyOwnerInfoServices.instance.delete(id: event.id); // add(const FetchTodos()); diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart index 02b42f4..6ded127 100644 --- a/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart @@ -19,20 +19,23 @@ class AddLandRef extends LandrefLocationEvent { final dynamic area; final dynamic surveyNo; final dynamic blkNo; + final String dateCreated; + final String dateModified; - const AddLandRef({ - required this.id, - required this.bldgapprDetailsId, - required this.assessedById, - required this.assessedByName, - required this.owner, - required this.cloaNo, - required this.lotNo, - required this.tdn, - required this.area, - required this.surveyNo, - required this.blkNo, - }); + const AddLandRef( + {required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.owner, + required this.cloaNo, + required this.lotNo, + required this.tdn, + required this.area, + required this.surveyNo, + required this.blkNo, + required this.dateCreated, + required this.dateModified}); @override List get props => [ @@ -46,15 +49,20 @@ class AddLandRef extends LandrefLocationEvent { tdn, area, surveyNo, - blkNo + blkNo, + dateCreated, + dateModified ]; } -class UpdateTodo extends LandrefLocationEvent { - final Todo todo; - const UpdateTodo({required this.todo}); +class UpdateBldgLandRef extends LandrefLocationEvent { + final LandRef landRef; + final int id; + + UpdateBldgLandRef({required this.id, required this.landRef}); + @override - List get props => [todo]; + List get props => [id, landRef]; } class FetchLanRef extends LandrefLocationEvent { diff --git a/lib/bloc/offline/offline_passo/building/location/location_bloc.dart b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart index d3324be..bd334ac 100644 --- a/lib/bloc/offline/offline_passo/building/location/location_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart @@ -3,8 +3,6 @@ import 'package:equatable/equatable.dart'; import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; import '../../../../../model/passo/bldg_loc.dart'; -import '../../../../../model/passo/todo.dart'; -import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; part 'location_event.dart'; part 'location_state.dart'; @@ -43,5 +41,8 @@ class LocationBloc extends Bloc { print('No data found.'); } }); + on((event, emit) async { + await SQLServices.instance.updateLocation(event.id, event.bldgLoc); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/location/location_event.dart b/lib/bloc/offline/offline_passo/building/location/location_event.dart index 94d3330..54f788a 100644 --- a/lib/bloc/offline/offline_passo/building/location/location_event.dart +++ b/lib/bloc/offline/offline_passo/building/location/location_event.dart @@ -16,17 +16,20 @@ class AddLocation extends LocationEvent { final String barangay; final String municipality; final String province; + final String dateCreated; + final String dateModified; - const AddLocation({ - required this.id, - required this.bldgapprDetailsId, - required this.assessedById, - required this.assessedByName, - required this.street, - required this.barangay, - required this.municipality, - required this.province, - }); + const AddLocation( + {required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.street, + required this.barangay, + required this.municipality, + required this.province, + required this.dateCreated, + required this.dateModified}); @override List get props => [ @@ -37,14 +40,19 @@ class AddLocation extends LocationEvent { barangay, municipality, province, + dateCreated, + dateModified ]; } -class UpdateTodo extends LocationEvent { - final Todo todo; - const UpdateTodo({required this.todo}); +class UpdateBldgLoc extends LocationEvent { + final BldgLoc bldgLoc; + final int id; + + UpdateBldgLoc({required this.id, required this.bldgLoc}); + @override - List get props => [todo]; + List get props => [id, bldgLoc]; } class FetchLanRef extends LocationEvent { diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart index 33f3ea4..3d33930 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart @@ -10,36 +10,50 @@ part 'crud_state.dart'; class CrudBloc extends Bloc { CrudBloc() : super(CrudInitial()) { - List todos = []; + List propertyOwner = []; on((event, emit) async { - await SQLServices.instance.createBldgOwner( - PropertyInfo( - transCode: event.transCode, - tdn: event.tdn, - pin: event.pin, - owner: event.owner, - address: event.address, - telno: event.telno, - tin: event.tin, - adminUser: event.adminUser, - adminAddress: event.adminAddress, - adminTelno: event.adminTelno, - adminTin: event.adminTin, - faasType: event.faasType, - assessedById: event.assessedById, - assessedByName: event.assessedByName), - ); + try { + PropertyInfo ownerInfo; + ownerInfo = await SQLServices.instance.createBldgOwner( + PropertyInfo( + transCode: event.transCode, + tdn: event.tdn, + pin: event.pin, + owner: event.owner, + address: event.address, + telno: event.telno, + tin: event.tin, + adminUser: event.adminUser, + adminAddress: event.adminAddress, + adminTelno: event.adminTelno, + adminTin: event.adminTin, + faasType: event.faasType, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified), + ); + + propertyOwner.add(ownerInfo); + + emit(PropertyInfoLoaded(propertyInfos: propertyOwner)); + } catch (e) { + emit(PropertyOwnerInfoErrorState(errorMessage: 'Failed to add todo')); + print('Error: $e'); + // You might want to throw or log the error, or take other appropriate actions + + // If you want to rethrow the error, uncomment the following line + // throw e; + } }); - on((event, emit) async { - await PropertyOwnerInfoServices.instance.update( - todo: event.todo, - ); + on((event, emit) async { + await SQLServices.instance.updateBldgOwner(event.id, event.propertyInfo); }); on((event, emit) async { - todos = await SQLServices.instance.readAllBldgOwner(); - emit(DisplayTodos(todo: todos)); + propertyOwner = await SQLServices.instance.readAllBldgOwner(); + emit(PropertyInfoLoaded(propertyInfos: propertyOwner)); }); // on((event, emit) async { diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart index 64198e6..c14ea95 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart @@ -20,6 +20,8 @@ class AddTodo extends CrudEvent { final String faasType; final String assessedById; final String assessedByName; + final String dateCreated; + final String dateModified; const AddTodo( {required this.id, @@ -36,7 +38,9 @@ class AddTodo extends CrudEvent { required this.adminTin, required this.faasType, required this.assessedById, - required this.assessedByName}); + required this.assessedByName, + required this.dateCreated, + required this.dateModified}); @override List get props => [ @@ -54,15 +58,20 @@ class AddTodo extends CrudEvent { adminTin, faasType, assessedById, - assessedByName + assessedByName, + dateCreated, + dateModified ]; } -class UpdateTodo extends CrudEvent { - final Todo todo; - const UpdateTodo({required this.todo}); +class UpdatePropertyOwnerInfo extends CrudEvent { + final PropertyInfo propertyInfo; + final int id; + + UpdatePropertyOwnerInfo({required this.id, required this.propertyInfo}); + @override - List get props => [todo]; + List get props => [id, propertyInfo]; } class FetchTodos extends CrudEvent { diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart index cfa94de..11058fc 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart @@ -9,12 +9,24 @@ class CrudInitial extends CrudState { List get props => []; } -class DisplayTodos extends CrudState { - final List todo; - - const DisplayTodos({required this.todo}); +class PropertyOwnerInfoLoading extends CrudState { @override - List get props => [todo]; + List get props => []; +} + +class PropertyOwnerInfoErrorState extends CrudState { + final String errorMessage; + const PropertyOwnerInfoErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} + +class PropertyInfoLoaded extends CrudState { + final List propertyInfos; + + const PropertyInfoLoaded({required this.propertyInfos}); + @override + List get props => [propertyInfos]; } class DisplaySpecificTodo extends CrudState { diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart index 1749177..4d0785c 100644 --- a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart @@ -32,7 +32,7 @@ class StructuralMaterialOfflineBloc extends Bloc materialList = - result.map((map) => StructureMaterials.fromJson(map)).toList(); + result.map((map) => StructureMaterials.fromJson2(map)).toList(); // Choose a specific element from locationList StructureMaterials firstMaterial = @@ -45,5 +45,9 @@ class StructuralMaterialOfflineBloc extends Bloc((event, emit) async { + await SQLServices.instance + .updateStructuralMaterial(event.id, event.materials); + }); } } diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart index 18ef539..9f3509f 100644 --- a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart @@ -18,19 +18,26 @@ class AddStructuralMaterial extends StructuralMaterialOfflineEvent { final List? flooring; final List? walls; final List? others; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; - const AddStructuralMaterial({ - required this.id, - required this.bldgapprDetailsId, - required this.foundation, - required this.columns, - required this.beams, - required this.trussFraming, - required this.roof, - required this.flooring, - required this.walls, - required this.others, - }); + const AddStructuralMaterial( + {required this.id, + required this.bldgapprDetailsId, + required this.foundation, + required this.columns, + required this.beams, + required this.trussFraming, + required this.roof, + required this.flooring, + required this.walls, + required this.others, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified}); @override List get props => [ @@ -43,7 +50,11 @@ class AddStructuralMaterial extends StructuralMaterialOfflineEvent { ...?roof, ...?flooring, ...?walls, - ...?others + ...?others, + assessedById, + assessedByName, + dateCreated, + dateModified ]; } @@ -54,3 +65,13 @@ class FetchSingleStructuralMaterial extends StructuralMaterialOfflineEvent { @override List get props => [id]; } + +class UpdateStructuralMaterials extends StructuralMaterialOfflineEvent { + final StructureMaterialsII materials; + final int id; + + UpdateStructuralMaterials({required this.id, required this.materials}); + + @override + List get props => [id, materials]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart new file mode 100644 index 0000000..3e6e278 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart @@ -0,0 +1,71 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/model/passo/land_appr.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_appraisal_event.dart'; +part 'land_property_appraisal_state.dart'; + +class LandPropertyAppraisalBloc + extends Bloc { + LandPropertyAppraisalBloc() : super(LandPropertyAppraisalInitial()) { + List landAppr = []; + on((event, emit) async { + emit(LandPropertyAppraisalInitial()); + try { + emit(LandPropertyAppraisalLoaded(landAppr: landAppr)); + } catch (e) { + emit(LandPropertyAppraisalErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(LandPropertyAppraisalInitial()); + List> result = + await SQLServices.instance.getLandPropertyAppraisal(event.id); + + if (result.isNotEmpty) { + landAppr = result.map((map) => LandAppr.fromJson2(map)).toList(); + + emit(LandPropertyAppraisalLoaded(landAppr: landAppr)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + print(event); + LandAppr item = await SQLServices.instance.createLandAppraisal(LandAppr( + landapprDetailsId: event.landapprDetailsId, + classification: event.classification, + subClass: event.subClass, + area: event.area, + unitValue: event.unitValue, + baseMarketval: event.baseMarketval)); + + print('Appraisal'); + print(item.toJson()); + + landAppr.add(item); + + emit(LandPropertyAppraisalLoaded(landAppr: landAppr)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowAddItemsScreen()); + }); + // on((event, emit) async { + // addItems = await SQLServices.instance.readAdditionalItems(); + // emit(AdditionalItemsLoaded(addItem: addItems)); + // }); + on((event, emit) async { + landAppr.removeWhere(((LandAppr element) => element.id == event.id)); + await SQLServices.instance.deleteLandPropertyAppraisal(id: event.id); + emit(const LandPropertyAppraisalDeletedState(success: true)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_event.dart b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_event.dart new file mode 100644 index 0000000..64670f0 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_event.dart @@ -0,0 +1,86 @@ +part of 'land_property_appraisal_bloc.dart'; + +class LandPropertyAppraisalEvent extends Equatable { + const LandPropertyAppraisalEvent(); + + @override + List get props => []; +} + +class LoadLandPropertyAppraisal extends LandPropertyAppraisalEvent { + final List landAppr; + + const LoadLandPropertyAppraisal({this.landAppr = const []}); + + @override + List get props => [landAppr]; +} + +class LoadLandPropertyAppraisalEdit extends LandPropertyAppraisalEvent { + final List landAppr; + final int? id; + + const LoadLandPropertyAppraisalEdit({required this.landAppr, this.id}); + + @override + List get props => [landAppr]; +} + +class AddLandPropertyAppraisal extends LandPropertyAppraisalEvent { + final int landapprDetailsId; + final String classification; + final String subClass; + final String area; + final String unitValue; + final String baseMarketval; + + const AddLandPropertyAppraisal({ + required this.landapprDetailsId, + required this.classification, + required this.subClass, + required this.area, + required this.unitValue, + required this.baseMarketval, + }); + + @override + List get props => [ + landapprDetailsId, + classification, + subClass, + area, + unitValue, + baseMarketval, + ]; +} + +class UpdateLandPropertyAppraisal extends LandPropertyAppraisalEvent { + final LandAppr landAppr; + const UpdateLandPropertyAppraisal({required this.landAppr}); + @override + List get props => [landAppr]; +} + +class FetchLandPropertyAppraisal extends LandPropertyAppraisalEvent { + const FetchLandPropertyAppraisal(); + + @override + List get props => []; +} + +class FetchSpecificLandPropertyAppraisal extends LandPropertyAppraisalEvent { + final int id; + const FetchSpecificLandPropertyAppraisal({required this.id}); + + @override + List get props => [id]; +} + +class DeleteLandPropertyAppraisal extends LandPropertyAppraisalEvent { + final int id; + const DeleteLandPropertyAppraisal({required this.id}); + @override + List get props => [id]; +} + +class ShowAdditionalItems extends LandPropertyAppraisalEvent {} diff --git a/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_state.dart b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_state.dart new file mode 100644 index 0000000..5a63020 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_state.dart @@ -0,0 +1,46 @@ +part of 'land_property_appraisal_bloc.dart'; + +class LandPropertyAppraisalState extends Equatable { + const LandPropertyAppraisalState(); + + @override + List get props => []; +} + +class LandPropertyAppraisalInitial extends LandPropertyAppraisalState { + @override + List get props => []; +} + +class LandPropertyAppraisalLoaded extends LandPropertyAppraisalState { + final List landAppr; + + const LandPropertyAppraisalLoaded({required this.landAppr}); + @override + List get props => [landAppr]; +} + +class LoadSpecificLandPropertyAppraisal extends LandPropertyAppraisalState { + final LandAppr landAppr; + + const LoadSpecificLandPropertyAppraisal({required this.landAppr}); + @override + List get props => [landAppr]; +} + +class ShowAddItemsScreen extends LandPropertyAppraisalState {} + +class LandPropertyAppraisalErrorState extends LandPropertyAppraisalState { + const LandPropertyAppraisalErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class LandPropertyAppraisalDeletedState extends LandPropertyAppraisalState { + final bool success; + const LandPropertyAppraisalDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart new file mode 100644 index 0000000..2d99f77 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart @@ -0,0 +1,72 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_property_assessment.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_assessment_event.dart'; +part 'land_property_assessment_state.dart'; + +class LandPropertyAssessmentBloc + extends Bloc { + LandPropertyAssessmentBloc() : super(LandPropertyAssessmentInitial()) { + List landPropertyAssessment = []; + on((event, emit) async { + emit(LandPropertyAssessmentInitial()); + try { + emit(LandPropertyAssessmentLoaded( + landPropertyAssessment: landPropertyAssessment)); + } catch (e) { + emit(LandPropertyAssessmentErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(LandPropertyAssessmentInitial()); + List> result = + await SQLServices.instance.getLandPropertyAssessment(event.id); + + if (result.isNotEmpty) { + landPropertyAssessment = + result.map((map) => LandPropertyAssessment.fromJson2(map)).toList(); + + emit(LandPropertyAssessmentLoaded( + landPropertyAssessment: landPropertyAssessment)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + LandPropertyAssessment item = await SQLServices.instance + .createLandPropertyAssessment(LandPropertyAssessment( + landapprDetailsId: event.landapprDetailsId, + actualUse: event.actualUse, + marketval: event.marketval, + assessmentLevel: event.assessmentLevel, + assessedValue: event.assessedValue, + totalMarketval: event.totalMarketval, + totalAssessedval: event.totalAssessedval, + )); + + print(item.toJson()); + + landPropertyAssessment.add(item); + + emit(LandPropertyAssessmentLoaded( + landPropertyAssessment: landPropertyAssessment)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowLandPropertyAssessmentcreen()); + }); + on((event, emit) async { + landPropertyAssessment.removeWhere( + ((LandPropertyAssessment element) => element.id == event.id)); + await SQLServices.instance.deleteLandPropertyAssessment(id: event.id); + emit(const LandPropertyAssessmentDeletedState(success: true)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_event.dart b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_event.dart new file mode 100644 index 0000000..4e61c9b --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_event.dart @@ -0,0 +1,91 @@ +part of 'land_property_assessment_bloc.dart'; + +class LandPropertyAssessmentEvent extends Equatable { + const LandPropertyAssessmentEvent(); + + @override + List get props => []; +} + +class LoadLandPropertyAssessment extends LandPropertyAssessmentEvent { + final List landPropertyAssessment; + + const LoadLandPropertyAssessment( + {this.landPropertyAssessment = const []}); + + @override + List get props => [landPropertyAssessment]; +} + +class LoadLandPropertyAssessmentEdit extends LandPropertyAssessmentEvent { + final List landPropertyAssessment; + final int? id; + + const LoadLandPropertyAssessmentEdit( + {required this.landPropertyAssessment, this.id}); + + @override + List get props => [landPropertyAssessment]; +} + +class AddLandPropertyAssessment extends LandPropertyAssessmentEvent { + final int landapprDetailsId; + final String actualUse; + final String marketval; + final String assessmentLevel; + final String assessedValue; + final String totalMarketval; + final String totalAssessedval; + + const AddLandPropertyAssessment({ + required this.landapprDetailsId, + required this.actualUse, + required this.marketval, + required this.assessmentLevel, + required this.assessedValue, + required this.totalMarketval, + required this.totalAssessedval, + }); + + @override + List get props => [ + landapprDetailsId, + actualUse, + marketval, + assessmentLevel, + assessedValue, + totalMarketval, + totalAssessedval, + ]; +} + +class UpdateLandPropertyAssessment extends LandPropertyAssessmentEvent { + final LandPropertyAssessment landPropertyAssessment; + const UpdateLandPropertyAssessment({required this.landPropertyAssessment}); + @override + List get props => [landPropertyAssessment]; +} + +class FetchLandPropertyAssessment extends LandPropertyAssessmentEvent { + const FetchLandPropertyAssessment(); + + @override + List get props => []; +} + +class FetchSpecificLandPropertyAssessment extends LandPropertyAssessmentEvent { + final int id; + const FetchSpecificLandPropertyAssessment({required this.id}); + + @override + List get props => [id]; +} + +class DeleteLandPropertyAssessment extends LandPropertyAssessmentEvent { + final int id; + const DeleteLandPropertyAssessment({required this.id}); + @override + List get props => [id]; +} + +class ShowLandPropertyAssessment extends LandPropertyAssessmentEvent {} diff --git a/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_state.dart b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_state.dart new file mode 100644 index 0000000..5fd09f7 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_state.dart @@ -0,0 +1,47 @@ +part of 'land_property_assessment_bloc.dart'; + +class LandPropertyAssessmentState extends Equatable { + const LandPropertyAssessmentState(); + + @override + List get props => []; +} + +class LandPropertyAssessmentInitial extends LandPropertyAssessmentState { + @override + List get props => []; +} + +class LandPropertyAssessmentLoaded extends LandPropertyAssessmentState { + final List landPropertyAssessment; + + const LandPropertyAssessmentLoaded({required this.landPropertyAssessment}); + @override + List get props => [landPropertyAssessment]; +} + +class LoadSpecificLandPropertyAssessment extends LandPropertyAssessmentState { + final LandPropertyAssessment landPropertyAssessment; + + const LoadSpecificLandPropertyAssessment( + {required this.landPropertyAssessment}); + @override + List get props => [landPropertyAssessment]; +} + +class ShowLandPropertyAssessmentcreen extends LandPropertyAssessmentState {} + +class LandPropertyAssessmentErrorState extends LandPropertyAssessmentState { + const LandPropertyAssessmentErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class LandPropertyAssessmentDeletedState extends LandPropertyAssessmentState { + final bool success; + const LandPropertyAssessmentDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart new file mode 100644 index 0000000..014bdf2 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart @@ -0,0 +1,55 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_property_boundaries.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_boundaries_event.dart'; +part 'land_property_boundaries_state.dart'; + +class LandPropertyBoundariesBloc + extends Bloc { + LandPropertyBoundariesBloc() : super(LandPropertyBoundariesInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createLandPropertyBoundaries( + LandPropertyBoundaries( + id: event.id, + landapprDetailsId: event.landapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified, + north: event.north, + east: event.east, + south: event.south, + west: event.west, + sketch: event.sketch)); + }); + on((event, emit) async { + List> result = + await SQLServices.instance.getLandPropertyBoundaries(event.id); + + if (result.isNotEmpty) { + List landpropertyboundariesList = + result.map((map) => LandPropertyBoundaries.fromJson(map)).toList(); + + // Choose a specific element from landpropertyboundariesList + LandPropertyBoundaries firstLandPropertyBoundaries = + landpropertyboundariesList + .first; // You can change this to select a specific item + + print('landpropertyboundaries test result'); + print(firstLandPropertyBoundaries); + emit(SpecificLandPropertyBoundariesLoaded( + landpropertyboundaries: firstLandPropertyBoundaries)); + } else { + print('No data found.'); + } + }); + on((event, emit) async { + await SQLServices.instance + .updateLandPropertyBoundaries(event.id, event.landPropertyBoundaries); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_event.dart b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_event.dart new file mode 100644 index 0000000..e89773a --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_event.dart @@ -0,0 +1,77 @@ +part of 'land_property_boundaries_bloc.dart'; + +class LandPropertyBoundariesEvent extends Equatable { + const LandPropertyBoundariesEvent(); + + @override + List get props => []; +} + +class AddLandPropertyBoundaries extends LandPropertyBoundariesEvent { + final int id; + final int landapprDetailsId; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; + final String north; + final String east; + final String south; + final String west; + final String sketch; + + const AddLandPropertyBoundaries({ + required this.id, + required this.landapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.north, + required this.east, + required this.south, + required this.west, + required this.sketch, + }); + + @override + List get props => [ + id, + landapprDetailsId, + assessedById, + assessedByName, + dateCreated, + dateModified, + north, + east, + south, + west, + sketch, + ]; +} + +class UpdateLandPropertyBoundaries extends LandPropertyBoundariesEvent { + final LandPropertyBoundaries landPropertyBoundaries; + final int id; + + UpdateLandPropertyBoundaries( + {required this.id, required this.landPropertyBoundaries}); + + @override + List get props => [id, landPropertyBoundaries]; +} + +class FetchLanRef extends LandPropertyBoundariesEvent { + const FetchLanRef(); + + @override + List get props => []; +} + +class FetchSingleLandPropertyBoundaries extends LandPropertyBoundariesEvent { + final int id; + const FetchSingleLandPropertyBoundaries({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_state.dart b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_state.dart new file mode 100644 index 0000000..8e49360 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_state.dart @@ -0,0 +1,30 @@ +part of 'land_property_boundaries_bloc.dart'; + +class LandPropertyBoundariesState extends Equatable { + const LandPropertyBoundariesState(); + + @override + List get props => []; +} + +class LandPropertyBoundariesInitial extends LandPropertyBoundariesState { + @override + List get props => []; +} + +class LandPropertyBoundariesLoaded extends LandPropertyBoundariesState { + final List landpropertyboundaries; + + const LandPropertyBoundariesLoaded({required this.landpropertyboundaries}); + @override + List get props => [landpropertyboundaries]; +} + +class SpecificLandPropertyBoundariesLoaded extends LandPropertyBoundariesState { + final LandPropertyBoundaries landpropertyboundaries; + + const SpecificLandPropertyBoundariesLoaded( + {required this.landpropertyboundaries}); + @override + List get props => [landpropertyboundaries]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart new file mode 100644 index 0000000..57b5375 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart @@ -0,0 +1,58 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_property_loc.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_location_event.dart'; +part 'land_property_location_state.dart'; + +class LandPropertyLocationBloc + extends Bloc { + LandPropertyLocationBloc() : super(LandPropertyLocationInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createLandLocation(LandPropertyLoc( + id: event.id, + landapprDetailsId: event.landapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified, + street: event.street, + municipality: event.municipality, + barangay: event.barangay, + province: event.province, + )); + }); + on((event, emit) async { + // todos = await SQLServices.instance.getLandPropertyOwner(); + // emit(LandPropertyOwnerLoaded(landPropertyOwner: todos)); + }); + + on((event, emit) async { + List> result = + await SQLServices.instance.getLandPropertyLocation(event.id); + + if (result.isNotEmpty) { + List landpropertylocationList = + result.map((map) => LandPropertyLoc.fromJson2(map)).toList(); + + // Choose a specific element from landpropertylocationList + LandPropertyLoc firstLandPropertyLocation = landpropertylocationList + .first; // You can change this to select a specific item + + print('landpropertylocation test result'); + print(firstLandPropertyLocation); + emit(SpecificLandPropertyLocationLoaded( + landpropertylocation: firstLandPropertyLocation)); + } else { + print('No data found.'); + } + }); + on((event, emit) async { + await SQLServices.instance + .updateLandPropertyLocation(event.id, event.landPropertyLocation); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_event.dart b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_event.dart new file mode 100644 index 0000000..8782757 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_event.dart @@ -0,0 +1,81 @@ +part of 'land_property_location_bloc.dart'; + +class LandPropertyLocationEvent extends Equatable { + const LandPropertyLocationEvent(); + + @override + List get props => []; +} + +class AddLandPropertyLocation extends LandPropertyLocationEvent { + final int id; + final int landapprDetailsId; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; + final String street; + final String municipality; + final String barangay; + final String province; + + const AddLandPropertyLocation({ + required this.id, + required this.landapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.street, + required this.municipality, + required this.barangay, + required this.province, + }); + + @override + List get props => [ + id, + landapprDetailsId, + assessedById, + assessedByName, + dateCreated, + dateModified, + street, + municipality, + barangay, + province, + ]; +} + +class UpdateLandPropertyLocation extends LandPropertyLocationEvent { + final LandPropertyLoc landPropertyLocation; + final int id; + + UpdateLandPropertyLocation( + {required this.id, required this.landPropertyLocation}); + + @override + List get props => [id, landPropertyLocation]; +} + +class LoadLandPropertyLocation extends LandPropertyLocationEvent { + const LoadLandPropertyLocation(); + + @override + List get props => []; +} + +class FetchLanRef extends LandPropertyLocationEvent { + const FetchLanRef(); + + @override + List get props => []; +} + +class FetchSingleLandPropertyLocation extends LandPropertyLocationEvent { + final int id; + const FetchSingleLandPropertyLocation({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_state.dart b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_state.dart new file mode 100644 index 0000000..dcdb7d6 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_location/land_property_location_state.dart @@ -0,0 +1,30 @@ +part of 'land_property_location_bloc.dart'; + +class LandPropertyLocationState extends Equatable { + const LandPropertyLocationState(); + + @override + List get props => []; +} + +class LandPropertyLocationInitial extends LandPropertyLocationState { + @override + List get props => []; +} + +class LandPropertyLocationLoaded extends LandPropertyLocationState { + final List landpropertylocation; + + const LandPropertyLocationLoaded({required this.landpropertylocation}); + @override + List get props => [landpropertylocation]; +} + +class SpecificLandPropertyLocationLoaded extends LandPropertyLocationState { + final LandPropertyLoc landpropertylocation; + + const SpecificLandPropertyLocationLoaded( + {required this.landpropertylocation}); + @override + List get props => [landpropertylocation]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart new file mode 100644 index 0000000..911288d --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart @@ -0,0 +1,71 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_owner_event.dart'; +part 'land_property_owner_state.dart'; + +class LandPropertyOwnerBloc + extends Bloc { + LandPropertyOwnerBloc() : super(LandPropertyOwnerInitial()) { + List todos = []; + on((event, emit) async { + try { + await SQLServices.instance.createLandOwner( + LandPropertyOwner( + id: event.id, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified, + transCode: event.transCode, + tdn: event.tdn, + pin: event.pin, + cloaNo: event.cloaNo, + dated: event.dated, + surveyNo: event.surveyNo, + lotNo: event.lotNo, + blkNo: event.blkNo, + owner: event.owner, + address: event.address, + telno: event.telno, + tin: event.tin, + adminUser: event.adminUser, + adminTelno: event.adminTelno, + adminAddress: event.adminAddress, + adminTin: event.adminTin, + faasType: event.faasType), + ); + } catch (e) { + emit(LandPropertyOwnerInfoErrorState(errorMessage: 'error')); + print('Error: $e'); + // You might want to throw or log the error, or take other appropriate actions + + // If you want to rethrow the error, uncomment the following line + // throw e; + } + }); + + on((event, emit) async { + await SQLServices.instance + .updateLandPropertyOwner(event.id, event.landPropertyOwner); + }); + + on((event, emit) async { + todos = await SQLServices.instance.getLandPropertyOwner(); + emit(LandPropertyOwnerLoaded(landPropertyOwner: todos)); + }); + + // on((event, emit) async { + // Prop todo = await PropertyOwnerInfoServices.instance.readTodo(id: event.id); + // emit(DisplaySpecificTodo(todo: todo)); + // }); + + on((event, emit) async { + await SQLServices.instance.deleteLandPropertyOwner(id: event.id); + add(const LoadLandPropertyOwner()); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_event.dart b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_event.dart new file mode 100644 index 0000000..6d7806b --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_event.dart @@ -0,0 +1,116 @@ +part of 'land_property_owner_bloc.dart'; + +class LandPropertyOwnerEvent extends Equatable { + const LandPropertyOwnerEvent(); + + @override + List get props => []; +} + +class AddLandPropertyOwner extends LandPropertyOwnerEvent { + final int id; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; + final String transCode; + final String tdn; + final String pin; + final String cloaNo; + final String dated; + final String surveyNo; + final String lotNo; + final String blkNo; + final String owner; + final String address; + final String telno; + final String tin; + final String adminUser; + final String adminAddress; + final String adminTelno; + final String adminTin; + final String faasType; + + const AddLandPropertyOwner( + {required this.id, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.transCode, + required this.tdn, + required this.pin, + required this.cloaNo, + required this.dated, + required this.surveyNo, + required this.lotNo, + required this.blkNo, + required this.owner, + required this.address, + required this.telno, + required this.tin, + required this.adminUser, + required this.adminTelno, + required this.adminAddress, + required this.adminTin, + required this.faasType}); + + @override + List get props => [ + id, + assessedById, + assessedByName, + dateCreated, + dateModified, + transCode, + tdn, + pin, + cloaNo, + dated, + surveyNo, + lotNo, + blkNo, + owner, + address, + telno, + tin, + adminUser, + adminTelno, + adminAddress, + adminTin, + faasType + ]; +} + +class UpdateLandPropertyOwnerInfo extends LandPropertyOwnerEvent { + final LandPropertyOwner landPropertyOwner; + final int id; + + const UpdateLandPropertyOwnerInfo( + {required this.id, required this.landPropertyOwner}); + + @override + List get props => [id, landPropertyOwner]; +} + +class LoadLandPropertyOwner extends LandPropertyOwnerEvent { + const LoadLandPropertyOwner(); + + @override + List get props => []; +} + +class LoadSpecificLandPropertyOwnerInfo extends LandPropertyOwnerEvent { + final int id; + const LoadSpecificLandPropertyOwnerInfo({required this.id}); + + @override + List get props => [id]; +} + +class DeleteLandPropertyOwner extends LandPropertyOwnerEvent { + final int id; + const DeleteLandPropertyOwner({required this.id}); + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_state.dart b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_state.dart new file mode 100644 index 0000000..666655b --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_state.dart @@ -0,0 +1,39 @@ +part of 'land_property_owner_bloc.dart'; + +class LandPropertyOwnerState extends Equatable { + @override + List get props => []; +} + +class LandPropertyOwnerInitial extends LandPropertyOwnerState { + @override + List get props => []; +} + +class LandPropertyOwnerInfoLoading extends LandPropertyOwnerState { + @override + List get props => []; +} + +class LandPropertyOwnerInfoErrorState extends LandPropertyOwnerState { + String errorMessage; + LandPropertyOwnerInfoErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} + +class LandPropertyOwnerLoaded extends LandPropertyOwnerState { + List landPropertyOwner; + + LandPropertyOwnerLoaded({required this.landPropertyOwner}); + @override + List get props => [landPropertyOwner]; +} + +class LoadSpecificLandPropertyOwner extends LandPropertyOwnerState { + LandPropertyOwner landPropertyOwner; + + LoadSpecificLandPropertyOwner({required this.landPropertyOwner}); + @override + List get props => [landPropertyOwner]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart new file mode 100644 index 0000000..d8d1530 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart @@ -0,0 +1,88 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_ext.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'land_property_signature_event.dart'; +part 'land_property_signature_state.dart'; + +class LandPropertySignatureBloc + extends Bloc { + LandPropertySignatureBloc() : super(LandPropertySignatureInitial()) { + List landExt = []; + on((event, emit) async { + try { + print(event.landapprDetailsId); + await SQLServices.instance.createLandPropertySignatories( + LandExt( + id: event.id, + landapprDetailsId: event.landapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified, + taxable: event.taxable, + exempt: event.exempt, + qtr: event.qtr, + yr: event.yr, + appraisedbyName: event.appraisedbyName, + appraisedbyDate: event.appraisedbyDate, + recommendapprName: event.recommendapprName, + recommendapprDate: event.recommendapprDate, + approvedbyName: event.approvedbyName, + approvedbyDate: event.approvedbyDate, + memoranda: event.memoranda, + swornstatementNo: event.swornstatementNo, + dateReceived: event.dateReceived, + entryDateAssessment: event.entryDateAssessment, + entryDateBy: event.entryDateBy, + ), + ); + } catch (e) { + emit(LandPropertySignatureInfoErrorState(errorMessage: 'error')); + print('Error: $e'); + // You might want to throw or log the error, or take other appropriate actions + + // If you want to rethrow the error, uncomment the following line + // throw e; + } + }); + + on((event, emit) async { + await SQLServices.instance + .updateLandPropertySignature(event.id, event.landPropertySignature); + }); + + // on((event, emit) async { + // todos = await SQLServices.instance.getLandPropertySignature(); + // emit(LandPropertySignatureLoaded(landPropertySignature: todos)); + // }); + + on((event, emit) async { + List> result = + await SQLServices.instance.getLandPropertySignature(event.id); + + if (result.isNotEmpty) { + List genDescList = + result.map((map) => LandExt.fromJson2(map)).toList(); + + // Choose a specific element from locationList + LandExt firstLandExt = + genDescList.first; // You can change this to select a specific item + + print('location test result'); + print(firstLandExt); + emit(LoadSpecificLandPropertySignature( + landPropertySignature: firstLandExt)); + } else { + print('No data found.'); + } + }); + + // on((event, emit) async { + // await SQLServices.instance.de(id: event.id); + // add(const LoadLandPropertySignature()); + // }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_event.dart b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_event.dart new file mode 100644 index 0000000..cdae6ef --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_event.dart @@ -0,0 +1,114 @@ +part of 'land_property_signature_bloc.dart'; + +class LandPropertySignatureEvent extends Equatable { + const LandPropertySignatureEvent(); + + @override + List get props => []; +} + +class AddLandPropertySignature extends LandPropertySignatureEvent { + final int id; + final int landapprDetailsId; + final String assessedById; + final String assessedByName; + final String dateCreated; + final String dateModified; + final String taxable; + final String exempt; + final String qtr; + final String yr; + final String appraisedbyName; + final String appraisedbyDate; + final String recommendapprName; + final String recommendapprDate; + final String approvedbyName; + final String approvedbyDate; + final String memoranda; + final String swornstatementNo; + final String dateReceived; + final String entryDateAssessment; + final String entryDateBy; + + const AddLandPropertySignature({ + required this.id, + required this.landapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.taxable, + required this.exempt, + required this.qtr, + required this.yr, + required this.appraisedbyName, + required this.appraisedbyDate, + required this.recommendapprName, + required this.recommendapprDate, + required this.approvedbyName, + required this.approvedbyDate, + required this.memoranda, + required this.swornstatementNo, + required this.dateReceived, + required this.entryDateAssessment, + required this.entryDateBy, + }); + + @override + List get props => [ + id, + landapprDetailsId, + assessedById, + assessedByName, + dateCreated, + dateModified, + taxable, + exempt, + qtr, + yr, + appraisedbyName, + appraisedbyDate, + recommendapprName, + recommendapprDate, + approvedbyName, + approvedbyDate, + memoranda, + swornstatementNo, + dateReceived, + entryDateAssessment, + entryDateBy, + ]; +} + +class UpdateLandPropertySignatureInfo extends LandPropertySignatureEvent { + final LandExt landPropertySignature; + final int id; + + const UpdateLandPropertySignatureInfo( + {required this.id, required this.landPropertySignature}); + + @override + List get props => [id, landPropertySignature]; +} + +class LoadLandPropertySignature extends LandPropertySignatureEvent { + const LoadLandPropertySignature(); + + @override + List get props => []; +} + +class LoadSpecificLandPropertySignatureInfo extends LandPropertySignatureEvent { + final int id; + const LoadSpecificLandPropertySignatureInfo({required this.id}); + + @override + List get props => [id]; +} + +class DeleteLandPropertySignature extends LandPropertySignatureEvent { + final int id; + const DeleteLandPropertySignature({required this.id}); + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_state.dart b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_state.dart new file mode 100644 index 0000000..c644a26 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_state.dart @@ -0,0 +1,41 @@ +part of 'land_property_signature_bloc.dart'; + +class LandPropertySignatureState extends Equatable { + const LandPropertySignatureState(); + + @override + List get props => []; +} + +class LandPropertySignatureInitial extends LandPropertySignatureState { + @override + List get props => []; +} + +class LandPropertySignatureInfoLoading extends LandPropertySignatureState { + @override + List get props => []; +} + +class LandPropertySignatureInfoErrorState extends LandPropertySignatureState { + String errorMessage; + LandPropertySignatureInfoErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} + +class LandPropertySignatureLoaded extends LandPropertySignatureState { + List landPropertySignature; + + LandPropertySignatureLoaded({required this.landPropertySignature}); + @override + List get props => [landPropertySignature]; +} + +class LoadSpecificLandPropertySignature extends LandPropertySignatureState { + LandExt landPropertySignature; + + LoadSpecificLandPropertySignature({required this.landPropertySignature}); + @override + List get props => [landPropertySignature]; +} diff --git a/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart new file mode 100644 index 0000000..c5959c3 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart @@ -0,0 +1,75 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; + +import '../../../../../model/passo/other_improvements.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'other_improvements_event.dart'; +part 'other_improvements_state.dart'; + +class OtherImprovementsBloc + extends Bloc { + OtherImprovementsBloc() : super(OtherImprovementsInitial()) { + List otherImprovements = []; + on((event, emit) async { + emit(OtherImprovementsInitial()); + try { + emit(OtherImprovementsLoaded(otherImprovements: otherImprovements)); + } catch (e) { + emit(OtherImprovementsErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(OtherImprovementsInitial()); + List> result = + await SQLServices.instance.getOtherImprovements(event.id); + + if (result.isNotEmpty) { + otherImprovements = + result.map((map) => OtherImprovements.fromJson2(map)).toList(); + + emit(OtherImprovementsLoaded(otherImprovements: otherImprovements)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + OtherImprovements item = await SQLServices.instance + .createOtherImprovements(OtherImprovements( + landapprDetailsId: event.landapprDetailsId, + kindsOfTrees: event.kindsOfTrees, + subclassAge: event.subclassAge, + quantity: event.quantity, + unitValue: event.unitValue, + baseMarketval: event.baseMarketval, + noOfProductive: event.noOfProductive, + noOfNonproductive: event.noOfNonproductive, + fruitBearing: event.fruitBearing)); + + print(item.toJson()); + + otherImprovements.add(item); + + emit(OtherImprovementsLoaded(otherImprovements: otherImprovements)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowOtherImprovementScreen()); + }); + // on((event, emit) async { + // addItems = await SQLServices.instance.readAdditionalItems(); + // emit(AdditionalItemsLoaded(addItem: addItems)); + // }); + on((event, emit) async { + otherImprovements + .removeWhere(((OtherImprovements element) => element.id == event.id)); + await SQLServices.instance.deleteOtherImprovements(id: event.id); + emit(const OtherImprovementsDeletedState(success: true)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_event.dart b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_event.dart new file mode 100644 index 0000000..ab31f40 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_event.dart @@ -0,0 +1,96 @@ +part of 'other_improvements_bloc.dart'; + +class OtherImprovementsEvent extends Equatable { + const OtherImprovementsEvent(); + + @override + List get props => []; +} + +class LoadOtherImprovements extends OtherImprovementsEvent { + final List otherImprovements; + + const LoadOtherImprovements( + {this.otherImprovements = const []}); + + @override + List get props => [otherImprovements]; +} + +class LoadOtherImprovementsEdit extends OtherImprovementsEvent { + final List otherImprovements; + final int? id; + + const LoadOtherImprovementsEdit({required this.otherImprovements, this.id}); + + @override + List get props => [otherImprovements]; +} + +class AddOtherImprovements extends OtherImprovementsEvent { + final int landapprDetailsId; + final String kindsOfTrees; + final String subclassAge; + final int quantity; + final String unitValue; + final String baseMarketval; + final int noOfProductive; + final int noOfNonproductive; + final String fruitBearing; + + const AddOtherImprovements({ + required this.landapprDetailsId, + required this.kindsOfTrees, + required this.subclassAge, + required this.quantity, + required this.unitValue, + required this.baseMarketval, + required this.noOfProductive, + required this.noOfNonproductive, + required this.fruitBearing, + }); + + @override + List get props => [ + landapprDetailsId, + kindsOfTrees, + subclassAge, + quantity, + unitValue, + baseMarketval, + noOfProductive, + noOfNonproductive, + fruitBearing, + ]; +} + +class UpdateOtherImprovements extends OtherImprovementsEvent { + final OtherImprovements otherImprovements; + const UpdateOtherImprovements({required this.otherImprovements}); + @override + List get props => [otherImprovements]; +} + +class FetchOtherImprovements extends OtherImprovementsEvent { + const FetchOtherImprovements(); + + @override + List get props => []; +} + +class FetchSpecificOtherImprovements extends OtherImprovementsEvent { + final int id; + const FetchSpecificOtherImprovements({required this.id}); + + @override + List get props => [id]; +} + +class DeleteOtherImprovements extends OtherImprovementsEvent { + final int id; + const DeleteOtherImprovements({required this.id}); + @override + List get props => [id]; +} + +class ShowOtherImprovement extends OtherImprovementsEvent {} diff --git a/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_state.dart b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_state.dart new file mode 100644 index 0000000..7ae926e --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/other_improvements/other_improvements_state.dart @@ -0,0 +1,46 @@ +part of 'other_improvements_bloc.dart'; + +class OtherImprovementsState extends Equatable { + const OtherImprovementsState(); + + @override + List get props => []; +} + +class OtherImprovementsInitial extends OtherImprovementsState { + @override + List get props => []; +} + +class OtherImprovementsLoaded extends OtherImprovementsState { + final List otherImprovements; + + const OtherImprovementsLoaded({required this.otherImprovements}); + @override + List get props => [otherImprovements]; +} + +class LoadSpecificOtherImprovements extends OtherImprovementsState { + final OtherImprovements otherImprovements; + + const LoadSpecificOtherImprovements({required this.otherImprovements}); + @override + List get props => [otherImprovements]; +} + +class ShowOtherImprovementScreen extends OtherImprovementsState {} + +class OtherImprovementsErrorState extends OtherImprovementsState { + const OtherImprovementsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class OtherImprovementsDeletedState extends OtherImprovementsState { + final bool success; + const OtherImprovementsDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart new file mode 100644 index 0000000..0bcae56 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart @@ -0,0 +1,69 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'value_adjustment_event.dart'; +part 'value_adjustment_state.dart'; + +class ValueAdjustmentBloc + extends Bloc { + ValueAdjustmentBloc() : super(ValueAdjustmentInitial()) { + List valueAdjustment = []; + on((event, emit) async { + emit(ValueAdjustmentInitial()); + try { + emit(ValueAdjustmentLoaded(valueAdjustment: valueAdjustment)); + } catch (e) { + emit(ValueAdjustmentErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(ValueAdjustmentInitial()); + List> result = + await SQLServices.instance.getValueAdjustments(event.id); + + if (result.isNotEmpty) { + valueAdjustment = + result.map((map) => ValueAdjustments.fromJson2(map)).toList(); + + emit(ValueAdjustmentLoaded(valueAdjustment: valueAdjustment)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + ValueAdjustments item = + await SQLServices.instance.createValueAdjustments(ValueAdjustments( + landapprDetailsId: event.landapprDetailsId, + baseMarketval: event.baseMarketval, + adjustmentFactors: event.adjustmentFactors, + adjustment: event.adjustment, + valueAdjustment: event.valueAdjustment, + marketValue: event.marketValue, + )); + + print(item.toJson()); + + valueAdjustment.add(item); + + emit(ValueAdjustmentLoaded(valueAdjustment: valueAdjustment)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowValueAdjustmentcreen()); + }); + on((event, emit) async { + valueAdjustment + .removeWhere(((ValueAdjustments element) => element.id == event.id)); + await SQLServices.instance.deleteValueAdjustment(id: event.id); + emit(const ValueAdjustmentDeletedState(success: true)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_event.dart b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_event.dart new file mode 100644 index 0000000..f31daa9 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_event.dart @@ -0,0 +1,88 @@ +part of 'value_adjustment_bloc.dart'; + +class ValueAdjustmentEvent extends Equatable { + const ValueAdjustmentEvent(); + + @override + List get props => []; +} + +class LoadValueAdjustment extends ValueAdjustmentEvent { + final List valueAdjustment; + + const LoadValueAdjustment( + {this.valueAdjustment = const []}); + + @override + List get props => [valueAdjustment]; +} + +class LoadValueAdjustmentEdit extends ValueAdjustmentEvent { + final List valueAdjustment; + final int? id; + + const LoadValueAdjustmentEdit( + {required this.valueAdjustment, required this.id}); + + @override + List get props => [valueAdjustment]; +} + +class AddValueAdjustments extends ValueAdjustmentEvent { + final int landapprDetailsId; + final String baseMarketval; + final String adjustmentFactors; + final String adjustment; + final String valueAdjustment; + final String marketValue; + + const AddValueAdjustments({ + required this.landapprDetailsId, + required this.baseMarketval, + required this.adjustmentFactors, + required this.adjustment, + required this.valueAdjustment, + required this.marketValue, + }); + + @override + List get props => [ + landapprDetailsId, + baseMarketval, + adjustmentFactors, + adjustment, + valueAdjustment, + marketValue, + ]; +} + +class UpdateValueAdjustment extends ValueAdjustmentEvent { + final ValueAdjustments valueAdjustment; + const UpdateValueAdjustment({required this.valueAdjustment}); + @override + List get props => [valueAdjustment]; +} + +class FetchValueAdjustment extends ValueAdjustmentEvent { + const FetchValueAdjustment(); + + @override + List get props => []; +} + +class FetchSpecificValueAdjustment extends ValueAdjustmentEvent { + final int id; + const FetchSpecificValueAdjustment({required this.id}); + + @override + List get props => [id]; +} + +class DeleteValueAdjustment extends ValueAdjustmentEvent { + final int id; + const DeleteValueAdjustment({required this.id}); + @override + List get props => [id]; +} + +class ShowValueAdjustment extends ValueAdjustmentEvent {} diff --git a/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_state.dart b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_state.dart new file mode 100644 index 0000000..95807b6 --- /dev/null +++ b/lib/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_state.dart @@ -0,0 +1,46 @@ +part of 'value_adjustment_bloc.dart'; + +class ValueAdjustmentState extends Equatable { + const ValueAdjustmentState(); + + @override + List get props => []; +} + +class ValueAdjustmentInitial extends ValueAdjustmentState { + @override + List get props => []; +} + +class ValueAdjustmentLoaded extends ValueAdjustmentState { + final List valueAdjustment; + + const ValueAdjustmentLoaded({required this.valueAdjustment}); + @override + List get props => [valueAdjustment]; +} + +class LoadSpecificValueAdjustment extends ValueAdjustmentState { + final ValueAdjustments valueAdjustment; + + const LoadSpecificValueAdjustment({required this.valueAdjustment}); + @override + List get props => [valueAdjustment]; +} + +class ShowValueAdjustmentcreen extends ValueAdjustmentState {} + +class ValueAdjustmentErrorState extends ValueAdjustmentState { + const ValueAdjustmentErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class ValueAdjustmentDeletedState extends ValueAdjustmentState { + final bool success; + const ValueAdjustmentDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/model/passo/building_and_structure.dart b/lib/model/passo/building_and_structure.dart new file mode 100644 index 0000000..4c1df21 --- /dev/null +++ b/lib/model/passo/building_and_structure.dart @@ -0,0 +1,131 @@ +// To parse this JSON data, do +// +// final bldgAndStructure = bldgAndStructureFromJson(jsonString); + +import 'dart:convert'; + +BldgAndStructure bldgAndStructureFromJson(String str) => + BldgAndStructure.fromJson(json.decode(str)); + +String bldgAndStructureToJson(BldgAndStructure data) => + json.encode(data.toJson()); + +class BldgAndStructure { + final int? id; + final int? bldgapprDetailsId; + final String? assessedById; + final String? assessedByName; + final String? dateCreated; + final String? dateModified; + final String? bldgType; + final String? strucType; + final String? description; + final String? actualUse; + final String? floorCount; + final String? bldgArea; + final String? unitValue; + final String? depRate; + final String? marketValue; + final String? depAmount; + final String? adjustedMarketValue; + + BldgAndStructure({ + this.id, + this.bldgapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.bldgType, + this.strucType, + this.description, + this.actualUse, + this.floorCount, + this.bldgArea, + this.unitValue, + this.depRate, + this.marketValue, + this.depAmount, + this.adjustedMarketValue, + }); + + BldgAndStructure copy({ + int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + String? dateCreated, + String? dateModified, + String? bldgType, + String? strucType, + String? description, + String? actualUse, + String? floorCount, + String? bldgArea, + String? unitValue, + String? depRate, + String? marketValue, + String? depAmount, + String? adjustedMarketValue, + }) => + BldgAndStructure( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + bldgType: bldgType ?? this.bldgType, + strucType: strucType ?? this.strucType, + description: description ?? this.description, + actualUse: actualUse ?? this.actualUse, + floorCount: floorCount ?? this.floorCount, + bldgArea: bldgArea ?? this.bldgArea, + unitValue: unitValue ?? this.unitValue, + depRate: depRate ?? this.depRate, + marketValue: marketValue ?? this.marketValue, + depAmount: depAmount ?? this.depAmount, + adjustedMarketValue: adjustedMarketValue ?? this.adjustedMarketValue, + ); + + factory BldgAndStructure.fromJson(Map json) => + BldgAndStructure( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + bldgType: json["bldgType"], + strucType: json["strucType"], + description: json["description"], + actualUse: json["actualUse"], + floorCount: json["floorCount"], + bldgArea: json["bldgArea"], + unitValue: json["unitValue"], + depRate: json["depRate"], + marketValue: json["marketValue"], + depAmount: json["depAmount"], + adjustedMarketValue: json["adjustedMarketValue"], + ); + + Map toJson() => { + "id": id, + "bldgapprDetailsId": bldgapprDetailsId, + "assessedById": assessedById, + "assessedByName": assessedByName, + "dateCreated": dateCreated, + "dateModified": dateModified, + "bldgType": bldgType, + "strucType": strucType, + "description": description, + "actualUse": actualUse, + "floorCount": floorCount, + "bldgArea": bldgArea, + "unitValue": unitValue, + "depRate": depRate, + "marketValue": marketValue, + "depAmount": depAmount, + "adjustedMarketValue": adjustedMarketValue, + }; +} diff --git a/lib/model/passo/general_description.dart b/lib/model/passo/general_description.dart index 0f05141..19d4e80 100644 --- a/lib/model/passo/general_description.dart +++ b/lib/model/passo/general_description.dart @@ -34,60 +34,61 @@ class GeneralDesc { final String? totalFloorArea; final dynamic floorSketch; final String? actualUse; + final String? unitValue; - GeneralDesc({ - this.id, - this.bldgapprDetailsId, - this.assessedById, - this.assessedByName, - this.dateCreated, - this.dateModified, - this.bldgKind, - this.strucType, - this.bldgPermit, - this.dateIssued, - this.cct, - this.certCompletionIssued, - this.certOccupancyIssued, - this.dateCompleted, - this.dateOccupied, - this.bldgAge, - this.noStoreys, - this.area1Stfloor, - this.area2Ndfloor, - this.area3Rdfloor, - this.area4Thfloor, - this.totalFloorArea, - this.floorSketch, - this.actualUse, - }); + GeneralDesc( + {this.id, + this.bldgapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.bldgKind, + this.strucType, + this.bldgPermit, + this.dateIssued, + this.cct, + this.certCompletionIssued, + this.certOccupancyIssued, + this.dateCompleted, + this.dateOccupied, + this.bldgAge, + this.noStoreys, + this.area1Stfloor, + this.area2Ndfloor, + this.area3Rdfloor, + this.area4Thfloor, + this.totalFloorArea, + this.floorSketch, + this.actualUse, + this.unitValue}); - GeneralDesc copy({ - int? id, - int? bldgapprDetailsId, - String? assessedById, - String? assessedByName, - String? dateCreated, - String? dateModified, - String? bldgKind, - String? strucType, - String? bldgPermit, - String? dateIssued, - String? cct, - String? certCompletionIssued, - String? certOccupancyIssued, - String? dateCompleted, - String? dateOccupied, - String? bldgAge, - String? noStoreys, - String? area1Stfloor, - String? area2Ndfloor, - String? area3Rdfloor, - String? area4Thfloor, - String? totalFloorArea, - dynamic floorSketch, - String? actualUse, - }) { + GeneralDesc copy( + {int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + String? dateCreated, + String? dateModified, + String? bldgKind, + String? strucType, + String? bldgPermit, + String? dateIssued, + String? cct, + String? certCompletionIssued, + String? certOccupancyIssued, + String? dateCompleted, + String? dateOccupied, + String? bldgAge, + String? noStoreys, + String? area1Stfloor, + String? area2Ndfloor, + String? area3Rdfloor, + String? area4Thfloor, + String? totalFloorArea, + dynamic floorSketch, + String? actualUse, + String? unitValue}) { return GeneralDesc( id: id ?? this.id, bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, @@ -112,62 +113,63 @@ class GeneralDesc { area4Thfloor: area4Thfloor ?? this.area4Thfloor, totalFloorArea: totalFloorArea ?? this.totalFloorArea, floorSketch: floorSketch ?? this.floorSketch, - actualUse: actualUse ?? this.actualUse); + actualUse: actualUse ?? this.actualUse, + unitValue: unitValue ?? this.unitValue); } factory GeneralDesc.fromJson(Map json) => GeneralDesc( - id: json["id"], - bldgapprDetailsId: json["bldgappr_details_id"], - assessedById: json["assessed_by_id"], - assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"], - dateModified: json["date_modified"], - bldgKind: json["bldg_kind"], - strucType: json["struc_type"], - bldgPermit: json["bldg_permit"], - dateIssued: json["date_issued"], - cct: json["cct"], - certCompletionIssued: json["cert_completion_issued"], - certOccupancyIssued: json["cert_occupancy_issued"], - dateCompleted: json["date_completed"], - dateOccupied: json["date_occupied"], - bldgAge: json["bldg_age"], - noStoreys: json["no_storeys"], - area1Stfloor: json["area_1stfloor"], - area2Ndfloor: json["area_2ndfloor"], - area3Rdfloor: json["area_3rdfloor"], - area4Thfloor: json["area_4thfloor"], - totalFloorArea: json["total_floor_area"], - floorSketch: json["floor_sketch"], - actualUse: json["actual_use"], - ); + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + assessedById: json["assessed_by_id"], + assessedByName: json["assessed_by_name"], + dateCreated: json["date_created"], + dateModified: json["date_modified"], + bldgKind: json["bldg_kind"], + strucType: json["struc_type"], + bldgPermit: json["bldg_permit"], + dateIssued: json["date_issued"], + cct: json["cct"], + certCompletionIssued: json["cert_completion_issued"], + certOccupancyIssued: json["cert_occupancy_issued"], + dateCompleted: json["date_completed"], + dateOccupied: json["date_occupied"], + bldgAge: json["bldg_age"], + noStoreys: json["no_storeys"], + area1Stfloor: json["area_1stfloor"], + area2Ndfloor: json["area_2ndfloor"], + area3Rdfloor: json["area_3rdfloor"], + area4Thfloor: json["area_4thfloor"], + totalFloorArea: json["total_floor_area"], + floorSketch: json["floor_sketch"], + actualUse: json["actual_use"], + unitValue: json["unit_value"]); factory GeneralDesc.fromJson2(Map json) => GeneralDesc( - id: json["id"], - bldgapprDetailsId: json["bldgapprDetailsId"], - assessedById: json["assessedById"], - assessedByName: json["assessedByName"], - dateCreated: json["dateCreated"], - dateModified: json["dateModified"], - bldgKind: json["bldgKind"], - strucType: json["strucType"], - bldgPermit: json["bldgPermit"], - dateIssued: json["dateIssued"], - cct: json["cct"], - certCompletionIssued: json["certCompletionIssued"], - certOccupancyIssued: json["certOccupancyIssued"], - dateCompleted: json["dateCompleted"], - dateOccupied: json["dateOccupied"], - bldgAge: json["bldgAge"], - noStoreys: json["noStoreys"], - area1Stfloor: json["area1Stfloor"], - area2Ndfloor: json["area2Ndfloor"], - area3Rdfloor: json["area3Rdfloor"], - area4Thfloor: json["area4Thfloor"], - totalFloorArea: json["totalFloorArea"], - floorSketch: json["floorSketch"], - actualUse: json["actualUse"], - ); + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + bldgKind: json["bldgKind"], + strucType: json["strucType"], + bldgPermit: json["bldgPermit"], + dateIssued: json["dateIssued"], + cct: json["cct"], + certCompletionIssued: json["certCompletionIssued"], + certOccupancyIssued: json["certOccupancyIssued"], + dateCompleted: json["dateCompleted"], + dateOccupied: json["dateOccupied"], + bldgAge: json["bldgAge"], + noStoreys: json["noStoreys"], + area1Stfloor: json["area1Stfloor"], + area2Ndfloor: json["area2Ndfloor"], + area3Rdfloor: json["area3Rdfloor"], + area4Thfloor: json["area4Thfloor"], + totalFloorArea: json["totalFloorArea"], + floorSketch: json["floorSketch"], + actualUse: json["actualUse"], + unitValue: json["unitValue"]); Map toJson() => { "id": id, @@ -194,5 +196,6 @@ class GeneralDesc { "total_floor_area": totalFloorArea, "floor_sketch": floorSketch, "actual_use": actualUse, + "unit_value": unitValue }; } diff --git a/lib/model/passo/land_appr.dart b/lib/model/passo/land_appr.dart index 91e9b1b..4c88c3c 100644 --- a/lib/model/passo/land_appr.dart +++ b/lib/model/passo/land_appr.dart @@ -27,6 +27,26 @@ class LandAppr { this.baseMarketval, }); + LandAppr copy({ + int? id, + int? landapprDetailsId, + String? classification, + String? subClass, + String? area, + String? unitValue, + String? baseMarketval, + }) { + return LandAppr( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + classification: classification ?? this.classification, + subClass: subClass ?? this.subClass, + area: area ?? this.area, + unitValue: unitValue ?? this.unitValue, + baseMarketval: baseMarketval ?? this.baseMarketval, + ); + } + factory LandAppr.fromJson(Map json) => LandAppr( id: json["id"], landapprDetailsId: json["landappr_details_id"], @@ -37,6 +57,16 @@ class LandAppr { baseMarketval: json["base_marketval"], ); + factory LandAppr.fromJson2(Map json) => LandAppr( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + classification: json["classification"], + subClass: json["subClass"], + area: json["area"], + unitValue: json["unitValue"], + baseMarketval: json["baseMarketval"], + ); + Map toJson() => { "id": id, "landappr_details_id": landapprDetailsId, diff --git a/lib/model/passo/land_classification.dart b/lib/model/passo/land_classification.dart index 0315271..cccd29c 100644 --- a/lib/model/passo/land_classification.dart +++ b/lib/model/passo/land_classification.dart @@ -21,6 +21,17 @@ class LandClassification { this.description, }); + LandClassification copy({ + final int? id, + final String? classificationCode, + final String? description, + }) { + return LandClassification( + id: id ?? this.id, + classificationCode: classificationCode ?? this.classificationCode, + description: description ?? this.description); + } + factory LandClassification.fromJson(Map json) => LandClassification( id: json["id"], @@ -28,6 +39,13 @@ class LandClassification { description: json["description"], ); + factory LandClassification.fromJson2(Map json) => + LandClassification( + id: json["id"], + classificationCode: json["classificationCode"], + description: json["description"], + ); + Map toJson() => { "id": id, "classification_code": classificationCode, diff --git a/lib/model/passo/land_ext.dart b/lib/model/passo/land_ext.dart index 5c935f8..a4302f1 100644 --- a/lib/model/passo/land_ext.dart +++ b/lib/model/passo/land_ext.dart @@ -13,22 +13,22 @@ class LandExt { final int? landapprDetailsId; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; - final bool? taxable; - final bool? exempt; - final int? qtr; - final int? yr; + final String? dateCreated; + final String? dateModified; + final String? taxable; + final String? exempt; + final String? qtr; + final String? yr; final String? appraisedbyName; - final DateTime? appraisedbyDate; + final String? appraisedbyDate; final String? recommendapprName; - final DateTime? recommendapprDate; + final String? recommendapprDate; final String? approvedbyName; - final DateTime? approvedbyDate; + final String? approvedbyDate; final String? memoranda; final String? swornstatementNo; - final DateTime? dateReceived; - final DateTime? entryDateAssessment; + final String? dateReceived; + final String? entryDateAssessment; final String? entryDateBy; LandExt({ @@ -55,70 +55,123 @@ class LandExt { this.entryDateBy, }); + LandExt copy({ + final int? id, + final int? landapprDetailsId, + final String? assessedById, + final String? assessedByName, + final String? dateCreated, + final String? dateModified, + final String? taxable, + final String? exempt, + final String? qtr, + final String? yr, + final String? appraisedbyName, + final String? appraisedbyDate, + final String? recommendapprName, + final String? recommendapprDate, + final String? approvedbyName, + final String? approvedbyDate, + final String? memoranda, + final String? swornstatementNo, + final String? dateReceived, + final String? entryDateAssessment, + final String? entryDateBy, + }) { + return LandExt( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + taxable: taxable ?? this.taxable, + exempt: exempt ?? this.exempt, + qtr: qtr ?? this.qtr, + yr: yr ?? this.yr, + appraisedbyName: appraisedbyName ?? this.appraisedbyName, + appraisedbyDate: appraisedbyDate ?? this.appraisedbyDate, + recommendapprName: recommendapprName ?? this.recommendapprName, + recommendapprDate: recommendapprDate ?? this.recommendapprDate, + approvedbyName: approvedbyName ?? this.approvedbyName, + approvedbyDate: approvedbyDate ?? this.approvedbyDate, + memoranda: memoranda ?? this.memoranda, + swornstatementNo: swornstatementNo ?? this.swornstatementNo, + dateReceived: dateReceived ?? this.dateReceived, + entryDateAssessment: entryDateAssessment ?? this.entryDateAssessment, + entryDateBy: entryDateBy ?? this.entryDateBy, + ); + } + factory LandExt.fromJson(Map json) => LandExt( id: json["id"], landapprDetailsId: json["landappr_details_id"], assessedById: json["assessed_by_id"], assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), + dateCreated: json["date_created"], + dateModified: json["date_modified"], taxable: json["taxable"], exempt: json["exempt"], qtr: json["qtr"], yr: json["yr"], appraisedbyName: json["appraisedby_name"], - appraisedbyDate: json["appraisedby_date"] == null - ? null - : DateTime.parse(json["appraisedby_date"]), + appraisedbyDate: json["appraisedby_date"], recommendapprName: json["recommendappr_name"], - recommendapprDate: json["recommendappr_date"] == null - ? null - : DateTime.parse(json["recommendappr_date"]), + recommendapprDate: json["recommendappr_date"], approvedbyName: json["approvedby_name"], - approvedbyDate: json["approvedby_date"] == null - ? null - : DateTime.parse(json["approvedby_date"]), + approvedbyDate: json["approvedby_date"], memoranda: json["memoranda"], swornstatementNo: json["swornstatement_no"], - dateReceived: json["date_received"] == null - ? null - : DateTime.parse(json["date_received"]), - entryDateAssessment: json["entry_date_assessment"] == null - ? null - : DateTime.parse(json["entry_date_assessment"]), + dateReceived: json["date_received"], + entryDateAssessment: json["entry_date_assessment"], entryDateBy: json["entry_date_by"], ); + factory LandExt.fromJson2(Map json) => LandExt( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + taxable: json["taxable"], + exempt: json["exempt"], + qtr: json["qtr"], + yr: json["yr"], + appraisedbyName: json["appraisedbyName"], + appraisedbyDate: json["appraisedbyDate"], + recommendapprName: json["recommendapprName"], + recommendapprDate: json["recommendapprDate"], + approvedbyName: json["approvedbyName"], + approvedbyDate: json["approvedbyDate"], + memoranda: json["memoranda"], + swornstatementNo: json["swornstatementNo"], + dateReceived: json["dateReceived"], + entryDateAssessment: json["entryDateAssessment"], + entryDateBy: json["entryDateBy"], + ); + Map toJson() => { "id": id, "landappr_details_id": landapprDetailsId, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "taxable": taxable, "exempt": exempt, "qtr": qtr, "yr": yr, "appraisedby_name": appraisedbyName, - "appraisedby_date": - "${appraisedbyDate!.year.toString().padLeft(4, '0')}-${appraisedbyDate!.month.toString().padLeft(2, '0')}-${appraisedbyDate!.day.toString().padLeft(2, '0')}", + "appraisedby_date": appraisedbyDate, "recommendappr_name": recommendapprName, - "recommendappr_date": - "${recommendapprDate!.year.toString().padLeft(4, '0')}-${recommendapprDate!.month.toString().padLeft(2, '0')}-${recommendapprDate!.day.toString().padLeft(2, '0')}", + "recommendappr_date": recommendapprDate, "approvedby_name": approvedbyName, - "approvedby_date": - "${approvedbyDate!.year.toString().padLeft(4, '0')}-${approvedbyDate!.month.toString().padLeft(2, '0')}-${approvedbyDate!.day.toString().padLeft(2, '0')}", + "approvedby_date": approvedbyDate, "memoranda": memoranda, "swornstatement_no": swornstatementNo, - "date_received": - "${dateReceived!.year.toString().padLeft(4, '0')}-${dateReceived!.month.toString().padLeft(2, '0')}-${dateReceived!.day.toString().padLeft(2, '0')}", - "entry_date_assessment": - "${entryDateAssessment!.year.toString().padLeft(4, '0')}-${entryDateAssessment!.month.toString().padLeft(2, '0')}-${entryDateAssessment!.day.toString().padLeft(2, '0')}", + "date_received": dateReceived, + "entry_date_assessment": entryDateAssessment, "entry_date_by": entryDateBy, }; } diff --git a/lib/model/passo/land_property_assessment.dart b/lib/model/passo/land_property_assessment.dart index cbab632..35f007f 100644 --- a/lib/model/passo/land_property_assessment.dart +++ b/lib/model/passo/land_property_assessment.dart @@ -31,6 +31,28 @@ class LandPropertyAssessment { this.totalAssessedval, }); + LandPropertyAssessment copy({ + final int? id, + final int? landapprDetailsId, + final String? actualUse, + final String? marketval, + final String? assessmentLevel, + final String? assessedValue, + final String? totalMarketval, + final String? totalAssessedval, + }) { + return LandPropertyAssessment( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + actualUse: actualUse ?? this.actualUse, + marketval: marketval ?? this.marketval, + assessmentLevel: assessmentLevel ?? this.assessmentLevel, + assessedValue: assessedValue ?? this.assessedValue, + totalMarketval: totalMarketval ?? this.totalMarketval, + totalAssessedval: totalAssessedval ?? this.totalAssessedval, + ); + } + factory LandPropertyAssessment.fromJson(Map json) => LandPropertyAssessment( id: json["id"], @@ -43,6 +65,18 @@ class LandPropertyAssessment { totalAssessedval: json["total_assessedval"], ); + factory LandPropertyAssessment.fromJson2(Map json) => + LandPropertyAssessment( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + actualUse: json["actualUse"], + marketval: json["marketval"], + assessmentLevel: json["assessmentLevel"], + assessedValue: json["assessedValue"], + totalMarketval: json["totalMarketval"], + totalAssessedval: json["totalAssessedval"], + ); + Map toJson() => { "id": id, "landappr_details_id": landapprDetailsId, diff --git a/lib/model/passo/land_property_boundaries.dart b/lib/model/passo/land_property_boundaries.dart index 49a3ada..efbbf62 100644 --- a/lib/model/passo/land_property_boundaries.dart +++ b/lib/model/passo/land_property_boundaries.dart @@ -15,13 +15,13 @@ class LandPropertyBoundaries { final int? landapprDetailsId; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? north; final String? east; final String? south; final String? west; - final dynamic sketch; + final String? sketch; LandPropertyBoundaries({ this.id, @@ -37,18 +37,57 @@ class LandPropertyBoundaries { this.sketch, }); + LandPropertyBoundaries copy({ + final int? id, + final int? landapprDetailsId, + final String? assessedById, + final String? assessedByName, + final String? dateCreated, + final String? dateModified, + final String? north, + final String? east, + final String? south, + final String? west, + final String? sketch, + }) { + return LandPropertyBoundaries( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + north: north ?? this.north, + east: east ?? this.east, + south: south ?? this.south, + west: west ?? this.west, + sketch: sketch ?? this.sketch, + ); + } + factory LandPropertyBoundaries.fromJson(Map json) => LandPropertyBoundaries( id: json["id"], landapprDetailsId: json["landappr_details_id"], assessedById: json["assessed_by_id"], assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), + dateCreated: json["date_created"], + dateModified: json["date_modified"], + north: json["north"], + east: json["east"], + south: json["south"], + west: json["west"], + sketch: json["sketch"], + ); + + factory LandPropertyBoundaries.fromJson2(Map json) => + LandPropertyBoundaries( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], north: json["north"], east: json["east"], south: json["south"], @@ -61,8 +100,8 @@ class LandPropertyBoundaries { "landappr_details_id": landapprDetailsId, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "north": north, "east": east, "south": south, diff --git a/lib/model/passo/land_property_loc.dart b/lib/model/passo/land_property_loc.dart index 25a7466..b91d095 100644 --- a/lib/model/passo/land_property_loc.dart +++ b/lib/model/passo/land_property_loc.dart @@ -15,8 +15,8 @@ class LandPropertyLoc { final int? landapprDetailsId; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? street; final String? municipality; final String? barangay; @@ -35,18 +35,53 @@ class LandPropertyLoc { this.province, }); + LandPropertyLoc copy({ + int? id, + int? landapprDetailsId, + String? assessedById, + String? assessedByName, + String? dateCreated, + String? dateModified, + String? street, + String? municipality, + String? barangay, + String? province, + }) => + LandPropertyLoc( + id: id, + landapprDetailsId: landapprDetailsId, + assessedById: assessedById, + assessedByName: assessedByName, + dateCreated: dateCreated, + dateModified: dateModified, + street: street, + municipality: municipality, + barangay: barangay, + province: province, + ); + factory LandPropertyLoc.fromJson(Map json) => LandPropertyLoc( id: json["id"], landapprDetailsId: json["landappr_details_id"], assessedById: json["assessed_by_id"], assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), + dateCreated: json["date_created"], + dateModified: json["date_modified"], + street: json["street"], + municipality: json["municipality"], + barangay: json["barangay"], + province: json["province"], + ); + + factory LandPropertyLoc.fromJson2(Map json) => + LandPropertyLoc( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], street: json["street"], municipality: json["municipality"], barangay: json["barangay"], @@ -58,8 +93,8 @@ class LandPropertyLoc { "landappr_details_id": landapprDetailsId, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "street": street, "municipality": municipality, "barangay": barangay, diff --git a/lib/model/passo/land_property_owner.dart b/lib/model/passo/land_property_owner.dart index 9c644af..fce1d0b 100644 --- a/lib/model/passo/land_property_owner.dart +++ b/lib/model/passo/land_property_owner.dart @@ -14,13 +14,13 @@ class LandPropertyOwner { final int? id; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? transCode; final String? tdn; final String? pin; final String? cloaNo; - final DateTime? dated; + final String? dated; final String? surveyNo; final String? lotNo; final String? blkNo; @@ -59,22 +59,68 @@ class LandPropertyOwner { this.faasType, }); + LandPropertyOwner copy({ + int? id, + String? assessedById, + String? assessedByName, + String? dateCreated, + String? dateModified, + String? transCode, + String? tdn, + String? pin, + String? cloaNo, + String? dated, + String? surveyNo, + String? lotNo, + String? blkNo, + String? owner, + String? address, + String? telno, + String? tin, + String? adminUser, + String? adminAddress, + String? adminTelno, + String? adminTin, + String? faasType, + }) { + return LandPropertyOwner( + id: id, + assessedById: assessedById, + assessedByName: assessedByName, + dateCreated: dateCreated, + dateModified: dateModified, + transCode: transCode, + tdn: tdn, + pin: pin, + cloaNo: cloaNo, + dated: dated, + surveyNo: surveyNo, + lotNo: lotNo, + blkNo: blkNo, + owner: owner, + address: address, + telno: telno, + tin: tin, + adminUser: adminUser, + adminAddress: adminAddress, + adminTelno: adminTelno, + adminTin: adminTin, + faasType: faasType, + ); + } + factory LandPropertyOwner.fromJson(Map json) => LandPropertyOwner( id: json["id"], assessedById: json["assessed_by_id"], assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), + dateCreated: json["date_created"], + dateModified: json["date_modified"], transCode: json["trans_code"], tdn: json["tdn"], pin: json["pin"], cloaNo: json["cloa_no"], - dated: json["dated"] == null ? null : DateTime.parse(json["dated"]), + dated: json["dated"], surveyNo: json["survey_no"], lotNo: json["lot_no"], blkNo: json["blk_no"], @@ -89,18 +135,43 @@ class LandPropertyOwner { faasType: json["faas_type"], ); + factory LandPropertyOwner.fromJson2(Map json) => + LandPropertyOwner( + id: json["id"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + transCode: json["transCode"], + tdn: json["tdn"], + pin: json["pin"], + cloaNo: json["cloaNo"], + dated: json["dated"], + surveyNo: json["surveyNo"], + lotNo: json["lotNo"], + blkNo: json["blkNo"], + owner: json["owner"], + address: json["address"], + telno: json["telno"], + tin: json["tin"], + adminUser: json["adminUser"], + adminAddress: json["adminAddress"], + adminTelno: json["adminTelno"], + adminTin: json["adminTin"], + faasType: json["faasType"], + ); + Map toJson() => { "id": id, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "trans_code": transCode, "tdn": tdn, "pin": pin, "cloa_no": cloaNo, - "dated": - "${dated!.year.toString().padLeft(4, '0')}-${dated!.month.toString().padLeft(2, '0')}-${dated!.day.toString().padLeft(2, '0')}", + "dated": dated, "survey_no": surveyNo, "lot_no": lotNo, "blk_no": blkNo, diff --git a/lib/model/passo/land_subclassification.dart b/lib/model/passo/land_subclassification.dart index 8bb042a..a9acfd4 100644 --- a/lib/model/passo/land_subclassification.dart +++ b/lib/model/passo/land_subclassification.dart @@ -27,6 +27,24 @@ class LandSubClassification { this.baseUnitMarketval, }); + LandSubClassification copy({ + final int? id, + final int? classificationId, + final String? cityCode, + final String? subclassCode, + final String? subclassDescription, + final String? baseUnitMarketval, + }) { + return LandSubClassification( + id: id ?? this.id, + classificationId: classificationId ?? this.classificationId, + cityCode: cityCode ?? this.cityCode, + subclassCode: subclassCode ?? this.subclassCode, + subclassDescription: subclassDescription ?? this.subclassDescription, + baseUnitMarketval: baseUnitMarketval ?? this.baseUnitMarketval, + ); + } + factory LandSubClassification.fromJson(Map json) => LandSubClassification( id: json["id"], @@ -37,6 +55,16 @@ class LandSubClassification { baseUnitMarketval: json["base_unit_marketval"], ); + factory LandSubClassification.fromJson2(Map json) => + LandSubClassification( + id: json["id"], + classificationId: json["classificationId"], + cityCode: json["cityCode"], + subclassCode: json["subclassCode"], + subclassDescription: json["subclassDescription"], + baseUnitMarketval: json["baseUnitMarketval"], + ); + Map toJson() => { "id": id, "classification_id": classificationId, diff --git a/lib/model/passo/land_value_adjustment.dart b/lib/model/passo/land_value_adjustment.dart index 33bdc59..f4e25ff 100644 --- a/lib/model/passo/land_value_adjustment.dart +++ b/lib/model/passo/land_value_adjustment.dart @@ -29,6 +29,26 @@ class ValueAdjustments { this.marketValue, }); + ValueAdjustments copy({ + final int? id, + final int? landapprDetailsId, + final String? baseMarketval, + final String? adjustmentFactors, + final String? adjustment, + final String? valueAdjustment, + final String? marketValue, + }) { + return ValueAdjustments( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + baseMarketval: baseMarketval ?? this.baseMarketval, + adjustmentFactors: adjustmentFactors ?? this.adjustmentFactors, + adjustment: adjustment ?? this.adjustment, + valueAdjustment: valueAdjustment ?? this.valueAdjustment, + marketValue: marketValue ?? this.marketValue, + ); + } + factory ValueAdjustments.fromJson(Map json) => ValueAdjustments( id: json["id"], @@ -40,6 +60,17 @@ class ValueAdjustments { marketValue: json["market_value"], ); + factory ValueAdjustments.fromJson2(Map json) => + ValueAdjustments( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + baseMarketval: json["baseMarketval"], + adjustmentFactors: json["adjustmentFactors"], + adjustment: json["adjustment"], + valueAdjustment: json["valueAdjustment"], + marketValue: json["marketValue"], + ); + Map toJson() => { "id": id, "landappr_details_id": landapprDetailsId, diff --git a/lib/model/passo/other_improvements.dart b/lib/model/passo/other_improvements.dart index bb36523..1735433 100644 --- a/lib/model/passo/other_improvements.dart +++ b/lib/model/passo/other_improvements.dart @@ -20,7 +20,7 @@ class OtherImprovements { final String? baseMarketval; final int? noOfProductive; final int? noOfNonproductive; - final bool? fruitBearing; + final String? fruitBearing; OtherImprovements({ this.id, @@ -35,6 +35,32 @@ class OtherImprovements { this.fruitBearing, }); + OtherImprovements copy({ + final int? id, + final int? landapprDetailsId, + final String? kindsOfTrees, + final String? subclassAge, + final int? quantity, + final String? unitValue, + final String? baseMarketval, + final int? noOfProductive, + final int? noOfNonproductive, + final String? fruitBearing, + }) { + return OtherImprovements( + id: id ?? this.id, + landapprDetailsId: landapprDetailsId ?? this.landapprDetailsId, + kindsOfTrees: kindsOfTrees ?? this.kindsOfTrees, + subclassAge: subclassAge ?? this.subclassAge, + quantity: quantity ?? this.quantity, + unitValue: unitValue ?? this.unitValue, + baseMarketval: baseMarketval ?? this.baseMarketval, + noOfProductive: noOfProductive ?? this.noOfProductive, + noOfNonproductive: noOfNonproductive ?? this.noOfNonproductive, + fruitBearing: fruitBearing ?? this.fruitBearing, + ); + } + factory OtherImprovements.fromJson(Map json) => OtherImprovements( id: json["id"], @@ -49,6 +75,20 @@ class OtherImprovements { fruitBearing: json["fruit_bearing"], ); + factory OtherImprovements.fromJson2(Map json) => + OtherImprovements( + id: json["id"], + landapprDetailsId: json["landapprDetailsId"], + kindsOfTrees: json["kindsOfTrees"], + subclassAge: json["subclassAge"], + quantity: json["quantity"], + unitValue: json["unitValue"], + baseMarketval: json["baseMarketval"], + noOfProductive: json["noOfProductive"], + noOfNonproductive: json["noOfNonproductive"], + fruitBearing: json["fruitBearing"], + ); + Map toJson() => { "id": id, "landappr_details_id": landapprDetailsId, diff --git a/lib/model/passo/property_appraisal.dart b/lib/model/passo/property_appraisal.dart index 4a3bd07..1cd661b 100644 --- a/lib/model/passo/property_appraisal.dart +++ b/lib/model/passo/property_appraisal.dart @@ -15,8 +15,8 @@ class PropertyAppraisal { final int? bldgapprDetailsId; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? unitconstructCost; final String? buildingCore; final String? unitconstructSubtotal; @@ -53,8 +53,8 @@ class PropertyAppraisal { int? bldgapprDetailsId, String? assessedById, String? assessedByName, - DateTime? dateCreated, - DateTime? dateModified, + String? dateCreated, + String? dateModified, String? unitconstructCost, String? buildingCore, String? unitconstructSubtotal, @@ -93,12 +93,8 @@ class PropertyAppraisal { bldgapprDetailsId: json["bldgappr_details_id"], assessedById: json["assessed_by_id"], assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), + dateCreated: json["date_created"], + dateModified: json["date_modified"], unitconstructCost: json["unitconstruct_cost"], buildingCore: json["building_core"], unitconstructSubtotal: json["unitconstruct_subtotal"], @@ -111,13 +107,33 @@ class PropertyAppraisal { totalArea: json["total_area"], actualUse: json["actual_use"]); + factory PropertyAppraisal.fromJson2(Map json) => + PropertyAppraisal( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + unitconstructCost: json["unitconstructCost"], + buildingCore: json["buildingCore"], + unitconstructSubtotal: json["unitconstructSubtotal"], + depreciationRate: json["depreciationRate"], + depreciationCost: json["depreciationCost"], + costAddItems: json["costAddItems"], + addItemsSubtotal: json["addItemsSubtotal"], + totalpercentDepreciation: json["totalpercentDepreciation"], + marketValue: json["marketValue"], + totalArea: json["totalArea"], + actualUse: json["actualUse"]); + Map toJson() => { "id": id, "bldgappr_details_id": bldgapprDetailsId, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "unitconstruct_cost": unitconstructCost, "building_core": buildingCore, "unitconstruct_subtotal": unitconstructSubtotal, diff --git a/lib/model/passo/property_assessment.dart b/lib/model/passo/property_assessment.dart index db53ccd..d1f525c 100644 --- a/lib/model/passo/property_assessment.dart +++ b/lib/model/passo/property_assessment.dart @@ -18,19 +18,19 @@ class PropertyAssessment { final String marketValue; final String assessmentLevel; final String assessedValue; - final bool taxable; - final bool exempt; - final int qtr; - final int yr; + final String taxable; + final String exempt; + final String qtr; + final String yr; final String appraisedbyName; - final DateTime appraisedbyDate; + final String appraisedbyDate; final String recommendapprName; - final DateTime recommendapprDate; + final String recommendapprDate; final String approvedbyName; final String memoranda; final String swornstatementNo; - final DateTime dateReceived; - final DateTime entryDateAssessment; + final String dateReceived; + final String entryDateAssessment; final String entryDateBy; PropertyAssessment({ @@ -63,19 +63,19 @@ class PropertyAssessment { String? marketValue, String? assessmentLevel, String? assessedValue, - bool? taxable, - bool? exempt, - int? qtr, - int? yr, + String? taxable, + String? exempt, + String? qtr, + String? yr, String? appraisedbyName, - DateTime? appraisedbyDate, + String? appraisedbyDate, String? recommendapprName, - DateTime? recommendapprDate, + String? recommendapprDate, String? approvedbyName, String? memoranda, String? swornstatementNo, - DateTime? dateReceived, - DateTime? entryDateAssessment, + String? dateReceived, + String? entryDateAssessment, String? entryDateBy, }) => PropertyAssessment( @@ -114,17 +114,41 @@ class PropertyAssessment { qtr: json["qtr"], yr: json["yr"], appraisedbyName: json["appraisedby_name"], - appraisedbyDate: DateTime.parse(json["appraisedby_date"]), + appraisedbyDate: json["appraisedby_date"], recommendapprName: json["recommendappr_name"], - recommendapprDate: DateTime.parse(json["recommendappr_date"]), + recommendapprDate: json["recommendappr_date"], approvedbyName: json["approvedby_name"], memoranda: json["memoranda"], swornstatementNo: json["swornstatement_no"], - dateReceived: DateTime.parse(json["date_received"]), - entryDateAssessment: DateTime.parse(json["entry_date_assessment"]), + dateReceived: json["date_received"], + entryDateAssessment: json["entry_date_assessment"], entryDateBy: json["entry_date_by"], ); + factory PropertyAssessment.fromJson2(Map json) => + PropertyAssessment( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + actualUse: json["actualUse"], + marketValue: json["marketValue"], + assessmentLevel: json["assessmentLevel"], + assessedValue: json["assessedValue"], + taxable: json["taxable"], + exempt: json["exempt"], + qtr: json["qtr"], + yr: json["yr"], + appraisedbyName: json["appraisedbyName"], + appraisedbyDate: json["appraisedbyDate"], + recommendapprName: json["recommendapprName"], + recommendapprDate: json["recommendapprDate"], + approvedbyName: json["approvedbyName"], + memoranda: json["memoranda"], + swornstatementNo: json["swornstatementNo"], + dateReceived: json["dateReceived"], + entryDateAssessment: json["entryDateAssessment"], + entryDateBy: json["entryDateBy"], + ); + Map toJson() => { "id": id, "bldgappr_details_id": bldgapprDetailsId, @@ -137,18 +161,13 @@ class PropertyAssessment { "qtr": qtr, "yr": yr, "appraisedby_name": appraisedbyName, - "appraisedby_date": - "${appraisedbyDate.year.toString().padLeft(4, '0')}-${appraisedbyDate.month.toString().padLeft(2, '0')}-${appraisedbyDate.day.toString().padLeft(2, '0')}", + "appraisedby_date": appraisedbyDate, "recommendappr_name": recommendapprName, - "recommendappr_date": - "${recommendapprDate.year.toString().padLeft(4, '0')}-${recommendapprDate.month.toString().padLeft(2, '0')}-${recommendapprDate.day.toString().padLeft(2, '0')}", + "recommendappr_date": recommendapprDate, "approvedby_name": approvedbyName, "memoranda": memoranda, "swornstatement_no": swornstatementNo, - "date_received": - "${dateReceived.year.toString().padLeft(4, '0')}-${dateReceived.month.toString().padLeft(2, '0')}-${dateReceived.day.toString().padLeft(2, '0')}", - "entry_date_assessment": - "${entryDateAssessment.year.toString().padLeft(4, '0')}-${entryDateAssessment.month.toString().padLeft(2, '0')}-${entryDateAssessment.day.toString().padLeft(2, '0')}", + "date_received": dateReceived, "entry_date_by": entryDateBy, }; } diff --git a/lib/model/passo/property_info.dart b/lib/model/passo/property_info.dart index 69b2c45..29de6b3 100644 --- a/lib/model/passo/property_info.dart +++ b/lib/model/passo/property_info.dart @@ -13,8 +13,8 @@ class PropertyInfo { final int? id; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? transCode; final String? tdn; final String? pin; @@ -52,8 +52,8 @@ class PropertyInfo { int? id, String? assessedById, String? assessedByName, - DateTime? dateCreated, - DateTime? dateModified, + String? dateCreated, + String? dateModified, String? transCode, String? tdn, String? pin, @@ -111,6 +111,30 @@ class PropertyInfo { faasType: json["faas_type"], ); + factory PropertyInfo.fromJson2(Map json) => PropertyInfo( + id: json["id"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + // dateCreated: json["date_created"] == null + // ? null + // : DateTime.parse(json["date_created"]), + // dateModified: json["date_modified"] == null + // ? null + // : DateTime.parse(json["date_modified"]), + transCode: json["transCode"], + tdn: json["tdn"], + pin: json["pin"], + owner: json["owner"], + address: json["address"], + telno: json["telno"], + tin: json["tin"], + adminUser: json["adminUser"], + adminAddress: json["adminAddress"], + adminTelno: json["adminTelno"], + adminTin: json["adminTin"], + faasType: json["faasType"], + ); + factory PropertyInfo.fromMap(Map map) => PropertyInfo( id: map["id"], assessedById: map["assessedById"], @@ -135,8 +159,8 @@ class PropertyInfo { "id": id, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "trans_code": transCode, "tdn": tdn, "pin": pin, diff --git a/lib/model/passo/structureMaterial.dart b/lib/model/passo/structureMaterial.dart index 783a2a5..efed05c 100644 --- a/lib/model/passo/structureMaterial.dart +++ b/lib/model/passo/structureMaterial.dart @@ -71,6 +71,19 @@ class StructureMaterials { walls: json["walls"], others: json["others"]); + factory StructureMaterials.fromJson2(Map json) => + StructureMaterials( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + foundation: json["foundation"], + columns: json["columns"], + beams: json["beams"], + trussFraming: json["trussFraming"], + roof: json["roof"], + flooring: json["flooring"], + walls: json["walls"], + others: json["others"]); + Map toJson() => { "id": id, "bldgappr_details_id": bldgapprDetailsId, diff --git a/lib/model/passo/trees_improvements.dart b/lib/model/passo/trees_improvements.dart index cc72f4a..68e3f28 100644 --- a/lib/model/passo/trees_improvements.dart +++ b/lib/model/passo/trees_improvements.dart @@ -23,6 +23,20 @@ class TreesImprovements { this.subclassCode, }); + TreesImprovements copy({ + final int? id, + final String? improvement, + final String? pricePerTree, + final dynamic subclassCode, + }) { + return TreesImprovements( + id: id ?? this.id, + improvement: improvement ?? this.improvement, + pricePerTree: pricePerTree ?? this.pricePerTree, + subclassCode: subclassCode ?? this.subclassCode, + ); + } + factory TreesImprovements.fromJson(Map json) => TreesImprovements( id: json["id"], @@ -31,6 +45,14 @@ class TreesImprovements { subclassCode: json["subclass_code"], ); + factory TreesImprovements.fromJson2(Map json) => + TreesImprovements( + id: json["id"], + improvement: json["improvement"], + pricePerTree: json["pricePerTree"], + subclassCode: json["subclassCode"], + ); + Map toJson() => { "id": id, "improvement": improvement, diff --git a/lib/model/passo/type_of_location.dart b/lib/model/passo/type_of_location.dart index 9990236..9e2bd34 100644 --- a/lib/model/passo/type_of_location.dart +++ b/lib/model/passo/type_of_location.dart @@ -22,6 +22,15 @@ class TypeOfLocation { this.localTradingCenter, }); + TypeOfLocation copy({ + final int? id, + final String? distanceKm, + final String? allRoadTypes, + final String? localTradingCenter, + }) { + return TypeOfLocation(); + } + factory TypeOfLocation.fromJson(Map json) => TypeOfLocation( id: json["id"], distanceKm: json["distance_km"], @@ -29,6 +38,13 @@ class TypeOfLocation { localTradingCenter: json["local_trading_center"], ); + factory TypeOfLocation.fromJson2(Map json) => TypeOfLocation( + id: json["id"], + distanceKm: json["distanceKm"], + allRoadTypes: json["allRoadTypes"], + localTradingCenter: json["localTradingCenter"], + ); + Map toJson() => { "id": id, "distance_km": distanceKm, diff --git a/lib/model/passo/type_of_road.dart b/lib/model/passo/type_of_road.dart index e545e29..a3d86cc 100644 --- a/lib/model/passo/type_of_road.dart +++ b/lib/model/passo/type_of_road.dart @@ -20,12 +20,30 @@ class TypeOfRoad { this.deduction, }); + TypeOfRoad copy({ + final int? id, + final String? roadType, + final String? deduction, + }) { + return TypeOfRoad( + id: id ?? this.id, + roadType: roadType ?? this.roadType, + deduction: deduction ?? this.deduction, + ); + } + factory TypeOfRoad.fromJson(Map json) => TypeOfRoad( id: json["id"], roadType: json["road_type"], deduction: json["deduction"], ); + factory TypeOfRoad.fromJson2(Map json) => TypeOfRoad( + id: json["id"], + roadType: json["roadType"], + deduction: json["deduction"], + ); + Map toJson() => { "id": id, "road_type": roadType, diff --git a/lib/screens/offline/homepage/module_screen.dart b/lib/screens/offline/homepage/module_screen.dart index a48e2f9..8fbca6c 100644 --- a/lib/screens/offline/homepage/module_screen.dart +++ b/lib/screens/offline/homepage/module_screen.dart @@ -59,7 +59,8 @@ class OfflineModuleScreen extends StatelessWidget { ontap: () { Navigator.push(context, MaterialPageRoute(builder: ((context) { - return const PassoOfflineMainScreen(); + return PassoOfflineMainScreen( + state.offlineProfile); }))); })) .toList()), diff --git a/lib/screens/offline/passo/admin/admin_main_screen.dart b/lib/screens/offline/passo/admin/admin_main_screen.dart index 0f661c9..6439f56 100644 --- a/lib/screens/offline/passo/admin/admin_main_screen.dart +++ b/lib/screens/offline/passo/admin/admin_main_screen.dart @@ -3,19 +3,34 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttericon/elusive_icons.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart'; import 'package:unit2/screens/offline/passo/admin/barangay.dart'; import 'package:unit2/screens/offline/passo/admin/class_components.dart'; +import 'package:unit2/screens/offline/passo/admin/globalSyncService.dart'; +import 'package:unit2/screens/offline/passo/admin/land_classification.dart'; +import 'package:unit2/screens/offline/passo/admin/land_sub_classification.dart'; import 'package:unit2/screens/offline/passo/admin/memoranda.dart'; import 'package:unit2/screens/offline/passo/admin/municipalities.dart'; import 'package:unit2/screens/offline/passo/admin/signatories.dart'; +import 'package:unit2/screens/offline/passo/admin/trees_improvements.dart'; +import 'package:unit2/screens/offline/passo/admin/type_of_location.dart'; +import 'package:unit2/screens/offline/passo/admin/type_of_road.dart'; import 'package:unit2/screens/offline/passo/admin/unit_construction.dart'; +import 'package:unit2/screens/offline/passo/admin/value_adjustment.dart'; import 'package:unit2/screens/profile/components/main_menu.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/type_of_location.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import '../../../../bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; + class AdminMainScreen extends StatefulWidget { const AdminMainScreen({super.key}); @@ -31,11 +46,27 @@ class _AdminMainScreen extends State { backgroundColor: primary, title: const Text("PASSO Admin"), centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + GlobalSyncService().syncAllData(); + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], ), body: ListView( children: [ MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Municipalities", onTap: () { Navigator.push(context, @@ -50,7 +81,7 @@ class _AdminMainScreen extends State { ), const Divider(), MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Barangays", onTap: () { Navigator.push(context, @@ -64,7 +95,7 @@ class _AdminMainScreen extends State { ), const Divider(), MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Class Components", onTap: () { Navigator.push(context, @@ -79,7 +110,7 @@ class _AdminMainScreen extends State { ), const Divider(), MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Structural Types", onTap: () { Navigator.push(context, @@ -94,7 +125,7 @@ class _AdminMainScreen extends State { ), const Divider(), MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Signatories", onTap: () { Navigator.push(context, @@ -109,7 +140,7 @@ class _AdminMainScreen extends State { ), const Divider(), MainMenu( - icon: Elusive.group, + icon: Elusive.wrench, title: "Memoranda", onTap: () { Navigator.push(context, @@ -122,6 +153,81 @@ class _AdminMainScreen extends State { })); }, ), + const Divider(), + MainMenu( + icon: Elusive.wrench, + title: "Land SubClassification", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => LandSubclassificationBloc() + ..add(const LoadLandSubClassification()), + child: const LandSubClassificationAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.wrench, + title: "Land Classification", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => LandClassificationBloc() + ..add(const LoadLandClassification()), + child: const LandClassificationAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.wrench, + title: "Trees", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + TreesImprovementsBloc()..add(LoadTreesImprovements()), + child: const TreesImprovementsAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.wrench, + title: "Type of Road", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(const LoadTypeOfRoad()), + child: const TypesOfRoadAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.wrench, + title: "Type of Location", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(const LoadTypeOfLocation()), + child: const TypesOfLocationAdminPage(), + ); + })); + }, + ), ], ), ); diff --git a/lib/screens/offline/passo/admin/class_components.dart b/lib/screens/offline/passo/admin/class_components.dart index 60d0eab..8a3b127 100644 --- a/lib/screens/offline/passo/admin/class_components.dart +++ b/lib/screens/offline/passo/admin/class_components.dart @@ -100,8 +100,9 @@ class _ClassComponentsAdminPage extends State { rows: state.classes.map((dataRow) { return DataRow( cells: [ - DataCell(Text(dataRow.componentName ?? - 'N/A')), // Use a default value if cityCode is null + DataCell( + Text(dataRow.componentName ?? 'N/A')), + // Use a default value if cityCode is null DataCell(Text(dataRow.withoutBucc .toString() ?? 'N/A')), // Use a default value if cityDescription is null diff --git a/lib/screens/offline/passo/admin/globalSyncService.dart b/lib/screens/offline/passo/admin/globalSyncService.dart new file mode 100644 index 0000000..368495a --- /dev/null +++ b/lib/screens/offline/passo/admin/globalSyncService.dart @@ -0,0 +1,246 @@ +import '../../../../model/passo/barangay.dart'; +import '../../../../model/passo/city.dart'; +import '../../../../model/passo/class_components _offline.dart'; +import '../../../../model/passo/class_components.dart'; +import '../../../../model/passo/land_classification.dart'; +import '../../../../model/passo/land_subclassification.dart'; +import '../../../../model/passo/land_value_adjustment.dart'; +import '../../../../model/passo/memoranda.dart'; +import '../../../../model/passo/signatories.dart'; +import '../../../../model/passo/trees_improvements.dart'; +import '../../../../model/passo/type_of_location.dart'; +import '../../../../model/passo/type_of_road.dart'; +import '../../../../model/passo/unit_construct.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/class_components_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/land_classification_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/land_sub_classification_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/memoranda_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/signatories.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/trees_improvements_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/type_of_location.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/type_of_road_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/unit_construction_api_services.dart'; +import '../../../../sevices/offline/offline_passo/admin/api_services/value_adjustments.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class GlobalSyncService { + static final GlobalSyncService _instance = GlobalSyncService._internal(); + + factory GlobalSyncService() { + return _instance; + } + + GlobalSyncService._internal(); + + Future syncAllData() async { + const maxRetries = 100; + int retryCount = 0; + + // Helper function for retrying individual sync methods + Future syncWithRetry(Future Function() syncMethod) async { + if (retryCount < maxRetries) { + retryCount++; + print('Retrying synchronization for ${retryCount}...'); + // Implement a backoff strategy, for example, using a delay. + await Future.delayed(Duration(seconds: retryCount * 2)); + await syncMethod(); + } else { + print('Max retries reached for ${syncMethod.toString()}. Sync failed.'); + // Handle the failure as needed (e.g., show an error message). + } + } + + Future retrySync() async { + try { + await syncWithRetry(syncBrgyData); + await syncWithRetry(syncClassComponentsData); + await syncWithRetry(syncLandClassification); + await syncWithRetry(syncLandSubClassification); + await syncWithRetry(syncMemoranda); + await syncWithRetry(syncMunicipalities); + await syncWithRetry(syncSignatories); + await syncWithRetry(syncTreesImprovements); + await syncWithRetry(syncTypeOfLocation); + await syncWithRetry(syncTypeOfRoad); + await syncWithRetry(syncUnitConstruct); + await syncWithRetry(syncValueAdjustment); + } catch (e) { + print(e); + print('Max retries reached. Sync failed.'); + // Handle the failure as needed (e.g., show an error message). + } + } + + await retrySync(); + // Add more sync methods as needed + } + + Future syncBrgyData() async { + final result = await BrgyAdminApiServices.instance.fetch(); + final brgys = result.map((json) => Brgy.fromJson(json)).toList(); + + for (Brgy brgy in brgys) { + await SQLServices.instance.createBarangay(brgy); + } + } + + Future syncClassComponentsData() async { + final result = await ClassComponentAdminApiServices.instance.fetch(); + final classes = + result.map((json) => ClassComponents.fromJson(json)).toList(); + + for (ClassComponents classs in classes) { + await SQLServices.instance.createClassComponents( + ClassComponentsOffline( + componentName: classs.componentName, + minBaseUnitvalPercent: classs.minBaseUnitvalPercent, + maxBaseUnitvalPercent: classs.maxBaseUnitvalPercent, + minUnitvalSqrmtr: classs.minUnitvalSqrmtr, + maxUnitvalSqrmtr: classs.maxUnitvalSqrmtr, + minAddBaseunitval: classs.minAddBaseunitval, + maxAddBaseunitval: classs.maxAddBaseunitval, + minDeductBaserate: classs.minAddBaseunitval, + maxDeductBaserate: classs.maxDeductBaserate, + minLinearMeter: classs.minLinearMeter, + maxLinearMeter: classs.maxLinearMeter, + minSpacing: classs.minSpacing, + maxSpacing: classs.maxSpacing, + roughFinish: classs.roughFinish, + highFinish: classs.highFinish, + withoutBucc: classs.withoutBucc == true ? 1 : 0), + ); + } + } + + Future syncLandClassification() async { + final result = await LandClassificationAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final landClass = + result.map((json) => LandClassification.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (LandClassification landClassification in landClass) { + await SQLServices.instance.createLandClassification(landClassification); + } + } + + Future syncLandSubClassification() async { + final result = await LandSubClassificationAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final landSubClass = + result.map((json) => LandSubClassification.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (LandSubClassification landSubClassification in landSubClass) { + await SQLServices.instance + .createLandSubClassification(landSubClassification); + } + } + + Future syncMemoranda() async { + final result = await MemorandaAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final memos = result.map((json) => Memoranda.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (Memoranda memo in memos) { + await SQLServices.instance.createMemoranda(memo); + } + } + + Future syncMunicipalities() async { + final result = await MunicipalityAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final cities = result.map((json) => City.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (City city in cities) { + print(city.cityDescription); + print(city.cityCode); + await SQLServices.instance.createMunicipalities(city); + } + } + + Future syncSignatories() async { + final result = await SignatoriesAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final signatories = + result.map((json) => Signatories.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (Signatories signatory in signatories) { + await SQLServices.instance.createSignatories(signatory); + } + } + + Future syncTreesImprovements() async { + final result = await TreesImprovementsAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final treesImpr = + result.map((json) => TreesImprovements.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TreesImprovements treesImprovements in treesImpr) { + await SQLServices.instance.createTreesImprovements(treesImprovements); + } + } + + Future syncTypeOfLocation() async { + final result = await TypeOfLocationAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final typesOfLoc = + result.map((json) => TypeOfLocation.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TypeOfLocation typesOfLocation in typesOfLoc) { + await SQLServices.instance.createTypeOfLocation(typesOfLocation); + } + } + + Future syncTypeOfRoad() async { + final result = await TypeOfRoadAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final typesOfRoad = + result.map((json) => TypeOfRoad.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TypeOfRoad typesOfRoad in typesOfRoad) { + await SQLServices.instance.createTypeOfRoad(typesOfRoad); + } + } + + Future syncUnitConstruct() async { + final result = await UnitConstructionAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final units = result.map((json) => UnitConstruct.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (UnitConstruct unit in units) { + await SQLServices.instance.createUnitConstruction(unit); + } + } + + Future syncValueAdjustment() async { + final result = await ValueAdjustmentsAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final valueAdj = + result.map((json) => ValueAdjustments.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (ValueAdjustments valueAdjustments in valueAdj) { + await SQLServices.instance.createValueAdjustments(valueAdjustments); + } + } +} diff --git a/lib/screens/offline/passo/admin/land_classification.dart b/lib/screens/offline/passo/admin/land_classification.dart new file mode 100644 index 0000000..3389bd4 --- /dev/null +++ b/lib/screens/offline/passo/admin/land_classification.dart @@ -0,0 +1,109 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; + +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/land_classification_api_services.dart'; + +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class LandClassificationAdminPage extends StatefulWidget { + const LandClassificationAdminPage(); + + @override + _LandClassificationAdminPage createState() => _LandClassificationAdminPage(); +} + +class _LandClassificationAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Land Classification"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await LandClassificationAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final landClass = result + .map((json) => LandClassification.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (LandClassification landClassification in landClass) { + await SQLServices.instance + .createLandClassification(landClassification); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandClassificationLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Code'), + ), + const DataColumn( + label: Text('Memoranda'), + ), + ], + rows: state.landClassification.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.classificationCode ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.description ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/land_sub_classification.dart b/lib/screens/offline/passo/admin/land_sub_classification.dart new file mode 100644 index 0000000..f091df9 --- /dev/null +++ b/lib/screens/offline/passo/admin/land_sub_classification.dart @@ -0,0 +1,118 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/land_sub_classification_api_services.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../model/passo/land_subclassification.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class LandSubClassificationAdminPage extends StatefulWidget { + const LandSubClassificationAdminPage(); + + @override + _LandSubClassificationAdminPage createState() => + _LandSubClassificationAdminPage(); +} + +class _LandSubClassificationAdminPage + extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Land Sub-Classification"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = await LandSubClassificationAdminApiServices + .instance + .fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final landSubClass = result + .map((json) => LandSubClassification.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (LandSubClassification landSubClassification + in landSubClass) { + await SQLServices.instance + .createLandSubClassification(landSubClassification); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandSubClassificationLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Municipality'), + ), + const DataColumn( + label: Text('Sub-Class Description'), + ), + const DataColumn( + label: Text('Base Unit Market Value'), + ), + ], + rows: state.landSubClassification.map((dataRow) { + return DataRow( + cells: [ + DataCell( + Text(dataRow.id.toString() ?? 'N/A')), + DataCell(Text(dataRow.cityCode.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.subclassDescription ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell( + Text(dataRow.baseUnitMarketval ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/trees_improvements.dart b/lib/screens/offline/passo/admin/trees_improvements.dart new file mode 100644 index 0000000..9fa8a6d --- /dev/null +++ b/lib/screens/offline/passo/admin/trees_improvements.dart @@ -0,0 +1,108 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/trees_improvements_api_services.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../model/passo/trees_improvements.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class TreesImprovementsAdminPage extends StatefulWidget { + const TreesImprovementsAdminPage(); + + @override + _TreesImprovementsAdminPage createState() => _TreesImprovementsAdminPage(); +} + +class _TreesImprovementsAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Trees Improvement"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await TreesImprovementsAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final treesImpr = result + .map((json) => TreesImprovements.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TreesImprovements treesImprovements in treesImpr) { + await SQLServices.instance + .createTreesImprovements(treesImprovements); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TreesImprovementsLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Code'), + ), + const DataColumn( + label: Text('Memoranda'), + ), + ], + rows: state.treesImprovements.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.improvement ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell( + Text(dataRow.pricePerTree ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/admin/type_of_location.dart b/lib/screens/offline/passo/admin/type_of_location.dart new file mode 100644 index 0000000..83ca701 --- /dev/null +++ b/lib/screens/offline/passo/admin/type_of_location.dart @@ -0,0 +1,114 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/type_of_location.dart'; + +import '../../../../model/passo/type_of_location.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class TypesOfLocationAdminPage extends StatefulWidget { + const TypesOfLocationAdminPage(); + + @override + _TypesOfLocationAdminPage createState() => _TypesOfLocationAdminPage(); +} + +class _TypesOfLocationAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Type of Location"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await TypeOfLocationAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final typesOfLoc = result + .map((json) => TypeOfLocation.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TypeOfLocation typesOfLocation in typesOfLoc) { + await SQLServices.instance + .createTypeOfLocation(typesOfLocation); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfLocationLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Distance in KM'), + ), + const DataColumn( + label: Text('Road Types'), + ), + const DataColumn( + label: Text( + 'Distance from Local Trading Center'), + ), + ], + rows: state.typeOfLocation.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.distanceKm ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell( + Text(dataRow.allRoadTypes ?? 'N/A')), + DataCell(Text( + dataRow.localTradingCenter ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/admin/type_of_road.dart b/lib/screens/offline/passo/admin/type_of_road.dart new file mode 100644 index 0000000..a72006f --- /dev/null +++ b/lib/screens/offline/passo/admin/type_of_road.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/type_of_road_api_services.dart'; + +import '../../../../model/passo/type_of_road.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class TypesOfRoadAdminPage extends StatefulWidget { + const TypesOfRoadAdminPage(); + + @override + _TypesOfRoadAdminPage createState() => _TypesOfRoadAdminPage(); +} + +class _TypesOfRoadAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Type of Road"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await TypeOfRoadAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final typesOfRoad = + result.map((json) => TypeOfRoad.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (TypeOfRoad typesOfRoad in typesOfRoad) { + await SQLServices.instance.createTypeOfRoad(typesOfRoad); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfRoadLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Road Type'), + ), + const DataColumn( + label: Text('Deduction'), + ), + ], + rows: state.typeOfRoad.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.roadType ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.deduction ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/admin/value_adjustment.dart b/lib/screens/offline/passo/admin/value_adjustment.dart new file mode 100644 index 0000000..3c6f9c1 --- /dev/null +++ b/lib/screens/offline/passo/admin/value_adjustment.dart @@ -0,0 +1,122 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/value_adjustments.dart'; + +import '../../../../model/passo/land_value_adjustment.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class ValueAdjustmentsAdminPage extends StatefulWidget { + const ValueAdjustmentsAdminPage(); + + @override + _ValueAdjustmentsAdminPage createState() => _ValueAdjustmentsAdminPage(); +} + +class _ValueAdjustmentsAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Value Adjustment"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await ValueAdjustmentsAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final valueAdj = result + .map((json) => ValueAdjustments.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (ValueAdjustments valueAdjustments in valueAdj) { + await SQLServices.instance + .createValueAdjustments(valueAdjustments); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is ValueAdjustmentsLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Adjustment Factor'), + ), + const DataColumn( + label: Text('Adjustment'), + ), + const DataColumn( + label: Text('Value Adjustment'), + ), + const DataColumn( + label: Text('Market Value'), + ), + ], + rows: state.valueAdjustments.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.baseMarketval ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text( + dataRow.adjustmentFactors ?? 'N/A')), + DataCell(Text(dataRow.adjustment ?? 'N/A')), + DataCell( + Text(dataRow.valueAdjustment ?? 'N/A')), + DataCell( + Text(dataRow.marketValue ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart b/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart new file mode 100644 index 0000000..fb2f391 --- /dev/null +++ b/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart @@ -0,0 +1,368 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/model/passo/building_and_structure.dart'; + +import '../../../../../model/passo/unit_construct.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class AddBuildingAndStructureOffline extends StatefulWidget { + final OfflineProfile offlineProfile; + AddBuildingAndStructureOffline(this.offlineProfile); + + @override + _AddBuildingAndStructureOffline createState() => + _AddBuildingAndStructureOffline(); +} + +class _AddBuildingAndStructureOffline + extends State { + GlobalKey formKey = GlobalKey(); + final focus = FocusNode(); + + final DateTime now; + final String formatter; + + _AddBuildingAndStructureOffline() + : now = DateTime.now(), + formatter = DateFormat.yMMMMd('en_US').format(DateTime.now()); + + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + double _unitBase = 0; + String _structureType = ""; + double _areaValue = 0; + double _depRate = 0; + + double _totalMarketValue(unitBase, bldgArea) { + return unitBase * bldgArea; + } + + double _amountofDepreciation(unitBase, area, depreciation) { + return (unitBase * area) * depreciation; + } + + double _adjustedMarketValue(unitBase, area, depreciation) { + double marketVal = unitBase * area; + double depAmount = (unitBase * area) * depreciation; + return marketVal - depAmount; + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + print(state); + if (state is ShowBldgAndStructuresScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + return FormBuilder( + key: formKey, + onChanged: () { + formKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(0.0), + child: Container( + height: 800, + child: SingleChildScrollView( + padding: const EdgeInsets.all(2.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: state.unit + .map((UnitConstruct unit) => + SearchFieldListItem( + '${unit.bldgType} - ${unit.building}', + item: unit, + child: ListTile( + title: Text( + '${unit.bldgType} - ${unit.building!.toUpperCase()}', + overflow: + TextOverflow.ellipsis, + ), + ))) + .toList(), + + validator: FormBuilderValidators.required( + errorText: "This field is required"), + + searchInputDecoration: + normalTextFieldStyle("Structure Type", "") + .copyWith( + suffixIcon: const Icon( + Icons.arrow_drop_down)), + ////agency suggestion tap + focusNode: focus, + suggestionState: Suggestion.expand, + onSuggestionTap: (unit) { + setState(() { + _unitBase = + double.parse(unit.item!.unitValue); + _structureType = + '${unit.item!.bldgType} - ${unit.item!.building}'; + + formKey.currentState!.patchValue( + {'unit_value': unit.item?.unitValue}); + }); + focus.unfocus(); + }, + ), + ), + ), + const SizedBox( + height: 10, + ), + customDropDownField( + "Actual Use", "", 'actual_use', actual_use), + const SizedBox( + height: 5, + ), + const SizedBox( + height: 10, + ), + Container( + child: FormBuilderTextField( + name: 'unit_value', + decoration: + normalTextFieldStyle("Unit Value", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + // setState(() { + // _areaValue = int.parse(value!); + // }); + }, + ), + ), + SizedBox( + height: 10, + ), + Row( + children: [ + Expanded( + child: FormBuilderTextField( + name: 'dep_rate', + decoration: normalTextFieldStyle( + "Depreciation Rate", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _depRate = double.parse(value!); + }); + }, + ), + ), + const SizedBox( + width: 5, + ), + Expanded( + child: FormBuilderTextField( + name: 'bldg_area', + decoration: + normalTextFieldStyle("Area", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _areaValue = double.parse(value!); + }); + }, + ), + ), + ], + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_totalMarketValue( + _unitBase, _areaValue)))), + ), + const SizedBox(height: 10), + const Text('Amount of Depreciation'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_amountofDepreciation( + _unitBase, _areaValue, _depRate)))), + ), + const SizedBox(height: 10), + const Text('Adjusted Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_adjustedMarketValue( + _unitBase, _areaValue, _depRate)))), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + try { + final tempID = await SharedPreferences + .getInstance(); + var bldgStructure = BldgAndStructure( + id: 1, + bldgapprDetailsId: tempID.getInt( + 'tempid')!, + assessedById: widget + .offlineProfile.id + .toString(), + assessedByName: widget + .offlineProfile.firstName, + dateCreated: formatter, + dateModified: 'none', + bldgType: _structureType, + strucType: _structureType, + description: 'None', + actualUse: formKey.currentState + ?.value['actual_use'], + floorCount: '1', + bldgArea: _areaValue.toString(), + unitValue: _unitBase.toString(), + depRate: _depRate.toString(), + marketValue: _totalMarketValue( + _unitBase, + _areaValue) + .toString(), + depAmount: _amountofDepreciation( + _unitBase, + _areaValue, + _depRate) + .toString(), + adjustedMarketValue: + _adjustedMarketValue(_unitBase, + _areaValue, _depRate) + .toString()); + context + .read() + .add(AddBuildingAndStructure( + bldgAndStructure: + bldgStructure)); + } catch (e) { + print(e); + } + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add( + const LoadBuildingAndStructure()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + ), + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart index 2a92d2f..5373e01 100644 --- a/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart +++ b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart @@ -9,6 +9,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/class_components.dart'; import 'package:unit2/model/passo/unit_construct.dart'; @@ -17,7 +18,8 @@ import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/error_state.dart'; class AddExtraItemsOffline extends StatefulWidget { - AddExtraItemsOffline(); + final OfflineProfile offlineProfile; + AddExtraItemsOffline(this.offlineProfile); @override _AddExtraItemsOffline createState() => _AddExtraItemsOffline(); @@ -30,7 +32,7 @@ class _AddExtraItemsOffline extends State { bool isSecondHand = false; TextEditingController textEditingController = TextEditingController(); double _unitBase = 0; - int _areaValue = 0; + double _areaValue = 0; final double _depValue = 0; double _unitValue = 0; String _className = ""; @@ -40,6 +42,13 @@ class _AddExtraItemsOffline extends State { int _notPaintedUnitVal = 0; int _secondHandUnitVal = 0; + final DateTime now; + final String formatter; + + _AddExtraItemsOffline() + : now = DateTime.now(), + formatter = DateFormat.yMMMMd('en_US').format(DateTime.now()); + BoxDecoration box1() { return const BoxDecoration(boxShadow: [ BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) @@ -304,10 +313,22 @@ class _AddExtraItemsOffline extends State { suggestionState: Suggestion.expand, onSuggestionTap: (unit) { setState(() { - _unitBase = double.parse( - unit.item!.unitValue); - _structureType = - '${unit.item!.bldgType} - ${unit.item!.building}'; + if (_withoutBUCC) { + _unitBase = double.parse( + unit.item!.unitValue); + _structureType = + '${unit.item!.bldgType} - ${unit.item!.building}'; + } else { + _unitBase = double.parse( + unit.item!.unitValue); + _structureType = + '${unit.item!.bldgType} - ${unit.item!.building}'; + formKey.currentState! + .patchValue({ + 'unitValue': + unit.item!.unitValue + }); + } }); focus.unfocus(); }, @@ -364,7 +385,8 @@ class _AddExtraItemsOffline extends State { []), onChanged: (value) { setState(() { - _areaValue = int.parse(value!); + _areaValue = + double.parse(value!); }); }, ), @@ -603,29 +625,33 @@ class _AddExtraItemsOffline extends State { await SharedPreferences .getInstance(); - context - .read< - AdditionalItemsOfflineBloc>() - .add(AddAdditionalItems( + context.read().add( + AddAdditionalItems( id: 1, - bldgapprDetailsId: - tempID - .getInt( - 'tempid')!, + bldgapprDetailsId: tempID + .getInt('tempid')!, classId: _classId, + assessedById: widget + .offlineProfile.id + .toString(), + assessedByName: widget + .offlineProfile + .firstName!, + dateCreated: formatter, + dateModified: 'None', className: _className, structType: _structureType, unitValue: - _withoutBUCC == - true + _withoutBUCC == true ? 0 : _unitValue, baseUnitValue: _unitBase, area: _areaValue, marketValue: - (_unitValue * _unitBase) * + (_unitValue * + _unitBase) * _areaValue, depreciationRate: _depValue, @@ -676,9 +702,11 @@ class _AddExtraItemsOffline extends State { padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () { - // context - // .read() - // .add(const LoadAdditionalItems()); + context + .read< + AdditionalItemsOfflineBloc>() + .add( + const LoadAdditionalItems()); }, style: ElevatedButton.styleFrom( primary: Colors.black, diff --git a/lib/screens/offline/passo/building/add/add_building.dart b/lib/screens/offline/passo/building/add/add_building.dart index 10db27a..901b1bd 100644 --- a/lib/screens/offline/passo/building/add/add_building.dart +++ b/lib/screens/offline/passo/building/add/add_building.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:im_stepper/stepper.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/screens/offline/passo/building/add/building_and_structure.dart'; import 'package:unit2/screens/offline/passo/building/add/property_appraisal.dart'; import 'package:unit2/screens/offline/passo/building/add/property_assessment.dart'; import 'package:unit2/screens/offline/passo/building/add/property_owner_info.dart'; @@ -13,12 +15,14 @@ import 'package:unit2/theme-data.dart/colors.dart'; import '../../../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; import '../../../../../model/passo/property_info.dart'; +import '../../../../../utils/alerts.dart'; GlobalKey offlineBldgKey = GlobalKey(); class AddBuilding extends StatefulWidget { Function triggerBlocEvent; - AddBuilding(this.triggerBlocEvent); + final OfflineProfile offlineProfile; + AddBuilding(this.triggerBlocEvent, this.offlineProfile); @override _AddBuilding createState() => _AddBuilding(); } @@ -27,6 +31,14 @@ class _AddBuilding extends State { int activeStep = 0; // Initial step set to 5. int upperBound = 6; + List foundation = []; + List column = []; + List beam = []; + List trussFraming = []; + List roof = []; + List flooring = []; + List walls = []; + void PrevBtn() { setState(() { activeStep--; @@ -39,81 +51,160 @@ class _AddBuilding extends State { }); } + void updateFoundation(List updatedList) { + setState(() { + foundation = updatedList; + }); + } + + void updateColumn(List updatedList) { + setState(() { + column = updatedList; + }); + } + + void updateBeam(List updatedList) { + setState(() { + beam = updatedList; + }); + } + + void updateTrussFraming(List updatedList) { + setState(() { + trussFraming = updatedList; + }); + } + + void updateRoof(List updatedList) { + setState(() { + roof = updatedList; + }); + } + + void updateFlooring(List updatedList) { + setState(() { + flooring = updatedList; + }); + } + + void updateWalls(List updatedList) { + setState(() { + walls = updatedList; + }); + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: primary, - centerTitle: true, - title: const Text("Offline Building FAAS"), + print(widget.offlineProfile.toJson()); + return WillPopScope( + onWillPop: () async { + confirmAlertWithCancel( + context, + onCloseTransaction, + () => null, + 'Cancel transaction?', + "Are you sure you want to cancel this transaction?"); // Action to perform on back pressed + return false; + }, + child: Scaffold( + appBar: AppBar( + backgroundColor: primary, + centerTitle: true, + title: const Text("Offline Building FAAS"), + ), + body: Column(children: [ + NumberStepper( + numbers: [1, 2, 3, 4, 5, 6, 7, 8], + stepPadding: 5, + activeStepColor: primary, + numberStyle: TextStyle(color: Colors.white), + lineColor: primary, + // activeStep property set to activeStep variable defined above. + activeStep: activeStep, + activeStepBorderColor: Colors.white, + activeStepBorderWidth: 1, + // This ensures step-tapping updates the activeStep. + onStepReached: (index) { + setState(() { + activeStep = index; + }); + }, + enableStepTapping: false, + ), + Expanded( + child: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return FormBuilder( + key: offlineBldgKey, + onChanged: () { + offlineBldgKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Container( + child: content(PrevBtn, NextBtn), + ), + ); + }), + ), + ]), ), - body: Column(children: [ - NumberStepper( - numbers: [1, 2, 3, 4, 5, 6, 7], - stepPadding: 5, - activeStepColor: primary, - numberStyle: TextStyle(color: Colors.white), - lineColor: primary, - // activeStep property set to activeStep variable defined above. - activeStep: activeStep, - activeStepBorderColor: Colors.white, - activeStepBorderWidth: 1, - // This ensures step-tapping updates the activeStep. - onStepReached: (index) { - setState(() { - activeStep = index; - }); - }, - enableStepTapping: false, - ), - Expanded( - child: StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return FormBuilder( - key: offlineBldgKey, - onChanged: () { - offlineBldgKey.currentState?.save(); - }, - autovalidateMode: AutovalidateMode.disabled, - child: Container( - child: content(PrevBtn, NextBtn), - ), - ); - }), - ), - ]), ); } Widget content(PrevBtn, NextBtn) { switch (activeStep) { case 0: - return PropertyInfoOfflinePage(NextBtn); + return PropertyInfoOfflinePage(NextBtn, widget.offlineProfile); case 1: - return LandRefLocationOfflinePage(PrevBtn, NextBtn); + return LandRefLocationOfflinePage( + PrevBtn, NextBtn, widget.offlineProfile); case 2: - return GeneralDescriptionOfflinePage(NextBtn, PrevBtn); + return GeneralDescriptionOfflinePage( + NextBtn, PrevBtn, widget.offlineProfile); case 3: - return StructuralMaterialsOfflinePage(PrevBtn, NextBtn); + return BuildingAndStructureOfflinePage( + PrevBtn, NextBtn, widget.offlineProfile); case 4: - return AdditionalItemOfflinePage(PrevBtn, NextBtn); + return StatefulBuilder( + builder: (context, StateSetter setInnerState) => + StructuralMaterialsOfflinePage(PrevBtn, NextBtn, + foundation: foundation, + column: column, + beam: beam, + trussFraming: trussFraming, + roof: roof, + flooring: flooring, + walls: walls, + updateFoundation: updateFoundation, + updateColumn: updateColumn, + updateBeam: updateBeam, + updateFlooring: updateFlooring, + updateRoof: updateRoof, + updateTrussFraming: updateTrussFraming, + updateWalls: updateWalls)); case 5: - return PropertyAppraisalOfflinePage(NextBtn, PrevBtn); + return AdditionalItemOfflinePage( + PrevBtn, NextBtn, widget.offlineProfile); case 6: - return PropertyAssessmentOfflinePage(onSAveAll); + return PropertyAppraisalOfflinePage( + NextBtn, PrevBtn, widget.offlineProfile); + + case 7: + return PropertyAssessmentOfflinePage( + onCloseTransaction, widget.offlineProfile); default: return Text("Property Info"); } } - void onSAveAll() { + void onCloseTransaction() { Navigator.of(context).pop(); widget.triggerBlocEvent(); } diff --git a/lib/screens/offline/passo/building/add/additional_items.dart b/lib/screens/offline/passo/building/add/additional_items.dart index b4b7ae6..98f0c34 100644 --- a/lib/screens/offline/passo/building/add/additional_items.dart +++ b/lib/screens/offline/passo/building/add/additional_items.dart @@ -2,16 +2,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/AddExtraItemsOffline.dart'; +import '../../../../../utils/alerts.dart'; import '../../../../../widgets/passo/custom_button.dart'; class AdditionalItemOfflinePage extends StatefulWidget { final VoidCallback additionalItemsPrevBtn; final VoidCallback additionalItemsNextBtn; + final OfflineProfile offlineProfile; - const AdditionalItemOfflinePage( - this.additionalItemsPrevBtn, this.additionalItemsNextBtn); + const AdditionalItemOfflinePage(this.additionalItemsPrevBtn, + this.additionalItemsNextBtn, this.offlineProfile); @override _AdditionalItemOfflinePage createState() => _AdditionalItemOfflinePage(); @@ -22,12 +25,18 @@ class _AdditionalItemOfflinePage extends State { // context.read().add(DeleteAdditionalItems(id: itemId)); // } + void deleteItem(int itemId) { + context + .read() + .add(DeleteAdditionalItems(id: itemId)); + } + final items = []; double _totalMarketValue(items) { double total = 0; items.forEach((row) { - total += double.parse(row.adjustedMarketVal); + total += row.adjustedMarketVal; }); return total; } @@ -155,11 +164,17 @@ class _AdditionalItemOfflinePage extends State { return DataRow( cells: [ DataCell(Text(dataRow.className)), - DataCell( - Text(dataRow.baseUnitValue.toString())), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(dataRow.baseUnitValue).toString())), DataCell(Text(dataRow.unitValue.toString())), - DataCell(Text(((double.parse( - dataRow.adjustedMarketVal.toString()))) + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(((double.parse( + dataRow.adjustedMarketVal.toString())))) .toString())), DataCell(Row( children: [ @@ -178,28 +193,14 @@ class _AdditionalItemOfflinePage extends State { ), ), onTap: () { - // deleteItem(dataRow.id); + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); }, ), - const SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: const Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), ], )) ], @@ -217,15 +218,15 @@ class _AdditionalItemOfflinePage extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( - 'Total', + 'Total Market Value', style: - TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ), Text( NumberFormat.currency(locale: 'en-PH', symbol: "₱") - .format(_totalMarketValue(items)), + .format(_totalMarketValue(state.addItem)), style: - TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ) ], ), @@ -261,6 +262,19 @@ class _AdditionalItemOfflinePage extends State { ], ); } + if (state is AdditionalItemsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(LoadAdditionalItems()); + }); + }); + } + } if (state is ShowAddItemsScreen) { return ConstrainedBox( constraints: BoxConstraints(maxHeight: 1000.0), @@ -276,7 +290,9 @@ class _AdditionalItemOfflinePage extends State { content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, - children: [Expanded(child: AddExtraItemsOffline())], + children: [ + Expanded(child: AddExtraItemsOffline(widget.offlineProfile)) + ], ), ), ); diff --git a/lib/screens/offline/passo/building/add/building_and_structure.dart b/lib/screens/offline/passo/building/add/building_and_structure.dart new file mode 100644 index 0000000..1a20ffc --- /dev/null +++ b/lib/screens/offline/passo/building/add/building_and_structure.dart @@ -0,0 +1,336 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/screens/offline/passo/building/add/AddBuildingAndStructure..dart'; + +import '../../../../../utils/alerts.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class BuildingAndStructureOfflinePage extends StatefulWidget { + final VoidCallback additionalItemsPrevBtn; + final VoidCallback additionalItemsNextBtn; + final OfflineProfile offlineProfile; + + const BuildingAndStructureOfflinePage(this.additionalItemsPrevBtn, + this.additionalItemsNextBtn, this.offlineProfile); + + @override + _BuildingAndStructureOfflinePage createState() => + _BuildingAndStructureOfflinePage(); +} + +class _BuildingAndStructureOfflinePage + extends State { + // void deleteItem(int itemId) { + // context.read().add(DeleteAdditionalItems(id: itemId)); + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteBuildingAndStructure(id: itemId)); + } + + final items = []; + + double _totalMarketValue(items) { + double total = 0; + items.forEach((row) { + total += double.parse(row.adjustedMarketValue); + }); + return total; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is BuildingAndStructureOfflineInitial) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column(children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('BUILDING AND STRUCTURE', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowBuildingAndStructure()); + }, + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD NEW'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ) + ])))) + ]); + } + if (state is BuildingAndStructureLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('BUILDING AND STRUCTURES', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowBuildingAndStructure()); + }, + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Building Core'), + ), + const DataColumn( + label: Text('Type'), + ), + const DataColumn( + label: Text('Area'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('% of BUCC'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('% of Depreciation'), + ), + const DataColumn( + label: Text('Depreciation Cost'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.bldgAndStructure.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.actualUse!)), + DataCell(Text(dataRow.bldgType!)), + DataCell(Text(dataRow.bldgArea!)), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(double.parse(dataRow.unitValue!)), + )), + const DataCell(Text("100%")), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format( + double.parse(dataRow.marketValue!)), + )), + DataCell(Text(dataRow.depRate!)), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(double.parse(dataRow.depAmount!)), + )), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(double.parse( + dataRow.adjustedMarketValue!)), + )), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: const Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList(), + ), + ) + ], + ), + ), + )), + Padding( + padding: const EdgeInsets.only(left: 20.0, right: 20.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Total Market Value', + style: + TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + ), + Text( + NumberFormat.currency(locale: 'en-PH', symbol: "₱") + .format(_totalMarketValue(state.bldgAndStructure)), + style: + TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + ) + ], + ), + ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.additionalItemsPrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.additionalItemsNextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is BuildingAndStructureDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(LoadBuildingAndStructure()); + }); + }); + } + } + if (state is ShowBldgAndStructuresScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 10.0, + vertical: 10.0, + ), + title: const Text( + 'ADD NEW BLDG & STRUCTURE', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: + AddBuildingAndStructureOffline(widget.offlineProfile)) + ], + ), + ), + ); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/building/add/general_description.dart b/lib/screens/offline/passo/building/add/general_description.dart index 9dc2ad6..5288e95 100644 --- a/lib/screens/offline/passo/building/add/general_description.dart +++ b/lib/screens/offline/passo/building/add/general_description.dart @@ -6,6 +6,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import 'package:unit2/screens/passo/Building/add_building_components/general_description.dart'; @@ -13,13 +14,15 @@ import '../../../../../model/passo/general_description.dart'; import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../widgets/passo/custom_button.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; +import 'package:intl/intl.dart'; class GeneralDescriptionOfflinePage extends StatefulWidget { final VoidCallback onPutGeneralDescription; final VoidCallback gendescPrevBtn; + final OfflineProfile offlineProfile; GeneralDescriptionOfflinePage( - this.onPutGeneralDescription, this.gendescPrevBtn); + this.onPutGeneralDescription, this.gendescPrevBtn, this.offlineProfile); @override _GeneralDescriptionOfflinePage createState() => @@ -37,6 +40,13 @@ class _GeneralDescriptionOfflinePage "Timberland", ]; + final DateTime now; + final String formatter; + + _GeneralDescriptionOfflinePage() + : now = DateTime.now(), + formatter = DateFormat.yMMMMd('en_US').format(DateTime.now()); + @override Widget build(BuildContext context) { return BlocConsumer( @@ -88,12 +98,16 @@ class _GeneralDescriptionOfflinePage // optional flex property if flex is 1 because the default flex is 1 flex: 1, child: customDatTimePicker( - "Certificate of Occupancy Issued ON", - "", - 'date_issued')) + "Date Issued", "", 'date_issued')) ]), - customTextField( - "Condominium Certificate of Title (CCT)", "", 'cct'), + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('Condominium Certificate of Title (CCT)', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 15), + textAlign: TextAlign.start), + ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -201,18 +215,21 @@ class _GeneralDescriptionOfflinePage context.read().add(AddGendesc( id: 1, bldgapprDetailsId: tempID.getInt('tempid')!, - assessedById: '1', - assessedByName: 'cyril', + assessedById: + widget.offlineProfile.id.toString(), + assessedByName: + widget.offlineProfile.firstName!, + dateCreated: formatter, + dateModified: 'None', bldgKind: offlineBldgKey .currentState?.value['bldg_type'].building, strucType: offlineBldgKey .currentState?.value['bldg_type'].bldgType, bldgPermit: offlineBldgKey .currentState?.value['bldg_permit'], - dateIssued: offlineBldgKey - .currentState!.value['coc_issued'] + dateIssued: offlineBldgKey.currentState!.value['coc_issued'] .toString(), - cct: offlineBldgKey.currentState?.value['cct'], + cct: 'None', certCompletionIssued: offlineBldgKey .currentState!.value['coc_issued'] .toString(), @@ -233,7 +250,9 @@ class _GeneralDescriptionOfflinePage area4Thfloor: '0', totalFloorArea: offlineBldgKey.currentState?.value['total_area'], floorSketch: null, - actualUse: offlineBldgKey.currentState?.value['actual_use'])); + actualUse: offlineBldgKey.currentState?.value['actual_use'], + unitValue: offlineBldgKey.currentState?.value['bldg_type'].unitValue)); + widget.onPutGeneralDescription(); } ; }, diff --git a/lib/screens/offline/passo/building/add/landref_location.dart b/lib/screens/offline/passo/building/add/landref_location.dart index 7331635..0c14349 100644 --- a/lib/screens/offline/passo/building/add/landref_location.dart +++ b/lib/screens/offline/passo/building/add/landref_location.dart @@ -7,6 +7,7 @@ import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_a import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import '../../../../../model/passo/barangay.dart'; @@ -14,18 +15,27 @@ import '../../../../../model/passo/city.dart'; import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../widgets/passo/custom_button.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; +import 'package:intl/intl.dart'; class LandRefLocationOfflinePage extends StatefulWidget { final VoidCallback PrevBtn; final VoidCallback NextBtn; + final OfflineProfile offlineProfile; - LandRefLocationOfflinePage(this.PrevBtn, this.NextBtn); + LandRefLocationOfflinePage(this.PrevBtn, this.NextBtn, this.offlineProfile); @override _LandRefLocationOfflinePage createState() => _LandRefLocationOfflinePage(); } class _LandRefLocationOfflinePage extends State { + final DateTime now; + final String formatter; + + _LandRefLocationOfflinePage() + : now = DateTime.now(), + formatter = DateFormat.yMMMMd('en_US').format(DateTime.now()); + @override Widget build(BuildContext context) { return BlocConsumer( @@ -271,8 +281,12 @@ class _LandRefLocationOfflinePage extends State { id: 1, bldgapprDetailsId: tempID.getInt('tempid')!, - assessedById: 'cyril', - assessedByName: 'cyril', + assessedById: + widget.offlineProfile.id.toString(), + assessedByName: + widget.offlineProfile.firstName!, + dateCreated: 'None', + dateModified: 'NOne', street: offlineBldgKey .currentState?.value['street'], barangay: offlineBldgKey @@ -289,8 +303,12 @@ class _LandRefLocationOfflinePage extends State { id: 1, bldgapprDetailsId: tempID.getInt('tempid')!, - assessedById: '1', - assessedByName: 'cyril', + assessedById: + widget.offlineProfile.id.toString(), + assessedByName: + widget.offlineProfile.firstName!, + dateCreated: 'None', + dateModified: 'None', owner: offlineBldgKey .currentState?.value['l_owner'], cloaNo: offlineBldgKey.currentState @@ -306,6 +324,8 @@ class _LandRefLocationOfflinePage extends State { blkNo: offlineBldgKey .currentState?.value['blk_no'], )); + + widget.NextBtn(); }, ); }) diff --git a/lib/screens/offline/passo/building/add/property_appraisal.dart b/lib/screens/offline/passo/building/add/property_appraisal.dart index a3e3e0a..e03b752 100644 --- a/lib/screens/offline/passo/building/add/property_appraisal.dart +++ b/lib/screens/offline/passo/building/add/property_appraisal.dart @@ -2,20 +2,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import 'package:unit2/screens/offline/passo/building/add/additional_items.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; import 'package:unit2/theme-data.dart/form-style.dart'; import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/building_and_structure.dart'; import '../../../../../widgets/passo/custom_button.dart'; class PropertyAppraisalOfflinePage extends StatefulWidget { final VoidCallback NextBtn; final VoidCallback PrevBtn; + final OfflineProfile offlineProfile; - PropertyAppraisalOfflinePage(this.NextBtn, this.PrevBtn); + PropertyAppraisalOfflinePage(this.NextBtn, this.PrevBtn, this.offlineProfile); @override _PropertyAppraisalOfflinePage createState() => @@ -35,7 +42,7 @@ class _PropertyAppraisalOfflinePage final focus = FocusNode(); String assessmentLevel(marketValues, property_class) { - final marketValue = double.parse(marketValues); + final marketValue = marketValues; switch (property_class) { case 'Residential': if (marketValue < 175000) { @@ -244,7 +251,7 @@ class _PropertyAppraisalOfflinePage } double assessmentValue(marketValues, property_class) { - final marketValue = double.parse(marketValues); + final marketValue = marketValues; switch (property_class) { case 'Residential': if (marketValue < 175000) { @@ -452,588 +459,402 @@ class _PropertyAppraisalOfflinePage return 0; } - calculateAdditionalItems(List items) { - double sum = 0; + _calculateMarketValue( + List items, List bldg) { + double add_sum = 0; double product = 1; + double bldg_sum = 0; for (AdditionalItems value in items) { - sum += double.parse(value.adjustedMarketVal.toString()); + add_sum += double.parse(value.adjustedMarketVal.toString()); } - return sum; + for (BldgAndStructure value in bldg) { + bldg_sum += double.parse(value.adjustedMarketValue.toString()); + } + + return add_sum + bldg_sum; } - calculateTotalConstructionCost(buildingCost, additionalItems) { - double sum = 0; - double product = 1; - - sum = buildingCost + calculateAdditionalItems(additionalItems); - - return sum; - } - - calculateMarketValue(buildingCost, additionalItems, dep) { - double sum = 0; - double depreciation = 0; + double _totalMarketValue(items) { double total = 0; - - sum = buildingCost + calculateAdditionalItems(additionalItems); - - depreciation = sum * dep; - - total = sum - depreciation; - + items.forEach((row) { + total += row.adjustedMarketVal; + }); return total; } - calculateDepCost(buildingCost, additionalItems, dep) { - double sum = 0; - double depreciation = 0; + double _totalMarketValueBLDG(items) { double total = 0; - - sum = buildingCost + calculateAdditionalItems(additionalItems); - - depreciation = sum * dep; - - total = sum - depreciation; - - return depreciation; + items.forEach((row) { + total += double.parse(row.adjustedMarketValue); + }); + return total; } + // calculateMarketValue(buildingCost, additionalItems, dep) { + // double sum = 0; + // double depreciation = 0; + // double total = 0; + + // sum = buildingCost + calculateAdditionalItems(additionalItems); + + // depreciation = sum * dep; + + // total = sum - depreciation; + + // return total; + // } + + // calculateDepCost(buildingCost, additionalItems, dep) { + // double sum = 0; + // double depreciation = 0; + // double total = 0; + + // sum = buildingCost + calculateAdditionalItems(additionalItems); + + // depreciation = sum * dep; + + // total = sum - depreciation; + + // return depreciation; + // } + @override Widget build(BuildContext context) { return Scaffold( body: BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, + listener: (context, state) {}, builder: (context, state) { if (state is AdditionalItemsLoaded) { - return SingleChildScrollView( - child: Container( - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 20), - child: const Text('PROPERTY APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + final addItem = state.addItem; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is BuildingAndStructureLoaded) { + return SingleChildScrollView( + padding: const EdgeInsets.all(20), + child: Column( children: [ Container( - child: const Text( - "Unit Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + textAlign: TextAlign.left), ), - Container( - child: Text( - offlineBldgKey - .currentState!.value['bldg_type'].unitValue + - ' sq.m', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Building Core", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - (double.parse(offlineBldgKey - .currentState!.value['total_area']) * - double.parse(offlineBldgKey.currentState! - .value['bldg_type'].unitValue)) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Cost of Additional Items", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: const Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateAdditionalItems(state.addItem).toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Total Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateTotalConstructionCost( - (double.parse(offlineBldgKey - .currentState!.value['total_area']) * - double.parse(offlineBldgKey.currentState! - .value['bldg_type'].unitValue)), - state.addItem) - .toString(), - textAlign: TextAlign.right, - ), - ), - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Depreciation Rate", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - SizedBox( - width: 90, - height: 25, - child: FormBuilderTextField( - name: 'depRate', - decoration: normalTextFieldStyle("", ""), - validator: FormBuilderValidators.compose([]), - onChanged: (value) { - setState(() { - depRate = double.parse(value!); - }); - }, - ), - ), - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Depreciation Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateDepCost( - (double.parse(offlineBldgKey - .currentState!.value['total_area']) * - double.parse(offlineBldgKey.currentState! - .value['bldg_type'].unitValue)), - state.addItem, - depRate) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Total % Depreciation", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '${(depRate * 100).toStringAsFixed(2)}%', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: const Text( - "Market Value", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateMarketValue( - (double.parse(offlineBldgKey - .currentState!.value['total_area']) * - double.parse(offlineBldgKey.currentState! - .value['bldg_type'].unitValue)), - state.addItem, - depRate) - .toString(), - textAlign: TextAlign.right, - ), - ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Container( - margin: const EdgeInsets.only( - left: 20.0, right: 20.0), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text('PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.left), - ), - Column( - children: [ - Row( - children: [ - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Actual Use', - style: TextStyle( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('BUILDING & STRUCTURE', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable( + columns: [ + const DataColumn( + label: Text('Building Core'), + ), + const DataColumn( + label: Text(''), + ), + const DataColumn( + label: Text('Market Value'), + ), + ], + rows: [ + ...state.bldgAndStructure + .map((dataRow) { + return DataRow(cells: [ + DataCell(Text(dataRow.actualUse!)), + DataCell(Text("")), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse(dataRow + .adjustedMarketValue + .toString()!)), + )) + ]); + }), + DataRow(cells: [ + DataCell(Text('Total', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15, + color: Colors.red))), + DataCell(Text('')), + DataCell( + Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(_totalMarketValueBLDG( + state.bldgAndStructure)), + style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Market Value', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Level', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Value', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - ], - ), - SizedBox( - height: 59, - child: Row( - children: [ - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - offlineBldgKey.currentState - ?.value['actual_use']!, - style: const TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - calculateMarketValue( - (double.parse(offlineBldgKey - .currentState! - .value[ - 'total_area']) * - double.parse(offlineBldgKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state.addItem, - depRate) - .toString(), - style: const TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - assessmentLevel( - calculateMarketValue( - (double.parse(offlineBldgKey - .currentState! - .value[ - 'total_area']) * - double.parse(offlineBldgKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state.addItem, - depRate) - .toString(), - offlineBldgKey - .currentState - ?.value[ - 'actual_use']), - style: const TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - assessmentValue( - calculateMarketValue( - (double.parse(offlineBldgKey.currentState!.value[ - 'total_area']) * - double.parse(offlineBldgKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state - .addItem, - depRate) - .toString(), - offlineBldgKey - .currentState - ?.value[ - 'actual_use']) - .toString(), - style: const TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - ], - ), + fontSize: 15, + color: Colors.red)), ) + ]), + ], + ) + ], + )), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('ADDITIONAL ITEMS', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable(columns: [ + const DataColumn( + label: Text('Additional Item'), + ), + const DataColumn( + label: Text(''), + ), + const DataColumn( + label: Text('Market Value'), + ), + ], rows: [ + ...addItem.map((dataRow) { + return DataRow(cells: [ + DataCell(Text(dataRow.className!)), + DataCell(Text('')), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format(double.parse(dataRow + .marketValue + .toString()!)) + .toString(), + )) + ]); + }).toList(), + DataRow( + // color: MaterialStateColor.resolveWith( + // (states) { + // // Use a color for the DataRow, for example, Colors.blue + // return Colors.redAccent; + // }), + cells: [ + DataCell(Text('Total', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15, + color: Colors.red))), + DataCell(Text('')), + DataCell( + Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(_totalMarketValue( + addItem)), + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 15, + color: Colors.red)), + ) + ]), + ]), + ], + )), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable(columns: const [ + DataColumn( + label: Text('Actual Use'), + ), + DataColumn( + label: Text('Market Value'), + ), + DataColumn( + label: Text('Ass. Level'), + ), + DataColumn( + label: Text('Ass. Value'), + ), + ], rows: [ + DataRow( + cells: [ + DataCell(Text(offlineBldgKey + .currentState + ?.value['actual_use'])), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_calculateMarketValue( + addItem, + state.bldgAndStructure)))), + DataCell( + Text( + assessmentLevel( + _calculateMarketValue(addItem, + state.bldgAndStructure), + offlineBldgKey.currentState + ?.value['actual_use']), + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format(double.parse( + assessmentValue( + _calculateMarketValue( + addItem, + state + .bldgAndStructure), + offlineBldgKey + .currentState + ?.value[ + 'actual_use']) + .toString(), + )) + .toString(), + )), ], ), - ]))), + ]) + ], + )), + ), + ], + ), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + // final tempID = + // await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // context.read().add(AddBldgAppraisal( + // id: 1, + // bldgapprDetailsId: tempID.getInt('tempid')!, + // assessedById: '1', + // assessedByName: 'ad', + // dateCreated: '00', + // dateModified: '00', + // unitconstructCost: offlineBldgKey + // .currentState + // ?.value['bldg_type'] + // .unitValue, + // buildingCore: 'test', + // unitconstructSubtotal: + // (double.parse(offlineBldgKey.currentState!.value['total_area']) * + // double.parse(offlineBldgKey + // .currentState! + // .value['bldg_type'] + // .unitValue)) + // .toString(), + // depreciationRate: depRate.toString(), + // depreciationCost: calculateDepCost( + // (double.parse(offlineBldgKey.currentState!.value['total_area']) * + // double.parse(offlineBldgKey.currentState?.value['bldg_type'].unitValue)), + // addItem, + // depRate) + // .toString(), + // costAddItems: calculateAdditionalItems(addItem).toString(), + // addItemsSubtotal: calculateAdditionalItems(addItem).toString(), + // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), + // marketValue: calculateMarketValue((double.parse(offlineBldgKey.currentState!.value['total_area']) * double.parse(offlineBldgKey.currentState!.value['bldg_type'].unitValue)), addItem, depRate).toString(), + // totalArea: offlineBldgKey.currentState!.value['total_area'], + // actualUse: "Residential")); + widget.NextBtn(); + } + ; + }, + ) + ], ), ], ), - const SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - { - // final tempID = - // await SharedPreferences.getInstance(); - // print(tempID.getInt('tempid')); - // var appraisals = PropertyAppraisal( - // id: 1, - // bldgapprDetailsId: - // tempID.getInt('tempid')! - 1, - // unitconstructCost: formKey - // .currentState! - // .value['bldg_type'] - // .unitValue, - // buildingCore: 'test', - // unitconstructSubtotal: (double.parse(formKey.currentState!.value['total_area']) * - // double.parse(formKey - // .currentState! - // .value['bldg_type'] - // .unitValue)) - // .toString(), - // depreciationRate: depRate.toString(), - // depreciationCost: calculateDepCost( - // (double.parse(formKey.currentState!.value['total_area']) * - // double.parse(formKey.currentState!.value['bldg_type'].unitValue)), - // state.items, - // depRate) - // .toString(), - // costAddItems: calculateAdditionalItems(state.items).toString(), - // addItemsSubtotal: calculateAdditionalItems(state.items).toString(), - // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), - // marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), - // totalArea: formKey.currentState!.value['total_area'], - // actualUse: "Residential"); - // context.read() - // ..add(AddPropertyAppraisal( - // appraisal: appraisals)); - } - ; - }, - ) - ], - ), - ], - ), - ), + ); + } + return Container(); + }, ); } return Container(); diff --git a/lib/screens/offline/passo/building/add/property_assessment.dart b/lib/screens/offline/passo/building/add/property_assessment.dart index 5fcb1c8..7b60fa9 100644 --- a/lib/screens/offline/passo/building/add/property_assessment.dart +++ b/lib/screens/offline/passo/building/add/property_assessment.dart @@ -3,17 +3,26 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:accordion/accordion.dart'; +import 'package:accordion/controllers.dart'; +import '../../../../../bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; import '../../../../../model/passo/memoranda.dart'; import '../../../../../model/passo/signatories.dart'; import '../../../../../theme-data.dart/colors.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import 'package:intl/intl.dart'; // Import the intl package class PropertyAssessmentOfflinePage extends StatefulWidget { Function function; + final OfflineProfile offlineProfile; - PropertyAssessmentOfflinePage(this.function); + PropertyAssessmentOfflinePage(this.function, this.offlineProfile); @override _PropertyAssessmentOfflinePage createState() => @@ -25,8 +34,17 @@ class _PropertyAssessmentOfflinePage double assessment_level = 0; bool isTaxable = false; bool isExempt = false; - String _memoranda = ''; + String _memoranda = ""; + String _notes = ""; + final focus = FocusNode(); + final focuss = FocusNode(); + final appraisedByFocus = FocusNode(); + final recByFocus = FocusNode(); + final apprvdByFocus = FocusNode(); + + TextEditingController memorandaController = TextEditingController(); + TextEditingController noteController = TextEditingController(); @override Widget build(BuildContext context) { @@ -37,6 +55,7 @@ class _PropertyAssessmentOfflinePage builder: (context, state) { if (state is MemorandaLoaded) { final memoranda = state.memo; + final note = state.memo; return BlocConsumer( listener: (context, state) { // TODO: implement listener @@ -153,52 +172,128 @@ class _PropertyAssessmentOfflinePage textAlign: TextAlign.start, ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'appraised_by', - autofocus: false, - items: state.signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - const Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'app_date', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, + const SizedBox( + height: 15, + ), - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - const Text('Date'), - ], + Column( + children: [ + SearchField( + itemHeight: 70, + suggestions: state.signatories + .map((Signatories signatories) => + SearchFieldListItem( + '${signatories.firstname} ${signatories.lastname}', + item: signatories, + child: ListTile( + title: Text( + '${signatories.firstname} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: TextAlign.center, + ), + ))) + .toList(), + + validator: FormBuilderValidators.required( + errorText: "This field is required"), + + // searchInputDecoration: + // normalTextFieldStyle("Appraised by", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down)), + ////agency suggestion tap + focusNode: appraisedByFocus, + suggestionState: Suggestion.expand, + onSuggestionTap: (unit) { + setState(() {}); + appraisedByFocus.unfocus(); + }, + ), + Text( + 'Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14), + ) + ], + ), + const SizedBox( + height: 15, + ), + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDateTimePicker( + name: 'app_date', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + format: DateFormat('MMMM dd, yyyy'), + textAlign: TextAlign.center, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text( + 'Date', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14), ), ], ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // children: [ + // Column( + // children: [ + // SizedBox( + // width: 200, + // child: FormBuilderDropdown( + // name: 'appraised_by', + // autofocus: false, + // items: state.signatories + // .map((signatories) => + // DropdownMenuItem( + // value: signatories, + // child: Text( + // '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + // )) + // .toList()), + // ), + // const Text('Name'), + // ], + // ), + // const SizedBox( + // width: 15, + // ), + // Column( + // children: [ + // SizedBox( + // width: 100, + // child: FormBuilderDateTimePicker( + // name: 'app_date', + // initialEntryMode: + // DatePickerEntryMode.calendarOnly, + // initialValue: DateTime.now(), + // inputType: InputType.date, + + // initialTime: + // const TimeOfDay(hour: 8, minute: 0), + // // locale: const Locale.fromSubtags(languageCode: 'fr'), + // ), + // ), + // const Text('Date'), + // ], + // ), + // ], + // ), const SizedBox( height: 30, ), @@ -208,52 +303,107 @@ class _PropertyAssessmentOfflinePage 'RECOMMENDING APPROVAL:', style: TextStyle(fontWeight: FontWeight.bold), )), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'rec_approval', - autofocus: false, - items: state.signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - const Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'rec_date', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, + const SizedBox( + height: 15, + ), - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - const Text('Date'), - ], + Column( + children: [ + SearchField( + itemHeight: 70, + suggestions: state.signatories + .map((Signatories signatories) => + SearchFieldListItem( + '${signatories.firstname} ${signatories.lastname}', + item: signatories, + child: ListTile( + title: Text( + '${signatories.firstname} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: TextAlign.center, + ), + ))) + .toList(), + + validator: FormBuilderValidators.required( + errorText: "This field is required"), + + // searchInputDecoration: + // normalTextFieldStyle("Appraised by", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down)), + ////agency suggestion tap + focusNode: recByFocus, + suggestionState: Suggestion.expand, + onSuggestionTap: (unit) { + setState(() {}); + recByFocus.unfocus(); + }, + ), + Text( + 'Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14), + ) + ], + ), + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDateTimePicker( + name: 'rec_date', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + format: DateFormat('MMMM dd, yyyy'), + textAlign: TextAlign.center, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text( + 'Date', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14), ), ], ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // children: [ + // Column( + // children: [ + // SizedBox( + // width: 200, + // child: FormBuilderDropdown( + // name: 'rec_approval', + // autofocus: false, + // items: state.signatories + // .map((signatories) => + // DropdownMenuItem( + // value: signatories, + // child: Text( + // '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + // )) + // .toList()), + // ), + // const Text('Name'), + // ], + // ), + // const SizedBox( + // width: 15, + // ), + + // ], + // ), const SizedBox( height: 30, ), @@ -265,30 +415,51 @@ class _PropertyAssessmentOfflinePage fontWeight: FontWeight.bold, ), )), - Row( - mainAxisAlignment: MainAxisAlignment.center, + Column( children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'apprvd_by', - autofocus: false, - items: state.signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - const Text('Name'), - ], + Center( + child: SearchField( + itemHeight: 70, + suggestions: state.signatories + .map( + (Signatories signatories) => + SearchFieldListItem( + '${signatories.firstname} ${signatories.lastname}', + item: signatories, + child: ListTile( + title: Padding( + padding: + const EdgeInsets.all(8.0), + child: Text( + '${signatories.firstname} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: TextAlign.center, + ), + ), + ), + ), + ) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + focusNode: apprvdByFocus, + suggestionState: Suggestion.expand, + onSuggestionTap: (unit) { + setState(() {}); + apprvdByFocus.unfocus(); + }, + ), + ), + Text( + 'Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14), ), ], ), + const SizedBox( height: 50, ), @@ -305,9 +476,10 @@ class _PropertyAssessmentOfflinePage ), SizedBox( width: 500, - height: 100, + height: 50, child: SearchField( - itemHeight: 70, + itemHeight: 200, + controller: memorandaController, suggestions: memoranda .map((Memoranda memoranda) => SearchFieldListItem( @@ -317,7 +489,7 @@ class _PropertyAssessmentOfflinePage child: ListTile( title: Text( '${memoranda.memoranda}', - overflow: TextOverflow.ellipsis, + overflow: TextOverflow.visible, ), ), )) @@ -325,21 +497,192 @@ class _PropertyAssessmentOfflinePage validator: FormBuilderValidators.required( errorText: "This field is required"), // searchInputDecoration: - // normalTextFieldStyle( - // "Memoranda", "") + // normalTextFieldStyle("Memoranda", "") // .copyWith( - // suffixIcon: const Icon( - // Icons.arrow_drop_down), + // suffixIcon: + // const Icon(Icons.arrow_drop_down), + // contentPadding: EdgeInsets.symmetric( + // vertical: 15.0, horizontal: 16.0), + // border: OutlineInputBorder( + // borderRadius: BorderRadius.circular(10.0), + // borderSide: BorderSide( + // color: + // Colors.grey, // Adjust border color + // ), + // ), + // focusedBorder: OutlineInputBorder( + // borderRadius: BorderRadius.circular(10.0), + // borderSide: BorderSide( + // color: Colors + // .blue, // Adjust focused border color + // ), + // ), // ), - // focusNode: focus, + focusNode: focuss, suggestionState: Suggestion.expand, + suggestionDirection: SuggestionDirection.up, onSuggestionTap: (memoranda) { setState(() { - _memoranda = memoranda.item!.memoranda!; + _memoranda = memorandaController.text; }); focus.unfocus(); }, )), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(10), + child: Column( + children: [ + TextField( + controller: memorandaController, + keyboardType: TextInputType.multiline, + maxLines: 7, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + width: 1, + color: Colors.redAccent)), + disabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + width: 1, + color: Colors.grey, + ), + borderRadius: BorderRadius.circular(5), + ), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.grey, + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + ), + ), + ], + ), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'NOTE: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + const SizedBox( + height: 30, + ), + SizedBox( + width: 400, + height: 50, + child: SearchField( + itemHeight: 200, + controller: noteController, + suggestions: note + .map((Memoranda note) => + SearchFieldListItem( + '${note.memoranda}', + item: + note, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${note.memoranda}', + overflow: TextOverflow.visible, + ), + ), + )) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + searchInputDecoration: + InputDecoration().copyWith( + suffixIcon: + const Icon(Icons.arrow_drop_down), + ), + focusNode: focus, + suggestionState: Suggestion.expand, + suggestionDirection: SuggestionDirection.up, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = memorandaController.text; + }); + focus.unfocus(); + }, + )), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(10), + child: Column( + children: [ + TextField( + controller: noteController, + keyboardType: TextInputType.multiline, + maxLines: 7, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + width: 1, + color: Colors.redAccent)), + disabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + width: 1, + color: Colors.grey, + ), + borderRadius: BorderRadius.circular(5), + ), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.grey, + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + ), + ), + ], + ), + ), + const SizedBox( + height: 30, + ), + // Container( + // alignment: Alignment.center, + // padding: EdgeInsets.all(10), + // child: Column( + // children: [ + // TextField( + // enabled: false, + // keyboardType: TextInputType.multiline, + // maxLines: 5, + // decoration: InputDecoration( + // hintText: "Note", + // focusedBorder: OutlineInputBorder( + // borderSide: BorderSide( + // width: 1, + // color: Colors.redAccent)), + // disabledBorder: OutlineInputBorder( + // borderSide: const BorderSide( + // width: 1, + // color: Colors.grey, + // ), + // borderRadius: BorderRadius.circular(5), + // ), + // enabledBorder: OutlineInputBorder( + // borderSide: const BorderSide( + // color: Colors.grey, + // width: 1, + // ), + // borderRadius: BorderRadius.circular(5), + // ), + // ), + // ), + // ], + // ), + // ), + const SizedBox( height: 30, ), @@ -432,120 +775,116 @@ class _PropertyAssessmentOfflinePage ), ElevatedButton( onPressed: () async { - // final tempID = - // await SharedPreferences.getInstance(); - // print(tempID.getInt('tempid')! - 1); + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')! - 1); // final List // propertyAssessments = []; + DateTime? appDate = offlineBldgKey + .currentState!.value['app_date']; + String appDateString = + appDate != null ? appDate.toString() : ''; + context + .read() + .add(AddBldgAssessment( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')!, + assessedById: + widget.offlineProfile.id.toString(), + assessedByName: + widget.offlineProfile.firstName!, + dateCreated: '', + dateModified: '', + actualUse: offlineBldgKey.currentState! + .value['actual_use'] ?? + '', // Replace null with an empty string + marketValue: '0.00', + assessmentLevel: '0.00', + assessedValue: '0.00', + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: int.parse(offlineBldgKey + .currentState!.value['qtr'] ?? + '0'), // Replace null with '0' + yr: int.parse(offlineBldgKey + .currentState!.value['yr'] ?? + '0'), // Replace null with '0' + appraisedbyName: (offlineBldgKey + .currentState! + .value['appraised_by'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['appraised_by'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['appraised_by'] + ?.lastname ?? + ''), + appraisedbyDate: + appDateString, // Replace null with current date + recommendapprName: (offlineBldgKey + .currentState! + .value['rec_approval'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['rec_approval'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['rec_approval'] + ?.lastname ?? + ''), + recommendapprDate: offlineBldgKey + .currentState!.value['rec_date'] + .toString(), // Replace null with current date + approvedbyName: (offlineBldgKey + .currentState! + .value['apprvd_by'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['apprvd_by'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgKey + .currentState! + .value['apprvd_by'] + ?.lastname ?? + ''), + memoranda: _memoranda, + swornstatementNo: offlineBldgKey + .currentState! + .value['sworn_statement'] ?? + '', // Replace null with an empty string + dateReceived: offlineBldgKey + .currentState!.value['date_received'] + .toString(), + // Replace null with current date + entryDateAssessment: offlineBldgKey + .currentState!.value['date_of_entry'] + .toString(), + // Replace null with current date + entryDateBy: offlineBldgKey + .currentState!.value['by'] ?? + '', // Replace null with an empty string + )); - // PropertyAssessment ass = - // PropertyAssessment( - // id: 1, - // bldgapprDetailsId: - // tempID.getInt('tempid')! - 1, - // actualUse: formKey.currentState! - // .value['actual_use'] ?? - // '', // Replace null with an empty string - // marketValue: '0.00', - // assessmentLevel: '0.00', - // assessedValue: '0.00', - // taxable: isTaxable, - // exempt: isExempt, - // qtr: int.parse(formKey - // .currentState!.value['qtr'] ?? - // '0'), // Replace null with '0' - // yr: int.parse( - // formKey.currentState!.value['yr'] ?? - // '0'), // Replace null with '0' - // appraisedbyName: (formKey - // .currentState! - // .value['appraised_by'] - // ?.firstname ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['appraised_by'] - // ?.middlename ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['appraised_by'] - // ?.lastname ?? - // ''), - // appraisedbyDate: formKey.currentState! - // .value['app_date'] - // as DateTime? ?? - // DateTime - // .now(), // Replace null with current date - // recommendapprName: (formKey - // .currentState! - // .value['rec_approval'] - // ?.firstname ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['rec_approval'] - // ?.middlename ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['rec_approval'] - // ?.lastname ?? - // ''), - // recommendapprDate: formKey.currentState! - // .value['rec_date'] - // as DateTime? ?? - // DateTime - // .now(), // Replace null with current date - // approvedbyName: (formKey - // .currentState! - // .value['apprvd_by'] - // ?.firstname ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['apprvd_by'] - // ?.middlename ?? - // '') + - // ' ' + - // (formKey - // .currentState! - // .value['apprvd_by'] - // ?.lastname ?? - // ''), - // memoranda: _memoranda, - // swornstatementNo: formKey.currentState! - // .value['sworn_statement'] ?? - // '', // Replace null with an empty string - // dateReceived: formKey.currentState! - // .value['date_received'] - // as DateTime? ?? - // DateTime - // .now(), // Replace null with current date - // entryDateAssessment: formKey - // .currentState! - // .value['date_of_entry'] - // as DateTime? ?? - // DateTime - // .now(), // Replace null with current date - // entryDateBy: formKey - // .currentState!.value['by'] ?? - // '', // Replace null with an empty string - // ); - - // propertyAssessments.add(ass); - - // context - // .read() - // .add(UpdatePropertyAssessment( - // assessment: - // propertyAssessments[0])); - // widget.function(); + widget.function(); }, style: ElevatedButton.styleFrom( backgroundColor: primary, @@ -582,3 +921,26 @@ class _PropertyAssessmentOfflinePage ); } } + +class MyInputForm extends StatelessWidget //__ +{ + const MyInputForm({super.key}); + + @override + Widget build(context) //__ + { + return Column( + children: [ + TextFormField( + maxLines: 5, + decoration: InputDecoration( + label: const Text('Some text goes here ...'), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + ), + ], + ); + } +} diff --git a/lib/screens/offline/passo/building/add/property_owner_info.dart b/lib/screens/offline/passo/building/add/property_owner_info.dart index fbee3b1..e77324b 100644 --- a/lib/screens/offline/passo/building/add/property_owner_info.dart +++ b/lib/screens/offline/passo/building/add/property_owner_info.dart @@ -1,15 +1,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; - +import 'package:intl/intl.dart'; import '../../../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; class PropertyInfoOfflinePage extends StatefulWidget { final VoidCallback handleButtonPress; - const PropertyInfoOfflinePage(this.handleButtonPress, {super.key}); + final OfflineProfile offlineProfile; + const PropertyInfoOfflinePage(this.handleButtonPress, this.offlineProfile, + {super.key}); @override _PropertyInfoPage createState() => _PropertyInfoPage(); @@ -18,6 +21,12 @@ class PropertyInfoOfflinePage extends StatefulWidget { class _PropertyInfoPage extends State { int tempId = 0; final transaction_codes = ['New', 'Revision']; + final DateTime now; + final String formatter; + + _PropertyInfoPage() + : now = DateTime.now(), + formatter = DateFormat.yMMMMd('en_US').format(DateTime.now()); @override Widget build(BuildContext context) { @@ -130,8 +139,10 @@ class _PropertyInfoPage extends State { adminTin: offlineBldgKey.currentState!.value['benificiary_tin'] ?? '', adminTelno: offlineBldgKey.currentState!.value['benificiary_telno'] ?? '', faasType: "BUILDING", - assessedById: '1', - assessedByName: 'Cyril'), + assessedById: widget.offlineProfile.id.toString(), + assessedByName: widget.offlineProfile.firstName!, + dateCreated: formatter, + dateModified: ''), ); widget.handleButtonPress(); }, diff --git a/lib/screens/offline/passo/building/add/structural_material.dart b/lib/screens/offline/passo/building/add/structural_material.dart index 1dc7bd8..12580cb 100644 --- a/lib/screens/offline/passo/building/add/structural_material.dart +++ b/lib/screens/offline/passo/building/add/structural_material.dart @@ -6,6 +6,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; @@ -18,10 +19,45 @@ class MaterialOption { } class StructuralMaterialsOfflinePage extends StatefulWidget { - final VoidCallback NextBtn; final VoidCallback PrevBtn; + final VoidCallback NextBtn; - StructuralMaterialsOfflinePage(this.NextBtn, this.PrevBtn); + final List foundation; + final List column; + final List beam; + final List trussFraming; + final List roof; + final List flooring; + final List walls; + + final Function(List) updateFoundation; + final Function(List) updateColumn; + final Function(List) updateBeam; + final Function(List) updateTrussFraming; + final Function(List) updateRoof; + final Function(List) updateFlooring; + final Function(List) updateWalls; + + StructuralMaterialsOfflinePage( + this.PrevBtn, + this.NextBtn, { + Key? key, + required this.foundation, + required this.column, + required this.beam, + required this.trussFraming, + required this.roof, + required this.flooring, + required this.walls, + required this.updateFoundation, + required this.updateColumn, + required this.updateBeam, + required this.updateTrussFraming, + required this.updateRoof, + required this.updateFlooring, + required this.updateWalls, + // Repeat for other update methods... + }); @override _StructuralMaterialsOfflinePage createState() => @@ -30,13 +66,13 @@ class StructuralMaterialsOfflinePage extends StatefulWidget { class _StructuralMaterialsOfflinePage extends State { - List foundation = []; - List column = []; - List beam = []; - List truss_framing = []; - List roof = []; - List flooring = []; - List walls = []; + // List foundation = []; + // List column = []; + // List beam = []; + // List trussFraming = []; + // List roof = []; + // List flooring = []; + // List walls = []; bool foundationOthers = false; bool columOthers = false; bool beamsOthers = false; @@ -53,6 +89,8 @@ class _StructuralMaterialsOfflinePage List selectedColumnValues = []; + FocusNode _focusNode = FocusNode(); + @override Widget build(BuildContext context) { return StatefulBuilder(builder: (context, structuralState) { @@ -96,12 +134,10 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - foundation = x; - }); + widget.updateFoundation(x); }, options: const ['Reinforced Concrete', 'Plain Concrete'], - selectedValues: foundation, + selectedValues: widget.foundation, whenEmpty: 'Select Foundations', ), ), @@ -135,12 +171,10 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - column = x; - }); + widget.updateColumn(x); }, options: const ['Steel', 'Reinforced Concrete', 'Wood'], - selectedValues: column, + selectedValues: widget.column, whenEmpty: 'Select Column/s', ), ), @@ -173,12 +207,10 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - beam = x; - }); + widget.updateBeam(x); }, options: const ['Steel', 'Reinforced Concrete', 'Wood'], - selectedValues: beam, + selectedValues: widget.beam, whenEmpty: 'Select Beam/s', ), ), @@ -212,18 +244,16 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - truss_framing = x; - }); + widget.updateTrussFraming(x); }, options: const ['Steel', 'Wood'], - selectedValues: truss_framing, + selectedValues: widget.trussFraming, whenEmpty: 'Select Truss Framing/s', ), ), ), Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'ROOF', textAlign: TextAlign.start, ), @@ -250,9 +280,7 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - roof = x; - }); + widget.updateRoof(x); }, options: const [ 'Reinforced Concrete', @@ -264,7 +292,7 @@ class _StructuralMaterialsOfflinePage 'Concrete Desk', 'Nipa/Anahaw/Cogon' ], - selectedValues: roof, + selectedValues: widget.roof, whenEmpty: 'Select Roof/s', ), ), @@ -298,9 +326,7 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - structuralState(() { - flooring = x; - }); + widget.updateFlooring(x); }, options: const [ 'Reinforced Concrete', @@ -309,7 +335,7 @@ class _StructuralMaterialsOfflinePage 'Wood', 'Tiles' ], - selectedValues: flooring, + selectedValues: widget.flooring, whenEmpty: 'Select Flooring/s', ), ), @@ -343,9 +369,7 @@ class _StructuralMaterialsOfflinePage replacement: DropDownMultiSelect( selected_values_style: TextStyle(color: Colors.black), onChanged: (List x) { - setState(() { - walls = x; - }); + widget.updateWalls(x); }, options: const [ 'Reinforced Concrete', @@ -357,7 +381,7 @@ class _StructuralMaterialsOfflinePage 'Sawali', 'Bamboo' ], - selectedValues: walls, + selectedValues: widget.walls, whenEmpty: 'Select Walls & Partition/s', ), ), @@ -382,41 +406,60 @@ class _StructuralMaterialsOfflinePage { final tempID = await SharedPreferences.getInstance(); - context.read().add( - AddStructuralMaterial( - id: 1, - bldgapprDetailsId: tempID.getInt('tempid')! - 1, - foundation: foundationOthers - ? formKey - .currentState!.value['other_foundation'] - .split(',') - : foundation, - columns: columOthers - ? formKey.currentState!.value['other_column'] - .split(',') - : column, - beams: beamsOthers - ? formKey.currentState!.value['other_beam'] - .split(',') - : beam, - trussFraming: tfOthers - ? formKey.currentState!.value['other_tf'] - .split(',') - : truss_framing, - roof: roofOthers - ? formKey.currentState!.value['other_roof'] - .split(',') - : roof, - flooring: flooringOthers - ? formKey - .currentState!.value['other_flooring'] - .split(',') - : flooring, - walls: wpOthers - ? formKey.currentState!.value['other_wp'] - .split(',') - : walls, - others: ["Others"])); + context + .read() + .add(AddStructuralMaterial( + id: 1, + bldgapprDetailsId: tempID.getInt('tempid')!, + assessedById: '', + assessedByName: '', + dateCreated: '', + dateModified: '', + foundation: foundationOthers + ? [ + offlineBldgKey + .currentState!.value['other_foundation'] + ] + : widget.foundation, + columns: columOthers + ? [ + offlineBldgKey + .currentState!.value['other_column'] + ] + : widget.column, + beams: beamsOthers + ? [ + offlineBldgKey + .currentState!.value['other_beam'] + ] + : widget.beam, + trussFraming: tfOthers + ? [ + offlineBldgKey + .currentState!.value['other_tf'] + ] + : widget.trussFraming, + roof: roofOthers + ? [ + offlineBldgKey + .currentState!.value['other_roof'] + ] + : widget.roof, + flooring: flooringOthers + ? [ + offlineBldgKey + .currentState!.value['other_flooring'] + ] + : widget.flooring, + walls: wpOthers + ? [ + offlineBldgKey + .currentState!.value['other_wp'] + ] + : widget.walls, + others: const ["Others"], + )); + widget.NextBtn(); } ; }, diff --git a/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart index cc6ce7f..a3c57bb 100644 --- a/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart +++ b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart @@ -5,6 +5,7 @@ import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; import 'package:searchfield/searchfield.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/model/passo/class_components%20_offline.dart'; import '../../../../../model/passo/additional_items.dart'; import '../../../../../model/passo/class_components.dart'; @@ -13,7 +14,7 @@ import '../../../../../theme-data.dart/form-style.dart'; class AddExtraItemsEditOffline extends StatefulWidget { final List unit; - final List options; + final List options; final int tempId; AddExtraItemsEditOffline(this.unit, this.options, this.tempId); @@ -113,28 +114,30 @@ class _AddExtraItemsEditOffline extends State { items: widget.options .map((e) => DropdownMenuItem( value: e, - child: Text(e.componentName), + child: Text(e.componentName!), )) .toList(), onChanged: (value) { if (value!.minBaseUnitvalPercent != '0.00') { setState(() { - _unitValue = - double.parse(value.minBaseUnitvalPercent); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + _unitValue = double.parse( + value.minBaseUnitvalPercent!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minBaseUnitvalPercent}); } if (value.maxBaseUnitvalPercent != '0.00') { setState(() { - _unitValue = - double.parse(value.maxBaseUnitvalPercent); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + _unitValue = double.parse( + value.maxBaseUnitvalPercent!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.maxBaseUnitvalPercent}); @@ -142,10 +145,11 @@ class _AddExtraItemsEditOffline extends State { if (value.minUnitvalSqrmtr != '0.00') { setState(() { _unitValue = - double.parse(value.minUnitvalSqrmtr); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minUnitvalSqrmtr!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minUnitvalSqrmtr}); @@ -153,10 +157,11 @@ class _AddExtraItemsEditOffline extends State { if (value.maxUnitvalSqrmtr != '0.00') { setState(() { _unitValue = - double.parse(value.maxUnitvalSqrmtr); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxUnitvalSqrmtr!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.maxUnitvalSqrmtr}); @@ -164,10 +169,11 @@ class _AddExtraItemsEditOffline extends State { if (value.minAddBaseunitval != '0.00') { setState(() { _unitValue = - double.parse(value.minAddBaseunitval); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minAddBaseunitval!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minAddBaseunitval}); @@ -175,10 +181,11 @@ class _AddExtraItemsEditOffline extends State { if (value.maxAddBaseunitval != '0.00') { setState(() { _unitValue = - double.parse(value.maxAddBaseunitval); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxAddBaseunitval!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.maxAddBaseunitval}); @@ -186,10 +193,11 @@ class _AddExtraItemsEditOffline extends State { if (value.minDeductBaserate != '0.00') { setState(() { _unitValue = - double.parse(value.minDeductBaserate); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minDeductBaserate!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minDeductBaserate}); @@ -197,10 +205,11 @@ class _AddExtraItemsEditOffline extends State { if (value.maxDeductBaserate != '0.00') { setState(() { _unitValue = - double.parse(value.maxDeductBaserate); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxDeductBaserate!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.maxDeductBaserate}); @@ -523,28 +532,33 @@ class _AddExtraItemsEditOffline extends State { id: 1, bldgapprDetailsId: widget.tempId, classId: _classId, + assessedById: '', + assessedByName: '', + dateCreated: '', + dateModified: '', className: _className, structType: _structureType, unitValue: _withoutBUCC == true ? 0 : _unitValue, - baseUnitValue: _unitBase, + baseUnitValue: _unitBase.toString(), area: _areaValue, marketValue: (_unitValue * _unitBase) * _areaValue, depreciationRate: _depValue, adjustedMarketVal: _totalMarketValue( - _unitValue, - _unitBase, - _areaValue, - _depValue, - _withoutBUCC, - _className, - isPainted, - isSecondHand, - _notPaintedUnitVal, - _secondHandUnitVal), + _unitValue, + _unitBase, + _areaValue, + _depValue, + _withoutBUCC, + _className, + isPainted, + isSecondHand, + _notPaintedUnitVal, + _secondHandUnitVal) + .toString(), actualUse: 'Test', amtDepreciation: _amountofDepreciation( diff --git a/lib/screens/offline/passo/building/edit/additional_items_edit.dart b/lib/screens/offline/passo/building/edit/additional_items_edit.dart index 9a8daa5..950ea89 100644 --- a/lib/screens/offline/passo/building/edit/additional_items_edit.dart +++ b/lib/screens/offline/passo/building/edit/additional_items_edit.dart @@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; import 'package:unit2/model/passo/class_components%20_offline.dart'; +import 'package:unit2/screens/offline/passo/building/edit/AddExtraItemsEdit.dart'; import '../../../../../bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import '../../../../../model/passo/additional_items.dart'; @@ -127,11 +129,18 @@ class _AdditionalItemEditPageOffline return DataRow( cells: [ DataCell(Text(dataRow.className)), - DataCell(Text(dataRow.baseUnitValue)), - DataCell(Text(dataRow.unitValue)), - DataCell(Text(((double.parse( - dataRow.adjustedMarketVal))) - .toString())), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow.baseUnitValue)))), + DataCell( + Text(dataRow.unitValue.toString())), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow.adjustedMarketVal)))), DataCell(Row( children: [ InkWell( @@ -149,7 +158,13 @@ class _AdditionalItemEditPageOffline ), ), onTap: () { - deleteItem(dataRow.id); + confirmAlertWithCancel( + context, + () => + deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); }, ), SizedBox( @@ -265,7 +280,7 @@ class _AdditionalItemEditPageOffline crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: AddExtraItemsEdit( + child: AddExtraItemsEditOffline( widget.unit, widget.options, widget.tempId)) ], ), diff --git a/lib/screens/offline/passo/building/edit/edit_building.dart b/lib/screens/offline/passo/building/edit/edit_building.dart index e4747f6..541832a 100644 --- a/lib/screens/offline/passo/building/edit/edit_building.dart +++ b/lib/screens/offline/passo/building/edit/edit_building.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:im_stepper/stepper.dart'; @@ -8,12 +9,16 @@ import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_co import 'package:unit2/screens/offline/passo/building/edit/additional_items_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/general_description_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/landref_location_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_appraisal_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_assessment_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/structural_materials_edit.dart'; import '../../../../../model/passo/property_info.dart'; import '../../../../../theme-data.dart/colors.dart'; +GlobalKey offlineBldgEditKey = GlobalKey(); + class EditBuildingOffline extends StatefulWidget { final int index; final PropertyInfo faas; @@ -46,6 +51,10 @@ class _EditBuildingOffline extends State { }); } + void onSAveAll() { + return Navigator.of(context).pop(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -128,20 +137,22 @@ class _EditBuildingOffline extends State { return BldgLocLandRefEditOffline(widget.faas.id!, NextBtn, PrevBtn); case 2: - return GeneralDescriptionEditOffline(NextBtn, PrevBtn); + return GeneralDescriptionEditOffline(widget.faas.id!, NextBtn, PrevBtn); case 3: - return StructuralMaterialsPageEditOffline(NextBtn, PrevBtn); + return StructuralMaterialsPageEditOffline( + widget.faas.id!, NextBtn, PrevBtn); case 4: return AdditionalItemEditPageOffline( unit, classes, widget.faas.id!, NextBtn, PrevBtn); - // case 5: - // return PropertyAppraisalEditPage(widget.faas.id!, NextBtn, PrevBtn); + case 5: + return PropertyAppraisalEditPageOffline( + widget.faas.id!, NextBtn, PrevBtn); - // case 6: - // return PropertyAssessmentEditPage(widget.faas.id!); + case 6: + return PropertyAssessmentEditOfflinePage(widget.faas.id!, onSAveAll); default: return Container(); diff --git a/lib/screens/offline/passo/building/edit/general_description_edit.dart b/lib/screens/offline/passo/building/edit/general_description_edit.dart index 7ecab77..11d4e1b 100644 --- a/lib/screens/offline/passo/building/edit/general_description_edit.dart +++ b/lib/screens/offline/passo/building/edit/general_description_edit.dart @@ -5,6 +5,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; import '../../../../../model/passo/general_description.dart'; @@ -14,10 +15,11 @@ import '../../../../../widgets/passo/custom_button.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; class GeneralDescriptionEditOffline extends StatefulWidget { + final int tempId; final VoidCallback NextBtn; final VoidCallback PrevBtn; - GeneralDescriptionEditOffline(this.NextBtn, this.PrevBtn); + GeneralDescriptionEditOffline(this.tempId, this.NextBtn, this.PrevBtn); @override _GeneralDescriptionEditOffline createState() => _GeneralDescriptionEditOffline(); @@ -300,9 +302,10 @@ class _GeneralDescriptionEditOffline offlineBldgEditKey.currentState! .save(); - context.read().add(AddGendesc( + var gendescData = GeneralDesc( id: 1, - bldgapprDetailsId: 1, + bldgapprDetailsId: + widget.tempId, assessedById: "1", assessedByName: 'hhs', bldgKind: offlineBldgEditKey @@ -315,23 +318,22 @@ class _GeneralDescriptionEditOffline ?.value['bldg_type'] ?.bldgType ?? gendesc.strucType, - bldgPermit: offlineBldgEditKey - .currentState - ?.value['bldg_permit'], - dateIssued: offlineBldgEditKey - .currentState - ?.value['coc_issued'], - cct: offlineBldgEditKey - .currentState - ?.value['cct'], - certCompletionIssued: offlineBldgEditKey - .currentState - ?.value['coc_issued'], - certOccupancyIssued: offlineBldgEditKey - .currentState - ?.value['coo_issued'], - dateCompleted: offlineBldgEditKey.currentState?.value['date_cnstructed'], - dateOccupied: offlineBldgEditKey.currentState?.value['date_occupied'], + bldgPermit: offlineBldgEditKey.currentState?.value['bldg_permit'] ?? + gendesc.bldgPermit, + dateIssued: offlineBldgEditKey.currentState?.value['date_issued'] != null + ? offlineBldgEditKey.currentState!.value['date_issued'] + .toString() + : gendesc.dateIssued, + cct: offlineBldgEditKey.currentState!.value['cct'] ?? + gendesc.cct, + certCompletionIssued: + offlineBldgEditKey + .currentState! + .value['coc_issued'] + .toString(), + certOccupancyIssued: offlineBldgEditKey.currentState!.value['coo_issued'].toString(), + dateCompleted: offlineBldgEditKey.currentState!.value['date_cnstructed'].toString(), + dateOccupied: offlineBldgEditKey.currentState!.value['date_occupied'].toString(), bldgAge: offlineBldgEditKey.currentState?.value['bldg_age']!, noStoreys: offlineBldgEditKey.currentState?.value['no_of_storeys']!, area1Stfloor: offlineBldgEditKey.currentState?.value['area_of_1stFl'], @@ -339,8 +341,18 @@ class _GeneralDescriptionEditOffline area3Rdfloor: offlineBldgEditKey.currentState?.value['area_of_3rdFl'], area4Thfloor: offlineBldgEditKey.currentState?.value['area_of_4thFl'], totalFloorArea: offlineBldgEditKey.currentState?.value['total_area'], - floorSketch: null, - actualUse: offlineBldgEditKey.currentState?.value['actual_use'])); + floorSketch: 'null', + actualUse: offlineBldgEditKey.currentState?.value['actual_use'], + unitValue: offlineBldgEditKey.currentState?.value['bldg_type']?.unitValue ?? gendesc.unitValue); + + context + .read< + GeneralDescriptionBloc>() + .add( + UpdateGeneralDescription( + id: widget.tempId, + gendesc: + gendescData)); widget.NextBtn(); } diff --git a/lib/screens/offline/passo/building/edit/landref_location_edit.dart b/lib/screens/offline/passo/building/edit/landref_location_edit.dart index 7b096ab..295368c 100644 --- a/lib/screens/offline/passo/building/edit/landref_location_edit.dart +++ b/lib/screens/offline/passo/building/edit/landref_location_edit.dart @@ -7,12 +7,14 @@ import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_a import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; import 'package:unit2/theme-data.dart/form-style.dart'; import '../../../../../model/passo/barangay.dart'; import '../../../../../model/passo/bldg_loc.dart'; import '../../../../../model/passo/city.dart'; +import '../../../../../model/passo/land_ref.dart'; import '../../../../../widgets/passo/custom_button.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; @@ -137,12 +139,12 @@ class _BldgLocLandRefEditOffline extends State { left: 0, top: 20, right: 0, - bottom: 10), + bottom: 20), child: const Text('BUILDING LOCATION', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), + textAlign: TextAlign.center), ), Row( mainAxisAlignment: @@ -245,12 +247,12 @@ class _BldgLocLandRefEditOffline extends State { left: 0, top: 20, right: 0, - bottom: 10), + bottom: 20), child: const Text('LAND REFERENCE', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), + textAlign: TextAlign.center), ), customTextField( "Land Owner", "", 'l_owner'), @@ -332,43 +334,78 @@ class _BldgLocLandRefEditOffline extends State { color: Colors.white), onPressed: () { { - // var bldgLocData = BldgLoc( - // id: widget.tempId, - // street: offlineBldgEditKey.currentState - // ?.value['street'], - // barangay: offlineBldgEditKey.currentState - // ?.value['brgy'], - // municipality: offlineBldgEditKey - // .currentState - // ?.value[ - // 'municipality'] - // ?.cityDescription ?? - // bldgloc.municipality, - // province: offlineBldgEditKey.currentState - // ?.value['province'], - // ); - // var landRefData = LandRef( - // id: widget.tempId, - // owner: offlineBldgEditKey.currentState - // ?.value['l_owner'], - // cloaNo: offlineBldgEditKey.currentState - // ?.value['oct_tct_cloa'], - // lotNo: offlineBldgEditKey.currentState - // ?.value['lot_no'], - // tdn: offlineBldgEditKey.currentState - // ?.value['l_td_arp'], - // area: offlineBldgEditKey.currentState - // ?.value['area'], - // surveyNo: offlineBldgEditKey.currentState - // ?.value['survey_no'], - // blkNo: offlineBldgEditKey.currentState - // ?.value['blk_no'], - // ); - // context.read() - // ..add(UpdateBldgLoc( - // bldg_loc: bldgLocData)) - // ..add(UpdateLandRef( - // land_ref: landRefData)); + var bldgLocData = BldgLoc( + id: widget.tempId, + bldgapprDetailsId: + widget.tempId, + assessedById: '1', + assessedByName: 'cyril', + street: offlineBldgEditKey + .currentState + ?.value['street'] ?? + bldgloc.street, + barangay: offlineBldgEditKey + .currentState + ?.value['brgy'] ?? + bldgloc.barangay, + municipality: offlineBldgEditKey + .currentState + ?.value[ + 'municipality'] + ?.cityDescription ?? + bldgloc.municipality, + province: offlineBldgEditKey + .currentState + ?.value['province'] ?? + bldgloc.province, + ); + var landRefData = LandRef( + id: widget.tempId, + bldgapprDetailsId: + widget.tempId, + assessedById: '1', + assessedByName: 'cyril', + owner: offlineBldgEditKey + .currentState + ?.value['l_owner'] ?? + landRef.owner, + cloaNo: offlineBldgEditKey + .currentState + ?.value[ + 'oct_tct_cloa'] ?? + landRef.cloaNo, + lotNo: offlineBldgEditKey + .currentState + ?.value['lot_no'] ?? + landRef.lotNo, + tdn: offlineBldgEditKey + .currentState + ?.value['l_td_arp'] ?? + landRef.tdn, + area: offlineBldgEditKey + .currentState + ?.value['area'] ?? + landRef.area, + surveyNo: offlineBldgEditKey + .currentState + ?.value[ + 'survey_no'] ?? + landRef.surveyNo, + blkNo: offlineBldgEditKey + .currentState + ?.value['blk_no'] ?? + landRef.blkNo, + ); + context + .read() + .add(UpdateBldgLoc( + id: widget.tempId, + bldgLoc: bldgLocData)); + context + .read() + .add(UpdateBldgLandRef( + id: widget.tempId, + landRef: landRefData)); widget.NextBtn(); } diff --git a/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart b/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart new file mode 100644 index 0000000..b914d56 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart @@ -0,0 +1,1269 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class PropertyAppraisalEditPageOffline extends StatefulWidget { + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + PropertyAppraisalEditPageOffline(this.tempId, this.NextBtn, this.PrevBtn); + + @override + _PropertyAppraisalEditPage createState() => _PropertyAppraisalEditPage(); +} + +class _PropertyAppraisalEditPage + extends State { + double depRate = 0; + // int totalAreas = 0; + // String actualUse = ""; + + // @override + // void initState() { + // super.initState(); + // _loadDataFromSharedPreferences(); // Call the method to load data + // } + + // Method to load data from SharedPreferences + // _loadDataFromSharedPreferences() async { + // SharedPreferences prefs = await SharedPreferences.getInstance(); + // setState(() { + // actualUse = prefs.getString('actualUse') ?? ''; + // totalAreas = prefs.getInt('totalArea') ?? + // 0; // Provide a default value if the key doesn't exist + // }); + // } + + calculateAdditionalItems(List items) { + double sum = 0; + double product = 1; + + for (AdditionalItems value in items) { + sum += double.parse(value.adjustedMarketVal); + } + + return sum; + } + + calculateMarketValue(buildingCost, additionalItems, dep) { + double sum = 0; + double depreciation = 0; + double total = 0; + + sum = buildingCost + calculateAdditionalItems(additionalItems); + + depreciation = sum * dep; + + total = sum - depreciation; + + return total; + } + + calculateDepCost(buildingCost, additionalItems, dep) { + double sum = 0; + double depreciation = 0; + double total = 0; + + sum = buildingCost + calculateAdditionalItems(additionalItems); + + depreciation = sum * dep; + + total = sum - depreciation; + + return depreciation; + } + + calculateConstructionCost(constructioncost, addtionalCost) { + double sum = 0; + sum = constructioncost + addtionalCost; + + return sum; + } + + String assessmentLevel(marketValues, property_class) { + final marketValue = double.parse(marketValues); + switch (property_class) { + case 'Residential': + if (marketValue < 175000) { + // setState(() { + // assessment_level = 0; + // }); + return '0 '; + } else if (marketValue < 300000 && marketValue > 175000) { + // setState(() { + // assessment_level = 0.10; + // }); + return '10 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.20; + // }); + return '20 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.25; + // }); + return '25 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } + break; + case 'Agricultural': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return '45 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 750000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.55; + // }); + return '55 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return '65 '; + } else if (marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } + break; + case 'Commercial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return '75 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + } + break; + case 'Industrial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return '75 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + return '80 '; + } + break; + case 'Mineral': + break; + case 'Timberland': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return '45 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.55; + // }); + return '55 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return '65 '; + } else if (marketValue < 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } + break; + default: + } + return ''; + } + + double assessmentValue(marketValues, property_class) { + final marketValue = double.parse(marketValues); + switch (property_class) { + case 'Residential': + if (marketValue < 175000) { + // setState(() { + // assessment_level = 0; + // }); + return marketValue * 0; + } else if (marketValue < 300000 && marketValue > 175000) { + // setState(() { + // assessment_level = 0.10; + // }); + return marketValue * 0.10; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.20; + // }); + return marketValue * 0.20; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.25; + // }); + return marketValue * 0.25; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } + break; + case 'Agricultural': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return marketValue * 0.45; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 750000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.55; + // }); + return marketValue * 0.55; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return marketValue * 0.65; + } else if (marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } + break; + case 'Commercial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return marketValue * 0.75; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + } + break; + case 'Industrial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return marketValue * 0.75; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + return marketValue * 0.80; + } + break; + case 'Mineral': + break; + case 'Timberland': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return marketValue * 0.45; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.55; + // }); + return marketValue * 0.55; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return marketValue * 0.65; + } else if (marketValue < 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } + break; + default: + } + return 0; + } + + @override + Widget build(BuildContext context) { + return ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // if (state is PropertyAppraisalEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is PropertyAppraisalEditErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificBldgAppraisalLoaded) { + final appraisal = state.appraisal; + return BlocConsumer(listener: (context, state) { + // if (state is PropertyAppraisalEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is AdditionalItemsEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is AdditionalItemsEditErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + if (state is AdditionalItemsLoaded) { + final item = state.addItem; + + return BlocConsumer( + listener: (context, state) { + // if (state is GenDescLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is GenDescLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is GenDescErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificGeneralDescriptionLoaded) { + double totalArea = double.tryParse( + (state.gendesc.totalFloorArea ?? + appraisal.totalArea) + ?.toString() ?? + '0.0') ?? + 0.0; + + double bldgUnitValue = double.tryParse( + state.gendesc.unitValue ?? + appraisal.unitconstructCost!) ?? + 0.0; + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + margin: const EdgeInsets.only( + left: 20.0, right: 20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Unit Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + bldgUnitValue.toString() + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Building Core", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: const Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format((double.parse(state + .gendesc + .totalFloorArea!) * + double.parse(state + .gendesc.unitValue!))) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: const Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse(appraisal + .addItemsSubtotal!)) ?? + '0.00', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(calculateConstructionCost( + double.parse(appraisal + .unitconstructSubtotal!), + double.parse(appraisal + .addItemsSubtotal!))) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Rate", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: 90, + height: 25, + child: FormBuilderTextField( + name: 'depRate', + decoration: normalTextFieldStyle( + "0.00", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + setState(() { + depRate = double.parse(value!); + }); + }, + ), + ), + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (totalArea * bldgUnitValue), + item, + double.parse(offlineBldgEditKey + .currentState + ?.value[ + 'depRate'] ?? + appraisal + .depreciationRate)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total % Depreciation", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '${(double.parse(offlineBldgEditKey.currentState?.value['depRate'] ?? appraisal.depreciationRate) * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(calculateMarketValue( + (totalArea * bldgUnitValue), + item, + double.parse(offlineBldgEditKey + .currentState + ?.value[ + 'depRate'] ?? + appraisal + .depreciationRate))) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + margin: + const EdgeInsets.symmetric( + horizontal: 20.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + margin: const EdgeInsets + .fromLTRB(0, 20, 0, 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 18, + ), + textAlign: TextAlign.left, + ), + ), + Column( + children: [ + Row( + children: [ + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Actual Use', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Market Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Level', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + ], + ), + SizedBox( + height: 50, + child: + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row(children: [ + Container( + height: 100, + child: Row( + children: [ + Container( + width: 100, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets + .all( + 5.0), + child: Text( + state.gendesc + .actualUse ?? + "", + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets + .all( + 5.0), + child: Text( + NumberFormat + .currency( + locale: + 'en-PH', + symbol: + "₱", + ).format( + calculateMarketValue( + (totalArea * + bldgUnitValue), + item, + double.parse(offlineBldgEditKey.currentState?.value['depRate'] ?? + appraisal.depreciationRate)), + ), + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 100, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets + .all( + 5.0), + child: Text( + '${assessmentLevel(calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(offlineBldgEditKey.currentState?.value['depRate'] ?? appraisal.depreciationRate)).toString(), state.gendesc.actualUse)}%', + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets + .all( + 5.0), + child: Text( + NumberFormat + .currency( + locale: + 'en-PH', + symbol: + "₱", + ).format(assessmentValue( + calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(offlineBldgEditKey.currentState?.value['depRate'] ?? appraisal.depreciationRate)) + .toString(), + state + .gendesc + .actualUse)), + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + const SizedBox( + height: 80, + ), + ], + ), + ) + ]), + ), + ) + ], + ) + ], + ), + ), + ), + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon( + Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + + final id = tempID.getInt('tempid')!; + { + var appraisals = PropertyAppraisal( + id: 1, + bldgapprDetailsId: id, + assessedById: '1', + assessedByName: 'cyril', + dateCreated: '000', + actualUse: + state.gendesc.actualUse, + dateModified: '222', + unitconstructCost: + bldgUnitValue.toString(), + buildingCore: 'test', + unitconstructSubtotal: + (totalArea * bldgUnitValue) + .toString(), + depreciationRate: + depRate.toString(), + depreciationCost: + calculateDepCost((totalArea * bldgUnitValue), item, depRate) + .toString(), + costAddItems: calculateAdditionalItems(item) + .toString(), + addItemsSubtotal: + calculateAdditionalItems(item) + .toString(), + totalpercentDepreciation: + (depRate * 100) + .toStringAsFixed(2), + marketValue: calculateMarketValue( + (totalArea * bldgUnitValue), + item, + depRate) + .toString(), + totalArea: totalArea.toString()); + + context + .read< + BldgAppraisalOfflineBloc>() + .add(UpdateAppraisal( + appraisal: appraisals, + id: widget.tempId)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), + ), + ), + ], + ); + } + return Container(); + }, + ); + } + return Container(); + }); + } + // if (state is PropertyAppraisalEditErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(LoadPropertyAppraisalEdit( + // appraisalEdit: PropertyAppraisalEdit(), + // id: widget.tempId, + // )); + // }, + // ); + // } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/edit/property_assessment_edit.dart b/lib/screens/offline/passo/building/edit/property_assessment_edit.dart new file mode 100644 index 0000000..9c58e1f --- /dev/null +++ b/lib/screens/offline/passo/building/edit/property_assessment_edit.dart @@ -0,0 +1,1226 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../../model/passo/memoranda.dart'; +import '../../../../../model/passo/property_assessment.dart'; +import '../../../../../model/passo/property_assessment_edit.dart'; +import '../../../../../model/passo/signatories.dart'; +import '../../../../../theme-data.dart/form-style.dart'; + +class PropertyAssessmentEditOfflinePage extends StatefulWidget { + int tempId; + Function onSAve; + PropertyAssessmentEditOfflinePage(this.tempId, this.onSAve); + @override + _PropertyAssessmentEditOfflinePage createState() => + _PropertyAssessmentEditOfflinePage(); +} + +class _PropertyAssessmentEditOfflinePage + extends State { + double assessment_level = 0; + bool isTaxable = false; + bool isExempt = false; + String _memoranda = ''; + final focus = FocusNode(); + + String assessmentLevel(marketValues, property_class) { + final marketValue = double.parse(marketValues); + switch (property_class) { + case 'Residential': + if (marketValue < 175000) { + // setState(() { + // assessment_level = 0; + // }); + return '0 '; + } else if (marketValue < 300000 && marketValue > 175000) { + // setState(() { + // assessment_level = 0.10; + // }); + return '10 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.20; + // }); + return '20 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.25; + // }); + return '25 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } + break; + case 'Agricultural': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return '45 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 750000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.55; + // }); + return '55 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return '65 '; + } else if (marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } + break; + case 'Commercial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return '75 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + } + break; + case 'Industrial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return '30 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return '35 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return '40 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return '75 '; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + return '80 '; + } + break; + case 'Mineral': + break; + case 'Timberland': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return '45 '; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return '50 '; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.55; + // }); + return '55 '; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return '60 '; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return '65 '; + } else if (marketValue < 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return '70 '; + } + break; + default: + } + return ''; + } + + double assessmentValue(marketValues, property_class) { + final marketValue = double.parse(marketValues); + switch (property_class) { + case 'Residential': + if (marketValue < 175000) { + // setState(() { + // assessment_level = 0; + // }); + return marketValue * 0; + } else if (marketValue < 300000 && marketValue > 175000) { + // setState(() { + // assessment_level = 0.10; + // }); + return marketValue * 0.10; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.20; + // }); + return marketValue * 0.20; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.25; + // }); + return marketValue * 0.25; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } + break; + case 'Agricultural': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return marketValue * 0.45; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 750000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.55; + // }); + return marketValue * 0.55; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return marketValue * 0.65; + } else if (marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } + break; + case 'Commercial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return marketValue * 0.75; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + } + break; + case 'Industrial': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.30; + // }); + return marketValue * 0.30; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.35; + // }); + return marketValue * 0.35; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.40; + // }); + return marketValue * 0.40; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 5000000 && marketValue > 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } else if (marketValue < 10000000 && marketValue > 5000000) { + // setState(() { + // assessment_level = 0.75; + // }); + return marketValue * 0.75; + } else if (marketValue > 10000000) { + // setState(() { + // assessment_level = 0.80; + // }); + return marketValue * 0.80; + } + break; + case 'Mineral': + break; + case 'Timberland': + if (marketValue < 300000) { + // setState(() { + // assessment_level = 0.45; + // }); + return marketValue * 0.45; + } else if (marketValue < 500000 && marketValue > 300000) { + // setState(() { + // assessment_level = 0.50; + // }); + return marketValue * 0.50; + } else if (marketValue < 750000 && marketValue > 500000) { + // setState(() { + // assessment_level = 0.55; + // }); + return marketValue * 0.55; + } else if (marketValue < 1000000 && marketValue > 750000) { + // setState(() { + // assessment_level = 0.60; + // }); + return marketValue * 0.60; + } else if (marketValue < 2000000 && marketValue > 1000000) { + // setState(() { + // assessment_level = 0.65; + // }); + return marketValue * 0.65; + } else if (marketValue < 2000000) { + // setState(() { + // assessment_level = 0.70; + // }); + return marketValue * 0.70; + } + break; + default: + } + return 0; + } + + @override + Widget build(BuildContext context) { + return ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is PropertyAssessmentEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + if (state is SpecificBldgAssessmentLoaded) { + setState(() { + isTaxable = state.assessment.taxable == '1' ? true : false; + isExempt = state.assessment.exempt == '1' ? true : false; + }); + } + // if (state is PropertyAssessmentEditErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificBldgAssessmentLoaded) { + final assessment = state.assessment; + return BlocConsumer( + listener: (context, state) { + // if (state is SignatoriesLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is SignatoriesErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + + return BlocConsumer( + listener: (context, state) { + // if (state is MemorandaLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is MemorandaLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is MemorandaErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return Padding( + padding: const EdgeInsets.all(20.0), + child: FormBuilder( + key: offlineBldgEditKey, + initialValue: { + 'qtr': assessment.qtr?.toString() ?? '', + 'yr': assessment.qtr?.toString() ?? '', + 'app_date': + assessment.appraisedbyDate?.toString() ?? '', + 'rec_date': + assessment.recommendapprDate?.toString() ?? + '', + 'memoranda': assessment.memoranda ?? '', + 'sworn_statement': + assessment.swornstatementNo ?? '', + 'date_received': + assessment.dateReceived?.toString() ?? '', + 'date_of_entry': + assessment.entryDateAssessment?.toString() ?? + '', + 'by': assessment.entryDateBy ?? '', + }, + enabled: true, + onChanged: () { + offlineBldgEditKey.currentState!.save(); + debugPrint(offlineBldgEditKey.currentState!.value + .toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Expanded( + child: Column( + children: [ + Container( + margin: + const EdgeInsets.fromLTRB(0, 20, 0, 20), + child: const Text( + 'PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + ), + textAlign: TextAlign.left, + ), + ), + Expanded( + flex: 3, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: Colors.white, + value: isTaxable, + onChanged: (bool? value) { + setState(() { + isTaxable = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: Colors.white, + value: isExempt, + onChanged: (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], + ), + ], + ), + Column( + children: [ + const SizedBox( + height: 20, + ), + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', + style: TextStyle( + fontWeight: + FontWeight.bold), + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: + FormBuilderTextField( + name: 'qtr', + validator: + FormBuilderValidators + .compose([]), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: + FormBuilderTextField( + name: 'yr', + validator: + FormBuilderValidators + .compose([]), + ), + ), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle( + fontWeight: + FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'appraised_by', + decoration: + InputDecoration( + labelText: assessment + .appraisedbyName ?? + "", + labelStyle: + const TextStyle( + color: Colors + .black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: + signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: + FormBuilderDateTimePicker( + name: 'app_date', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: + DateTime.now(), + inputType: + InputType.date, + + initialTime: + const TimeOfDay( + hour: 8, + minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: TextStyle( + fontWeight: + FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'rec_approval', + decoration: + InputDecoration( + labelText: assessment + .recommendapprName ?? + "", + labelStyle: + const TextStyle( + color: Colors + .black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: + signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: + FormBuilderDateTimePicker( + name: 'rec_date', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: + DateTime.now(), + inputType: + InputType.date, + + initialTime: + const TimeOfDay( + hour: 8, + minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'apprvd_by', + autofocus: false, + decoration: + InputDecoration( + labelText: assessment + .approvedbyName ?? + "", + labelStyle: + const TextStyle( + color: Colors + .black), + ), + items: signatories + .map((signatories) => + DropdownMenuItem( + value: + signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + SizedBox( + height: 30, + ), + SizedBox( + width: 500, + height: 100, + child: SearchField( + itemHeight: 70, + suggestionDirection: + SuggestionDirection.up, + suggestions: state.memo + .map((Memoranda + memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow + .ellipsis, + ), + ), + )) + .toList(), + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + hint: assessment.memoranda, + focusNode: focus, + suggestionState: + Suggestion.expand, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = memoranda + .item!.memoranda!; + }); + focus.unfocus(); + }, + )), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement', + decoration: + InputDecoration(), + validator: + FormBuilderValidators + .compose([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text('Date Received:'), + SizedBox( + width: 150, + height: 20, + child: + FormBuilderDateTimePicker( + name: 'date_received', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: + DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: + FormBuilderDateTimePicker( + name: 'date_of_entry', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: + DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by', + decoration: + InputDecoration(), + validator: + FormBuilderValidators + .compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: + Colors.red), + child: const SizedBox( + width: 200, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: + TextAlign.center, + ), + ), + ), + onPressed: () { + var ass = PropertyAssessment( + id: 1, + bldgapprDetailsId: + widget.tempId, + actualUse: + assessment.actualUse, + marketValue: '0.0', + assessmentLevel: '0.0', + assessedValue: "1.0", + taxable: isTaxable == true + ? '1' + : '0', + exempt: isExempt == true + ? '1' + : '0', + qtr: offlineBldgEditKey + .currentState! + .value['qtr'], + yr: offlineBldgEditKey + .currentState! + .value['yr'], + appraisedbyName: (offlineBldgEditKey + .currentState + ?.value[ + 'appraised_by'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'appraised_by'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'appraised_by'] + ?.lastname ?? + '') ?? + assessment + .appraisedbyName, + appraisedbyDate: + offlineBldgEditKey + .currentState! + .value['app_date'] + .toString(), + recommendapprName: (offlineBldgEditKey + .currentState + ?.value[ + 'rec_approval'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'rec_approval'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'rec_approval'] + ?.lastname ?? + '') ?? + assessment + .recommendapprName, + recommendapprDate: + offlineBldgEditKey + .currentState! + .value['rec_date'] + .toString(), + approvedbyName: (offlineBldgEditKey + .currentState + ?.value[ + 'apprvd_by'] + ?.firstname ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'apprvd_by'] + ?.middlename ?? + '') + + ' ' + + (offlineBldgEditKey + .currentState + ?.value[ + 'apprvd_by'] + ?.lastname ?? + '') ?? + assessment + .approvedbyName, + memoranda: _memoranda, + swornstatementNo: + offlineBldgEditKey + .currentState! + .value[ + 'sworn_statement'], + dateReceived: + offlineBldgEditKey + .currentState! + .value[ + 'date_received'] + .toString(), + entryDateAssessment: + offlineBldgEditKey + .currentState! + .value[ + 'date_of_entry'] + .toString(), + entryDateBy: + offlineBldgEditKey + .currentState! + .value['by'], + ); + + context + .read< + BldgAssessmentOfflineBloc>() + .add(UpdateBldgAssessment( + id: widget.tempId, + assessment: ass)); + + widget.onSAve(); + }, + ), + ), + ], + ), + )) + ], + ), + ), + ), + ); + } + // if (state is MemorandaErrorState) { + // return SomethingWentWrong( + // message: state.error, + // onpressed: () { + // context + // .read() + // .add(const LoadMemoranda()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is SignatoriesErrorState) { + // return SomethingWentWrong( + // message: state.error, + // onpressed: () { + // context + // .read() + // .add(const LoadSignatories()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is PropertyAssessmentEditErrorState) { + // return SomethingWentWrong( + // message: state.error, + // onpressed: () { + // context.read().add( + // LoadPropertyAssessmentEdit( + // assessmentsEdit: PropertyAssessmentEdit(), + // id: widget.tempId)); + // }, + // ); + // } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart index 4c657e2..2d210c2 100644 --- a/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart +++ b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart @@ -1,20 +1,21 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; -GlobalKey offlineBldgEditKey = GlobalKey(); - class PropertyOwnerInfoEditOffline extends StatefulWidget { final int index; final PropertyInfo faas; final String title; - final VoidCallback NextBtn; final VoidCallback PrevBtn; + final VoidCallback NextBtn; const PropertyOwnerInfoEditOffline( - this.index, this.faas, this.title, this.NextBtn, this.PrevBtn); + this.index, this.faas, this.title, this.PrevBtn, this.NextBtn); @override State createState() => @@ -66,7 +67,7 @@ class _PropertyOwnerInfoEditOffline 'benificiary': widget.faas.adminUser, 'benificiary_telno': widget.faas.adminTelno, 'benificiary_address': widget.faas.adminAddress, - 'benificaiary_tin': widget.faas.adminTin, + 'benificiary_tin': widget.faas.adminTin, }, enabled: true, onChanged: () { @@ -89,8 +90,11 @@ class _PropertyOwnerInfoEditOffline textAlign: TextAlign.left), ), const SizedBox(height: 15), - customDropDownField("Transaction Code", "", - "transaction_code", transaction_codes), + customDropDownField( + widget.faas.transCode ?? "Transaction Code", + "", + "transaction_code", + transaction_codes), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -165,36 +169,36 @@ class _PropertyOwnerInfoEditOffline color: Colors.white), onPressed: () { var property_info = PropertyInfo( - id: widget.faas.id, - transCode: offlineBldgEditKey - .currentState!.value['transaction_code'] - .toString(), - tdn: offlineBldgEditKey - .currentState!.value['arp_td'], - pin: offlineBldgEditKey - .currentState!.value['pin'], - owner: offlineBldgEditKey - .currentState!.value['owner'], - address: offlineBldgEditKey - .currentState!.value['address'], - telno: offlineBldgEditKey - .currentState!.value['tel_no'], - tin: offlineBldgEditKey - .currentState!.value['tin'], - adminUser: offlineBldgEditKey - .currentState!.value['benificiary'], - adminAddress: offlineBldgEditKey - .currentState! - .value['benificiary_address'], - adminTin: offlineBldgEditKey - .currentState!.value['benificiary_tin'], - adminTelno: offlineBldgEditKey.currentState! - .value['benificiary_telno'], - ); + id: widget.faas.id, + transCode: offlineBldgEditKey.currentState + ?.value['transaction_code'] + .toString() ?? + widget.faas.transCode, + assessedById: '1', + assessedByName: 'cyril', + tdn: offlineBldgEditKey + .currentState!.value['arp_td'] ?? + widget.faas.tdn, + pin: offlineBldgEditKey.currentState!.value['pin'] ?? + widget.faas.pin, + owner: offlineBldgEditKey + .currentState!.value['owner'] ?? + widget.faas.owner, + address: offlineBldgEditKey + .currentState!.value['address'] ?? + widget.faas.address, + telno: offlineBldgEditKey.currentState!.value['tel_no'] ?? widget.faas.telno, + tin: offlineBldgEditKey.currentState!.value['tin'] ?? widget.faas.tin, + adminUser: offlineBldgEditKey.currentState!.value['benificiary'] ?? widget.faas.adminUser, + adminAddress: offlineBldgEditKey.currentState!.value['benificiary_address'] ?? widget.faas.adminAddress, + adminTin: offlineBldgEditKey.currentState!.value['benificiary_tin'] ?? widget.faas.adminTin, + adminTelno: offlineBldgEditKey.currentState!.value['benificiary_telno'] ?? widget.faas.adminTelno, + faasType: "Building"); - // context.read().add( - // UpdatPropertyInfo( - // property_info: property_info)); + context.read().add( + UpdatePropertyOwnerInfo( + id: widget.faas.id!, + propertyInfo: property_info)); widget.NextBtn(); }, diff --git a/lib/screens/offline/passo/building/edit/structural_materials_edit.dart b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart index e4e0cdb..8578340 100644 --- a/lib/screens/offline/passo/building/edit/structural_materials_edit.dart +++ b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:multiselect/multiselect.dart'; import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import '../../../../../model/passo/structureMaterial.dart'; import '../../../../../widgets/passo/custom_button.dart'; @@ -9,10 +11,11 @@ import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; class StructuralMaterialsPageEditOffline extends StatefulWidget { // final VoidCallback onPutStructuralMaterials; + final int tempId; final VoidCallback NextBtn; final VoidCallback PrevBtn; - StructuralMaterialsPageEditOffline(this.NextBtn, this.PrevBtn); + StructuralMaterialsPageEditOffline(this.tempId, this.NextBtn, this.PrevBtn); @override _StructuralMaterialsPageEditOffline createState() => @@ -399,16 +402,49 @@ class _StructuralMaterialsPageEditOffline icon: const Icon(Icons.chevron_right_rounded, color: Colors.white), onPressed: () { - var strucMaterials = StructureMaterials( - foundation: foundation.toString(), - columns: column.toString(), - beams: beam.toString(), - trussFraming: truss_framing.toString(), - roof: roof.toString(), - flooring: flooring.toString(), - walls: walls.toString(), - others: ["Others"].toString(), - ); + var strucMaterials = StructureMaterialsII( + id: 1, + bldgapprDetailsId: widget.tempId, + foundation: foundationOthers + ? offlineBldgEditKey + .currentState!.value['other_foundation'] + .split(',') + : foundation, + columns: columOthers + ? offlineBldgEditKey + .currentState!.value['other_column'] + .split(',') + : column, + beams: beamsOthers + ? offlineBldgEditKey + .currentState!.value['other_beam'] + .split(',') + : beam, + trussFraming: tfOthers + ? offlineBldgEditKey + .currentState!.value['other_tf'] + .split(',') + : truss_framing, + roof: roofOthers + ? offlineBldgEditKey + .currentState!.value['other_roof'] + .split(',') + : roof, + flooring: flooringOthers + ? offlineBldgEditKey + .currentState!.value['other_flooring'] + .split(',') + : flooring, + walls: wpOthers + ? offlineBldgEditKey + .currentState!.value['other_wp'] + .split(',') + : walls, + others: ["Others"]); + + context.read().add( + UpdateStructuralMaterials( + id: widget.tempId, materials: strucMaterials)); widget.NextBtn(); }, ), diff --git a/lib/screens/offline/passo/building_home_offline.dart b/lib/screens/offline/passo/building_home_offline.dart index 4507902..d0499dd 100644 --- a/lib/screens/offline/passo/building_home_offline.dart +++ b/lib/screens/offline/passo/building_home_offline.dart @@ -12,21 +12,40 @@ import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_co import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_info.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/widgets/empty_data.dart'; +import '../../../bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; +import '../../../bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; +import '../../../utils/alerts.dart'; class BuildingHomeOffline extends StatelessWidget { - const BuildingHomeOffline({super.key}); + final OfflineProfile offlineProfile; + const BuildingHomeOffline(this.offlineProfile, {super.key}); @override Widget build(BuildContext context) { @@ -34,10 +53,15 @@ class BuildingHomeOffline extends StatelessWidget { context.read().add(DeleteTodo(id: itemId)); } - // void triggerBlocEvent() { - // final myBloc = BlocProvider.of(context); - // myBloc.add(LoadPropertyInfo()); - // } + void triggerLoadBldgFaas() { + final myBloc = BlocProvider.of(context); + myBloc.add(FetchTodos()); + } + + void triggerLoadLandFaas() { + final myBloc = BlocProvider.of(context); + myBloc.add(LoadLandPropertyOwner()); + } return Scaffold( body: ProgressHUD( @@ -45,8 +69,8 @@ class BuildingHomeOffline extends StatelessWidget { indicatorWidget: const SpinKitFadingCircle(color: Colors.white), child: BlocBuilder( builder: (context, state) { - if (state is DisplayTodos) { - if (state.todo.isNotEmpty) { + if (state is PropertyInfoLoaded) { + if (state.propertyInfos.isNotEmpty) { return Container( padding: const EdgeInsets.symmetric(horizontal: 12), child: Column( @@ -54,10 +78,14 @@ class BuildingHomeOffline extends StatelessWidget { Expanded( child: ListView.builder( shrinkWrap: true, - itemCount: state.todo.length, + itemCount: state.propertyInfos.length, itemBuilder: (BuildContext context, int index) { - return _listCard(state.todo[index], context, - index, deleteItem, state.todo.length); + return _listCard( + state.propertyInfos[index], + context, + index, + deleteItem, + state.propertyInfos.length); }, ), ), @@ -107,6 +135,8 @@ class BuildingHomeOffline extends StatelessWidget { ..add( const LoadBarangayInMunicipality(cityCode: '01')), ), + BlocProvider( + create: (context) => BuildingAndStructureBloc()), BlocProvider( create: (context) => ClassComponentsAdminBloc() ..add(const LoadClassComponents()), @@ -136,7 +166,7 @@ class BuildingHomeOffline extends StatelessWidget { create: (context) => BldgAppraisalOfflineBloc()), BlocProvider( create: (context) => BldgAssessmentOfflineBloc()), - ], child: AddBuilding(deleteItem)); + ], child: AddBuilding(triggerLoadBldgFaas, offlineProfile)); })); }), SpeedDialChild( @@ -145,7 +175,76 @@ class BuildingHomeOffline extends StatelessWidget { color: primary, ), label: 'Land/Other Improvements', - onTap: () {}, + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider(providers: [ + BlocProvider( + create: (context) => LandPropertyOwnerBloc(), + ), + BlocProvider( + create: (context) => LandPropertyAppraisalBloc() + ..add(const LoadLandPropertyAppraisal()), + ), + BlocProvider( + create: (context) => LandClassificationBloc() + ..add(const LoadLandClassification()), + ), + BlocProvider( + create: (context) => LandSubclassificationBloc() + ..add(const LoadLandSubClassification()), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => OtherImprovementsBloc() + ..add(const LoadOtherImprovements()), + ), + BlocProvider( + create: (context) => TreesImprovementsBloc() + ..add(const LoadTreesImprovements()), + ), + BlocProvider( + create: (context) => ValueAdjustmentBloc() + ..add(const LoadValueAdjustment()), + ), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(const LoadTypeOfRoad()), + ), + BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(const LoadTypeOfLocation()), + ), + BlocProvider( + create: (context) => LandPropertyAssessmentBloc() + ..add(const LoadLandPropertyAssessment()), + ), + BlocProvider( + create: (context) => LandPropertySignatureBloc()), + BlocProvider( + create: (context) => + SignatoriesAdminBloc()..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider( + create: (context) => LandPropertyLocationBloc(), + ), + BlocProvider( + create: (context) => LandPropertyBoundariesBloc(), + ), + BlocProvider( + create: (context) => TreesImprovementsBloc() + ..add(const LoadTreesImprovements()), + ), + ], child: AddLandOffline(triggerLoadBldgFaas)); + })); + }, ), SpeedDialChild( child: const Icon( @@ -155,17 +254,14 @@ class BuildingHomeOffline extends StatelessWidget { label: 'Machinery', onTap: () {}, ), - // SpeedDialChild( - // child: const Icon( - // Icons.report_problem_rounded, - // color: primary, - // ), - // label: 'Testing Screen', - // onTap: () { - // Navigator.of(context) - // .push(MaterialPageRoute(builder: (ctx) => Multi_Select())); - // }, - // ), + SpeedDialChild( + child: const Icon( + Icons.upload, + color: primary, + ), + label: 'Upload/Sync', + onTap: () {}, + ), ]), ); } @@ -216,6 +312,10 @@ Card _listCard( create: (context) => MemorandaAdminBloc()..add(const LoadMemoranda()), ), + BlocProvider( + create: (context) => BldgAppraisalOfflineBloc() + ..add(FetchSingleBldgAppraisal(id: property_info.id!)), + ), BlocProvider( create: (context) => LandrefLocationBloc() ..add(FetchSingleLandref(id: property_info.id!))), @@ -230,6 +330,9 @@ Card _listCard( create: (context) => StructuralMaterialOfflineBloc() ..add(FetchSingleStructuralMaterial( id: property_info.id!))), + BlocProvider( + create: (context) => BldgAssessmentOfflineBloc() + ..add(FetchSingleBldgAssessment(id: property_info.id!))), BlocProvider( create: (context) => AdditionalItemsOfflineBloc() ..add(LoadAdditionalItemsEdit( @@ -254,7 +357,7 @@ Card _listCard( shape: BoxShape.circle, border: Border.all( color: primary, // Border color - width: 2, // Border width + width: 1, // Border width ), ), child: const Icon( @@ -279,7 +382,7 @@ Card _listCard( ), SizedBox(height: 5), Text( - '${property_info.tdn} - ${property_info.id}', + '${property_info.tdn}', style: TextStyle( fontSize: 13, ), @@ -290,7 +393,12 @@ Card _listCard( ), IconButton( onPressed: () { - deleteItem(property_info.id); + confirmAlertWithCancel( + context, + () => deleteItem(property_info.id), + () => null, + 'Delete FAAS Item?', + "Are you sure you want to delete this item?"); }, icon: const Icon(Icons.delete_rounded), color: primary, diff --git a/lib/screens/offline/passo/land/add/AddLandAppraisal.dart b/lib/screens/offline/passo/land/add/AddLandAppraisal.dart new file mode 100644 index 0000000..8a8de1a --- /dev/null +++ b/lib/screens/offline/passo/land/add/AddLandAppraisal.dart @@ -0,0 +1,459 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; +import 'package:unit2/widgets/error_state.dart'; + +import '../../../../../model/passo/city.dart'; +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../model/passo/land_classification.dart'; +import '../../../../../model/passo/land_subclassification.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; + +class AddLandAppraisalOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddLandAppraisalOfflineModal createState() => + _AddLandAppraisalOfflineModal(); +} + +class _AddLandAppraisalOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + bool _withoutBUCC = false; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + + GlobalKey appraisalLandKey = GlobalKey(); + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddItemsScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandClassificationLoaded) { + final classification = state.landClassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandSubClassificationLoaded) { + final subclassification = state.landSubClassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalitiesLoaded) { + return FormBuilder( + key: appraisalLandKey, + onChanged: () { + appraisalLandKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: + FormBuilderDropdown( + name: + 'appraisal_municipality', + autofocus: false, + decoration: + normalTextFieldStyle( + cityDesc ?? + "Municipality", + ""), + items: state.city + .map((municipality) => + DropdownMenuItem< + City>( + value: municipality, + child: Text(municipality + .cityDescription!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedCity) { + if (selectedCity != null) { + final selectedCityCode = + selectedCity.cityCode; + setState(() { + cityCode = + selectedCityCode!; + cityDesc = selectedCity + .cityDescription!; + _classDesc = ""; + appraisalLandKey + .currentState + ?.patchValue({ + 'classification': + LandClassification(), + }); + }); + final barangayBloc = + context.read< + LandSubclassificationBloc>(); + barangayBloc.add( + LoadSpecificLandSubClassification( + cityCode: + cityCode, + classCode: + classCode)); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandClassification>( + name: 'classification', + autofocus: false, + decoration: + normalTextFieldStyle( + _classDesc + .toString() ?? + "Classification", + ""), + items: classification + .map((classification) => + DropdownMenuItem< + LandClassification>( + value: + classification, + child: Text( + classification + .description!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedClass) { + if (selectedClass != null) { + final selectedClassCode = + selectedClass.id; + setState(() { + classCode = + selectedClassCode ?? + 0; + _classDesc = selectedClass + .description ?? + ''; + }); + final barangayBloc = + context.read< + LandSubclassificationBloc>(); + barangayBloc.add( + LoadSpecificLandSubClassification( + cityCode: + cityCode, + classCode: + classCode)); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: subclassification + .map((LandSubClassification + subclass) => + SearchFieldListItem( + '${subclass.subclassCode} - ${subclass.subclassDescription}', + item: subclass, + child: ListTile( + title: Text( + '${subclass.subclassCode} - ${subclass.subclassDescription!.toUpperCase()}', + overflow: + TextOverflow + .ellipsis, + ), + ))) + .toList(), + + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + + searchInputDecoration: + normalTextFieldStyle( + "Structure Type", + "") + .copyWith( + suffixIcon: + const Icon(Icons + .arrow_drop_down)), + ////agency suggestion tap + focusNode: focus, + suggestionState: + Suggestion.expand, + suggestionDirection: + SuggestionDirection.up, + onSuggestionTap: (subclass) { + setState(() { + _unitBase = double.parse( + subclass.item! + .baseUnitMarketval!); + _subClassDesc = + '${subclass.item!.subclassCode} - ${subclass.item!.subclassDescription}'; + }); + focus.unfocus(); + }, + ), + ), + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'land_appraisal_area', + decoration: normalTextFieldStyle( + "Area", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + setState(() { + _areaValue = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format( + _totalMarketValue( + _unitBase, + _areaValue)))), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + + context + .read< + LandPropertyAppraisalBloc>() + .add(AddLandPropertyAppraisal( + landapprDetailsId: + tempID.getInt( + 'landid')! + + 1, + classification: + _classDesc, + subClass: + _subClassDesc, + area: _areaValue + .toString(), + unitValue: _unitBase + .toString(), + baseMarketval: + _totalMarketValue( + _unitBase, + _areaValue) + .toString())); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + LandPropertyAppraisalBloc>() + .add( + const LoadLandPropertyAppraisal()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ), + ], + ), + ), + ))); + } + // if (state is MunicipalityErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(LoadMunicipality()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is LandSubClassificationErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context.read().add( + // const LoadLandSubClassification( + // cityCode: '1', classCode: 1)); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is LandClassificationErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(const LoadLandClassification()); + // }, + // ); + // } + return Container(); + }, + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadLandPropertyAppraisal()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/add/AddLandPropertyAssessmentModal.dart b/lib/screens/offline/passo/land/add/AddLandPropertyAssessmentModal.dart new file mode 100644 index 0000000..958e8b7 --- /dev/null +++ b/lib/screens/offline/passo/land/add/AddLandPropertyAssessmentModal.dart @@ -0,0 +1,353 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; + +import '../../../../../bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import '../../../../../model/passo/land_property_assessment.dart'; +import '../../../../../model/passo/land_value_adjustment.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class AddPropertyAssessmentOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddPropertyAssessmentOfflineModal createState() => + _AddPropertyAssessmentOfflineModal(); +} + +class _AddPropertyAssessmentOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + String _actualUse = "Residential"; + String _assessmentLevel = ""; + + GlobalKey assessmentKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + calculateAssessmentValue() { + switch (_actualUse) { + case "Residential": + return (_unitValue * 0.20).ceil(); + case "Agricultural": + return (_unitValue * 0.40).ceil(); + case "Commercial": + return (_unitValue * 0.50).ceil(); + case "Industrial": + return (_unitValue * 0.50).ceil(); + case "Mineral": + return (_unitValue * 0.50).ceil(); + case "Timberland": + return (_unitValue * 0.20).ceil(); + default: + } + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowLandPropertyAssessmentcreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is ValueAdjustmentLoaded) { + final assessment = state.valueAdjustment; + return FormBuilder( + key: assessmentKey, + onChanged: () { + assessmentKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'value_adjustments', + autofocus: false, + decoration: normalTextFieldStyle( + "Value Adjustments", ""), + items: state.valueAdjustment + .map((adj) => + DropdownMenuItem( + value: adj, + child: Text( + (adj.adjustmentFactors ?? ""), + ), + )) + .toList(), + onChanged: (selectedAdj) { + if (selectedAdj != null) { + setState(() { + _unitValue = double.parse( + selectedAdj.marketValue!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + FormBuilderDropdown( + name: "land_actual_use", + autofocus: false, + decoration: normalTextFieldStyle("Actual Use", ""), + items: actual_use + .map((item) => DropdownMenuItem( + value: item, + child: Text(item), + )) + .toList(), + onChanged: (value) { + setState(() { + _actualUse = value!; + + switch (value) { + case "Residential": + setState(() { + _assessmentLevel = '20'; + }); + + break; + case "Agricultural": + setState(() { + _assessmentLevel = '40'; + }); + + break; + case "Commercial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Industrial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Mineral": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Timberland": + setState(() { + _assessmentLevel = '20'; + }); + + break; + default: + } + }); + }, + ), + SizedBox( + height: 10, + ), + Text('Assessment Level'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(_assessmentLevel + '%'), + ), + ), + SizedBox( + height: 10, + ), + Text('Assessment Value'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateAssessmentValue().toString() == + "0.00" + ? "00.0" + : calculateAssessmentValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('landid')! - 1); + + context + .read() + .add(AddLandPropertyAssessment( + landapprDetailsId: + tempID.getInt('landid')! + 1, + actualUse: _actualUse, + marketval: _unitValue.toString(), + assessmentLevel: _assessmentLevel, + assessedValue: + calculateAssessmentValue() + .toString(), + totalMarketval: '0', + totalAssessedval: '0')); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add( + const LoadLandPropertyAssessment()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is ValueAdjustmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadValueAdjustment()); + }, + ); + } + return Container(); + }); + } + if (state is LandPropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadLandPropertyAssessment()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/add/AddOtherImprovementModal.dart b/lib/screens/offline/passo/land/add/AddOtherImprovementModal.dart new file mode 100644 index 0000000..c455d55 --- /dev/null +++ b/lib/screens/offline/passo/land/add/AddOtherImprovementModal.dart @@ -0,0 +1,364 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart'; + +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/model/passo/trees_improvements.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +import '../../../../../bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; + +class AddOtherImprovementModalOffline extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddOtherImprovementModalOffline createState() => + _AddOtherImprovementModalOffline(); +} + +class _AddOtherImprovementModalOffline + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + + GlobalKey otherImpKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + _calculateBaseMarketValue() { + double base = 0.00; + if (_fruitBearing) { + base = (pr_qty + nonpr_qty) * _unitValue; + } else { + base = qty * _unitValue; + } + return base; + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowOtherImprovementScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is TreesImprovementsLoaded) { + final trees = state.treesImprovements; + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'kinds_of_trees', + autofocus: false, + decoration: normalTextFieldStyle( + "Kinds of Trees", ""), + items: state.treesImprovements + .map((trees) => + DropdownMenuItem( + value: trees, + child: Text( + (trees.improvement ?? "") + + " " + + (trees.subclassCode ?? ""), + ), + )) + .toList(), + onChanged: (selectedTree) { + if (selectedTree != null) { + setState(() { + _unitValue = double.parse( + selectedTree.pricePerTree!); + _treeType = selectedTree.improvement!; + }); + } + }, + )), + ), + Container( + child: Row( + children: [ + Row( + children: [ + Checkbox( + value: _fruitBearing, + onChanged: (bool? value) { + setState(() { + _fruitBearing = value!; + }); + }, + ), + Text('Fruit Bearing ?'), + ], + ), + ], + ), + ), + Visibility( + visible: !_fruitBearing, + child: Row( + children: [ + Expanded( + child: FormBuilderTextField( + name: 'subClass', + decoration: normalTextFieldStyle( + "SubClass/Age", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _subClassDesc = value!; + }); + }, + ), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: FormBuilderTextField( + name: 'qty', + decoration: normalTextFieldStyle("No.", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + qty = int.parse(value!); + }); + }, + ), + ), + ], + ), + replacement: Column( + children: [ + FormBuilderTextField( + name: 'no_of_productive', + decoration: normalTextFieldStyle( + "No. of Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + pr_qty = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'no_of_nonproductive', + decoration: normalTextFieldStyle( + "No. of Non-Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + nonpr_qty = int.parse(value!); + }); + }, + ), + ], + ), + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_unitValue))), + ), + const SizedBox(height: 10), + const Text('Base Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(_calculateBaseMarketValue().toString() == + "0.00" + ? "00.0" + : _calculateBaseMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('landid')); + + context + .read() + .add(AddOtherImprovements( + landapprDetailsId: + tempID.getInt('landid')! + 1, + kindsOfTrees: _treeType, + subclassAge: _subClassDesc, + quantity: qty, + unitValue: _unitValue.toString(), + baseMarketval: + _calculateBaseMarketValue() + .toString(), + noOfProductive: pr_qty, + noOfNonproductive: nonpr_qty, + fruitBearing: + _fruitBearing == true ? '1' : '0', + )); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add(const LoadOtherImprovements()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is LandTreesImprovementsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandTreesImprovements()); + }, + ); + } + return Container(); + }); + } + if (state is OtherImprovementsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadOtherImprovements()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/add/AddValueAdjustmentModal.dart b/lib/screens/offline/passo/land/add/AddValueAdjustmentModal.dart new file mode 100644 index 0000000..c18892c --- /dev/null +++ b/lib/screens/offline/passo/land/add/AddValueAdjustmentModal.dart @@ -0,0 +1,524 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; + +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../model/passo/land_value_adjustment.dart'; +import '../../../../../model/passo/type_of_location.dart'; +import '../../../../../model/passo/type_of_road.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class AddLandValueAdjustmentOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddLandValueAdjustmentOfflineModal createState() => + _AddLandValueAdjustmentOfflineModal(); +} + +class _AddLandValueAdjustmentOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + double _roadTypeDeduction = 0; + double _locTypeRoad = 0; + double _locTypePob = 0; + String _roadType = ''; + String _distance = ''; + String _locRdDistance = ''; + String _locPobDistance = ''; + + GlobalKey otherImpKey = GlobalKey(); + + _calculateBaseMarketValue() { + double base = 0.00; + if (_fruitBearing) { + base = (pr_qty + nonpr_qty) * _unitValue; + } else { + base = qty * _unitValue; + } + return base; + } + + double calculateAdjustment() { + double adjustment = 0; + + if (_locPobDistance == '0 TO 1') { + adjustment = _locTypePob - (_roadTypeDeduction + _locTypeRoad); + } else { + adjustment = (_roadTypeDeduction + _locTypeRoad + _locTypePob) * -1; + } + + return adjustment; + } + + double calculateValueAdjustment() { + double adjustment = calculateAdjustment(); + double valueAdjustment = _unitValue * adjustment; + + return valueAdjustment; + } + + double calculateMarketValue() { + double marketValue = 0; + + marketValue = _unitValue + calculateValueAdjustment(); // Adding adjustment + + return marketValue; + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowValueAdjustmentcreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandPropertyAppraisalLoaded) { + final land_appr = state.landAppr; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfRoadLoaded) { + final roadType = state.typeOfRoad; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfLocationLoaded) { + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandAppr?>( + name: 'land_appr_item', + autofocus: false, + decoration: + normalTextFieldStyle( + "Land Appraisal Items", + ""), + items: land_appr + .map((land_appr) => + DropdownMenuItem< + LandAppr?>( + value: land_appr, + child: Text((land_appr + .subClass ?? + "")), + )) + .toList(), + onChanged: + (selectedLandAppr) { + if (selectedLandAppr != + null) { + setState(() { + _unitValue = double.parse( + selectedLandAppr + .baseMarketval!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Adjustment Factors"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfRoad?>( + name: 'road_type', + autofocus: false, + decoration: + normalTextFieldStyle( + "Type of Road", ""), + items: roadType + .map((roadType) => + DropdownMenuItem< + TypeOfRoad?>( + value: roadType, + child: Text((roadType + .roadType ?? + "")), + )) + .toList(), + onChanged: (selectedRoad) { + if (selectedRoad != null) { + setState(() { + _roadTypeDeduction = + double.parse( + selectedRoad + .deduction!); + _roadType = selectedRoad + .roadType!; + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Type of Location"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_road', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Road", + ""), + items: state.typeOfLocation + .map((locTypeRoad) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypeRoad, + child: Text((locTypeRoad + .distanceKm ?? + "")), + )) + .toList(), + onChanged: + (selectedLoadRoad) { + if (selectedLoadRoad != + null) { + setState(() { + _locTypeRoad = double + .parse(selectedLoadRoad + .allRoadTypes!); + _locRdDistance = + selectedLoadRoad + .distanceKm!; + }); + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_pob', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Poblacion", + ""), + items: state.typeOfLocation + .map((locTypePob) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypePob, + child: Text((locTypePob + .distanceKm ?? + "")), + )) + .toList(), + onChanged: (selectedLocPob) { + if (selectedLocPob != + null) { + setState(() { + _locTypePob = double + .parse(selectedLocPob + .localTradingCenter!); + + _locPobDistance = + selectedLocPob + .distanceKm!; + }); + } + }, + )), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + (calculateAdjustment() * 100) + .toString() + + '%'), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + calculateValueAdjustment())), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + + context.read().add(AddValueAdjustments( + landapprDetailsId: + tempID.getInt( + 'landid')! + + 1, + baseMarketval: + _unitValue + .toString(), + adjustmentFactors: _roadType + + ' , ' + + _locPobDistance + + ' km from road , ' + + _locPobDistance + + ' km from poblacion', + adjustment: + calculateAdjustment() + .toString(), + valueAdjustment: + calculateValueAdjustment() + .toString(), + marketValue: + calculateMarketValue() + .toString())); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + ValueAdjustmentBloc>() + .add( + const LoadValueAdjustment()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is TypeOfLocationState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadTypeOfLocation()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandPropertyAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandPropertyAppraisal()); + }, + ); + } + return Container(); + }, + ); + } + if (state is ValueAdjustmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadValueAdjustment()); + }, + ); + } + return Container(); + }); + } + if (state is ValueAdjustmentErrorState) { + return Text(state.error); + } + return Container( + child: Text("Land Value Adjustment"), + ); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/add/add_land.dart b/lib/screens/offline/passo/land/add/add_land.dart new file mode 100644 index 0000000..848986e --- /dev/null +++ b/lib/screens/offline/passo/land/add/add_land.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; + +import 'package:im_stepper/stepper.dart'; +import 'package:unit2/screens/offline/passo/land/add/land_appraisal.dart'; +import 'package:unit2/screens/offline/passo/land/add/land_property_assessment.dart'; +import 'package:unit2/screens/offline/passo/land/add/land_property_owner_offline.dart'; +import 'package:unit2/screens/offline/passo/land/add/land_property_signatories.dart'; +import 'package:unit2/screens/offline/passo/land/add/location_and_boundaries_offline.dart'; +import 'package:unit2/screens/offline/passo/land/add/other_improvement.dart'; +import 'package:unit2/screens/offline/passo/land/add/value_adjustment_offline.dart'; + +import '../../../../../theme-data.dart/colors.dart'; +import '../../../../../utils/alerts.dart'; + +GlobalKey landKeyOffline = GlobalKey(); + +class AddLandOffline extends StatefulWidget { + Function loadLandFass; + AddLandOffline(this.loadLandFass); + @override + _AddLandOffline createState() => _AddLandOffline(); +} + +class _AddLandOffline extends State { + // THE FOLLOWING TWO VARIABLES ARE REQUIRED TO CONTROL THE STEPPER. + int activeStep = 0; // Initial step set to 5. + + int upperBound = 6; // upperBound MUST BE total number of icons minus 1. + + void PrevBtn() { + setState(() { + activeStep--; + }); + } + + void NextBtn() { + setState(() { + activeStep++; + }); + } + + void onCloseTransaction() { + Navigator.of(context).pop(); + widget.loadLandFass(); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async { + confirmAlertWithCancel( + context, + onCloseTransaction, + () => null, + 'Cancel transaction?', + "Are you sure you want to cancel this transaction?"); // Action to perform on back pressed + return false; + }, + child: Scaffold( + appBar: AppBar( + centerTitle: true, + backgroundColor: primary, + title: const Text('Land FAAS'), + ), + body: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + NumberStepper( + numbers: const [1, 2, 3, 4, 5, 6, 7], + activeStepColor: primary, + numberStyle: const TextStyle(color: Colors.white), + lineColor: primary, + // activeStep property set to activeStep variable defined above. + activeStep: activeStep, + activeStepBorderColor: Colors.white, + activeStepBorderWidth: 1, + // This ensures step-tapping updates the activeStep. + onStepReached: (index) { + setState(() { + activeStep = index; + }); + }, + ), + Expanded( + child: FormBuilder( + key: landKeyOffline, + + // enabled: false, + onChanged: () { + landKeyOffline.currentState?.save(); + + print(landKeyOffline.currentState?.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Container( + child: content(PrevBtn, NextBtn, onCloseTransaction), + ), + ), + ), + ], + ), + ), + ), + ); + } + + /// Returns the next button. + + // Returns the content widget based on the activeStep. + Widget content(PrevBtn, NextBtn, onSAveAll) { + switch (activeStep) { + case 0: + return LandPropertyOwnerInfoOffline(NextBtn); + case 1: + return LandLocationAndBoundariesOffline(PrevBtn, NextBtn); + case 2: + return LandAppraisalOffline(PrevBtn, NextBtn); + case 3: + return OtherImprovementOfflinePage(PrevBtn, NextBtn); + case 4: + return ValueAdjustmentOfflinePage(PrevBtn, NextBtn); + case 5: + return LandPropertyAssessmentOfflinePage(PrevBtn, NextBtn); + case 6: + return LandSignatoriesOfflinePage(onSAveAll); + + default: + return Container(); + } + } +} diff --git a/lib/screens/offline/passo/land/add/land_appraisal.dart b/lib/screens/offline/passo/land/add/land_appraisal.dart new file mode 100644 index 0000000..ff2ac45 --- /dev/null +++ b/lib/screens/offline/passo/land/add/land_appraisal.dart @@ -0,0 +1,277 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/screens/offline/passo/land/add/AddLandAppraisal.dart'; +import 'package:unit2/screens/passo/Land/add_land/AddLandAppraisal.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +import '../../../../../bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; + +class LandAppraisalOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandAppraisalOffline(this.PrevBtn, this.NextBtn); + @override + _LandAppraisalOffline createState() => _LandAppraisalOffline(); +} + +class _LandAppraisalOffline extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandPropertyAppraisal(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is LandAppraisalLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandAppraisalLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandAppraisalErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAppraisalLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('LAND APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Classification'), + ), + const DataColumn( + label: Text('Sub-Classification'), + ), + const DataColumn( + label: Text('Area'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base MArket Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.landAppr.map((dataRow) { + return DataRow( + cells: [ + DataCell( + Text(dataRow.classification ?? "")), + DataCell(Text(dataRow.subClass ?? "")), + DataCell(Text(dataRow.area ?? "")), + DataCell(Text(((double.parse( + dataRow.unitValue ?? "0"))) + .toString())), + DataCell(Text(((double.parse( + dataRow.baseMarketval ?? "0"))) + .toString())), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: const Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAppraisalDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandPropertyAppraisal()); + }); + }); + } + } + if (state is ShowAddItemsScreen) { + return ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: const Text( + 'ADD LAND APPRAISAL', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddLandAppraisalOfflineModal()), + ], + ), + ), + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadLandPropertyAppraisal()); + }, + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/add/land_property_assessment.dart b/lib/screens/offline/passo/land/add/land_property_assessment.dart new file mode 100644 index 0000000..6896eae --- /dev/null +++ b/lib/screens/offline/passo/land/add/land_property_assessment.dart @@ -0,0 +1,255 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/screens/offline/passo/land/add/AddLandPropertyAssessmentModal.dart'; + +import '../../../../../bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class LandPropertyAssessmentOfflinePage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandPropertyAssessmentOfflinePage(this.PrevBtn, this.NextBtn); + @override + _LandPropertyAssessmentOfflinePage createState() => + _LandPropertyAssessmentOfflinePage(); +} + +class _LandPropertyAssessmentOfflinePage + extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandPropertyAssessment(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer(listener: (context, state) { + // if (state is LandPropertyAssessmentLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandPropertyAssessmentLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandPropertyAssessmentErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAssessmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowLandPropertyAssessment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Actual Use'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Assessment Level'), + ), + const DataColumn( + label: Text('Assessed Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: + state.landPropertyAssessment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.actualUse!)), + DataCell(Text(dataRow.marketval!)), + DataCell( + Text(dataRow.assessmentLevel! + '%')), + DataCell(Text(dataRow.assessedValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAssessmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandPropertyAssessment()); + }); + }); + } + } + if (state is ShowLandPropertyAssessmentcreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD PROPERTY ASSESSMENT', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddPropertyAssessmentOfflineModal()) + ], + ), + ), + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/add/land_property_owner_offline.dart b/lib/screens/offline/passo/land/add/land_property_owner_offline.dart new file mode 100644 index 0000000..4f7d98d --- /dev/null +++ b/lib/screens/offline/passo/land/add/land_property_owner_offline.dart @@ -0,0 +1,184 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; + +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class LandPropertyOwnerInfoOffline extends StatefulWidget { + Function NextBtn; + LandPropertyOwnerInfoOffline(this.NextBtn); + @override + _LandPropertyOwnerInfoOffline createState() => + _LandPropertyOwnerInfoOffline(); +} + +class _LandPropertyOwnerInfoOffline + extends State { + final transaction_codes = ['New', 'Revision']; + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: + const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY OWNER INFO', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox(height: 15), + customDropDownField( + "Transaction Code", "", "transaction_code", transaction_codes), + customTextField("ARP No./ TD No.", "", "td_no"), + customTextField("Owner", "", "owner"), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded(flex: 1, child: customTextField("PIN", "", "pin")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("TIN", "", "tin")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("OCT/TCT CLOA No.", "", "cloa_no"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker("Dated", "", "dated")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Survey No.", "", "survey_no"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Lot No.", "", "lot_no")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Blk", "", "blk")), + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Address", "", "address"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Tel No.", "", "tel_no")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Administrator/Beneficial User", "", "admin"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("TIN", "", "admin_tin")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Address", "", "admin_address"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Tel No.", "", "admin_telno")) + ]), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_right, color: Colors.white), + onPressed: () { + context.read().add( + AddLandPropertyOwner( + id: 1, + transCode: landKeyOffline + .currentState!.value['transaction_code'] + .toString(), + tdn: landKeyOffline.currentState!.value['td_no'] ?? + '', + cloaNo: + landKeyOffline.currentState!.value['cloa_no'] ?? + '', + dated: landKeyOffline.currentState!.value['dated'] + .toString(), + assessedById: "1", + assessedByName: "cyril", + dateCreated: landKeyOffline + .currentState!.value['dated'] + .toString(), + dateModified: landKeyOffline + .currentState!.value['dated'] + .toString(), + pin: landKeyOffline.currentState!.value['pin'], + surveyNo: + landKeyOffline.currentState!.value['survey_no'], + lotNo: landKeyOffline.currentState!.value['lot_no'], + blkNo: landKeyOffline.currentState!.value['blk'], + owner: landKeyOffline.currentState!.value['owner'], + address: + landKeyOffline.currentState!.value['address'], + telno: landKeyOffline.currentState!.value['tel_no'], + tin: landKeyOffline.currentState!.value['tin'], + adminUser: + landKeyOffline.currentState!.value['admin'], + adminAddress: landKeyOffline + .currentState!.value['admin_address'], + adminTin: + landKeyOffline.currentState!.value['admin_tin'], + // faasType: "LAND", + adminTelno: landKeyOffline + .currentState!.value['admin_telno'], + faasType: 'Land')); + + widget.NextBtn(); + }, + ) + ], + ), + const SizedBox( + height: 20, + ), + ]), + )); + } +} diff --git a/lib/screens/offline/passo/land/add/land_property_signatories.dart b/lib/screens/offline/passo/land/add/land_property_signatories.dart new file mode 100644 index 0000000..913b3aa --- /dev/null +++ b/lib/screens/offline/passo/land/add/land_property_signatories.dart @@ -0,0 +1,628 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; + +import '../../../../../model/passo/land_ext.dart'; +import '../../../../../model/passo/memoranda.dart'; +import '../../../../../model/passo/signatories.dart'; +import '../../../../../theme-data.dart/colors.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class LandSignatoriesOfflinePage extends StatefulWidget { + Function onSAve; + LandSignatoriesOfflinePage(this.onSAve); + + @override + _LandSignatoriesOfflinePage createState() => _LandSignatoriesOfflinePage(); +} + +class _LandSignatoriesOfflinePage extends State { + bool isTaxable = false; + bool isExempt = false; + final focus = FocusNode(); + String _memoranda = ""; + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is LandExtLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is LandExtErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is LandPropertySignatureInitial) { + return BlocConsumer( + listener: (context, state) { + // if (state is SignatoriesLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is SignatoriesErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + // if (state is MemorandaLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is MemorandaLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is MemorandaErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return SingleChildScrollView( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: Colors.white, + value: isTaxable, + onChanged: (bool? value) { + setState(() { + isTaxable = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: Colors.white, + value: isExempt, + onChanged: (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], + ), + ], + ), + Column( + children: [ + const SizedBox( + height: 20, + ), + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', + style: + TextStyle(fontWeight: FontWeight.bold), + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_qtr', + validator: + FormBuilderValidators.compose([]), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_yr', + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + ], + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 40, right: 0, bottom: 10), + child: const Text('SIGNATORIES', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox( + height: 30, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'appraised_by_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: + TextStyle(fontWeight: FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'rec_approval_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'apprvd_by_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'apprvd_by_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + SizedBox( + height: 50, + ), + SizedBox( + width: 500, + height: 50, + child: SearchField( + itemHeight: 70, + suggestions: state.memo + .map((Memoranda memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow.ellipsis, + ), + ), + )) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle( + // "Memoranda", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down), + // ), + focusNode: focus, + suggestionState: Suggestion.expand, + suggestionDirection: SuggestionDirection.up, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = memoranda.item!.memoranda!; + }); + focus.unfocus(); + }, + )), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement_land', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Date Received:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_received_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_of_entry_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by_land', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + var ext = LandExt(); + + print(ext.toJson()); + context.read().add(AddLandPropertySignature( + id: 1, + landapprDetailsId: + tempID.getInt('landid')! + 1, + dateCreated: 'test', + dateModified: 'test', + assessedById: 'test', + assessedByName: 'test', + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: landKeyOffline + .currentState!.value['land_qtr'], + yr: landKeyOffline + .currentState!.value['land_yr'], + appraisedbyName: landKeyOffline + .currentState! + .value['appraised_by_land'] + .firstname + + ' ' + + landKeyOffline + .currentState! + .value['appraised_by_land'] + .middlename + + ' ' + + landKeyOffline + .currentState! + .value['appraised_by_land'] + .lastname, + appraisedbyDate: landKeyOffline.currentState!.value['app_date_land'] + .toString(), + recommendapprName: landKeyOffline + .currentState! + .value['rec_approval_land'] + .firstname + + ' ' + + landKeyOffline + .currentState! + .value['rec_approval_land'] + .middlename + + ' ' + + landKeyOffline.currentState!.value['rec_approval_land'].lastname, + recommendapprDate: landKeyOffline.currentState!.value['rec_date_land'].toString(), + approvedbyName: landKeyOffline.currentState!.value['apprvd_by_land'].firstname + ' ' + landKeyOffline.currentState!.value['apprvd_by_land'].middlename + ' ' + landKeyOffline.currentState!.value['apprvd_by_land'].lastname, + approvedbyDate: landKeyOffline.currentState!.value['apprvd_by_date_land'].toString(), + memoranda: _memoranda, + swornstatementNo: landKeyOffline.currentState!.value['sworn_statement_land'], + dateReceived: landKeyOffline.currentState!.value['date_received_land'].toString(), + entryDateAssessment: landKeyOffline.currentState!.value['date_of_entry_land'].toString(), + entryDateBy: landKeyOffline.currentState!.value['by_land'])); + widget.onSAve(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: SizedBox( + width: 250, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ], + )); + } + // if (state is MemorandaErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // // context + // // .read() + // // .add(LoadMemoranda()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is SignatoriesAd) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context.read().add(LoadSignatories()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is LandExtErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context.read().add(LoadLandExt()); + // }, + // ); + // } + return Container(); + }, + ), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/add/location_and_boundaries_offline.dart b/lib/screens/offline/passo/land/add/location_and_boundaries_offline.dart new file mode 100644 index 0000000..ed2e02b --- /dev/null +++ b/lib/screens/offline/passo/land/add/location_and_boundaries_offline.dart @@ -0,0 +1,195 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; + +import '../../../../../model/passo/land_property_boundaries.dart'; +import '../../../../../model/passo/land_property_loc.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class LandLocationAndBoundariesOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandLocationAndBoundariesOffline(this.PrevBtn, this.NextBtn); + @override + _LandLocationAndBoundariesOffline createState() => + _LandLocationAndBoundariesOffline(); +} + +class _LandLocationAndBoundariesOffline + extends State { + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandPropertyLocationInitial) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandPropertyBoundariesInitial) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "No. / Street", "", "street")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Brgy./District", "", "brgy")), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Municipality", "", "municipality"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Province/City", "", "province")) + ]), + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY BOUNDARIES', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("North", "", "north"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("East", "", "east")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("South", "", "south"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("West", "", "west")) + ]), + SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left, + color: Colors.white), + onPressed: () { + widget.PrevBtn(); + }), + CustomButton( + icon: const Icon(Icons.chevron_right, + color: Colors.white), + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('landid')); + + context + .read() + .add(AddLandPropertyLocation( + id: tempID.getInt('landid')! - 1, + landapprDetailsId: + tempID.getInt('landid')!, + assessedById: 'test', + assessedByName: 'test', + dateCreated: 'test', + dateModified: 'test', + street: landKeyOffline + .currentState?.value['street'], + barangay: landKeyOffline + .currentState?.value['brgy'], + municipality: landKeyOffline + .currentState + ?.value['municipality'], + province: landKeyOffline + .currentState?.value['province'], + )); + + context + .read() + .add(AddLandPropertyBoundaries( + id: tempID.getInt('landid')! - 1, + landapprDetailsId: + tempID.getInt('landid')!, + assessedById: 'test', + assessedByName: 'test', + dateCreated: 'test', + dateModified: 'test', + north: landKeyOffline + .currentState?.value['north'], + east: landKeyOffline + .currentState?.value['east'], + south: landKeyOffline + .currentState?.value['south'], + west: landKeyOffline + .currentState?.value['west'], + sketch: 'test')); + widget.NextBtn(); + }) + ], + ) + ]), + ), + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/offline/passo/land/add/other_improvement.dart b/lib/screens/offline/passo/land/add/other_improvement.dart new file mode 100644 index 0000000..d299af7 --- /dev/null +++ b/lib/screens/offline/passo/land/add/other_improvement.dart @@ -0,0 +1,276 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/screens/offline/passo/land/add/AddOtherImprovementModal.dart'; + +import 'package:unit2/screens/passo/Land/add_land/AddOtherImprovementModal.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +import '../../../../../bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; + +class OtherImprovementOfflinePage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + OtherImprovementOfflinePage(this.PrevBtn, this.NextBtn); + @override + _OtherImprovementOfflinePage createState() => _OtherImprovementOfflinePage(); +} + +class _OtherImprovementOfflinePage extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteOtherImprovements(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // if (state is OtherImprovementLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is OtherImprovementLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is OtherImprovementErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is OtherImprovementsLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('OTHER IMPROVEMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowOtherImprovement()); + }, + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Kinds of Tress'), + ), + const DataColumn( + label: Text('Sub-Class / Age'), + ), + const DataColumn( + label: Text('Type of Tree'), + ), + const DataColumn( + label: Text('No.'), + ), + const DataColumn( + label: Text('No. of Productive'), + ), + const DataColumn( + label: Text('No. of Non-Productive'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.otherImprovements.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.kindsOfTrees!)), + DataCell(Text(dataRow.subclassAge!)), + DataCell(Text(dataRow.fruitBearing == true + ? "Fruit Bearing" + : "Non-Fruit Bearing")), + DataCell( + Text(dataRow.quantity.toString()!)), + DataCell(Text( + dataRow.noOfProductive.toString()!)), + DataCell(Text(dataRow.noOfNonproductive + .toString()!)), + DataCell( + Text(dataRow.unitValue.toString()!)), + DataCell(Text( + dataRow.baseMarketval.toString()!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is OtherImprovementsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadOtherImprovements()); + }); + }); + } + } + if (state is ShowOtherImprovementScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: const Text( + 'ADD OTHER IMPROVEMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddOtherImprovementModalOffline()) + ], + ), + ), + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/add/value_adjustment_offline.dart b/lib/screens/offline/passo/land/add/value_adjustment_offline.dart new file mode 100644 index 0000000..041e30c --- /dev/null +++ b/lib/screens/offline/passo/land/add/value_adjustment_offline.dart @@ -0,0 +1,246 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/add/AddValueAdjustmentModal.dart'; + +import '../../../../../utils/alerts.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class ValueAdjustmentOfflinePage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + ValueAdjustmentOfflinePage(this.PrevBtn, this.NextBtn); + @override + _ValueAdjustmentOfflinePage createState() => _ValueAdjustmentOfflinePage(); +} + +class _ValueAdjustmentOfflinePage extends State { + void deleteItem(int itemId) { + context.read().add(DeleteValueAdjustment(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // if (state is LandValueAdjustmentsLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandValueAdjustmentsLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandValueAdjustmentsErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is ValueAdjustmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('VALUE ADJUSTMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowValueAdjustment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Adjustment Factors'), + ), + const DataColumn( + label: Text('% Adjustment'), + ), + const DataColumn( + label: Text('Value Adjustment'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.valueAdjustment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.baseMarketval!)), + DataCell( + Text(dataRow.adjustmentFactors!)), + DataCell(Text(dataRow.adjustment!)), + DataCell(Text(dataRow.valueAdjustment!)), + DataCell(Text(dataRow.marketValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is ValueAdjustmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadValueAdjustment()); + }); + }); + } + } + if (state is ShowValueAdjustmentcreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD VALUE ADJUSTMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddLandValueAdjustmentOfflineModal()) + ], + ), + ), + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/AddLandAppraisal.dart b/lib/screens/offline/passo/land/edit/AddLandAppraisal.dart new file mode 100644 index 0000000..c23539f --- /dev/null +++ b/lib/screens/offline/passo/land/edit/AddLandAppraisal.dart @@ -0,0 +1,436 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/widgets/error_state.dart'; + +import '../../../../../model/passo/city.dart'; +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../model/passo/land_classification.dart'; +import '../../../../../model/passo/land_subclassification.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; + +class AddLandAppraisalEditOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + final int tempId; + + AddLandAppraisalEditOfflineModal(this.tempId); + + @override + _AddLandAppraisalEditOfflineModal createState() => + _AddLandAppraisalEditOfflineModal(); +} + +class _AddLandAppraisalEditOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + bool _withoutBUCC = false; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + + GlobalKey appraisalLandKey = GlobalKey(); + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddItemsScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandClassificationLoaded) { + final classification = state.landClassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandSubClassificationLoaded) { + final subclassification = state.landSubClassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalitiesLoaded) { + return FormBuilder( + key: appraisalLandKey, + onChanged: () { + appraisalLandKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: + FormBuilderDropdown( + name: + 'appraisal_municipality', + autofocus: false, + decoration: + normalTextFieldStyle( + cityDesc ?? + "Municipality", + ""), + items: state.city + .map((municipality) => + DropdownMenuItem< + City>( + value: municipality, + child: Text(municipality + .cityDescription!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedCity) { + if (selectedCity != null) { + final selectedCityCode = + selectedCity.cityCode; + setState(() { + cityCode = + selectedCityCode!; + cityDesc = selectedCity + .cityDescription!; + }); + final barangayBloc = + context.read< + LandSubclassificationBloc>(); + barangayBloc.add( + LoadLandSubClassification()); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandClassification>( + name: 'classification', + autofocus: false, + decoration: + normalTextFieldStyle( + _classDesc + .toString() ?? + "Classification", + ""), + items: classification + .map((classification) => + DropdownMenuItem< + LandClassification>( + value: + classification, + child: Text( + classification + .description!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedClass) { + if (selectedClass != null) { + final selectedClassCode = + selectedClass.id; + setState(() { + classCode = + selectedClassCode!; + _classDesc = + selectedClass + .description!; + }); + final barangayBloc = + context.read< + LandSubclassificationBloc>(); + barangayBloc.add( + LoadLandSubClassification()); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: subclassification + .map((LandSubClassification + subclass) => + SearchFieldListItem( + '${subclass.subclassCode} - ${subclass.subclassDescription}', + item: subclass, + child: ListTile( + title: Text( + '${subclass.subclassCode} - ${subclass.subclassDescription!.toUpperCase()}', + overflow: + TextOverflow + .ellipsis, + ), + ))) + .toList(), + + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + + searchInputDecoration: + normalTextFieldStyle( + "Structure Type", + "") + .copyWith( + suffixIcon: + const Icon(Icons + .arrow_drop_down)), + ////agency suggestion tap + focusNode: focus, + suggestionState: + Suggestion.expand, + onSuggestionTap: (subclass) { + setState(() { + _unitBase = double.parse( + subclass.item! + .baseUnitMarketval!); + _subClassDesc = + '${subclass.item!.subclassCode} - ${subclass.item!.subclassDescription}'; + }); + focus.unfocus(); + }, + ), + ), + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'land_appraisal_area', + decoration: normalTextFieldStyle( + "Area", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + setState(() { + _areaValue = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format( + _totalMarketValue( + _unitBase, + _areaValue)))), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + + context.read().add( + AddLandPropertyAppraisal( + landapprDetailsId: + tempID.getInt( + 'landid')!, + classification: + _classDesc, + subClass: + _subClassDesc, + area: _areaValue + .toString(), + unitValue: _unitBase + .toString(), + baseMarketval: + _totalMarketValue( + _unitBase, + _areaValue) + .toString())); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + LandPropertyAppraisalBloc>() + .add( + const LoadLandPropertyAppraisal()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ), + ], + ), + ), + ))); + } + // if (state is MunicipalityErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(LoadMunicipality()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is LandSubClassificationErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context.read().add( + // const LoadLandSubClassification( + // cityCode: '1', classCode: 1)); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is LandClassificationErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(const LoadLandClassification()); + // }, + // ); + // } + return Container(); + }, + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadLandPropertyAppraisal()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/edit/AddOtherImprovementModal.dart b/lib/screens/offline/passo/land/edit/AddOtherImprovementModal.dart new file mode 100644 index 0000000..ad91064 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/AddOtherImprovementModal.dart @@ -0,0 +1,361 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; + +import '../../../../../model/passo/trees_improvements.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class AddOtherImprovementModalEditOffline extends StatefulWidget { + // final List unit; + // final List options; + final int tempId; + + AddOtherImprovementModalEditOffline(this.tempId); + + @override + _AddOtherImprovementModalEditOffline createState() => + _AddOtherImprovementModalEditOffline(); +} + +class _AddOtherImprovementModalEditOffline + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + + GlobalKey otherImpKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + _calculateBaseMarketValue() { + double base = 0.00; + if (_fruitBearing) { + base = (pr_qty + nonpr_qty) * _unitValue; + } else { + base = qty * _unitValue; + } + return base; + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowOtherImprovementScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is TreesImprovementsLoaded) { + final trees = state.treesImprovements; + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'kinds_of_trees', + autofocus: false, + decoration: normalTextFieldStyle( + "Kinds of Trees", ""), + items: state.treesImprovements + .map((trees) => + DropdownMenuItem( + value: trees, + child: Text( + (trees.improvement ?? "") + + " " + + (trees.subclassCode ?? ""), + ), + )) + .toList(), + onChanged: (selectedTree) { + if (selectedTree != null) { + setState(() { + _unitValue = double.parse( + selectedTree.pricePerTree!); + _treeType = selectedTree.improvement!; + }); + } + }, + )), + ), + Container( + child: Row( + children: [ + Row( + children: [ + Checkbox( + value: _fruitBearing, + onChanged: (bool? value) { + setState(() { + _fruitBearing = value!; + }); + }, + ), + Text('Fruit Bearing ?'), + ], + ), + ], + ), + ), + Visibility( + visible: !_fruitBearing, + child: Row( + children: [ + Expanded( + child: FormBuilderTextField( + name: 'subClass', + decoration: normalTextFieldStyle( + "SubClass/Age", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _subClassDesc = value!; + }); + }, + ), + ), + SizedBox( + width: 10, + ), + Expanded( + child: FormBuilderTextField( + name: 'qty', + decoration: normalTextFieldStyle("No.", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + qty = int.parse(value!); + }); + }, + ), + ), + ], + ), + replacement: Column( + children: [ + FormBuilderTextField( + name: 'no_of_productive', + decoration: normalTextFieldStyle( + "No. of Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + pr_qty = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'no_of_nonproductive', + decoration: normalTextFieldStyle( + "No. of Non-Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + nonpr_qty = int.parse(value!); + }); + }, + ), + ], + ), + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_unitValue))), + ), + const SizedBox(height: 10), + const Text('Base Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(_calculateBaseMarketValue().toString() == + "0.00" + ? "00.0" + : _calculateBaseMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('landid')); + + context + .read() + .add(AddOtherImprovements( + landapprDetailsId: + tempID.getInt('landid')! - 1, + kindsOfTrees: _treeType, + subclassAge: _subClassDesc, + quantity: qty, + unitValue: _unitValue.toString(), + baseMarketval: + _calculateBaseMarketValue() + .toString(), + noOfProductive: pr_qty, + noOfNonproductive: nonpr_qty, + fruitBearing: + _fruitBearing == true ? '1' : '0', + )); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add(const LoadOtherImprovements()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + // if (state is LandTreesImprovementsErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(LoadLandTreesImprovements()); + // }, + // ); + // } + return Container(); + }); + } + if (state is OtherImprovementsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadOtherImprovements()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/edit/AddPropertyAssessmentEditModal.dart b/lib/screens/offline/passo/land/edit/AddPropertyAssessmentEditModal.dart new file mode 100644 index 0000000..1df1a38 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/AddPropertyAssessmentEditModal.dart @@ -0,0 +1,352 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; + +import '../../../../../model/passo/land_value_adjustment.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class AddPropertyAssessmentEditOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddPropertyAssessmentEditOfflineModal createState() => + _AddPropertyAssessmentEditOfflineModal(); +} + +class _AddPropertyAssessmentEditOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + String _actualUse = "Residential"; + String _assessmentLevel = ""; + + GlobalKey assessmentKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + calculateAssessmentValue() { + switch (_actualUse) { + case "Residential": + return (_unitValue * 0.20).ceil(); + case "Agricultural": + return (_unitValue * 0.40).ceil(); + case "Commercial": + return (_unitValue * 0.50).ceil(); + case "Industrial": + return (_unitValue * 0.50).ceil(); + case "Mineral": + return (_unitValue * 0.50).ceil(); + case "Timberland": + return (_unitValue * 0.20).ceil(); + default: + } + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowLandPropertyAssessmentcreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is ValueAdjustmentLoaded) { + final assessment = state.valueAdjustment; + return FormBuilder( + key: assessmentKey, + onChanged: () { + assessmentKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'value_adjustments', + autofocus: false, + decoration: normalTextFieldStyle( + "Value Adjustments", ""), + items: state.valueAdjustment + .map((adj) => + DropdownMenuItem( + value: adj, + child: Text( + (adj.adjustmentFactors ?? ""), + ), + )) + .toList(), + onChanged: (selectedAdj) { + if (selectedAdj != null) { + setState(() { + _unitValue = double.parse( + selectedAdj.marketValue!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + FormBuilderDropdown( + name: "land_actual_use", + autofocus: false, + decoration: normalTextFieldStyle("Actual Use", ""), + items: actual_use + .map((item) => DropdownMenuItem( + value: item, + child: Text(item), + )) + .toList(), + onChanged: (value) { + setState(() { + _actualUse = value!; + + switch (value) { + case "Residential": + setState(() { + _assessmentLevel = '20'; + }); + + break; + case "Agricultural": + setState(() { + _assessmentLevel = '40'; + }); + + break; + case "Commercial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Industrial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Mineral": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Timberland": + setState(() { + _assessmentLevel = '20'; + }); + + break; + default: + } + }); + }, + ), + SizedBox( + height: 10, + ), + Text('Assessment Level'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(_assessmentLevel + '%'), + ), + ), + SizedBox( + height: 10, + ), + Text('Assessment Value'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateAssessmentValue().toString() == + "0.00" + ? "00.0" + : calculateAssessmentValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('landid')! - 1); + + context + .read() + .add(AddLandPropertyAssessment( + landapprDetailsId: + tempID.getInt('landid')! - 1, + actualUse: _actualUse, + marketval: _unitValue.toString(), + assessmentLevel: _assessmentLevel, + assessedValue: + calculateAssessmentValue() + .toString(), + totalMarketval: '0', + totalAssessedval: '0')); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add( + const LoadLandPropertyAssessment()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is ValueAdjustmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadValueAdjustment()); + }, + ); + } + return Container(); + }); + } + if (state is LandPropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadLandPropertyAssessment()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/land/edit/AddValueAdjustmentModalOffline.dart b/lib/screens/offline/passo/land/edit/AddValueAdjustmentModalOffline.dart new file mode 100644 index 0000000..cff6a92 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/AddValueAdjustmentModalOffline.dart @@ -0,0 +1,523 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; + +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../model/passo/type_of_location.dart'; +import '../../../../../model/passo/type_of_road.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class AddLandValueAdjustmentEditOfflineModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddLandValueAdjustmentEditOfflineModal createState() => + _AddLandValueAdjustmentEditOfflineModal(); +} + +class _AddLandValueAdjustmentEditOfflineModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + double _roadTypeDeduction = 0; + double _locTypeRoad = 0; + double _locTypePob = 0; + String _roadType = ''; + String _distance = ''; + String _locRdDistance = ''; + String _locPobDistance = ''; + + GlobalKey otherImpKey = GlobalKey(); + + _calculateBaseMarketValue() { + double base = 0.00; + if (_fruitBearing) { + base = (pr_qty + nonpr_qty) * _unitValue; + } else { + base = qty * _unitValue; + } + return base; + } + + double calculateAdjustment() { + double adjustment = 0; + + if (_locPobDistance == '0 TO 1') { + adjustment = _locTypePob - (_roadTypeDeduction + _locTypeRoad); + } else { + adjustment = (_roadTypeDeduction + _locTypeRoad + _locTypePob) * -1; + } + + return adjustment; + } + + double calculateValueAdjustment() { + double adjustment = calculateAdjustment(); + double valueAdjustment = _unitValue * adjustment; + + return valueAdjustment; + } + + double calculateMarketValue() { + double marketValue = 0; + + marketValue = _unitValue + calculateValueAdjustment(); // Adding adjustment + + return marketValue; + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowValueAdjustmentcreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandPropertyAppraisalLoaded) { + final land_appr = state.landAppr; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfRoadLoaded) { + final roadType = state.typeOfRoad; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfLocationLoaded) { + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandAppr?>( + name: 'land_appr_item', + autofocus: false, + decoration: + normalTextFieldStyle( + "Land Appraisal Items", + ""), + items: land_appr + .map((land_appr) => + DropdownMenuItem< + LandAppr?>( + value: land_appr, + child: Text((land_appr + .subClass ?? + "")), + )) + .toList(), + onChanged: + (selectedLandAppr) { + if (selectedLandAppr != + null) { + setState(() { + _unitValue = double.parse( + selectedLandAppr + .baseMarketval!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Adjustment Factors"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfRoad?>( + name: 'road_type', + autofocus: false, + decoration: + normalTextFieldStyle( + "Type of Road", ""), + items: roadType + .map((roadType) => + DropdownMenuItem< + TypeOfRoad?>( + value: roadType, + child: Text((roadType + .roadType ?? + "")), + )) + .toList(), + onChanged: (selectedRoad) { + if (selectedRoad != null) { + setState(() { + _roadTypeDeduction = + double.parse( + selectedRoad + .deduction!); + _roadType = selectedRoad + .roadType!; + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Type of Location"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_road', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Road", + ""), + items: state.typeOfLocation + .map((locTypeRoad) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypeRoad, + child: Text((locTypeRoad + .distanceKm ?? + "")), + )) + .toList(), + onChanged: + (selectedLoadRoad) { + if (selectedLoadRoad != + null) { + setState(() { + _locTypeRoad = double + .parse(selectedLoadRoad + .allRoadTypes!); + _locRdDistance = + selectedLoadRoad + .distanceKm!; + }); + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_pob', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Poblacion", + ""), + items: state.typeOfLocation + .map((locTypePob) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypePob, + child: Text((locTypePob + .distanceKm ?? + "")), + )) + .toList(), + onChanged: (selectedLocPob) { + if (selectedLocPob != + null) { + setState(() { + _locTypePob = double + .parse(selectedLocPob + .localTradingCenter!); + + _locPobDistance = + selectedLocPob + .distanceKm!; + }); + } + }, + )), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + (calculateAdjustment() * 100) + .toString() + + '%'), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + calculateValueAdjustment())), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + + context.read().add(AddValueAdjustments( + landapprDetailsId: + tempID.getInt( + 'landid')! - + 1, + baseMarketval: + _unitValue + .toString(), + adjustmentFactors: _roadType + + ' , ' + + _locPobDistance + + ' km from road , ' + + _locPobDistance + + ' km from poblacion', + adjustment: + calculateAdjustment() + .toString(), + valueAdjustment: + calculateValueAdjustment() + .toString(), + marketValue: + calculateMarketValue() + .toString())); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + ValueAdjustmentBloc>() + .add( + const LoadValueAdjustment()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is TypeOfLocationState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadTypeOfLocation()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandPropertyAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandPropertyAppraisal()); + }, + ); + } + return Container(); + }, + ); + } + if (state is ValueAdjustmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadValueAdjustment()); + }, + ); + } + return Container(); + }); + } + if (state is ValueAdjustmentErrorState) { + return Text(state.error); + } + return Container( + child: Text("Land Value Adjustment"), + ); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/edit_land.dart b/lib/screens/offline/passo/land/edit/edit_land.dart new file mode 100644 index 0000000..7689469 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/edit_land.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:im_stepper/stepper.dart'; +import 'package:unit2/screens/offline/passo/land/edit/land_appraisal_edit_offline.dart'; +import 'package:unit2/screens/offline/passo/land/edit/land_property_assessement_edit.dart'; +import 'package:unit2/screens/offline/passo/land/edit/land_property_owner_offline_edit.dart'; +import 'package:unit2/screens/offline/passo/land/edit/land_signatories_edit.dart'; +import 'package:unit2/screens/offline/passo/land/edit/location_and_boundaries_edit_offline.dart'; +import 'package:unit2/screens/offline/passo/land/edit/other_improvements_edit.dart'; +import 'package:unit2/screens/offline/passo/land/edit/value_adjustment_edit.dart'; + +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../theme-data.dart/colors.dart'; + +GlobalKey landOfflineKeyEdit = GlobalKey(); + +class EditLandOffline extends StatefulWidget { + final int index; + final LandPropertyOwner faas; + final String title; + + const EditLandOffline( + {super.key, + required this.title, + required this.index, + required this.faas}); + @override + _EditLandOffline createState() => _EditLandOffline(); +} + +class _EditLandOffline extends State { + // THE FOLLOWING TWO VARIABLES ARE REQUIRED TO CONTROL THE STEPPER. + int activeStep = 0; // Initial step set to 5. + + int upperBound = 6; // upperBound MUST BE total number of icons minus 1. + + void PrevBtn() { + setState(() { + activeStep--; + }); + } + + void NextBtn() { + setState(() { + activeStep++; + }); + } + + void onSAveAll() { + return Navigator.of(context).pop(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + centerTitle: true, + backgroundColor: primary, + title: Text('Land FAAS'), + ), + body: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + NumberStepper( + numbers: [1, 2, 3, 4, 5, 6, 7], + activeStepColor: primary, + numberStyle: TextStyle(color: Colors.white), + lineColor: primary, + // activeStep property set to activeStep variable defined above. + activeStep: activeStep, + activeStepBorderColor: Colors.white, + activeStepBorderWidth: 1, + // This ensures step-tapping updates the activeStep. + onStepReached: (index) { + setState(() { + activeStep = index; + }); + }, + ), + Expanded( + child: Container( + child: content(PrevBtn, NextBtn, onSAveAll), + ), + ), + ], + ), + ), + ); + } + + /// Returns the next button. + + // Returns the content widget based on the activeStep. + Widget content(PrevBtn, NextBtn, onSAveAll) { + switch (activeStep) { + case 0: + return LandPropertyOwnerInfoOfflineEdit(NextBtn, widget.faas); + case 1: + return LandLocationAndBoundariesOfflineEdit( + PrevBtn, NextBtn, widget.faas!); + case 2: + return LandAppraisalEditOffline(PrevBtn, NextBtn, widget.faas.id!); + case 3: + return OtherImprovementEditPageOffline( + PrevBtn, NextBtn, widget.faas.id!); + case 4: + return ValueAdjustmentEditPageOffline( + PrevBtn, NextBtn, widget.faas.id!); + case 5: + return LandPropertyAssessmentEditPageOffline( + PrevBtn, NextBtn, widget.faas.id!); + case 6: + return LandSignatoriesEditOffline(onSAveAll, widget.faas.id!); + + default: + return SizedBox.shrink(); + } + } +} diff --git a/lib/screens/offline/passo/land/edit/land_appraisal_edit_offline.dart b/lib/screens/offline/passo/land/edit/land_appraisal_edit_offline.dart new file mode 100644 index 0000000..43f0839 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/land_appraisal_edit_offline.dart @@ -0,0 +1,291 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/AddLandAppraisal.dart'; + +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class LandAppraisalEditOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + final int faasId; + LandAppraisalEditOffline(this.PrevBtn, this.NextBtn, this.faasId); + @override + _LandAppraisalEditOffline createState() => _LandAppraisalEditOffline(); +} + +class _LandAppraisalEditOffline extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandPropertyAppraisal(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is LandAppraisalLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandAppraisalLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandAppraisalErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAppraisalLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('LAND APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Classification'), + ), + const DataColumn( + label: Text('Sub-Classification'), + ), + const DataColumn( + label: Text('Area'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base MArket Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.landAppr.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.classification!)), + DataCell(Text(dataRow.subClass!)), + DataCell(Text(dataRow.area!)), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(((double.parse( + dataRow.unitValue!)))) + .toString())), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(((double.parse( + dataRow.baseMarketval!)))) + .toString())), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: const Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAppraisalDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadLandPropertyAppraisalEdit( + landAppr: const [], id: widget.faasId!)); + }); + }); + } + } + if (state is ShowAddItemsScreen) { + return ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: 700.0, + ), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: const Text( + 'ADD LAND APPRAISAL', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.topCenter, + child: Container( + child: ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 500), + child: AddLandAppraisalEditOfflineModal(widget.faasId), + ), + ), + ), + ], + ), + ), + ); + } + if (state is LandPropertyAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandPropertyAppraisalEdit( + landAppr: const [], id: widget.faasId!)); + }, + ); + } + return Container(); + }), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/land_property_assessement_edit.dart b/lib/screens/offline/passo/land/edit/land_property_assessement_edit.dart new file mode 100644 index 0000000..389d573 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/land_property_assessement_edit.dart @@ -0,0 +1,282 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/AddPropertyAssessmentEditModal.dart'; + +import '../../../../../model/passo/land_property_assessment.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class LandPropertyAssessmentEditPageOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + final int faasId; + LandPropertyAssessmentEditPageOffline( + this.PrevBtn, this.NextBtn, this.faasId); + @override + _LandPropertyAssessmentEditPageOffline createState() => + _LandPropertyAssessmentEditPageOffline(); +} + +class _LandPropertyAssessmentEditPageOffline + extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandPropertyAssessment(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer(listener: (context, state) { + // if (state is LandPropertyAssessmentLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandPropertyAssessmentLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandPropertyAssessmentErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAssessmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowLandPropertyAssessment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Actual Use'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Assessment Level'), + ), + const DataColumn( + label: Text('Assessed Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: + state.landPropertyAssessment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.actualUse ?? "")), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + double.parse(dataRow.marketval!)))), + DataCell(Text(dataRow.assessmentLevel ?? + "0" + '%')), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow.assessedValue!)))), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAssessmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadLandPropertyAssessmentEdit( + landPropertyAssessment: [], + id: widget.faasId)); + }); + }); + } + } + if (state is ShowLandPropertyAssessmentcreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD PROPERTY ASSESSMENT', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container(child: AddPropertyAssessmentEditOfflineModal()) + ], + ), + ), + ); + } + if (state is LandPropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandPropertyAssessmentEdit( + landPropertyAssessment: const [], + id: widget.faasId)); + }, + ); + } + + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/land_property_owner_offline_edit.dart b/lib/screens/offline/passo/land/edit/land_property_owner_offline_edit.dart new file mode 100644 index 0000000..c55bd33 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/land_property_owner_offline_edit.dart @@ -0,0 +1,225 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/edit_land.dart'; + +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class LandPropertyOwnerInfoOfflineEdit extends StatefulWidget { + Function NextBtn; + LandPropertyOwner land; + LandPropertyOwnerInfoOfflineEdit(this.NextBtn, this.land); + @override + _LandPropertyOwnerInfoOfflineEdit createState() => + _LandPropertyOwnerInfoOfflineEdit(); +} + +class _LandPropertyOwnerInfoOfflineEdit + extends State { + final transaction_codes = ['New', 'Revision']; + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + return FormBuilder( + key: landOfflineKeyEdit, + initialValue: { + 'transaction_code': widget.land.transCode ?? '', + 'td_no': widget.land.tdn ?? '', + 'owner': widget.land.owner ?? '', + 'pin': widget.land.pin ?? '', + 'tin': widget.land.tin ?? '', + 'cloa_no': widget.land.cloaNo ?? '', + 'dated': widget.land.dated ?? '', + 'survey_no': widget.land.surveyNo ?? '', + 'lot_no': widget.land.lotNo ?? '', + 'blk': widget.land.blkNo ?? '', + 'address': widget.land.address ?? '', + 'tel_no': widget.land.telno ?? '', + 'admin': widget.land.adminUser ?? '', + 'admin_tin': widget.land.adminTin ?? '', + 'admin_address': widget.land.adminAddress ?? '', + 'admin_telno': widget.land.adminTelno ?? '', + }, + enabled: true, + onChanged: () { + landOfflineKeyEdit.currentState!.save(); + debugPrint(landOfflineKeyEdit.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY OWNER INFO', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox(height: 15), + customDropDownField("Transaction Code", "", + "transaction_code", transaction_codes), + customTextField("ARP No./ TD No.", "", "td_no"), + customTextField("Owner", "", "owner"), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, child: customTextField("PIN", "", "pin")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("TIN", "", "tin")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "OCT/TCT CLOA No.", "", "cloa_no"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker("Dated", "", "dated")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Survey No.", "", "survey_no"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Lot No.", "", "lot_no")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Blk", "", "blk")), + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Address", "", "address"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Tel No.", "", "tel_no")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Administrator/Beneficial User", "", "admin"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("TIN", "", "admin_tin")) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: + customTextField("Address", "", "admin_address"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: + customTextField("Tel No.", "", "admin_telno")) + ]), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_right, + color: Colors.white), + onPressed: () { + var landOwner = LandPropertyOwner( + id: widget.land.id!, + transCode: landOfflineKeyEdit + .currentState!.value['transaction_code'] + .toString(), + tdn: landOfflineKeyEdit + .currentState!.value['td_no'], + cloaNo: landOfflineKeyEdit + .currentState!.value['cloa_no'], + dated: landOfflineKeyEdit + .currentState!.value['dated'] + .toString(), + assessedById: "1", + assessedByName: "cyril", + dateCreated: 'none', + dateModified: 'none', + pin: + landOfflineKeyEdit.currentState!.value['pin'], + surveyNo: landOfflineKeyEdit + .currentState!.value['survey_no'], + lotNo: landOfflineKeyEdit + .currentState!.value['lot_no'], + blkNo: + landOfflineKeyEdit.currentState!.value['blk'], + owner: landOfflineKeyEdit + .currentState!.value['owner'], + address: landOfflineKeyEdit + .currentState!.value['address'], + telno: landOfflineKeyEdit.currentState!.value['tel_no'], + tin: landOfflineKeyEdit.currentState!.value['tin'], + adminUser: landOfflineKeyEdit.currentState!.value['admin'], + adminAddress: landOfflineKeyEdit.currentState!.value['admin_address'], + adminTin: landOfflineKeyEdit.currentState!.value['admin_tin'], + faasType: "LAND", + adminTelno: landOfflineKeyEdit.currentState!.value['admin_telno']); + context.read().add( + UpdateLandPropertyOwnerInfo( + landPropertyOwner: landOwner, + id: widget.land.id!)); + + widget.NextBtn(); + }, + ) + ], + ), + const SizedBox( + height: 20, + ), + ]), + )), + ); + }, + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/land_signatories_edit.dart b/lib/screens/offline/passo/land/edit/land_signatories_edit.dart new file mode 100644 index 0000000..f1a1cf4 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/land_signatories_edit.dart @@ -0,0 +1,681 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/edit_land.dart'; + +import '../../../../../model/passo/land_ext.dart'; +import '../../../../../model/passo/memoranda.dart'; +import '../../../../../model/passo/signatories.dart'; +import '../../../../../theme-data.dart/colors.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; + +class LandSignatoriesEditOffline extends StatefulWidget { + Function onSAve; + final int faasId; + LandSignatoriesEditOffline(this.onSAve, this.faasId); + + @override + _LandSignatoriesEditOffline createState() => _LandSignatoriesEditOffline(); +} + +class _LandSignatoriesEditOffline extends State { + bool isTaxable = false; + bool isExempt = false; + final focus = FocusNode(); + String _memoranda = ""; + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is LandExtEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + if (state is LoadSpecificLandPropertySignature) { + setState(() { + isTaxable = + state.landPropertySignature.taxable == '1' ? true : false; + isExempt = + state.landPropertySignature.exempt == '1' ? true : false; + }); + } + }, + builder: (context, state) { + if (state is LoadSpecificLandPropertySignature) { + final landext = state.landPropertySignature; + return BlocConsumer( + listener: (context, state) { + // if (state is SignatoriesErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + // if (state is MemorandaLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is MemorandaErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return FormBuilder( + key: landOfflineKeyEdit, + initialValue: { + 'land_qtr': landext.qtr.toString(), + 'land_yr': landext.yr.toString(), + 'app_date_land': landext.appraisedbyDate, + 'rec_date_land': landext.recommendapprDate, + 'apprvd_by_date_land': landext.approvedbyDate, + 'sworn_statement_land': landext.swornstatementNo, + 'date_received_land': landext.dateReceived, + 'date_of_entry_land': landext.entryDateAssessment, + 'by_land': landext.entryDateBy + }, + enabled: true, + onChanged: () { + landOfflineKeyEdit.currentState!.save(); + debugPrint(landOfflineKeyEdit.currentState!.value + .toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text( + 'PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: Colors.white, + value: isTaxable, + onChanged: (bool? value) { + setState(() { + isTaxable = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: Colors.white, + value: isExempt, + onChanged: (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], + ), + ], + ), + Column( + children: [ + const SizedBox( + height: 20, + ), + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', + style: TextStyle( + fontWeight: FontWeight.bold), + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_qtr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_yr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + ], + ), + ], + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 40, right: 0, bottom: 10), + child: const Text('SIGNATORIES', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: + TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'appraised_by_land', + decoration: InputDecoration( + labelText: landext + .appraisedbyName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: TextStyle( + fontWeight: FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'rec_approval_land', + decoration: InputDecoration( + labelText: landext + .recommendapprName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'apprvd_by_land', + decoration: InputDecoration( + labelText: + landext.approvedbyName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'apprvd_by_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + const SizedBox( + height: 50, + ), + SizedBox( + width: 500, + height: 100, + child: SearchField( + itemHeight: 70, + hint: landext.memoranda, + suggestions: state.memo + .map((Memoranda memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow.ellipsis, + ), + ), + )) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle( + // "Memoranda", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down), + // ), + focusNode: focus, + suggestionDirection: + SuggestionDirection.up, + suggestionState: Suggestion.expand, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = + memoranda.item!.memoranda!; + }); + focus.unfocus(); + }, + )), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement_land', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Date Received:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_received_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_of_entry_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by_land', + decoration: const InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + var ext = LandExt( + landapprDetailsId: + landext.landapprDetailsId, + assessedById: 'test', + assessedByName: 'test', + dateCreated: 'test', + dateModified: 'test', + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: landOfflineKeyEdit + .currentState!.value['land_qtr'], + yr: landOfflineKeyEdit + .currentState!.value['land_yr'], + appraisedbyName: (landOfflineKeyEdit.currentState!.value['appraised_by_land']?.firstname ?? '') + + ' ' + + (landOfflineKeyEdit + .currentState! + .value['appraised_by_land'] + ?.middlename ?? + '') + + ' ' + + (landOfflineKeyEdit + .currentState! + .value['appraised_by_land'] + ?.lastname ?? + ''), + appraisedbyDate: landOfflineKeyEdit.currentState!.value['app_date_land'] + .toString(), + recommendapprName: (landOfflineKeyEdit + .currentState! + .value['rec_approval_land'] + ?.firstname ?? + '') + + ' ' + + (landOfflineKeyEdit.currentState!.value['rec_approval_land']?.middlename ?? '') + + ' ' + + (landOfflineKeyEdit.currentState!.value['rec_approval_land']?.lastname ?? ''), + recommendapprDate: landOfflineKeyEdit.currentState!.value['rec_date_land'].toString(), + approvedbyName: (landOfflineKeyEdit.currentState!.value['apprvd_by_land']?.firstname ?? '') + ' ' + (landOfflineKeyEdit.currentState!.value['apprvd_by_land']?.middlename ?? '') + ' ' + (landOfflineKeyEdit.currentState!.value['apprvd_by_land']?.lastname ?? ''), + approvedbyDate: landOfflineKeyEdit.currentState!.value['apprvd_by_date_land'].toString(), + memoranda: _memoranda, + swornstatementNo: landOfflineKeyEdit.currentState!.value['sworn_statement_land'], + dateReceived: landOfflineKeyEdit.currentState!.value['date_received_land'].toString(), + entryDateAssessment: landOfflineKeyEdit.currentState!.value['date_of_entry_land'].toString(), + entryDateBy: landOfflineKeyEdit.currentState!.value['by_land']); + + context + .read() + .add(UpdateLandPropertySignatureInfo( + id: landext.id!, + landPropertySignature: ext)); + widget.onSAve(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: const SizedBox( + width: 250, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + ), + const SizedBox( + height: 30, + ), + ], + )), + ); + } + // if (state is Memo) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(const LoadMemoranda()); + // }, + // ); + // } + return Container(); + }, + ); + } + // if (state is SignatoriesErrorState) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context + // .read() + // .add(const LoadSignatories()); + // }, + // ); + // } + return Container(); + }, + ); + } + if (state is LandPropertySignatureInfoErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadSpecificLandPropertySignatureInfo(id: widget.faasId)); + }, + ); + } + return Container(); + }, + ), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/location_and_boundaries_edit_offline.dart b/lib/screens/offline/passo/land/edit/location_and_boundaries_edit_offline.dart new file mode 100644 index 0000000..bf12f2f --- /dev/null +++ b/lib/screens/offline/passo/land/edit/location_and_boundaries_edit_offline.dart @@ -0,0 +1,258 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/edit_land.dart'; + +import '../../../../../model/passo/land_property_boundaries.dart'; +import '../../../../../model/passo/land_property_loc.dart'; +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class LandLocationAndBoundariesOfflineEdit extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandPropertyOwner land; + LandLocationAndBoundariesOfflineEdit(this.PrevBtn, this.NextBtn, this.land); + @override + _LandLocationAndBoundariesOfflineEdit createState() => + _LandLocationAndBoundariesOfflineEdit(); +} + +class _LandLocationAndBoundariesOfflineEdit + extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + // if (state is LandLocationEditLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is LandLocationEditErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificLandPropertyLocationLoaded) { + final landLoc = state.landpropertylocation; + return BlocConsumer( + listener: (context, state) {}, + builder: (context, state) { + if (state is SpecificLandPropertyBoundariesLoaded) { + return FormBuilder( + key: landOfflineKeyEdit, + initialValue: { + 'street': landLoc.street, + 'brgy': landLoc.barangay, + 'municipality': landLoc.municipality, + 'province': landLoc.province, + 'north': state.landpropertyboundaries.north, + 'south': state.landpropertyboundaries.south, + 'east': state.landpropertyboundaries.east, + 'west': state.landpropertyboundaries.west + }, + enabled: true, + onChanged: () { + landOfflineKeyEdit.currentState!.save(); + debugPrint( + landOfflineKeyEdit.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "No. / Street", "", "street")), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Brgy./District", "", "brgy")), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Municipality", "", "municipality"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Province/City", "", "province")) + ]), + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY BOUNDARIES', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "North", "", "north"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "East", "", "east")) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "South", "", "south"), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "West", "", "west")) + ]), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left, + color: Colors.white), + onPressed: () { + widget.PrevBtn(); + }), + CustomButton( + icon: const Icon(Icons.chevron_right, + color: Colors.white), + onPressed: () { + print(widget.land.id); + var boundaries = + LandPropertyBoundaries( + id: widget.land.id, + landapprDetailsId: widget.land.id, + assessedById: '1', + assessedByName: 'Cyril', + sketch: 'None', + dateCreated: 'test', + dateModified: 'test', + north: landOfflineKeyEdit + .currentState?.value['north'], + east: landOfflineKeyEdit + .currentState?.value['east'], + west: landOfflineKeyEdit + .currentState?.value['west'], + south: landOfflineKeyEdit + .currentState?.value['south'], + ); + var location = LandPropertyLoc( + id: widget.land.id, + landapprDetailsId: widget.land.id, + assessedById: '1', + assessedByName: 'Cyril', + dateCreated: 'test', + dateModified: 'test', + street: landOfflineKeyEdit + .currentState?.value['street'], + barangay: landOfflineKeyEdit + .currentState?.value['brgy'], + municipality: landOfflineKeyEdit + .currentState + ?.value['municipality'], + province: landOfflineKeyEdit + .currentState + ?.value['province'], + ); + + context + .read() + .add(UpdateLandPropertyLocation( + landPropertyLocation: + location, + id: widget.land.id!)); + + context + .read< + LandPropertyBoundariesBloc>() + .add(UpdateLandPropertyBoundaries( + landPropertyBoundaries: + boundaries, + id: widget.land.id!)); + + widget.NextBtn(); + }) + ], + ) + ]), + ), + ), + ); + } + + return Container(); + }, + ); + } + ; + + return Container(); + }, + ), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/other_improvements_edit.dart b/lib/screens/offline/passo/land/edit/other_improvements_edit.dart new file mode 100644 index 0000000..99a70d7 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/other_improvements_edit.dart @@ -0,0 +1,314 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/AddOtherImprovementModal.dart'; + +import '../../../../../model/passo/other_improvements.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class OtherImprovementEditPageOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + final int faasId; + OtherImprovementEditPageOffline(this.PrevBtn, this.NextBtn, this.faasId); + @override + _OtherImprovementEditPageOffline createState() => + _OtherImprovementEditPageOffline(); +} + +class _OtherImprovementEditPageOffline + extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteOtherImprovements(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // if (state is OtherImprovementLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is OtherImprovementLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is OtherImprovementErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is OtherImprovementsLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('OTHER IMPROVEMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowOtherImprovement()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Kinds of Tress'), + ), + const DataColumn( + label: Text('Sub-Class / Age'), + ), + const DataColumn( + label: Text('Type of Tree'), + ), + const DataColumn( + label: Text('No.'), + ), + const DataColumn( + label: Text('No. of Productive'), + ), + const DataColumn( + label: Text('No. of Non-Productive'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.otherImprovements.map((dataRow) { + return DataRow( + cells: [ + DataCell( + Text(dataRow.kindsOfTrees ?? "")), + DataCell(Text(dataRow.subclassAge ?? "")), + DataCell(Text(dataRow.fruitBearing == '1' + ? "Fruit Bearing" + : "Non-Fruit Bearing")), + DataCell( + Text(dataRow.quantity.toString())), + DataCell(Text( + dataRow.noOfProductive.toString())), + DataCell(Text(dataRow.noOfNonproductive + .toString()!)), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format( + double.parse(dataRow.unitValue!)) + .toString())), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ) + .format(double.parse( + dataRow.baseMarketval!)) + .toString())), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is OtherImprovementsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadOtherImprovements()); + }); + }); + } + } + if (state is ShowOtherImprovementScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD OTHER IMPROVEMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.topCenter, + child: Container( + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 500), + child: Container( + child: AddOtherImprovementModalEditOffline( + widget.faasId), + ), + ), + ), + ), + ], + ), + ), + ); + } + if (state is OtherImprovementsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadOtherImprovementsEdit( + otherImprovements: const [], + id: widget.faasId)); + }, + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land/edit/value_adjustment_edit.dart b/lib/screens/offline/passo/land/edit/value_adjustment_edit.dart new file mode 100644 index 0000000..0507619 --- /dev/null +++ b/lib/screens/offline/passo/land/edit/value_adjustment_edit.dart @@ -0,0 +1,284 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; +import 'package:unit2/screens/offline/passo/land/edit/AddValueAdjustmentModalOffline.dart'; + +import '../../../../../model/passo/land_value_adjustment.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../utils/text_container.dart'; +import '../../../../../widgets/error_state.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class ValueAdjustmentEditPageOffline extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + final int faasId; + ValueAdjustmentEditPageOffline(this.PrevBtn, this.NextBtn, this.faasId); + @override + _ValueAdjustmentEditPageOffline createState() => + _ValueAdjustmentEditPageOffline(); +} + +class _ValueAdjustmentEditPageOffline + extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context.read().add(DeleteValueAdjustment(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // if (state is LandValueAdjustmentsLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandValueAdjustmentsLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is LandValueAdjustmentsErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + final state = context.watch().state; + if (state is ValueAdjustmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('VALUE ADJUSTMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowValueAdjustment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Adjustment Factors'), + ), + const DataColumn( + label: Text('% Adjustment'), + ), + const DataColumn( + label: Text('Value Adjustment'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.valueAdjustment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow.baseMarketval!)))), + DataCell( + Text(dataRow.adjustmentFactors!)), + DataCell(Text(dataRow.adjustment!)), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow.valueAdjustment!)))), + DataCell(Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + double.parse(dataRow.marketValue!)))), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + confirmAlertWithCancel( + context, + () => deleteItem(dataRow.id!), + () => null, + 'Delete Item?', + "Are you sure you want to delete this item?"); + }, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is ValueAdjustmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadValueAdjustmentEdit( + valueAdjustment: [], + id: widget.faasId)); + }); + }); + } + } + if (state is ShowValueAdjustmentcreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD VALUE ADJUSTMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddLandValueAdjustmentEditOfflineModal()) + ], + ), + ), + ); + } + if (state is ValueAdjustmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadValueAdjustmentEdit( + valueAdjustment: const [], + id: widget.faasId)); + }, + ); + } + return Container(); + }), + ), + ); + } +} diff --git a/lib/screens/offline/passo/land_home_offline.dart b/lib/screens/offline/passo/land_home_offline.dart new file mode 100644 index 0000000..1a3c946 --- /dev/null +++ b/lib/screens/offline/passo/land_home_offline.dart @@ -0,0 +1,439 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/trees_improvements/trees_improvements_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_appraisal/land_property_appraisal_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_boundaries/land_property_boundaries_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_location/land_property_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/model/passo/land_property_owner.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; +import 'package:unit2/screens/offline/passo/land/edit/edit_land.dart'; + +import '../../../bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/land_classification/land_classification_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/location/location_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; +import '../../../bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; +import '../../../theme-data.dart/colors.dart'; +import '../../../utils/alerts.dart'; +import '../../../widgets/empty_data.dart'; + +class LandHomeOffline extends StatelessWidget { + final OfflineProfile offlineProfile; + const LandHomeOffline(this.offlineProfile, {super.key}); + + @override + Widget build(BuildContext context) { + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandPropertyOwner(id: itemId)); + } + + void triggerLoadBldgFaas() { + final myBloc = BlocProvider.of(context); + myBloc.add(FetchTodos()); + } + + void triggerLoadLandFaas() { + final myBloc = BlocProvider.of(context); + myBloc.add(LoadLandPropertyOwner()); + } + + return Scaffold( + body: BlocBuilder( + builder: (context, state) { + if (state is LandPropertyOwnerLoaded) { + if (state.landPropertyOwner.isNotEmpty) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( + children: [ + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: state.landPropertyOwner.length, + itemBuilder: (BuildContext context, int index) { + return _listCard( + state.landPropertyOwner[index], + context, + index, + deleteItem, + state.landPropertyOwner.length); + }, + ), + ), + ], + ), + ); + } else { + return const EmptyData( + message: + "You don't have any building faas added. Please click + to add"); + } + } + return Container(); + }, + ), + floatingActionButton: SpeedDial( +//provide here features of your parent FAB + icon: Icons.add, + backgroundColor: primary, + heroTag: null, + useRotationAnimation: true, + activeIcon: Icons.close, + animationCurve: Curves.elasticInOut, + children: [ + SpeedDialChild( + child: const Icon( + Icons.maps_home_work_rounded, + color: primary, + ), + label: 'Building & Other Structure', + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider(providers: [ + BlocProvider( + create: (context) => CrudBloc(), + ), + BlocProvider( + create: (context) => AdditionalItemsOfflineBloc(), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => BarangayAdminBloc() + ..add( + const LoadBarangayInMunicipality(cityCode: '01')), + ), + BlocProvider( + create: (context) => ClassComponentsAdminBloc() + ..add(const LoadClassComponents()), + ), + BlocProvider( + create: (context) => UnitConstructionAdminBloc() + ..add(const LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => SignatoriesAdminBloc() + ..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider(create: (context) => LandrefLocationBloc()), + BlocProvider(create: (context) => LocationBloc()), + BlocProvider( + create: (context) => GeneralDescriptionBloc()), + BlocProvider( + create: (context) => StructuralMaterialOfflineBloc()), + BlocProvider( + create: (context) => AdditionalItemsOfflineBloc() + ..add(const LoadAdditionalItems())), + BlocProvider( + create: (context) => BldgAppraisalOfflineBloc()), + BlocProvider( + create: (context) => BldgAssessmentOfflineBloc()), + ], child: AddBuilding(triggerLoadBldgFaas, offlineProfile)); + })); + }), + SpeedDialChild( + child: const Icon( + Icons.forest_rounded, + color: primary, + ), + label: 'Land/Other Improvements', + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider(providers: [ + BlocProvider( + create: (context) => LandPropertyOwnerBloc(), + ), + BlocProvider( + create: (context) => LandPropertyAppraisalBloc() + ..add(const LoadLandPropertyAppraisal()), + ), + BlocProvider( + create: (context) => LandClassificationBloc() + ..add(const LoadLandClassification()), + ), + BlocProvider( + create: (context) => LandSubclassificationBloc() + ..add(const LoadLandSubClassification()), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => OtherImprovementsBloc() + ..add(const LoadOtherImprovements()), + ), + BlocProvider( + create: (context) => TreesImprovementsBloc() + ..add(const LoadTreesImprovements()), + ), + BlocProvider( + create: (context) => ValueAdjustmentBloc() + ..add(const LoadValueAdjustment()), + ), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(const LoadTypeOfRoad()), + ), + BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(const LoadTypeOfLocation()), + ), + BlocProvider( + create: (context) => LandPropertyAssessmentBloc() + ..add(const LoadLandPropertyAssessment()), + ), + BlocProvider( + create: (context) => LandPropertySignatureBloc()), + BlocProvider( + create: (context) => + SignatoriesAdminBloc()..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider( + create: (context) => LandPropertyLocationBloc(), + ), + BlocProvider( + create: (context) => LandPropertyBoundariesBloc(), + ), + BlocProvider( + create: (context) => TreesImprovementsBloc() + ..add(const LoadTreesImprovements()), + ), + ], child: AddLandOffline(triggerLoadLandFaas)); + })); + }, + ), + SpeedDialChild( + child: const Icon( + Icons.precision_manufacturing_rounded, + color: primary, + ), + label: 'Machinery', + onTap: () {}, + ), + // SpeedDialChild(a + // child: const Icon( + // Icons.report_problem_rounded, + // color: primary, + // ), + // label: 'Testing Screen', + // onTap: () { + // Navigator.of(context) + // .push(MaterialPageRoute(builder: (ctx) => Multi_Select())); + // }, + // ), + ]), + ); + } +} + +Card _listCard(LandPropertyOwner landPropertyOwner, context, index, deleteItem, + bldgLength) { + return Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + //set border radius more than 50% of height and width to make circle + ), + margin: const EdgeInsets.all(5.0), + elevation: 5, + shadowColor: Colors.grey, + child: Padding( + padding: const EdgeInsets.all(15.0), + child: InkWell( + onTap: () async { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => + LandPropertyOwnerBloc()..add(LoadLandPropertyOwner()), + ), + BlocProvider( + create: (context) => LandPropertyLocationBloc() + ..add(FetchSingleLandPropertyLocation( + id: landPropertyOwner.id!)), + ), + BlocProvider( + create: (context) => LandPropertyBoundariesBloc() + ..add(FetchSingleLandPropertyBoundaries( + id: landPropertyOwner.id!)), + ), + BlocProvider( + create: (context) => LandPropertyAppraisalBloc() + ..add(LoadLandPropertyAppraisalEdit( + id: landPropertyOwner.id!, landAppr: [])), + ), + BlocProvider( + create: (context) => LandPropertyBoundariesBloc() + ..add(FetchSingleLandPropertyBoundaries( + id: landPropertyOwner.id!)), + ), + BlocProvider( + create: (context) => OtherImprovementsBloc() + ..add(LoadOtherImprovementsEdit( + otherImprovements: [], + id: landPropertyOwner.id)), + ), + BlocProvider( + create: (context) => ValueAdjustmentBloc() + ..add(LoadValueAdjustmentEdit( + valueAdjustment: [], + id: landPropertyOwner.id)), + ), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(const LoadTypeOfRoad()), + ), + BlocProvider( + create: (context) => LandClassificationBloc() + ..add(const LoadLandClassification()), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => LandSubclassificationBloc() + ..add(const LoadLandSubClassification()), + ), + BlocProvider( + create: (context) => LandPropertyAssessmentBloc() + ..add(LoadLandPropertyAssessmentEdit( + landPropertyAssessment: [], + id: landPropertyOwner.id)), + ), + BlocProvider( + create: (context) => LandPropertySignatureBloc() + ..add(LoadSpecificLandPropertySignatureInfo( + id: landPropertyOwner.id!)), + ), + BlocProvider( + create: (context) => + SignatoriesAdminBloc()..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider( + create: (context) => TreesImprovementsBloc() + ..add(const LoadTreesImprovements()), + ), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(const LoadTypeOfRoad()), + ), + BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(const LoadTypeOfLocation()), + ), + ], + child: EditLandOffline( + index: index, + faas: landPropertyOwner, + title: "Land FAAS", + )); + })); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 40, // Adjust this to your desired size + height: 40, // Adjust this to your desired size + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: primary, // Border color + width: 1, // Border width + ), + ), + child: const Icon( + Icons.forest_rounded, + color: primary, // Icon color + ), + ), + const SizedBox( + width: 20, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${landPropertyOwner.owner}', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + SizedBox(height: 5), + Text( + '${landPropertyOwner.tdn} - ${landPropertyOwner.id}', + style: TextStyle( + fontSize: 13, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + IconButton( + onPressed: () { + confirmAlertWithCancel( + context, + () => deleteItem(landPropertyOwner.id), + () => null, + 'Delete FAAS Item?', + "Are you sure you want to delete this item?"); + }, + icon: const Icon(Icons.delete_rounded), + color: primary, + ), + ], + ), + ), + ), + ); +} diff --git a/lib/screens/offline/passo/passo_main_dashboard.dart b/lib/screens/offline/passo/passo_main_dashboard.dart index 892dbec..ab2ca2a 100644 --- a/lib/screens/offline/passo/passo_main_dashboard.dart +++ b/lib/screens/offline/passo/passo_main_dashboard.dart @@ -3,6 +3,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; import 'package:fluttericon/font_awesome5_icons.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/admin/admin_main_screen.dart'; import 'package:unit2/screens/offline/passo/passo_offline_dashboard.dart'; @@ -10,7 +11,8 @@ import '../../../theme-data.dart/colors.dart'; import '../../unit2/homepage.dart/components/dashboard/shared_card_label.dart'; class PassoOfflineMainScreen extends StatelessWidget { - const PassoOfflineMainScreen({super.key}); + final OfflineProfile offlineProfile; + const PassoOfflineMainScreen(this.offlineProfile, {super.key}); @override Widget build(BuildContext context) { @@ -45,16 +47,16 @@ class PassoOfflineMainScreen extends StatelessWidget { ontap: () { Navigator.push(context, MaterialPageRoute(builder: ((context) { - return PassoOfflineDashBoard(); + return PassoOfflineDashBoard(offlineProfile); }))); }), CardLabel( - icon: FontAwesome5.eye, + icon: FontAwesome5.tools, title: "Super Admin", ontap: () { Navigator.push(context, MaterialPageRoute(builder: ((context) { - return PassoOfflineDashBoard(); + return PassoOfflineDashBoard(offlineProfile); }))); }) ]))); diff --git a/lib/screens/offline/passo/passo_offline_dashboard.dart b/lib/screens/offline/passo/passo_offline_dashboard.dart index 45a1e20..c9eb2e0 100644 --- a/lib/screens/offline/passo/passo_offline_dashboard.dart +++ b/lib/screens/offline/passo/passo_offline_dashboard.dart @@ -1,13 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building_home_offline.dart'; +import 'package:unit2/screens/offline/passo/land_home_offline.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/widgets/empty_data.dart'; import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; class PassoOfflineDashBoard extends StatefulWidget { + final OfflineProfile offlineProfile; + + const PassoOfflineDashBoard(this.offlineProfile, {super.key}); + @override _PassoOfflineDashBoard createState() => _PassoOfflineDashBoard(); } @@ -42,10 +49,12 @@ class _PassoOfflineDashBoard extends State { children: [ BlocProvider( create: (context) => CrudBloc()..add(FetchTodos()), - child: BuildingHomeOffline(), + child: BuildingHomeOffline(widget.offlineProfile), ), - EmptyData( - message: "Sorry, this page is under construction.", + BlocProvider( + create: (context) => + LandPropertyOwnerBloc()..add(LoadLandPropertyOwner()), + child: LandHomeOffline(widget.offlineProfile), ), EmptyData( message: "Sorry, this page is under construction.", diff --git a/lib/screens/passo/Building/add_building_components/property_assessment.dart b/lib/screens/passo/Building/add_building_components/property_assessment.dart index 0084998..ed3c38a 100644 --- a/lib/screens/passo/Building/add_building_components/property_assessment.dart +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -489,14 +489,12 @@ class _PropertyAssessmentPage extends State { marketValue: '0.00', assessmentLevel: '0.00', assessedValue: '0.00', - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse(formKey - .currentState!.value['qtr'] ?? - '0'), // Replace null with '0' - yr: int.parse( - formKey.currentState!.value['yr'] ?? - '0'), // Replace null with '0' + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: formKey.currentState!.value[ + 'qtr'], // Replace null with '0' + yr: formKey.currentState!.value[ + 'yr'], // Replace null with '0' appraisedbyName: (formKey .currentState! .value['appraised_by'] @@ -514,11 +512,9 @@ class _PropertyAssessmentPage extends State { .value['appraised_by'] ?.lastname ?? ''), - appraisedbyDate: formKey.currentState! - .value['app_date'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date + appraisedbyDate: formKey + .currentState!.value['app_date'], + // Replace null with current date recommendapprName: (formKey .currentState! .value['rec_approval'] @@ -536,11 +532,9 @@ class _PropertyAssessmentPage extends State { .value['rec_approval'] ?.lastname ?? ''), - recommendapprDate: formKey.currentState! - .value['rec_date'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date + recommendapprDate: formKey + .currentState!.value['rec_date'], + // Replace null with current date approvedbyName: (formKey .currentState! .value['apprvd_by'] @@ -563,16 +557,12 @@ class _PropertyAssessmentPage extends State { .value['sworn_statement'] ?? '', // Replace null with an empty string dateReceived: formKey.currentState! - .value['date_received'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date + .value['date_received'], + // Replace null with current date entryDateAssessment: formKey - .currentState! - .value['date_of_entry'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date + .currentState! + .value['date_of_entry'], + // Replace null with current date entryDateBy: formKey .currentState!.value['by'] ?? '', // Replace null with an empty string diff --git a/lib/screens/passo/Building/edit_building/additional_items.dart b/lib/screens/passo/Building/edit_building/additional_items.dart index 070b54a..cdc0c20 100644 --- a/lib/screens/passo/Building/edit_building/additional_items.dart +++ b/lib/screens/passo/Building/edit_building/additional_items.dart @@ -149,7 +149,7 @@ class _AdditionalItemEditPage extends State { child: Container( height: 30, width: 30, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.red, ), diff --git a/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart b/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart index 3f6e6b4..a445d65 100644 --- a/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart +++ b/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart @@ -292,7 +292,8 @@ class _AddOtherImprovementModal extends State { .toString(), noOfProductive: pr_qty, noOfNonproductive: nonpr_qty, - fruitBearing: _fruitBearing); + fruitBearing: + _fruitBearing == true ? '1' : '0'); context.read().add( AddOtherImprovement( diff --git a/lib/screens/passo/Land/add_land/location_and_boundaries.dart b/lib/screens/passo/Land/add_land/location_and_boundaries.dart index e81d200..4c40f29 100644 --- a/lib/screens/passo/Land/add_land/location_and_boundaries.dart +++ b/lib/screens/passo/Land/add_land/location_and_boundaries.dart @@ -127,10 +127,10 @@ class _LandLocationAndBoundaries extends State { province: landKey.currentState?.value['province'], ); - context.read() - ..add( - UpdateLandBoundaries(land_boundaries: boundaries)) - ..add(UpdateLandLoc(land_loc: location)); + // context.read() + // ..add( + // UpdateLandBoundaries(land_boundaries: boundaries)) + // ..add(UpdateLandLoc(land_loc: location)); widget.NextBtn(); }) diff --git a/lib/screens/passo/Land/add_land/other_improvements.dart b/lib/screens/passo/Land/add_land/other_improvements.dart index 45b99aa..d84bcd2 100644 --- a/lib/screens/passo/Land/add_land/other_improvements.dart +++ b/lib/screens/passo/Land/add_land/other_improvements.dart @@ -81,14 +81,14 @@ class _OtherImprovementPage extends State { .read() .add(ShowOtherImprovement()); }, - child: Row( + child: const Row( mainAxisSize: MainAxisSize.min, children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( + Text('ADD ITEM'), // <-- Text + SizedBox( width: 5, ), - const Icon( + Icon( // <-- Icon Icons.add, size: 24.0, @@ -135,7 +135,7 @@ class _OtherImprovementPage extends State { cells: [ DataCell(Text(dataRow.kindsOfTrees!)), DataCell(Text(dataRow.subclassAge!)), - DataCell(Text(dataRow.fruitBearing! + DataCell(Text(dataRow.fruitBearing == '1' ? "Fruit Bearing" : "Non-Fruit Bearing")), DataCell( @@ -261,11 +261,11 @@ class _OtherImprovementPage extends State { return ConstrainedBox( constraints: BoxConstraints(maxHeight: 1000.0), child: AlertDialog( - insetPadding: EdgeInsets.symmetric( + insetPadding: const EdgeInsets.symmetric( horizontal: 20.0, vertical: 10.0, ), - title: Text( + title: const Text( 'ADD OTHER IMPROVEMENTS', textAlign: TextAlign.center, ), diff --git a/lib/screens/passo/Land/add_land/property_assessment_cont.dart b/lib/screens/passo/Land/add_land/property_assessment_cont.dart index cf2f93f..c44bd06 100644 --- a/lib/screens/passo/Land/add_land/property_assessment_cont.dart +++ b/lib/screens/passo/Land/add_land/property_assessment_cont.dart @@ -505,16 +505,13 @@ class _LandSignatories extends State { var ext = LandExt( landapprDetailsId: tempID.getInt('landid')! - 1, - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse(landKey - .currentState!.value['land_qtr']), - yr: int.parse(landKey - .currentState!.value['land_yr']), - appraisedbyName: landKey - .currentState! - .value['appraised_by_land'] - .firstname + + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: landKey + .currentState!.value['land_qtr'], + yr: landKey + .currentState!.value['land_yr'], + appraisedbyName: landKey.currentState!.value['appraised_by_land'].firstname + ' ' + landKey .currentState! @@ -527,16 +524,24 @@ class _LandSignatories extends State { .lastname, appraisedbyDate: landKey .currentState!.value['app_date_land'], - recommendapprName: landKey + recommendapprName: landKey.currentState!.value['rec_approval_land'].firstname + + ' ' + + landKey .currentState! .value['rec_approval_land'] - .firstname + + .middlename + ' ' + - landKey.currentState!.value['rec_approval_land'].middlename + + landKey + .currentState! + .value['rec_approval_land'] + .lastname, + recommendapprDate: landKey + .currentState!.value['rec_date_land'], + approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname + ' ' + - landKey.currentState!.value['rec_approval_land'].lastname, - recommendapprDate: landKey.currentState!.value['rec_date_land'], - approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname + ' ' + landKey.currentState!.value['apprvd_by_land'].middlename + ' ' + landKey.currentState!.value['apprvd_by_land'].lastname, + landKey.currentState!.value['apprvd_by_land'].middlename + + ' ' + + landKey.currentState!.value['apprvd_by_land'].lastname, approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'], memoranda: _memoranda, swornstatementNo: landKey.currentState!.value['sworn_statement_land'], diff --git a/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart b/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart index 30df942..65582a8 100644 --- a/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart +++ b/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart @@ -290,7 +290,8 @@ class _AddOtherImprovementEditModal .toString(), noOfProductive: pr_qty, noOfNonproductive: nonpr_qty, - fruitBearing: _fruitBearing); + fruitBearing: + _fruitBearing == true ? "1" : "0"); context.read().add( AddOtherImprovement( diff --git a/lib/screens/passo/Land/edit_land/other_improvements_edit.dart b/lib/screens/passo/Land/edit_land/other_improvements_edit.dart index 13cf33c..4d814e0 100644 --- a/lib/screens/passo/Land/edit_land/other_improvements_edit.dart +++ b/lib/screens/passo/Land/edit_land/other_improvements_edit.dart @@ -140,7 +140,7 @@ class _OtherImprovementEditPage extends State { cells: [ DataCell(Text(dataRow.kindsOfTrees!)), DataCell(Text(dataRow.subclassAge!)), - DataCell(Text(dataRow.fruitBearing! + DataCell(Text(dataRow.fruitBearing == '1' ? "Fruit Bearing" : "Non-Fruit Bearing")), DataCell( diff --git a/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart b/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart index 4d43bb5..3885c4d 100644 --- a/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart +++ b/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart @@ -549,13 +549,16 @@ class _LandSignatoriesEdit extends State { var ext = LandExt( landapprDetailsId: tempID.getInt('landid')! - 1, - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse(landEditKey - .currentState!.value['land_qtr']), - yr: int.parse(landEditKey - .currentState!.value['land_yr']), - appraisedbyName: landEditKey.currentState!.value['appraised_by_land'].firstname + + taxable: isTaxable == true ? '1' : '0', + exempt: isExempt == true ? '1' : '0', + qtr: landEditKey + .currentState!.value['land_qtr'], + yr: landEditKey + .currentState!.value['land_yr'], + appraisedbyName: landEditKey + .currentState! + .value['appraised_by_land'] + .firstname + ' ' + landEditKey .currentState! @@ -569,11 +572,20 @@ class _LandSignatoriesEdit extends State { appraisedbyDate: landEditKey .currentState! .value['app_date_land'], - recommendapprName: landEditKey.currentState!.value['rec_approval_land'].firstname + + recommendapprName: landEditKey + .currentState! + .value['rec_approval_land'] + .firstname + ' ' + - landEditKey.currentState!.value['rec_approval_land'].middlename + + landEditKey + .currentState! + .value['rec_approval_land'] + .middlename + ' ' + - landEditKey.currentState!.value['rec_approval_land'].lastname, + landEditKey + .currentState! + .value['rec_approval_land'] + .lastname, recommendapprDate: landEditKey.currentState!.value['rec_date_land'], approvedbyName: landEditKey.currentState!.value['apprvd_by_land'].firstname + ' ' + landEditKey.currentState!.value['apprvd_by_land'].middlename + ' ' + landEditKey.currentState!.value['apprvd_by_land'].lastname, approvedbyDate: landEditKey.currentState!.value['apprvd_by_date_land'], diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart index e31c053..8901e3d 100644 --- a/lib/screens/passo/building_home.dart +++ b/lib/screens/passo/building_home.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart'; import 'package:unit2/bloc/passo/barangay/barangay_bloc.dart'; import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; @@ -42,16 +43,12 @@ import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_appraisal_edit.dart'; import 'package:unit2/model/passo/property_assessment_edit.dart'; import 'package:unit2/model/passo/property_info.dart'; -import 'package:unit2/model/passo/structural_materials_ii.dart'; import 'package:unit2/model/passo/structureMaterial.dart'; import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; import 'package:unit2/screens/passo/Building/edit_building.dart'; import 'package:unit2/screens/passo/Land/add_land.dart'; -import 'package:unit2/screens/passo/Test%20Envi/multi_dropdown.dart'; -import 'package:unit2/screens/passo/Test%20Envi/speed_dial.dart'; import 'package:unit2/theme-data.dart/colors.dart'; -import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/error_state.dart'; @@ -190,6 +187,9 @@ class BuildingHome extends StatelessWidget { create: (context) => ClassComponentsBloc()..add(LoadClassComponents()), ), + BlocProvider( + create: (context) => BuildingAndStructureBloc(), + ), BlocProvider( create: (context) => UnitConstructBloc()..add(LoadUnitConstruct()), diff --git a/lib/sevices/offline/offline_passo/admin/api_services/land_classification_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/land_classification_api_services.dart new file mode 100644 index 0000000..f14f4b9 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/land_classification_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class LandClassificationAdminApiServices { + static final LandClassificationAdminApiServices _instance = + LandClassificationAdminApiServices(); + static LandClassificationAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getLandClassification(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/land_sub_classification_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/land_sub_classification_api_services.dart new file mode 100644 index 0000000..e91bb45 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/land_sub_classification_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class LandSubClassificationAdminApiServices { + static final LandSubClassificationAdminApiServices _instance = + LandSubClassificationAdminApiServices(); + static LandSubClassificationAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getLandSubClassification(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/trees_improvements_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/trees_improvements_api_services.dart new file mode 100644 index 0000000..8edb94c --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/trees_improvements_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class TreesImprovementsAdminApiServices { + static final TreesImprovementsAdminApiServices _instance = + TreesImprovementsAdminApiServices(); + static TreesImprovementsAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getTreesImprovements(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/type_of_location.dart b/lib/sevices/offline/offline_passo/admin/api_services/type_of_location.dart new file mode 100644 index 0000000..f03a510 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/type_of_location.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class TypeOfLocationAdminApiServices { + static final TypeOfLocationAdminApiServices _instance = + TypeOfLocationAdminApiServices(); + static TypeOfLocationAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getTypeOfLocation(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/type_of_road_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/type_of_road_api_services.dart new file mode 100644 index 0000000..bba5b0d --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/type_of_road_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class TypeOfRoadAdminApiServices { + static final TypeOfRoadAdminApiServices _instance = + TypeOfRoadAdminApiServices(); + static TypeOfRoadAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getTypeOfRoad(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/value_adjustments.dart b/lib/sevices/offline/offline_passo/admin/api_services/value_adjustments.dart new file mode 100644 index 0000000..de8ba33 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/value_adjustments.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/urls.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:http/http.dart' as http; + +class ValueAdjustmentsAdminApiServices { + static final ValueAdjustmentsAdminApiServices _instance = + ValueAdjustmentsAdminApiServices(); + static ValueAdjustmentsAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getValueAdjustmentss(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart index cc29fd9..20d4ba9 100644 --- a/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart +++ b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart @@ -6,9 +6,13 @@ import 'package:path/path.dart'; import 'package:unit2/model/passo/bldg_loc.dart'; import 'package:unit2/model/passo/city.dart'; import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; import 'package:unit2/model/passo/signatories.dart'; import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/model/passo/type_of_road.dart'; import 'package:unit2/model/passo/unit_construct.dart'; import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/urls.dart'; @@ -16,13 +20,23 @@ import 'package:http/http.dart' as http; import '../../../../../model/passo/additional_items.dart'; import '../../../../../model/passo/barangay.dart'; +import '../../../../../model/passo/building_and_structure.dart'; import '../../../../../model/passo/class_components _offline.dart'; import '../../../../../model/passo/general_description.dart'; +import '../../../../../model/passo/land_appr.dart'; +import '../../../../../model/passo/land_classification.dart'; +import '../../../../../model/passo/land_ext.dart'; +import '../../../../../model/passo/land_property_loc.dart'; +import '../../../../../model/passo/land_property_owner.dart'; +import '../../../../../model/passo/land_subclassification.dart'; +import '../../../../../model/passo/land_value_adjustment.dart'; import '../../../../../model/passo/memoranda.dart'; import '../../../../../model/passo/property_appraisal.dart'; import '../../../../../model/passo/property_assessment.dart'; import '../../../../../model/passo/property_info.dart'; import '../../../../../model/passo/structureMaterial.dart'; +import '../../../../../model/passo/trees_improvements.dart'; +import '../../../../../model/passo/type_of_location.dart'; class SQLServices { static final SQLServices instance = SQLServices._init(); @@ -48,7 +62,8 @@ class SQLServices { CREATE TABLE municipalities ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, cityCode TEXT NOT NULL, - cityDescription TEXT NOT NULL + cityDescription TEXT NOT NULL, + gen_code TEXT ) '''); await db.execute(''' @@ -57,7 +72,8 @@ class SQLServices { barangayId INTEGER NOT NULL, barangayCode TEXT NOT NULL, cityCode TEXT NOT NULL, - barangayDescription TEXT NOT NULL + barangayDescription TEXT NOT NULL, + gen_code TEXT ) '''); @@ -79,7 +95,8 @@ class SQLServices { maxSpacing TEXT NOT NULL, roughFinish TEXT NOT NULL, highFinish TEXT NOT NULL, - withoutBucc INTEGER NOT NULL + withoutBucc INTEGER NOT NULL, + gen_code TEXT ) '''); @@ -88,7 +105,8 @@ class SQLServices { id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, bldgType TEXT NOT NULL, building TEXT NOT NULL, - unitValue TEXT NOT NULL + unitValue TEXT NOT NULL, + gen_code TEXT ) '''); @@ -98,7 +116,8 @@ class SQLServices { signatoryId INTEGER NOT NULL, firstname TEXT NOT NULL, middlename TEXT NOT NULL, - lastname TEXT NOT NULL + lastname TEXT NOT NULL, + gen_code TEXT ) '''); @@ -106,7 +125,71 @@ class SQLServices { CREATE TABLE memoranda ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, code TEXT NOT NULL, - memoranda TEXT NOT NULL + memoranda TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_classification ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + classificationCode TEXT NOT NULL, + description TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_subclassification ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + classificationId INTEGER NOT NULL, + cityCode TEXT NOT NULL, + subclassCode TEXT NOT NULL, + subclassDescription TEXT NOT NULL, + baseUnitMarketval TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE trees_improvement ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + improvement TEXT NOT NULL, + pricePerTree TEXT NOT NULL, + subclassCode TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE type_of_location ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + distanceKm TEXT NOT NULL, + allRoadTypes TEXT NOT NULL, + localTradingCenter TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE type_of_road ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + roadType TEXT NOT NULL, + deduction TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE value_adjustments ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + baseMarketval TEXT NOT NULL, + adjustmentFactors TEXT NOT NULL, + adjustment TEXT NOT NULL, + valueAdjustment TEXT NOT NULL, + marketValue TEXT NOT NULL, + gen_code TEXT ) '''); @@ -126,7 +209,10 @@ class SQLServices { adminTin TEXT NOT NULL, faasType TEXT NOT NULL, assessedById TEXT NOT NULL, - assessedByName TEXT NOT NULL + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + gen_code TEXT ) '''); @@ -144,7 +230,8 @@ class SQLServices { tdn TEXT NOT NULL, area TEXT NOT NULL, surveyNo TEXT NOT NULL, - blkNo TEXT NOT NULL + blkNo TEXT NOT NULL, + gen_code TEXT ) '''); @@ -159,7 +246,8 @@ class SQLServices { street TEXT NOT NULL, barangay TEXT NOT NULL, municipality TEXT NOT NULL, - province TEXT NOT NULL + province TEXT NOT NULL, + gen_code TEXT ) '''); @@ -188,7 +276,33 @@ class SQLServices { area4Thfloor TEXT NOT NULL, totalFloorArea TEXT NOT NULL, floorSketch TEXT NOT NULL, - actualUse TEXT NOT NULL + actualUse TEXT NOT NULL, + unitValue TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE bldg_and_structure ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + bldgType TEXT NOT NULL, + strucType TEXT NOT NULL, + description TEXT NOT NULL, + actualUse TEXT NOT NULL, + floorCount TEXT NOT NULL, + bldgArea TEXT NOT NULL, + unitValue TEXT NOT NULL, + buccPercentage TEXT NOT NULL, + depRate TEXT NOT NULL, + marketValue TEXT NOT NULL, + depAmount TEXT NOT NULL, + adjustedMarketValue TEXT NOT NULL, + gen_code TEXT ) '''); @@ -196,13 +310,18 @@ class SQLServices { CREATE TABLE structural_materials ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, foundation TEXT NOT NULL, columns TEXT NOT NULL, beams TEXT NOT NULL, trussFraming TEXT NOT NULL, roof TEXT NOT NULL, flooring TEXT NOT NULL, - walls TEXT NOT NULL + walls TEXT NOT NULL, + gen_code TEXT ) '''); @@ -224,7 +343,8 @@ class SQLServices { totalpercentDepreciation TEXT NOT NULL, marketValue TEXT NOT NULL, totalArea TEXT NOT NULL, - actualUse TEXT NOT NULL + actualUse TEXT NOT NULL, + gen_code TEXT ) '''); @@ -232,6 +352,10 @@ class SQLServices { CREATE TABLE bldg_assessment ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, actualUse TEXT NOT NULL, marketValue TEXT NOT NULL, assessmentLevel TEXT NOT NULL, @@ -249,7 +373,8 @@ class SQLServices { swornstatementNo TEXT NOT NULL, dateReceived TEXT NOT NULL, entryDateAssessment TEXT NOT NULL, - entryDateBy TEXT NOT NULL + entryDateBy TEXT NOT NULL, + gen_code TEXT ) '''); @@ -271,7 +396,139 @@ class SQLServices { secondhand TEXT NOT NULL, paintedUnitval TEXT NOT NULL, secondhandUnitval TEXT NOT NULL, - actualUse TEXT NOT NULL + actualUse TEXT NOT NULL, + + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_owner ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + transCode TEXT NOT NULL, + tdn TEXT NOT NULL, + pin TEXT NOT NULL, + cloaNo TEXT NOT NULL, + dated TEXT NOT NULL, + surveyNo TEXT NOT NULL, + lotNo TEXT NOT NULL, + blkNo TEXT NOT NULL, + owner TEXT NOT NULL, + address TEXT NOT NULL, + telno TEXT NOT NULL, + tin TEXT NOT NULL, + adminUser TEXT NOT NULL, + adminTelno TEXT NOT NULL, + adminAddress TEXT NOT NULL, + adminTin TEXT NOT NULL, + faasType TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_location ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + street TEXT NOT NULL, + municipality TEXT NOT NULL, + barangay TEXT NOT NULL, + province TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_boundaries ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + north TEXT NOT NULL, + east TEXT NOT NULL, + south TEXT NOT NULL, + west TEXT NOT NULL, + sketch TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_appr ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + classification TEXT NOT NULL, + subClass TEXT NOT NULL, + area TEXT NOT NULL, + unitValue TEXT NOT NULL, + baseMarketval TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_other_improvements ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + kindsOfTrees TEXT NOT NULL, + subclassAge TEXT NOT NULL, + quantity INTEGER NOT NULL, + unitValue TEXT NOT NULL, + baseMarketval TEXT NOT NULL, + noOfProductive INTEGER NOT NULL, + noOfNonproductive INTEGER NOT NULL, + fruitBearing TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_assessment ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + actualUse TEXT NOT NULL, + marketval TEXT NOT NULL, + assessmentLevel TEXT NOT NULL, + assessedValue TEXT NOT NULL, + totalMarketval TEXT NOT NULL, + totalAssessedval TEXT NOT NULL, + gen_code TEXT + ) + '''); + + await db.execute(''' + CREATE TABLE land_property_ext ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + landapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + taxable TEXT NOT NULL, + exempt TEXT NOT NULL, + qtr TEXT NOT NULL, + yr TEXT NOT NULL, + appraisedbyName TEXT NOT NULL, + appraisedbyDate TEXT NOT NULL, + recommendapprName TEXT NOT NULL, + recommendapprDate TEXT NOT NULL, + approvedbyName TEXT NOT NULL, + approvedbyDate TEXT NOT NULL, + memoranda TEXT NOT NULL, + swornstatementNo TEXT NOT NULL, + dateReceived TEXT NOT NULL, + entryDateAssessment TEXT NOT NULL, + entryDateBy TEXT NOT NULL, + gen_code TEXT ) '''); } @@ -453,6 +710,156 @@ class SQLServices { return result.map((json) => Memoranda.fromJson2(json)).toList(); } + // Land Classification + + Future createLandClassification( + LandClassification landClass) async { + final db = await instance.database; + + final data = { + // "id": landClass.id, + "classificationCode": landClass.classificationCode, + "description": landClass.description + }; + final id = await db.insert('land_classification', data); + return landClass.copy(id: id); + } + + Future> readAllLandClassification() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('land_classification', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => LandClassification.fromJson2(json)).toList(); + } + + //Land SubClassification + + Future createLandSubClassification( + LandSubClassification landSubClass) async { + final db = await instance.database; + + final data = { + "id": landSubClass.id, + "classificationId": landSubClass.classificationId, + "cityCode": landSubClass.cityCode, + "subclassCode": landSubClass.subclassCode, + "subclassDescription": landSubClass.subclassDescription, + "baseUnitMarketval": landSubClass.baseUnitMarketval + }; + final id = await db.insert('land_subclassification', data); + return landSubClass.copy(id: id); + } + + Future> readAllLandSubClassification() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('land_subclassification', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => LandSubClassification.fromJson2(json)).toList(); + } + + Future> readSpecificLandSubClassification( + cityCode, classificationId) async { + final db = await instance.database; + const orderBy = 'id'; + + // Use placeholders for the WHERE clause and provide the values separately. + final params = [cityCode, classificationId]; // List of values to substitute + + final result = await db.query('land_subclassification', + orderBy: orderBy, + where: 'cityCode = ? AND classificationId = ?', + whereArgs: params); + + print('result'); + print(cityCode); + print(classificationId); + print(result.toString()); + + return result.map((json) => LandSubClassification.fromJson2(json)).toList(); + } + + //Trees Improvements + + Future createTreesImprovements( + TreesImprovements treesImprovements) async { + final db = await instance.database; + + final data = { + // "id": treesImprovements.id, + "improvement": treesImprovements.improvement, + "pricePerTree": treesImprovements.pricePerTree, + "subclassCode": treesImprovements.subclassCode + }; + final id = await db.insert('trees_improvement', data); + return treesImprovements.copy(id: id); + } + + Future> readAllTreesImprovements() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('trees_improvement', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => TreesImprovements.fromJson2(json)).toList(); + } + + //Type of Location + + Future createTypeOfLocation( + TypeOfLocation typeOfLocation) async { + final db = await instance.database; + + final data = { + "id": typeOfLocation.id, + "distanceKm": typeOfLocation.distanceKm, + "allRoadTypes": typeOfLocation.allRoadTypes, + "localTradingCenter": typeOfLocation.localTradingCenter + }; + final id = await db.insert('type_of_location', data); + return typeOfLocation.copy(id: id); + } + + Future> readAllTypeOfLocation() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('type_of_location', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => TypeOfLocation.fromJson2(json)).toList(); + } + + //Type of Road + + Future createTypeOfRoad(TypeOfRoad typeOfRoad) async { + final db = await instance.database; + + final data = { + "id": typeOfRoad.id, + "roadType": typeOfRoad.roadType, + "deduction": typeOfRoad.deduction, + }; + final id = await db.insert('type_of_road', data); + return typeOfRoad.copy(id: id); + } + + Future> readAllTypeOfRoad() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('type_of_road', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => TypeOfRoad.fromJson2(json)).toList(); + } + //BLDG Owner Future createBldgOwner(PropertyInfo propertyInfo) async { @@ -474,10 +881,12 @@ class SQLServices { "faasType": propertyInfo.faasType, "assessedById": propertyInfo.assessedById, "assessedByName": propertyInfo.assessedByName, + "dateCreated": "000", + "dateModified": "000", }; final id = await db.insert('bldg_owner', data); final tempID = await SharedPreferences.getInstance(); - print(id); + print(propertyInfo.copy(id: id).toJson()); await tempID.setInt('tempid', id); return propertyInfo.copy(id: id); } @@ -487,7 +896,39 @@ class SQLServices { const orderBy = 'id'; final result = await db.query('bldg_owner', orderBy: orderBy); - return result.map((json) => PropertyInfo.fromJson(json)).toList(); + return result.map((json) => PropertyInfo.fromJson2(json)).toList(); + } + + Future updateBldgOwner(id, PropertyInfo propertyInfo) async { + final db = await instance.database; + final data = { + "transCode": propertyInfo.transCode, + "tdn": propertyInfo.tdn, + "pin": propertyInfo.pin, + "owner": propertyInfo.owner, + "address": propertyInfo.address, + "telno": propertyInfo.telno, + "tin": propertyInfo.tin, + "adminUser": propertyInfo.adminUser, + "adminAddress": propertyInfo.adminAddress, + "adminTelno": propertyInfo.adminTelno, + "adminTin": propertyInfo.adminTin, + "faasType": propertyInfo.faasType, + "assessedById": propertyInfo.assessedById, + "assessedByName": propertyInfo.assessedByName, + "dateCreated": "000", + "dateModified": "000", + }; + + final result = + await db.update('bldg_owner', data, where: "id = ?", whereArgs: [id]); + + if (result > 0) { + print('Bldg Owner Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; } Future deleteBldgOwner({required int id}) async { @@ -523,18 +964,33 @@ class SQLServices { return landref.copy(id: id); } - // Future getLandRef({required int id}) async { - // final db = await instance.database; - // final maps = await db.query('landref', - // where: "bldgapprDetailsId = ?", whereArgs: [id], limit: 1); - // print(maps[0].toString()); - // if (maps.isNotEmpty) { - // final firstMap = maps[0]; - // return LandRef.fromJson2(firstMap); - // } else { - // return null; // No data found - // } - // } + Future updateLandRef(id, LandRef landref) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": landref.bldgapprDetailsId, + "assessedById": landref.assessedById, + "assessedByName": landref.assessedByName, + "dateCreated": "000", + "dateModified": "000", + "owner": landref.owner, + "cloaNo": landref.cloaNo, + "lotNo": landref.lotNo, + "tdn": landref.tdn, + "area": landref.area, + "surveyNo": landref.surveyNo, + "blkNo": landref.blkNo + }; + + final result = await db.update('landref', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('LanRef Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } Future>> getLandRef(id) async { final db = await instance.database; @@ -588,6 +1044,31 @@ class SQLServices { return bldgloc.copy(id: id); } + Future updateLocation(id, BldgLoc bldgloc) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": bldgloc.bldgapprDetailsId, + "assessedById": bldgloc.assessedById, + "assessedByName": bldgloc.assessedByName, + "dateCreated": "000", + "dateModified": "000", + "street": bldgloc.street, + "barangay": bldgloc.barangay, + "municipality": bldgloc.municipality, + "province": bldgloc.province + }; + + final result = await db.update('bldgloc', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('Location Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + Future>> getLocation(id) async { final db = await instance.database; final results = await db.query('bldgloc', @@ -626,7 +1107,8 @@ class SQLServices { "area4Thfloor": gendesc.area4Thfloor, "totalFloorArea": gendesc.totalFloorArea, "floorSketch": 'None', - "actualUse": gendesc.actualUse + "actualUse": gendesc.actualUse, + "unitValue": gendesc.unitValue }; final id = await db.insert('gendesc', data); print(gendesc.copy(id: id)); @@ -643,6 +1125,46 @@ class SQLServices { return results; } + Future updateGeneralDescription(id, GeneralDesc gendesc) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": gendesc.bldgapprDetailsId, + "assessedById": gendesc.assessedById, + "assessedByName": gendesc.assessedByName, + "dateCreated": 'None', + "dateModified": 'None', + "bldgKind": gendesc.bldgKind, + "strucType": gendesc.strucType, + "bldgPermit": gendesc.bldgPermit, + "dateIssued": gendesc.dateIssued, + "cct": gendesc.cct, + "certCompletionIssued": gendesc.certCompletionIssued, + "certOccupancyIssued": gendesc.certOccupancyIssued, + "dateCompleted": gendesc.dateCompleted, + "dateOccupied": gendesc.dateOccupied, + "bldgAge": gendesc.bldgAge, + "noStoreys": gendesc.noStoreys, + "area1Stfloor": gendesc.area1Stfloor, + "area2Ndfloor": gendesc.area2Ndfloor, + "area3Rdfloor": gendesc.area3Rdfloor, + "area4Thfloor": gendesc.area4Thfloor, + "totalFloorArea": gendesc.totalFloorArea, + "floorSketch": 'None', + "actualUse": gendesc.actualUse, + "unitValue": gendesc.unitValue + }; + + final result = await db.update('gendesc', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('GenDesc Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + //Structural Materials Future createStructuralMaterials( @@ -661,7 +1183,7 @@ class SQLServices { "walls": materials.walls!.join(', ').splitMapJoin(', '), }; final id = await db.insert('structural_materials', data); - print('gendesc test idcopy'); + print('strct Mat test idcopy'); print(id); return materials.copy(id: id); } @@ -669,13 +1191,38 @@ class SQLServices { Future>> getStructuralMaterials(id) async { final db = await instance.database; final results = await db.query('structural_materials', - where: "id = ?", whereArgs: [id], limit: 1); + where: "bldgapprDetailsId = ?", whereArgs: [id], limit: 1); print('strucmat test result'); print(results); return results; } + Future updateStructuralMaterial( + id, StructureMaterialsII materials) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": materials.bldgapprDetailsId, + "foundation": materials.foundation?.join(', ').splitMapJoin(', '), + "columns": materials.columns!.join(', ').splitMapJoin(', '), + "beams": materials.beams!.join(', ').splitMapJoin(', '), + "trussFraming": materials.trussFraming!.join(', ').splitMapJoin(', '), + "roof": materials.roof!.join(', ').splitMapJoin(', '), + "flooring": materials.flooring!.join(', ').splitMapJoin(', '), + "walls": materials.walls!.join(', ').splitMapJoin(', '), + }; + + final result = await db.update('structural_materials', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('Structural Materials Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + //Additional Items Future createAdditionalItems( @@ -723,6 +1270,75 @@ class SQLServices { return results; } + Future deleteAdditionalItems({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'additionalitems', + where: 'id = ?', + whereArgs: [id], + ); + } + + // Building and Structure + + Future createBuildingAndStructure( + BldgAndStructure bldgAndStructure) async { + final db = await instance.database; + + final data = { + // "id": bldgAndStructure.id, + "bldgapprDetailsId": bldgAndStructure.bldgapprDetailsId, + "assessedById": bldgAndStructure.assessedById, + "assessedByName": bldgAndStructure.assessedByName, + "dateCreated": bldgAndStructure.dateCreated, + "dateModified": bldgAndStructure.dateModified, + "bldgType": bldgAndStructure.bldgType, + "strucType": bldgAndStructure.strucType, + "description": bldgAndStructure.description, + "actualUse": bldgAndStructure.actualUse, + "floorCount": bldgAndStructure.floorCount, + "bldgArea": bldgAndStructure.bldgArea, + "unitValue": bldgAndStructure.unitValue, + "depRate": bldgAndStructure.depRate, + "marketValue": bldgAndStructure.marketValue, + "depAmount": bldgAndStructure.depAmount, + "adjustedMarketValue": bldgAndStructure.adjustedMarketValue + }; + final id = await db.insert('bldg_and_structure', data); + return bldgAndStructure.copy(id: id); + } + + Future> readBuildingAndStructure() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('bldg_and_structure', orderBy: orderBy); + + return result.map((json) => BldgAndStructure.fromJson(json)).toList(); + } + + Future>> getBuildingAndStructure(id) async { + final db = await instance.database; + final results = await db.query('bldg_and_structure', + where: "bldgapprDetailsId = ?", whereArgs: [id]); + print('add edit test result'); + print(results); + + return results; + } + + Future deleteBuildingAndStructure({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'bldg_and_structure', + where: 'id = ?', + whereArgs: [id], + ); + } + //Bldg Appraisal Future createBldgAppraisal( @@ -730,7 +1346,7 @@ class SQLServices { final db = await instance.database; final data = { - "id": appraisal.id, + // "id": appraisal.id, "bldgapprDetailsId": appraisal.bldgapprDetailsId, "assessedById": appraisal.assessedById, "assessedByName": appraisal.assessedByName, @@ -752,13 +1368,55 @@ class SQLServices { return appraisal.copy(id: id); } + Future>> getBldgAppraisal(id) async { + final db = await instance.database; + final results = await db.query('bldg_appraisal', + where: "bldgapprDetailsId = ?", whereArgs: [id]); + print('appraisal edit test result'); + print(results); + + return results; + } + + Future updateAppraisal(id, PropertyAppraisal appraisal) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": appraisal.bldgapprDetailsId, + "assessedById": appraisal.assessedById, + "assessedByName": appraisal.assessedByName, + "dateCreated": appraisal.dateCreated, + "dateModified": appraisal.dateModified, + "unitconstructCost": appraisal.unitconstructCost, + "buildingCore": appraisal.buildingCore, + "unitconstructSubtotal": appraisal.unitconstructSubtotal, + "depreciationRate": appraisal.depreciationRate, + "depreciationCost": appraisal.depreciationCost, + "costAddItems": appraisal.costAddItems, + "addItemsSubtotal": appraisal.addItemsSubtotal, + "totalpercentDepreciation": appraisal.totalpercentDepreciation, + "marketValue": appraisal.marketValue, + "totalArea": appraisal.totalArea, + "actualUse": appraisal.actualUse + }; + + final result = await db.update('bldg_appraisal', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('Appraisal Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + //Bldg Assessment Future createBldgAssessment( PropertyAssessment assessment) async { final db = await instance.database; final data = { - "id": assessment.id, + // "id": assessment.id, "bldgapprDetailsId": assessment.bldgapprDetailsId, "actualUse": assessment.actualUse, "marketValue": assessment.marketValue, @@ -782,4 +1440,538 @@ class SQLServices { final id = await db.insert('bldg_assessment', data); return assessment.copy(id: id); } + + Future>> getBldgAssessment(id) async { + final db = await instance.database; + final results = await db.query('bldg_assessment', + where: "bldgapprDetailsId = ?", whereArgs: [id]); + print('assessment edit test result'); + print(results); + + return results; + } + + Future updateAssessment(id, PropertyAssessment assessment) async { + final db = await instance.database; + final data = { + "bldgapprDetailsId": assessment.bldgapprDetailsId, + "actualUse": assessment.actualUse, + "marketValue": assessment.marketValue, + "assessmentLevel": assessment.assessmentLevel, + "assessedValue": assessment.assessedValue, + "taxable": assessment.taxable, + "exempt": assessment.exempt, + "qtr": assessment.qtr, + "yr": assessment.yr, + "appraisedbyName": assessment.appraisedbyName, + "appraisedbyDate": assessment.appraisedbyDate, + "recommendapprName": assessment.recommendapprName, + "recommendapprDate": assessment.recommendapprDate, + "approvedbyName": assessment.approvedbyName, + "memoranda": assessment.memoranda, + "swornstatementNo": assessment.swornstatementNo, + "dateReceived": assessment.dateReceived, + "entryDateAssessment": assessment.entryDateAssessment, + "entryDateBy": assessment.entryDateBy + }; + + final result = await db.update('bldg_assessment', data, + where: "bldgapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('Assessment Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + +//Land Property Owner + + Future createLandOwner( + LandPropertyOwner landPropertyOwner) async { + final db = await instance.database; + + final data = { + // "id": landPropertyOwner.id, + "assessedById": landPropertyOwner.assessedById, + "assessedByName": landPropertyOwner.assessedByName, + "dateCreated": landPropertyOwner.dateCreated, + "dateModified": landPropertyOwner.dateModified, + "transCode": landPropertyOwner.transCode, + "tdn": landPropertyOwner.tdn, + "pin": landPropertyOwner.pin, + "cloaNo": landPropertyOwner.cloaNo, + "dated": landPropertyOwner.dated, + "surveyNo": landPropertyOwner.surveyNo, + "lotNo": landPropertyOwner.lotNo, + "blkNo": landPropertyOwner.blkNo, + "owner": landPropertyOwner.owner, + "address": landPropertyOwner.address, + "telno": landPropertyOwner.telno, + "tin": landPropertyOwner.tin, + "adminUser": landPropertyOwner.adminUser, + "adminTelno": landPropertyOwner.adminTelno, + "adminAddress": landPropertyOwner.adminAddress, + "adminTin": landPropertyOwner.adminTin, + "faasType": landPropertyOwner.faasType + }; + final id = await db.insert('land_property_owner', data); + final tempID = await SharedPreferences.getInstance(); + print(landPropertyOwner.copy(id: id).toJson()); + await tempID.setInt('landid', id); + return landPropertyOwner.copy(id: id); + } + + Future> getLandPropertyOwner() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('land_property_owner', orderBy: orderBy); + + return result.map((json) => LandPropertyOwner.fromJson2(json)).toList(); + } + + Future updateLandPropertyOwner( + id, LandPropertyOwner landPropertyOwner) async { + final db = await instance.database; + final data = { + // "id": landPropertyOwner.id, + "assessedById": landPropertyOwner.assessedById, + "assessedByName": landPropertyOwner.assessedByName, + "dateCreated": landPropertyOwner.dateCreated, + "dateModified": landPropertyOwner.dateModified, + "transCode": landPropertyOwner.transCode, + "tdn": landPropertyOwner.tdn, + "pin": landPropertyOwner.pin, + "cloaNo": landPropertyOwner.cloaNo, + "dated": landPropertyOwner.dated, + "surveyNo": landPropertyOwner.surveyNo, + "lotNo": landPropertyOwner.lotNo, + "blkNo": landPropertyOwner.blkNo, + "owner": landPropertyOwner.owner, + "address": landPropertyOwner.address, + "telno": landPropertyOwner.telno, + "tin": landPropertyOwner.tin, + "adminUser": landPropertyOwner.adminUser, + "adminTelno": landPropertyOwner.adminTelno, + "adminAddress": landPropertyOwner.adminAddress, + "adminTin": landPropertyOwner.adminTin, + "faasType": landPropertyOwner.faasType + }; + + final result = await db + .update('land_property_owner', data, where: "id = ?", whereArgs: [id]); + + if (result > 0) { + print('Bldg Owner Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + + Future deleteLandPropertyOwner({required int id}) async { + final db = await instance.database; + + return await db.delete( + 'land_property_owner', + where: 'id = ?', + whereArgs: [id], + ); + } + + //Land Location + + Future createLandLocation( + LandPropertyLoc landPropertyLoc) async { + final db = await instance.database; + + final data = { + "id": landPropertyLoc.id, + "landapprDetailsId": landPropertyLoc.landapprDetailsId, + "assessedById": landPropertyLoc.assessedById, + "assessedByName": landPropertyLoc.assessedByName, + "dateCreated": landPropertyLoc.dateCreated, + "dateModified": landPropertyLoc.dateModified, + "street": landPropertyLoc.street, + "municipality": landPropertyLoc.municipality, + "barangay": landPropertyLoc.barangay, + "province": landPropertyLoc.province + }; + print('loc test'); + print(data); + final id = await db.insert('land_property_location', data); + final tempID = await SharedPreferences.getInstance(); + + await tempID.setInt('landid', id); + return landPropertyLoc.copy(id: id); + } + + Future>> getLandPropertyLocation(id) async { + final db = await instance.database; + final results = await db.query('land_property_location', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('land_property_location test result'); + print(results); + + return results; + } + + Future updateLandPropertyLocation( + id, LandPropertyLoc landPropertyLoc) async { + final db = await instance.database; + final data = { + "id": landPropertyLoc.id, + "landapprDetailsId": landPropertyLoc.landapprDetailsId, + "assessedById": landPropertyLoc.assessedById, + "assessedByName": landPropertyLoc.assessedByName, + "dateCreated": landPropertyLoc.dateCreated, + "dateModified": landPropertyLoc.dateModified, + "street": landPropertyLoc.street, + "municipality": landPropertyLoc.municipality, + "barangay": landPropertyLoc.barangay, + "province": landPropertyLoc.province + }; + + final result = await db.update('land_property_location', data, + where: "landapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('land_property_location Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + + // Land Boundaries + + Future createLandPropertyBoundaries( + LandPropertyBoundaries landPropertyBoundaries) async { + final db = await instance.database; + + final data = { + "id": landPropertyBoundaries.id, + "landapprDetailsId": landPropertyBoundaries.landapprDetailsId, + "assessedById": landPropertyBoundaries.assessedById, + "assessedByName": landPropertyBoundaries.assessedByName, + "dateCreated": landPropertyBoundaries.dateCreated, + "dateModified": landPropertyBoundaries.dateModified, + "north": landPropertyBoundaries.north, + "east": landPropertyBoundaries.east, + "south": landPropertyBoundaries.south, + "west": landPropertyBoundaries.west, + "sketch": landPropertyBoundaries.sketch, + }; + final id = await db.insert('land_property_boundaries', data); + final tempID = await SharedPreferences.getInstance(); + print(landPropertyBoundaries.copy(id: id).toJson()); + await tempID.setInt('tempid', id); + return landPropertyBoundaries.copy(id: id); + } + + Future>> getLandPropertyBoundaries(id) async { + final db = await instance.database; + final results = await db.query('land_property_boundaries', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('get land boundary test result'); + print(results); + + return results; + } + + Future updateLandPropertyBoundaries( + id, LandPropertyBoundaries landPropertyBoundaries) async { + final db = await instance.database; + final data = { + "id": landPropertyBoundaries.id, + "landapprDetailsId": landPropertyBoundaries.landapprDetailsId, + "assessedById": landPropertyBoundaries.assessedById, + "assessedByName": landPropertyBoundaries.assessedByName, + "dateCreated": landPropertyBoundaries.dateCreated, + "dateModified": landPropertyBoundaries.dateModified, + "north": landPropertyBoundaries.north, + "east": landPropertyBoundaries.east, + "south": landPropertyBoundaries.south, + "west": landPropertyBoundaries.west, + "sketch": landPropertyBoundaries.sketch, + }; + + final result = await db.update('land_property_boundaries', data, + where: "landapprDetailsId = ?", whereArgs: [id]); + + if (result > 0) { + print('land_property_boundaries Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } + + //Land Appraisal + + Future createLandAppraisal(LandAppr landPropertyAppr) async { + final db = await instance.database; + + final data = { + "landapprDetailsId": landPropertyAppr.landapprDetailsId, + "classification": landPropertyAppr.classification, + "subClass": landPropertyAppr.subClass, + "area": landPropertyAppr.area, + "unitValue": landPropertyAppr.unitValue, + "baseMarketval": landPropertyAppr.baseMarketval + }; + + print('data'); + print(data); + + final id = await db.insert('land_property_appr', data); + print(id); + + return landPropertyAppr.copy(id: id); + } + + Future> readLandPropertyAppraisal() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('land_property_appr', orderBy: orderBy); + + return result.map((json) => LandAppr.fromJson(json)).toList(); + } + + Future>> getLandPropertyAppraisal(id) async { + final db = await instance.database; + final results = await db.query('land_property_appr', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('add edit test result'); + print(results); + + return results; + } + + Future deleteLandPropertyAppraisal({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'land_property_appr', + where: 'id = ?', + whereArgs: [id], + ); + } + + //Land Adjustments + + Future createValueAdjustments( + ValueAdjustments adjustments) async { + final db = await instance.database; + + final data = { + // "id": adjustments.id, + "landapprDetailsId": adjustments.landapprDetailsId, + "baseMarketval": adjustments.baseMarketval, + "adjustmentFactors": adjustments.adjustmentFactors, + "adjustment": adjustments.adjustment, + "valueAdjustment": adjustments.valueAdjustment, + "marketValue": adjustments.marketValue + }; + final id = await db.insert('value_adjustments', data); + return adjustments.copy(id: id); + } + + Future> readAllValueAdjustments() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('value_adjustments', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => ValueAdjustments.fromJson2(json)).toList(); + } + + Future>> getValueAdjustments(id) async { + final db = await instance.database; + final results = await db.query('value_adjustments', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('land value Adjustments test result'); + print(results); + + return results; + } + + Future deleteValueAdjustment({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'value_adjustments', + where: 'id = ?', + whereArgs: [id], + ); + } + + // Land Other Improvements + + Future createOtherImprovements( + OtherImprovements otherImprovements) async { + final db = await instance.database; + + final data = { + "landapprDetailsId": otherImprovements.landapprDetailsId, + "kindsOfTrees": otherImprovements.kindsOfTrees, + "subclassAge": otherImprovements.subclassAge, + "quantity": otherImprovements.quantity, + "unitValue": otherImprovements.unitValue, + "baseMarketval": otherImprovements.baseMarketval, + "noOfProductive": otherImprovements.noOfProductive, + "noOfNonproductive": otherImprovements.noOfNonproductive, + "fruitBearing": otherImprovements.fruitBearing + }; + final id = await db.insert('land_property_other_improvements', data); + return otherImprovements.copy(id: id); + } + + Future>> getOtherImprovements(id) async { + final db = await instance.database; + final results = await db.query('land_property_other_improvements', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('land other improvement test result'); + print(results); + + return results; + } + + Future deleteOtherImprovements({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'land_property_other_improvements', + where: 'id = ?', + whereArgs: [id], + ); + } + + //Land Property Assessment + + Future createLandPropertyAssessment( + LandPropertyAssessment assessment) async { + final db = await instance.database; + + final data = { + // "id": adjustments.id, + "landapprDetailsId": assessment.landapprDetailsId, + "actualUse": assessment.actualUse, + "marketval": assessment.marketval, + "assessmentLevel": assessment.assessmentLevel, + "assessedValue": assessment.assessedValue, + "totalMarketval": assessment.totalMarketval, + "totalAssessedval": assessment.totalAssessedval + }; + final id = await db.insert('land_property_assessment', data); + return assessment.copy(id: id); + } + + Future>> getLandPropertyAssessment(id) async { + final db = await instance.database; + final results = await db.query('land_property_assessment', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('land_property_assessment test result'); + print(results); + + return results; + } + + Future deleteLandPropertyAssessment({required int id}) async { + final db = await instance.database; + print(id); + + return await db.delete( + 'land_property_assessment', + where: 'id = ?', + whereArgs: [id], + ); + } + +// Land Property Sgnatories + + Future createLandPropertySignatories(LandExt landExt) async { + final db = await instance.database; + + final data = { + // "id": landExt.id, + "landapprDetailsId": landExt.landapprDetailsId, + "assessedById": landExt.assessedById, + "assessedByName": landExt.assessedByName, + "dateCreated": landExt.dateCreated, + "dateModified": landExt.dateModified, + "taxable": landExt.taxable, + "exempt": landExt.exempt, + "qtr": landExt.qtr, + "yr": landExt.yr, + "appraisedbyName": landExt.appraisedbyName, + "appraisedbyDate": landExt.appraisedbyDate, + "recommendapprName": landExt.recommendapprName, + "recommendapprDate": landExt.recommendapprDate, + "approvedbyName": landExt.approvedbyName, + "approvedbyDate": landExt.approvedbyDate, + "memoranda": landExt.memoranda, + "swornstatementNo": landExt.swornstatementNo, + "dateReceived": landExt.dateReceived, + "entryDateAssessment": landExt.entryDateAssessment, + "entryDateBy": landExt.entryDateBy, + }; + final id = await db.insert('land_property_ext', data); + final tempID = await SharedPreferences.getInstance(); + print(landExt.copy(id: id).toJson()); + await tempID.setInt('tempid', id); + return landExt.copy(id: id); + } + + Future>> getLandPropertySignature(id) async { + final db = await instance.database; + final results = await db.query('land_property_ext', + where: "landapprDetailsId = ?", whereArgs: [id]); + print('land_property_ext test result'); + print(results); + + return results; + } + + Future updateLandPropertySignature(id, LandExt landExt) async { + final db = await instance.database; + final data = { + // "id": landPropertyOwner.id, + "landapprDetailsId": landExt.landapprDetailsId, + "assessedById": landExt.assessedById, + "assessedByName": landExt.assessedByName, + "dateCreated": landExt.dateCreated, + "dateModified": landExt.dateModified, + "taxable": landExt.taxable, + "exempt": landExt.exempt, + "qtr": landExt.qtr, + "yr": landExt.yr, + "appraisedbyName": landExt.appraisedbyName, + "appraisedbyDate": landExt.appraisedbyDate, + "recommendapprName": landExt.recommendapprName, + "recommendapprDate": landExt.recommendapprDate, + "approvedbyName": landExt.approvedbyName, + "approvedbyDate": landExt.approvedbyDate, + "memoranda": landExt.memoranda, + "swornstatementNo": landExt.swornstatementNo, + "dateReceived": landExt.dateReceived, + "entryDateAssessment": landExt.entryDateAssessment, + "entryDateBy": landExt.entryDateBy, + }; + + final result = await db + .update('land_property_ext', data, where: "id = ?", whereArgs: [id]); + + if (result > 0) { + print('Land Signatory Updated Successfully'); + } else { + throw Exception('Failed to update the Journal.'); + } + return result; + } } diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index b6b3eb9..cd576c1 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -7,7 +7,7 @@ class Url { // return '192.168.10.183:3000'; return 'agusandelnorte.gov.ph'; // return "192.168.10.219:3000"; - // return "192.168.10.241"; + // return "192.168.10.241"; // return "192.168.10.221:3004"; // return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; diff --git a/pubspec.lock b/pubspec.lock index 70e9e47..9412a34 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "64.0.0" + accordion: + dependency: "direct main" + description: + name: accordion + sha256: "0eca3d1c619c6df63d6e384010fd2ef1164e7385d7102f88a6b56f658f160cd0" + url: "https://pub.dev" + source: hosted + version: "2.6.0" analyzer: dependency: transitive description: @@ -685,6 +693,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + get: + dependency: transitive + description: + name: get + sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e + url: "https://pub.dev" + source: hosted + version: "4.6.6" glob: dependency: transitive description: @@ -1253,6 +1269,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.27.7" + scroll_to_index: + dependency: transitive + description: + name: scroll_to_index + sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176 + url: "https://pub.dev" + source: hosted + version: "3.0.1" scrollable_positioned_list: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 23e8c68..b558772 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -98,6 +98,7 @@ dependencies: share_plus: ^7.1.0 animated_splash_screen: ^1.3.0 sqflite: ^2.3.0 + accordion: ^2.6.0 device_info_plus: ^9.0.3 better_open_file: ^3.6.4