diff --git a/android/app/build.gradle b/android/app/build.gradle index e896139..be52da5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + ndkVersion "25.1.8937393" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/lib/bloc/passo/barangay/barangay_bloc.dart b/lib/bloc/passo/barangay/barangay_bloc.dart new file mode 100644 index 0000000..f8ae3e7 --- /dev/null +++ b/lib/bloc/passo/barangay/barangay_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/sevices/passo/barangay.dart'; + +part 'barangay_event.dart'; +part 'barangay_state.dart'; + +class BarangayBloc extends Bloc { + BarangayBloc() : super(BarangayInitial()) { + on((event, emit) async { + emit(BarangayLoading()); + try { + final barangay = await BarangayServices.instance.fetch(event.id); + emit(BarangayLoaded(barangay)); + } catch (e) { + emit(BarangayErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/barangay/barangay_event.dart b/lib/bloc/passo/barangay/barangay_event.dart new file mode 100644 index 0000000..5012e1a --- /dev/null +++ b/lib/bloc/passo/barangay/barangay_event.dart @@ -0,0 +1,17 @@ +part of 'barangay_bloc.dart'; + +abstract class BarangayEvent extends Equatable { + const BarangayEvent(); + + @override + List get props => []; +} + +class LoadBarangay extends BarangayEvent { + final String id; + + const LoadBarangay({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/passo/barangay/barangay_state.dart b/lib/bloc/passo/barangay/barangay_state.dart new file mode 100644 index 0000000..bc36c1b --- /dev/null +++ b/lib/bloc/passo/barangay/barangay_state.dart @@ -0,0 +1,28 @@ +part of 'barangay_bloc.dart'; + +abstract class BarangayState extends Equatable { + const BarangayState(); + + @override + List get props => []; +} + +class BarangayInitial extends BarangayState {} + +class BarangayLoading extends BarangayState {} + +class BarangayLoaded extends BarangayState { + BarangayLoaded(this.brgy); + final List brgy; + + @override + List get props => [brgy]; +} + +class BarangayErrorState extends BarangayState { + BarangayErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart new file mode 100644 index 0000000..167c65e --- /dev/null +++ b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart @@ -0,0 +1,60 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/building/additional_items_services.dart'; + +part 'additional_item_event.dart'; +part 'additional_item_state.dart'; + +class AdditionalItemBloc + extends Bloc { + AdditionalItemBloc() : super(AdditionalItemsLoading()) { + List globalAdditionalItems = []; + on((event, emit) async { + emit(AdditionalItemsLoading()); + try { + // final tempID = await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // final additionalItem = await GetAdditionalItems.getAdditionalItems( + // tempID.getInt('tempid')); + + emit(AdditionalItemsLoaded(globalAdditionalItems)); + } catch (e) { + emit(AdditionalItemsErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await AdditionalItemsServices.instance.add(event.items))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + AdditionalItems newAdditional = + AdditionalItems.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalAdditionalItems.add(newAdditional); + + emit(AdditionalItemsLoaded(globalAdditionalItems)); + } + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await AdditionalItemsServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalAdditionalItems + .removeWhere(((AdditionalItems element) => element.id == event.id)); + emit(AdditionalItemsDeletedState(success: true)); + } + }); + + on((event, emit) async { + emit(ShowAddItemsScreen()); + }); + } +} diff --git a/lib/bloc/passo/bulding/additional_item/additional_item_event.dart b/lib/bloc/passo/bulding/additional_item/additional_item_event.dart new file mode 100644 index 0000000..3922048 --- /dev/null +++ b/lib/bloc/passo/bulding/additional_item/additional_item_event.dart @@ -0,0 +1,37 @@ +part of 'additional_item_bloc.dart'; + +abstract class AdditionalItemEvent extends Equatable { + const AdditionalItemEvent(); + + @override + List get props => []; +} + +class LoadAdditionalItems extends AdditionalItemEvent { + final List items; + + const LoadAdditionalItems({this.items = const []}); + + @override + List get props => [items]; +} + +class AddAdditionalItems extends AdditionalItemEvent { + final AdditionalItems items; + + const AddAdditionalItems({required this.items}); + + @override + List get props => [items]; +} + +class DeleteAdditionalItems extends AdditionalItemEvent { + final int id; + + const DeleteAdditionalItems({required this.id}); + + @override + List get props => [id]; +} + +class ShowAdditionalItems extends AdditionalItemEvent {} diff --git a/lib/bloc/passo/bulding/additional_item/additional_item_state.dart b/lib/bloc/passo/bulding/additional_item/additional_item_state.dart new file mode 100644 index 0000000..d39fc65 --- /dev/null +++ b/lib/bloc/passo/bulding/additional_item/additional_item_state.dart @@ -0,0 +1,35 @@ +part of 'additional_item_bloc.dart'; + +abstract class AdditionalItemState extends Equatable { + const AdditionalItemState(); + + @override + List get props => []; +} + +class AdditionalItemsLoading extends AdditionalItemState {} + +class AdditionalItemsLoaded extends AdditionalItemState { + const AdditionalItemsLoaded(this.items); + final List items; + + @override + List get props => [items]; +} + +class ShowAddItemsScreen extends AdditionalItemState {} + +class AdditionalItemsErrorState extends AdditionalItemState { + const AdditionalItemsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class AdditionalItemsDeletedState extends AdditionalItemState { + final bool success; + const AdditionalItemsDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart new file mode 100644 index 0000000..7d243c4 --- /dev/null +++ b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart @@ -0,0 +1,63 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/building/additional_items_services.dart'; +part 'additional_items_edit_event.dart'; +part 'additional_items_edit_state.dart'; + +class AdditionalItemsEditBloc + extends Bloc { + AdditionalItemsEditBloc() : super(AdditionalItemsEditInitial()) { + List globalAdditionalItemsEdit = []; + on((event, emit) async { + if (globalAdditionalItemsEdit.isEmpty) { + emit(AdditionalItemsEditLoading()); + try { + final additionalItems = + await AdditionalItemsServices.instance.fetch(event.id); + + globalAdditionalItemsEdit + .addAll(additionalItems); // Append fetched data + emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit)); + } catch (e) { + emit(AdditionalItemsEditErrorState(e.toString())); + } + } else { + emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit)); + } + }); + + on((event, emit) async { + http.Response response = + (await AdditionalItemsServices.instance.add(event.items))!; + print(response.statusCode); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + AdditionalItems newAdditional = + AdditionalItems.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalAdditionalItemsEdit.add(newAdditional); + + emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit)); + } + }); + on((event, emit) async { + emit(ShowAddItemsScreenEdit()); + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await AdditionalItemsServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalAdditionalItemsEdit + .removeWhere(((AdditionalItems element) => element.id == event.id)); + emit(AdditionalItemsEditDeletedState(success: true)); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_event.dart b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_event.dart new file mode 100644 index 0000000..8b34fd0 --- /dev/null +++ b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_event.dart @@ -0,0 +1,38 @@ +part of 'additional_items_edit_bloc.dart'; + +abstract class AdditionalItemsEditEvent extends Equatable { + const AdditionalItemsEditEvent(); + + @override + List get props => []; +} + +class LoadAdditionalItemsEdit extends AdditionalItemsEditEvent { + final List items; + final int? id; + + const LoadAdditionalItemsEdit({required this.items, this.id}); + + @override + List get props => [items]; +} + +class AddAdditionalItemsEdit extends AdditionalItemsEditEvent { + final AdditionalItems items; + + const AddAdditionalItemsEdit({required this.items}); + + @override + List get props => [items]; +} + +class ShowAdditionalItemsEdit extends AdditionalItemsEditEvent {} + +class DeleteAdditionalItemsEdit extends AdditionalItemsEditEvent { + final int id; + + const DeleteAdditionalItemsEdit({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_state.dart b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_state.dart new file mode 100644 index 0000000..4016b98 --- /dev/null +++ b/lib/bloc/passo/bulding/additional_items_edit/additional_items_edit_state.dart @@ -0,0 +1,37 @@ +part of 'additional_items_edit_bloc.dart'; + +abstract class AdditionalItemsEditState extends Equatable { + const AdditionalItemsEditState(); + + @override + List get props => []; +} + +class AdditionalItemsEditInitial extends AdditionalItemsEditState {} + +class AdditionalItemsEditLoading extends AdditionalItemsEditState {} + +class AdditionalItemsEditLoaded extends AdditionalItemsEditState { + const AdditionalItemsEditLoaded(this.items); + final List items; + + @override + List get props => [items]; +} + +class AdditionalItemsEditErrorState extends AdditionalItemsEditState { + const AdditionalItemsEditErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class ShowAddItemsScreenEdit extends AdditionalItemsEditState {} + +class AdditionalItemsEditDeletedState extends AdditionalItemsEditState { + final bool success; + const AdditionalItemsEditDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/passo/bulding/class_components/class_components_bloc.dart b/lib/bloc/passo/bulding/class_components/class_components_bloc.dart new file mode 100644 index 0000000..084c0e3 --- /dev/null +++ b/lib/bloc/passo/bulding/class_components/class_components_bloc.dart @@ -0,0 +1,22 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/sevices/passo/class_components_services.dart'; + +part 'class_components_event.dart'; +part 'class_components_state.dart'; + +class ClassComponentsBloc + extends Bloc { + ClassComponentsBloc() : super(ClassComponentLoading()) { + on((event, emit) async { + emit(ClassComponentLoading()); + try { + final classs = await ClassComponentService.instance.fetch(); + emit(ClassComponentLoaded(classs)); + } catch (e) { + emit(ClassComponentErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/class_components/class_components_event.dart b/lib/bloc/passo/bulding/class_components/class_components_event.dart new file mode 100644 index 0000000..5efdac8 --- /dev/null +++ b/lib/bloc/passo/bulding/class_components/class_components_event.dart @@ -0,0 +1,17 @@ +part of 'class_components_bloc.dart'; + +abstract class ClassComponentsEvent extends Equatable { + const ClassComponentsEvent(); + + @override + List get props => []; +} + +class LoadClassComponents extends ClassComponentsEvent { + final List classes; + + const LoadClassComponents({this.classes = const []}); + + @override + List get props => [classes]; +} diff --git a/lib/bloc/passo/bulding/class_components/class_components_state.dart b/lib/bloc/passo/bulding/class_components/class_components_state.dart new file mode 100644 index 0000000..99beb14 --- /dev/null +++ b/lib/bloc/passo/bulding/class_components/class_components_state.dart @@ -0,0 +1,26 @@ +part of 'class_components_bloc.dart'; + +abstract class ClassComponentsState extends Equatable { + const ClassComponentsState(); + + @override + List get props => []; +} + +class ClassComponentLoading extends ClassComponentsState {} + +class ClassComponentLoaded extends ClassComponentsState { + ClassComponentLoaded(this.classes); + final List classes; + + @override + List get props => [classes]; +} + +class ClassComponentErrorState extends ClassComponentsState { + ClassComponentErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/general_description/general_description_bloc.dart b/lib/bloc/passo/bulding/general_description/general_description_bloc.dart new file mode 100644 index 0000000..0e0b213 --- /dev/null +++ b/lib/bloc/passo/bulding/general_description/general_description_bloc.dart @@ -0,0 +1,23 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/sevices/passo/building/general_description_services.dart'; + +part 'general_description_event.dart'; +part 'general_description_state.dart'; + +class GeneralDescriptionBloc + extends Bloc { + GeneralDescriptionBloc() : super(GenDescLoading()) { + on((event, emit) async { + emit(GenDescLoading()); + try { + final gendesc = + await GeneralDescriptionServices.instance.fetch(event.id); + emit(GenDescLoaded(gendesc)); + } catch (e) { + emit(GenDescErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/general_description/general_description_event.dart b/lib/bloc/passo/bulding/general_description/general_description_event.dart new file mode 100644 index 0000000..91cf288 --- /dev/null +++ b/lib/bloc/passo/bulding/general_description/general_description_event.dart @@ -0,0 +1,27 @@ +part of 'general_description_bloc.dart'; + +abstract class GeneralDescriptionEvent extends Equatable { + const GeneralDescriptionEvent(); + + @override + List get props => []; +} + +class LoadGenDesc extends GeneralDescriptionEvent { + final GeneralDesc gendesc; + final int? id; + + const LoadGenDesc({required this.gendesc, required this.id}); + + @override + List get props => [gendesc]; +} + +class UpdateGenDesc extends GeneralDescriptionEvent { + final GeneralDesc gendesc; + + const UpdateGenDesc(this.gendesc); + + @override + List get props => [gendesc]; +} diff --git a/lib/bloc/passo/bulding/general_description/general_description_state.dart b/lib/bloc/passo/bulding/general_description/general_description_state.dart new file mode 100644 index 0000000..9fb075a --- /dev/null +++ b/lib/bloc/passo/bulding/general_description/general_description_state.dart @@ -0,0 +1,26 @@ +part of 'general_description_bloc.dart'; + +abstract class GeneralDescriptionState extends Equatable { + const GeneralDescriptionState(); + + @override + List get props => []; +} + +class GenDescLoading extends GeneralDescriptionState {} + +class GenDescLoaded extends GeneralDescriptionState { + GenDescLoaded(this.gendesc); + final GeneralDesc gendesc; + + @override + List get props => [gendesc]; +} + +class GenDescErrorState extends GeneralDescriptionState { + GenDescErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/landref/landref_bloc.dart b/lib/bloc/passo/bulding/landref/landref_bloc.dart new file mode 100644 index 0000000..99fcc1b --- /dev/null +++ b/lib/bloc/passo/bulding/landref/landref_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/sevices/passo/building/landref_services.dart'; + +part 'landref_event.dart'; +part 'landref_state.dart'; + +class LandrefBloc extends Bloc { + LandrefBloc() : super(LandrefLoading()) { + on((event, emit) async { + emit(LandrefLoading()); + try { + final landRef = await LandRefServices.instance.fetch(event.id); + emit(LandrefLoaded(landRef)); + } catch (e) { + emit(LandrefErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/landref/landref_event.dart b/lib/bloc/passo/bulding/landref/landref_event.dart new file mode 100644 index 0000000..aaf2e78 --- /dev/null +++ b/lib/bloc/passo/bulding/landref/landref_event.dart @@ -0,0 +1,27 @@ +part of 'landref_bloc.dart'; + +abstract class LandrefEvent extends Equatable { + const LandrefEvent(); + + @override + List get props => []; +} + +class LoadLandref extends LandrefEvent { + final LandRef landRef; + final int? id; + + const LoadLandref({required this.landRef, required this.id}); + + @override + List get props => [landRef]; +} + +class UpdateLandref extends LandrefEvent { + final LandRef landRef; + + const UpdateLandref(this.landRef); + + @override + List get props => [landRef]; +} diff --git a/lib/bloc/passo/bulding/landref/landref_state.dart b/lib/bloc/passo/bulding/landref/landref_state.dart new file mode 100644 index 0000000..0832733 --- /dev/null +++ b/lib/bloc/passo/bulding/landref/landref_state.dart @@ -0,0 +1,26 @@ +part of 'landref_bloc.dart'; + +abstract class LandrefState extends Equatable { + const LandrefState(); + + @override + List get props => []; +} + +class LandrefLoading extends LandrefState {} + +class LandrefLoaded extends LandrefState { + LandrefLoaded(this.landRef); + final LandRef landRef; + + @override + List get props => [landRef]; +} + +class LandrefErrorState extends LandrefState { + LandrefErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/location/location_bloc.dart b/lib/bloc/passo/bulding/location/location_bloc.dart new file mode 100644 index 0000000..20aff1b --- /dev/null +++ b/lib/bloc/passo/bulding/location/location_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/sevices/passo/building/location_landref_services.dart'; + +part 'location_event.dart'; +part 'location_state.dart'; + +class LocationBloc extends Bloc { + LocationBloc() : super(LocationLoading()) { + on((event, emit) async { + emit(LocationLoading()); + try { + final bldgloc = await LocationLandrefServices.instance.fetch(event.id); + emit(LocationLoaded(bldgloc)); + } catch (e) { + emit(LocationErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/location/location_event.dart b/lib/bloc/passo/bulding/location/location_event.dart new file mode 100644 index 0000000..008f6db --- /dev/null +++ b/lib/bloc/passo/bulding/location/location_event.dart @@ -0,0 +1,27 @@ +part of 'location_bloc.dart'; + +abstract class LocationEvent extends Equatable { + const LocationEvent(); + + @override + List get props => []; +} + +class LoadLocation extends LocationEvent { + final BldgLoc bldgloc; + final int? id; + + const LoadLocation({required this.bldgloc, required this.id}); + + @override + List get props => [bldgloc]; +} + +class UpdateLocation extends LocationEvent { + final BldgLoc bldgloc; + + const UpdateLocation(this.bldgloc); + + @override + List get props => [bldgloc]; +} diff --git a/lib/bloc/passo/bulding/location/location_state.dart b/lib/bloc/passo/bulding/location/location_state.dart new file mode 100644 index 0000000..8281995 --- /dev/null +++ b/lib/bloc/passo/bulding/location/location_state.dart @@ -0,0 +1,26 @@ +part of 'location_bloc.dart'; + +abstract class LocationState extends Equatable { + const LocationState(); + + @override + List get props => []; +} + +class LocationLoading extends LocationState {} + +class LocationLoaded extends LocationState { + LocationLoaded(this.bldgloc); + final BldgLoc bldgloc; + + @override + List get props => [bldgloc]; +} + +class LocationErrorState extends LocationState { + LocationErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart new file mode 100644 index 0000000..e7953c2 --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart @@ -0,0 +1,45 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/building/property_appraisal_services.dart'; + +part 'property_appraisal_event.dart'; +part 'property_appraisal_state.dart'; + +class PropertyAppraisalBloc + extends Bloc { + PropertyAppraisalBloc() : super(PropertyAppraisalInitial()) { + List globalPropertyAppraisal = []; + on((event, emit) async { + emit(PropertyAppraisalLoading()); + try { + final appraisal = await PropertyAppraisalServices.instance.fetch(); + + emit(PropertyAppraisalLoaded(appraisal)); + } catch (e) { + emit(PropertyAppraisalErrorState(e.toString())); + } + }); + on((event, emit) async { + final tempID = await SharedPreferences.getInstance(); + + http.Response response = (await PropertyAppraisalServices.instance + .update(event.appraisal, tempID.getInt('tempid')! - 1))!; + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + PropertyAppraisal newAppraisal = + PropertyAppraisal.fromJson(jsonResponse['data']); + print("PA"); + print(newAppraisal); + print(response.statusCode); + + emit(PropertyAppraisalLoaded(newAppraisal)); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_event.dart b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_event.dart new file mode 100644 index 0000000..8eda5e3 --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_event.dart @@ -0,0 +1,26 @@ +part of 'property_appraisal_bloc.dart'; + +abstract class PropertyAppraisalEvent extends Equatable { + const PropertyAppraisalEvent(); + + @override + List get props => []; +} + +class LoadPropertyAppraisal extends PropertyAppraisalEvent { + final PropertyAppraisal appraisal; + + const LoadPropertyAppraisal({required this.appraisal}); + + @override + List get props => [appraisal]; +} + +class AddPropertyAppraisal extends PropertyAppraisalEvent { + final PropertyAppraisal appraisal; + + const AddPropertyAppraisal({required this.appraisal}); + + @override + List get props => [appraisal]; +} diff --git a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_state.dart b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_state.dart new file mode 100644 index 0000000..2010d45 --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_state.dart @@ -0,0 +1,28 @@ +part of 'property_appraisal_bloc.dart'; + +abstract class PropertyAppraisalState extends Equatable { + const PropertyAppraisalState(); + + @override + List get props => []; +} + +class PropertyAppraisalInitial extends PropertyAppraisalState {} + +class PropertyAppraisalLoading extends PropertyAppraisalState {} + +class PropertyAppraisalLoaded extends PropertyAppraisalState { + PropertyAppraisalLoaded(this.appraisal); + final PropertyAppraisal appraisal; + + @override + List get props => [appraisal]; +} + +class PropertyAppraisalErrorState extends PropertyAppraisalState { + PropertyAppraisalErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart new file mode 100644 index 0000000..33e6443 --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/property_appraisal_edit.dart'; +import 'package:unit2/sevices/passo/building/property_appraisal_services.dart'; +import 'package:http/http.dart' as http; + +part 'property_appraisal_edit_event.dart'; +part 'property_appraisal_edit_state.dart'; + +class PropertyAppraisalEditBloc + extends Bloc { + PropertyAppraisalEditBloc() : super(PropertyAppraisalEditLoading()) { + on((event, emit) async { + emit(PropertyAppraisalEditLoading()); + try { + final appraisalEdit = + await PropertyAppraisalServices.instance.fetchEdit(event.id); + emit(PropertyAppraisalEditLoaded(appraisalEdit)); + } catch (e) { + emit(PropertyAppraisalEditErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = (await PropertyAppraisalServices.instance + .updateAppraisal(event.appraisalEdit!, event.id))!; + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + PropertyAppraisalEdit newAppraisal = + PropertyAppraisalEdit.fromJson(jsonResponse['data']); + print(response.statusCode); + emit(PropertyAppraisalEditLoaded(newAppraisal)); + + // emit(PropertyAppraisalLoaded(globalPropertyAppraisal)); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_event.dart b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_event.dart new file mode 100644 index 0000000..c1b5d75 --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_event.dart @@ -0,0 +1,28 @@ +part of 'property_appraisal_edit_bloc.dart'; + +abstract class PropertyAppraisalEditEvent extends Equatable { + const PropertyAppraisalEditEvent(); + + @override + List get props => []; +} + +class LoadPropertyAppraisalEdit extends PropertyAppraisalEditEvent { + final PropertyAppraisalEdit appraisalEdit; + final int? id; + + const LoadPropertyAppraisalEdit( + {required this.appraisalEdit, required this.id}); + + @override + List get props => [appraisalEdit]; +} + +class UpdatePropertyAppraisalEdit extends PropertyAppraisalEditEvent { + final PropertyAppraisalEdit? appraisalEdit; + final int? id; + const UpdatePropertyAppraisalEdit({this.appraisalEdit, required this.id}); + + @override + List get props => [appraisalEdit!]; +} diff --git a/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_state.dart b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_state.dart new file mode 100644 index 0000000..c6b812e --- /dev/null +++ b/lib/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_state.dart @@ -0,0 +1,26 @@ +part of 'property_appraisal_edit_bloc.dart'; + +abstract class PropertyAppraisalEditState extends Equatable { + const PropertyAppraisalEditState(); + + @override + List get props => []; +} + +class PropertyAppraisalEditLoading extends PropertyAppraisalEditState {} + +class PropertyAppraisalEditLoaded extends PropertyAppraisalEditState { + PropertyAppraisalEditLoaded(this.appraisalEdit); + final PropertyAppraisalEdit appraisalEdit; + + @override + List get props => [appraisalEdit]; +} + +class PropertyAppraisalEditErrorState extends PropertyAppraisalEditState { + PropertyAppraisalEditErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart b/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart new file mode 100644 index 0000000..9bf078b --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart @@ -0,0 +1,60 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/property_assessment.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/building/property_assessment_services.dart'; + +part 'property_assessment_event.dart'; +part 'property_assessment_state.dart'; + +class PropertyAssessmentBloc + extends Bloc { + PropertyAssessmentBloc() : super(PropertyAssessmentInitial()) { + List globalPropertyAssessment = []; + on((event, emit) async { + emit(PropertyAssessmentLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + + final assessments = await PropertyAssessmentServices.instance + .fetch(tempID.getInt('tempid')! + 1); + + emit(PropertyAssessmentLoaded(assessments)); + } catch (e) { + emit(PropertyAssessmentErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await PropertyAssessmentServices.instance.add(event.assessments))!; + print('Assessment'); + print(response.statusCode); + print(response.body); + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + PropertyAssessment newAssessment = + PropertyAssessment.fromJson(jsonResponse['data']); + + globalPropertyAssessment.add(newAssessment); + + emit(PropertyAssessmentLoaded(globalPropertyAssessment)); + } + }); + on((event, emit) async { + final tempID = await SharedPreferences.getInstance(); + final tempID2 = tempID.getInt('tempid')! - 1; + http.Response response = (await PropertyAssessmentServices.instance + .update(event.assessment, tempID2))!; + print('assessment'); + print(response.statusCode); + print(response.body); + // if (response.statusCode == 201) { + // final faas = await PropertyInfoRepository.getUsers(); + // emit(FaasLoaded(faas)); + // } + }); + } +} diff --git a/lib/bloc/passo/bulding/property_assessment/property_assessment_event.dart b/lib/bloc/passo/bulding/property_assessment/property_assessment_event.dart new file mode 100644 index 0000000..3c7621c --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment/property_assessment_event.dart @@ -0,0 +1,38 @@ +part of 'property_assessment_bloc.dart'; + +abstract class PropertyAssessmentEvent extends Equatable { + const PropertyAssessmentEvent(); + + @override + List get props => []; +} + +class LoadPropertyAssessment extends PropertyAssessmentEvent { + final List assessments; + + const LoadPropertyAssessment( + {this.assessments = const []}); + + @override + List get props => [assessments]; +} + +class AddPropertyAssessment extends PropertyAssessmentEvent { + final PropertyAssessment assessments; + + const AddPropertyAssessment({required this.assessments}); + + @override + List get props => [assessments]; +} + +class UpdatePropertyAssessment extends PropertyAssessmentEvent { + // ignore: non_constant_identifier_names + final PropertyAssessment assessment; + + // ignore: non_constant_identifier_names + const UpdatePropertyAssessment({required this.assessment}); + + @override + List get props => [assessment]; +} diff --git a/lib/bloc/passo/bulding/property_assessment/property_assessment_state.dart b/lib/bloc/passo/bulding/property_assessment/property_assessment_state.dart new file mode 100644 index 0000000..6c88b75 --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment/property_assessment_state.dart @@ -0,0 +1,28 @@ +part of 'property_assessment_bloc.dart'; + +abstract class PropertyAssessmentState extends Equatable { + const PropertyAssessmentState(); + + @override + List get props => []; +} + +class PropertyAssessmentInitial extends PropertyAssessmentState {} + +class PropertyAssessmentLoading extends PropertyAssessmentState {} + +class PropertyAssessmentLoaded extends PropertyAssessmentState { + PropertyAssessmentLoaded(this.assessments); + final List assessments; + + @override + List get props => [assessments]; +} + +class PropertyAssessmentErrorState extends PropertyAssessmentState { + PropertyAssessmentErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart new file mode 100644 index 0000000..517d0fb --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart @@ -0,0 +1,61 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/property_assessment_edit.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/building/property_assessment_services.dart'; +part 'property_assessment_edit_event.dart'; +part 'property_assessment_edit_state.dart'; + +class PropertyAssessmentEditBloc + extends Bloc { + PropertyAssessmentEdit globalPropertyAssessmentEdit; + PropertyAssessmentEditBloc() + : globalPropertyAssessmentEdit = PropertyAssessmentEdit(), + super(PropertyAssessmentEditInitial()) { + on((event, emit) async { + emit(PropertyAssessmentEditLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + + final assessments = + await PropertyAssessmentServices.instance.fetchEdit(event.id); + + emit(PropertyAssessmentEditLoaded(assessments)); + } catch (e) { + emit(PropertyAssessmentEditErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = (await PropertyAssessmentServices.instance + .addEdit(event.assessmentsEdit))!; + print('Assessment'); + print(response.statusCode); + print(response.body); + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + PropertyAssessmentEdit newAssessment = + PropertyAssessmentEdit.fromJson(jsonResponse['data']); + + globalPropertyAssessmentEdit = newAssessment; + + emit(PropertyAssessmentEditLoaded(globalPropertyAssessmentEdit)); + } + }); + on((event, emit) async { + final tempID = await SharedPreferences.getInstance(); + final tempID2 = tempID.getInt('tempid')! - 1; + http.Response response = (await PropertyAssessmentServices.instance + .updateEdit(event.assessmentsEdit, tempID2))!; + print('assessment'); + print(response.statusCode); + print(response.body); + // if (response.statusCode == 201) { + // final faas = await PropertyInfoRepository.getUsers(); + // emit(FaasLoaded(faas)); + // } + }); + } +} diff --git a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_event.dart b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_event.dart new file mode 100644 index 0000000..4d478f4 --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_event.dart @@ -0,0 +1,39 @@ +part of 'property_assessment_edit_bloc.dart'; + +abstract class PropertyAssessmentEditEvent extends Equatable { + const PropertyAssessmentEditEvent(); + + @override + List get props => []; +} + +class LoadPropertyAssessmentEdit extends PropertyAssessmentEditEvent { + final PropertyAssessmentEdit assessmentsEdit; + final int? id; + + const LoadPropertyAssessmentEdit( + {required this.assessmentsEdit, required this.id}); + + @override + List get props => [assessmentsEdit]; +} + +class AddPropertyAssessmentEdit extends PropertyAssessmentEditEvent { + final PropertyAssessmentEdit assessmentsEdit; + + const AddPropertyAssessmentEdit({required this.assessmentsEdit}); + + @override + List get props => [assessmentsEdit]; +} + +class UpdatePropertyAssessmentEdit extends PropertyAssessmentEditEvent { + // ignore: non_constant_identifier_names + final PropertyAssessmentEdit assessmentsEdit; + + // ignore: non_constant_identifier_names + const UpdatePropertyAssessmentEdit({required this.assessmentsEdit}); + + @override + List get props => [assessmentsEdit]; +} diff --git a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_state.dart b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_state.dart new file mode 100644 index 0000000..70d41a8 --- /dev/null +++ b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_state.dart @@ -0,0 +1,28 @@ +part of 'property_assessment_edit_bloc.dart'; + +abstract class PropertyAssessmentEditState extends Equatable { + const PropertyAssessmentEditState(); + + @override + List get props => []; +} + +class PropertyAssessmentEditInitial extends PropertyAssessmentEditState {} + +class PropertyAssessmentEditLoading extends PropertyAssessmentEditState {} + +class PropertyAssessmentEditLoaded extends PropertyAssessmentEditState { + PropertyAssessmentEditLoaded(this.assessmentsEdit); + final PropertyAssessmentEdit assessmentsEdit; + + @override + List get props => [assessmentsEdit]; +} + +class PropertyAssessmentEditErrorState extends PropertyAssessmentEditState { + PropertyAssessmentEditErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/property_info/property_info_bloc.dart b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart new file mode 100644 index 0000000..37a75b9 --- /dev/null +++ b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart @@ -0,0 +1,112 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/sevices/passo/building/general_description_services.dart'; +import 'package:unit2/sevices/passo/building/property_info_services.dart'; +import 'package:http/http.dart' as http; + +import 'package:unit2/sevices/passo/building/structural_material_services.dart'; + +part 'property_info_event.dart'; +part 'property_info_state.dart'; + +class PropertyInfoBloc extends Bloc { + PropertyInfoBloc() : super(PropertyInfoLoading()) { + on((event, emit) async { + emit(PropertyInfoLoading()); + try { + final property_info = await PropertyInfoService.instance.fetch(); + emit(PropertyInfoLoaded(property_info)); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + }); + on((event, emit) async { + final state = this.state; + try { + http.Response response = + (await PropertyInfoService.instance.add(event.property_info))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + final tempID = await SharedPreferences.getInstance(); + print(jsonResponse['data']); + await tempID.setInt('tempid', jsonResponse['data']['id'] + 1); + final faas = await PropertyInfoService.instance.fetch(); + emit(PropertyInfoLoaded(faas)); + } + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + }); + on(((event, emit) async { + final state = this.state; + try { + http.Response response = (await PropertyInfoService.instance + .update(event.property_info, event.property_info.id))!; + print('property_info'); + print(response.body); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + })); + on(((event, emit) async { + final state = this.state; + try { + http.Response response = (await PropertyInfoService.instance + .updateBldg(event.bldg_loc, event.bldg_loc.id))!; + print('bldgLoc'); + print(response.statusCode); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + })); + on( + (event, emit) async { + final state = this.state; + try { + http.Response response = (await PropertyInfoService.instance + .updateLandRef(event.land_ref, event.land_ref.id))!; + print('landref'); + print(response.body); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + }, + ); + + on((event, emit) async { + final state = this.state; + try { + http.Response response = (await PropertyInfoService.instance + .updateGenDesc(event.gen_desc, event.gen_desc.id))!; + print('genDesc'); + print(response.body); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + }); + + on((event, emit) async { + final state = this.state; + try { + final tempID = await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')! - 1); + http.Response response = (await StrucMaterialServices.instance + .update(event.data, event.data.id))!; + print('struc Material'); + print(response.body); + } catch (e) { + emit(PropertyInfoErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/property_info/property_info_event.dart b/lib/bloc/passo/bulding/property_info/property_info_event.dart new file mode 100644 index 0000000..0b678c8 --- /dev/null +++ b/lib/bloc/passo/bulding/property_info/property_info_event.dart @@ -0,0 +1,75 @@ +part of 'property_info_bloc.dart'; + +abstract class PropertyInfoEvent extends Equatable { + const PropertyInfoEvent(); + + @override + List get props => []; +} + +class LoadPropertyInfo extends PropertyInfoEvent { + final List property_info; + + const LoadPropertyInfo({this.property_info = const []}); + + @override + List get props => [property_info]; +} + +class AddPropertyInfo extends PropertyInfoEvent { + final PropertyInfo property_info; + + const AddPropertyInfo({required this.property_info}); + + @override + List get props => [property_info]; +} + +class UpdatPropertyInfo extends PropertyInfoEvent { + // ignore: non_constant_identifier_names + final PropertyInfo property_info; + + // ignore: non_constant_identifier_names + const UpdatPropertyInfo({required this.property_info}); + + @override + List get props => [property_info]; +} + +class UpdateBldgLoc extends PropertyInfoEvent { + // ignore: non_constant_identifier_names + final BldgLoc bldg_loc; + + // ignore: non_constant_identifier_names + const UpdateBldgLoc({required this.bldg_loc}); + + @override + List get props => [bldg_loc]; +} + +class UpdateLandRef extends PropertyInfoEvent { + final LandRef land_ref; + + const UpdateLandRef({required this.land_ref}); + + @override + List get props => [land_ref]; +} + +class UpdateGeneralDesc extends PropertyInfoEvent { + final GeneralDesc gen_desc; + + const UpdateGeneralDesc({required this.gen_desc}); + + @override + List get props => [gen_desc]; +} + +class UpdateStrucMaterials extends PropertyInfoEvent { + final StructureMaterialsII data; + + const UpdateStrucMaterials({required this.data}); + + @override + List get props => [data]; +} diff --git a/lib/bloc/passo/bulding/property_info/property_info_state.dart b/lib/bloc/passo/bulding/property_info/property_info_state.dart new file mode 100644 index 0000000..b325da5 --- /dev/null +++ b/lib/bloc/passo/bulding/property_info/property_info_state.dart @@ -0,0 +1,26 @@ +part of 'property_info_bloc.dart'; + +abstract class PropertyInfoState extends Equatable { + const PropertyInfoState(); + + @override + List get props => []; +} + +class PropertyInfoLoading extends PropertyInfoState {} + +class PropertyInfoLoaded extends PropertyInfoState { + const PropertyInfoLoaded(this.property_info); + final List property_info; + + @override + List get props => [property_info]; +} + +class PropertyInfoErrorState extends PropertyInfoState { + const PropertyInfoErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/structural_material/structural_material_bloc.dart b/lib/bloc/passo/bulding/structural_material/structural_material_bloc.dart new file mode 100644 index 0000000..4d58461 --- /dev/null +++ b/lib/bloc/passo/bulding/structural_material/structural_material_bloc.dart @@ -0,0 +1,23 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/model/passo/structureMaterial.dart'; +import 'package:unit2/sevices/passo/building/structural_material_services.dart'; + +part 'structural_material_event.dart'; +part 'structural_material_state.dart'; + +class StructuralMaterialBloc + extends Bloc { + StructuralMaterialBloc() : super(StructuralMaterialInitial()) { + on((event, emit) async { + emit(StructuralMaterialsLoading()); + try { + final structure = await StrucMaterialServices.instance.fetch(event.id); + emit(StructuralMaterialsLoaded(structure)); + } catch (e) { + emit(StructuralMaterialsErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/structural_material/structural_material_event.dart b/lib/bloc/passo/bulding/structural_material/structural_material_event.dart new file mode 100644 index 0000000..f54301a --- /dev/null +++ b/lib/bloc/passo/bulding/structural_material/structural_material_event.dart @@ -0,0 +1,18 @@ +part of 'structural_material_bloc.dart'; + +class StructuralMaterialEvent extends Equatable { + const StructuralMaterialEvent(); + + @override + List get props => []; +} + +class LoadStructuralMaterial extends StructuralMaterialEvent { + final StructureMaterials structure; + final int? id; + + const LoadStructuralMaterial({required this.structure, required this.id}); + + @override + List get props => [structure]; +} diff --git a/lib/bloc/passo/bulding/structural_material/structural_material_state.dart b/lib/bloc/passo/bulding/structural_material/structural_material_state.dart new file mode 100644 index 0000000..b5c0609 --- /dev/null +++ b/lib/bloc/passo/bulding/structural_material/structural_material_state.dart @@ -0,0 +1,28 @@ +part of 'structural_material_bloc.dart'; + +class StructuralMaterialState extends Equatable { + const StructuralMaterialState(); + + @override + List get props => []; +} + +class StructuralMaterialInitial extends StructuralMaterialState {} + +class StructuralMaterialsLoading extends StructuralMaterialState {} + +class StructuralMaterialsLoaded extends StructuralMaterialState { + const StructuralMaterialsLoaded(this.structure); + final StructureMaterials structure; + + @override + List get props => [structure]; +} + +class StructuralMaterialsErrorState extends StructuralMaterialState { + const StructuralMaterialsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart b/lib/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart new file mode 100644 index 0000000..02f0650 --- /dev/null +++ b/lib/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/sevices/passo/unit_construct_services.dart'; + +part 'unit_construct_event.dart'; +part 'unit_construct_state.dart'; + +class UnitConstructBloc extends Bloc { + UnitConstructBloc() : super(UnitConstructLoading()) { + on((event, emit) async { + emit(UnitConstructLoading()); + try { + final unit = await UnitConstructService.instance.fetch(); + emit(UnitConstructLoaded(unit)); + } catch (e) { + emit(UnitConstructErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/bulding/unit_construct/unit_construct_event.dart b/lib/bloc/passo/bulding/unit_construct/unit_construct_event.dart new file mode 100644 index 0000000..dfd9e83 --- /dev/null +++ b/lib/bloc/passo/bulding/unit_construct/unit_construct_event.dart @@ -0,0 +1,17 @@ +part of 'unit_construct_bloc.dart'; + +abstract class UnitConstructEvent extends Equatable { + const UnitConstructEvent(); + + @override + List get props => []; +} + +class LoadUnitConstruct extends UnitConstructEvent { + final List unit; + + const LoadUnitConstruct({this.unit = const []}); + + @override + List get props => [unit]; +} diff --git a/lib/bloc/passo/bulding/unit_construct/unit_construct_state.dart b/lib/bloc/passo/bulding/unit_construct/unit_construct_state.dart new file mode 100644 index 0000000..51adea0 --- /dev/null +++ b/lib/bloc/passo/bulding/unit_construct/unit_construct_state.dart @@ -0,0 +1,26 @@ +part of 'unit_construct_bloc.dart'; + +abstract class UnitConstructState extends Equatable { + const UnitConstructState(); + + @override + List get props => []; +} + +class UnitConstructLoading extends UnitConstructState {} + +class UnitConstructLoaded extends UnitConstructState { + UnitConstructLoaded(this.unit); + final List unit; + + @override + List get props => [unit]; +} + +class UnitConstructErrorState extends UnitConstructState { + UnitConstructErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart b/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart new file mode 100644 index 0000000..b542dbf --- /dev/null +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart @@ -0,0 +1,60 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/land/land_appraisal.dart'; +part 'land_appraisal_event.dart'; +part 'land_appraisal_state.dart'; + +class LandAppraisalBloc extends Bloc { + LandAppraisalBloc() : super(LandAppraisalLoading()) { + List globalLandAppraisal = []; + on((event, emit) async { + emit(LandAppraisalLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + print(tempID.getInt('landid')); + final additionalItems = + await LandAppraisalServices.instance.fetch(tempID.getInt('tempid')); + + globalLandAppraisal + .addAll(additionalItems); // Append all items to the list + emit(LandAppraisalLoaded(globalLandAppraisal)); + } catch (e) { + emit(LandAppraisalErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await LandAppraisalServices.instance.add(event.land_appr))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + LandAppr newAdditional = LandAppr.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalLandAppraisal.add(newAdditional); + + emit(LandAppraisalLoaded(globalLandAppraisal)); + } + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await LandAppraisalServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalLandAppraisal + .removeWhere(((LandAppr element) => element.id == event.id)); + emit(LandAppraisalDeletedState(success: true)); + } + }); + + on((event, emit) async { + emit(ShowAddLandAppraisalScreen()); + }); + } +} diff --git a/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart b/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart new file mode 100644 index 0000000..50c1007 --- /dev/null +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart @@ -0,0 +1,37 @@ +part of 'land_appraisal_bloc.dart'; + +class LandAppraisalEvent extends Equatable { + const LandAppraisalEvent(); + + @override + List get props => []; +} + +class LoadLandAppraisal extends LandAppraisalEvent { + final List land_appr; + + const LoadLandAppraisal({this.land_appr = const []}); + + @override + List get props => [land_appr]; +} + +class AddLandAppraisal extends LandAppraisalEvent { + final LandAppr land_appr; + + const AddLandAppraisal({required this.land_appr}); + + @override + List get props => [land_appr]; +} + +class DeleteLandAppraisal extends LandAppraisalEvent { + final int id; + + const DeleteLandAppraisal({required this.id}); + + @override + List get props => [id]; +} + +class ShowLandAppraisal extends LandAppraisalEvent {} diff --git a/lib/bloc/passo/land/land_appraisal/land_appraisal_state.dart b/lib/bloc/passo/land/land_appraisal/land_appraisal_state.dart new file mode 100644 index 0000000..d037ad6 --- /dev/null +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_state.dart @@ -0,0 +1,35 @@ +part of 'land_appraisal_bloc.dart'; + +class LandAppraisalState extends Equatable { + const LandAppraisalState(); + + @override + List get props => []; +} + +class LandAppraisalLoading extends LandAppraisalState {} + +class LandAppraisalLoaded extends LandAppraisalState { + const LandAppraisalLoaded(this.land_appr); + final List land_appr; + + @override + List get props => [land_appr]; +} + +class ShowAddLandAppraisalScreen extends LandAppraisalState {} + +class LandAppraisalErrorState extends LandAppraisalState { + const LandAppraisalErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class LandAppraisalDeletedState extends LandAppraisalState { + final bool success; + const LandAppraisalDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/passo/land/land_classification/land_classification_bloc.dart b/lib/bloc/passo/land/land_classification/land_classification_bloc.dart new file mode 100644 index 0000000..cdecd0f --- /dev/null +++ b/lib/bloc/passo/land/land_classification/land_classification_bloc.dart @@ -0,0 +1,22 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:unit2/sevices/passo/land/land_classification.dart'; + +part 'land_classification_event.dart'; +part 'land_classification_state.dart'; + +class LandClassificationBloc + extends Bloc { + LandClassificationBloc() : super(LandClassificationLoading()) { + on((event, emit) async { + emit(LandClassificationLoading()); + try { + final classs = await LandClassificationService.instance.fetch(); + emit(LandClassificationLoaded(classs)); + } catch (e) { + emit(LandClassificationErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/land/land_classification/land_classification_event.dart b/lib/bloc/passo/land/land_classification/land_classification_event.dart new file mode 100644 index 0000000..d0cea3e --- /dev/null +++ b/lib/bloc/passo/land/land_classification/land_classification_event.dart @@ -0,0 +1,18 @@ +part of 'land_classification_bloc.dart'; + +class LandClassificationEvent extends Equatable { + const LandClassificationEvent(); + + @override + List get props => []; +} + +class LoadLandClassification extends LandClassificationEvent { + final List land_classification; + + const LoadLandClassification( + {this.land_classification = const []}); + + @override + List get props => [land_classification]; +} diff --git a/lib/bloc/passo/land/land_classification/land_classification_state.dart b/lib/bloc/passo/land/land_classification/land_classification_state.dart new file mode 100644 index 0000000..eeef362 --- /dev/null +++ b/lib/bloc/passo/land/land_classification/land_classification_state.dart @@ -0,0 +1,26 @@ +part of 'land_classification_bloc.dart'; + +class LandClassificationState extends Equatable { + const LandClassificationState(); + + @override + List get props => []; +} + +class LandClassificationLoading extends LandClassificationState {} + +class LandClassificationLoaded extends LandClassificationState { + LandClassificationLoaded(this.land_classification); + final List land_classification; + + @override + List get props => [land_classification]; +} + +class LandClassificationErrorState extends LandClassificationState { + LandClassificationErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_ext/land_ext_bloc.dart b/lib/bloc/passo/land/land_ext/land_ext_bloc.dart new file mode 100644 index 0000000..7fa7292 --- /dev/null +++ b/lib/bloc/passo/land/land_ext/land_ext_bloc.dart @@ -0,0 +1,57 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/land_ext.dart'; +import 'package:unit2/sevices/passo/land/land_ext.dart'; +import 'package:http/http.dart' as http; +part 'land_ext_event.dart'; +part 'land_ext_state.dart'; + +class LandExtBloc extends Bloc { + LandExtBloc() : super(LandExtInitial()) { + List globalLandExt = []; + on((event, emit) async { + emit(LandExtLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + + final assessments = + await LandExtServices.instance.fetch(tempID.getInt('tempid')! + 1); + + emit(LandExtLoaded(assessments)); + } catch (e) { + emit(LandExtErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await LandExtServices.instance.add(event.landext))!; + print('landext'); + print(response.statusCode); + print(response.body); + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + LandExt newAssessment = LandExt.fromJson(jsonResponse['data']); + + globalLandExt.add(newAssessment); + + emit(LandExtLoaded(globalLandExt)); + } + }); + on((event, emit) async { + final tempID = await SharedPreferences.getInstance(); + final tempID2 = tempID.getInt('tempid')! - 1; + http.Response response = + (await LandExtServices.instance.update(event.landext, tempID2))!; + print('landext'); + print(response.statusCode); + print(response.body); + // if (response.statusCode == 201) { + // final faas = await PropertyInfoRepository.getUsers(); + // emit(FaasLoaded(faas)); + // } + }); + } +} diff --git a/lib/bloc/passo/land/land_ext/land_ext_event.dart b/lib/bloc/passo/land/land_ext/land_ext_event.dart new file mode 100644 index 0000000..8aef275 --- /dev/null +++ b/lib/bloc/passo/land/land_ext/land_ext_event.dart @@ -0,0 +1,37 @@ +part of 'land_ext_bloc.dart'; + +class LandExtEvent extends Equatable { + const LandExtEvent(); + + @override + List get props => []; +} + +class LoadLandExt extends LandExtEvent { + final List landext; + + const LoadLandExt({this.landext = const []}); + + @override + List get props => [landext]; +} + +class AddLandExt extends LandExtEvent { + final LandExt landext; + + const AddLandExt({required this.landext}); + + @override + List get props => [landext]; +} + +class UpdateLandExt extends LandExtEvent { + // ignore: non_constant_identifier_names + final LandExt landext; + + // ignore: non_constant_identifier_names + const UpdateLandExt({required this.landext}); + + @override + List get props => [landext]; +} diff --git a/lib/bloc/passo/land/land_ext/land_ext_state.dart b/lib/bloc/passo/land/land_ext/land_ext_state.dart new file mode 100644 index 0000000..c59eec3 --- /dev/null +++ b/lib/bloc/passo/land/land_ext/land_ext_state.dart @@ -0,0 +1,28 @@ +part of 'land_ext_bloc.dart'; + +class LandExtState extends Equatable { + const LandExtState(); + + @override + List get props => []; +} + +class LandExtInitial extends LandExtState {} + +class LandExtLoading extends LandExtState {} + +class LandExtLoaded extends LandExtState { + LandExtLoaded(this.landext); + final List landext; + + @override + List get props => [landext]; +} + +class LandExtErrorState extends LandExtState { + LandExtErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart new file mode 100644 index 0000000..08d18b0 --- /dev/null +++ b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart @@ -0,0 +1,63 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/sevices/passo/land/land_property_assessment.dart'; +import 'package:http/http.dart' as http; + +part 'land_property_assessment_event.dart'; +part 'land_property_assessment_state.dart'; + +class LandPropertyAssessmentBloc + extends Bloc { + LandPropertyAssessmentBloc() : super(LandPropertyAssessmentLoading()) { + List globalLandPropertyAssessment = []; + on((event, emit) async { + emit(LandPropertyAssessmentLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + print(tempID.getInt('landid')); + final additionalItems = await LandPropertyAssessmentServices.instance + .fetch(tempID.getInt('tempid')); + + globalLandPropertyAssessment + .addAll(additionalItems); // Append all items to the list + emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment)); + } catch (e) { + emit(LandPropertyAssessmentErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = (await LandPropertyAssessmentServices.instance + .add(event.assessment))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + LandPropertyAssessment newAdditional = + LandPropertyAssessment.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalLandPropertyAssessment.add(newAdditional); + + emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment)); + } + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await LandPropertyAssessmentServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalLandPropertyAssessment.removeWhere( + ((LandPropertyAssessment element) => element.id == event.id)); + emit(LandPropertyAssessmentDeletedState(success: true)); + } + }); + + on((event, emit) async { + emit(ShowAddLandPropertyAssessmentScreen()); + }); + } +} diff --git a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart new file mode 100644 index 0000000..7eb84e0 --- /dev/null +++ b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart @@ -0,0 +1,38 @@ +part of 'land_property_assessment_bloc.dart'; + +class LandPropertyAssessmentEvent extends Equatable { + const LandPropertyAssessmentEvent(); + + @override + List get props => []; +} + +class LoadLandPropertyAssessment extends LandPropertyAssessmentEvent { + final List assessment; + + const LoadLandPropertyAssessment( + {this.assessment = const []}); + + @override + List get props => [assessment]; +} + +class AddLandPropertyAssessment extends LandPropertyAssessmentEvent { + final LandPropertyAssessment assessment; + + const AddLandPropertyAssessment({required this.assessment}); + + @override + List get props => [assessment]; +} + +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/passo/land/land_property_assessment/land_property_assessment_state.dart b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_state.dart new file mode 100644 index 0000000..ce2d738 --- /dev/null +++ b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_state.dart @@ -0,0 +1,35 @@ +part of 'land_property_assessment_bloc.dart'; + +class LandPropertyAssessmentState extends Equatable { + const LandPropertyAssessmentState(); + + @override + List get props => []; +} + +class LandPropertyAssessmentLoading extends LandPropertyAssessmentState {} + +class LandPropertyAssessmentLoaded extends LandPropertyAssessmentState { + const LandPropertyAssessmentLoaded(this.assessment); + final List assessment; + + @override + List get props => [assessment]; +} + +class ShowAddLandPropertyAssessmentScreen 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/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart new file mode 100644 index 0000000..1abcfdc --- /dev/null +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart @@ -0,0 +1,65 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/land_property_boundaries.dart'; +import 'package:unit2/model/passo/land_property_loc.dart'; +import 'package:unit2/model/passo/land_property_owner.dart'; +import 'package:unit2/sevices/passo/land/land_boundaries.dart'; +import 'package:unit2/sevices/passo/land/land_location.dart'; +import 'package:unit2/sevices/passo/land/land_property_owner.dart'; +import 'package:http/http.dart' as http; +part 'land_property_owner_info_event.dart'; +part 'land_property_owner_info_state.dart'; + +class LandPropertyOwnerInfoBloc + extends Bloc { + LandPropertyOwnerInfoBloc() : super(LandLoading()) { + on((event, emit) async { + emit(LandLoading()); + try { + final faas = await LandServices.instance.fetch(); + emit(LandLoaded(faas)); + } catch (e) { + emit(LandErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = (await LandServices.instance.add(event.land))!; + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + var details = jsonResponse['data']['details']; + + if (details != null) { + var id = details['id']; + final tempID = await SharedPreferences.getInstance(); + print(id); + await tempID.setInt('landid', id + 1); + final faas = await LandServices.instance.fetch(); + emit(LandLoaded(faas)); + } else { + print("No 'details' object found in the response."); + // Handle the case when 'details' is missing + } + } + }); + + on((event, emit) async { + final state = this.state; + http.Response response = (await LandLocationService.instance + .update(event.land_loc, event.land_loc.id))!; + print('Land LOc'); + print(response.body); + }); + + on((event, emit) async { + final state = this.state; + http.Response response = (await LandBoundariesService.instance + .update(event.land_boundaries, event.land_boundaries.id))!; + print('Land Boundaries'); + print(response.body); + }); + } +} diff --git a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart new file mode 100644 index 0000000..c05cacf --- /dev/null +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart @@ -0,0 +1,48 @@ +part of 'land_property_owner_info_bloc.dart'; + +class LandPropertyOwnerInfoEvent extends Equatable { + const LandPropertyOwnerInfoEvent(); + + @override + List get props => []; +} + +class LoadLand extends LandPropertyOwnerInfoEvent { + final List land; + + const LoadLand({this.land = const []}); + + @override + List get props => [land]; +} + +class AddPropertyOwnerLand extends LandPropertyOwnerInfoEvent { + final LandPropertyOwner land; + + const AddPropertyOwnerLand({required this.land}); + + @override + List get props => [land]; +} + +class UpdateLandLoc extends LandPropertyOwnerInfoEvent { + // ignore: non_constant_identifier_names + final LandPropertyLoc land_loc; + + // ignore: non_constant_identifier_names + const UpdateLandLoc({required this.land_loc}); + + @override + List get props => [land_loc]; +} + +class UpdateLandBoundaries extends LandPropertyOwnerInfoEvent { + // ignore: non_constant_identifier_names + final LandPropertyBoundaries land_boundaries; + + // ignore: non_constant_identifier_names + const UpdateLandBoundaries({required this.land_boundaries}); + + @override + List get props => [land_boundaries]; +} diff --git a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart new file mode 100644 index 0000000..ec64d5f --- /dev/null +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart @@ -0,0 +1,34 @@ +part of 'land_property_owner_info_bloc.dart'; + +class LandPropertyOwnerInfoState extends Equatable { + const LandPropertyOwnerInfoState(); + + @override + List get props => []; +} + +class LandLoading extends LandPropertyOwnerInfoState {} + +class LandLoaded extends LandPropertyOwnerInfoState { + const LandLoaded(this.land); + final List land; + + @override + List get props => [land]; +} + +// class PropertyAppraisalLoaded extends AssessorsState { +// PropertyAppraisalLoaded(this.appraisal); +// final List appraisal; + +// @override +// List get props => [appraisal]; +// } + +class LandErrorState extends LandPropertyOwnerInfoState { + const LandErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart b/lib/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart new file mode 100644 index 0000000..edca8e3 --- /dev/null +++ b/lib/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart @@ -0,0 +1,25 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:unit2/model/passo/land_subclassification.dart'; +import 'package:unit2/sevices/passo/land/land_classification.dart'; +import 'package:unit2/sevices/passo/land/land_subclassification.dart'; + +part 'land_subclassification_event.dart'; +part 'land_subclassification_state.dart'; + +class LandSubClassificationBloc + extends Bloc { + LandSubClassificationBloc() : super(LandSubClassificationLoading()) { + on((event, emit) async { + emit(LandSubClassificationLoading()); + try { + final classs = await LandSubClassificationService.instance + .fetch(event.cityCode, event.classCode); + emit(LandSubClassificationLoaded(classs)); + } catch (e) { + emit(LandSubClassificationErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/land/land_subclassification/land_subclassification_event.dart b/lib/bloc/passo/land/land_subclassification/land_subclassification_event.dart new file mode 100644 index 0000000..dfd7a29 --- /dev/null +++ b/lib/bloc/passo/land/land_subclassification/land_subclassification_event.dart @@ -0,0 +1,19 @@ +part of 'land_subclassification_bloc.dart'; + +class LandSubClassificationEvent extends Equatable { + const LandSubClassificationEvent(); + + @override + List get props => []; +} + +class LoadLandSubClassification extends LandSubClassificationEvent { + final String cityCode; + final int classCode; + + const LoadLandSubClassification( + {required this.cityCode, required this.classCode}); + + @override + List get props => [cityCode, classCode]; +} diff --git a/lib/bloc/passo/land/land_subclassification/land_subclassification_state.dart b/lib/bloc/passo/land/land_subclassification/land_subclassification_state.dart new file mode 100644 index 0000000..d0f1be9 --- /dev/null +++ b/lib/bloc/passo/land/land_subclassification/land_subclassification_state.dart @@ -0,0 +1,26 @@ +part of 'land_subclassification_bloc.dart'; + +class LandSubClassificationState extends Equatable { + const LandSubClassificationState(); + + @override + List get props => []; +} + +class LandSubClassificationLoading extends LandSubClassificationState {} + +class LandSubClassificationLoaded extends LandSubClassificationState { + LandSubClassificationLoaded(this.land_subclassification); + final List land_subclassification; + + @override + List get props => [land_subclassification]; +} + +class LandSubClassificationErrorState extends LandSubClassificationState { + LandSubClassificationErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart new file mode 100644 index 0000000..6f270ab --- /dev/null +++ b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart @@ -0,0 +1,22 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/trees_improvements.dart'; +import 'package:unit2/sevices/passo/land/land_trees_improvements.dart'; + +part 'land_trees_improvements_event.dart'; +part 'land_trees_improvements_state.dart'; + +class LandTreesImprovementsBloc + extends Bloc { + LandTreesImprovementsBloc() : super(LandTreesImprovementsInitial()) { + on((event, emit) async { + emit(LandTreesImprovementsLoading()); + try { + final trees_imp = await LandTreesImprovementsServices.instance.fetch(); + emit(LandTreesImprovementsLoaded(trees_imp)); + } catch (e) { + emit(LandTreesImprovementsErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_event.dart b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_event.dart new file mode 100644 index 0000000..690977c --- /dev/null +++ b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_event.dart @@ -0,0 +1,17 @@ +part of 'land_trees_improvements_bloc.dart'; + +class LandTreesImprovementsEvent extends Equatable { + const LandTreesImprovementsEvent(); + + @override + List get props => []; +} + +class LoadLandTreesImprovements extends LandTreesImprovementsEvent { + final List trees_imp; + const LoadLandTreesImprovements( + {this.trees_imp = const []}); + + @override + List get props => [trees_imp]; +} diff --git a/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_state.dart b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_state.dart new file mode 100644 index 0000000..f11621a --- /dev/null +++ b/lib/bloc/passo/land/land_trees_improvements/land_trees_improvements_state.dart @@ -0,0 +1,28 @@ +part of 'land_trees_improvements_bloc.dart'; + +class LandTreesImprovementsState extends Equatable { + const LandTreesImprovementsState(); + + @override + List get props => []; +} + +class LandTreesImprovementsInitial extends LandTreesImprovementsState {} + +class LandTreesImprovementsLoading extends LandTreesImprovementsState {} + +class LandTreesImprovementsLoaded extends LandTreesImprovementsState { + LandTreesImprovementsLoaded(this.trees_imp); + final List trees_imp; + + @override + List get props => [trees_imp]; +} + +class LandTreesImprovementsErrorState extends LandTreesImprovementsState { + LandTreesImprovementsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart new file mode 100644 index 0000000..7655903 --- /dev/null +++ b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart @@ -0,0 +1,59 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/sevices/passo/land/land_value_adjustment.dart'; +part 'land_value_adjustments_event.dart'; +part 'land_value_adjustments_state.dart'; + +class LandValueAdjustmentsBloc + extends Bloc { + LandValueAdjustmentsBloc() : super(LandValueAdjustmentsLoading()) { + List globalLandValueAdjustments = []; + on((event, emit) async { + emit(LandValueAdjustmentsLoading()); + try { + // final tempID = await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // final additionalItem = await GetLandValueAdjustments.getLandValueAdjustments( + // tempID.getInt('tempid')); + + emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments)); + } catch (e) { + emit(LandValueAdjustmentsErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await ValueAdjustmentsServices.instance.add(event.val_adj))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + ValueAdjustments newAdditional = + ValueAdjustments.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalLandValueAdjustments.add(newAdditional); + + emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments)); + } + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await ValueAdjustmentsServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalLandValueAdjustments.removeWhere( + ((ValueAdjustments element) => element.id == event.id)); + emit(LandValueAdjustmentsDeletedState(success: true)); + } + }); + + on((event, emit) async { + emit(ShowAddLandValueAdjustmentsScreen()); + }); + } +} diff --git a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart new file mode 100644 index 0000000..857e6f8 --- /dev/null +++ b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart @@ -0,0 +1,37 @@ +part of 'land_value_adjustments_bloc.dart'; + +class LandValueAdjustmentsEvent extends Equatable { + const LandValueAdjustmentsEvent(); + + @override + List get props => []; +} + +class LoadLandValueAdjustments extends LandValueAdjustmentsEvent { + final List val_adj; + + const LoadLandValueAdjustments({this.val_adj = const []}); + + @override + List get props => [val_adj]; +} + +class AddLandValueAdjustments extends LandValueAdjustmentsEvent { + final ValueAdjustments val_adj; + + const AddLandValueAdjustments({required this.val_adj}); + + @override + List get props => [val_adj]; +} + +class DeleteLandValueAdjustments extends LandValueAdjustmentsEvent { + final int id; + + const DeleteLandValueAdjustments({required this.id}); + + @override + List get props => [id]; +} + +class ShowLandValueAdjustments extends LandValueAdjustmentsEvent {} diff --git a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_state.dart b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_state.dart new file mode 100644 index 0000000..8f76eec --- /dev/null +++ b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_state.dart @@ -0,0 +1,35 @@ +part of 'land_value_adjustments_bloc.dart'; + +class LandValueAdjustmentsState extends Equatable { + const LandValueAdjustmentsState(); + + @override + List get props => []; +} + +class LandValueAdjustmentsLoading extends LandValueAdjustmentsState {} + +class LandValueAdjustmentsLoaded extends LandValueAdjustmentsState { + const LandValueAdjustmentsLoaded(this.val_adj); + final List val_adj; + + @override + List get props => [val_adj]; +} + +class ShowAddLandValueAdjustmentsScreen extends LandValueAdjustmentsState {} + +class LandValueAdjustmentsErrorState extends LandValueAdjustmentsState { + const LandValueAdjustmentsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class LandValueAdjustmentsDeletedState extends LandValueAdjustmentsState { + final bool success; + const LandValueAdjustmentsDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart b/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart new file mode 100644 index 0000000..3271961 --- /dev/null +++ b/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart @@ -0,0 +1,59 @@ +import 'dart:convert'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/sevices/passo/land/land_other_improvements.dart'; +import 'package:http/http.dart' as http; +part 'other_improvements_event.dart'; +part 'other_improvements_state.dart'; + +class OtherImprovementsBloc + extends Bloc { + OtherImprovementsBloc() : super(OtherImprovementLoading()) { + List globalOtherImprovement = []; + on((event, emit) async { + emit(OtherImprovementLoading()); + try { + // final tempID = await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // final additionalItem = await GetOtherImprovement.getOtherImprovement( + // tempID.getInt('tempid')); + + emit(OtherImprovementLoaded(globalOtherImprovement)); + } catch (e) { + emit(OtherImprovementErrorState(e.toString())); + } + }); + on((event, emit) async { + http.Response response = + (await OtherImprovementServices.instance.add(event.other_imp))!; + print(response.body); + + if (response.statusCode == 201) { + var jsonResponse = jsonDecode(response.body); + OtherImprovements newAdditional = + OtherImprovements.fromJson(jsonResponse['data']); + print(jsonResponse['data']); + globalOtherImprovement.add(newAdditional); + + emit(OtherImprovementLoaded(globalOtherImprovement)); + } + }); + on((event, emit) async { + print(event.id); + http.Response response = + (await OtherImprovementServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + globalOtherImprovement.removeWhere( + ((OtherImprovements element) => element.id == event.id)); + emit(OtherImprovementDeletedState(success: true)); + } + }); + + on((event, emit) async { + emit(ShowAddOtherImprovementScreen()); + }); + } +} diff --git a/lib/bloc/passo/land/other_improvements/other_improvements_event.dart b/lib/bloc/passo/land/other_improvements/other_improvements_event.dart new file mode 100644 index 0000000..135746f --- /dev/null +++ b/lib/bloc/passo/land/other_improvements/other_improvements_event.dart @@ -0,0 +1,37 @@ +part of 'other_improvements_bloc.dart'; + +class OtherImprovementsEvent extends Equatable { + const OtherImprovementsEvent(); + + @override + List get props => []; +} + +class LoadOtherImprovement extends OtherImprovementsEvent { + final List other_imp; + + const LoadOtherImprovement({this.other_imp = const []}); + + @override + List get props => [other_imp]; +} + +class AddOtherImprovement extends OtherImprovementsEvent { + final OtherImprovements other_imp; + + const AddOtherImprovement({required this.other_imp}); + + @override + List get props => [other_imp]; +} + +class DeleteOtherImprovement extends OtherImprovementsEvent { + final int id; + + const DeleteOtherImprovement({required this.id}); + + @override + List get props => [id]; +} + +class ShowOtherImprovement extends OtherImprovementsEvent {} diff --git a/lib/bloc/passo/land/other_improvements/other_improvements_state.dart b/lib/bloc/passo/land/other_improvements/other_improvements_state.dart new file mode 100644 index 0000000..75b3b01 --- /dev/null +++ b/lib/bloc/passo/land/other_improvements/other_improvements_state.dart @@ -0,0 +1,35 @@ +part of 'other_improvements_bloc.dart'; + +class OtherImprovementsState extends Equatable { + const OtherImprovementsState(); + + @override + List get props => []; +} + +class OtherImprovementLoading extends OtherImprovementsState {} + +class OtherImprovementLoaded extends OtherImprovementsState { + const OtherImprovementLoaded(this.other_imp); + final List other_imp; + + @override + List get props => [other_imp]; +} + +class ShowAddOtherImprovementScreen extends OtherImprovementsState {} + +class OtherImprovementErrorState extends OtherImprovementsState { + const OtherImprovementErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class OtherImprovementDeletedState extends OtherImprovementsState { + final bool success; + const OtherImprovementDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/passo/land/type_of_location/type_of_location_bloc.dart b/lib/bloc/passo/land/type_of_location/type_of_location_bloc.dart new file mode 100644 index 0000000..439e0e2 --- /dev/null +++ b/lib/bloc/passo/land/type_of_location/type_of_location_bloc.dart @@ -0,0 +1,22 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/type_of_location.dart'; +import 'package:unit2/sevices/passo/land/type_of_location.dart'; + +part 'type_of_location_event.dart'; +part 'type_of_location_state.dart'; + +class TypeOfLocationBloc + extends Bloc { + TypeOfLocationBloc() : super(TypeOfLocationInitial()) { + on((event, emit) async { + emit(TypeOfLocationLoading()); + try { + final locType = await TypeOfLocationServices.instance.fetch(); + emit(TypeOfLocationLoaded(locType)); + } catch (e) { + emit(TypeOfLocationErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/land/type_of_location/type_of_location_event.dart b/lib/bloc/passo/land/type_of_location/type_of_location_event.dart new file mode 100644 index 0000000..dfcd9b9 --- /dev/null +++ b/lib/bloc/passo/land/type_of_location/type_of_location_event.dart @@ -0,0 +1,17 @@ +part of 'type_of_location_bloc.dart'; + +class TypeOfLocationEvent extends Equatable { + const TypeOfLocationEvent(); + + @override + List get props => []; +} + +class LoadTypeOfLocation extends TypeOfLocationEvent { + final List locType; + + const LoadTypeOfLocation({this.locType = const []}); + + @override + List get props => [locType]; +} diff --git a/lib/bloc/passo/land/type_of_location/type_of_location_state.dart b/lib/bloc/passo/land/type_of_location/type_of_location_state.dart new file mode 100644 index 0000000..cbbb893 --- /dev/null +++ b/lib/bloc/passo/land/type_of_location/type_of_location_state.dart @@ -0,0 +1,28 @@ +part of 'type_of_location_bloc.dart'; + +class TypeOfLocationState extends Equatable { + const TypeOfLocationState(); + + @override + List get props => []; +} + +class TypeOfLocationInitial extends TypeOfLocationState {} + +class TypeOfLocationLoading extends TypeOfLocationState {} + +class TypeOfLocationLoaded extends TypeOfLocationState { + TypeOfLocationLoaded(this.loc_type); + final List loc_type; + + @override + List get props => [loc_type]; +} + +class TypeOfLocationErrorState extends TypeOfLocationState { + TypeOfLocationErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/type_of_road/type_of_road_bloc.dart b/lib/bloc/passo/land/type_of_road/type_of_road_bloc.dart new file mode 100644 index 0000000..555a75b --- /dev/null +++ b/lib/bloc/passo/land/type_of_road/type_of_road_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/type_of_road.dart'; +import 'package:unit2/sevices/passo/land/type_of_road.dart'; + +part 'type_of_road_event.dart'; +part 'type_of_road_state.dart'; + +class TypeOfRoadBloc extends Bloc { + TypeOfRoadBloc() : super(TypeOfRoadInitial()) { + on((event, emit) async { + emit(TypeOfRoadLoading()); + try { + final roadType = await TypeOfRoadServices.instance.fetch(); + emit(TypeOfRoadLoaded(roadType)); + } catch (e) { + emit(TypeOfRoadErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/land/type_of_road/type_of_road_event.dart b/lib/bloc/passo/land/type_of_road/type_of_road_event.dart new file mode 100644 index 0000000..1d3cdd3 --- /dev/null +++ b/lib/bloc/passo/land/type_of_road/type_of_road_event.dart @@ -0,0 +1,17 @@ +part of 'type_of_road_bloc.dart'; + +class TypeOfRoadEvent extends Equatable { + const TypeOfRoadEvent(); + + @override + List get props => []; +} + +class LoadTypeOfRoad extends TypeOfRoadEvent { + final List roadType; + + const LoadTypeOfRoad({this.roadType = const []}); + + @override + List get props => [roadType]; +} diff --git a/lib/bloc/passo/land/type_of_road/type_of_road_state.dart b/lib/bloc/passo/land/type_of_road/type_of_road_state.dart new file mode 100644 index 0000000..ad65a1c --- /dev/null +++ b/lib/bloc/passo/land/type_of_road/type_of_road_state.dart @@ -0,0 +1,28 @@ +part of 'type_of_road_bloc.dart'; + +class TypeOfRoadState extends Equatable { + const TypeOfRoadState(); + + @override + List get props => []; +} + +class TypeOfRoadInitial extends TypeOfRoadState {} + +class TypeOfRoadLoading extends TypeOfRoadState {} + +class TypeOfRoadLoaded extends TypeOfRoadState { + TypeOfRoadLoaded(this.road_type); + final List road_type; + + @override + List get props => [road_type]; +} + +class TypeOfRoadErrorState extends TypeOfRoadState { + TypeOfRoadErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/memoranda/memoranda_bloc.dart b/lib/bloc/passo/memoranda/memoranda_bloc.dart new file mode 100644 index 0000000..c1b1a31 --- /dev/null +++ b/lib/bloc/passo/memoranda/memoranda_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/memoranda.dart'; +import 'package:unit2/sevices/passo/memoranda.dart'; + +part 'memoranda_event.dart'; +part 'memoranda_state.dart'; + +class MemorandaBloc extends Bloc { + MemorandaBloc() : super(MemorandaInitial()) { + on((event, emit) async { + emit(MemorandaLoading()); + try { + final municipality = await MemorandaServices.instance.fetch(); + emit(MemorandaLoaded(municipality)); + } catch (e) { + emit(MemorandaErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/memoranda/memoranda_event.dart b/lib/bloc/passo/memoranda/memoranda_event.dart new file mode 100644 index 0000000..06ac2b6 --- /dev/null +++ b/lib/bloc/passo/memoranda/memoranda_event.dart @@ -0,0 +1,16 @@ +part of 'memoranda_bloc.dart'; + +class MemorandaEvent extends Equatable { + const MemorandaEvent(); + + @override + List get props => []; +} + +class LoadMemoranda extends MemorandaEvent { + final List memoranda; + const LoadMemoranda({this.memoranda = const []}); + + @override + List get props => [memoranda]; +} diff --git a/lib/bloc/passo/memoranda/memoranda_state.dart b/lib/bloc/passo/memoranda/memoranda_state.dart new file mode 100644 index 0000000..1803cd8 --- /dev/null +++ b/lib/bloc/passo/memoranda/memoranda_state.dart @@ -0,0 +1,28 @@ +part of 'memoranda_bloc.dart'; + +class MemorandaState extends Equatable { + const MemorandaState(); + + @override + List get props => []; +} + +class MemorandaInitial extends MemorandaState {} + +class MemorandaLoading extends MemorandaState {} + +class MemorandaLoaded extends MemorandaState { + MemorandaLoaded(this.memorada); + final List memorada; + + @override + List get props => [memorada]; +} + +class MemorandaErrorState extends MemorandaState { + MemorandaErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/municipality/municipality_bloc.dart b/lib/bloc/passo/municipality/municipality_bloc.dart new file mode 100644 index 0000000..3a6a246 --- /dev/null +++ b/lib/bloc/passo/municipality/municipality_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/sevices/passo/municipality.dart'; + +part 'municipality_event.dart'; +part 'municipality_state.dart'; + +class MunicipalityBloc extends Bloc { + MunicipalityBloc() : super(MunicipalityInitial()) { + on((event, emit) async { + emit(MunicipalityLoading()); + try { + final municipality = await MunicipalityServices.instance.fetch(); + emit(MunicipalityLoaded(municipality)); + } catch (e) { + emit(MunicipalityErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/municipality/municipality_event.dart b/lib/bloc/passo/municipality/municipality_event.dart new file mode 100644 index 0000000..4b7556f --- /dev/null +++ b/lib/bloc/passo/municipality/municipality_event.dart @@ -0,0 +1,17 @@ +part of 'municipality_bloc.dart'; + +class MunicipalityEvent extends Equatable { + const MunicipalityEvent(); + + @override + List get props => []; +} + +class LoadMunicipality extends MunicipalityEvent { + final List municipality; + + const LoadMunicipality({this.municipality = const []}); + + @override + List get props => [municipality]; +} diff --git a/lib/bloc/passo/municipality/municipality_state.dart b/lib/bloc/passo/municipality/municipality_state.dart new file mode 100644 index 0000000..25c1131 --- /dev/null +++ b/lib/bloc/passo/municipality/municipality_state.dart @@ -0,0 +1,28 @@ +part of 'municipality_bloc.dart'; + +class MunicipalityState extends Equatable { + const MunicipalityState(); + + @override + List get props => []; +} + +class MunicipalityInitial extends MunicipalityState {} + +class MunicipalityLoading extends MunicipalityState {} + +class MunicipalityLoaded extends MunicipalityState { + MunicipalityLoaded(this.municipality); + final List municipality; + + @override + List get props => [municipality]; +} + +class MunicipalityErrorState extends MunicipalityState { + MunicipalityErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/signatories/signatories_bloc.dart b/lib/bloc/passo/signatories/signatories_bloc.dart new file mode 100644 index 0000000..8c55403 --- /dev/null +++ b/lib/bloc/passo/signatories/signatories_bloc.dart @@ -0,0 +1,21 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/sevices/passo/signatories_service.dart'; + +part 'signatories_event.dart'; +part 'signatories_state.dart'; + +class SignatoriesBloc extends Bloc { + SignatoriesBloc() : super(SignatoriesInitial()) { + on((event, emit) async { + emit(SignatoriesLoading()); + try { + final signatories = await SignatoriesServices.instance.fetch(); + emit(SignatoriesLoaded(signatories)); + } catch (e) { + emit(SignatoriesErrorState(e.toString())); + } + }); + } +} diff --git a/lib/bloc/passo/signatories/signatories_event.dart b/lib/bloc/passo/signatories/signatories_event.dart new file mode 100644 index 0000000..a1949cd --- /dev/null +++ b/lib/bloc/passo/signatories/signatories_event.dart @@ -0,0 +1,17 @@ +part of 'signatories_bloc.dart'; + +abstract class SignatoriesEvent extends Equatable { + const SignatoriesEvent(); + + @override + List get props => []; +} + +class LoadSignatories extends SignatoriesEvent { + final List signatories; + + const LoadSignatories({this.signatories = const []}); + + @override + List get props => [signatories]; +} diff --git a/lib/bloc/passo/signatories/signatories_state.dart b/lib/bloc/passo/signatories/signatories_state.dart new file mode 100644 index 0000000..a914bc9 --- /dev/null +++ b/lib/bloc/passo/signatories/signatories_state.dart @@ -0,0 +1,28 @@ +part of 'signatories_bloc.dart'; + +abstract class SignatoriesState extends Equatable { + const SignatoriesState(); + + @override + List get props => []; +} + +class SignatoriesInitial extends SignatoriesState {} + +class SignatoriesLoading extends SignatoriesState {} + +class SignatoriesLoaded extends SignatoriesState { + SignatoriesLoaded(this.signatories); + final List signatories; + + @override + List get props => [signatories]; +} + +class SignatoriesErrorState extends SignatoriesState { + SignatoriesErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/model/passo/additional_items.dart b/lib/model/passo/additional_items.dart new file mode 100644 index 0000000..9f89494 --- /dev/null +++ b/lib/model/passo/additional_items.dart @@ -0,0 +1,93 @@ +// To parse this JSON data, do +// +// final additionalItems = additionalItemsFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +AdditionalItems additionalItemsFromJson(String str) => + AdditionalItems.fromJson(json.decode(str)); + +String additionalItemsToJson(AdditionalItems data) => + json.encode(data.toJson()); + +class AdditionalItems { + final int id; + final int bldgapprDetailsId; + final int classId; + final String className; + final String structType; + final dynamic unitValue; + final dynamic baseUnitValue; + final dynamic area; + final dynamic marketValue; + final dynamic depreciationRate; + final dynamic adjustedMarketVal; + final dynamic amtDepreciation; + final bool painted; + final bool secondhand; + final dynamic paintedUnitval; + final dynamic secondhandUnitval; + final String actualUse; + + AdditionalItems({ + required this.id, + required this.bldgapprDetailsId, + required this.classId, + required this.className, + required this.structType, + required this.unitValue, + required this.baseUnitValue, + required this.area, + required this.marketValue, + required this.depreciationRate, + required this.adjustedMarketVal, + required this.amtDepreciation, + required this.painted, + required this.secondhand, + required this.paintedUnitval, + required this.secondhandUnitval, + required this.actualUse, + }); + + factory AdditionalItems.fromJson(Map json) => + AdditionalItems( + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + classId: json["class_id"], + className: json["class_name"], + structType: json["struct_type"], + unitValue: json["unit_value"], + baseUnitValue: json["base_unit_value"], + area: json["area"], + marketValue: json["market_value"], + depreciationRate: json["depreciation_rate"], + adjustedMarketVal: json["adjusted_market_val"], + amtDepreciation: json["amt_depreciation"], + painted: json["painted"], + secondhand: json["secondhand"], + paintedUnitval: json["painted_unitval"], + secondhandUnitval: json["secondhand_unitval"], + actualUse: json["actual_use"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "class_id": classId, + "class_name": className, + "struct_type": structType, + "unit_value": unitValue, + "base_unit_value": baseUnitValue, + "area": area, + "market_value": marketValue, + "depreciation_rate": depreciationRate, + "adjusted_market_val": adjustedMarketVal, + "amt_depreciation": amtDepreciation, + "painted": painted, + "secondhand": secondhand, + "painted_unitval": paintedUnitval, + "secondhand_unitval": secondhandUnitval, + "actual_use": actualUse, + }; +} diff --git a/lib/model/passo/barangay.dart b/lib/model/passo/barangay.dart new file mode 100644 index 0000000..6dacfa1 --- /dev/null +++ b/lib/model/passo/barangay.dart @@ -0,0 +1,37 @@ +// To parse this JSON data, do +// +// final barangay = barangayFromJson(jsonString); + +import 'dart:convert'; + +Brgy barangayFromJson(String str) => Brgy.fromJson(json.decode(str)); + +String barangayToJson(Brgy data) => json.encode(data.toJson()); + +class Brgy { + final int? barangayId; + final String? barangayCode; + final String? cityCode; + final String? barangayDescription; + + Brgy({ + this.barangayId, + this.barangayCode, + this.cityCode, + this.barangayDescription, + }); + + factory Brgy.fromJson(Map json) => Brgy( + barangayId: json["barangay_id"], + barangayCode: json["barangay_code"], + cityCode: json["city_code"], + barangayDescription: json["barangay_description"], + ); + + Map toJson() => { + "barangay_id": barangayId, + "barangay_code": barangayCode, + "city_code": cityCode, + "barangay_description": barangayDescription, + }; +} diff --git a/lib/model/passo/bldg_loc.dart b/lib/model/passo/bldg_loc.dart new file mode 100644 index 0000000..06714fb --- /dev/null +++ b/lib/model/passo/bldg_loc.dart @@ -0,0 +1,65 @@ +// To parse this JSON data, do +// +// final bldgLoc = bldgLocFromJson(jsonString); + +import 'dart:convert'; + +BldgLoc bldgLocFromJson(String str) => BldgLoc.fromJson(json.decode(str)); + +String bldgLocToJson(BldgLoc data) => json.encode(data.toJson()); + +class BldgLoc { + final int? id; + final int? bldgapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final dynamic street; + final dynamic barangay; + final dynamic municipality; + final dynamic province; + + BldgLoc({ + this.id, + this.bldgapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.street, + this.barangay, + this.municipality, + this.province, + }); + + factory BldgLoc.fromJson(Map json) => BldgLoc( + id: json["id"], + 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"]), + street: json["street"], + barangay: json["barangay"], + municipality: json["municipality"], + province: json["province"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "street": street, + "barangay": barangay, + "municipality": municipality, + "province": province, + }; +} diff --git a/lib/model/passo/city.dart b/lib/model/passo/city.dart new file mode 100644 index 0000000..eb22f22 --- /dev/null +++ b/lib/model/passo/city.dart @@ -0,0 +1,29 @@ +// To parse this JSON data, do +// +// final city = cityFromJson(jsonString); + +import 'dart:convert'; + +City cityFromJson(String str) => City.fromJson(json.decode(str)); + +String cityToJson(City data) => json.encode(data.toJson()); + +class City { + final String? cityCode; + final String? cityDescription; + + City({ + this.cityCode, + this.cityDescription, + }); + + factory City.fromJson(Map json) => City( + cityCode: json["city_code"], + cityDescription: json["city_description"], + ); + + Map toJson() => { + "city_code": cityCode, + "city_description": cityDescription, + }; +} diff --git a/lib/model/passo/class_components.dart b/lib/model/passo/class_components.dart new file mode 100644 index 0000000..b9ce05b --- /dev/null +++ b/lib/model/passo/class_components.dart @@ -0,0 +1,93 @@ +// To parse this JSON data, do +// +// final classComponents = classComponentsFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +ClassComponents classComponentsFromJson(String str) => + ClassComponents.fromJson(json.decode(str)); + +String classComponentsToJson(ClassComponents data) => + json.encode(data.toJson()); + +class ClassComponents { + final int id; + final String componentName; + final String minBaseUnitvalPercent; + final String maxBaseUnitvalPercent; + final String minUnitvalSqrmtr; + final String maxUnitvalSqrmtr; + final String minAddBaseunitval; + final String maxAddBaseunitval; + final String minDeductBaserate; + final String maxDeductBaserate; + final String minLinearMeter; + final String maxLinearMeter; + final String minSpacing; + final String maxSpacing; + final String roughFinish; + final String highFinish; + final bool withoutBucc; + + ClassComponents({ + required this.id, + required this.componentName, + required this.minBaseUnitvalPercent, + required this.maxBaseUnitvalPercent, + required this.minUnitvalSqrmtr, + required this.maxUnitvalSqrmtr, + required this.minAddBaseunitval, + required this.maxAddBaseunitval, + required this.minDeductBaserate, + required this.maxDeductBaserate, + required this.minLinearMeter, + required this.maxLinearMeter, + required this.minSpacing, + required this.maxSpacing, + required this.roughFinish, + required this.highFinish, + required this.withoutBucc, + }); + + factory ClassComponents.fromJson(Map json) => + ClassComponents( + id: json["id"], + componentName: json["component_name"], + minBaseUnitvalPercent: json["min_base_unitval_percent"], + maxBaseUnitvalPercent: json["max_base_unitval_percent"], + minUnitvalSqrmtr: json["min_unitval_sqrmtr"], + maxUnitvalSqrmtr: json["max_unitval_sqrmtr"], + minAddBaseunitval: json["min_add_baseunitval"], + maxAddBaseunitval: json["max_add_baseunitval"], + minDeductBaserate: json["min_deduct_baserate"], + maxDeductBaserate: json["max_deduct_baserate"], + minLinearMeter: json["min_linear_meter"], + maxLinearMeter: json["max_linear_meter"], + minSpacing: json["min_spacing"], + maxSpacing: json["max_spacing"], + roughFinish: json["rough_finish"], + highFinish: json["high_finish"], + withoutBucc: json["without_bucc"], + ); + + Map toJson() => { + "id": id, + "component_name": componentName, + "min_base_unitval_percent": minBaseUnitvalPercent, + "max_base_unitval_percent": maxBaseUnitvalPercent, + "min_unitval_sqrmtr": minUnitvalSqrmtr, + "max_unitval_sqrmtr": maxUnitvalSqrmtr, + "min_add_baseunitval": minAddBaseunitval, + "max_add_baseunitval": maxAddBaseunitval, + "min_deduct_baserate": minDeductBaserate, + "max_deduct_baserate": maxDeductBaserate, + "min_linear_meter": minLinearMeter, + "max_linear_meter": maxLinearMeter, + "min_spacing": minSpacing, + "max_spacing": maxSpacing, + "rough_finish": roughFinish, + "high_finish": highFinish, + "without_bucc": withoutBucc, + }; +} diff --git a/lib/model/passo/general_description.dart b/lib/model/passo/general_description.dart new file mode 100644 index 0000000..68002a5 --- /dev/null +++ b/lib/model/passo/general_description.dart @@ -0,0 +1,137 @@ +// To parse this JSON data, do +// +// final generalDesc = generalDescFromJson(jsonString); + +import 'dart:convert'; + +GeneralDesc generalDescFromJson(String str) => + GeneralDesc.fromJson(json.decode(str)); + +String generalDescToJson(GeneralDesc data) => json.encode(data.toJson()); + +class GeneralDesc { + final int? id; + final int? bldgapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? bldgKind; + final String? strucType; + final String? bldgPermit; + final DateTime? dateIssued; + final String? cct; + final DateTime? certCompletionIssued; + final DateTime? certOccupancyIssued; + final DateTime? dateCompleted; + final DateTime? dateOccupied; + final int? bldgAge; + final int? noStoreys; + final String? area1Stfloor; + final String? area2Ndfloor; + final String? area3Rdfloor; + final String? area4Thfloor; + final String? totalFloorArea; + final dynamic floorSketch; + final String? 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, + }); + + 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"] == null + ? null + : DateTime.parse(json["date_created"]), + dateModified: json["date_modified"] == null + ? null + : DateTime.parse(json["date_modified"]), + bldgKind: json["bldg_kind"], + strucType: json["struc_type"], + bldgPermit: json["bldg_permit"], + dateIssued: json["date_issued"] == null + ? null + : DateTime.parse(json["date_issued"]), + cct: json["cct"], + certCompletionIssued: json["cert_completion_issued"] == null + ? null + : DateTime.parse(json["cert_completion_issued"]), + certOccupancyIssued: json["cert_occupancy_issued"] == null + ? null + : DateTime.parse(json["cert_occupancy_issued"]), + dateCompleted: json["date_completed"] == null + ? null + : DateTime.parse(json["date_completed"]), + dateOccupied: json["date_occupied"] == null + ? null + : DateTime.parse(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"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "bldg_kind": bldgKind, + "struc_type": strucType, + "bldg_permit": bldgPermit, + "date_issued": + "${dateIssued!.year.toString().padLeft(4, '0')}-${dateIssued!.month.toString().padLeft(2, '0')}-${dateIssued!.day.toString().padLeft(2, '0')}", + "cct": cct, + "cert_completion_issued": + "${certCompletionIssued!.year.toString().padLeft(4, '0')}-${certCompletionIssued!.month.toString().padLeft(2, '0')}-${certCompletionIssued!.day.toString().padLeft(2, '0')}", + "cert_occupancy_issued": + "${certOccupancyIssued!.year.toString().padLeft(4, '0')}-${certOccupancyIssued!.month.toString().padLeft(2, '0')}-${certOccupancyIssued!.day.toString().padLeft(2, '0')}", + "date_completed": + "${dateCompleted!.year.toString().padLeft(4, '0')}-${dateCompleted!.month.toString().padLeft(2, '0')}-${dateCompleted!.day.toString().padLeft(2, '0')}", + "date_occupied": + "${dateOccupied!.year.toString().padLeft(4, '0')}-${dateOccupied!.month.toString().padLeft(2, '0')}-${dateOccupied!.day.toString().padLeft(2, '0')}", + "bldg_age": bldgAge, + "no_storeys": noStoreys, + "area_1stfloor": area1Stfloor, + "area_2ndfloor": area2Ndfloor, + "area_3rdfloor": area3Rdfloor, + "area_4thfloor": area4Thfloor, + "total_floor_area": totalFloorArea, + "floor_sketch": floorSketch, + "actual_use": actualUse, + }; +} diff --git a/lib/model/passo/land_appr.dart b/lib/model/passo/land_appr.dart new file mode 100644 index 0000000..91e9b1b --- /dev/null +++ b/lib/model/passo/land_appr.dart @@ -0,0 +1,49 @@ +// To parse this JSON data, do +// +// final landAppr = landApprFromJson(jsonString); + +import 'dart:convert'; + +LandAppr landApprFromJson(String str) => LandAppr.fromJson(json.decode(str)); + +String landApprToJson(LandAppr data) => json.encode(data.toJson()); + +class LandAppr { + final int? id; + final int? landapprDetailsId; + final String? classification; + final String? subClass; + final String? area; + final String? unitValue; + final String? baseMarketval; + + LandAppr({ + this.id, + this.landapprDetailsId, + this.classification, + this.subClass, + this.area, + this.unitValue, + this.baseMarketval, + }); + + factory LandAppr.fromJson(Map json) => LandAppr( + id: json["id"], + landapprDetailsId: json["landappr_details_id"], + classification: json["classification"], + subClass: json["sub_class"], + area: json["area"], + unitValue: json["unit_value"], + baseMarketval: json["base_marketval"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "classification": classification, + "sub_class": subClass, + "area": area, + "unit_value": unitValue, + "base_marketval": baseMarketval, + }; +} diff --git a/lib/model/passo/land_classification.dart b/lib/model/passo/land_classification.dart new file mode 100644 index 0000000..0315271 --- /dev/null +++ b/lib/model/passo/land_classification.dart @@ -0,0 +1,36 @@ +// To parse this JSON data, do +// +// final landClassification = landClassificationFromJson(jsonString); + +import 'dart:convert'; + +LandClassification landClassificationFromJson(String str) => + LandClassification.fromJson(json.decode(str)); + +String landClassificationToJson(LandClassification data) => + json.encode(data.toJson()); + +class LandClassification { + final int? id; + final String? classificationCode; + final String? description; + + LandClassification({ + this.id, + this.classificationCode, + this.description, + }); + + factory LandClassification.fromJson(Map json) => + LandClassification( + id: json["id"], + classificationCode: json["classification_code"], + description: json["description"], + ); + + Map toJson() => { + "id": id, + "classification_code": classificationCode, + "description": description, + }; +} diff --git a/lib/model/passo/land_ext.dart b/lib/model/passo/land_ext.dart new file mode 100644 index 0000000..5c935f8 --- /dev/null +++ b/lib/model/passo/land_ext.dart @@ -0,0 +1,124 @@ +// To parse this JSON data, do +// +// final landExt = landExtFromJson(jsonString); + +import 'dart:convert'; + +LandExt landExtFromJson(String str) => LandExt.fromJson(json.decode(str)); + +String landExtToJson(LandExt data) => json.encode(data.toJson()); + +class LandExt { + final int? id; + 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? appraisedbyName; + final DateTime? appraisedbyDate; + final String? recommendapprName; + final DateTime? recommendapprDate; + final String? approvedbyName; + final DateTime? approvedbyDate; + final String? memoranda; + final String? swornstatementNo; + final DateTime? dateReceived; + final DateTime? entryDateAssessment; + final String? entryDateBy; + + LandExt({ + this.id, + this.landapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.taxable, + this.exempt, + this.qtr, + this.yr, + this.appraisedbyName, + this.appraisedbyDate, + this.recommendapprName, + this.recommendapprDate, + this.approvedbyName, + this.approvedbyDate, + this.memoranda, + this.swornstatementNo, + this.dateReceived, + this.entryDateAssessment, + 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"]), + 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"]), + recommendapprName: json["recommendappr_name"], + recommendapprDate: json["recommendappr_date"] == null + ? null + : DateTime.parse(json["recommendappr_date"]), + approvedbyName: json["approvedby_name"], + approvedbyDate: json["approvedby_date"] == null + ? null + : DateTime.parse(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"]), + entryDateBy: json["entry_date_by"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "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')}", + "recommendappr_name": recommendapprName, + "recommendappr_date": + "${recommendapprDate!.year.toString().padLeft(4, '0')}-${recommendapprDate!.month.toString().padLeft(2, '0')}-${recommendapprDate!.day.toString().padLeft(2, '0')}", + "approvedby_name": approvedbyName, + "approvedby_date": + "${approvedbyDate!.year.toString().padLeft(4, '0')}-${approvedbyDate!.month.toString().padLeft(2, '0')}-${approvedbyDate!.day.toString().padLeft(2, '0')}", + "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')}", + "entry_date_by": entryDateBy, + }; +} diff --git a/lib/model/passo/land_property_assessment.dart b/lib/model/passo/land_property_assessment.dart new file mode 100644 index 0000000..cbab632 --- /dev/null +++ b/lib/model/passo/land_property_assessment.dart @@ -0,0 +1,56 @@ +// To parse this JSON data, do +// +// final landPropertyAssessment = landPropertyAssessmentFromJson(jsonString); + +import 'dart:convert'; + +LandPropertyAssessment landPropertyAssessmentFromJson(String str) => + LandPropertyAssessment.fromJson(json.decode(str)); + +String landPropertyAssessmentToJson(LandPropertyAssessment data) => + json.encode(data.toJson()); + +class LandPropertyAssessment { + final int? id; + final int? landapprDetailsId; + final String? actualUse; + final String? marketval; + final String? assessmentLevel; + final String? assessedValue; + final String? totalMarketval; + final String? totalAssessedval; + + LandPropertyAssessment({ + this.id, + this.landapprDetailsId, + this.actualUse, + this.marketval, + this.assessmentLevel, + this.assessedValue, + this.totalMarketval, + this.totalAssessedval, + }); + + factory LandPropertyAssessment.fromJson(Map json) => + LandPropertyAssessment( + id: json["id"], + landapprDetailsId: json["landappr_details_id"], + actualUse: json["actual_use"], + marketval: json["marketval"], + assessmentLevel: json["assessment_level"], + assessedValue: json["assessed_value"], + totalMarketval: json["total_marketval"], + totalAssessedval: json["total_assessedval"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "actual_use": actualUse, + "marketval": marketval, + "assessment_level": assessmentLevel, + "assessed_value": assessedValue, + "total_marketval": totalMarketval, + "total_assessedval": totalAssessedval, + }; +} diff --git a/lib/model/passo/land_property_boundaries.dart b/lib/model/passo/land_property_boundaries.dart new file mode 100644 index 0000000..49a3ada --- /dev/null +++ b/lib/model/passo/land_property_boundaries.dart @@ -0,0 +1,72 @@ +// To parse this JSON data, do +// +// final landPropertyBoundaries = landPropertyBoundariesFromJson(jsonString); + +import 'dart:convert'; + +LandPropertyBoundaries landPropertyBoundariesFromJson(String str) => + LandPropertyBoundaries.fromJson(json.decode(str)); + +String landPropertyBoundariesToJson(LandPropertyBoundaries data) => + json.encode(data.toJson()); + +class LandPropertyBoundaries { + final int? id; + final int? landapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? north; + final String? east; + final String? south; + final String? west; + final dynamic sketch; + + LandPropertyBoundaries({ + this.id, + this.landapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.north, + this.east, + this.south, + this.west, + 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"]), + north: json["north"], + east: json["east"], + south: json["south"], + west: json["west"], + sketch: json["sketch"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "north": north, + "east": east, + "south": south, + "west": west, + "sketch": sketch, + }; +} diff --git a/lib/model/passo/land_property_loc.dart b/lib/model/passo/land_property_loc.dart new file mode 100644 index 0000000..25a7466 --- /dev/null +++ b/lib/model/passo/land_property_loc.dart @@ -0,0 +1,68 @@ +// To parse this JSON data, do +// +// final lnadPropertyLoc = lnadPropertyLocFromJson(jsonString); + +import 'dart:convert'; + +LandPropertyLoc lnadPropertyLocFromJson(String str) => + LandPropertyLoc.fromJson(json.decode(str)); + +String lnadPropertyLocToJson(LandPropertyLoc data) => + json.encode(data.toJson()); + +class LandPropertyLoc { + final int? id; + final int? landapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? street; + final String? municipality; + final String? barangay; + final String? province; + + LandPropertyLoc({ + this.id, + this.landapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.street, + this.municipality, + this.barangay, + this.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"]), + street: json["street"], + municipality: json["municipality"], + barangay: json["barangay"], + province: json["province"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "street": street, + "municipality": municipality, + "barangay": barangay, + "province": province, + }; +} diff --git a/lib/model/passo/land_property_owner.dart b/lib/model/passo/land_property_owner.dart new file mode 100644 index 0000000..9c644af --- /dev/null +++ b/lib/model/passo/land_property_owner.dart @@ -0,0 +1,117 @@ +// To parse this JSON data, do +// +// final landPropertyOwner = landPropertyOwnerFromJson(jsonString); + +import 'dart:convert'; + +LandPropertyOwner landPropertyOwnerFromJson(String str) => + LandPropertyOwner.fromJson(json.decode(str)); + +String landPropertyOwnerToJson(LandPropertyOwner data) => + json.encode(data.toJson()); + +class LandPropertyOwner { + final int? id; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? transCode; + final String? tdn; + final String? pin; + final String? cloaNo; + final DateTime? 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; + + LandPropertyOwner({ + this.id, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.transCode, + this.tdn, + this.pin, + this.cloaNo, + this.dated, + this.surveyNo, + this.lotNo, + this.blkNo, + this.owner, + this.address, + this.telno, + this.tin, + this.adminUser, + this.adminAddress, + this.adminTelno, + this.adminTin, + this.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"]), + transCode: json["trans_code"], + tdn: json["tdn"], + pin: json["pin"], + cloaNo: json["cloa_no"], + dated: json["dated"] == null ? null : DateTime.parse(json["dated"]), + surveyNo: json["survey_no"], + lotNo: json["lot_no"], + blkNo: json["blk_no"], + owner: json["owner"], + address: json["address"], + telno: json["telno"], + tin: json["tin"], + adminUser: json["admin_user"], + adminAddress: json["admin_address"], + adminTelno: json["admin_telno"], + adminTin: json["admin_tin"], + faasType: json["faas_type"], + ); + + Map toJson() => { + "id": id, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "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')}", + "survey_no": surveyNo, + "lot_no": lotNo, + "blk_no": blkNo, + "owner": owner, + "address": address, + "telno": telno, + "tin": tin, + "admin_user": adminUser, + "admin_address": adminAddress, + "admin_telno": adminTelno, + "admin_tin": adminTin, + "faas_type": faasType, + }; +} diff --git a/lib/model/passo/land_ref.dart b/lib/model/passo/land_ref.dart new file mode 100644 index 0000000..8f4649d --- /dev/null +++ b/lib/model/passo/land_ref.dart @@ -0,0 +1,77 @@ +// To parse this JSON data, do +// +// final landRef = landRefFromJson(jsonString); + +import 'dart:convert'; + +LandRef landRefFromJson(String str) => LandRef.fromJson(json.decode(str)); + +String landRefToJson(LandRef data) => json.encode(data.toJson()); + +class LandRef { + final int? id; + final int? bldgapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final dynamic owner; + final dynamic cloaNo; + final dynamic lotNo; + final dynamic tdn; + final dynamic area; + final dynamic surveyNo; + final dynamic blkNo; + + LandRef({ + this.id, + this.bldgapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.owner, + this.cloaNo, + this.lotNo, + this.tdn, + this.area, + this.surveyNo, + this.blkNo, + }); + + factory LandRef.fromJson(Map json) => LandRef( + id: json["id"], + 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"]), + owner: json["owner"], + cloaNo: json["cloa_no"], + lotNo: json["lot_no"], + tdn: json["tdn"], + area: json["area"], + surveyNo: json["survey_no"], + blkNo: json["blk_no"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "owner": owner, + "cloa_no": cloaNo, + "lot_no": lotNo, + "tdn": tdn, + "area": area, + "survey_no": surveyNo, + "blk_no": blkNo, + }; +} diff --git a/lib/model/passo/land_subclassification.dart b/lib/model/passo/land_subclassification.dart new file mode 100644 index 0000000..8bb042a --- /dev/null +++ b/lib/model/passo/land_subclassification.dart @@ -0,0 +1,48 @@ +// To parse this JSON data, do +// +// final landSubClassification = landSubClassificationFromJson(jsonString); + +import 'dart:convert'; + +LandSubClassification landSubClassificationFromJson(String str) => + LandSubClassification.fromJson(json.decode(str)); + +String landSubClassificationToJson(LandSubClassification data) => + json.encode(data.toJson()); + +class LandSubClassification { + final int? id; + final int? classificationId; + final String? cityCode; + final String? subclassCode; + final String? subclassDescription; + final String? baseUnitMarketval; + + LandSubClassification({ + this.id, + this.classificationId, + this.cityCode, + this.subclassCode, + this.subclassDescription, + this.baseUnitMarketval, + }); + + factory LandSubClassification.fromJson(Map json) => + LandSubClassification( + id: json["id"], + classificationId: json["classification_id"], + cityCode: json["city_code"], + subclassCode: json["subclass_code"], + subclassDescription: json["subclass_description"], + baseUnitMarketval: json["base_unit_marketval"], + ); + + Map toJson() => { + "id": id, + "classification_id": classificationId, + "city_code": cityCode, + "subclass_code": subclassCode, + "subclass_description": subclassDescription, + "base_unit_marketval": baseUnitMarketval, + }; +} diff --git a/lib/model/passo/land_value_adjustment.dart b/lib/model/passo/land_value_adjustment.dart new file mode 100644 index 0000000..33bdc59 --- /dev/null +++ b/lib/model/passo/land_value_adjustment.dart @@ -0,0 +1,52 @@ +// To parse this JSON data, do +// +// final valueAdjustments = valueAdjustmentsFromJson(jsonString); + +import 'dart:convert'; + +ValueAdjustments valueAdjustmentsFromJson(String str) => + ValueAdjustments.fromJson(json.decode(str)); + +String valueAdjustmentsToJson(ValueAdjustments data) => + json.encode(data.toJson()); + +class ValueAdjustments { + final int? id; + final int? landapprDetailsId; + final String? baseMarketval; + final String? adjustmentFactors; + final String? adjustment; + final String? valueAdjustment; + final String? marketValue; + + ValueAdjustments({ + this.id, + this.landapprDetailsId, + this.baseMarketval, + this.adjustmentFactors, + this.adjustment, + this.valueAdjustment, + this.marketValue, + }); + + factory ValueAdjustments.fromJson(Map json) => + ValueAdjustments( + id: json["id"], + landapprDetailsId: json["landappr_details_id"], + baseMarketval: json["base_marketval"], + adjustmentFactors: json["adjustment_factors"], + adjustment: json["adjustment"], + valueAdjustment: json["value_adjustment"], + marketValue: json["market_value"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "base_marketval": baseMarketval, + "adjustment_factors": adjustmentFactors, + "adjustment": adjustment, + "value_adjustment": valueAdjustment, + "market_value": marketValue, + }; +} diff --git a/lib/model/passo/memoranda.dart b/lib/model/passo/memoranda.dart new file mode 100644 index 0000000..8c629fd --- /dev/null +++ b/lib/model/passo/memoranda.dart @@ -0,0 +1,33 @@ +// To parse this JSON data, do +// +// final memoranda = memorandaFromJson(jsonString); + +import 'dart:convert'; + +Memoranda memorandaFromJson(String str) => Memoranda.fromJson(json.decode(str)); + +String memorandaToJson(Memoranda data) => json.encode(data.toJson()); + +class Memoranda { + final int? id; + final String? code; + final String? memoranda; + + Memoranda({ + this.id, + this.code, + this.memoranda, + }); + + factory Memoranda.fromJson(Map json) => Memoranda( + id: json["id"], + code: json["code"], + memoranda: json["memoranda"], + ); + + Map toJson() => { + "id": id, + "code": code, + "memoranda": memoranda, + }; +} diff --git a/lib/model/passo/other_improvements.dart b/lib/model/passo/other_improvements.dart new file mode 100644 index 0000000..bb36523 --- /dev/null +++ b/lib/model/passo/other_improvements.dart @@ -0,0 +1,64 @@ +// To parse this JSON data, do +// +// final otherImprovements = otherImprovementsFromJson(jsonString); + +import 'dart:convert'; + +OtherImprovements otherImprovementsFromJson(String str) => + OtherImprovements.fromJson(json.decode(str)); + +String otherImprovementsToJson(OtherImprovements data) => + json.encode(data.toJson()); + +class OtherImprovements { + 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 bool? fruitBearing; + + OtherImprovements({ + this.id, + this.landapprDetailsId, + this.kindsOfTrees, + this.subclassAge, + this.quantity, + this.unitValue, + this.baseMarketval, + this.noOfProductive, + this.noOfNonproductive, + this.fruitBearing, + }); + + factory OtherImprovements.fromJson(Map json) => + OtherImprovements( + id: json["id"], + landapprDetailsId: json["landappr_details_id"], + kindsOfTrees: json["kinds_of_trees"], + subclassAge: json["subclass_age"], + quantity: json["quantity"], + unitValue: json["unit_value"], + baseMarketval: json["base_marketval"], + noOfProductive: json["no_of_productive"], + noOfNonproductive: json["no_of_nonproductive"], + fruitBearing: json["fruit_bearing"], + ); + + Map toJson() => { + "id": id, + "landappr_details_id": landapprDetailsId, + "kinds_of_trees": kindsOfTrees, + "subclass_age": subclassAge, + "quantity": quantity, + "unit_value": unitValue, + "base_marketval": baseMarketval, + "no_of_productive": noOfProductive, + "no_of_nonproductive": noOfNonproductive, + "fruit_bearing": fruitBearing, + }; +} diff --git a/lib/model/passo/property_appraisal.dart b/lib/model/passo/property_appraisal.dart new file mode 100644 index 0000000..9ebe509 --- /dev/null +++ b/lib/model/passo/property_appraisal.dart @@ -0,0 +1,91 @@ +// To parse this JSON data, do +// +// final propertyAppraisal = propertyAppraisalFromJson(jsonString); + +import 'dart:convert'; + +PropertyAppraisal propertyAppraisalFromJson(String str) => + PropertyAppraisal.fromJson(json.decode(str)); + +String propertyAppraisalToJson(PropertyAppraisal data) => + json.encode(data.toJson()); + +class PropertyAppraisal { + final int? id; + final int? bldgapprDetailsId; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? unitconstructCost; + final String? buildingCore; + final String? unitconstructSubtotal; + final String? depreciationRate; + final String? depreciationCost; + final String? costAddItems; + final String? addItemsSubtotal; + final String? totalpercentDepreciation; + final String? marketValue; + final String? totalArea; + + PropertyAppraisal( + {this.id, + this.bldgapprDetailsId, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.unitconstructCost, + this.buildingCore, + this.unitconstructSubtotal, + this.depreciationRate, + this.depreciationCost, + this.costAddItems, + this.addItemsSubtotal, + this.totalpercentDepreciation, + this.marketValue, + this.totalArea}); + + factory PropertyAppraisal.fromJson(Map json) => + PropertyAppraisal( + id: json["id"], + 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"]), + unitconstructCost: json["unitconstruct_cost"], + buildingCore: json["building_core"], + unitconstructSubtotal: json["unitconstruct_subtotal"], + depreciationRate: json["depreciation_rate"], + depreciationCost: json["depreciation_cost"], + costAddItems: json["cost_add_items"], + addItemsSubtotal: json["add_items_subtotal"], + totalpercentDepreciation: json["totalpercent_depreciation"], + marketValue: json["market_value"], + totalArea: json["total_area"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "unitconstruct_cost": unitconstructCost, + "building_core": buildingCore, + "unitconstruct_subtotal": unitconstructSubtotal, + "depreciation_rate": depreciationRate, + "depreciation_cost": depreciationCost, + "cost_add_items": costAddItems, + "add_items_subtotal": addItemsSubtotal, + "totalpercent_depreciation": totalpercentDepreciation, + "market_value": marketValue, + "total_area": totalArea + }; +} diff --git a/lib/model/passo/property_appraisal_edit.dart b/lib/model/passo/property_appraisal_edit.dart new file mode 100644 index 0000000..43e37ee --- /dev/null +++ b/lib/model/passo/property_appraisal_edit.dart @@ -0,0 +1,71 @@ +// To parse this JSON data, do +// +// final propertyAppraisal = propertyAppraisalFromJson(jsonString); + +import 'dart:convert'; + +PropertyAppraisalEdit propertyAppraisalFromJson(String str) => + PropertyAppraisalEdit.fromJson(json.decode(str)); + +String propertyAppraisalToJson(PropertyAppraisalEdit data) => + json.encode(data.toJson()); + +class PropertyAppraisalEdit { + final int? id; + final int? bldgapprDetailsId; + final String? unitconstructCost; + final String? buildingCore; + final String? unitconstructSubtotal; + final String? depreciationRate; + final String? depreciationCost; + final String? costAddItems; + final String? addItemsSubtotal; + final String? totalpercentDepreciation; + final String? marketValue; + final String? totalArea; + + PropertyAppraisalEdit( + {this.id, + this.bldgapprDetailsId, + this.unitconstructCost, + this.buildingCore, + this.unitconstructSubtotal, + this.depreciationRate, + this.depreciationCost, + this.costAddItems, + this.addItemsSubtotal, + this.totalpercentDepreciation, + this.marketValue, + this.totalArea}); + + factory PropertyAppraisalEdit.fromJson(Map json) => + PropertyAppraisalEdit( + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + unitconstructCost: json["unitconstruct_cost"], + buildingCore: json["building_core"], + unitconstructSubtotal: json["unitconstruct_subtotal"], + depreciationRate: json["depreciation_rate"], + depreciationCost: json["depreciation_cost"], + costAddItems: json["cost_add_items"], + addItemsSubtotal: json["add_items_subtotal"], + totalpercentDepreciation: json["totalpercent_depreciation"], + marketValue: json["market_value"], + totalArea: json["total_area"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "unitconstruct_cost": unitconstructCost, + "building_core": buildingCore, + "unitconstruct_subtotal": unitconstructSubtotal, + "depreciation_rate": depreciationRate, + "depreciation_cost": depreciationCost, + "cost_add_items": costAddItems, + "add_items_subtotal": addItemsSubtotal, + "totalpercent_depreciation": totalpercentDepreciation, + "market_value": marketValue, + "total_area": totalArea + }; +} diff --git a/lib/model/passo/property_assessment.dart b/lib/model/passo/property_assessment.dart new file mode 100644 index 0000000..fb91bff --- /dev/null +++ b/lib/model/passo/property_assessment.dart @@ -0,0 +1,109 @@ +// To parse this JSON data, do +// +// final propertyAssessment = propertyAssessmentFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +PropertyAssessment propertyAssessmentFromJson(String str) => + PropertyAssessment.fromJson(json.decode(str)); + +String propertyAssessmentToJson(PropertyAssessment data) => + json.encode(data.toJson()); + +class PropertyAssessment { + final int id; + final int bldgapprDetailsId; + final String actualUse; + final String marketValue; + final String assessmentLevel; + final String assessedValue; + final bool taxable; + final bool exempt; + final int qtr; + final int yr; + final String appraisedbyName; + final DateTime appraisedbyDate; + final String recommendapprName; + final DateTime recommendapprDate; + final String approvedbyName; + final String memoranda; + final String swornstatementNo; + final DateTime dateReceived; + final DateTime entryDateAssessment; + final String entryDateBy; + + PropertyAssessment({ + required this.id, + required this.bldgapprDetailsId, + required this.actualUse, + required this.marketValue, + required this.assessmentLevel, + required this.assessedValue, + 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.memoranda, + required this.swornstatementNo, + required this.dateReceived, + required this.entryDateAssessment, + required this.entryDateBy, + }); + + factory PropertyAssessment.fromJson(Map json) => + PropertyAssessment( + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + actualUse: json["actual_use"], + marketValue: json["market_value"], + assessmentLevel: json["assessment_level"], + assessedValue: json["assessed_value"], + taxable: json["taxable"], + exempt: json["exempt"], + qtr: json["qtr"], + yr: json["yr"], + appraisedbyName: json["appraisedby_name"], + appraisedbyDate: DateTime.parse(json["appraisedby_date"]), + recommendapprName: json["recommendappr_name"], + recommendapprDate: DateTime.parse(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"]), + entryDateBy: json["entry_date_by"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "actual_use": actualUse, + "market_value": marketValue, + "assessment_level": assessmentLevel, + "assessed_value": assessedValue, + "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')}", + "recommendappr_name": recommendapprName, + "recommendappr_date": + "${recommendapprDate.year.toString().padLeft(4, '0')}-${recommendapprDate.month.toString().padLeft(2, '0')}-${recommendapprDate.day.toString().padLeft(2, '0')}", + "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')}", + "entry_date_by": entryDateBy, + }; +} diff --git a/lib/model/passo/property_assessment_edit.dart b/lib/model/passo/property_assessment_edit.dart new file mode 100644 index 0000000..5e0ee15 --- /dev/null +++ b/lib/model/passo/property_assessment_edit.dart @@ -0,0 +1,109 @@ +// To parse this JSON data, do +// +// final propertyAssessment = propertyAssessmentFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +PropertyAssessmentEdit propertyAssessmentFromJson(String str) => + PropertyAssessmentEdit.fromJson(json.decode(str)); + +String propertyAssessmentToJson(PropertyAssessmentEdit data) => + json.encode(data.toJson()); + +class PropertyAssessmentEdit { + final int? id; + final int? bldgapprDetailsId; + final String? actualUse; + final String? marketValue; + final String? assessmentLevel; + final String? assessedValue; + final bool? taxable; + final bool? exempt; + final int? qtr; + final int? yr; + final String? appraisedbyName; + final DateTime? appraisedbyDate; + final String? recommendapprName; + final DateTime? recommendapprDate; + final String? approvedbyName; + final String? memoranda; + final String? swornstatementNo; + final DateTime? dateReceived; + final DateTime? entryDateAssessment; + final String? entryDateBy; + + PropertyAssessmentEdit({ + this.id, + this.bldgapprDetailsId, + this.actualUse, + this.marketValue, + this.assessmentLevel, + this.assessedValue, + this.taxable, + this.exempt, + this.qtr, + this.yr, + this.appraisedbyName, + this.appraisedbyDate, + this.recommendapprName, + this.recommendapprDate, + this.approvedbyName, + this.memoranda, + this.swornstatementNo, + this.dateReceived, + this.entryDateAssessment, + this.entryDateBy, + }); + + factory PropertyAssessmentEdit.fromJson(Map json) => + PropertyAssessmentEdit( + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + actualUse: json["actual_use"], + marketValue: json["market_value"], + assessmentLevel: json["assessment_level"], + assessedValue: json["assessed_value"], + taxable: json["taxable"], + exempt: json["exempt"], + qtr: json["qtr"], + yr: json["yr"], + appraisedbyName: json["appraisedby_name"], + appraisedbyDate: DateTime.parse(json["appraisedby_date"]), + recommendapprName: json["recommendappr_name"], + recommendapprDate: DateTime.parse(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"]), + entryDateBy: json["entry_date_by"], + ); + + Map toJson() => { + "id": id, + "bldgappr_details_id": bldgapprDetailsId, + "actual_use": actualUse, + "market_value": marketValue, + "assessment_level": assessmentLevel, + "assessed_value": assessedValue, + "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')}", + "recommendappr_name": recommendapprName, + "recommendappr_date": + "${recommendapprDate!.year.toString().padLeft(4, '0')}-${recommendapprDate!.month.toString().padLeft(2, '0')}-${recommendapprDate!.day.toString().padLeft(2, '0')}", + "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')}", + "entry_date_by": entryDateBy, + }; +} diff --git a/lib/model/passo/property_info.dart b/lib/model/passo/property_info.dart new file mode 100644 index 0000000..68406e2 --- /dev/null +++ b/lib/model/passo/property_info.dart @@ -0,0 +1,94 @@ +// To parse this JSON data, do +// +// final propertyInfo = propertyInfoFromJson(jsonString); + +import 'dart:convert'; + +PropertyInfo propertyInfoFromJson(String str) => + PropertyInfo.fromJson(json.decode(str)); + +String propertyInfoToJson(PropertyInfo data) => json.encode(data.toJson()); + +class PropertyInfo { + final int? id; + final String? assessedById; + final String? assessedByName; + final DateTime? dateCreated; + final DateTime? dateModified; + final String? transCode; + final String? tdn; + final String? pin; + 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; + + PropertyInfo({ + this.id, + this.assessedById, + this.assessedByName, + this.dateCreated, + this.dateModified, + this.transCode, + this.tdn, + this.pin, + this.owner, + this.address, + this.telno, + this.tin, + this.adminUser, + this.adminAddress, + this.adminTelno, + this.adminTin, + this.faasType, + }); + + factory PropertyInfo.fromJson(Map json) => PropertyInfo( + 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"]), + transCode: json["trans_code"], + tdn: json["tdn"], + pin: json["pin"], + owner: json["owner"], + address: json["address"], + telno: json["telno"], + tin: json["tin"], + adminUser: json["admin_user"], + adminAddress: json["admin_address"], + adminTelno: json["admin_telno"], + adminTin: json["admin_tin"], + faasType: json["faas_type"], + ); + + Map toJson() => { + "id": id, + "assessed_by_id": assessedById, + "assessed_by_name": assessedByName, + "date_created": dateCreated?.toIso8601String(), + "date_modified": dateModified?.toIso8601String(), + "trans_code": transCode, + "tdn": tdn, + "pin": pin, + "owner": owner, + "address": address, + "telno": telno, + "tin": tin, + "admin_user": adminUser, + "admin_address": adminAddress, + "admin_telno": adminTelno, + "admin_tin": adminTin, + "faas_type": faasType, + }; +} diff --git a/lib/model/passo/signatories.dart b/lib/model/passo/signatories.dart new file mode 100644 index 0000000..641f491 --- /dev/null +++ b/lib/model/passo/signatories.dart @@ -0,0 +1,42 @@ +// To parse this JSON data, do +// +// final signatories = signatoriesFromJson(jsonString); + +import 'dart:convert'; + +Signatories signatoriesFromJson(String str) => + Signatories.fromJson(json.decode(str)); + +String signatoriesToJson(Signatories data) => json.encode(data.toJson()); + +class Signatories { + final int? id; + final int signatoryId; + final String firstname; + final String middlename; + final String lastname; + + Signatories({ + this.id, + required this.signatoryId, + required this.firstname, + required this.middlename, + required this.lastname, + }); + + factory Signatories.fromJson(Map json) => Signatories( + id: json["id"], + signatoryId: json["signatory_id"], + firstname: json["firstname"], + middlename: json["middlename"], + lastname: json["lastname"], + ); + + Map toJson() => { + "id": id, + "signatory_id": signatoryId, + "firstname": firstname, + "middlename": middlename, + "lastname": lastname, + }; +} diff --git a/lib/model/passo/structural_materials_ii.dart b/lib/model/passo/structural_materials_ii.dart new file mode 100644 index 0000000..cfa3ec2 --- /dev/null +++ b/lib/model/passo/structural_materials_ii.dart @@ -0,0 +1,60 @@ +// To parse this JSON data, do +// +// final structureMaterialsIi = structureMaterialsIiFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +StructureMaterialsII structureMaterialsIiFromJson(String str) => + StructureMaterialsII.fromJson(json.decode(str)); + +String structureMaterialsIiToJson(StructureMaterialsII data) => + json.encode(data.toJson()); + +class StructureMaterialsII { + final int? id; + final List? foundation; + final List? columns; + final List? beams; + final List? trussFraming; + final List? roof; + final List? flooring; + final List? walls; + final List? others; + + StructureMaterialsII( + {this.id, + this.foundation, + this.columns, + this.beams, + this.trussFraming, + this.roof, + this.flooring, + this.walls, + this.others}); + + factory StructureMaterialsII.fromJson(Map json) => + StructureMaterialsII( + id: json["id"], + foundation: List.from(json["foundation"].map((x) => x)), + columns: List.from(json["columns"].map((x) => x)), + beams: List.from(json["beams"].map((x) => x)), + trussFraming: List.from(json["truss_framing"].map((x) => x)), + roof: List.from(json["roof"].map((x) => x)), + flooring: List.from(json["flooring"].map((x) => x)), + walls: List.from(json["walls"].map((x) => x)), + others: List.from(json["others"].map((x) => x)), + ); + + Map toJson() => { + "id": id, + "foundation": List.from(foundation!.map((x) => x)), + "columns": List.from(columns!.map((x) => x)), + "beams": List.from(beams!.map((x) => x)), + "truss_framing": List.from(trussFraming!.map((x) => x)), + "roof": List.from(roof!.map((x) => x)), + "flooring": List.from(flooring!.map((x) => x)), + "walls": List.from(walls!.map((x) => x)), + "others": List.from(others!.map((x) => x)), + }; +} diff --git a/lib/model/passo/structureMaterial.dart b/lib/model/passo/structureMaterial.dart new file mode 100644 index 0000000..4c07c23 --- /dev/null +++ b/lib/model/passo/structureMaterial.dart @@ -0,0 +1,57 @@ +// To parse this JSON data, do +// +// final structureMaterials = structureMaterialsFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +StructureMaterials structureMaterialsFromJson(String str) => + StructureMaterials.fromJson(json.decode(str)); + +String structureMaterialsToJson(StructureMaterials data) => + json.encode(data.toJson()); + +class StructureMaterials { + final int? id; + final String? foundation; + final String? columns; + final String? beams; + final String? trussFraming; + final String? roof; + final String? flooring; + final String? walls; + + StructureMaterials({ + this.id, + this.foundation, + this.columns, + this.beams, + this.trussFraming, + this.roof, + this.flooring, + this.walls, + }); + + factory StructureMaterials.fromJson(Map json) => + StructureMaterials( + id: json["id"], + foundation: json["foundation"], + columns: json["columns"], + beams: json["beams"], + trussFraming: json["truss_framing"], + roof: json["roof"], + flooring: json["flooring"], + walls: json["walls"], + ); + + Map toJson() => { + "id": id, + "foundation": foundation, + "columns": columns, + "beams": beams, + "truss_framing": trussFraming, + "roof": roof, + "flooring": flooring, + "walls": walls, + }; +} diff --git a/lib/model/passo/trees_improvements.dart b/lib/model/passo/trees_improvements.dart new file mode 100644 index 0000000..cc72f4a --- /dev/null +++ b/lib/model/passo/trees_improvements.dart @@ -0,0 +1,40 @@ +// To parse this JSON data, do +// +// final treesImprovements = treesImprovementsFromJson(jsonString); + +import 'dart:convert'; + +TreesImprovements treesImprovementsFromJson(String str) => + TreesImprovements.fromJson(json.decode(str)); + +String treesImprovementsToJson(TreesImprovements data) => + json.encode(data.toJson()); + +class TreesImprovements { + final int? id; + final String? improvement; + final String? pricePerTree; + final dynamic subclassCode; + + TreesImprovements({ + this.id, + this.improvement, + this.pricePerTree, + this.subclassCode, + }); + + factory TreesImprovements.fromJson(Map json) => + TreesImprovements( + id: json["id"], + improvement: json["improvement"], + pricePerTree: json["price_per_tree"], + subclassCode: json["subclass_code"], + ); + + Map toJson() => { + "id": id, + "improvement": improvement, + "price_per_tree": pricePerTree, + "subclass_code": subclassCode, + }; +} diff --git a/lib/model/passo/type_of_location.dart b/lib/model/passo/type_of_location.dart new file mode 100644 index 0000000..9990236 --- /dev/null +++ b/lib/model/passo/type_of_location.dart @@ -0,0 +1,38 @@ +// To parse this JSON data, do +// +// final typeOfLocation = typeOfLocationFromJson(jsonString); + +import 'dart:convert'; + +TypeOfLocation typeOfLocationFromJson(String str) => + TypeOfLocation.fromJson(json.decode(str)); + +String typeOfLocationToJson(TypeOfLocation data) => json.encode(data.toJson()); + +class TypeOfLocation { + final int? id; + final String? distanceKm; + final String? allRoadTypes; + final String? localTradingCenter; + + TypeOfLocation({ + this.id, + this.distanceKm, + this.allRoadTypes, + this.localTradingCenter, + }); + + factory TypeOfLocation.fromJson(Map json) => TypeOfLocation( + id: json["id"], + distanceKm: json["distance_km"], + allRoadTypes: json["all_road_types"], + localTradingCenter: json["local_trading_center"], + ); + + Map toJson() => { + "id": id, + "distance_km": distanceKm, + "all_road_types": allRoadTypes, + "local_trading_center": localTradingCenter, + }; +} diff --git a/lib/model/passo/type_of_road.dart b/lib/model/passo/type_of_road.dart new file mode 100644 index 0000000..e545e29 --- /dev/null +++ b/lib/model/passo/type_of_road.dart @@ -0,0 +1,34 @@ +// To parse this JSON data, do +// +// final typeOfRoad = typeOfRoadFromJson(jsonString); + +import 'dart:convert'; + +TypeOfRoad typeOfRoadFromJson(String str) => + TypeOfRoad.fromJson(json.decode(str)); + +String typeOfRoadToJson(TypeOfRoad data) => json.encode(data.toJson()); + +class TypeOfRoad { + final int? id; + final String? roadType; + final String? deduction; + + TypeOfRoad({ + this.id, + this.roadType, + this.deduction, + }); + + factory TypeOfRoad.fromJson(Map json) => TypeOfRoad( + id: json["id"], + roadType: json["road_type"], + deduction: json["deduction"], + ); + + Map toJson() => { + "id": id, + "road_type": roadType, + "deduction": deduction, + }; +} diff --git a/lib/model/passo/unit_construct.dart b/lib/model/passo/unit_construct.dart new file mode 100644 index 0000000..bc97fa3 --- /dev/null +++ b/lib/model/passo/unit_construct.dart @@ -0,0 +1,38 @@ +// To parse this JSON data, do +// +// final unitConstruct = unitConstructFromJson(jsonString); + +import 'dart:convert'; + +UnitConstruct unitConstructFromJson(String str) => + UnitConstruct.fromJson(json.decode(str)); + +String unitConstructToJson(UnitConstruct data) => json.encode(data.toJson()); + +class UnitConstruct { + final int id; + final String bldgType; + final String building; + final String unitValue; + + UnitConstruct({ + required this.id, + required this.bldgType, + required this.building, + required this.unitValue, + }); + + factory UnitConstruct.fromJson(Map json) => UnitConstruct( + id: json["id"], + bldgType: json["bldg_type"], + building: json["building"], + unitValue: json["unit_value"], + ); + + Map toJson() => { + "id": id, + "bldg_type": bldgType, + "building": building, + "unit_value": unitValue, + }; +} diff --git a/lib/screens/passo/Building/add_building.dart b/lib/screens/passo/Building/add_building.dart new file mode 100644 index 0000000..d2d94a8 --- /dev/null +++ b/lib/screens/passo/Building/add_building.dart @@ -0,0 +1,281 @@ +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:fluttertoast/fluttertoast.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/bulding/class_components/class_components_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/additional_items.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/bldg_location_landref.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/general_description.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/property_appraisal.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/property_assessment.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/property_info.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/structural_materials.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:im_stepper/stepper.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +GlobalKey formKey = GlobalKey(); + +class AddBuilding extends StatefulWidget { + @override + _AddBuilding createState() => _AddBuilding(); +} + +class _AddBuilding extends State { + int activeStep = 0; // Initial step set to 5. + int upperBound = 6; + + bool saveStep1 = false; + bool saveStep2 = false; + bool saveStep3 = false; + bool saveStep4 = false; + bool saveStep5 = false; + bool saveStep6 = false; + bool saveStep7 = false; + int tempId = 0; + + Future _loadTempId() async { + final prefs = await SharedPreferences.getInstance(); + setState(() { + tempId = (prefs.getInt('tempid') ?? 0); + }); + } + + void PrevBtn() { + setState(() { + activeStep--; + }); + } + + void NextBtn() { + setState(() { + activeStep++; + }); + } + + void onPutStructuralMaterials() { + if (activeStep < upperBound) { + setState(() { + activeStep++; + }); + } + // var strucMaterials = StructureMaterialsII( + // foundation: _foundations.getSelectedAsString().split(","), + // columns: _coumns.getSelectedAsString().split(","), + // beams: _beams.getSelectedAsString().split(","), + // trussFraming: + // _trussframing.getSelectedAsString().split(","), + // roof: _roof.getSelectedAsString().split(","), + // flooring: _flooring.getSelectedAsString().split(","), + // walls: _walls.getSelectedAsString().split(",")); + } + + void onPutPropertyAppraisal() {} + void bldgPrevBtn() { + if (activeStep > 0) { + setState(() { + activeStep--; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + centerTitle: true, + title: const Text("Building FAAS"), + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer(listener: ( + context, + state, + ) { + if (state is PropertyInfoLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is PropertyInfoLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyInfoErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + Fluttertoast.showToast( + msg: onError, + fontSize: 24, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.CENTER, + backgroundColor: Colors.black, + textColor: Colors.white); + } + }, builder: (context, state) { + if (state is PropertyInfoLoaded || + state is PropertyInfoErrorState) { + return BlocConsumer( + listener: ( + context, + state, + ) { + if (state is UnitConstructLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is UnitConstructLoaded || + state is UnitConstructErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + final unit = state.unit; + return BlocConsumer( + listener: ( + context, + state, + ) { + if (state is ClassComponentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is ClassComponentLoaded || + state is ClassComponentErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is ClassComponentLoaded) { + final classes = state.classes; + + return 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: formKey, + onChanged: () { + formKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Container( + child: content( + unit, + classes, + PrevBtn, + NextBtn, + ), + ), + ); + }), + ), + ], + ); + } + if (state is ClassComponentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadClassComponents()); + }, + ); + } + return Container(); + }, + ); + } + if (state is UnitConstructErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadUnitConstruct()); + }, + ); + } + return Container(); + }, + ); + } + + return Container(); + })), + ); + } + + Widget content(unit, List classes, PrevBtn, NextBtn) { + switch (activeStep) { + case 0: + return PropertyInfoPage(NextBtn); + + case 1: + return BldgLocationLandrefPage(PrevBtn, NextBtn); + + case 2: + return GeneralDescriptionPage(unit, NextBtn, PrevBtn); + + case 3: + return StructuralMaterialsPage(PrevBtn, NextBtn); + + case 4: + return AdditionalItemPage(unit, classes, PrevBtn, NextBtn); + + case 5: + return PropertyAppraisalPage(NextBtn, PrevBtn); + + case 6: + return PropertyAssessmentPage(onSAveAll); + + default: + return Text("Property Info"); + } + } + + void onSAveAll() { + return Navigator.of(context).pop(); + } +} diff --git a/lib/screens/passo/Building/add_building_components/AddExtraItems.dart b/lib/screens/passo/Building/add_building_components/AddExtraItems.dart new file mode 100644 index 0000000..eb3a9a7 --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/AddExtraItems.dart @@ -0,0 +1,579 @@ +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/passo/bulding/additional_item/additional_item_bloc.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'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +class AddExtraItems extends StatefulWidget { + final List unit; + final List options; + + AddExtraItems(this.unit, this.options); + + @override + _AddExtraItems createState() => _AddExtraItems(); +} + +class _AddExtraItems extends State { + GlobalKey formKey = GlobalKey(); + 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 _className = ""; + int _classId = 0; + String _structureType = ""; + bool _withoutBUCC = false; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + + 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(unitVal, unitBase, area, depreciation, withBUCC, + className, painted, secondHand, paintedUnitVal, secondhandUntVal) { + if (withBUCC == false) { + if (painted == true || secondHand == true) { + final deductions = (paintedUnitVal + secondhandUntVal) / 100; + + print(deductions); + return (((unitVal - deductions) * unitBase) * area); + } else { + return ((unitVal * unitBase) * area); + } + } else { + return (unitVal * area); + } + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddItemsScreen) { + return FormBuilder( + key: formKey, + onChanged: () { + formKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 800, + 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: FormBuilderDropdown( + name: 'extra_item', + autofocus: false, + decoration: + normalTextFieldStyle("Additional Item", ""), + items: widget.options + .map((e) => DropdownMenuItem( + value: e, + 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; + }); + 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; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxBaseUnitvalPercent}); + } + if (value.minUnitvalSqrmtr != '0.00') { + setState(() { + _unitValue = + double.parse(value.minUnitvalSqrmtr); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minUnitvalSqrmtr}); + } + if (value.maxUnitvalSqrmtr != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxUnitvalSqrmtr); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxUnitvalSqrmtr}); + } + if (value.minAddBaseunitval != '0.00') { + setState(() { + _unitValue = + double.parse(value.minAddBaseunitval); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minAddBaseunitval}); + } + if (value.maxAddBaseunitval != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxAddBaseunitval); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxAddBaseunitval}); + } + if (value.minDeductBaserate != '0.00') { + setState(() { + _unitValue = + double.parse(value.minDeductBaserate); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minDeductBaserate}); + } + if (value.maxDeductBaserate != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxDeductBaserate); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxDeductBaserate}); + } + }, + ), + ), + const SizedBox(height: 10), + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: widget.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}'; + }); + focus.unfocus(); + }, + ), + ), + ), + // const SizedBox(height: 10), + // Container( + // margin: const EdgeInsets.only( + // left: 0, top: 10, right: 0, bottom: 0), + // child: FormBuilderDropdown( + // name: 'struc_type', + // autofocus: false, + // decoration: + // normalTextFieldStyle("Structure Type", ""), + // items: widget.unit + // .map((e) => DropdownMenuItem( + // value: e, + // child: + // Text(e.bldgType + " - " + e.building), + // )) + // .toList(), + // onChanged: (val) { + // setState(() { + // _unitBase = double.parse(val!.unitValue); + // _structureType = val.bldgType; + // }); + // }, + // ), + // ), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + flex: 1, + child: FormBuilderTextField( + name: 'unitValue', + decoration: + normalTextFieldStyle("Unit Value", ""), + validator: FormBuilderValidators.compose([]), + ), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: FormBuilderTextField( + name: 'areaValue', + decoration: normalTextFieldStyle("Area", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _areaValue = int.parse(value!); + }); + }, + ), + ), + ], + ), + // const SizedBox(height: 10), + // FormBuilderTextField( + // name: 'depRate', + // decoration: + // normalTextFieldStyle("Depreciation Rate", ""), + // validator: FormBuilderValidators.compose([]), + // onChanged: (value) { + // setState(() { + // _depValue = double.parse(value!); + // }); + // }, + // ), + // const SizedBox(height: 10), + // FormBuilderTextField( + // name: 'marketValue', + // decoration: normalTextFieldStyle( + // NumberFormat.currency( + // locale: 'en-PH', symbol: "₱") + // .format(_totalMarketValue(_unitValue, + // _unitBase, _areaValue, _depValue)), + // ""), + // validator: FormBuilderValidators.compose([]), + // onChanged: (value) { + // setState(() { + // _marketValue = double.parse(value!); + // }); + // }, + // ), + // const SizedBox(height: 10), + // 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(_unitValue, + // _unitBase, _areaValue, _depValue)))), + // ), + + Visibility( + visible: !_withoutBUCC, + child: Column( + children: [ + const SizedBox(height: 10), + const Text('Building is not painted?'), + const SizedBox(height: 5), + Container( + child: Row( + children: [ + Checkbox( + value: isPainted, + onChanged: (bool? value) { + setState(() { + isPainted = value!; + if (value == false) { + _notPaintedUnitVal = 0; + } else { + _notPaintedUnitVal = 10; + } + }); + }, + ), + const SizedBox(width: 10), + Container( + height: 40.0, + width: 100, + 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(' - ' + + _notPaintedUnitVal.toString() + + '%')), + ), + ], + ), + ), + const SizedBox(height: 10), + const Text('Uses second hand materials?'), + const SizedBox(height: 5), + Container( + child: Row( + children: [ + Checkbox( + value: isSecondHand, + onChanged: (bool? value) { + setState(() { + isSecondHand = value!; + if (isSecondHand == false) { + _secondHandUnitVal = 0; + formKey.currentState!.patchValue( + {'secondHandMat': '0'}); + } else { + _secondHandUnitVal = 5; + formKey.currentState!.patchValue( + {'secondHandMat': '5'}); + } + }); + }, + ), + const SizedBox(width: 10), + Row( + children: [ + SizedBox( + height: 40, + width: 100, + child: FormBuilderTextField( + enabled: isSecondHand, + name: 'secondHandMat', + textAlign: TextAlign.center, + decoration: normalTextFieldStyle( + "Unit Value", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + // Check if the value is not null before parsing to double + if (value != null && + value.isNotEmpty) { + setState(() { + _secondHandUnitVal = + int.parse(value); + }); + } else { + // Handle the case when the value is empty or null + // For example, set _secondHandUnitVal to a default value or show an error message. + } + }, + ), + ), + const SizedBox( + height: 40, + width: 40, + child: Center( + child: Text( + '%', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), + ), + ), + ) + ], + ), + ], + ), + ), + ], + ), + ), + + 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( + _unitValue, + _unitBase, + _areaValue, + _depValue, + _withoutBUCC, + _className, + isPainted, + isSecondHand, + _notPaintedUnitVal, + _secondHandUnitVal)))), + ), + 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(); + var itemss = AdditionalItems( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')! - 1, + classId: _classId, + className: _className, + structType: _structureType, + unitValue: + _withoutBUCC == true ? 0 : _unitValue, + baseUnitValue: _unitBase, + area: _areaValue, + marketValue: + (_unitValue * _unitBase) * _areaValue, + depreciationRate: _depValue, + adjustedMarketVal: _totalMarketValue( + _unitValue, + _unitBase, + _areaValue, + _depValue, + _withoutBUCC, + _className, + isPainted, + isSecondHand, + _notPaintedUnitVal, + _secondHandUnitVal), + actualUse: 'Test', + amtDepreciation: _amountofDepreciation( + _unitValue, + _unitBase, + _areaValue, + _depValue, + ), + painted: true, + secondhand: true, + paintedUnitval: '1', + secondhandUnitval: '1'); + + context + .read() + .add(AddAdditionalItems(items: itemss)); + }, + 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 LoadAdditionalItems()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ))); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Building/add_building_components/additional_items.dart b/lib/screens/passo/Building/add_building_components/additional_items.dart new file mode 100644 index 0000000..f087534 --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/additional_items.dart @@ -0,0 +1,296 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/AddExtraItems.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class AdditionalItemPage extends StatefulWidget { + final List unit; + final List options; + + final VoidCallback additionalItemsPrevBtn; + final VoidCallback additionalItemsNextBtn; + + const AdditionalItemPage(this.unit, this.options, this.additionalItemsPrevBtn, + this.additionalItemsNextBtn); + + @override + _AdditionalItemPage createState() => _AdditionalItemPage(); +} + +class _AdditionalItemPage extends State { + void deleteItem(int itemId) { + context.read().add(DeleteAdditionalItems(id: itemId)); + } + + double _totalMarketValue(items) { + double total = 0; + items.forEach((row) { + total += double.parse(row.adjustedMarketVal); + }); + return total; + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + final state = context.watch().state; + if (state is AdditionalItemsLoaded) { + 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('ADDITIONAL ITEMS', + 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: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + 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('Items'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('% of BUCC'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.items.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.className)), + DataCell(Text(dataRow.baseUnitValue)), + DataCell(Text(dataRow.unitValue)), + DataCell(Text(((double.parse( + dataRow.adjustedMarketVal))) + .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: () { + deleteItem(dataRow.id); + }, + ), + 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: () {}, + ), + ], + )) + ], + ); + }).toList(), + ), + ), + ], + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 20.0, right: 20.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Total', + style: + TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + ), + Text( + NumberFormat.currency(locale: 'en-PH', symbol: "₱") + .format(_totalMarketValue(state.items)), + 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.additionalItemsPrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.additionalItemsNextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + 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(const LoadAdditionalItems()); + }); + }); + } + } + if (state is ShowAddItemsScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: const Text( + 'ADD EXTRA ITEMS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddExtraItems(widget.unit, widget.options)) + ], + ), + ), + ); + } + return Container( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('ADDITIONAL MATERIALS', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart b/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart new file mode 100644 index 0000000..0ecfe0a --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart @@ -0,0 +1,336 @@ +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:fluttertoast/fluttertoast.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/barangay/barangay_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; + +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; +import 'package:unit2/model/location/barangay.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; + +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/screens/passo/Building/add_building.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 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +import '../../../../model/passo/barangay.dart'; + +class BldgLocationLandrefPage extends StatefulWidget { + final VoidCallback PrevBtn; + final VoidCallback NextBtn; + BldgLocationLandrefPage(this.PrevBtn, this.NextBtn); + + @override + _BldgLocationLandrefPage createState() => _BldgLocationLandrefPage(); +} + +class _BldgLocationLandrefPage 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 MunicipalityLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is MunicipalityLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is MunicipalityErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is MunicipalityLoaded) { + List cityList = state.municipality; + + return BlocConsumer( + listener: (context, state) { + if (state is BarangayLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is BarangayLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is BarangayErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is BarangayLoaded) { + List brgyList = state.brgy; + List brgyNAmes = brgyList + .map((brgy) => brgy.barangayDescription) + .toList() + .cast(); + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('BUILDING LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Province / City", "", 'province')), + const SizedBox(width: 10.0), + Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'municipality', + autofocus: false, + decoration: normalTextFieldStyle( + "Municipality", ""), + items: cityList + .map((city) => + DropdownMenuItem( + value: city, + child: Text(city + .cityDescription!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedCity) { + if (selectedCity != null) { + final selectedCityCode = + selectedCity.cityCode; + final barangayBloc = + context.read(); + barangayBloc.add(LoadBarangay( + id: selectedCityCode!)); // Use selectedCityCode directly + } + }, + )), + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + 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: customDropDownField( + "Brgy. / District", + "", + 'brgy', + brgyNAmes)) + ]), + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('LAND REFERENCE', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + customTextField("Land Owner", "", 'l_owner'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "OCT/TCT/CLOA No.", "", 'oct_tct_cloa'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Survey No.", "", 'survey_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + 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 No.", "", 'blk_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "TD / ARP No.", "", 'l_td_arp'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: + customTextField("Area", "", 'area')) + ]), + 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(); + var bldgLocData = BldgLoc( + id: tempID.getInt('tempid')! - 1, + street: formKey + .currentState?.value['street'], + barangay: + formKey.currentState?.value['brgy'], + municipality: formKey + .currentState + ?.value['municipality'] + .cityDescription, + province: formKey + .currentState?.value['province'], + ); + var landRefData = LandRef( + id: tempID.getInt('tempid')! - 1, + owner: formKey + .currentState?.value['l_owner'], + cloaNo: formKey.currentState + ?.value['oct_tct_cloa'], + lotNo: formKey + .currentState?.value['lot_no'], + tdn: formKey + .currentState?.value['l_td_arp'], + area: + formKey.currentState?.value['area'], + surveyNo: formKey + .currentState?.value['survey_no'], + blkNo: formKey + .currentState?.value['blk_no'], + ); + context.read() + ..add(UpdateBldgLoc( + bldg_loc: bldgLocData)) + ..add(UpdateLandRef( + land_ref: landRefData)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), + ); + } + if (state is BarangayErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadBarangay(id: '1')); + }, + ); + } + return Container(); + }, + ); + } + if (state is MunicipalityErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadMunicipality()); + }, + ); + } + return Container(); + }, + ), + ), + ); + } + + Future _waitForAddPropertyInfoToComplete() async { + // Wait for the state change indicating completion + final propertyInfoState = context.read().state; + + if (propertyInfoState is PropertyInfoErrorState) { + // Check if the add operation was successful + return true; // You'll need to define this in your state class + } + + // Return false if the state didn't change as expected + return false; + } +} diff --git a/lib/screens/passo/Building/add_building_components/general_description.dart b/lib/screens/passo/Building/add_building_components/general_description.dart new file mode 100644 index 0000000..78bbbe2 --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/general_description.dart @@ -0,0 +1,226 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class GeneralDescriptionPage extends StatefulWidget { + final List unit; + final VoidCallback onPutGeneralDescription; + final VoidCallback gendescPrevBtn; + + GeneralDescriptionPage( + this.unit, this.onPutGeneralDescription, this.gendescPrevBtn); + + @override + _GeneralDescriptionPage createState() => _GeneralDescriptionPage(); +} + +class _GeneralDescriptionPage extends State { + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Container( + margin: + const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), + child: const Text('GENERAL DESCRIPTION', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Container( + margin: + const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderDropdown( + name: 'bldg_type', + autofocus: false, + decoration: normalTextFieldStyle("Kind of Building", ""), + items: widget.unit + .map((e) => DropdownMenuItem( + value: e, + child: Text('${e.bldgType}-${e.building}'), + )) + .toList(), + ), + ), + customDropDownField("Actual Use", "", 'actual_use', actual_use), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: + customTextField("Bldg. Permit No.", "", 'bldg_permit'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'date_issued')) + ]), + customTextField( + "Condominium Certificate of Title (CCT)", "", 'cct'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Certificate of Completion Issued ON", + "", + 'coc_issued'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'coo_issued')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Date Constructed /Completed", "", 'date_cnstructed'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Date Occupied", "", 'date_occupied')) + ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: < + Widget>[ + Expanded( + flex: 1, + child: customTextField("Bldg. Age", "", 'bldg_age'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("No. of storeys", "", 'no_of_storeys')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Area of 1st Floor", "", 'area_of_1stFl'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area of 2nd Floor", "", 'area_of_2ndFl')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Area of 3rd Floor", "", 'area_of_3rdFl')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area of 4th Floor", "", 'area_of_4thFl')) + ]), + customTextField("Total Area", "", 'total_area'), + SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.gendescPrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = await SharedPreferences.getInstance(); + widget.onPutGeneralDescription(); + var genDescData = GeneralDesc( + id: tempID.getInt('tempid')! - 1, + bldgKind: + formKey.currentState?.value['bldg_type'].building, + strucType: + formKey.currentState?.value['bldg_type'].bldgType, + bldgPermit: + formKey.currentState?.value['bldg_permit'], + dateIssued: formKey.currentState?.value['coc_issued'], + cct: formKey.currentState?.value['cct'], + certCompletionIssued: + formKey.currentState?.value['coc_issued'], + certOccupancyIssued: + formKey.currentState?.value['coo_issued'], + dateCompleted: + formKey.currentState?.value['date_cnstructed'], + dateOccupied: + formKey.currentState?.value['date_occupied'], + bldgAge: int.tryParse( + formKey.currentState?.value['bldg_age']), + noStoreys: int.tryParse( + formKey.currentState?.value['no_of_storeys']), + area1Stfloor: '0', + area2Ndfloor: '0', + area3Rdfloor: '0', + area4Thfloor: '0', + totalFloorArea: + formKey.currentState?.value['total_area'], + floorSketch: null, + actualUse: formKey.currentState?.value['actual_use']); + + context.read() + ..add(UpdateGeneralDesc(gen_desc: genDescData)); + } + ; + }, + ) + ], + ) + ], + ), + ), + ); + } +} diff --git a/lib/screens/passo/Building/add_building_components/property_appraisal.dart b/lib/screens/passo/Building/add_building_components/property_appraisal.dart new file mode 100644 index 0000000..e746860 --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/property_appraisal.dart @@ -0,0 +1,1032 @@ +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/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class PropertyAppraisalPage extends StatefulWidget { + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + PropertyAppraisalPage(this.NextBtn, this.PrevBtn); + + @override + _PropertyAppraisalPage createState() => _PropertyAppraisalPage(); +} + +class _PropertyAppraisalPage extends State { + double depRate = 0; + + double _depRate = 0; + + 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; + } + + calculateAdditionalItems(List items) { + double sum = 0; + double product = 1; + + for (AdditionalItems value in items) { + sum += double.parse(value.adjustedMarketVal); + } + + return 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 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 BlocConsumer( + listener: (context, state) {}, + builder: (context, state) { + if (state is AdditionalItemsLoaded) { + return 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: Text( + "Unit Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + formKey.currentState!.value['bldg_type'].unitValue + + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: 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(formKey + .currentState!.value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateAdditionalItems(state.items).toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateTotalConstructionCost( + (double.parse(formKey + .currentState!.value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: 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: Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (double.parse(formKey + .currentState!.value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: 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: Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (double.parse(formKey + .currentState!.value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items, + 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), + 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( + 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( + formKey.currentState + ?.value['actual_use']!, + 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: Text( + calculateMarketValue( + (double.parse(formKey + .currentState! + .value[ + 'total_area']) * + double.parse(formKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state.items, + depRate) + .toString(), + 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: Text( + assessmentLevel( + calculateMarketValue( + (double.parse(formKey + .currentState! + .value[ + 'total_area']) * + double.parse(formKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state.items, + depRate) + .toString(), + formKey.currentState + ?.value[ + 'actual_use']), + 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: Text( + assessmentValue( + calculateMarketValue( + (double.parse(formKey.currentState!.value[ + 'total_area']) * + double.parse(formKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state.items, + depRate) + .toString(), + formKey.currentState + ?.value[ + 'actual_use']) + .toString(), + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ) + ], + ), + ]))), + ), + ], + ), + 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')!, + 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']); + context.read() + ..add( + AddPropertyAppraisal(appraisal: appraisals)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ], + ), + ), + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/passo/Building/add_building_components/property_assessment.dart b/lib/screens/passo/Building/add_building_components/property_assessment.dart new file mode 100644 index 0000000..ff0d03c --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -0,0 +1,1168 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.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:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; + +import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; +import 'package:unit2/model/passo/memoranda.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:unit2/model/passo/property_assessment.dart'; +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/theme-data.dart/colors.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 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class PropertyAssessmentPage extends StatefulWidget { + Function function; + + PropertyAssessmentPage(this.function); + + @override + _PropertyAssessmentPage createState() => _PropertyAssessmentPage(); +} + +class _PropertyAssessmentPage 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 Scaffold( + resizeToAvoidBottomInset: true, + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is PropertyAssessmentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is PropertyAssessmentLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyAssessmentErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is PropertyAssessmentLoaded) { + return BlocConsumer( + listener: (context, state) { + if (state is SignatoriesLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is SignatoriesLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is SignatoriesErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + 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(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + final memoranda = state.memorada; + return BlocConsumer( + listener: (context, state) { + if (state is PropertyAppraisalLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is PropertyAppraisalLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyAppraisalErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, builder: (context, state) { + if (state is PropertyAppraisalLoaded) { + return ListView( + children: [ + Align( + alignment: Alignment.center, + child: 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( + padding: EdgeInsets.only( + left: 20.0, right: 20.0), + 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', + 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', + 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, + 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, + suggestions: memoranda + .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, + 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([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID.getInt('tempid')! - 1); + final List + propertyAssessments = []; + + PropertyAssessment ass = + PropertyAssessment( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')! - 1, + actualUse: formKey.currentState! + .value['actual_use'], + marketValue: '0.00', + assessmentLevel: '0.00', + assessedValue: '0.00', + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(formKey + .currentState!.value['qtr']), + yr: int.parse(formKey + .currentState!.value['yr']), + 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'], + 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'], + 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'], + dateReceived: formKey + .currentState! + .value['date_received'], + entryDateAssessment: formKey + .currentState! + .value['date_of_entry'], + entryDateBy: formKey + .currentState!.value['by'], + ); + + propertyAssessments.add(ass); + + context + .read() + ..add(UpdatePropertyAssessment( + assessment: + propertyAssessments[0])); + widget.function(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: SizedBox( + width: 200, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ]), + ), + ) + ], + ); + } + if (state is PropertyAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadPropertyAppraisal( + appraisal: PropertyAppraisal())); + }, + ); + } + return Container(); + }); + } + if (state is MemorandaErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadMemoranda()); + }, + ); + } + return Container(); + }, + ); + } + if (state is SignatoriesErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadSignatories()); + }, + ); + } + return Container(); + }, + ); + } + if (state is PropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadPropertyAssessment()); + }, + ); + } + return Container(); + }, + ), + ), + ); + } +} diff --git a/lib/screens/passo/Building/add_building_components/property_info.dart b/lib/screens/passo/Building/add_building_components/property_info.dart new file mode 100644 index 0000000..6cad1fc --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/property_info.dart @@ -0,0 +1,156 @@ +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/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/model/passo/property_info.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'; + +GlobalKey ownerKey = GlobalKey(); + +class PropertyInfoPage extends StatefulWidget { + final VoidCallback handleButtonPress; + const PropertyInfoPage(this.handleButtonPress, {super.key}); + + @override + _PropertyInfoPage createState() => _PropertyInfoPage(); +} + +class _PropertyInfoPage extends State { + int tempId = 0; + final transaction_codes = ['New', 'Revision']; + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.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), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("ARP No. / TD No.", "", 'arp_td')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Pin", "", 'pin')), + ], + ), + customTextField("Owner", "", 'owner'), + customTextField("Address", "", 'address'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Tel No.", "", 'tel_no'), + ), + 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( + "Administrator / Benificial User", "", 'benificiary'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("TIN", "", 'benificiary_tin')) + ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: < + Widget>[ + Expanded( + flex: 1, + child: customTextField("Address", "", 'benificiary_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.", "", 'benificiary_telno')) + ]), + const SizedBox(height: 25), + CustomButton( + icon: const Icon(Icons.chevron_right, color: Colors.white), + onPressed: () async { + var property_info = PropertyInfo( + id: 1, + transCode: formKey.currentState!.value['transaction_code'] + .toString(), + tdn: formKey.currentState!.value['arp_td'], + pin: formKey.currentState!.value['pin'], + owner: formKey.currentState!.value['owner'], + address: formKey.currentState!.value['address'], + telno: formKey.currentState!.value['tel_no'], + tin: formKey.currentState!.value['tin'], + adminUser: formKey.currentState!.value['benificiary'], + adminAddress: + formKey.currentState!.value['benificiary_address'], + adminTin: formKey.currentState!.value['benificiary_tin'], + adminTelno: + formKey.currentState!.value['benificiary_telno'], + assessedById: '1', + assessedByName: 'Cyril', + faasType: "BUILDING", + dateModified: DateTime.now(), + dateCreated: DateTime.now()); + + // Dispatch the event to add the property_info + context.read().add( + AddPropertyInfo(property_info: property_info), + ); + + // Wait for the event to complete and get the result + bool success = await _waitForAddPropertyInfoToComplete(); + + if (success) { + // Proceed to the next step or perform an action + widget.handleButtonPress(); + } else { + // Stay or show an error message + } + }, + ) + ]), + ), + ); + } + + Future _waitForAddPropertyInfoToComplete() async { + // Wait for the state change indicating completion + final propertyInfoState = context.read().state; + + if (propertyInfoState is PropertyInfoLoaded) { + // Check if the add operation was successful + return true; // You'll need to define this in your state class + } + + // Return false if the state didn't change as expected + return false; + } +} diff --git a/lib/screens/passo/Building/add_building_components/structural_materials.dart b/lib/screens/passo/Building/add_building_components/structural_materials.dart new file mode 100644 index 0000000..67f6edd --- /dev/null +++ b/lib/screens/passo/Building/add_building_components/structural_materials.dart @@ -0,0 +1,421 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:multiselect/multiselect.dart'; +import 'package:shared_preferences/shared_preferences.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/passo/Building/add_building.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class MaterialOption { + final String id; + final String label; + + MaterialOption(this.id, this.label); +} + +class StructuralMaterialsPage extends StatefulWidget { + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + StructuralMaterialsPage(this.NextBtn, this.PrevBtn); + + @override + _StructuralMaterialsPage createState() => _StructuralMaterialsPage(); +} + +class _StructuralMaterialsPage extends State { + List foundation = []; + List column = []; + List beam = []; + List truss_framing = []; + List roof = []; + List flooring = []; + List walls = []; + bool foundationOthers = false; + bool columOthers = false; + bool beamsOthers = false; + bool tfOthers = false; + bool roofOthers = false; + bool flooringOthers = false; + bool wpOthers = false; + + List columnOptions = [ + MaterialOption('steel', 'Steel'), + MaterialOption('concrete', 'Reinforced Concrete'), + MaterialOption('wood', 'Wood'), + ]; + + List selectedColumnValues = []; + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + padding: const EdgeInsets.all(30.0), + child: Column( + children: [ + Container( + margin: + const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), + child: const Text('STRUCTURAL MATERIALS', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'FOUNDATION', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: foundationOthers, + onChanged: (bool? value) { + setState(() { + foundationOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: foundationOthers, + child: customTextField( + "Enter other foundation", "", "other_foundation"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + foundation = x; + }); + }, + options: const ['Reinforced Concrete', 'Plain Concrete'], + selectedValues: foundation, + whenEmpty: 'Select Foundations', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'COLUMNS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: columOthers, + onChanged: (bool? value) { + setState(() { + columOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: columOthers, + child: customTextField("Enter other columns", "", "other_column"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + column = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: column, + whenEmpty: 'Select Column/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'BEAMS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: beamsOthers, + onChanged: (bool? value) { + setState(() { + beamsOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: beamsOthers, + child: customTextField("Enter other beam/s", "", "other_beam"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + beam = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: beam, + whenEmpty: 'Select Beam/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'TRUSS FRAMING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: tfOthers, + onChanged: (bool? value) { + setState(() { + tfOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: tfOthers, + child: customTextField( + "Enter other truss framing/s", "", "other_tf"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + truss_framing = x; + }); + }, + options: const ['Steel', 'Wood'], + selectedValues: truss_framing, + whenEmpty: 'Select Truss Framing/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'ROOF', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: roofOthers, + onChanged: (bool? value) { + setState(() { + roofOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: roofOthers, + child: customTextField("Enter other roof/s", "", "other_roof"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + roof = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Tiles', + 'G.I Sheet', + 'Aluminum', + 'Asbestos', + 'Long Span', + 'Concrete Desk', + 'Nipa/Anahaw/Cogon' + ], + selectedValues: roof, + whenEmpty: 'Select Roof/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'FLOORING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: flooringOthers, + onChanged: (bool? value) { + setState(() { + flooringOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: flooringOthers, + child: customTextField( + "Enter other flooring/s", "", "other_flooring"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + flooring = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Cement', + 'Marble', + 'Wood', + 'Tiles' + ], + selectedValues: flooring, + whenEmpty: 'Select Flooring/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'WALLS & PARTITIONS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: wpOthers, + onChanged: (bool? value) { + setState(() { + wpOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: wpOthers, + child: customTextField( + "Enter other walls & partition/s", "", "other_wp"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + walls = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Concrete', + 'Wood', + 'CHIB', + 'G.I Sheet', + 'Build-a-wall', + 'Sawali', + 'Bamboo' + ], + selectedValues: walls, + whenEmpty: 'Select Walls & Partition/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: + const Icon(Icons.chevron_left_rounded, color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = await SharedPreferences.getInstance(); + var strucMaterials = StructureMaterialsII( + id: 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(UpdateStrucMaterials(data: strucMaterials)); + + widget.PrevBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ); + } +} diff --git a/lib/screens/passo/Building/edit_building.dart b/lib/screens/passo/Building/edit_building.dart new file mode 100644 index 0000000..6a1dde5 --- /dev/null +++ b/lib/screens/passo/Building/edit_building.dart @@ -0,0 +1,204 @@ +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:im_stepper/stepper.dart'; +import 'package:unit2/bloc/passo/bulding/class_components/class_components_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Building/edit_building/additional_items.dart'; +import 'package:unit2/screens/passo/Building/edit_building/bldgloc_landref.dart'; +import 'package:unit2/screens/passo/Building/edit_building/general_description.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_appraisal.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_assessement_edit.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.dart'; +import 'package:unit2/screens/passo/Building/edit_building/structural_materials.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +class EditBuilding extends StatefulWidget { + final int index; + final PropertyInfo faas; + final String title; + + const EditBuilding( + {super.key, + required this.title, + required this.index, + required this.faas}); + @override + _EditBuilding createState() => _EditBuilding(); +} + +class _EditBuilding 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++; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: AppBar( + centerTitle: true, + backgroundColor: primary, + title: Text('Building FAAS Edit'), + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is UnitConstructLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is UnitConstructLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is UnitConstructErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + final unit = state.unit; + return BlocConsumer( + listener: (context, state) { + if (state is ClassComponentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is ClassComponentLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is ClassComponentErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is ClassComponentLoaded) { + return 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; + }); + }, + ), + content(unit, state.classes), + ], + ), + ); + } + if (state is ClassComponentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadClassComponents()); + }, + ); + } + return Container(); + }, + ); + } + if (state is UnitConstructErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadUnitConstruct()); + }, + ); + } + return Container(); + }, + ), + ), + ), + ); + } + + // Returns the header text based on the activeStep. + Widget content(List unit, classes) { + switch (activeStep) { + case 0: + return PropertyOwnerInfoEdit( + widget.index, widget.faas, widget.title, NextBtn, PrevBtn); + + case 1: + return BldgLocLandRefEdit(widget.faas.id!, NextBtn, PrevBtn); + + case 2: + return GeneralDescriptionEdit(unit, widget.faas.id!, NextBtn, PrevBtn); + + case 3: + return StructuralMaterialsPageEdit(widget.faas.id!, NextBtn, PrevBtn); + + case 4: + return AdditionalItemEditPage( + unit, classes, widget.faas.id!, NextBtn, PrevBtn); + + case 5: + return PropertyAppraisalEditPage(widget.faas.id!, NextBtn, PrevBtn); + + case 6: + return PropertyAssessmentEditPage(widget.faas.id!); + + default: + return PropertyOwnerInfoEdit( + widget.index, widget.faas, widget.title, NextBtn, PrevBtn); + } + } +} diff --git a/lib/screens/passo/Building/edit_building/AddExtraItems.dart b/lib/screens/passo/Building/edit_building/AddExtraItems.dart new file mode 100644 index 0000000..374968d --- /dev/null +++ b/lib/screens/passo/Building/edit_building/AddExtraItems.dart @@ -0,0 +1,594 @@ +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:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.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'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +class AddExtraItemsEdit extends StatefulWidget { + final List unit; + final List options; + final int tempId; + + AddExtraItemsEdit(this.unit, this.options, this.tempId); + + @override + _AddExtraItemsEdit createState() => _AddExtraItemsEdit(); +} + +class _AddExtraItemsEdit extends State { + GlobalKey formKey = GlobalKey(); + final focus = FocusNode(); + double _computedValue = 0; + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + double _depValue = 0; + double _unitValue = 0; + double _marketValue = 0; + String _className = ""; + int _classId = 0; + String _structureType = ""; + bool _withoutBUCC = false; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _computeValue(double unitbase, double unitvalue, double area) { +// Compute some value based on the text here + return (unitbase * unitvalue) * area; + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _adjustedMarketValue(unitVal, unitBase, area, depreciation) { + double depAmount = ((unitVal * unitBase) * area) * depreciation; + + return ((unitVal * unitBase) * area) - depAmount; + } + + double _totalMarketValue(unitVal, unitBase, area, depreciation, withBUCC, + className, painted, secondHand, paintedUnitVal, secondhandUntVal) { + if (withBUCC == false) { + if (painted == true || secondHand == true) { + final deductions = (paintedUnitVal + secondhandUntVal) / 100; + + print(deductions); + return (((unitVal - deductions) * unitBase) * area); + } else { + return ((unitVal * unitBase) * area); + } + } else { + return (unitVal * area); + } + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddItemsScreenEdit) { + return FormBuilder( + key: formKey, + onChanged: () { + formKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 800, + 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: FormBuilderDropdown( + name: 'extra_item', + autofocus: false, + decoration: + normalTextFieldStyle("Additional Item", ""), + items: widget.options + .map((e) => DropdownMenuItem( + value: e, + 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; + }); + 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; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxBaseUnitvalPercent}); + } + if (value.minUnitvalSqrmtr != '0.00') { + setState(() { + _unitValue = + double.parse(value.minUnitvalSqrmtr); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minUnitvalSqrmtr}); + } + if (value.maxUnitvalSqrmtr != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxUnitvalSqrmtr); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxUnitvalSqrmtr}); + } + if (value.minAddBaseunitval != '0.00') { + setState(() { + _unitValue = + double.parse(value.minAddBaseunitval); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minAddBaseunitval}); + } + if (value.maxAddBaseunitval != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxAddBaseunitval); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxAddBaseunitval}); + } + if (value.minDeductBaserate != '0.00') { + setState(() { + _unitValue = + double.parse(value.minDeductBaserate); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.minDeductBaserate}); + } + if (value.maxDeductBaserate != '0.00') { + setState(() { + _unitValue = + double.parse(value.maxDeductBaserate); + _className = value.componentName; + _classId = value.id; + _withoutBUCC = value.withoutBucc; + }); + formKey.currentState!.patchValue( + {'unitValue': value.maxDeductBaserate}); + } + }, + ), + ), + const SizedBox(height: 10), + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: widget.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; + }); + focus.unfocus(); + }, + ), + ), + ), + // const SizedBox(height: 10), + // Container( + // margin: const EdgeInsets.only( + // left: 0, top: 10, right: 0, bottom: 0), + // child: FormBuilderDropdown( + // name: 'struc_type', + // autofocus: false, + // decoration: + // normalTextFieldStyle("Structure Type", ""), + // items: widget.unit + // .map((e) => DropdownMenuItem( + // value: e, + // child: + // Text(e.bldgType + " - " + e.building), + // )) + // .toList(), + // onChanged: (val) { + // setState(() { + // _unitBase = double.parse(val!.unitValue); + // _structureType = val.bldgType; + // }); + // }, + // ), + // ), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + flex: 1, + child: FormBuilderTextField( + name: 'unitValue', + decoration: + normalTextFieldStyle("Unit Value", ""), + validator: FormBuilderValidators.compose([]), + ), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: FormBuilderTextField( + name: 'areaValue', + decoration: normalTextFieldStyle("Area", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _areaValue = int.parse(value!); + }); + }, + ), + ), + ], + ), + // const SizedBox(height: 10), + // FormBuilderTextField( + // name: 'depRate', + // decoration: + // normalTextFieldStyle("Depreciation Rate", ""), + // validator: FormBuilderValidators.compose([]), + // onChanged: (value) { + // setState(() { + // _depValue = double.parse(value!); + // }); + // }, + // ), + // const SizedBox(height: 10), + // FormBuilderTextField( + // name: 'marketValue', + // decoration: normalTextFieldStyle( + // NumberFormat.currency( + // locale: 'en-PH', symbol: "₱") + // .format(_totalMarketValue(_unitValue, + // _unitBase, _areaValue, _depValue)), + // ""), + // validator: FormBuilderValidators.compose([]), + // onChanged: (value) { + // setState(() { + // _marketValue = double.parse(value!); + // }); + // }, + // ), + // const SizedBox(height: 10), + // 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(_unitValue, + // _unitBase, _areaValue, _depValue)))), + // ), + + Visibility( + visible: !_withoutBUCC, + child: Column( + children: [ + const SizedBox(height: 10), + Text('Building is not painted?'), + const SizedBox(height: 5), + Container( + child: Row( + children: [ + Checkbox( + value: isPainted, + onChanged: (bool? value) { + setState(() { + isPainted = value!; + if (value == false) { + _notPaintedUnitVal = 0; + } else { + _notPaintedUnitVal = 10; + } + }); + }, + ), + const SizedBox(width: 10), + Container( + height: 40.0, + width: 100, + 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(' - ' + + _notPaintedUnitVal.toString() + + '%')), + ), + ], + ), + ), + const SizedBox(height: 10), + Text('Uses second hand materials?'), + const SizedBox(height: 5), + Container( + child: Row( + children: [ + Checkbox( + value: isSecondHand, + onChanged: (bool? value) { + setState(() { + isSecondHand = value!; + if (isSecondHand == false) { + _secondHandUnitVal = 0; + formKey.currentState!.patchValue( + {'secondHandMat': '0'}); + } else { + _secondHandUnitVal = 5; + formKey.currentState!.patchValue( + {'secondHandMat': '5'}); + } + }); + }, + ), + const SizedBox(width: 10), + Row( + children: [ + SizedBox( + height: 40, + width: 100, + child: FormBuilderTextField( + enabled: isSecondHand, + name: 'secondHandMat', + textAlign: TextAlign.center, + decoration: normalTextFieldStyle( + "Unit Value", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + // Check if the value is not null before parsing to double + if (value != null && + value.isNotEmpty) { + setState(() { + _secondHandUnitVal = + int.parse(value); + }); + } else { + // Handle the case when the value is empty or null + // For example, set _secondHandUnitVal to a default value or show an error message. + } + }, + ), + ), + SizedBox( + height: 40, + width: 40, + child: Center( + child: Text( + '%', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold), + ), + ), + ) + ], + ), + ], + ), + ), + ], + ), + ), + + const SizedBox(height: 10), + 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( + _unitValue, + _unitBase, + _areaValue, + _depValue, + _withoutBUCC, + _className, + isPainted, + isSecondHand, + _notPaintedUnitVal, + _secondHandUnitVal)))), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + var itemss = AdditionalItems( + id: 1, + bldgapprDetailsId: widget.tempId, + classId: _classId, + className: _className, + structType: _structureType, + unitValue: + _withoutBUCC == true ? 0 : _unitValue, + baseUnitValue: _unitBase, + area: _areaValue, + marketValue: + (_unitValue * _unitBase) * _areaValue, + depreciationRate: _depValue, + adjustedMarketVal: _totalMarketValue( + _unitValue, + _unitBase, + _areaValue, + _depValue, + _withoutBUCC, + _className, + isPainted, + isSecondHand, + _notPaintedUnitVal, + _secondHandUnitVal), + actualUse: 'Test', + amtDepreciation: _amountofDepreciation( + _unitValue, + _unitBase, + _areaValue, + _depValue, + ), + painted: true, + secondhand: true, + paintedUnitval: '1', + secondhandUnitval: '1'); + + context.read().add( + AddAdditionalItemsEdit(items: itemss)); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + 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(LoadAdditionalItems()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ))); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Building/edit_building/additional_items.dart b/lib/screens/passo/Building/edit_building/additional_items.dart new file mode 100644 index 0000000..b5b9872 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/additional_items.dart @@ -0,0 +1,305 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.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'; +import 'package:unit2/screens/passo/Building/edit_building/AddExtraItems.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class AdditionalItemEditPage extends StatefulWidget { + final List unit; + final List options; + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + AdditionalItemEditPage( + this.unit, this.options, this.tempId, this.NextBtn, this.PrevBtn); + + @override + _AdditionalItemEditPage createState() => _AdditionalItemEditPage(); +} + +class _AdditionalItemEditPage extends State { + void deleteItem(int itemId) { + context + .read() + .add(DeleteAdditionalItemsEdit(id: itemId)); + } + + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row.adjustedMarketVal); + // }); + // return total; + // } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + final state = context.watch().state; + if (state is AdditionalItemsEditLoaded) { + return Column( + children: [ + Container( + height: 500, + child: 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('ADDITIONAL ITEMS', + 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(ShowAdditionalItemsEdit()); + }, + 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('Items'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('% of BUCC'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.items.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.className)), + DataCell(Text(dataRow.baseUnitValue)), + DataCell(Text(dataRow.unitValue)), + DataCell(Text(((double.parse( + dataRow.adjustedMarketVal))) + .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: () { + deleteItem(dataRow.id); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).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(_totalMarketValue(state.items)), + // 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 AdditionalItemsEditDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadAdditionalItemsEdit( + items: const [], id: widget.tempId)); + }); + }); + } + } + if (state is ShowAddItemsScreenEdit) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD EXTRA ITEMS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: AddExtraItemsEdit( + widget.unit, widget.options, widget.tempId)) + ], + ), + ), + ); + } + return Container( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('ADDITIONAL MATERIALS', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/screens/passo/Building/edit_building/bldgloc_landref.dart b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart new file mode 100644 index 0000000..2b6ced8 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart @@ -0,0 +1,453 @@ +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/passo/barangay/barangay_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/landref/landref_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/location/location_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; + +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; + +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.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 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class BldgLocLandRefEdit extends StatefulWidget { + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + BldgLocLandRefEdit(this.tempId, this.NextBtn, this.PrevBtn); + @override + _BldgLocLandRefEdit createState() => _BldgLocLandRefEdit(); +} + +class _BldgLocLandRefEdit extends State { + Set seenCityCodes = Set(); + @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 LocationLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LocationLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LocationErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is LocationLoaded) { + final bldgloc = state.bldgloc; + return BlocConsumer( + listener: (context, state) { + if (state is LandrefLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandrefLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandrefErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, + builder: (context, state) { + if (state is LandrefLoaded) { + final landRef = state.landRef; + return BlocConsumer( + listener: (context, state) { + if (state is MunicipalityLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is MunicipalityLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is MunicipalityErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, builder: (context, state) { + if (state is MunicipalityLoaded) { + final cityList = state.municipality; + Set uniqueItems = {}; + + // Iterate through the dropdownItems list to filter out duplicates + for (var item in cityList) { + uniqueItems.add(item); + } + return BlocConsumer( + listener: (context, state) { + if (state is BarangayLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is BarangayLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is BarangayErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + // Fluttertoast.showToast( + // msg: onError, + // fontSize: 24, + // toastLength: Toast.LENGTH_LONG, + // gravity: ToastGravity.CENTER, + // backgroundColor: Colors.black, + // textColor: Colors.white); + } + }, builder: (context, state) { + if (state is BarangayLoaded) { + List brgyList = state.brgy; + List brgyNAmes = brgyList + .map((brgy) => brgy.barangayDescription) + .toList() + .cast(); + return FormBuilder( + key: keys, + initialValue: { + 'street': bldgloc.street, + // 'brgy': bldgloc.barangay, + // 'municipality': bldgloc.municipality, + 'province': bldgloc.province, + 'l_owner': landRef.owner, + 'oct_tct_cloa': landRef.cloaNo, + 'survey_no': landRef.surveyNo, + 'lot_no': landRef.lotNo, + 'blk_no': landRef.blkNo, + 'l_td_arp': landRef.tdn, + 'area': landRef.area + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: ListView( + shrinkWrap: true, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 10), + child: const Text('BUILDING LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'municipality', + autofocus: false, + decoration: normalTextFieldStyle( + bldgloc.municipality ?? + "Municipality", + "", + ), + items: uniqueItems + .map( + (city) => + DropdownMenuItem( + value: city, + child: Text( + city.cityDescription ?? + ''), + ), + ) + .toList(), + onChanged: (selectedCityCode) { + // Find the corresponding City object using selectedCityCode + final selectedCity = cityList + .firstWhere((city) => + city.cityCode == + selectedCityCode); + + final barangayBloc = context + .read(); + barangayBloc.add(LoadBarangay( + id: selectedCityCode! + .cityCode!)); + }, + ), + ), + 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')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + 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: customDropDownField( + bldgloc.barangay, + "", + 'brgy', + brgyNAmes)) + ]), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 10), + child: const Text('LAND REFERENCE', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + customTextField( + "Land Owner", "", 'l_owner'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "OCT/TCT/CLOA No.", + "", + 'oct_tct_cloa'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Survey No.", + "", + 'survey_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + 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 No.", "", 'blk_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "TD / ARP No.", "", 'l_td_arp'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area", "", 'area')) + ]), + 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: () { + { + var bldgLocData = BldgLoc( + id: widget.tempId, + street: keys.currentState + ?.value['street'], + barangay: keys.currentState + ?.value['brgy'], + municipality: keys + .currentState + ?.value['municipality'] + ?.cityDescription ?? + bldgloc.municipality, + province: keys.currentState + ?.value['province'], + ); + var landRefData = LandRef( + id: widget.tempId, + owner: keys.currentState + ?.value['l_owner'], + cloaNo: keys.currentState + ?.value['oct_tct_cloa'], + lotNo: keys.currentState + ?.value['lot_no'], + tdn: keys.currentState + ?.value['l_td_arp'], + area: keys.currentState + ?.value['area'], + surveyNo: keys.currentState + ?.value['survey_no'], + blkNo: keys.currentState + ?.value['blk_no'], + ); + context.read() + ..add(UpdateBldgLoc( + bldg_loc: bldgLocData)) + ..add(UpdateLandRef( + land_ref: landRefData)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), + ), + ); + } + if (state is BarangayErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadBarangay(id: '01')); + }, + ); + } + return Container(); + }); + } + if (state is MunicipalityErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadMunicipality()); + }, + ); + } + return Container(); + }); + } + if (state is LandrefErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandref(id: widget.tempId, landRef: LandRef())); + }, + ); + } + return Container(); + }, + ); + } + + if (state is LocationErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLocation(id: widget.tempId, bldgloc: BldgLoc())); + }, + ); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/passo/Building/edit_building/general_description.dart b/lib/screens/passo/Building/edit_building/general_description.dart new file mode 100644 index 0000000..201d6b7 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/general_description.dart @@ -0,0 +1,306 @@ +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/passo/bulding/general_description/general_description_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.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 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +import '../add_building.dart'; + +class GeneralDescriptionEdit extends StatefulWidget { + final List unit; + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + GeneralDescriptionEdit(this.unit, this.tempId, this.NextBtn, this.PrevBtn); + @override + _GeneralDescriptionEdit createState() => _GeneralDescriptionEdit(); +} + +class _GeneralDescriptionEdit extends State { + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + @override + Widget build(BuildContext context) { + return Expanded( + child: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is GenDescLoaded) { + return FormBuilder( + key: keys, + initialValue: { + 'bldg_permit': state.gendesc.bldgPermit, + 'date_issued': state.gendesc.dateIssued.toString(), + 'cct': state.gendesc.cct.toString(), + 'coc_issued': state.gendesc.certCompletionIssued.toString(), + 'coo_issued': state.gendesc.certOccupancyIssued.toString(), + 'date_cnstructed': state.gendesc.dateIssued.toString(), + 'date_occupied': state.gendesc.dateOccupied.toString(), + 'bldg_age': state.gendesc.bldgAge.toString(), + 'no_of_storeys': state.gendesc.noStoreys.toString(), + 'area_of_1stFl': state.gendesc.area1Stfloor, + 'area_of_2ndFl': state.gendesc.area2Ndfloor, + 'area_of_3rdFl': state.gendesc.area3Rdfloor, + 'area_of_4thFl': state.gendesc.area4Thfloor, + 'total_area': state.gendesc.totalFloorArea.toString(), + 'actual_use': state.gendesc.actualUse + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('GENERAL DESCRIPTION', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderDropdown( + name: 'bldg_type', + autofocus: false, + decoration: normalTextFieldStyle( + state.gendesc.bldgKind ?? "Kind of Building", + "Kind of Building"), + items: widget.unit + .map((e) => DropdownMenuItem( + value: e, + child: + Text(e.bldgType + '-' + e.building), + )) + .toList(), + ), + ), + customDropDownField( + "Actual Use", "", 'actual_use', actual_use), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Bldg. Permit No.", "", 'bldg_permit'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'date_issued')) + ]), + customTextField( + "Condominium Certificate of Title (CCT)", + "", + 'cct'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Certificate of Completion Issued ON", + "", + 'coc_issued'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'coo_issued')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Date Constructed /Completed", + "", + 'date_cnstructed'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Date Occupied", "", 'date_occupied')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Bldg. Age", "", 'bldg_age'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "No. of storeys", "", 'no_of_storeys')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Area of 1st Floor", "", 'area_of_1stFl'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Area of 2nd Floor", + "", 'area_of_2ndFl')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Area of 3rd Floor", + "", 'area_of_3rdFl')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Area of 4th Floor", + "", 'area_of_4thFl')) + ]), + customTextField("Total Area", "", 'total_area'), + 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: () { + { + keys.currentState!.save(); + var genDescData = GeneralDesc( + id: widget.tempId, + bldgKind: keys + .currentState + ?.value['bldg_type'] + ?.building ?? + state.gendesc.bldgKind, + strucType: keys + .currentState + ?.value['bldg_type'] + ?.bldgType ?? + state.gendesc.strucType, + bldgPermit: keys + .currentState?.value['bldg_permit'], + dateIssued: keys + .currentState?.value['coc_issued'], + cct: keys.currentState?.value['cct'], + certCompletionIssued: keys + .currentState?.value['coc_issued'], + certOccupancyIssued: keys + .currentState?.value['coo_issued'], + dateCompleted: keys.currentState + ?.value['date_cnstructed'], + dateOccupied: keys.currentState + ?.value['date_occupied'], + bldgAge: int.tryParse(keys.currentState?.value['bldg_age']), + noStoreys: int.tryParse(keys.currentState?.value['no_of_storeys']), + area1Stfloor: keys.currentState?.value['area_of_1stFl'], + area2Ndfloor: keys.currentState?.value['area_of_2ndFl'], + area3Rdfloor: keys.currentState?.value['area_of_3rdFl'], + area4Thfloor: keys.currentState?.value['area_of_4thFl'], + totalFloorArea: keys.currentState?.value['total_area'], + floorSketch: null, + actualUse: keys.currentState?.value['actual_use']); + + context.read() + ..add(UpdateGeneralDesc( + gen_desc: genDescData)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), + ), + ), + ); + } + if (state is GenDescErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadGenDesc(id: widget.tempId, gendesc: GeneralDesc())); + }, + ); + } + return Container(); + }, + ), + ), + ); + } +} diff --git a/lib/screens/passo/Building/edit_building/property_appraisal.dart b/lib/screens/passo/Building/edit_building/property_appraisal.dart new file mode 100644 index 0000000..535eb1f --- /dev/null +++ b/lib/screens/passo/Building/edit_building/property_appraisal.dart @@ -0,0 +1,1135 @@ +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/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart'; + +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:unit2/model/passo/property_appraisal_edit.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.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 'package:unit2/widgets/passo/custom_button.dart'; + +class PropertyAppraisalEditPage extends StatefulWidget { + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + PropertyAppraisalEditPage(this.tempId, this.NextBtn, this.PrevBtn); + + @override + _PropertyAppraisalEditPage createState() => _PropertyAppraisalEditPage(); +} + +class _PropertyAppraisalEditPage extends State { + double depRate = 0; + + 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 BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is PropertyAppraisalEditLoaded) { + final appraisal = state.appraisalEdit; + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is AdditionalItemsEditLoaded) { + final item = state.items; + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is GenDescLoaded) { + double totalArea = double.tryParse( + state.gendesc.totalFloorArea ?? + appraisal.totalArea.toString()) ?? + 0.0; + + double bldgUnitValue = double.tryParse( + keys.currentState?.value['bldg_type']?.unitValue ?? + appraisal.unitconstructCost) ?? + 0.0; + return 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: 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: 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( + bldgUnitValue.toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + appraisal.addItemsSubtotal!, + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateConstructionCost( + double.parse(appraisal + .unitconstructSubtotal!), + double.parse( + appraisal.addItemsSubtotal!)) + .toString()!, + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: 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: Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (totalArea * bldgUnitValue), + item, + double.parse(keys.currentState + ?.value['depRate'] ?? + appraisal.depreciationRate)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total % Depreciation", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '${(double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate) * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (totalArea * bldgUnitValue), + item, + double.parse(keys.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: 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(keys + .currentState + ?.value['depRate'] ?? + appraisal.depreciationRate)), + ), + 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: Text( + assessmentLevel( + calculateMarketValue( + (totalArea * bldgUnitValue), + item, + double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)) + .toString(), + state.gendesc.actualUse) + + '%', + 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: Text( + NumberFormat + .currency( + locale: 'en-PH', + symbol: "₱", + ).format(assessmentValue( + calculateMarketValue( + (totalArea * + bldgUnitValue), + item, + double.parse(keys.currentState?.value['depRate'] ?? + appraisal + .depreciationRate)) + .toString(), + state.gendesc + .actualUse)), + style: 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')! - 1; + { + var appraisals = PropertyAppraisalEdit( + id: 1, + bldgapprDetailsId: id, + 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() + ..add(UpdatePropertyAppraisalEdit( + appraisalEdit: 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/passo/Building/edit_building/property_assessement_edit.dart b/lib/screens/passo/Building/edit_building/property_assessement_edit.dart new file mode 100644 index 0000000..e2b20e3 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/property_assessement_edit.dart @@ -0,0 +1,1093 @@ +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:unit2/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart'; +import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; +import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; +import 'package:unit2/model/passo/memoranda.dart'; +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/signatories.dart'; +import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.dart'; +import 'package:unit2/theme-data.dart/btn-style.dart'; +import 'package:unit2/theme-data.dart/colors.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 '../../../../model/passo/general_description.dart'; + +class PropertyAssessmentEditPage extends StatefulWidget { + int tempId; + PropertyAssessmentEditPage(this.tempId); + @override + _PropertyAssessmentEditPage createState() => _PropertyAssessmentEditPage(); +} + +class _PropertyAssessmentEditPage 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 BlocBuilder( + builder: (context, state) { + if (state is PropertyAssessmentEditLoaded) { + final assessment = state.assessmentsEdit; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return FormBuilder( + key: keys, + initialValue: { + 'qtr': assessment.qtr.toString(), + 'yr': assessment.qtr.toString(), + // 'appraised_by': assessment.appraisedbyName, + 'app_date': assessment.appraisedbyDate.toString(), + // 'rec_approval': assessment.recommendapprName, + 'rec_date': assessment.recommendapprDate.toString(), + // 'apprvd_by': assessment.approvedbyName, + 'memoranda': assessment.memoranda, + 'sworn_statement': assessment.swornstatementNo, + 'date_received': assessment.dateReceived.toString(), + 'date_of_entry': + assessment.entryDateAssessment.toString(), + 'by': assessment.entryDateBy + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.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, + + suggestions: state.memorada + .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, + 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([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + SizedBox( + width: + MediaQuery.of(context).size.width, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: SizedBox( + width: 200, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + onPressed: () { + final List + propertyAssessments = []; + + PropertyAssessmentEdit ass = + PropertyAssessmentEdit( + id: 1, + bldgapprDetailsId: 440, + actualUse: assessment.actualUse, + marketValue: '0.0', + assessmentLevel: '0.0', + assessedValue: "1.0", + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(keys + .currentState! + .value['qtr']), + yr: int.parse(keys + .currentState!.value['yr']), + appraisedbyName: keys + .currentState! + .value['appraised_by'] + .firstname + + ' ' + + keys + .currentState! + .value['appraised_by'] + .middlename + + ' ' + + keys + .currentState! + .value['appraised_by'] + .lastname, + appraisedbyDate: keys + .currentState! + .value['app_date'], + recommendapprName: keys + .currentState! + .value['rec_approval'] + .firstname + + ' ' + + keys + .currentState! + .value['rec_approval'] + .middlename + + ' ' + + keys + .currentState! + .value['rec_approval'] + .lastname, + recommendapprDate: keys + .currentState! + .value['rec_date'], + approvedbyName: keys + .currentState! + .value['apprvd_by'] + .firstname + + ' ' + + keys + .currentState! + .value['apprvd_by'] + .middlename + + ' ' + + keys + .currentState! + .value['apprvd_by'] + .lastname, + memoranda: _memoranda, + swornstatementNo: keys + .currentState! + .value['sworn_statement'], + dateReceived: keys.currentState! + .value['date_received'], + entryDateAssessment: keys + .currentState! + .value['date_of_entry'], + entryDateBy: keys + .currentState!.value['by'], + ); + + propertyAssessments.add(ass); + + context.read< + PropertyAssessmentEditBloc>() + ..add( + UpdatePropertyAssessmentEdit( + assessmentsEdit: + propertyAssessments[ + 0])); + }, + ), + ), + ], + ), + )) + ], + ), + ), + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + if (state is PropertyAssessmentEditErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadPropertyAssessmentEdit( + assessmentsEdit: PropertyAssessmentEdit(), + id: widget.tempId)); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/passo/Building/edit_building/property_owner_info.dart b/lib/screens/passo/Building/edit_building/property_owner_info.dart new file mode 100644 index 0000000..7e81231 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/property_owner_info.dart @@ -0,0 +1,229 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:multiselect/multiselect.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/theme-data.dart/btn-style.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +GlobalKey keys = GlobalKey(); + +class PropertyOwnerInfoEdit extends StatefulWidget { + final int index; + final PropertyInfo faas; + final String title; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + const PropertyOwnerInfoEdit( + this.index, this.faas, this.title, this.NextBtn, this.PrevBtn); + + @override + State createState() => _PropertyOwnerInfoEdit(); +} + +ButtonStyle secondaryBtnStyle( + Color background, Color borderColor, Color overlay) { + return ButtonStyle( + elevation: MaterialStateProperty.all(0), + backgroundColor: MaterialStateProperty.all(background), + overlayColor: MaterialStateProperty.all(overlay), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + side: BorderSide( + width: 2, + color: borderColor, + )))); +} + +class _PropertyOwnerInfoEdit extends State { + // late List selectedFoundation = widget.faas.foundations; + // late List selectedColumns = widget.faas.columns; + // late List selectedBeams = widget.faas.beams; + // late List selectedTFraming = widget.faas.truss_framing; + // late List selectedRoof = widget.faas.roof; + // late List selectedFlooring = widget.faas.flooring; + // late List selectedWallPartition = widget.faas.walls_and_partition; + + Map myMap = {'zero': 0, 'one': 1, 'two': 2}; + + final transaction_codes = ['New', 'Revision']; + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is PropertyInfoLoaded) { + return SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Expanded( + child: Column( + children: [ + FormBuilder( + key: keys, + initialValue: { + 'transaction_code': widget.faas.transCode, + 'arp_td': widget.faas.tdn, + 'pin': widget.faas.pin, + 'owner': widget.faas.owner, + 'address': widget.faas.address, + 'tel_no': widget.faas.telno, + 'tin': widget.faas.tin, + 'benificiary': widget.faas.adminUser, + 'benificiary_telno': widget.faas.adminTelno, + 'benificiary_address': widget.faas.adminAddress, + 'benificaiary_tin': widget.faas.adminTin, + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + 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), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "ARP No. / TD No.", "", 'arp_td')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Pin", "", 'pin')), + ], + ), + customTextField("Owner", "", 'owner'), + customTextField("Address", "", 'address'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: + customTextField("Tel No.", "", 'tel_no'), + ), + 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( + "Administrator / Benificial User", + "", + 'benificiary'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "TIN", "", 'benificiary_tin')) + ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Address", "", 'benificiary_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.", "", 'benificiary_telno')) + ]), + const SizedBox(height: 25), + SizedBox( + width: MediaQuery.of(context).size.width, + child: CustomButton( + icon: const Icon(Icons.chevron_right, + color: Colors.white), + onPressed: () { + var property_info = PropertyInfo( + id: widget.faas.id, + transCode: keys + .currentState!.value['transaction_code'] + .toString(), + tdn: keys.currentState!.value['arp_td'], + pin: keys.currentState!.value['pin'], + owner: keys.currentState!.value['owner'], + address: + keys.currentState!.value['address'], + telno: keys.currentState!.value['tel_no'], + tin: keys.currentState!.value['tin'], + adminUser: + keys.currentState!.value['benificiary'], + adminAddress: keys.currentState! + .value['benificiary_address'], + adminTin: keys + .currentState!.value['benificiary_tin'], + adminTelno: keys.currentState! + .value['benificiary_telno'], + assessedById: '1', + assessedByName: 'Cyril', + dateModified: DateTime.now(), + dateCreated: DateTime.now()); + + context.read().add( + UpdatPropertyInfo( + property_info: property_info)); + + widget.NextBtn(); + }, + ), + ), + ])), + ], + ), + ), + ); + } + if (state is PropertyInfoErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadPropertyInfo()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Building/edit_building/structural_materials.dart b/lib/screens/passo/Building/edit_building/structural_materials.dart new file mode 100644 index 0000000..5d37368 --- /dev/null +++ b/lib/screens/passo/Building/edit_building/structural_materials.dart @@ -0,0 +1,416 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:multiselect/multiselect.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/structural_material/structural_material_bloc.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class StructuralMaterialsPageEdit extends StatefulWidget { + // final VoidCallback onPutStructuralMaterials; + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + StructuralMaterialsPageEdit(this.tempId, this.NextBtn, this.PrevBtn); + + @override + _StructuralMaterialsPageEdit createState() => _StructuralMaterialsPageEdit(); +} + +class _StructuralMaterialsPageEdit extends State { + bool foundationOthers = false; + bool columOthers = false; + bool beamsOthers = false; + bool tfOthers = false; + bool roofOthers = false; + bool flooringOthers = false; + bool wpOthers = false; + List foundation = []; + List column = []; + List beam = []; + List truss_framing = []; + List roof = []; + List flooring = []; + List walls = []; + + List selectedColumnValues = []; + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + if (state is StructuralMaterialsLoaded) { + setState(() { + foundation = state.structure.foundation!.split(','); + column = state.structure.columns!.split(','); + beam = state.structure.beams!.split(','); + truss_framing = state.structure.trussFraming!.split(','); + roof = state.structure.roof!.split(','); + flooring = state.structure.flooring!.split(','); + walls = state.structure.walls!.split(','); + // Update other local state variables here if needed + }); + } + // TODO: implement listener + }, builder: (context, state) { + if (state is StructuralMaterialsLoaded) { + return Expanded( + child: SingleChildScrollView( + padding: const EdgeInsets.all(30.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('STRUCTURAL MATERIALS', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'FOUNDATION', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: foundationOthers, + onChanged: (bool? value) { + setState(() { + foundationOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: foundationOthers, + child: customTextField( + "Enter other foundation", "", "other_foundation"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + foundation = x; + }); + }, + options: const ['Reinforced Concrete', 'Plain Concrete'], + selectedValues: foundation, + whenEmpty: 'Select Foundations', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'COLUMNS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: columOthers, + onChanged: (bool? value) { + setState(() { + columOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: columOthers, + child: customTextField( + "Enter other columns", "", "other_column"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + column = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: column, + whenEmpty: 'Select Column/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'BEAMS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: beamsOthers, + onChanged: (bool? value) { + setState(() { + beamsOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: beamsOthers, + child: + customTextField("Enter other beam/s", "", "other_beam"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + beam = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: beam, + whenEmpty: 'Select Beam/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'TRUSS FRAMING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: tfOthers, + onChanged: (bool? value) { + setState(() { + tfOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: tfOthers, + child: customTextField( + "Enter other truss framing/s", "", "other_tf"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + truss_framing = x; + }); + }, + options: const ['Steel', 'Wood'], + selectedValues: truss_framing, + whenEmpty: 'Select Truss Framing/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'ROOF', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: roofOthers, + onChanged: (bool? value) { + setState(() { + roofOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: roofOthers, + child: + customTextField("Enter other roof/s", "", "other_roof"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + roof = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Tiles', + 'G.I Sheet', + 'Aluminum', + 'Asbestos', + 'Long Span', + 'Concrete Desk', + 'Nipa/Anahaw/Cogon' + ], + selectedValues: roof, + whenEmpty: 'Select Roof/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'FLOORING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: flooringOthers, + onChanged: (bool? value) { + setState(() { + flooringOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: flooringOthers, + child: customTextField( + "Enter other flooring/s", "", "other_flooring"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + flooring = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Cement', + 'Marble', + 'Wood', + 'Tiles' + ], + selectedValues: flooring, + whenEmpty: 'Select Flooring/s', + ), + ), + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + 'WALLS & PARTITIONS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: wpOthers, + onChanged: (bool? value) { + setState(() { + wpOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: wpOthers, + child: customTextField( + "Enter other walls & partition/s", "", "other_wp"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + walls = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Concrete', + 'Wood', + 'CHIB', + 'G.I Sheet', + 'Build-a-wall', + 'Sawali', + 'Bamboo' + ], + selectedValues: walls, + whenEmpty: 'Select Walls & Partition/s', + ), + ), + ), + 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: () { + { + var strucMaterials = StructureMaterialsII( + id: widget.tempId, + foundation: foundation, + columns: column, + beams: beam, + trussFraming: truss_framing, + roof: roof, + flooring: flooring, + walls: walls, + others: ["Others"]); + context.read() + ..add(UpdateStrucMaterials(data: strucMaterials)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + )); + } + if (state is StructuralMaterialsErrorState) { + return Text(state.error); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/add_land.dart b/lib/screens/passo/Land/add_land.dart new file mode 100644 index 0000000..4b7e3aa --- /dev/null +++ b/lib/screens/passo/Land/add_land.dart @@ -0,0 +1,120 @@ +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/screens/passo/Land/add_land/land_appraisal.dart'; +import 'package:unit2/screens/passo/Land/add_land/location_and_boundaries.dart'; +import 'package:unit2/screens/passo/Land/add_land/other_improvements.dart'; +import 'package:unit2/screens/passo/Land/add_land/property_assessment.dart'; +import 'package:unit2/screens/passo/Land/add_land/property_assessment_cont.dart'; +import 'package:unit2/screens/passo/Land/add_land/property_owner_info.dart'; +import 'package:unit2/screens/passo/Land/add_land/value_adjustments.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +GlobalKey landKey = GlobalKey(); + +class AddLand extends StatefulWidget { + @override + _AddLand createState() => _AddLand(); +} + +class _AddLand 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: FormBuilder( + key: landKey, + + // enabled: false, + onChanged: () { + landKey.currentState?.save(); + + print(landKey.currentState?.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + 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 LandPropertyOwnerInfo(NextBtn); + case 1: + return LandLocationAndBoundaries(PrevBtn, NextBtn); + case 2: + return LandAppraisal(PrevBtn, NextBtn); + case 3: + return OtherImprovementPage(PrevBtn, NextBtn); + case 4: + return ValueAdjustmentPage(PrevBtn, NextBtn); + case 5: + return LandPropertyAssessmentPage(PrevBtn, NextBtn); + case 6: + return LandSignatories(onSAveAll); + + default: + return LandPropertyOwnerInfo(NextBtn); + } + } +} diff --git a/lib/screens/passo/Land/add_land/AddLandAppraisal.dart b/lib/screens/passo/Land/add_land/AddLandAppraisal.dart new file mode 100644 index 0000000..6e70768 --- /dev/null +++ b/lib/screens/passo/Land/add_land/AddLandAppraisal.dart @@ -0,0 +1,415 @@ +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/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:unit2/model/passo/land_subclassification.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class AddLandAppraisalModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddLandAppraisalModal createState() => _AddLandAppraisalModal(); +} + +class _AddLandAppraisalModal 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 ShowAddLandAppraisalScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandClassificationLoaded) { + final classification = state.land_classification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandSubClassificationLoaded) { + final subclassification = state.land_subclassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalityLoaded) { + return FormBuilder( + key: appraisalLandKey, + onChanged: () { + appraisalLandKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 800, + 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.municipality + .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( + classCode: + classCode!, + cityCode: + selectedCityCode!)); // 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( + classCode: + selectedClassCode!, + cityCode: + cityCode)); // 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')); + var land_appraisal = LandAppr( + landapprDetailsId: + tempID.getInt( + 'landid')! - + 1, + classification: + _classDesc, + subClass: _subClassDesc, + area: _areaValue + .toString(), + unitValue: _unitBase + .toString(), + baseMarketval: + _totalMarketValue( + _unitBase, + _areaValue) + .toString()); + + context + .read< + LandAppraisalBloc>() + .add(AddLandAppraisal( + land_appr: + land_appraisal)); + }, + 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< + LandAppraisalBloc>() + .add( + const LoadLandAppraisal()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ))); + } + if (state is MunicipalityErrorState) { + return Text(state.error); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandAppraisalErrorState) { + return Text(state.error); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart new file mode 100644 index 0000000..64a53b6 --- /dev/null +++ b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart @@ -0,0 +1,467 @@ +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/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_road/type_of_road_bloc.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/model/passo/type_of_location.dart'; +import 'package:unit2/model/passo/type_of_road.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +class AddLandValueAdjustmentModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddLandValueAdjustmentModal createState() => _AddLandValueAdjustmentModal(); +} + +class _AddLandValueAdjustmentModal 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 BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddLandValueAdjustmentsScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandAppraisalLoaded) { + final land_appr = state.land_appr; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfRoadLoaded) { + final roadType = state.road_type; + 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( + 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.loc_type + .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.loc_type + .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')); + var adjustments = ValueAdjustments( + 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()); + + context + .read< + LandValueAdjustmentsBloc>() + .add( + AddLandValueAdjustments( + val_adj: + adjustments)); + }, + 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< + LandValueAdjustmentsBloc>() + .add( + const LoadLandValueAdjustments()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + + return Container(); + }); + } + if (state is LandValueAdjustmentsErrorState) { + return Text(state.error); + } + return Container( + child: Text("Land Value Adjustment"), + ); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart b/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart new file mode 100644 index 0000000..c89300d --- /dev/null +++ b/lib/screens/passo/Land/add_land/AddOtherImprovementModal.dart @@ -0,0 +1,344 @@ +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/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_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'; + +class AddOtherImprovementModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddOtherImprovementModal createState() => _AddOtherImprovementModal(); +} + +class _AddOtherImprovementModal 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 ShowAddOtherImprovementScreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandTreesImprovementsLoaded) { + final trees = state.trees_imp; + 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.trees_imp + .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')); + var improvement = OtherImprovements( + 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); + + context.read().add( + AddOtherImprovement( + other_imp: improvement)); + }, + 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 LoadOtherImprovement()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + + return Container(); + }); + } + if (state is OtherImprovementErrorState) { + return Text(state.error); + } + return Container( + child: Text("Other Improvement"), + ); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart b/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart new file mode 100644 index 0000000..35bf7f6 --- /dev/null +++ b/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart @@ -0,0 +1,342 @@ +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/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +class AddPropertyAssessmentModal extends StatefulWidget { + // final List unit; + // final List options; + // final int tempId; + + // AddLandAppraisalModal(this.unit, this.options, this.tempId); + + @override + _AddPropertyAssessmentModal createState() => _AddPropertyAssessmentModal(); +} + +class _AddPropertyAssessmentModal 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; + break; + case "Agricultural": + return _unitValue * 0.40; + break; + case "Commercial": + return _unitValue * 0.50; + break; + case "Industrial": + return _unitValue * 0.50; + break; + case "Mineral": + return _unitValue * 0.50; + break; + case "Timberland": + return _unitValue * 0.20; + break; + 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 ShowAddLandPropertyAssessmentScreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandValueAdjustmentsLoaded) { + final assessment = state.val_adj; + 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.val_adj + .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); + var assessment = LandPropertyAssessment( + landapprDetailsId: + tempID.getInt('landid')! - 1, + actualUse: _actualUse, + marketval: _unitValue.toString(), + assessmentLevel: _assessmentLevel, + assessedValue: + calculateAssessmentValue() + .toString(), + totalMarketval: '0', + totalAssessedval: '0'); + + context + .read() + .add(AddLandPropertyAssessment( + assessment: assessment)); + }, + 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"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + + return Container(); + }); + } + if (state is LandPropertyAssessmentErrorState) { + return Text(state.error); + } + return Container( + child: Text("Property Assessment"), + ); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/land_appraisal.dart b/lib/screens/passo/Land/add_land/land_appraisal.dart new file mode 100644 index 0000000..fa0ca77 --- /dev/null +++ b/lib/screens/passo/Land/add_land/land_appraisal.dart @@ -0,0 +1,248 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.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/passo/Land/add_land/AddLandAppraisal.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class LandAppraisal extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandAppraisal(this.PrevBtn, this.NextBtn); + @override + _LandAppraisal createState() => _LandAppraisal(); +} + +class _LandAppraisal extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context.read().add(DeleteLandAppraisal(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandAppraisalLoaded) { + 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(ShowLandAppraisal()); + }, + 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('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.land_appr.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.classification!)), + DataCell(Text(dataRow.subClass!)), + DataCell(Text(dataRow.area!)), + DataCell(Text( + ((double.parse(dataRow.unitValue!))) + .toString())), + DataCell(Text( + ((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: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).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 LandAppraisalDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add(const LoadLandAppraisal()); + }); + }); + } + } + if (state is ShowAddLandAppraisalScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD LAND APPRAISAL', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [Expanded(child: AddLandAppraisalModal())], + ), + ), + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/location_and_boundaries.dart b/lib/screens/passo/Land/add_land/location_and_boundaries.dart new file mode 100644 index 0000000..f27db38 --- /dev/null +++ b/lib/screens/passo/Land/add_land/location_and_boundaries.dart @@ -0,0 +1,140 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; +import 'package:unit2/model/passo/land_property_boundaries.dart'; +import 'package:unit2/model/passo/land_property_loc.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class LandLocationAndBoundaries extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandLocationAndBoundaries(this.PrevBtn, this.NextBtn); + @override + _LandLocationAndBoundaries createState() => _LandLocationAndBoundaries(); +} + +class _LandLocationAndBoundaries extends State { + @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 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: () { + var boundaries = LandPropertyBoundaries( + id: 3, + north: landKey.currentState?.value['north'], + east: landKey.currentState?.value['east'], + west: landKey.currentState?.value['west'], + south: landKey.currentState?.value['south'], + ); + var location = LandPropertyLoc( + id: 3, + street: landKey.currentState?.value['street'], + barangay: landKey.currentState?.value['brgy'], + municipality: + landKey.currentState?.value['municipality'], + province: landKey.currentState?.value['province'], + ); + + 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 new file mode 100644 index 0000000..295e1b7 --- /dev/null +++ b/lib/screens/passo/Land/add_land/other_improvements.dart @@ -0,0 +1,263 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.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'; + +class OtherImprovementPage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + OtherImprovementPage(this.PrevBtn, this.NextBtn); + @override + _OtherImprovementPage createState() => _OtherImprovementPage(); +} + +class _OtherImprovementPage extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteOtherImprovement(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + final state = context.watch().state; + if (state is OtherImprovementLoaded) { + 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.other_imp.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.kindsOfTrees!)), + DataCell(Text(dataRow.subclassAge!)), + DataCell(Text(dataRow.fruitBearing! + ? "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: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).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 OtherImprovementDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadOtherImprovement()); + }); + }); + } + } + if (state is ShowAddOtherImprovementScreen) { + 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: [Expanded(child: AddOtherImprovementModal())], + ), + ), + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/property_assessment.dart b/lib/screens/passo/Land/add_land/property_assessment.dart new file mode 100644 index 0000000..19f43bf --- /dev/null +++ b/lib/screens/passo/Land/add_land/property_assessment.dart @@ -0,0 +1,243 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class LandPropertyAssessmentPage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + LandPropertyAssessmentPage(this.PrevBtn, this.NextBtn); + @override + _LandPropertyAssessmentPage createState() => _LandPropertyAssessmentPage(); +} + +class _LandPropertyAssessmentPage 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 BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, 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.assessment.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: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).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 ShowAddLandPropertyAssessmentScreen) { + 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: AddPropertyAssessmentModal())], + ), + ), + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/add_land/property_assessment_cont.dart b/lib/screens/passo/Land/add_land/property_assessment_cont.dart new file mode 100644 index 0000000..ad1f710 --- /dev/null +++ b/lib/screens/passo/Land/add_land/property_assessment_cont.dart @@ -0,0 +1,541 @@ +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:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; +import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; +import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; +import 'package:unit2/model/passo/land_ext.dart'; +import 'package:unit2/model/passo/memoranda.dart'; +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +class LandSignatories extends StatefulWidget { + Function onSAve; + LandSignatories(this.onSAve); + + @override + _LandSignatories createState() => _LandSignatories(); +} + +class _LandSignatories extends State { + bool isTaxable = false; + bool isExempt = false; + final focus = FocusNode(); + String _memoranda = ""; + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandExtLoaded) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + 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: 100, + child: SearchField( + suggestions: state.memorada + .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, + 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([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + 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 + + ' ' + + landKey + .currentState! + .value['appraised_by_land'] + .middlename + + ' ' + + landKey.currentState! + .value['appraised_by_land'].lastname, + appraisedbyDate: landKey + .currentState!.value['app_date_land'], + recommendapprName: landKey + .currentState! + .value['rec_approval_land'] + .firstname + + ' ' + + 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['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'], + dateReceived: landKey.currentState!.value['date_received_land'], + entryDateAssessment: landKey.currentState!.value['date_of_entry_land'], + entryDateBy: landKey.currentState!.value['by_land']); + + context.read() + ..add(UpdateLandExt(landext: ext)); + 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, + ), + ], + )); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/passo/Land/add_land/property_owner_info.dart b/lib/screens/passo/Land/add_land/property_owner_info.dart new file mode 100644 index 0000000..ec1391f --- /dev/null +++ b/lib/screens/passo/Land/add_land/property_owner_info.dart @@ -0,0 +1,210 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; +import 'package:unit2/model/passo/land_property_owner.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class LandPropertyOwnerInfo extends StatefulWidget { + Function NextBtn; + LandPropertyOwnerInfo(this.NextBtn); + @override + _LandPropertyOwnerInfo createState() => _LandPropertyOwnerInfo(); +} + +class _LandPropertyOwnerInfo 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( + // width: double.infinity, + // height: 50, + // child: ElevatedButton( + // style: secondaryBtnStyle(const Color(0xffd92828), + // Color.fromARGB(0, 253, 252, 252), Colors.white54), + // child: const Text( + // "SUBMIT & PROCEED", + // style: TextStyle( + // color: Color.fromARGB(239, 255, 255, 255), + // fontWeight: FontWeight.w700), + // ), + // onPressed: () { + // // formKey.currentState?.save(); + // // // var faas = PropertyInfo( + // // // id: 1, + // // // transCode: formKey + // // // .currentState!.value['transaction_code'] + // // // .toString(), + // // // tdn: formKey.currentState!.value['arp_td'], + // // // pin: formKey.currentState!.value['pin'], + // // // owner: formKey.currentState!.value['owner'], + // // // address: formKey.currentState!.value['address'], + // // // telno: formKey.currentState!.value['tel_no'], + // // // tin: formKey.currentState!.value['tin'], + // // // adminUser: formKey.currentState!.value['benificiary'], + // // // adminAddress: formKey + // // // .currentState!.value['benificiary_address'], + // // // adminTin: + // // // formKey.currentState!.value['benificiary_tin'], + // // // adminTelno: + // // // formKey.currentState!.value['benificiary_telno']); + // // // context.read().add(AddFaas(faas: faas)); + // // // _loadTempId(); + // // _pageController.nextPage( + // // duration: _kDuration, curve: _kCurve); + // }), + // ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_right, color: Colors.white), + onPressed: () { + var land = LandPropertyOwner( + id: 1, + transCode: landKey + .currentState!.value['transaction_code'] + .toString(), + tdn: landKey.currentState!.value['td_no'], + cloaNo: landKey.currentState!.value['cloa_no'], + dated: landKey.currentState!.value['dated'], + assessedById: "1", + assessedByName: "cyril", + dateCreated: landKey.currentState!.value['dated'], + dateModified: landKey.currentState!.value['dated'], + pin: landKey.currentState!.value['pin'], + surveyNo: landKey.currentState!.value['survey_no'], + lotNo: landKey.currentState!.value['lot_no'], + blkNo: landKey.currentState!.value['blk'], + owner: landKey.currentState!.value['owner'], + address: landKey.currentState!.value['address'], + telno: landKey.currentState!.value['tel_no'], + tin: landKey.currentState!.value['tin'], + adminUser: landKey.currentState!.value['admin'], + adminAddress: + landKey.currentState!.value['admin_address'], + adminTin: landKey.currentState!.value['admin_tin'], + // faasType: "LAND", + adminTelno: landKey.currentState!.value['admin_telno']); + + context + .read() + .add(AddPropertyOwnerLand(land: land)); + + widget.NextBtn(); + }, + ) + ], + ), + const SizedBox( + height: 20, + ), + ]), + )); + } +} diff --git a/lib/screens/passo/Land/add_land/value_adjustments.dart b/lib/screens/passo/Land/add_land/value_adjustments.dart new file mode 100644 index 0000000..35dbaf2 --- /dev/null +++ b/lib/screens/passo/Land/add_land/value_adjustments.dart @@ -0,0 +1,246 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; + +class ValueAdjustmentPage extends StatefulWidget { + Function PrevBtn; + Function NextBtn; + ValueAdjustmentPage(this.PrevBtn, this.NextBtn); + @override + _ValueAdjustmentPage createState() => _ValueAdjustmentPage(); +} + +class _ValueAdjustmentPage extends State { + // double _totalMarketValue(items) { + // double total = 0; + // items.forEach((row) { + // total += double.parse(row); + // }); + // return total; + // } + + void deleteItem(int itemId) { + context + .read() + .add(DeleteLandValueAdjustments(id: itemId)); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandValueAdjustmentsLoaded) { + 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(ShowLandValueAdjustments()); + }, + 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.val_adj.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: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).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 LandValueAdjustmentsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandValueAdjustments()); + }); + }); + } + } + if (state is ShowAddLandValueAdjustmentsScreen) { + 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: AddLandValueAdjustmentModal())], + ), + ), + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Test Envi/multi_dropdown.dart b/lib/screens/passo/Test Envi/multi_dropdown.dart new file mode 100644 index 0000000..61a88e4 --- /dev/null +++ b/lib/screens/passo/Test Envi/multi_dropdown.dart @@ -0,0 +1,94 @@ +import 'package:flutter/material.dart'; +import 'package:multiselect/multiselect.dart'; + +class Multi_Select extends StatelessWidget { + const Multi_Select(); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + brightness: Brightness.light, + primarySwatch: Colors.red, + primaryColor: Colors.red, + primaryColorLight: Colors.redAccent, + inputDecorationTheme: const InputDecorationTheme( + filled: true, + fillColor: Color(0xFFEEEEEE), + ), + ), + themeMode: ThemeMode.dark, + darkTheme: ThemeData( + brightness: Brightness.dark, + primarySwatch: Colors.red, + primaryColor: Colors.red, + primaryColorLight: Colors.redAccent, + appBarTheme: const AppBarTheme(backgroundColor: Color(0xFF1b1926)), + snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.red), + canvasColor: const Color(0xFF272537), + dialogBackgroundColor: const Color(0xFF343346), + inputDecorationTheme: const InputDecorationTheme( + filled: true, + fillColor: Color(0xFF383849), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.all( + Radius.circular(35.0), + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.all( + Radius.circular(35.0), + ), + ), + ), + ), + home: const _Multi_Select(title: 'Flutter Demo Home Page'), + ); + } +} + +class _Multi_Select extends StatefulWidget { + const _Multi_Select({required this.title}); + final String title; + + @override + State<_Multi_Select> createState() => _Multi_SelectState(); +} + +class _Multi_SelectState extends State<_Multi_Select> { + int _counter = 0; + + void _incrementCounter() { + setState(() { + _counter++; + }); + } + + List selected = []; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: const EdgeInsets.all(20.0), + // DropDownMultiSelect comes from multiselect + child: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.white), + onChanged: (List x) { + setState(() { + selected = x; + }); + }, + options: ['a', 'b', 'c', 'd'], + selectedValues: selected, + whenEmpty: 'Select Something', + ), + ), + )); + } +} diff --git a/lib/screens/passo/Test Envi/speed_dial.dart b/lib/screens/passo/Test Envi/speed_dial.dart new file mode 100644 index 0000000..7d4c1c9 --- /dev/null +++ b/lib/screens/passo/Test Envi/speed_dial.dart @@ -0,0 +1,529 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; + +void main() => runApp(const SpeedDial()); + +class SpeedDials extends StatefulWidget { + const SpeedDials({Key? key}) : super(key: key); + @override + _SpeedDials createState() => _SpeedDials(); +} + +class _SpeedDials extends State { + var theme = ValueNotifier(ThemeMode.dark); + + @override + Widget build(BuildContext context) { + const appTitle = 'Flutter Speed Dial Example'; + return ValueListenableBuilder( + valueListenable: theme, + builder: (context, value, child) => MaterialApp( + title: appTitle, + home: MyHomePage(theme: theme), + debugShowCheckedModeBanner: false, + theme: ThemeData( + brightness: Brightness.light, + primaryColor: Colors.blue, + ), + darkTheme: ThemeData( + brightness: Brightness.dark, + primaryColor: Colors.lightBlue[900], + ), + themeMode: value, + )); + } +} + +class MyHomePage extends StatefulWidget { + final ValueNotifier theme; + const MyHomePage({Key? key, required this.theme}) : super(key: key); + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State with TickerProviderStateMixin { + var renderOverlay = true; + var visible = true; + var switchLabelPosition = false; + var extend = false; + var mini = false; + var rmicons = false; + var customDialRoot = false; + var closeManually = false; + var useRAnimation = true; + var isDialOpen = ValueNotifier(false); + var speedDialDirection = SpeedDialDirection.up; + var buttonSize = const Size(56.0, 56.0); + var childrenButtonSize = const Size(56.0, 56.0); + var selectedfABLocation = FloatingActionButtonLocation.endDocked; + var items = [ + FloatingActionButtonLocation.startFloat, + FloatingActionButtonLocation.startDocked, + FloatingActionButtonLocation.centerFloat, + FloatingActionButtonLocation.endFloat, + FloatingActionButtonLocation.endDocked, + FloatingActionButtonLocation.startTop, + FloatingActionButtonLocation.centerTop, + FloatingActionButtonLocation.endTop, + ]; + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async { + if (isDialOpen.value) { + isDialOpen.value = false; + return false; + } + return true; + }, + child: Scaffold( + appBar: AppBar( + title: const Text("Flutter Speed Dial Example"), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(16), + physics: const BouncingScrollPhysics(), + child: Center( + child: Container( + constraints: const BoxConstraints(maxWidth: 800), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric( + vertical: 6, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("SpeedDial Location", + style: Theme.of(context).textTheme.bodyLarge), + const SizedBox(height: 10), + Container( + decoration: BoxDecoration( + color: Theme.of(context).brightness == + Brightness.dark + ? Colors.grey[800] + : Colors.grey[200], + borderRadius: BorderRadius.circular(10)), + child: DropdownButton( + value: selectedfABLocation, + isExpanded: true, + icon: const Icon(Icons.arrow_drop_down), + iconSize: 20, + underline: const SizedBox(), + onChanged: (fABLocation) => setState( + () => selectedfABLocation = fABLocation!), + selectedItemBuilder: (BuildContext context) { + return items.map((item) { + return Align( + alignment: Alignment.centerLeft, + child: Container( + padding: const EdgeInsets.symmetric( + vertical: 4, horizontal: 10), + child: Text(item.value))); + }).toList(); + }, + items: items.map((item) { + return DropdownMenuItem< + FloatingActionButtonLocation>( + value: item, + child: Text( + item.value, + ), + ); + }).toList(), + ), + ), + ], + ), + ), + Container( + padding: const EdgeInsets.symmetric( + vertical: 6, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("SpeedDial Direction", + style: Theme.of(context).textTheme.bodyLarge), + const SizedBox(height: 10), + Container( + decoration: BoxDecoration( + color: Theme.of(context).brightness == + Brightness.dark + ? Colors.grey[800] + : Colors.grey[200], + borderRadius: BorderRadius.circular(10)), + child: DropdownButton( + value: speedDialDirection, + isExpanded: true, + icon: const Icon(Icons.arrow_drop_down), + iconSize: 20, + underline: const SizedBox(), + onChanged: (sdo) { + setState(() { + speedDialDirection = sdo!; + selectedfABLocation = (sdo.isUp && + selectedfABLocation.value + .contains("Top")) || + (sdo.isLeft && + selectedfABLocation.value + .contains("start")) + ? FloatingActionButtonLocation.endDocked + : sdo.isDown && + !selectedfABLocation.value + .contains("Top") + ? FloatingActionButtonLocation.endTop + : sdo.isRight && + selectedfABLocation.value + .contains("end") + ? FloatingActionButtonLocation + .startDocked + : selectedfABLocation; + }); + }, + selectedItemBuilder: (BuildContext context) { + return SpeedDialDirection.values + .toList() + .map((item) { + return Container( + padding: const EdgeInsets.symmetric( + vertical: 4, horizontal: 10), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + describeEnum(item).toUpperCase())), + ); + }).toList(); + }, + items: SpeedDialDirection.values + .toList() + .map((item) { + return DropdownMenuItem( + value: item, + child: Text(describeEnum(item).toUpperCase()), + ); + }).toList(), + ), + ), + ], + ), + ), + if (!customDialRoot) + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: extend, + title: const Text("Extend Speed Dial"), + onChanged: (val) { + setState(() { + extend = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: visible, + title: const Text("Visible"), + onChanged: (val) { + setState(() { + visible = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: mini, + title: const Text("Mini"), + onChanged: (val) { + setState(() { + mini = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: customDialRoot, + title: const Text("Custom dialRoot"), + onChanged: (val) { + setState(() { + customDialRoot = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: renderOverlay, + title: const Text("Render Overlay"), + onChanged: (val) { + setState(() { + renderOverlay = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: closeManually, + title: const Text("Close Manually"), + onChanged: (val) { + setState(() { + closeManually = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: rmicons, + title: const Text("Remove Icons (for children)"), + onChanged: (val) { + setState(() { + rmicons = val; + }); + }), + if (!customDialRoot) + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: useRAnimation, + title: const Text("Use Rotation Animation"), + onChanged: (val) { + setState(() { + useRAnimation = val; + }); + }), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + value: switchLabelPosition, + title: const Text("Switch Label Position"), + onChanged: (val) { + setState(() { + switchLabelPosition = val; + if (val) { + if ((selectedfABLocation.value.contains("end") || + selectedfABLocation.value + .toLowerCase() + .contains("top")) && + speedDialDirection.isUp) { + selectedfABLocation = + FloatingActionButtonLocation.startDocked; + } else if ((selectedfABLocation.value + .contains("end") || + !selectedfABLocation.value + .toLowerCase() + .contains("top")) && + speedDialDirection.isDown) { + selectedfABLocation = + FloatingActionButtonLocation.startTop; + } + } + }); + }), + const Text("Button Size"), + Slider( + value: buttonSize.width, + min: 50, + max: 500, + label: "Button Size", + onChanged: (val) { + setState(() { + buttonSize = Size(val, val); + }); + }, + ), + const Text("Children Button Size"), + Slider( + value: childrenButtonSize.height, + min: 50, + max: 500, + onChanged: (val) { + setState(() { + childrenButtonSize = Size(val, val); + }); + }, + ), + Container( + padding: const EdgeInsets.symmetric( + vertical: 6, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Navigation", + style: Theme.of(context).textTheme.bodyLarge), + const SizedBox(height: 10), + ElevatedButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => + MyHomePage(theme: widget.theme), + ), + ); + }, + child: const Text("Push Duplicate Page")), + ], + ), + ), + ], + ), + ), + )), + floatingActionButtonLocation: selectedfABLocation, + floatingActionButton: SpeedDial( + // animatedIcon: AnimatedIcons.menu_close, + // animatedIconTheme: IconThemeData(size: 22.0), + // / This is ignored if animatedIcon is non null + // child: Text("open"), + // activeChild: Text("close"), + icon: Icons.add, + activeIcon: Icons.close, + spacing: 3, + mini: mini, + openCloseDial: isDialOpen, + childPadding: const EdgeInsets.all(5), + spaceBetweenChildren: 4, + dialRoot: customDialRoot + ? (ctx, open, toggleChildren) { + return ElevatedButton( + onPressed: toggleChildren, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue[900], + padding: const EdgeInsets.symmetric( + horizontal: 22, vertical: 18), + ), + child: const Text( + "Custom Dial Root", + style: TextStyle(fontSize: 17), + ), + ); + } + : null, + buttonSize: + buttonSize, // it's the SpeedDial size which defaults to 56 itself + // iconTheme: IconThemeData(size: 22), + label: extend + ? const Text("Open") + : null, // The label of the main button. + /// The active label of the main button, Defaults to label if not specified. + activeLabel: extend ? const Text("Close") : null, + + /// Transition Builder between label and activeLabel, defaults to FadeTransition. + // labelTransitionBuilder: (widget, animation) => ScaleTransition(scale: animation,child: widget), + /// The below button size defaults to 56 itself, its the SpeedDial childrens size + childrenButtonSize: childrenButtonSize, + visible: visible, + direction: speedDialDirection, + switchLabelPosition: switchLabelPosition, + + /// If true user is forced to close dial manually + closeManually: closeManually, + + /// If false, backgroundOverlay will not be rendered. + renderOverlay: renderOverlay, + // overlayColor: Colors.black, + // overlayOpacity: 0.5, + onOpen: () => debugPrint('OPENING DIAL'), + onClose: () => debugPrint('DIAL CLOSED'), + useRotationAnimation: useRAnimation, + tooltip: 'Open Speed Dial', + heroTag: 'speed-dial-hero-tag', + // foregroundColor: Colors.black, + // backgroundColor: Colors.white, + // activeForegroundColor: Colors.red, + // activeBackgroundColor: Colors.blue, + elevation: 8.0, + animationCurve: Curves.elasticInOut, + isOpenOnStart: false, + shape: customDialRoot + ? const RoundedRectangleBorder() + : const StadiumBorder(), + // childMargin: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + children: [ + SpeedDialChild( + child: !rmicons ? const Icon(Icons.accessibility) : null, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: 'First', + onTap: () => setState(() => rmicons = !rmicons), + onLongPress: () => debugPrint('FIRST CHILD LONG PRESS'), + ), + SpeedDialChild( + child: !rmicons ? const Icon(Icons.brush) : null, + backgroundColor: Colors.deepOrange, + foregroundColor: Colors.white, + label: 'Second', + onTap: () => debugPrint('SECOND CHILD'), + ), + SpeedDialChild( + child: !rmicons ? const Icon(Icons.margin) : null, + backgroundColor: Colors.indigo, + foregroundColor: Colors.white, + label: 'Show Snackbar', + visible: true, + onTap: () => ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text(("Third Child Pressed")))), + onLongPress: () => debugPrint('THIRD CHILD LONG PRESS'), + ), + ], + ), + bottomNavigationBar: BottomAppBar( + shape: const CircularNotchedRectangle(), + notchMargin: 8.0, + child: Row( + mainAxisAlignment: selectedfABLocation == + FloatingActionButtonLocation.startDocked + ? MainAxisAlignment.end + : selectedfABLocation == FloatingActionButtonLocation.endDocked + ? MainAxisAlignment.start + : MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + IconButton( + icon: const Icon(Icons.nightlight_round), + tooltip: "Switch Theme", + onPressed: () => { + widget.theme.value = widget.theme.value.index == 2 + ? ThemeMode.light + : ThemeMode.dark + }, + ), + ValueListenableBuilder( + valueListenable: isDialOpen, + builder: (ctx, value, _) => IconButton( + icon: const Icon(Icons.open_in_browser), + tooltip: (!value ? "Open" : "Close") + (" Speed Dial"), + onPressed: () => {isDialOpen.value = !isDialOpen.value}, + )) + ], + ), + ), + ), + ); + } +} + +extension EnumExt on FloatingActionButtonLocation { + /// Get Value of The SpeedDialDirection Enum like Up, Down, etc. in String format + String get value => toString().split(".")[1]; +} diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart new file mode 100644 index 0000000..c2dcaeb --- /dev/null +++ b/lib/screens/passo/building_home.dart @@ -0,0 +1,406 @@ +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/passo/barangay/barangay_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/class_components/class_components_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/landref/landref_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/location/location_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/structural_material/structural_material_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_road/type_of_road_bloc.dart'; + +import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; + +import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; + +import 'package:unit2/bloc/user/user_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +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/error_state.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; + +import '../../model/passo/bldg_loc.dart'; + +class BuildingHome extends StatelessWidget { + const BuildingHome({super.key}); + + @override + Widget build(BuildContext context) { + int? profileId; + String? token; + Profile profile; + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.only(left: 24, right: 24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder(builder: (context, state) { + if (state is UserLoggedIn) { + profileId = state.userData!.user!.login!.user!.profileId; + token = state.userData!.user!.login!.token!; + profile = state.userData!.employeeInfo!.profile!; + return BlocConsumer( + listener: ( + context, + state, + ) { + if (state is PropertyInfoLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is PropertyInfoLoaded || + state is PropertyInfoErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is PropertyInfoLoaded) { + List propertyList = state.property_info; + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: propertyList.length, + itemBuilder: (BuildContext context, int index) { + return _listCard( + propertyList[index], context, index); + }, + ), + ), + ); + } + if (state is PropertyInfoErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadPropertyInfo()); + }, + ); + } + return Container(); + }, + ); + } + 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) => + PropertyInfoBloc()..add(LoadPropertyInfo()), + ), + BlocProvider( + create: (context) => + ClassComponentsBloc()..add(LoadClassComponents()), + ), + BlocProvider( + create: (context) => + UnitConstructBloc()..add(LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => + AdditionalItemBloc()..add(LoadAdditionalItems()), + ), + BlocProvider( + create: (context) => PropertyAppraisalBloc() + ..add(LoadPropertyAppraisal( + appraisal: PropertyAppraisal())), + ), + BlocProvider( + create: (context) => PropertyAssessmentBloc() + ..add(LoadPropertyAssessment())), + BlocProvider( + create: (context) => + SignatoriesBloc()..add(LoadSignatories())), + BlocProvider( + create: (context) => + MunicipalityBloc()..add(LoadMunicipality())), + BlocProvider( + create: (context) => + BarangayBloc()..add(LoadBarangay(id: '01'))), + BlocProvider( + create: (context) => + MemorandaBloc()..add(LoadMemoranda())), + ], child: AddBuilding()); + })); + }), + 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) => + LandPropertyOwnerInfoBloc()..add(LoadLand())), + BlocProvider( + create: (context) => LandClassificationBloc() + ..add(LoadLandClassification())), + BlocProvider( + create: (context) => LandSubClassificationBloc() + ..add(LoadLandSubClassification( + cityCode: "1", classCode: 1))), + BlocProvider( + create: (context) => + LandAppraisalBloc()..add(LoadLandAppraisal())), + BlocProvider( + create: (context) => + MunicipalityBloc()..add(LoadMunicipality())), + BlocProvider( + create: (context) => + BarangayBloc()..add(LoadBarangay(id: '01'))), + BlocProvider( + create: (context) => OtherImprovementsBloc() + ..add(LoadOtherImprovement())), + BlocProvider( + create: (context) => LandTreesImprovementsBloc() + ..add(LoadLandTreesImprovements())), + BlocProvider( + create: (context) => LandValueAdjustmentsBloc() + ..add(LoadLandValueAdjustments())), + BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(LoadTypeOfLocation())), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(LoadTypeOfRoad())), + BlocProvider( + create: (context) => LandPropertyAssessmentBloc() + ..add(LoadLandPropertyAssessment())), + BlocProvider( + create: (context) => + SignatoriesBloc()..add(LoadSignatories())), + BlocProvider( + create: (context) => LandExtBloc()..add(LoadLandExt())), + BlocProvider( + create: (context) => + MemorandaBloc()..add(LoadMemoranda())), + ], child: AddLand()); + })); + }, + ), + SpeedDialChild( + child: const Icon( + Icons.precision_manufacturing_rounded, + color: primary, + ), + 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())); + // }, + // ), + ]), + ); + } +} + +Card _listCard(PropertyInfo property_info, context, index) { + 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) => + PropertyInfoBloc()..add(LoadPropertyInfo()), + ), + BlocProvider( + create: (context) => + UnitConstructBloc()..add(LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => + ClassComponentsBloc()..add(LoadClassComponents()), + ), + BlocProvider( + create: (context) => + SignatoriesBloc()..add(LoadSignatories())), + BlocProvider( + create: (context) => LocationBloc() + ..add( + LoadLocation(bldgloc: BldgLoc(), id: property_info.id)), + ), + BlocProvider( + create: (context) => LandrefBloc() + ..add( + LoadLandref(landRef: LandRef(), id: property_info.id)), + ), + BlocProvider( + create: (context) => GeneralDescriptionBloc() + ..add(LoadGenDesc( + gendesc: GeneralDesc(), id: property_info.id)), + ), + BlocProvider( + create: (context) => AdditionalItemsEditBloc() + ..add(LoadAdditionalItemsEdit( + items: const [], + id: property_info.id)), + ), + BlocProvider( + create: (context) => PropertyAssessmentEditBloc() + ..add(LoadPropertyAssessmentEdit( + assessmentsEdit: PropertyAssessmentEdit(), + id: property_info.id)), + ), + BlocProvider( + create: (context) => PropertyAppraisalEditBloc() + ..add(LoadPropertyAppraisalEdit( + appraisalEdit: PropertyAppraisalEdit(), + id: property_info.id)), + ), + BlocProvider( + create: (context) => + MunicipalityBloc()..add(LoadMunicipality())), + BlocProvider( + create: (context) => + BarangayBloc()..add(LoadBarangay(id: '01'))), + BlocProvider( + create: (context) => MemorandaBloc()..add(LoadMemoranda())), + BlocProvider( + create: (context) => StructuralMaterialBloc() + ..add(LoadStructuralMaterial( + structure: StructureMaterials(), + id: property_info.id))), + ], + child: EditBuilding( + index: index, + faas: property_info, + title: 'Bldg & Structure Edit', + ), + ); + })); + }, + 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: 2, // Border width + ), + ), + child: Icon( + Icons.maps_home_work_rounded, + color: primary, // Icon color + ), + ), + SizedBox( + width: 20, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${property_info.owner}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + SizedBox(height: 5), + Text( + '${property_info.tdn}', + style: TextStyle( + fontSize: 13, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + IconButton(onPressed: () {}, icon: const Icon(Icons.chevron_right)), + ], + ), + ), + ), + ); +} diff --git a/lib/screens/passo/land_home .dart b/lib/screens/passo/land_home .dart new file mode 100644 index 0000000..4326133 --- /dev/null +++ b/lib/screens/passo/land_home .dart @@ -0,0 +1,406 @@ +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/passo/barangay/barangay_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/class_components/class_components_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/landref/landref_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/location/location_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/structural_material/structural_material_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_location/type_of_location_bloc.dart'; +import 'package:unit2/bloc/passo/land/type_of_road/type_of_road_bloc.dart'; + +import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; + +import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; + +import 'package:unit2/bloc/user/user_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_property_owner.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +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/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; + +import '../../model/passo/bldg_loc.dart'; + +class LandHome extends StatelessWidget { + const LandHome({super.key}); + + @override + Widget build(BuildContext context) { + int? profileId; + String? token; + Profile profile; + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.only(left: 24, right: 24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder(builder: (context, state) { + if (state is UserLoggedIn) { + profileId = state.userData!.user!.login!.user!.profileId; + token = state.userData!.user!.login!.token!; + profile = state.userData!.employeeInfo!.profile!; + return BlocConsumer( + listener: ( + context, + state, + ) { + if (state is LandLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandLoaded || state is LandErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is LandLoaded) { + List propertyList = state.land; + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: propertyList.length, + itemBuilder: (BuildContext context, int index) { + return _listCard( + propertyList[index], context, index); + }, + ), + ), + ); + } + if (state is LandErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLand()); + }, + ); + } + return Container(); + }, + ); + } + 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) => + PropertyInfoBloc()..add(LoadPropertyInfo()), + ), + BlocProvider( + create: (context) => + ClassComponentsBloc()..add(LoadClassComponents()), + ), + BlocProvider( + create: (context) => + UnitConstructBloc()..add(LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => + AdditionalItemBloc()..add(LoadAdditionalItems()), + ), + BlocProvider( + create: (context) => PropertyAppraisalBloc() + ..add(LoadPropertyAppraisal( + appraisal: PropertyAppraisal())), + ), + BlocProvider( + create: (context) => PropertyAssessmentBloc() + ..add(LoadPropertyAssessment())), + BlocProvider( + create: (context) => + SignatoriesBloc()..add(LoadSignatories())), + BlocProvider( + create: (context) => + MunicipalityBloc()..add(LoadMunicipality())), + BlocProvider( + create: (context) => + BarangayBloc()..add(LoadBarangay(id: '01'))), + BlocProvider( + create: (context) => + MemorandaBloc()..add(LoadMemoranda())), + ], child: AddBuilding()); + })); + }), + 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) => + LandPropertyOwnerInfoBloc()..add(LoadLand())), + BlocProvider( + create: (context) => LandClassificationBloc() + ..add(LoadLandClassification())), + BlocProvider( + create: (context) => LandSubClassificationBloc() + ..add(LoadLandSubClassification( + cityCode: "1", classCode: 1))), + BlocProvider( + create: (context) => + LandAppraisalBloc()..add(LoadLandAppraisal())), + BlocProvider( + create: (context) => + MunicipalityBloc()..add(LoadMunicipality())), + BlocProvider( + create: (context) => + BarangayBloc()..add(LoadBarangay(id: '01'))), + BlocProvider( + create: (context) => OtherImprovementsBloc() + ..add(LoadOtherImprovement())), + BlocProvider( + create: (context) => LandTreesImprovementsBloc() + ..add(LoadLandTreesImprovements())), + BlocProvider( + create: (context) => LandValueAdjustmentsBloc() + ..add(LoadLandValueAdjustments())), + BlocProvider( + create: (context) => + TypeOfLocationBloc()..add(LoadTypeOfLocation())), + BlocProvider( + create: (context) => + TypeOfRoadBloc()..add(LoadTypeOfRoad())), + BlocProvider( + create: (context) => LandPropertyAssessmentBloc() + ..add(LoadLandPropertyAssessment())), + BlocProvider( + create: (context) => + SignatoriesBloc()..add(LoadSignatories())), + BlocProvider( + create: (context) => LandExtBloc()..add(LoadLandExt())), + BlocProvider( + create: (context) => + MemorandaBloc()..add(LoadMemoranda())), + ], child: AddLand()); + })); + }, + ), + SpeedDialChild( + child: const Icon( + Icons.precision_manufacturing_rounded, + color: primary, + ), + 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())); + // }, + // ), + ]), + ); + } +} + +Card _listCard(LandPropertyOwner property_info, context, index) { + 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) => + // PropertyInfoBloc()..add(LoadPropertyInfo()), + // ), + // BlocProvider( + // create: (context) => + // UnitConstructBloc()..add(LoadUnitConstruct()), + // ), + // BlocProvider( + // create: (context) => + // ClassComponentsBloc()..add(LoadClassComponents()), + // ), + // BlocProvider( + // create: (context) => + // SignatoriesBloc()..add(LoadSignatories())), + // BlocProvider( + // create: (context) => LocationBloc() + // ..add( + // LoadLocation(bldgloc: BldgLoc(), id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => LandrefBloc() + // ..add( + // LoadLandref(landRef: LandRef(), id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => GeneralDescriptionBloc() + // ..add(LoadGenDesc( + // gendesc: GeneralDesc(), id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => AdditionalItemsEditBloc() + // ..add(LoadAdditionalItemsEdit( + // items: const [], + // id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => PropertyAssessmentEditBloc() + // ..add(LoadPropertyAssessmentEdit( + // assessmentsEdit: PropertyAssessmentEdit(), + // id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => PropertyAppraisalEditBloc() + // ..add(LoadPropertyAppraisalEdit( + // appraisalEdit: PropertyAppraisalEdit(), + // id: property_info.id)), + // ), + // BlocProvider( + // create: (context) => + // MunicipalityBloc()..add(LoadMunicipality())), + // BlocProvider( + // create: (context) => + // BarangayBloc()..add(LoadBarangay(id: '01'))), + // BlocProvider( + // create: (context) => MemorandaBloc()..add(LoadMemoranda())), + // BlocProvider( + // create: (context) => StructuralMaterialBloc() + // ..add(LoadStructuralMaterial( + // structure: StructureMaterials(), + // id: property_info.id))), + // ], + // child: EditBuilding( + // index: index, + // faas: property_info, + // title: 'Bldg & Structure Edit', + // ), + // ); + // })); + }, + 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: 2, // Border width + ), + ), + child: Icon( + Icons.forest_rounded, + color: primary, // Icon color + ), + ), + SizedBox( + width: 20, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${property_info.owner}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + SizedBox(height: 5), + Text( + '${property_info.tdn}', + style: TextStyle( + fontSize: 13, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + IconButton(onPressed: () {}, icon: const Icon(Icons.chevron_right)), + ], + ), + ), + ), + ); +} diff --git a/lib/screens/passo/passo_dashboard.dart b/lib/screens/passo/passo_dashboard.dart new file mode 100644 index 0000000..c423b8f --- /dev/null +++ b/lib/screens/passo/passo_dashboard.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; +import 'package:unit2/screens/passo/building_home.dart'; +import 'package:unit2/screens/passo/land_home%20.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/widgets/empty_data.dart'; + +class PassoDashBoard extends StatefulWidget { + @override + _PassoDashBoard createState() => _PassoDashBoard(); +} + +class _PassoDashBoard extends State { + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 3, + child: Scaffold( + body: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + new SliverAppBar( + backgroundColor: primary, + title: Text('Faas Dashboard'), + centerTitle: true, + pinned: true, + floating: true, + bottom: TabBar( + isScrollable: true, + tabs: [ + Tab(child: Text('Building')), + Tab(child: Text('Land')), + Tab(child: Text('Machineries')), + ], + ), + ), + ]; + }, + body: TabBarView( + children: [ + BlocProvider( + create: (context) => + PropertyInfoBloc()..add(const LoadPropertyInfo()), + child: const BuildingHome(), + ), + BlocProvider( + create: (context) => + LandPropertyOwnerInfoBloc()..add(const LoadLand()), + child: const LandHome(), + ), + EmptyData( + message: "Development ongoing ...", + ) + ], + ), + )), + ); + } +} diff --git a/lib/screens/unit2/homepage.dart/components/dashboard/dashboard.dart b/lib/screens/unit2/homepage.dart/components/dashboard/dashboard.dart index c03573d..2071193 100644 --- a/lib/screens/unit2/homepage.dart/components/dashboard/dashboard.dart +++ b/lib/screens/unit2/homepage.dart/components/dashboard/dashboard.dart @@ -69,7 +69,8 @@ class _DashBoardState extends State { } }); unit2Cards.forEach((element) { - print("${element.moduleName} - ${element.object.name!} - ${element.roleName} " ); + print( + "${element.moduleName} - ${element.object.name!} - ${element.roleName} "); }); if (superadminCards.length > 3) { tempSuperAdminCards = superadminCards.sublist(0, 4); @@ -605,8 +606,8 @@ class _DashBoardState extends State { columnCount: 4, )); }).toList())), - SizedBox( - height: rpassCards.isEmpty?0: 24, + SizedBox( + height: rpassCards.isEmpty ? 0 : 24, ), Container( child: rpassCards.isEmpty @@ -652,8 +653,8 @@ class _DashBoardState extends State { }).toList(), ), ), - SizedBox( - height: docSmsCards.isEmpty?0: 24, + SizedBox( + height: docSmsCards.isEmpty ? 0 : 24, ), Container( child: docSmsCards.isEmpty diff --git a/lib/sevices/passo/barangay.dart b/lib/sevices/passo/barangay.dart new file mode 100644 index 0000000..24490a1 --- /dev/null +++ b/lib/sevices/passo/barangay.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class BarangayServices { + static final BarangayServices _instance = BarangayServices(); + static BarangayServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(id) async { + String path = Url.instance.getBarangay(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "city_code": id.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => Brgy.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/building/additional_items_services.dart b/lib/sevices/passo/building/additional_items_services.dart new file mode 100644 index 0000000..b2a4441 --- /dev/null +++ b/lib/sevices/passo/building/additional_items_services.dart @@ -0,0 +1,87 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; + +import '../../../utils/urls.dart'; + +class AdditionalItemsServices { + static final AdditionalItemsServices _instance = AdditionalItemsServices(); + static AdditionalItemsServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.additionalItems(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result.map(((e) => AdditionalItems.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(AdditionalItems items) async { + String path = Url.instance.additionalItems(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: items.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future remove(id) async { + String path = Url.instance.additionalItems(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id.toString(), + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: params); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/building/general_description_services.dart b/lib/sevices/passo/building/general_description_services.dart new file mode 100644 index 0000000..17552c8 --- /dev/null +++ b/lib/sevices/passo/building/general_description_services.dart @@ -0,0 +1,69 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class GeneralDescriptionServices { + static final GeneralDescriptionServices _instance = + GeneralDescriptionServices(); + static GeneralDescriptionServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch(tempID) async { + String path = Url.instance.generalDescription(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('GenDescEdit'); + print(response.body); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = + GeneralDesc.fromJson(dataList[0] as Map); + + return result; + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future update(GeneralDesc data, id) async { + String path = Url.instance.generalDescription(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id, + }; + http.Response? response; + try { + print(id); + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + print(response.body); + } catch (e) { + throw e.toString(); + } + return response; + } +} diff --git a/lib/sevices/passo/building/landref_services.dart b/lib/sevices/passo/building/landref_services.dart new file mode 100644 index 0000000..ef90ba5 --- /dev/null +++ b/lib/sevices/passo/building/landref_services.dart @@ -0,0 +1,44 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandRefServices { + static final LandRefServices _instance = LandRefServices(); + static LandRefServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch(tempID) async { + String path = Url.instance.landRef(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('land ref'); + print(response.statusCode); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = LandRef.fromJson(dataList[0] as Map); + + return result; + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/building/location_landref_services.dart b/lib/sevices/passo/building/location_landref_services.dart new file mode 100644 index 0000000..b916aa8 --- /dev/null +++ b/lib/sevices/passo/building/location_landref_services.dart @@ -0,0 +1,68 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LocationLandrefServices { + static final LocationLandrefServices _instance = LocationLandrefServices(); + static LocationLandrefServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future update(BldgLoc data, id) async { + String path = Url.instance.bldgLocation(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future fetch(tempID) async { + String path = Url.instance.bldgLocation(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + + print('BldgLocEdit'); + print(response.body); + + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = BldgLoc.fromJson(dataList[0] as Map); + + return result; + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/building/property_appraisal_services.dart b/lib/sevices/passo/building/property_appraisal_services.dart new file mode 100644 index 0000000..2000441 --- /dev/null +++ b/lib/sevices/passo/building/property_appraisal_services.dart @@ -0,0 +1,133 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +import '../../../model/passo/property_appraisal_edit.dart'; + +class PropertyAppraisalServices { + static final PropertyAppraisalServices _instance = + PropertyAppraisalServices(); + static PropertyAppraisalServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + final tempID = await SharedPreferences.getInstance(); + print('sds'); + print(tempID.getInt('tempid')! - 1); + final id = tempID.getInt('tempid')! - 1; + String path = Url.instance.propertyAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('Appraisal TEMPID'); + print(response.body); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = + PropertyAppraisal.fromJson(dataList[0] as Map); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future update(PropertyAppraisal appraisal, tempID) async { + String path = Url.instance.propertyAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + print(tempID); + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, + body: appraisal.toJson(), + headers: headers, + param: params); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future fetchEdit(id) async { + String path = Url.instance.propertyAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('Property_Apraisaledit'); + print(response.statusCode); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = + PropertyAppraisalEdit.fromJson(dataList[0] as Map); + + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future updateAppraisal( + PropertyAppraisalEdit appraisal, tempID) async { + String path = Url.instance.propertyAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID, + }; + print(tempID); + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, + body: appraisal.toJson(), + headers: headers, + param: params); + } catch (e) { + log(e.toString()); + } + return response; + } +} diff --git a/lib/sevices/passo/building/property_assessment_services.dart b/lib/sevices/passo/building/property_assessment_services.dart new file mode 100644 index 0000000..3ac71ca --- /dev/null +++ b/lib/sevices/passo/building/property_assessment_services.dart @@ -0,0 +1,158 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/property_assessment.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/property_assessment_edit.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class PropertyAssessmentServices { + static final PropertyAssessmentServices _instance = + PropertyAssessmentServices(); + static PropertyAssessmentServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('Assessment'); + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => PropertyAssessment.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(PropertyAssessment assessment) async { + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: assessment.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future update(PropertyAssessment assessment, id) async { + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, + body: assessment.toJson(), + headers: headers, + param: params); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future fetchEdit(tempID) async { + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('Assessment'); + print(response.body); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = PropertyAssessmentEdit.fromJson( + dataList[0] as Map); + + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future addEdit(PropertyAssessmentEdit assessment) async { + Map statusResponse = {}; + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: assessment.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future updateEdit( + PropertyAssessmentEdit assessment, id) async { + String path = Url.instance.propertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, + body: assessment.toJson(), + headers: headers, + param: params); + } catch (e) { + log(e.toString()); + } + return response; + } +} diff --git a/lib/sevices/passo/building/property_info_services.dart b/lib/sevices/passo/building/property_info_services.dart new file mode 100644 index 0000000..ac90a92 --- /dev/null +++ b/lib/sevices/passo/building/property_info_services.dart @@ -0,0 +1,137 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class PropertyInfoService { + static final PropertyInfoService _instance = PropertyInfoService(); + static PropertyInfoService get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.propertyInfo(); + 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => PropertyInfo.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(PropertyInfo faas) async { + Map statusResponse = {}; + String path = Url.instance.propertyInfo(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: faas.toJson(), headers: headers); + } catch (e) { + throw e.toString(); + } + return response; + } + + Future update(PropertyInfo data, id) async { + String path = "${Url.instance.propertyInfo()}$id/"; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: {}); + } catch (e) { + throw e.toString(); + } + return response; + } + + Future updateBldg(BldgLoc data, id) async { + String path = Url.instance.bldgLocation(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + throw e.toString(); + } + return response; + } + + Future updateLandRef(LandRef data, id) async { + String path = Url.instance.landRef(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + throw e.toString(); + } + return response; + } + + Future updateGenDesc(GeneralDesc data, id) async { + String path = Url.instance.generalDescription(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + throw e.toString(); + } + return response; + } +} diff --git a/lib/sevices/passo/building/structural_material_services.dart b/lib/sevices/passo/building/structural_material_services.dart new file mode 100644 index 0000000..0da27f3 --- /dev/null +++ b/lib/sevices/passo/building/structural_material_services.dart @@ -0,0 +1,67 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/model/passo/structureMaterial.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class StrucMaterialServices { + static final StrucMaterialServices _instance = StrucMaterialServices(); + static StrucMaterialServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future update(StructureMaterialsII data, id) async { + String path = Url.instance.structuralMaterials(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future fetch(id) async { + String path = Url.instance.structuralMaterials(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "bldgappr_details_id": id.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + print('StructureMaterialsII'); + print(response.body); + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = + StructureMaterials.fromJson(dataList[0] as Map); + + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/class_components_services.dart b/lib/sevices/passo/class_components_services.dart new file mode 100644 index 0000000..8898ed4 --- /dev/null +++ b/lib/sevices/passo/class_components_services.dart @@ -0,0 +1,36 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/class_components.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class ClassComponentService { + static final ClassComponentService _instance = ClassComponentService(); + static ClassComponentService get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getClassComponents(); + 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => ClassComponents.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_appraisal.dart b/lib/sevices/passo/land/land_appraisal.dart new file mode 100644 index 0000000..065e5ad --- /dev/null +++ b/lib/sevices/passo/land/land_appraisal.dart @@ -0,0 +1,86 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/utils/request.dart'; + +import '../../../utils/urls.dart'; + +class LandAppraisalServices { + static final LandAppraisalServices _instance = LandAppraisalServices(); + static LandAppraisalServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.getLandAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result.map(((e) => LandAppr.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(LandAppr items) async { + String path = Url.instance.getLandAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: items.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future remove(id) async { + String path = Url.instance.getLandAppraisal(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id.toString(), + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: params); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_boundaries.dart b/lib/sevices/passo/land/land_boundaries.dart new file mode 100644 index 0000000..969d40c --- /dev/null +++ b/lib/sevices/passo/land/land_boundaries.dart @@ -0,0 +1,59 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_property_boundaries.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandBoundariesService { + static final LandBoundariesService _instance = LandBoundariesService(); + static LandBoundariesService get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getLandPropertyBoundaries(); + 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); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandPropertyBoundaries.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future update(LandPropertyBoundaries data, id) async { + String path = Url.instance.getLandPropertyBoundaries(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + log(e.toString()); + } + return response; + } +} diff --git a/lib/sevices/passo/land/land_classification.dart b/lib/sevices/passo/land/land_classification.dart new file mode 100644 index 0000000..198b509 --- /dev/null +++ b/lib/sevices/passo/land/land_classification.dart @@ -0,0 +1,39 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandClassificationService { + static final LandClassificationService _instance = + LandClassificationService(); + static LandClassificationService 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); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandClassification.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_ext.dart b/lib/sevices/passo/land/land_ext.dart new file mode 100644 index 0000000..4d23162 --- /dev/null +++ b/lib/sevices/passo/land/land_ext.dart @@ -0,0 +1,136 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/land_ext.dart'; +import 'package:unit2/model/passo/property_assessment.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/property_assessment_edit.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandExtServices { + static final LandExtServices _instance = LandExtServices(); + static LandExtServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.getLandExt(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + print('Assessment'); + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandExt.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(LandExt assessment) async { + Map statusResponse = {}; + String path = Url.instance.getLandExt(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: assessment.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future update(LandExt assessment, id) async { + String path = Url.instance.getLandExt(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, + body: assessment.toJson(), + headers: headers, + param: params); + } catch (e) { + log(e.toString()); + } + return response; + } + + // Future fetchEdit(tempID) async { + // http.Response response = await http.get(Uri.parse( + // '$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=$tempID')); + // print('Assessment'); + // print(response.body); + // if (response.statusCode == 200) { + // final jsonData = jsonDecode(response.body); + // final dataList = jsonData['data'] as List; + // final result = + // LandExtEdit.fromJson(dataList[0] as Map); + + // return result; + // } else { + // throw Exception(response.reasonPhrase); + // } + // } + + // Future addEdit(LandExtEdit assessment) async { + // http.Response? response; + // try { + // response = await http.post( + // Uri.parse("$baseUrl${Url.instance.getLandExt()}"), + // headers: { + // HttpHeaders.contentTypeHeader: "application/json", + // }, + // body: jsonEncode(assessment.toJson())); + // } catch (e) { + // log(e.toString()); + // } + // return response; + // } + + // Future updateEdit( + // LandExtEdit assessment, id) async { + // print(id); + // http.Response? response; + // try { + // response = await http.put(Uri.parse( + // // ignore: unnecessary_brace_in_string_interps + // "$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=${id}"), + // headers: { + // HttpHeaders.contentTypeHeader: "application/json", + // }, + // body: jsonEncode(assessment.toJson())); + // } catch (e) { + // log(e.toString()); + // } + // return response; + // } +} diff --git a/lib/sevices/passo/land/land_location.dart b/lib/sevices/passo/land/land_location.dart new file mode 100644 index 0000000..8a2fe5b --- /dev/null +++ b/lib/sevices/passo/land/land_location.dart @@ -0,0 +1,58 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/land_property_loc.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandLocationService { + static final LandLocationService _instance = LandLocationService(); + static LandLocationService get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getLandPropertyLoc(); + 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandPropertyLoc.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future update(LandPropertyLoc data, id) async { + String path = Url.instance.getLandPropertyLoc(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + log(e.toString()); + } + return response; + } +} diff --git a/lib/sevices/passo/land/land_other_improvements.dart b/lib/sevices/passo/land/land_other_improvements.dart new file mode 100644 index 0000000..d23652a --- /dev/null +++ b/lib/sevices/passo/land/land_other_improvements.dart @@ -0,0 +1,86 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/utils/request.dart'; + +import '../../../utils/urls.dart'; + +class OtherImprovementServices { + static final OtherImprovementServices _instance = OtherImprovementServices(); + static OtherImprovementServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.getOtherImprovements(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID, + }; + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result.map(((e) => OtherImprovements.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(OtherImprovements items) async { + String path = Url.instance.getOtherImprovements(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: items.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future remove(id) async { + String path = Url.instance.getOtherImprovements(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id, + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: {}); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_property_assessment.dart b/lib/sevices/passo/land/land_property_assessment.dart new file mode 100644 index 0000000..d8768bd --- /dev/null +++ b/lib/sevices/passo/land/land_property_assessment.dart @@ -0,0 +1,87 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/utils/request.dart'; + +import '../../../utils/urls.dart'; + +class LandPropertyAssessmentServices { + static final LandPropertyAssessmentServices _instance = + LandPropertyAssessmentServices(); + static LandPropertyAssessmentServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.getLandPropertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result.map(((e) => LandPropertyAssessment.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(LandPropertyAssessment items) async { + String path = Url.instance.getLandPropertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: items.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future remove(id) async { + String path = Url.instance.getLandPropertyAssessment(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id.toString(), + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: params); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_property_owner.dart b/lib/sevices/passo/land/land_property_owner.dart new file mode 100644 index 0000000..83798ab --- /dev/null +++ b/lib/sevices/passo/land/land_property_owner.dart @@ -0,0 +1,55 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:unit2/model/passo/land_property_owner.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandServices { + static final LandServices _instance = LandServices(); + static LandServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getLandOwnerInfo(); + 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); + + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandPropertyOwner.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(LandPropertyOwner land) async { + String path = Url.instance.getLandOwnerInfo(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: land.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } +} diff --git a/lib/sevices/passo/land/land_subclassification.dart b/lib/sevices/passo/land/land_subclassification.dart new file mode 100644 index 0000000..031c56e --- /dev/null +++ b/lib/sevices/passo/land/land_subclassification.dart @@ -0,0 +1,42 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_subclassification.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandSubClassificationService { + static final LandSubClassificationService _instance = + LandSubClassificationService(); + static LandSubClassificationService get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(cityCode, classCode) async { + String path = Url.instance.getLandSubClassification(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "city_code": cityCode.toString(), + "classification_id": classCode.toString() + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => LandSubClassification.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_trees_improvements.dart b/lib/sevices/passo/land/land_trees_improvements.dart new file mode 100644 index 0000000..29da425 --- /dev/null +++ b/lib/sevices/passo/land/land_trees_improvements.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/trees_improvements.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class LandTreesImprovementsServices { + static final LandTreesImprovementsServices _instance = + LandTreesImprovementsServices(); + static LandTreesImprovementsServices 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => TreesImprovements.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/land_value_adjustment.dart b/lib/sevices/passo/land/land_value_adjustment.dart new file mode 100644 index 0000000..8fda18f --- /dev/null +++ b/lib/sevices/passo/land/land_value_adjustment.dart @@ -0,0 +1,86 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/utils/request.dart'; + +import '../../../utils/urls.dart'; + +class ValueAdjustmentsServices { + static final ValueAdjustmentsServices _instance = ValueAdjustmentsServices(); + static ValueAdjustmentsServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch(tempID) async { + String path = Url.instance.getValueAdjustmentss(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID, + }; + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result.map(((e) => ValueAdjustments.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } + + Future add(ValueAdjustments items) async { + String path = Url.instance.getValueAdjustmentss(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + http.Response? response; + try { + response = await Request.instance.postRequest( + param: {}, path: path, body: items.toJson(), headers: headers); + } catch (e) { + log(e.toString()); + } + return response; + } + + Future remove(id) async { + String path = Url.instance.getValueAdjustmentss(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id, + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: {}); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/type_of_location.dart b/lib/sevices/passo/land/type_of_location.dart new file mode 100644 index 0000000..004e6d7 --- /dev/null +++ b/lib/sevices/passo/land/type_of_location.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/type_of_location.dart'; +import 'package:unit2/model/passo/type_of_road.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class TypeOfLocationServices { + static final TypeOfLocationServices _instance = TypeOfLocationServices(); + static TypeOfLocationServices 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); + if (response.statusCode == 200) { + print(response.body); + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => TypeOfLocation.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/land/type_of_road.dart b/lib/sevices/passo/land/type_of_road.dart new file mode 100644 index 0000000..51470ed --- /dev/null +++ b/lib/sevices/passo/land/type_of_road.dart @@ -0,0 +1,37 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/type_of_road.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class TypeOfRoadServices { + static final TypeOfRoadServices _instance = TypeOfRoadServices(); + static TypeOfRoadServices 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); + if (response.statusCode == 200) { + print(response.body); + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => TypeOfRoad.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/memoranda.dart b/lib/sevices/passo/memoranda.dart new file mode 100644 index 0000000..c29a6be --- /dev/null +++ b/lib/sevices/passo/memoranda.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/model/passo/memoranda.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class MemorandaServices { + static final MemorandaServices _instance = MemorandaServices(); + static MemorandaServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getMemoranda(); + 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => Memoranda.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/municipality.dart b/lib/sevices/passo/municipality.dart new file mode 100644 index 0000000..2bb4850 --- /dev/null +++ b/lib/sevices/passo/municipality.dart @@ -0,0 +1,39 @@ +import 'dart:convert'; + +import 'package:unit2/model/location/barangay.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class MunicipalityServices { + static final MunicipalityServices _instance = MunicipalityServices(); + static MunicipalityServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getMunicipality(); + 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); + if (response.statusCode == 200) { + print(response.body); + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => City.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/signatories_service.dart b/lib/sevices/passo/signatories_service.dart new file mode 100644 index 0000000..1d527f2 --- /dev/null +++ b/lib/sevices/passo/signatories_service.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; + +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class SignatoriesServices { + static final SignatoriesServices _instance = SignatoriesServices(); + static SignatoriesServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getSignatories(); + 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('Signatories'); + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => Signatories.fromJson(e))).toList(); + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/sevices/passo/unit_construct_services.dart b/lib/sevices/passo/unit_construct_services.dart new file mode 100644 index 0000000..39794e8 --- /dev/null +++ b/lib/sevices/passo/unit_construct_services.dart @@ -0,0 +1,36 @@ +import 'dart:convert'; + +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; + +class UnitConstructService { + static final UnitConstructService _instance = UnitConstructService(); + static UnitConstructService get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future> fetch() async { + String path = Url.instance.getUnitConstruct(); + 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); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => UnitConstruct.fromJson(e))).toList(); + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } +} diff --git a/lib/utils/app_router.dart b/lib/utils/app_router.dart index 610fd3f..27bc4a2 100644 --- a/lib/utils/app_router.dart +++ b/lib/utils/app_router.dart @@ -1,8 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart'; import 'package:unit2/bloc/sos/sos_bloc.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/screens/passo/passo_dashboard.dart'; +import 'package:unit2/screens/passo/building_home.dart'; import 'package:unit2/screens/sos/index.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/menu.dart'; @@ -57,19 +61,34 @@ class AppRouter { ); }); case '/pass-check': - PassCheckArguments arguments = routeSettings.arguments as PassCheckArguments; + PassCheckArguments arguments = + routeSettings.arguments as PassCheckArguments; return MaterialPageRoute(builder: (BuildContext context) { - return BlocProvider( - create: (context) => PassCheckBloc()..add(GetPassCheckAreas(roleId: arguments.roleId, userId: arguments.userId)), - child: QRCodeScannerSettings(roleId: arguments.roleId, userId: arguments.userId,), + return BlocProvider( + create: (context) => PassCheckBloc() + ..add(GetPassCheckAreas( + roleId: arguments.roleId, userId: arguments.userId)), + child: QRCodeScannerSettings( + roleId: arguments.roleId, + userId: arguments.userId, + ), + ); + }); + case '/passo-home': + return MaterialPageRoute(builder: (BuildContext context) { + return PassoDashBoard(); + }); + // BlocProvider.of( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser()); + // return MaterialPageRoute(builder: (_) { + // return const PassoHome(); + // }); + case '/rbac': + return MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (_) => RbacBloc()..add(SetRbacScreen()), + child: const RBACScreen(), ); }); - case '/rbac': - return MaterialPageRoute(builder: (BuildContext context){ - return BlocProvider( - create: (_) => RbacBloc()..add(SetRbacScreen()), - child:const RBACScreen(), - );}); default: return MaterialPageRoute(builder: (context) { return Container(); diff --git a/lib/utils/request.dart b/lib/utils/request.dart index 33c7a12..d75fcdc 100644 --- a/lib/utils/request.dart +++ b/lib/utils/request.dart @@ -104,47 +104,8 @@ class Request { required Map? param}) async { Response response; try { - response =await put(Uri.https(host,path,param),headers: headers,body: jsonEncode(body)); - } on TimeoutException catch (_) { - Fluttertoast.showToast( - msg: timeoutError, - toastLength: Toast.LENGTH_LONG, - gravity: ToastGravity.BOTTOM, - backgroundColor: Colors.black, - ); - throw (timeoutError); - } on SocketException catch (_) { - Fluttertoast.showToast( - msg: timeoutError, - toastLength: Toast.LENGTH_LONG, - gravity: ToastGravity.BOTTOM, - backgroundColor: Colors.black, - ); - throw (timeoutError); - } on FormatException catch (_) { - throw const FormatException(formatError); - } on HttpException catch (_) { - throw const HttpException(httpError); - } on Error catch (e) { - debugPrint("post request error: $e"); - Fluttertoast.showToast( - msg: onError, - toastLength: Toast.LENGTH_LONG, - gravity: ToastGravity.BOTTOM, - backgroundColor: Colors.black, - ); - throw (e.toString()); - } - return response; - } - Future patch( - {required String path, - required Map? headers, - required Map? body, - required Map? param}) async { - Response response; - try { - response =await patch(path: host+path, headers: headers,body: body,param: param); + response = await put(Uri.https(host, path, param), + headers: headers, body: jsonEncode(body)); } on TimeoutException catch (_) { Fluttertoast.showToast( msg: timeoutError, @@ -178,6 +139,47 @@ class Request { return response; } + Future patch( + {required String path, + required Map? headers, + required Map? body, + required Map? param}) async { + Response response; + try { + response = await patch( + path: host + path, headers: headers, body: body, param: param); + } on TimeoutException catch (_) { + Fluttertoast.showToast( + msg: timeoutError, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + backgroundColor: Colors.black, + ); + throw (timeoutError); + } on SocketException catch (_) { + Fluttertoast.showToast( + msg: timeoutError, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + backgroundColor: Colors.black, + ); + throw (timeoutError); + } on FormatException catch (_) { + throw const FormatException(formatError); + } on HttpException catch (_) { + throw const HttpException(httpError); + } on Error catch (e) { + debugPrint("post request error: $e"); + Fluttertoast.showToast( + msg: onError, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + backgroundColor: Colors.black, + ); + throw (e.toString()); + } + return response; + } Future deleteRequest( {required String path, diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index a2f27e4..896d0d7 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -12,7 +12,8 @@ class Url { // return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; } - String prefixHost(){ + + String prefixHost() { return "https"; // return "https"; } @@ -64,8 +65,9 @@ class Url { String workhistory() { return "/api/jobnet_app/profile/pds/work_experience/"; } - String deleteWorkHistory(){ - return "/api/jobnet_app/profile/pds/work/"; + + String deleteWorkHistory() { + return "/api/jobnet_app/profile/pds/work/"; } String getPositions() { @@ -174,7 +176,8 @@ class Url { String getServiceTypes() { return "/api/jobnet_app/comm_service_type/"; } - String attachments(){ + + String attachments() { return "/api/jobnet_app/profile/attachment/"; } @@ -299,18 +302,20 @@ class Url { String getStation() { return "/api/hrms_app/station/"; } - String postStation() { + + String postStation() { return "/api/hrms_app/stations/"; } - String getRoleAssignment(){ + String getRoleAssignment() { return "api/account/auth/role_assignment/"; } - String getStationType(){ + + String getStationType() { return "/api/hrms_app/station_type/"; } - String getPositionTitle(){ + String getPositionTitle() { return "/api/hrms_app/position_title/"; } @@ -338,7 +343,118 @@ class Url { String getAddressCategory() { return "/api/jobnet_app/address_categories/"; } - String attachmentCategories(){ + + ////passo path + + String additionalItems() { + return "/api/rptass_app/additional_items/"; + } + + String generalDescription() { + return "/api/rptass_app/bldgappr_gendesc/"; + } + + String landRef() { + return "/api/rptass_app/bldgappr_landref/"; + } + + String bldgLocation() { + return "/api/rptass_app/bldgappr_location/"; + } + + String propertyAppraisal() { + return "/api/rptass_app/property_appraisal/"; + } + + String propertyAssessment() { + return "/api/rptass_app/property_assessment/"; + } + + String propertyInfo() { + return "/api/rptass_app/bldgappr_details/"; + } + + String structuralMaterials() { + return "/api/rptass_app/structural_materials/"; + } + + String getBarangay() { + return "/api/rptass_app/agusan_barangay/"; + } + + String getClassComponents() { + return "/api/rptass_app/class_components/"; + } + + String getMunicipality() { + return "/api/rptass_app/agusan_city/"; + } + + String getSignatories() { + return "/api/rptass_app/signatories/"; + } + + String getUnitConstruct() { + return "/api/rptass_app/unitconstruct_values/"; + } + + String getMemoranda() { + return "/api/rptass_app/bldg_memoranda/"; + } + + String getLandOwnerInfo() { + return "/api/rptass_app/landappr_details/"; + } + + String getLandAppraisal() { + return "/api/rptass_app/landappr/"; + } + + String getLandClassification() { + return "/api/rptass_app/appraisal_classification/"; + } + + String getLandSubClassification() { + return "/api/rptass_app/appraisal_subclassification/"; + } + + String getLandPropertyLoc() { + return "/api/rptass_app/landappr_propertyloc/"; + } + + String getLandPropertyBoundaries() { + return "/api/rptass_app/landappr_prptybounderies/"; + } + + String getOtherImprovements() { + return "/api/rptass_app/landappr_plants_trees/"; + } + + String getTreesImprovements() { + return "/api/rptass_app/appraisal_improvement_price/"; + } + + String getValueAdjustmentss() { + return "/api/rptass_app/landappr_value_adjustment/"; + } + + String getTypeOfRoad() { + return "/api/rptass_app/appraisal_road_type/"; + } + + String getTypeOfLocation() { + return "/api/rptass_app/appraisal_location_type/"; + } + + String getLandPropertyAssessment() { + return "/api/rptass_app/landappr_property_assessment/"; + } + + String getLandExt() { + return '/api/rptass_app/landappr_propertyass_extn/'; + } + + String attachmentCategories() { return "/api/jobnet_app/attachment_categories/"; } } diff --git a/lib/widgets/passo/custom_button.dart b/lib/widgets/passo/custom_button.dart new file mode 100644 index 0000000..1a6d364 --- /dev/null +++ b/lib/widgets/passo/custom_button.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +class CustomButton extends StatelessWidget { + final VoidCallback onPressed; + final Icon icon; + + CustomButton({required this.onPressed, required this.icon}); + + @override + Widget build(BuildContext context) { + return ElevatedButton( + onPressed: onPressed, + style: ElevatedButton.styleFrom( + shape: const CircleBorder(), + padding: const EdgeInsets.all(30), + backgroundColor: primary, + foregroundColor: Colors.white, + ), + child: icon, + ); + } +} diff --git a/lib/widgets/passo/custom_formBuilder_fields.dart b/lib/widgets/passo/custom_formBuilder_fields.dart new file mode 100644 index 0000000..5adec45 --- /dev/null +++ b/lib/widgets/passo/custom_formBuilder_fields.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +Widget customTextField(String labelText, String hintText, String keyText) { + return Container( + margin: const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderTextField( + name: keyText, + decoration: normalTextFieldStyle(labelText, hintText), + validator: FormBuilderValidators.compose([]), + ), + ); +} + +Widget customDropDownField(String labelText, String hintText, String keyText, + List dropdownItems) { + // Create a Set to keep track of unique values + Set uniqueItems = {}; + + // Iterate through the dropdownItems list to filter out duplicates + for (var item in dropdownItems) { + uniqueItems.add(item); + } + + // Convert the Set back to a List to use for DropdownMenuItem + List filteredItems = uniqueItems.toList(); + + return Container( + margin: const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderDropdown( + name: keyText, + autofocus: false, + decoration: normalTextFieldStyle(labelText, hintText), + items: filteredItems + .map((item) => DropdownMenuItem( + value: item, + child: Text(item), + )) + .toList(), + ), + ); +} + +Widget customDatTimePicker(String labelText, String hintText, String keyText) { + return Container( + margin: const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderDateTimePicker( + name: keyText, + initialEntryMode: DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + decoration: normalTextFieldStyle(labelText, hintText), + initialTime: const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ); +} diff --git a/pubspec.lock b/pubspec.lock index 9ce9322..21b386e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -603,6 +603,16 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" +<<<<<<< HEAD + flutter_speed_dial: + dependency: "direct main" + description: + name: flutter_speed_dial + sha256: "41d7ad0bc224248637b3a5e0b9083e912a75445bdb450cf82b8ed06d7af7c61d" + url: "https://pub.dev" + source: hosted + version: "6.2.0" +======= flutter_simple_treeview: dependency: "direct main" description: @@ -611,6 +621,7 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" +>>>>>>> develop flutter_spinkit: dependency: "direct main" description: @@ -773,6 +784,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + im_stepper: + dependency: "direct main" + description: + name: im_stepper + sha256: "84ca411f7c4666cb8762a6dd6eec0353c96c67f674124614263875d0570ca634" + url: "https://pub.dev" + source: hosted + version: "1.0.1+1" image: dependency: transitive description: @@ -917,6 +936,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.9" + multi_select_flutter: + dependency: "direct main" + description: + name: multi_select_flutter + sha256: "503857b415d390d29159df8a9d92d83c6aac17aaf1c307fb7bcfc77d097d20ed" + url: "https://pub.dev" + source: hosted + version: "4.1.3" + multiselect: + dependency: "direct main" + description: + name: multiselect + sha256: "8d0c4a7b89bee6c5e5e4a25ecba68c796dafc1917492d5606f0caa3947d5905a" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + navigation_builder: + dependency: transitive + description: + name: navigation_builder + sha256: "95e25150191d9cd4e4b86504f33cd9e786d1e6732edb2e3e635bbedc5ef0dea7" + url: "https://pub.dev" + source: hosted + version: "0.0.3" nested: dependency: transitive description: @@ -1294,7 +1337,7 @@ packages: source: hosted version: "3.3.0" shared_preferences: - dependency: transitive + dependency: "direct main" description: name: shared_preferences sha256: "396f85b8afc6865182610c0a2fc470853d56499f75f7499e2a73a9f0539d23d0" @@ -1434,6 +1477,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + states_rebuilder: + dependency: transitive + description: + name: states_rebuilder + sha256: bf1a5ab5c543acdefce35e60f482eb7ab592339484fe3266d147ee597f18dc92 + url: "https://pub.dev" + source: hosted + version: "6.3.0" stream_channel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f87cecc..2f532b8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -82,6 +82,11 @@ dependencies: searchable_paginated_dropdown: ^1.2.0 audioplayers: ^4.1.0 assets_audio_player: ^3.0.6 + flutter_speed_dial: ^6.2.0 + im_stepper: ^1.0.1+1 + shared_preferences: ^2.0.20 + multiselect: ^0.1.0 + multi_select_flutter: ^4.1.3 flutter_custom_selector: ^0.0.3 flutter_staggered_animations: ^1.1.1 group_list_view: ^1.1.1