diff --git a/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart new file mode 100644 index 0000000..ec30376 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart @@ -0,0 +1,35 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/barangay.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'barangay_admin_event.dart'; +part 'barangay_admin_state.dart'; + +class BarangayAdminBloc extends Bloc { + BarangayAdminBloc() : super(BarangayAdminInitial()) { + List brgy = []; + on((event, emit) async { + brgy = await SQLServices.instance.readAllBarangay(); + + emit(BarangayLoaded(brgy: brgy)); + }); + on((event, emit) async { + brgy = await SQLServices.instance + .readBrgyInSelectedMunicipality(event.cityCode); + + emit(BarangayLoaded(brgy: brgy)); + }); + on((event, emit) async { + await SQLServices.instance.createBarangay( + Brgy( + id: event.id, + barangayId: event.barangayId, + barangayCode: event.barangayCode, + cityCode: event.cityCode, + barangayDescription: event.barangayDescription), + ); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_event.dart b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_event.dart new file mode 100644 index 0000000..757f835 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_event.dart @@ -0,0 +1,48 @@ +part of 'barangay_admin_bloc.dart'; + +class BarangayAdminEvent extends Equatable { + const BarangayAdminEvent(); + + @override + List get props => []; +} + +class AddBarangay extends BarangayAdminEvent { + final int id; + final int barangayId; + final String barangayCode; + final String cityCode; + final String barangayDescription; + + const AddBarangay({ + required this.id, + required this.barangayId, + required this.barangayCode, + required this.cityCode, + required this.barangayDescription, + }); + + @override + List get props => [ + id, + barangayId, + barangayCode, + cityCode, + barangayDescription, + ]; +} + +class LoadBarangay extends BarangayAdminEvent { + const LoadBarangay(); + + @override + List get props => []; +} + +class LoadBarangayInMunicipality extends BarangayAdminEvent { + final String cityCode; + const LoadBarangayInMunicipality({required this.cityCode}); + + @override + List get props => [cityCode]; +} diff --git a/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_state.dart b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_state.dart new file mode 100644 index 0000000..766e360 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_state.dart @@ -0,0 +1,21 @@ +part of 'barangay_admin_bloc.dart'; + +class BarangayAdminState extends Equatable { + const BarangayAdminState(); + + @override + List get props => []; +} + +class BarangayAdminInitial extends BarangayAdminState { + @override + List get props => []; +} + +class BarangayLoaded extends BarangayAdminState { + final List brgy; + + const BarangayLoaded({required this.brgy}); + @override + List get props => [brgy]; +} diff --git a/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart new file mode 100644 index 0000000..b0e27c3 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart @@ -0,0 +1,42 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/class_components _offline.dart'; +import '../../../../../model/passo/class_components.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'class_components_admin_event.dart'; +part 'class_components_admin_state.dart'; + +class ClassComponentsAdminBloc + extends Bloc { + ClassComponentsAdminBloc() : super(ClassComponentsAdminInitial()) { + List classes = []; + on((event, emit) async { + classes = await SQLServices.instance.readAllClassComponents(); + + emit(ClassComponentsAdminLoaded(classes: classes)); + }); + on((event, emit) async { + await SQLServices.instance.createClassComponents( + ClassComponentsOffline( + componentName: event.componentName, + minBaseUnitvalPercent: event.minBaseUnitvalPercent, + maxBaseUnitvalPercent: event.maxBaseUnitvalPercent, + minUnitvalSqrmtr: event.minUnitvalSqrmtr, + maxUnitvalSqrmtr: event.maxUnitvalSqrmtr, + minAddBaseunitval: event.minAddBaseunitval, + maxAddBaseunitval: event.maxAddBaseunitval, + minDeductBaserate: event.minDeductBaserate, + maxDeductBaserate: event.maxDeductBaserate, + minLinearMeter: event.minLinearMeter, + maxLinearMeter: event.maxLinearMeter, + minSpacing: event.minSpacing, + maxSpacing: event.maxSpacing, + roughFinish: event.roughFinish, + highFinish: event.highFinish, + withoutBucc: event.withoutBucc), + ); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_event.dart b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_event.dart new file mode 100644 index 0000000..800b85c --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_event.dart @@ -0,0 +1,73 @@ +part of 'class_components_admin_bloc.dart'; + +class ClassComponentsAdminEvent extends Equatable { + const ClassComponentsAdminEvent(); + + @override + List get props => []; +} + +class AddClassComponents extends ClassComponentsAdminEvent { + 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 int withoutBucc; + + const AddClassComponents({ + 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, + }); + + @override + List get props => [ + componentName, + minBaseUnitvalPercent, + maxBaseUnitvalPercent, + minUnitvalSqrmtr, + maxUnitvalSqrmtr, + minAddBaseunitval, + maxAddBaseunitval, + minDeductBaserate, + maxDeductBaserate, + minLinearMeter, + maxLinearMeter, + minSpacing, + maxSpacing, + roughFinish, + highFinish, + withoutBucc, + ]; +} + +class LoadClassComponents extends ClassComponentsAdminEvent { + const LoadClassComponents(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_state.dart b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_state.dart new file mode 100644 index 0000000..b08f829 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_state.dart @@ -0,0 +1,21 @@ +part of 'class_components_admin_bloc.dart'; + +class ClassComponentsAdminState extends Equatable { + const ClassComponentsAdminState(); + + @override + List get props => []; +} + +class ClassComponentsAdminInitial extends ClassComponentsAdminState { + @override + List get props => []; +} + +class ClassComponentsAdminLoaded extends ClassComponentsAdminState { + final List classes; + + const ClassComponentsAdminLoaded({required this.classes}); + @override + List get props => [classes]; +} diff --git a/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart new file mode 100644 index 0000000..4fc10ab --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart @@ -0,0 +1,27 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/memoranda.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'memoranda_admin_event.dart'; +part 'memoranda_admin_state.dart'; + +class MemorandaAdminBloc + extends Bloc { + MemorandaAdminBloc() : super(MemorandaAdminInitial()) { + List memo = []; + on((event, emit) async { + memo = await SQLServices.instance.readAllMemoranda(); + + emit(MemorandaLoaded(memo: memo)); + }); + on((event, emit) async { + await SQLServices.instance.createMemoranda(Memoranda( + id: event.id, + code: event.code, + memoranda: event.memoranda, + )); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_event.dart b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_event.dart new file mode 100644 index 0000000..b44a2de --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_event.dart @@ -0,0 +1,34 @@ +part of 'memoranda_admin_bloc.dart'; + +class MemorandaAdminEvent extends Equatable { + const MemorandaAdminEvent(); + + @override + List get props => []; +} + +class AddMemoranda extends MemorandaAdminEvent { + final int id; + final String code; + final String memoranda; + + const AddMemoranda({ + required this.id, + required this.code, + required this.memoranda, + }); + + @override + List get props => [ + id, + code, + memoranda, + ]; +} + +class LoadMemoranda extends MemorandaAdminEvent { + const LoadMemoranda(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_state.dart b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_state.dart new file mode 100644 index 0000000..eff98cd --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_state.dart @@ -0,0 +1,21 @@ +part of 'memoranda_admin_bloc.dart'; + +class MemorandaAdminState extends Equatable { + const MemorandaAdminState(); + + @override + List get props => []; +} + +class MemorandaAdminInitial extends MemorandaAdminState { + @override + List get props => []; +} + +class MemorandaLoaded extends MemorandaAdminState { + final List memo; + + const MemorandaLoaded({required this.memo}); + @override + List get props => [memo]; +} diff --git a/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart new file mode 100644 index 0000000..ce2c941 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart @@ -0,0 +1,28 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'municipalities_admin_event.dart'; +part 'municipalities_admin_state.dart'; + +class MunicipalitiesAdminBloc + extends Bloc { + MunicipalitiesAdminBloc() : super(MunicipalitiesAdminInitial()) { + List city = []; + on((event, emit) async { + city = await SQLServices.instance.readAllMunicipalities(); + + emit(MunicipalitiesLoaded(city: city)); + }); + on((event, emit) async { + await SQLServices.instance.createMunicipalities( + City( + id: event.id, + cityCode: event.cityCode, + cityDescription: event.cityDescription, + ), + ); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_event.dart b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_event.dart new file mode 100644 index 0000000..c72025c --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_event.dart @@ -0,0 +1,34 @@ +part of 'municipalities_admin_bloc.dart'; + +class MunicipalitiesAdminEvent extends Equatable { + const MunicipalitiesAdminEvent(); + + @override + List get props => []; +} + +class AddMunicipality extends MunicipalitiesAdminEvent { + final int id; + final String cityCode; + final String cityDescription; + + const AddMunicipality({ + required this.id, + required this.cityCode, + required this.cityDescription, + }); + + @override + List get props => [ + id, + cityCode, + cityDescription, + ]; +} + +class LoadMunicipalities extends MunicipalitiesAdminEvent { + const LoadMunicipalities(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_state.dart b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_state.dart new file mode 100644 index 0000000..1910161 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_state.dart @@ -0,0 +1,21 @@ +part of 'municipalities_admin_bloc.dart'; + +class MunicipalitiesAdminState extends Equatable { + const MunicipalitiesAdminState(); + + @override + List get props => []; +} + +class MunicipalitiesAdminInitial extends MunicipalitiesAdminState { + @override + List get props => []; +} + +class MunicipalitiesLoaded extends MunicipalitiesAdminState { + final List city; + + const MunicipalitiesLoaded({required this.city}); + @override + List get props => [city]; +} diff --git a/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart new file mode 100644 index 0000000..755c52b --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart @@ -0,0 +1,28 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/signatories.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'signatories_admin_event.dart'; +part 'signatories_admin_state.dart'; + +class SignatoriesAdminBloc + extends Bloc { + SignatoriesAdminBloc() : super(SignatoriesAdminInitial()) { + List signatories = []; + on((event, emit) async { + signatories = await SQLServices.instance.readAllSignatories(); + + emit(SignatoriesLoaded(signatories: signatories)); + }); + on((event, emit) async { + await SQLServices.instance.createSignatories(Signatories( + id: event.id, + signatoryId: event.signatoryId, + firstname: event.firstname, + middlename: event.middlename, + lastname: event.lastname)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_event.dart b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_event.dart new file mode 100644 index 0000000..2f8bd20 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_event.dart @@ -0,0 +1,40 @@ +part of 'signatories_admin_bloc.dart'; + +class SignatoriesAdminEvent extends Equatable { + const SignatoriesAdminEvent(); + + @override + List get props => []; +} + +class AddSignatories extends SignatoriesAdminEvent { + final int id; + final int signatoryId; + final String firstname; + final String middlename; + final String lastname; + + const AddSignatories({ + required this.id, + required this.signatoryId, + required this.firstname, + required this.middlename, + required this.lastname, + }); + + @override + List get props => [ + id, + signatoryId, + firstname, + middlename, + lastname, + ]; +} + +class LoadSignatories extends SignatoriesAdminEvent { + const LoadSignatories(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_state.dart b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_state.dart new file mode 100644 index 0000000..df9abe7 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/signatories/signatories_admin_state.dart @@ -0,0 +1,21 @@ +part of 'signatories_admin_bloc.dart'; + +class SignatoriesAdminState extends Equatable { + const SignatoriesAdminState(); + + @override + List get props => []; +} + +class SignatoriesAdminInitial extends SignatoriesAdminState { + @override + List get props => []; +} + +class SignatoriesLoaded extends SignatoriesAdminState { + final List signatories; + + const SignatoriesLoaded({required this.signatories}); + @override + List get props => [signatories]; +} diff --git a/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart new file mode 100644 index 0000000..5455282 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart @@ -0,0 +1,29 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/unit_construct.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'unit_construction_admin_event.dart'; +part 'unit_construction_admin_state.dart'; + +class UnitConstructionAdminBloc + extends Bloc { + UnitConstructionAdminBloc() : super(UnitConstructionAdminInitial()) { + List unit = []; + on((event, emit) async { + unit = await SQLServices.instance.readAllUnitConstruct(); + + emit(UnitConstructLoaded(unit: unit)); + }); + on((event, emit) async { + await SQLServices.instance.createUnitConstruction( + UnitConstruct( + id: event.id, + bldgType: event.bldgType, + building: event.building, + unitValue: event.unitValue), + ); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_event.dart b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_event.dart new file mode 100644 index 0000000..141103a --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_event.dart @@ -0,0 +1,37 @@ +part of 'unit_construction_admin_bloc.dart'; + +class UnitConstructionAdminEvent extends Equatable { + const UnitConstructionAdminEvent(); + + @override + List get props => []; +} + +class AddUnitConstruct extends UnitConstructionAdminEvent { + final int id; + final String bldgType; + final String building; + final String unitValue; + + const AddUnitConstruct({ + required this.id, + required this.bldgType, + required this.building, + required this.unitValue, + }); + + @override + List get props => [ + id, + bldgType, + building, + unitValue, + ]; +} + +class LoadUnitConstruct extends UnitConstructionAdminEvent { + const LoadUnitConstruct(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_state.dart b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_state.dart new file mode 100644 index 0000000..47c950b --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_state.dart @@ -0,0 +1,21 @@ +part of 'unit_construction_admin_bloc.dart'; + +class UnitConstructionAdminState extends Equatable { + const UnitConstructionAdminState(); + + @override + List get props => []; +} + +class UnitConstructionAdminInitial extends UnitConstructionAdminState { + @override + List get props => []; +} + +class UnitConstructLoaded extends UnitConstructionAdminState { + final List unit; + + const UnitConstructLoaded({required this.unit}); + @override + List get props => [unit]; +} diff --git a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart new file mode 100644 index 0000000..8565830 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart @@ -0,0 +1,78 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; + +part 'additional_items_offline_event.dart'; +part 'additional_items_offline_state.dart'; + +class AdditionalItemsOfflineBloc + extends Bloc { + AdditionalItemsOfflineBloc() : super(AdditionalItemsOfflineInitial()) { + List addItems = []; + on((event, emit) async { + emit(AdditionalItemsOfflineInitial()); + try { + emit(AdditionalItemsLoaded(addItem: addItems)); + } catch (e) { + emit(AdditionalItemsErrorState(e.toString())); + } + }); + on((event, emit) async { + emit(AdditionalItemsOfflineInitial()); + List> result = + await SQLServices.instance.getAdditionalItems(event.id); + + if (result.isNotEmpty) { + List locationList = + result.map((map) => AdditionalItems.fromJson(map)).toList(); + + emit(AdditionalItemsLoaded(addItem: locationList)); + } else { + print('No data found.'); + } + }); + + on((event, emit) async { + try { + AdditionalItems item = await SQLServices.instance.createAdditionalItems( + AdditionalItems( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + classId: event.classId, + className: event.className, + structType: event.structType, + unitValue: event.unitValue, + baseUnitValue: event.baseUnitValue, + area: event.area, + marketValue: event.marketValue, + depreciationRate: event.depreciationRate, + adjustedMarketVal: event.adjustedMarketVal, + amtDepreciation: event.amtDepreciation, + painted: event.painted == true ? '1' : '0', + secondhand: event.secondhand == true ? '1' : '0', + paintedUnitval: event.paintedUnitval, + secondhandUnitval: event.secondhandUnitval, + actualUse: event.actualUse)); + + print(item.toJson()); + + addItems.add(item); + + emit(AdditionalItemsLoaded(addItem: addItems)); + } catch (e) { + print(e.toString()); + } + }); + on((event, emit) async { + emit(ShowAddItemsScreen()); + }); + on((event, emit) async { + addItems = await SQLServices.instance.readAdditionalItems(); + emit(AdditionalItemsLoaded(addItem: addItems)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart new file mode 100644 index 0000000..4c5142e --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_event.dart @@ -0,0 +1,119 @@ +part of 'additional_items_offline_bloc.dart'; + +class AdditionalItemsOfflineEvent extends Equatable { + const AdditionalItemsOfflineEvent(); + + @override + List get props => []; +} + +class LoadAdditionalItems extends AdditionalItemsOfflineEvent { + final List items; + + const LoadAdditionalItems({this.items = const []}); + + @override + List get props => [items]; +} + +class LoadAdditionalItemsEdit extends AdditionalItemsOfflineEvent { + final List items; + final int? id; + + const LoadAdditionalItemsEdit({required this.items, this.id}); + + @override + List get props => [items]; +} + +class AddAdditionalItems extends AdditionalItemsOfflineEvent { + 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; + + const AddAdditionalItems({ + 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, + }); + + @override + List get props => [ + id, + bldgapprDetailsId, + classId, + className, + structType, + unitValue, + baseUnitValue, + area, + marketValue, + depreciationRate, + adjustedMarketVal, + amtDepreciation, + painted, + secondhand, + paintedUnitval, + secondhandUnitval, + actualUse + ]; +} + +class UpdateAdditionalItems extends AdditionalItemsOfflineEvent { + final AdditionalItems addItems; + const UpdateAdditionalItems({required this.addItems}); + @override + List get props => [addItems]; +} + +class FetchAdditionalItems extends AdditionalItemsOfflineEvent { + const FetchAdditionalItems(); + + @override + List get props => []; +} + +class FetchSpecificAdditionalItems extends AdditionalItemsOfflineEvent { + final int id; + const FetchSpecificAdditionalItems({required this.id}); + + @override + List get props => [id]; +} + +class DeleteAdditionalItems extends AdditionalItemsOfflineEvent { + final int id; + const DeleteAdditionalItems({required this.id}); + @override + List get props => [id]; +} + +class ShowAdditionalItems extends AdditionalItemsOfflineEvent {} diff --git a/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_state.dart b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_state.dart new file mode 100644 index 0000000..93864f5 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_state.dart @@ -0,0 +1,46 @@ +part of 'additional_items_offline_bloc.dart'; + +class AdditionalItemsOfflineState extends Equatable { + const AdditionalItemsOfflineState(); + + @override + List get props => []; +} + +class AdditionalItemsOfflineInitial extends AdditionalItemsOfflineState { + @override + List get props => []; +} + +class AdditionalItemsLoaded extends AdditionalItemsOfflineState { + final List addItem; + + const AdditionalItemsLoaded({required this.addItem}); + @override + List get props => [addItem]; +} + +class LoadSpecificAdditionalItems extends AdditionalItemsOfflineState { + final AdditionalItems addItem; + + const LoadSpecificAdditionalItems({required this.addItem}); + @override + List get props => [addItem]; +} + +class ShowAddItemsScreen extends AdditionalItemsOfflineState {} + +class AdditionalItemsErrorState extends AdditionalItemsOfflineState { + const AdditionalItemsErrorState(this.error); + final String error; + + @override + List get props => [error]; +} + +class AdditionalItemsDeletedState extends AdditionalItemsOfflineState { + final bool success; + const AdditionalItemsDeletedState({required this.success}); + @override + List get props => [success]; +} diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart new file mode 100644 index 0000000..e151994 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart @@ -0,0 +1,35 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/property_appraisal.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'bldg_appraisal_offline_event.dart'; +part 'bldg_appraisal_offline_state.dart'; + +class BldgAppraisalOfflineBloc + extends Bloc { + BldgAppraisalOfflineBloc() : super(BldgAppraisalOfflineInitial()) { + List appraisal = []; + on((event, emit) async { + await SQLServices.instance.createBldgAppraisal(PropertyAppraisal( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + dateCreated: event.dateCreated, + dateModified: event.dateModified, + unitconstructCost: event.unitconstructCost, + buildingCore: event.buildingCore, + unitconstructSubtotal: event.unitconstructSubtotal, + depreciationRate: event.depreciationRate, + depreciationCost: event.depreciationCost, + costAddItems: event.costAddItems, + addItemsSubtotal: event.addItemsSubtotal, + totalpercentDepreciation: event.totalpercentDepreciation, + marketValue: event.marketValue, + totalArea: event.totalArea, + actualUse: event.actualUse)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart new file mode 100644 index 0000000..6541288 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_event.dart @@ -0,0 +1,68 @@ +part of 'bldg_appraisal_offline_bloc.dart'; + +class BldgAppraisalOfflineEvent extends Equatable { + const BldgAppraisalOfflineEvent(); + + @override + List get props => []; +} + +class AddBldgAppraisal extends BldgAppraisalOfflineEvent { + 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; + final String actualUse; + + const AddBldgAppraisal( + {required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.dateCreated, + required this.dateModified, + required this.unitconstructCost, + required this.buildingCore, + required this.unitconstructSubtotal, + required this.depreciationRate, + required this.depreciationCost, + required this.costAddItems, + required this.addItemsSubtotal, + required this.totalpercentDepreciation, + required this.marketValue, + required this.totalArea, + required this.actualUse}); + + @override + List get props => [ + id, + bldgapprDetailsId, + assessedById, + assessedByName, + dateCreated, + dateModified, + unitconstructCost, + buildingCore, + unitconstructSubtotal, + depreciationRate, + depreciationCost, + costAddItems, + addItemsSubtotal, + totalpercentDepreciation, + marketValue, + totalArea, + actualUse + ]; +} diff --git a/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart new file mode 100644 index 0000000..07df647 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_state.dart @@ -0,0 +1,29 @@ +part of 'bldg_appraisal_offline_bloc.dart'; + +class BldgAppraisalOfflineState extends Equatable { + const BldgAppraisalOfflineState(); + + @override + List get props => []; +} + +class BldgAppraisalOfflineInitial extends BldgAppraisalOfflineState { + @override + List get props => []; +} + +class BldgAppraisalOfflineLoaded extends BldgAppraisalOfflineState { + final List appraisal; + + const BldgAppraisalOfflineLoaded({required this.appraisal}); + @override + List get props => [appraisal]; +} + +class LoadSpecificBldgAppraisalOffline extends BldgAppraisalOfflineState { + final PropertyAppraisal appraisal; + + const LoadSpecificBldgAppraisalOffline({required this.appraisal}); + @override + List get props => [appraisal]; +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart new file mode 100644 index 0000000..a88fa3b --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart @@ -0,0 +1,38 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/property_assessment.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'bldg_assessment_offline_event.dart'; +part 'bldg_assessment_offline_state.dart'; + +class BldgAssessmentOfflineBloc + extends Bloc { + BldgAssessmentOfflineBloc() : super(BldgAssessmentOfflineInitial()) { + List assessment = []; + on((event, emit) async { + await SQLServices.instance.createBldgAssessment(PropertyAssessment( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + actualUse: event.actualUse, + marketValue: event.marketValue, + assessmentLevel: event.assessmentLevel, + assessedValue: event.assessedValue, + taxable: event.taxable, + exempt: event.exempt, + qtr: event.qtr, + yr: event.yr, + appraisedbyName: event.appraisedbyName, + appraisedbyDate: event.appraisedbyDate, + recommendapprName: event.recommendapprName, + recommendapprDate: event.recommendapprDate, + approvedbyName: event.approvedbyName, + memoranda: event.memoranda, + swornstatementNo: event.swornstatementNo, + dateReceived: event.dateReceived, + entryDateAssessment: event.entryDateAssessment, + entryDateBy: event.entryDateBy)); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart new file mode 100644 index 0000000..6049057 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_event.dart @@ -0,0 +1,78 @@ +part of 'bldg_assessment_offline_bloc.dart'; + +class BldgAssessmentOfflineEvent extends Equatable { + const BldgAssessmentOfflineEvent(); + + @override + List get props => []; +} + +class AddBldgAssessment extends BldgAssessmentOfflineEvent { + 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; + + const AddBldgAssessment({ + 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, + }); + + @override + List get props => [ + id, + bldgapprDetailsId, + actualUse, + marketValue, + assessmentLevel, + assessedValue, + taxable, + exempt, + qtr, + yr, + appraisedbyName, + appraisedbyDate, + recommendapprName, + recommendapprDate, + approvedbyName, + memoranda, + swornstatementNo, + dateReceived, + entryDateAssessment, + entryDateBy, + ]; +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart new file mode 100644 index 0000000..ba0f778 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_state.dart @@ -0,0 +1,29 @@ +part of 'bldg_assessment_offline_bloc.dart'; + +class BldgAssessmentOfflineState extends Equatable { + const BldgAssessmentOfflineState(); + + @override + List get props => []; +} + +class BldgAssessmentOfflineInitial extends BldgAssessmentOfflineState { + @override + List get props => []; +} + +class BldgAssessmentOfflineLoaded extends BldgAssessmentOfflineState { + final List assessment; + + const BldgAssessmentOfflineLoaded({required this.assessment}); + @override + List get props => [assessment]; +} + +class LoadSpecificBldgAssessmentOffline extends BldgAssessmentOfflineState { + final PropertyAssessment assessment; + + const LoadSpecificBldgAssessmentOffline({required this.assessment}); + @override + List get props => [assessment]; +} diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart new file mode 100644 index 0000000..1765217 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart @@ -0,0 +1,59 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; + +part 'general_description_event.dart'; +part 'general_description_state.dart'; + +class GeneralDescriptionBloc + extends Bloc { + GeneralDescriptionBloc() : super(GeneralDescriptionInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createBldgGeneralDescription(GeneralDesc( + bldgapprDetailsId: event.bldgapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + bldgKind: event.bldgKind, + strucType: event.strucType, + bldgPermit: event.bldgPermit, + dateIssued: event.dateIssued.toString(), + cct: event.cct, + certCompletionIssued: event.certCompletionIssued.toString(), + certOccupancyIssued: event.certOccupancyIssued.toString(), + dateCompleted: event.dateCompleted.toString(), + dateOccupied: event.dateOccupied.toString(), + bldgAge: event.bldgAge, + noStoreys: event.noStoreys, + area1Stfloor: event.area1Stfloor, + area2Ndfloor: event.area2Ndfloor, + area3Rdfloor: event.area3Rdfloor, + area4Thfloor: event.area4Thfloor, + totalFloorArea: event.totalFloorArea, + floorSketch: event.floorSketch, + actualUse: event.actualUse)); + }); + on((event, emit) async { + List> result = + await SQLServices.instance.getGeneralDescription(event.id); + + if (result.isNotEmpty) { + List genDescList = + result.map((map) => GeneralDesc.fromJson2(map)).toList(); + + // Choose a specific element from locationList + GeneralDesc firstGenDesc = + genDescList.first; // You can change this to select a specific item + + print('location test result'); + print(firstGenDesc); + emit(SpecificGeneralDescriptionLoaded(gendesc: firstGenDesc)); + } else { + print('No data found.'); + } + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart new file mode 100644 index 0000000..5551f79 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart @@ -0,0 +1,92 @@ +part of 'general_description_bloc.dart'; + +class GeneralDescriptionEvent extends Equatable { + const GeneralDescriptionEvent(); + + @override + List get props => []; +} + +class AddGendesc extends GeneralDescriptionEvent { + final int id; + final int bldgapprDetailsId; + final String assessedById; + final String assessedByName; + final String bldgKind; + final String strucType; + final String bldgPermit; + final String dateIssued; + final String cct; + final String certCompletionIssued; + final String certOccupancyIssued; + final String dateCompleted; + final String dateOccupied; + final String bldgAge; + final String noStoreys; + final String area1Stfloor; + final String area2Ndfloor; + final String area3Rdfloor; + final String area4Thfloor; + final String totalFloorArea; + final dynamic floorSketch; + final String actualUse; + + const AddGendesc({ + required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.bldgKind, + required this.strucType, + required this.bldgPermit, + required this.dateIssued, + required this.cct, + required this.certCompletionIssued, + required this.certOccupancyIssued, + required this.dateCompleted, + required this.dateOccupied, + required this.bldgAge, + required this.noStoreys, + required this.area1Stfloor, + required this.area2Ndfloor, + required this.area3Rdfloor, + required this.area4Thfloor, + required this.totalFloorArea, + required this.floorSketch, + required this.actualUse, + }); + + @override + List get props => [ + id, + bldgapprDetailsId, + assessedById, + assessedByName, + bldgKind, + strucType, + bldgPermit, + dateIssued, + cct, + certCompletionIssued, + certOccupancyIssued, + dateCompleted, + dateOccupied, + bldgAge, + noStoreys, + area1Stfloor, + area2Ndfloor, + area3Rdfloor, + area4Thfloor, + totalFloorArea, + floorSketch, + actualUse, + ]; +} + +class FetchSingleGeneralDescription extends GeneralDescriptionEvent { + final int id; + const FetchSingleGeneralDescription({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_state.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_state.dart new file mode 100644 index 0000000..3a49f3b --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_state.dart @@ -0,0 +1,29 @@ +part of 'general_description_bloc.dart'; + +class GeneralDescriptionState extends Equatable { + const GeneralDescriptionState(); + + @override + List get props => []; +} + +class GeneralDescriptionInitial extends GeneralDescriptionState { + @override + List get props => []; +} + +class LocationLoaded extends GeneralDescriptionState { + final List gendesc; + + const LocationLoaded({required this.gendesc}); + @override + List get props => [gendesc]; +} + +class SpecificGeneralDescriptionLoaded extends GeneralDescriptionState { + final GeneralDesc gendesc; + + const SpecificGeneralDescriptionLoaded({required this.gendesc}); + @override + List get props => [gendesc]; +} diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart new file mode 100644 index 0000000..acbc897 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart @@ -0,0 +1,78 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +import '../../../../../model/passo/land_ref.dart'; +import '../../../../../model/passo/todo.dart'; +import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; + +part 'landref_location_event.dart'; +part 'landref_location_state.dart'; + +class LandrefLocationBloc + extends Bloc { + LandrefLocationBloc() : super(LandrefInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createBldgLandRef( + LandRef( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + owner: event.owner, + cloaNo: event.cloaNo, + lotNo: event.lotNo, + tdn: event.tdn, + area: event.area, + surveyNo: event.surveyNo, + blkNo: event.blkNo), + ); + }); + + // on((event, emit) async { + // await PropertyOwnerInfoServices.instance.update( + // todo: event.todo, + // ); + // }); + + // on((event, emit) async { + // landref = await PropertyOwnerInfoServices.instance.readAllTodos(); + // emit(LandrefLoaded(landref: landref)); + // }); + + on((event, emit) async { + List> result = + await SQLServices.instance.getLandRef(event.id); + + if (result.isNotEmpty) { + LandRef firstRow = LandRef( + id: result[0]["id"], + bldgapprDetailsId: result[0]["bldgapprDetailsId"], + assessedById: result[0]["assessedById"], + assessedByName: result[0]["assessedByName"], + dateCreated: DateTime.now(), + dateModified: DateTime.now(), + owner: result[0]["owner"], + cloaNo: result[0]["cloaNo"], + lotNo: result[0]["lotNo"], + tdn: result[0]["tdn"], + area: result[0]["area"], + surveyNo: result[0]["surveyNo"], + blkNo: result[0]["blkNo"], + ); + + print('landref test result'); + print(firstRow); + emit(SpecificLandrefLoaded(landref: firstRow)); + } else { + print('No data found.'); + } + }); + + // on((event, emit) async { + // await PropertyOwnerInfoServices.instance.delete(id: event.id); + // add(const FetchTodos()); + // }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart new file mode 100644 index 0000000..02b42f4 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart @@ -0,0 +1,80 @@ +part of 'landref_location_bloc.dart'; + +class LandrefLocationEvent extends Equatable { + const LandrefLocationEvent(); + + @override + List get props => []; +} + +class AddLandRef extends LandrefLocationEvent { + final int id; + final int bldgapprDetailsId; + final String assessedById; + final String assessedByName; + final dynamic owner; + final dynamic cloaNo; + final dynamic lotNo; + final dynamic tdn; + final dynamic area; + final dynamic surveyNo; + final dynamic blkNo; + + const AddLandRef({ + required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.owner, + required this.cloaNo, + required this.lotNo, + required this.tdn, + required this.area, + required this.surveyNo, + required this.blkNo, + }); + + @override + List get props => [ + id, + bldgapprDetailsId, + assessedById, + assessedByName, + owner, + cloaNo, + lotNo, + tdn, + area, + surveyNo, + blkNo + ]; +} + +class UpdateTodo extends LandrefLocationEvent { + final Todo todo; + const UpdateTodo({required this.todo}); + @override + List get props => [todo]; +} + +class FetchLanRef extends LandrefLocationEvent { + const FetchLanRef(); + + @override + List get props => []; +} + +class FetchSingleLandref extends LandrefLocationEvent { + final int id; + const FetchSingleLandref({required this.id}); + + @override + List get props => [id]; +} + +// class DeleteTodo extends LandrefLocationEvent { +// final int id; +// const DeleteTodo({required this.id}); +// @override +// List get props => [id]; +// } diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_state.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_state.dart new file mode 100644 index 0000000..4ae7a0d --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_state.dart @@ -0,0 +1,29 @@ +part of 'landref_location_bloc.dart'; + +class LandrefLocationState extends Equatable { + const LandrefLocationState(); + + @override + List get props => []; +} + +class LandrefInitial extends LandrefLocationState { + @override + List get props => []; +} + +class LandrefLoaded extends LandrefLocationState { + final List landref; + + const LandrefLoaded({required this.landref}); + @override + List get props => [landref]; +} + +class SpecificLandrefLoaded extends LandrefLocationState { + final LandRef landref; + + const SpecificLandrefLoaded({required this.landref}); + @override + List get props => [landref]; +} diff --git a/lib/bloc/offline/offline_passo/building/location/location_bloc.dart b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart new file mode 100644 index 0000000..d3324be --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart @@ -0,0 +1,47 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +import '../../../../../model/passo/bldg_loc.dart'; +import '../../../../../model/passo/todo.dart'; +import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; + +part 'location_event.dart'; +part 'location_state.dart'; + +class LocationBloc extends Bloc { + LocationBloc() : super(LocationInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createBldglocation(BldgLoc( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + assessedById: event.assessedById, + assessedByName: event.assessedByName, + street: event.street, + barangay: event.barangay, + municipality: event.municipality, + province: event.province, + )); + }); + on((event, emit) async { + List> result = + await SQLServices.instance.getLocation(event.id); + + if (result.isNotEmpty) { + List locationList = + result.map((map) => BldgLoc.fromJson(map)).toList(); + + // Choose a specific element from locationList + BldgLoc firstLocation = + locationList.first; // You can change this to select a specific item + + print('location test result'); + print(firstLocation); + emit(SpecificLocationLoaded(location: firstLocation)); + } else { + print('No data found.'); + } + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/location/location_event.dart b/lib/bloc/offline/offline_passo/building/location/location_event.dart new file mode 100644 index 0000000..94d3330 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/location/location_event.dart @@ -0,0 +1,70 @@ +part of 'location_bloc.dart'; + +class LocationEvent extends Equatable { + const LocationEvent(); + + @override + List get props => []; +} + +class AddLocation extends LocationEvent { + final int id; + final int bldgapprDetailsId; + final String assessedById; + final String assessedByName; + final String street; + final String barangay; + final String municipality; + final String province; + + const AddLocation({ + required this.id, + required this.bldgapprDetailsId, + required this.assessedById, + required this.assessedByName, + required this.street, + required this.barangay, + required this.municipality, + required this.province, + }); + + @override + List get props => [ + bldgapprDetailsId, + assessedById, + assessedByName, + street, + barangay, + municipality, + province, + ]; +} + +class UpdateTodo extends LocationEvent { + final Todo todo; + const UpdateTodo({required this.todo}); + @override + List get props => [todo]; +} + +class FetchLanRef extends LocationEvent { + const FetchLanRef(); + + @override + List get props => []; +} + +class FetchSingleLocation extends LocationEvent { + final int id; + const FetchSingleLocation({required this.id}); + + @override + List get props => [id]; +} + +// class DeleteTodo extends LocationEvent { +// final int id; +// const DeleteTodo({required this.id}); +// @override +// List get props => [id]; +// } diff --git a/lib/bloc/offline/offline_passo/building/location/location_state.dart b/lib/bloc/offline/offline_passo/building/location/location_state.dart new file mode 100644 index 0000000..ecc13ae --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/location/location_state.dart @@ -0,0 +1,29 @@ +part of 'location_bloc.dart'; + +class LocationState extends Equatable { + const LocationState(); + + @override + List get props => []; +} + +class LocationInitial extends LocationState { + @override + List get props => []; +} + +class LocationLoaded extends LocationState { + final List location; + + const LocationLoaded({required this.location}); + @override + List get props => [location]; +} + +class SpecificLocationLoaded extends LocationState { + final BldgLoc location; + + const SpecificLocationLoaded({required this.location}); + @override + List get props => [location]; +} diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart new file mode 100644 index 0000000..33f3ea4 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart @@ -0,0 +1,55 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../../model/passo/property_info.dart'; +import '../../../../../model/passo/todo.dart'; +import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; + +part 'crud_event.dart'; +part 'crud_state.dart'; + +class CrudBloc extends Bloc { + CrudBloc() : super(CrudInitial()) { + List todos = []; + on((event, emit) async { + await SQLServices.instance.createBldgOwner( + PropertyInfo( + transCode: event.transCode, + tdn: event.tdn, + pin: event.pin, + owner: event.owner, + address: event.address, + telno: event.telno, + tin: event.tin, + adminUser: event.adminUser, + adminAddress: event.adminAddress, + adminTelno: event.adminTelno, + adminTin: event.adminTin, + faasType: event.faasType, + assessedById: event.assessedById, + assessedByName: event.assessedByName), + ); + }); + + on((event, emit) async { + await PropertyOwnerInfoServices.instance.update( + todo: event.todo, + ); + }); + + on((event, emit) async { + todos = await SQLServices.instance.readAllBldgOwner(); + emit(DisplayTodos(todo: todos)); + }); + + // on((event, emit) async { + // Prop todo = await PropertyOwnerInfoServices.instance.readTodo(id: event.id); + // emit(DisplaySpecificTodo(todo: todo)); + // }); + + on((event, emit) async { + await SQLServices.instance.deleteBldgOwner(id: event.id); + add(const FetchTodos()); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart new file mode 100644 index 0000000..64198e6 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart @@ -0,0 +1,88 @@ +part of 'crud_bloc.dart'; + +abstract class CrudEvent extends Equatable { + const CrudEvent(); +} + +class AddTodo extends CrudEvent { + final String id; + 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; + final String assessedById; + final String assessedByName; + + const AddTodo( + {required this.id, + required this.transCode, + required this.tdn, + required this.pin, + required this.owner, + required this.address, + required this.telno, + required this.tin, + required this.adminUser, + required this.adminAddress, + required this.adminTelno, + required this.adminTin, + required this.faasType, + required this.assessedById, + required this.assessedByName}); + + @override + List get props => [ + id, + transCode, + tdn, + pin, + owner, + address, + telno, + tin, + adminUser, + adminAddress, + adminTelno, + adminTin, + faasType, + assessedById, + assessedByName + ]; +} + +class UpdateTodo extends CrudEvent { + final Todo todo; + const UpdateTodo({required this.todo}); + @override + List get props => [todo]; +} + +class FetchTodos extends CrudEvent { + const FetchTodos(); + + @override + List get props => []; +} + +class FetchSpecificTodo extends CrudEvent { + final int id; + const FetchSpecificTodo({required this.id}); + + @override + List get props => [id]; +} + +class DeleteTodo extends CrudEvent { + final int id; + const DeleteTodo({required this.id}); + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart new file mode 100644 index 0000000..cfa94de --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart @@ -0,0 +1,26 @@ +part of 'crud_bloc.dart'; + +abstract class CrudState extends Equatable { + const CrudState(); +} + +class CrudInitial extends CrudState { + @override + List get props => []; +} + +class DisplayTodos extends CrudState { + final List todo; + + const DisplayTodos({required this.todo}); + @override + List get props => [todo]; +} + +class DisplaySpecificTodo extends CrudState { + final Todo todo; + + const DisplaySpecificTodo({required this.todo}); + @override + List get props => [todo]; +} diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart new file mode 100644 index 0000000..1749177 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart @@ -0,0 +1,49 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/structural_materials_ii.dart'; +import '../../../../../model/passo/structureMaterial.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'structural_material_offline_event.dart'; +part 'structural_material_offline_state.dart'; + +class StructuralMaterialOfflineBloc extends Bloc { + StructuralMaterialOfflineBloc() : super(StructuralMaterialOfflineInitial()) { + List materials = []; + on((event, emit) async { + await SQLServices.instance.createStructuralMaterials(StructureMaterialsII( + id: event.id, + bldgapprDetailsId: event.bldgapprDetailsId, + foundation: event.foundation!.join(', ').split(', '), + columns: event.columns!.join(', ').split(', '), + beams: event.beams!.join(', ').split(', '), + trussFraming: event.trussFraming!.join(', ').split(', '), + roof: event.roof!.join(', ').split(', '), + flooring: event.flooring!.join(', ').split(', '), + walls: event.walls!.join(', ').split(', '), + others: event.others!.join(', ').split(', '), + )); + }); + on((event, emit) async { + List> result = + await SQLServices.instance.getStructuralMaterials(event.id); + + if (result.isNotEmpty) { + List materialList = + result.map((map) => StructureMaterials.fromJson(map)).toList(); + + // Choose a specific element from locationList + StructureMaterials firstMaterial = + materialList.first; // You can change this to select a specific item + + print('struct mat test result'); + print(firstMaterial); + emit(SpecificStructuralMaterialLoaded(materials: firstMaterial)); + } else { + print('No data found.'); + } + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart new file mode 100644 index 0000000..18ef539 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_event.dart @@ -0,0 +1,56 @@ +part of 'structural_material_offline_bloc.dart'; + +class StructuralMaterialOfflineEvent extends Equatable { + const StructuralMaterialOfflineEvent(); + + @override + List get props => []; +} + +class AddStructuralMaterial extends StructuralMaterialOfflineEvent { + final int id; + final int bldgapprDetailsId; + final List? foundation; + final List? columns; + final List? beams; + final List? trussFraming; + final List? roof; + final List? flooring; + final List? walls; + final List? others; + + const AddStructuralMaterial({ + required this.id, + required this.bldgapprDetailsId, + required this.foundation, + required this.columns, + required this.beams, + required this.trussFraming, + required this.roof, + required this.flooring, + required this.walls, + required this.others, + }); + + @override + List get props => [ + id, + bldgapprDetailsId, + ...?foundation, + ...?columns, + ...?beams, + ...?trussFraming, + ...?roof, + ...?flooring, + ...?walls, + ...?others + ]; +} + +class FetchSingleStructuralMaterial extends StructuralMaterialOfflineEvent { + final int id; + const FetchSingleStructuralMaterial({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_state.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_state.dart new file mode 100644 index 0000000..41ef1f3 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_state.dart @@ -0,0 +1,29 @@ +part of 'structural_material_offline_bloc.dart'; + +class StructuralMaterialOfflineState extends Equatable { + const StructuralMaterialOfflineState(); + + @override + List get props => []; +} + +class StructuralMaterialOfflineInitial extends StructuralMaterialOfflineState { + @override + List get props => []; +} + +class StructuralMaterialLoaded extends StructuralMaterialOfflineState { + final List materials; + + const StructuralMaterialLoaded({required this.materials}); + @override + List get props => [materials]; +} + +class SpecificStructuralMaterialLoaded extends StructuralMaterialOfflineState { + final StructureMaterials materials; + + const SpecificStructuralMaterialLoaded({required this.materials}); + @override + List get props => [materials]; +} diff --git a/lib/model/passo/additional_items.dart b/lib/model/passo/additional_items.dart index 9f89494..43571bf 100644 --- a/lib/model/passo/additional_items.dart +++ b/lib/model/passo/additional_items.dart @@ -24,8 +24,8 @@ class AdditionalItems { final dynamic depreciationRate; final dynamic adjustedMarketVal; final dynamic amtDepreciation; - final bool painted; - final bool secondhand; + final String painted; + final String secondhand; final dynamic paintedUnitval; final dynamic secondhandUnitval; final String actualUse; @@ -50,25 +50,64 @@ class AdditionalItems { required this.actualUse, }); + AdditionalItems copy({ + int? id, + int? bldgapprDetailsId, + int? classId, + String? className, + String? structType, + dynamic unitValue, + dynamic baseUnitValue, + dynamic area, + dynamic marketValue, + dynamic depreciationRate, + dynamic adjustedMarketVal, + dynamic amtDepreciation, + String? painted, + String? secondhand, + dynamic paintedUnitval, + dynamic secondhandUnitval, + String? actualUse, + }) { + return AdditionalItems( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + classId: classId ?? this.classId, + className: className ?? this.className, + structType: structType ?? this.structType, + unitValue: unitValue ?? this.unitValue, + baseUnitValue: baseUnitValue ?? this.baseUnitValue, + area: area ?? this.area, + marketValue: marketValue ?? this.marketValue, + depreciationRate: depreciationRate ?? this.depreciationRate, + adjustedMarketVal: adjustedMarketVal ?? this.adjustedMarketVal, + amtDepreciation: amtDepreciation ?? this.amtDepreciation, + painted: painted ?? this.painted, + secondhand: secondhand ?? this.secondhand, + paintedUnitval: paintedUnitval ?? this.paintedUnitval, + secondhandUnitval: secondhandUnitval ?? this.secondhandUnitval, + actualUse: actualUse ?? 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"], + bldgapprDetailsId: json["bldgapprDetailsId"], + classId: json["classId"], + className: json["className"], + structType: json["structType"], + unitValue: json["unitValue"], + baseUnitValue: json["baseUnitValue"], area: json["area"], - marketValue: json["market_value"], - depreciationRate: json["depreciation_rate"], - adjustedMarketVal: json["adjusted_market_val"], - amtDepreciation: json["amt_depreciation"], + marketValue: json["marketValue"], + depreciationRate: json["depreciationRate"], + adjustedMarketVal: json["adjustedMarketVal"], + amtDepreciation: json["amtDepreciation"], painted: json["painted"], secondhand: json["secondhand"], - paintedUnitval: json["painted_unitval"], - secondhandUnitval: json["secondhand_unitval"], - actualUse: json["actual_use"], + paintedUnitval: json["paintedUnitval"], + secondhandUnitval: json["secondhandUnitval"], + actualUse: json["actualUse"], ); Map toJson() => { diff --git a/lib/model/passo/barangay.dart b/lib/model/passo/barangay.dart index 6dacfa1..a60a06e 100644 --- a/lib/model/passo/barangay.dart +++ b/lib/model/passo/barangay.dart @@ -9,26 +9,52 @@ Brgy barangayFromJson(String str) => Brgy.fromJson(json.decode(str)); String barangayToJson(Brgy data) => json.encode(data.toJson()); class Brgy { + final int? id; final int? barangayId; final String? barangayCode; final String? cityCode; final String? barangayDescription; Brgy({ + this.id, this.barangayId, this.barangayCode, this.cityCode, this.barangayDescription, }); + Brgy copy( + {int? id, + int? barangayId, + String? barangayCode, + String? cityCode, + String? barangayDescription}) { + return Brgy( + id: id ?? this.id, + barangayId: barangayId ?? this.barangayId, + barangayCode: barangayCode ?? this.barangayCode, + cityCode: cityCode ?? this.cityCode, + barangayDescription: barangayDescription ?? this.barangayDescription); + } + factory Brgy.fromJson(Map json) => Brgy( + id: json["id"], barangayId: json["barangay_id"], barangayCode: json["barangay_code"], cityCode: json["city_code"], barangayDescription: json["barangay_description"], ); + factory Brgy.fromJson2(Map json) => Brgy( + id: json["id"], + barangayId: json["barangayId"], + barangayCode: json["barangayCode"], + cityCode: json["cityCode"], + barangayDescription: json["barangayDescription"], + ); + Map toJson() => { + "id": id, "barangay_id": barangayId, "barangay_code": barangayCode, "city_code": cityCode, diff --git a/lib/model/passo/bldg_loc.dart b/lib/model/passo/bldg_loc.dart index 06714fb..d5a575a 100644 --- a/lib/model/passo/bldg_loc.dart +++ b/lib/model/passo/bldg_loc.dart @@ -33,6 +33,31 @@ class BldgLoc { this.province, }); + BldgLoc copy({ + int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + DateTime? dateCreated, + DateTime? dateModified, + dynamic street, + dynamic barangay, + dynamic municipality, + dynamic province, + }) { + return BldgLoc( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + street: street ?? this.street, + barangay: barangay ?? this.barangay, + municipality: municipality ?? this.municipality, + province: province ?? this.province); + } + factory BldgLoc.fromJson(Map json) => BldgLoc( id: json["id"], bldgapprDetailsId: json["bldgappr_details_id"], diff --git a/lib/model/passo/city.dart b/lib/model/passo/city.dart index eb22f22..6d4eec0 100644 --- a/lib/model/passo/city.dart +++ b/lib/model/passo/city.dart @@ -9,20 +9,37 @@ City cityFromJson(String str) => City.fromJson(json.decode(str)); String cityToJson(City data) => json.encode(data.toJson()); class City { + final int? id; final String? cityCode; final String? cityDescription; City({ + this.id, this.cityCode, this.cityDescription, }); + City copy({int? id, String? cityCode, String? cityDescription}) { + return City( + id: id ?? this.id, + cityCode: cityCode ?? this.cityCode, + cityDescription: cityDescription ?? this.cityDescription); + } + factory City.fromJson(Map json) => City( + id: json["id"], cityCode: json["city_code"], cityDescription: json["city_description"], ); + factory City.fromJson2(Map json) => City( + id: json["id"], + cityCode: json["cityCode"], + cityDescription: json["cityDescription"], + ); + Map toJson() => { + "id": id, "city_code": cityCode, "city_description": cityDescription, }; diff --git a/lib/model/passo/class_components _offline.dart b/lib/model/passo/class_components _offline.dart new file mode 100644 index 0000000..71b777a --- /dev/null +++ b/lib/model/passo/class_components _offline.dart @@ -0,0 +1,156 @@ +// To parse this JSON data, do +// +// final classComponents = classComponentsFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +ClassComponentsOffline classComponentsFromJson(String str) => + ClassComponentsOffline.fromJson(json.decode(str)); + +String classComponentsToJson(ClassComponentsOffline data) => + json.encode(data.toJson()); + +class ClassComponentsOffline { + 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 int? withoutBucc; + + ClassComponentsOffline({ + this.id, + this.componentName, + this.minBaseUnitvalPercent, + this.maxBaseUnitvalPercent, + this.minUnitvalSqrmtr, + this.maxUnitvalSqrmtr, + this.minAddBaseunitval, + this.maxAddBaseunitval, + this.minDeductBaserate, + this.maxDeductBaserate, + this.minLinearMeter, + this.maxLinearMeter, + this.minSpacing, + this.maxSpacing, + this.roughFinish, + this.highFinish, + this.withoutBucc, + }); + + ClassComponentsOffline copy({ + int? id, + String? componentName, + String? minBaseUnitvalPercent, + String? maxBaseUnitvalPercent, + String? minUnitvalSqrmtr, + String? maxUnitvalSqrmtr, + String? minAddBaseunitval, + String? maxAddBaseunitval, + String? minDeductBaserate, + String? maxDeductBaserate, + String? minLinearMeter, + String? maxLinearMeter, + String? minSpacing, + String? maxSpacing, + String? roughFinish, + String? highFinish, + int? withoutBucc, + }) { + return ClassComponentsOffline( + id: id ?? this.id, + componentName: componentName ?? this.componentName, + minBaseUnitvalPercent: + minBaseUnitvalPercent ?? this.minBaseUnitvalPercent, + maxBaseUnitvalPercent: + maxBaseUnitvalPercent ?? this.maxBaseUnitvalPercent, + minUnitvalSqrmtr: minUnitvalSqrmtr ?? this.minUnitvalSqrmtr, + maxUnitvalSqrmtr: maxUnitvalSqrmtr ?? this.maxUnitvalSqrmtr, + minAddBaseunitval: minAddBaseunitval ?? this.minAddBaseunitval, + maxAddBaseunitval: maxAddBaseunitval ?? this.maxAddBaseunitval, + minDeductBaserate: minDeductBaserate ?? this.minDeductBaserate, + maxDeductBaserate: maxDeductBaserate ?? this.maxDeductBaserate, + minLinearMeter: minLinearMeter ?? this.minLinearMeter, + maxLinearMeter: maxLinearMeter ?? this.maxLinearMeter, + minSpacing: minSpacing ?? this.minSpacing, + maxSpacing: maxSpacing ?? this.maxSpacing, + roughFinish: roughFinish ?? this.roughFinish, + highFinish: highFinish ?? this.highFinish, + withoutBucc: withoutBucc ?? this.withoutBucc, + ); + } + + factory ClassComponentsOffline.fromJson(Map json) => + ClassComponentsOffline( + 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"], + ); + + factory ClassComponentsOffline.fromJson2(Map json) => + ClassComponentsOffline( + id: json["id"], + componentName: json["componentName"], + minBaseUnitvalPercent: json["minBaseUnitvalPercent"], + maxBaseUnitvalPercent: json["maxBaseUnitvalPercent"], + minUnitvalSqrmtr: json["minUnitvalSqrmtr"], + maxUnitvalSqrmtr: json["maxUnitvalSqrmtr"], + minAddBaseunitval: json["minAddBaseunitval"], + maxAddBaseunitval: json["maxAddBaseunitval"], + minDeductBaserate: json["minDeductBaserate"], + maxDeductBaserate: json["maxDeductBaserate"], + minLinearMeter: json["minLinearMeter"], + maxLinearMeter: json["maxLinearMeter"], + minSpacing: json["minSpacing"], + maxSpacing: json["maxSpacing"], + roughFinish: json["roughFinish"], + highFinish: json["highFinish"], + withoutBucc: json["withoutBucc"], + ); + + 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 index 68002a5..0f05141 100644 --- a/lib/model/passo/general_description.dart +++ b/lib/model/passo/general_description.dart @@ -14,19 +14,19 @@ class GeneralDesc { final int? bldgapprDetailsId; final String? assessedById; final String? assessedByName; - final DateTime? dateCreated; - final DateTime? dateModified; + final String? dateCreated; + final String? dateModified; final String? bldgKind; final String? strucType; final String? bldgPermit; - final DateTime? dateIssued; + final String? dateIssued; final String? cct; - final DateTime? certCompletionIssued; - final DateTime? certOccupancyIssued; - final DateTime? dateCompleted; - final DateTime? dateOccupied; - final int? bldgAge; - final int? noStoreys; + final String? certCompletionIssued; + final String? certOccupancyIssued; + final String? dateCompleted; + final String? dateOccupied; + final String? bldgAge; + final String? noStoreys; final String? area1Stfloor; final String? area2Ndfloor; final String? area3Rdfloor; @@ -62,36 +62,75 @@ class GeneralDesc { this.actualUse, }); + GeneralDesc copy({ + int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + String? dateCreated, + String? dateModified, + String? bldgKind, + String? strucType, + String? bldgPermit, + String? dateIssued, + String? cct, + String? certCompletionIssued, + String? certOccupancyIssued, + String? dateCompleted, + String? dateOccupied, + String? bldgAge, + String? noStoreys, + String? area1Stfloor, + String? area2Ndfloor, + String? area3Rdfloor, + String? area4Thfloor, + String? totalFloorArea, + dynamic floorSketch, + String? actualUse, + }) { + return GeneralDesc( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + bldgKind: bldgKind ?? this.bldgKind, + strucType: strucType ?? this.strucType, + bldgPermit: bldgPermit ?? this.bldgPermit, + dateIssued: dateIssued ?? this.dateIssued, + cct: cct ?? this.cct, + certCompletionIssued: certCompletionIssued ?? this.certCompletionIssued, + certOccupancyIssued: certOccupancyIssued ?? this.certOccupancyIssued, + dateCompleted: dateCompleted ?? this.dateCompleted, + dateOccupied: dateOccupied ?? this.dateOccupied, + bldgAge: bldgAge ?? this.bldgAge, + noStoreys: noStoreys ?? this.noStoreys, + area1Stfloor: area1Stfloor ?? this.area1Stfloor, + area2Ndfloor: area2Ndfloor ?? this.area2Ndfloor, + area3Rdfloor: area3Rdfloor ?? this.area3Rdfloor, + area4Thfloor: area4Thfloor ?? this.area4Thfloor, + totalFloorArea: totalFloorArea ?? this.totalFloorArea, + floorSketch: floorSketch ?? this.floorSketch, + actualUse: actualUse ?? 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"]), + dateCreated: json["date_created"], + dateModified: 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"]), + dateIssued: 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"]), + certCompletionIssued: json["cert_completion_issued"], + certOccupancyIssued: json["cert_occupancy_issued"], + dateCompleted: json["date_completed"], + dateOccupied: json["date_occupied"], bldgAge: json["bldg_age"], noStoreys: json["no_storeys"], area1Stfloor: json["area_1stfloor"], @@ -103,27 +142,49 @@ class GeneralDesc { actualUse: json["actual_use"], ); + factory GeneralDesc.fromJson2(Map json) => GeneralDesc( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"], + dateModified: json["dateModified"], + bldgKind: json["bldgKind"], + strucType: json["strucType"], + bldgPermit: json["bldgPermit"], + dateIssued: json["dateIssued"], + cct: json["cct"], + certCompletionIssued: json["certCompletionIssued"], + certOccupancyIssued: json["certOccupancyIssued"], + dateCompleted: json["dateCompleted"], + dateOccupied: json["dateOccupied"], + bldgAge: json["bldgAge"], + noStoreys: json["noStoreys"], + area1Stfloor: json["area1Stfloor"], + area2Ndfloor: json["area2Ndfloor"], + area3Rdfloor: json["area3Rdfloor"], + area4Thfloor: json["area4Thfloor"], + totalFloorArea: json["totalFloorArea"], + floorSketch: json["floorSketch"], + actualUse: json["actualUse"], + ); + Map toJson() => { "id": id, "bldgappr_details_id": bldgapprDetailsId, "assessed_by_id": assessedById, "assessed_by_name": assessedByName, - "date_created": dateCreated?.toIso8601String(), - "date_modified": dateModified?.toIso8601String(), + "date_created": dateCreated, + "date_modified": dateModified, "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')}", + "date_issued": dateIssued, "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')}", + "cert_completion_issued": certCompletionIssued, + "cert_occupancy_issued": certOccupancyIssued, + "date_completed": dateCompleted, + "date_occupied": dateOccupied, "bldg_age": bldgAge, "no_storeys": noStoreys, "area_1stfloor": area1Stfloor, diff --git a/lib/model/passo/land_ref.dart b/lib/model/passo/land_ref.dart index 8f4649d..f851337 100644 --- a/lib/model/passo/land_ref.dart +++ b/lib/model/passo/land_ref.dart @@ -39,6 +39,38 @@ class LandRef { this.blkNo, }); + LandRef copy({ + int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + DateTime? dateCreated, + DateTime? dateModified, + String? owner, + String? cloaNo, + String? lotNo, + String? tdn, + String? area, + String? surveyNo, + String? blkNo, + }) { + return LandRef( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + owner: owner ?? this.owner, + cloaNo: cloaNo ?? this.cloaNo, + lotNo: lotNo ?? this.lotNo, + tdn: tdn ?? this.tdn, + area: area ?? this.area, + surveyNo: surveyNo ?? this.surveyNo, + blkNo: blkNo ?? this.blkNo, + ); + } + factory LandRef.fromJson(Map json) => LandRef( id: json["id"], bldgapprDetailsId: json["bldgappr_details_id"], @@ -59,6 +91,26 @@ class LandRef { blkNo: json["blk_no"], ); + factory LandRef.fromJson2(Map json) => LandRef( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + assessedById: json["assessedById"], + assessedByName: json["assessedByName"], + dateCreated: json["dateCreated"] == null + ? null + : DateTime.parse(json["dateCreated"]), + dateModified: json["dateModified"] == null + ? null + : DateTime.parse(json["dateModified"]), + owner: json["owner"], + cloaNo: json["cloaNo"], + lotNo: json["lotNo"], + tdn: json["tdn"], + area: json["area"], + surveyNo: json["surveyNo"], + blkNo: json["blkNo"], + ); + Map toJson() => { "id": id, "bldgappr_details_id": bldgapprDetailsId, diff --git a/lib/model/passo/memoranda.dart b/lib/model/passo/memoranda.dart index 8c629fd..273cd35 100644 --- a/lib/model/passo/memoranda.dart +++ b/lib/model/passo/memoranda.dart @@ -19,12 +19,29 @@ class Memoranda { this.memoranda, }); + Memoranda copy({ + int? id, + String? code, + String? memoranda, + }) { + return Memoranda( + id: id ?? this.id, + code: code ?? this.code, + memoranda: memoranda ?? this.memoranda); + } + factory Memoranda.fromJson(Map json) => Memoranda( id: json["id"], code: json["code"], memoranda: json["memoranda"], ); + factory Memoranda.fromJson2(Map json) => Memoranda( + id: json["id"], + code: json["code"], + memoranda: json["memoranda"], + ); + Map toJson() => { "id": id, "code": code, diff --git a/lib/model/passo/property_appraisal.dart b/lib/model/passo/property_appraisal.dart index 24271b0..4a3bd07 100644 --- a/lib/model/passo/property_appraisal.dart +++ b/lib/model/passo/property_appraisal.dart @@ -48,6 +48,45 @@ class PropertyAppraisal { this.totalArea, this.actualUse}); + PropertyAppraisal copy({ + int? id, + int? bldgapprDetailsId, + String? assessedById, + String? assessedByName, + DateTime? dateCreated, + DateTime? dateModified, + String? unitconstructCost, + String? buildingCore, + String? unitconstructSubtotal, + String? depreciationRate, + String? depreciationCost, + String? costAddItems, + String? addItemsSubtotal, + String? totalpercentDepreciation, + String? marketValue, + String? totalArea, + String? actualUse, + }) => + PropertyAppraisal( + id: this.id, + bldgapprDetailsId: bldgapprDetailsId, + assessedById: assessedById, + assessedByName: assessedByName, + dateCreated: dateCreated, + dateModified: dateModified, + unitconstructCost: unitconstructCost, + buildingCore: buildingCore, + unitconstructSubtotal: unitconstructSubtotal, + depreciationRate: depreciationRate, + depreciationCost: depreciationCost, + costAddItems: costAddItems, + addItemsSubtotal: addItemsSubtotal, + totalpercentDepreciation: totalpercentDepreciation, + marketValue: marketValue, + totalArea: totalArea, + actualUse: actualUse, + ); + factory PropertyAppraisal.fromJson(Map json) => PropertyAppraisal( id: json["id"], diff --git a/lib/model/passo/property_assessment.dart b/lib/model/passo/property_assessment.dart index fb91bff..db53ccd 100644 --- a/lib/model/passo/property_assessment.dart +++ b/lib/model/passo/property_assessment.dart @@ -56,6 +56,51 @@ class PropertyAssessment { required this.entryDateBy, }); + PropertyAssessment copy({ + int? id, + int? bldgapprDetailsId, + String? actualUse, + String? marketValue, + String? assessmentLevel, + String? assessedValue, + bool? taxable, + bool? exempt, + int? qtr, + int? yr, + String? appraisedbyName, + DateTime? appraisedbyDate, + String? recommendapprName, + DateTime? recommendapprDate, + String? approvedbyName, + String? memoranda, + String? swornstatementNo, + DateTime? dateReceived, + DateTime? entryDateAssessment, + String? entryDateBy, + }) => + PropertyAssessment( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + actualUse: actualUse ?? this.actualUse, + marketValue: marketValue ?? this.marketValue, + assessmentLevel: assessmentLevel ?? this.assessmentLevel, + assessedValue: assessedValue ?? this.assessedValue, + taxable: taxable ?? this.taxable, + exempt: exempt ?? this.exempt, + qtr: qtr ?? this.qtr, + yr: yr ?? this.yr, + appraisedbyName: appraisedbyName ?? this.appraisedbyName, + appraisedbyDate: appraisedbyDate ?? this.appraisedbyDate, + recommendapprName: recommendapprName ?? this.recommendapprName, + recommendapprDate: recommendapprDate ?? this.recommendapprDate, + approvedbyName: approvedbyName ?? this.approvedbyName, + memoranda: memoranda ?? this.memoranda, + swornstatementNo: swornstatementNo ?? this.swornstatementNo, + dateReceived: dateReceived ?? this.dateReceived, + entryDateAssessment: entryDateAssessment ?? this.entryDateAssessment, + entryDateBy: entryDateBy ?? this.entryDateBy, + ); + factory PropertyAssessment.fromJson(Map json) => PropertyAssessment( id: json["id"], diff --git a/lib/model/passo/property_info.dart b/lib/model/passo/property_info.dart index 68406e2..69b2c45 100644 --- a/lib/model/passo/property_info.dart +++ b/lib/model/passo/property_info.dart @@ -48,16 +48,55 @@ class PropertyInfo { this.faasType, }); + PropertyInfo copy({ + int? id, + String? assessedById, + String? assessedByName, + DateTime? dateCreated, + DateTime? dateModified, + String? transCode, + String? tdn, + String? pin, + String? owner, + String? address, + String? telno, + String? tin, + String? adminUser, + String? adminAddress, + String? adminTelno, + String? adminTin, + String? faasType, + }) => + PropertyInfo( + id: id ?? this.id, + assessedById: assessedById ?? this.assessedById, + assessedByName: assessedByName ?? this.assessedByName, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + transCode: transCode ?? this.transCode, + tdn: tdn ?? this.tdn, + pin: pin ?? this.pin, + owner: owner ?? this.owner, + address: address ?? this.address, + telno: telno ?? this.telno, + tin: tin ?? this.tin, + adminUser: adminUser ?? this.adminUser, + adminAddress: adminAddress ?? this.adminAddress, + adminTelno: adminTelno ?? this.adminTelno, + adminTin: adminTin ?? this.adminTin, + faasType: faasType ?? 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"]), + // 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"], @@ -72,6 +111,26 @@ class PropertyInfo { faasType: json["faas_type"], ); + factory PropertyInfo.fromMap(Map map) => PropertyInfo( + id: map["id"], + assessedById: map["assessedById"], + assessedByName: map["assessedByName"], + dateCreated: map["dateCreated"], + dateModified: map["dateModified"], + transCode: map["transCode"], + tdn: map["tdn"], + pin: map["pin"], + owner: map["owner"], + address: map["address"], + telno: map["telno"], + tin: map["tin"], + adminUser: map["adminUser"], + adminAddress: map["adminUser"], + adminTelno: map["adminTelno"], + adminTin: map["adminTin"], + faasType: map["faasType"], + ); + Map toJson() => { "id": id, "assessed_by_id": assessedById, diff --git a/lib/model/passo/signatories.dart b/lib/model/passo/signatories.dart index 641f491..be09b44 100644 --- a/lib/model/passo/signatories.dart +++ b/lib/model/passo/signatories.dart @@ -24,6 +24,20 @@ class Signatories { required this.lastname, }); + Signatories copy( + {int? id, + int? signatoryId, + String? firstname, + String? middlename, + String? lastname}) { + return Signatories( + id: id ?? this.id, + signatoryId: signatoryId ?? this.signatoryId, + firstname: firstname ?? this.firstname, + middlename: middlename ?? this.middlename, + lastname: lastname ?? this.lastname); + } + factory Signatories.fromJson(Map json) => Signatories( id: json["id"], signatoryId: json["signatory_id"], @@ -32,6 +46,14 @@ class Signatories { lastname: json["lastname"], ); + factory Signatories.fromJson2(Map json) => Signatories( + id: json["id"], + signatoryId: json["signatoryId"], + firstname: json["firstname"], + middlename: json["middlename"], + lastname: json["lastname"], + ); + Map toJson() => { "id": id, "signatory_id": signatoryId, diff --git a/lib/model/passo/structural_materials_ii.dart b/lib/model/passo/structural_materials_ii.dart index cfa3ec2..d73f283 100644 --- a/lib/model/passo/structural_materials_ii.dart +++ b/lib/model/passo/structural_materials_ii.dart @@ -13,6 +13,7 @@ String structureMaterialsIiToJson(StructureMaterialsII data) => class StructureMaterialsII { final int? id; + final int? bldgapprDetailsId; final List? foundation; final List? columns; final List? beams; @@ -24,6 +25,7 @@ class StructureMaterialsII { StructureMaterialsII( {this.id, + this.bldgapprDetailsId, this.foundation, this.columns, this.beams, @@ -36,6 +38,7 @@ class StructureMaterialsII { factory StructureMaterialsII.fromJson(Map json) => StructureMaterialsII( id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], foundation: List.from(json["foundation"].map((x) => x)), columns: List.from(json["columns"].map((x) => x)), beams: List.from(json["beams"].map((x) => x)), @@ -46,8 +49,46 @@ class StructureMaterialsII { others: List.from(json["others"].map((x) => x)), ); + factory StructureMaterialsII.fromJson2(Map json) => + StructureMaterialsII( + id: json["id"], + bldgapprDetailsId: json["bldgapprDetailsId"], + 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["trussFraming"].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)), + ); + + StructureMaterialsII copy( + {int? id, + int? bldgapprDetailsId, + List? foundation, + List? columns, + List? beams, + List? trussFraming, + List? roof, + List? flooring, + List? walls, + List? others}) => + StructureMaterialsII( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + foundation: foundation ?? this.foundation, + columns: columns ?? this.columns, + beams: beams ?? this.beams, + trussFraming: trussFraming ?? this.trussFraming, + roof: roof ?? this.roof, + flooring: flooring ?? this.flooring, + walls: walls ?? this.walls, + others: others ?? this.others); + Map toJson() => { "id": id, + "bldgapprDetailsId": bldgapprDetailsId, "foundation": List.from(foundation!.map((x) => x)), "columns": List.from(columns!.map((x) => x)), "beams": List.from(beams!.map((x) => x)), diff --git a/lib/model/passo/structureMaterial.dart b/lib/model/passo/structureMaterial.dart index 4c07c23..783a2a5 100644 --- a/lib/model/passo/structureMaterial.dart +++ b/lib/model/passo/structureMaterial.dart @@ -13,6 +13,7 @@ String structureMaterialsToJson(StructureMaterials data) => class StructureMaterials { final int? id; + final int? bldgapprDetailsId; final String? foundation; final String? columns; final String? beams; @@ -20,32 +21,59 @@ class StructureMaterials { final String? roof; final String? flooring; final String? walls; + final String? others; - StructureMaterials({ - this.id, - this.foundation, - this.columns, - this.beams, - this.trussFraming, - this.roof, - this.flooring, - this.walls, - }); + StructureMaterials( + {this.id, + this.bldgapprDetailsId, + this.foundation, + this.columns, + this.beams, + this.trussFraming, + this.roof, + this.flooring, + this.walls, + this.others}); + + StructureMaterials copy( + {int? id, + int? bldgapprDetailsId, + String? foundation, + String? columns, + String? beams, + String? trussFraming, + String? roof, + String? flooring, + String? walls, + String? others}) => + StructureMaterials( + id: id ?? this.id, + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + foundation: foundation ?? this.foundation, + columns: columns ?? this.columns, + beams: beams ?? this.beams, + trussFraming: trussFraming ?? this.trussFraming, + roof: roof ?? this.roof, + flooring: flooring ?? this.flooring, + walls: walls ?? this.walls, + others: others ?? this.others); 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"], - ); + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + foundation: json["foundation"], + columns: json["columns"], + beams: json["beams"], + trussFraming: json["truss_framing"], + roof: json["roof"], + flooring: json["flooring"], + walls: json["walls"], + others: json["others"]); Map toJson() => { "id": id, + "bldgappr_details_id": bldgapprDetailsId, "foundation": foundation, "columns": columns, "beams": beams, @@ -53,5 +81,6 @@ class StructureMaterials { "roof": roof, "flooring": flooring, "walls": walls, + "others": others }; } diff --git a/lib/model/passo/todo.dart b/lib/model/passo/todo.dart new file mode 100644 index 0000000..a4110d4 --- /dev/null +++ b/lib/model/passo/todo.dart @@ -0,0 +1,68 @@ +const String todoTable = 'todos'; + +class TodoFields { + static final List values = [ + /// Add all fields + id, isImportant, number, title, description, time + ]; + + static const String id = '_id'; + static const String isImportant = 'isImportant'; + static const String number = 'number'; + static const String title = 'title'; + static const String description = 'description'; + static const String time = 'time'; +} + +class Todo { + final int? id; + final bool isImportant; + final int number; + final String title; + final String description; + final DateTime createdTime; + + const Todo({ + this.id, + required this.isImportant, + required this.number, + required this.title, + required this.description, + required this.createdTime, + }); + + Todo copy({ + int? id, + bool? isImportant, + int? number, + String? title, + String? description, + DateTime? createdTime, + }) => + Todo( + id: id ?? this.id, + isImportant: isImportant ?? this.isImportant, + number: number ?? this.number, + title: title ?? this.title, + description: description ?? this.description, + createdTime: createdTime ?? this.createdTime, + ); + + static Todo fromJson(Map json) => Todo( + id: json[TodoFields.id] as int?, + isImportant: json[TodoFields.isImportant] == 1, + number: json[TodoFields.number] as int, + title: json[TodoFields.title] as String, + description: json[TodoFields.description] as String, + createdTime: DateTime.parse(json[TodoFields.time] as String), + ); + + Map toJson() => { + TodoFields.id: id, + TodoFields.title: title, + TodoFields.isImportant: isImportant ? 1 : 0, + TodoFields.number: number, + TodoFields.description: description, + TodoFields.time: createdTime.toIso8601String(), + }; +} diff --git a/lib/model/passo/unit_construct.dart b/lib/model/passo/unit_construct.dart index bc97fa3..bb88027 100644 --- a/lib/model/passo/unit_construct.dart +++ b/lib/model/passo/unit_construct.dart @@ -22,6 +22,26 @@ class UnitConstruct { required this.unitValue, }); + UnitConstruct copy({ + int? id, + String? bldgType, + String? building, + String? unitValue, + }) { + return UnitConstruct( + id: id ?? this.id, + bldgType: bldgType ?? this.bldgType, + building: building ?? this.building, + unitValue: unitValue ?? this.unitValue); + } + + factory UnitConstruct.fromJson2(Map json) => UnitConstruct( + id: json["id"], + bldgType: json["bldgType"], + building: json["building"], + unitValue: json["unitValue"], + ); + factory UnitConstruct.fromJson(Map json) => UnitConstruct( id: json["id"], bldgType: json["bldg_type"], diff --git a/lib/screens/offline/homepage/module_screen.dart b/lib/screens/offline/homepage/module_screen.dart index 3055108..a48e2f9 100644 --- a/lib/screens/offline/homepage/module_screen.dart +++ b/lib/screens/offline/homepage/module_screen.dart @@ -6,10 +6,13 @@ import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:unit2/bloc/offline/offline_bloc/offline_bloc.dart'; import 'package:unit2/model/offline/offlane_modules.dart'; +import 'package:unit2/screens/offline/passo/passo_offline_dashboard.dart'; import 'package:unit2/screens/passo/passo_dashboard.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/shared_card_label.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import '../passo/passo_main_dashboard.dart'; + class OfflineModuleScreen extends StatelessWidget { const OfflineModuleScreen({super.key}); @@ -56,7 +59,7 @@ class OfflineModuleScreen extends StatelessWidget { ontap: () { Navigator.push(context, MaterialPageRoute(builder: ((context) { - return PassoDashBoard(); + return const PassoOfflineMainScreen(); }))); })) .toList()), diff --git a/lib/screens/offline/passo/admin/admin_main_screen.dart b/lib/screens/offline/passo/admin/admin_main_screen.dart new file mode 100644 index 0000000..0f661c9 --- /dev/null +++ b/lib/screens/offline/passo/admin/admin_main_screen.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fluttericon/elusive_icons.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/screens/offline/passo/admin/barangay.dart'; +import 'package:unit2/screens/offline/passo/admin/class_components.dart'; +import 'package:unit2/screens/offline/passo/admin/memoranda.dart'; +import 'package:unit2/screens/offline/passo/admin/municipalities.dart'; +import 'package:unit2/screens/offline/passo/admin/signatories.dart'; +import 'package:unit2/screens/offline/passo/admin/unit_construction.dart'; +import 'package:unit2/screens/profile/components/main_menu.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +class AdminMainScreen extends StatefulWidget { + const AdminMainScreen({super.key}); + + @override + _AdminMainScreen createState() => _AdminMainScreen(); +} + +class _AdminMainScreen extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("PASSO Admin"), + centerTitle: true, + ), + body: ListView( + children: [ + MainMenu( + icon: Elusive.group, + title: "Municipalities", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + MunicipalitiesAdminBloc()..add(LoadMunicipalities()), + child: const MunicipalitiesAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.group, + title: "Barangays", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => BarangayAdminBloc()..add(LoadBarangay()), + child: const BarangayAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.group, + title: "Class Components", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + ClassComponentsAdminBloc()..add(LoadClassComponents()), + child: const ClassComponentsAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.group, + title: "Structural Types", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + UnitConstructionAdminBloc()..add(LoadUnitConstruct()), + child: const UnitConstructionAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.group, + title: "Signatories", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + SignatoriesAdminBloc()..add(LoadSignatories()), + child: const SignatoriesAdminPage(), + ); + })); + }, + ), + const Divider(), + MainMenu( + icon: Elusive.group, + title: "Memoranda", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(LoadMemoranda()), + child: const MemorandaAdminPage(), + ); + })); + }, + ), + ], + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/barangay.dart b/lib/screens/offline/passo/admin/barangay.dart new file mode 100644 index 0000000..b482d97 --- /dev/null +++ b/lib/screens/offline/passo/admin/barangay.dart @@ -0,0 +1,110 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart'; + +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class BarangayAdminPage extends StatefulWidget { + const BarangayAdminPage(); + + @override + _BarangayAdminPage createState() => _BarangayAdminPage(); +} + +class _BarangayAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Municipaities"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = await BrgyAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final brgys = + result.map((json) => Brgy.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (Brgy brgy in brgys) { + await SQLServices.instance.createBarangay(brgy); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is BarangayLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Code'), + ), + const DataColumn( + label: Text('City Code'), + ), + const DataColumn( + label: Text('Description'), + ), + ], + rows: state.brgy.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.barangayId.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.barangayCode ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.cityCode ?? 'N/A')), + DataCell(Text( + dataRow.barangayDescription ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/class_components.dart b/lib/screens/offline/passo/admin/class_components.dart new file mode 100644 index 0000000..60d0eab --- /dev/null +++ b/lib/screens/offline/passo/admin/class_components.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/model/passo/class_components%20_offline.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/class_components_api_services.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../model/passo/city.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class ClassComponentsAdminPage extends StatefulWidget { + const ClassComponentsAdminPage(); + + @override + _ClassComponentsAdminPage createState() => _ClassComponentsAdminPage(); +} + +class _ClassComponentsAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Class Components"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await ClassComponentAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final classes = result + .map((json) => ClassComponents.fromJson(json)) + .toList(); + + // Loop through the list of City objects and insert them into the local database. + for (ClassComponents classs in classes) { + await SQLServices.instance.createClassComponents( + ClassComponentsOffline( + componentName: classs.componentName, + minBaseUnitvalPercent: classs.minBaseUnitvalPercent, + maxBaseUnitvalPercent: classs.maxBaseUnitvalPercent, + minUnitvalSqrmtr: classs.minUnitvalSqrmtr, + maxUnitvalSqrmtr: classs.maxUnitvalSqrmtr, + minAddBaseunitval: classs.minAddBaseunitval, + maxAddBaseunitval: classs.maxAddBaseunitval, + minDeductBaserate: classs.minAddBaseunitval, + maxDeductBaserate: classs.maxDeductBaserate, + minLinearMeter: classs.minLinearMeter, + maxLinearMeter: classs.maxLinearMeter, + minSpacing: classs.minSpacing, + maxSpacing: classs.maxSpacing, + roughFinish: classs.roughFinish, + highFinish: classs.highFinish, + withoutBucc: classs.withoutBucc == true ? 1 : 0)); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is ClassComponentsAdminLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Components Name'), + ), + const DataColumn( + label: Text('with BUCC?'), + ), + ], + rows: state.classes.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.componentName ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.withoutBucc + .toString() ?? + 'N/A')), // Use a default value if cityDescription is null + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/memoranda.dart b/lib/screens/offline/passo/admin/memoranda.dart new file mode 100644 index 0000000..428d523 --- /dev/null +++ b/lib/screens/offline/passo/admin/memoranda.dart @@ -0,0 +1,108 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/memoranda.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/memoranda_api_services.dart'; + +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class MemorandaAdminPage extends StatefulWidget { + const MemorandaAdminPage(); + + @override + _MemorandaAdminPage createState() => _MemorandaAdminPage(); +} + +class _MemorandaAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Memoranda"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = await MemorandaAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final memos = + result.map((json) => Memoranda.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (Memoranda memo in memos) { + await SQLServices.instance.createMemoranda(memo); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('Code'), + ), + const DataColumn( + label: Text('Memoranda'), + ), + ], + rows: state.memo.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.id.toString() ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.code ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.memoranda ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/municipalities.dart b/lib/screens/offline/passo/admin/municipalities.dart new file mode 100644 index 0000000..efe9421 --- /dev/null +++ b/lib/screens/offline/passo/admin/municipalities.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../model/passo/city.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class MunicipalitiesAdminPage extends StatefulWidget { + const MunicipalitiesAdminPage(); + + @override + _MunicipalitiesAdminPage createState() => _MunicipalitiesAdminPage(); +} + +class _MunicipalitiesAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Municipaities"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await MunicipalityAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final cities = + result.map((json) => City.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (City city in cities) { + print(city.cityDescription); + print(city.cityCode); + await SQLServices.instance.createMunicipalities(city); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalitiesLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('City Code'), + ), + const DataColumn( + label: Text('Description'), + ), + ], + rows: state.city.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.cityCode ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.cityDescription ?? + 'N/A')), // Use a default value if cityDescription is null + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/signatories.dart b/lib/screens/offline/passo/admin/signatories.dart new file mode 100644 index 0000000..afbe467 --- /dev/null +++ b/lib/screens/offline/passo/admin/signatories.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/signatories.dart'; + +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class SignatoriesAdminPage extends StatefulWidget { + const SignatoriesAdminPage(); + + @override + _SignatoriesAdminPage createState() => _SignatoriesAdminPage(); +} + +class _SignatoriesAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Signatories"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await SignatoriesAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final signatories = + result.map((json) => Signatories.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (Signatories signatory in signatories) { + await SQLServices.instance.createSignatories(signatory); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('ID'), + ), + const DataColumn( + label: Text('First Name'), + ), + const DataColumn( + label: Text('Middle Name'), + ), + const DataColumn( + label: Text('Last Name'), + ), + ], + rows: state.signatories.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.signatoryId + .toString())), // Use a default value if cityCode is null + DataCell(Text(dataRow.firstname ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.middlename ?? 'N/A')), + DataCell(Text(dataRow.lastname ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/admin/unit_construction.dart b/lib/screens/offline/passo/admin/unit_construction.dart new file mode 100644 index 0000000..2f86056 --- /dev/null +++ b/lib/screens/offline/passo/admin/unit_construction.dart @@ -0,0 +1,109 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/model/passo/barangay.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/unit_construction_api_services.dart'; + +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../theme-data.dart/colors.dart'; + +class UnitConstructionAdminPage extends StatefulWidget { + const UnitConstructionAdminPage(); + + @override + _UnitConstructionAdminPage createState() => _UnitConstructionAdminPage(); +} + +class _UnitConstructionAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Unit Construction"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + try { + final result = + await UnitConstructionAdminApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to City objects. + final units = + result.map((json) => UnitConstruct.fromJson(json)).toList(); + + // Loop through the list of City objects and insert them into the local database. + for (UnitConstruct unit in units) { + await SQLServices.instance.createUnitConstruction(unit); + } + } catch (e) { + // Handle any errors that might occur during the API call or database insertion. + print("Error: $e"); + } + }, + child: const Text('SYNC'), + ), + ], + ), + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Bldg Type'), + ), + const DataColumn( + label: Text('Building'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + ], + rows: state.unit.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.bldgType ?? + 'N/A')), // Use a default value if cityCode is null + DataCell(Text(dataRow.building ?? + 'N/A')), // Use a default value if cityDescription is null + DataCell(Text(dataRow.unitValue ?? 'N/A')), + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart new file mode 100644 index 0000000..2a92d2f --- /dev/null +++ b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart @@ -0,0 +1,715 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/model/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'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +class AddExtraItemsOffline extends StatefulWidget { + AddExtraItemsOffline(); + + @override + _AddExtraItemsOffline createState() => _AddExtraItemsOffline(); +} + +class _AddExtraItemsOffline 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 BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is ClassComponentsAdminLoaded) { + final classes = state.classes; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + return FormBuilder( + key: formKey, + onChanged: () { + formKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(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: classes + .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 == 1 + ? true + : false; + }); + formKey.currentState!.patchValue({ + 'unitValue': + value.minBaseUnitvalPercent + }); + } + if (value.maxBaseUnitvalPercent != + '0.00') { + setState(() { + _unitValue = double.parse( + value.maxBaseUnitvalPercent!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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 == 1 + ? true + : false; + }); + 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: state.unit + .map((UnitConstruct unit) => + SearchFieldListItem( + '${unit.bldgType} - ${unit.building}', + item: unit, + child: ListTile( + title: Text( + '${unit.bldgType} - ${unit.building!.toUpperCase()}', + overflow: TextOverflow + .ellipsis, + ), + ))) + .toList(), + + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + + searchInputDecoration: + normalTextFieldStyle( + "Structure Type", "") + .copyWith( + suffixIcon: const Icon( + Icons + .arrow_drop_down)), + ////agency suggestion tap + focusNode: focus, + suggestionState: Suggestion.expand, + onSuggestionTap: (unit) { + setState(() { + _unitBase = double.parse( + unit.item!.unitValue); + _structureType = + '${unit.item!.bldgType} - ${unit.item!.building}'; + }); + 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 { + try { + final tempID = + await SharedPreferences + .getInstance(); + + context + .read< + AdditionalItemsOfflineBloc>() + .add(AddAdditionalItems( + id: 1, + bldgapprDetailsId: + tempID + .getInt( + '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')); + } catch (e) { + Fluttertoast.showToast( + msg: + "Slow internet connection, please try again!", + ); + } + }, + 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(); + }, + ); + } + return Container(); + }, + ); + } + // if (state is Add) { + // return SomethingWentWrong( + // message: onError, + // onpressed: () { + // context.read().add(LoadAdditionalItems()); + // }, + // ); + // } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/building/add/add_building.dart b/lib/screens/offline/passo/building/add/add_building.dart new file mode 100644 index 0000000..10db27a --- /dev/null +++ b/lib/screens/offline/passo/building/add/add_building.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/offline/passo/building/add/property_appraisal.dart'; +import 'package:unit2/screens/offline/passo/building/add/property_assessment.dart'; +import 'package:unit2/screens/offline/passo/building/add/property_owner_info.dart'; +import 'package:unit2/screens/offline/passo/building/add/additional_items.dart'; +import 'package:unit2/screens/offline/passo/building/add/general_description.dart'; +import 'package:unit2/screens/offline/passo/building/add/landref_location.dart'; +import 'package:unit2/screens/offline/passo/building/add/structural_material.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; +import '../../../../../model/passo/property_info.dart'; + +GlobalKey offlineBldgKey = GlobalKey(); + +class AddBuilding extends StatefulWidget { + Function triggerBlocEvent; + AddBuilding(this.triggerBlocEvent); + @override + _AddBuilding createState() => _AddBuilding(); +} + +class _AddBuilding extends State { + int activeStep = 0; // Initial step set to 5. + int upperBound = 6; + + void PrevBtn() { + setState(() { + activeStep--; + }); + } + + void NextBtn() { + setState(() { + activeStep++; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + centerTitle: true, + title: const Text("Offline Building FAAS"), + ), + body: Column(children: [ + NumberStepper( + numbers: [1, 2, 3, 4, 5, 6, 7], + stepPadding: 5, + activeStepColor: primary, + numberStyle: TextStyle(color: Colors.white), + lineColor: primary, + // activeStep property set to activeStep variable defined above. + activeStep: activeStep, + activeStepBorderColor: Colors.white, + activeStepBorderWidth: 1, + // This ensures step-tapping updates the activeStep. + onStepReached: (index) { + setState(() { + activeStep = index; + }); + }, + enableStepTapping: false, + ), + Expanded( + child: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return FormBuilder( + key: offlineBldgKey, + onChanged: () { + offlineBldgKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Container( + child: content(PrevBtn, NextBtn), + ), + ); + }), + ), + ]), + ); + } + + Widget content(PrevBtn, NextBtn) { + switch (activeStep) { + case 0: + return PropertyInfoOfflinePage(NextBtn); + + case 1: + return LandRefLocationOfflinePage(PrevBtn, NextBtn); + + case 2: + return GeneralDescriptionOfflinePage(NextBtn, PrevBtn); + + case 3: + return StructuralMaterialsOfflinePage(PrevBtn, NextBtn); + + case 4: + return AdditionalItemOfflinePage(PrevBtn, NextBtn); + + case 5: + return PropertyAppraisalOfflinePage(NextBtn, PrevBtn); + + case 6: + return PropertyAssessmentOfflinePage(onSAveAll); + + default: + return Text("Property Info"); + } + } + + void onSAveAll() { + Navigator.of(context).pop(); + widget.triggerBlocEvent(); + } +} diff --git a/lib/screens/offline/passo/building/add/additional_items.dart b/lib/screens/offline/passo/building/add/additional_items.dart new file mode 100644 index 0000000..b4b7ae6 --- /dev/null +++ b/lib/screens/offline/passo/building/add/additional_items.dart @@ -0,0 +1,288 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/add/AddExtraItemsOffline.dart'; + +import '../../../../../widgets/passo/custom_button.dart'; + +class AdditionalItemOfflinePage extends StatefulWidget { + final VoidCallback additionalItemsPrevBtn; + final VoidCallback additionalItemsNextBtn; + + const AdditionalItemOfflinePage( + this.additionalItemsPrevBtn, this.additionalItemsNextBtn); + + @override + _AdditionalItemOfflinePage createState() => _AdditionalItemOfflinePage(); +} + +class _AdditionalItemOfflinePage extends State { + // void deleteItem(int itemId) { + // context.read().add(DeleteAdditionalItems(id: itemId)); + // } + + final items = []; + + double _totalMarketValue(items) { + double total = 0; + items.forEach((row) { + total += double.parse(row.adjustedMarketVal); + }); + return total; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is AdditionalItemsOfflineInitial) { + 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: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ) + ])))) + ]); + } + 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: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('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.addItem.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.className)), + DataCell( + Text(dataRow.baseUnitValue.toString())), + DataCell(Text(dataRow.unitValue.toString())), + DataCell(Text(((double.parse( + dataRow.adjustedMarketVal.toString()))) + .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(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 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: AddExtraItemsOffline())], + ), + ), + ); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/building/add/general_description.dart b/lib/screens/offline/passo/building/add/general_description.dart new file mode 100644 index 0000000..9dc2ad6 --- /dev/null +++ b/lib/screens/offline/passo/building/add/general_description.dart @@ -0,0 +1,252 @@ +import 'dart:ui'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/screens/passo/Building/add_building_components/general_description.dart'; + +import '../../../../../model/passo/general_description.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class GeneralDescriptionOfflinePage extends StatefulWidget { + final VoidCallback onPutGeneralDescription; + final VoidCallback gendescPrevBtn; + + GeneralDescriptionOfflinePage( + this.onPutGeneralDescription, this.gendescPrevBtn); + + @override + _GeneralDescriptionOfflinePage createState() => + _GeneralDescriptionOfflinePage(); +} + +class _GeneralDescriptionOfflinePage + extends State { + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + 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: state.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.gendescPrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = + await SharedPreferences.getInstance(); + + context.read().add(AddGendesc( + id: 1, + bldgapprDetailsId: tempID.getInt('tempid')!, + assessedById: '1', + assessedByName: 'cyril', + bldgKind: offlineBldgKey + .currentState?.value['bldg_type'].building, + strucType: offlineBldgKey + .currentState?.value['bldg_type'].bldgType, + bldgPermit: offlineBldgKey + .currentState?.value['bldg_permit'], + dateIssued: offlineBldgKey + .currentState!.value['coc_issued'] + .toString(), + cct: offlineBldgKey.currentState?.value['cct'], + certCompletionIssued: offlineBldgKey + .currentState!.value['coc_issued'] + .toString(), + certOccupancyIssued: offlineBldgKey + .currentState!.value['coo_issued'] + .toString(), + dateCompleted: offlineBldgKey + .currentState!.value['date_cnstructed'] + .toString(), + dateOccupied: offlineBldgKey + .currentState!.value['date_occupied'] + .toString(), + bldgAge: offlineBldgKey.currentState!.value['bldg_age'], + noStoreys: offlineBldgKey.currentState!.value['no_of_storeys'], + area1Stfloor: '0', + area2Ndfloor: '0', + area3Rdfloor: '0', + area4Thfloor: '0', + totalFloorArea: offlineBldgKey.currentState?.value['total_area'], + floorSketch: null, + actualUse: offlineBldgKey.currentState?.value['actual_use'])); + } + ; + }, + ) + ], + ) + ], + ), + ), + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/offline/passo/building/add/landref_location.dart b/lib/screens/offline/passo/building/add/landref_location.dart new file mode 100644 index 0000000..7331635 --- /dev/null +++ b/lib/screens/offline/passo/building/add/landref_location.dart @@ -0,0 +1,327 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; + +import '../../../../../model/passo/barangay.dart'; +import '../../../../../model/passo/city.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class LandRefLocationOfflinePage extends StatefulWidget { + final VoidCallback PrevBtn; + final VoidCallback NextBtn; + + LandRefLocationOfflinePage(this.PrevBtn, this.NextBtn); + + @override + _LandRefLocationOfflinePage createState() => _LandRefLocationOfflinePage(); +} + +class _LandRefLocationOfflinePage extends State { + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalitiesLoaded) { + final city = state.city; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + 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( + child: 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: const Align( + alignment: Alignment.center, + child: Text( + "AGUSAN DEL NORTE", + style: TextStyle(fontSize: 15), + ), + ), + ), + ), + const SizedBox(width: 10.0), + Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'municipality', + autofocus: false, + decoration: normalTextFieldStyle( + "Municipality", ""), + items: city + .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(LoadBarangayInMunicipality( + cityCode: + 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')) + ]), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + // Builder(builder: (context) { + // return CustomButton( + // icon: const Icon( + // Icons.chevron_right_rounded, + // color: Colors.white), + // onPressed: () async { + // { + // try { + // final progress = + // ProgressHUD.of(context); + // Future.delayed(Duration(seconds: 3), + // () { + // progress?.dismiss(); + // }); + // 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: "Agusan Del Norte"); + // 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)); + // } catch (e) { + // Fluttertoast.showToast( + // msg: + // "Slow internet connection, please try again!"); + // } + // } + // ; + // }, + // ); + // }) + Builder(builder: (context) { + return CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white, + ), + onPressed: () async { + // Rest of your code... + final tempID = + await SharedPreferences.getInstance(); + + print('id check'); + print(tempID.getInt('tempid')!); + + context.read().add(AddLocation( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')!, + assessedById: 'cyril', + assessedByName: 'cyril', + street: offlineBldgKey + .currentState?.value['street'], + barangay: offlineBldgKey + .currentState?.value['brgy'], + municipality: offlineBldgKey + .currentState + ?.value['municipality'] + .cityDescription, + province: "Agusan Del Norte")); + + context + .read() + .add(AddLandRef( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')!, + assessedById: '1', + assessedByName: 'cyril', + owner: offlineBldgKey + .currentState?.value['l_owner'], + cloaNo: offlineBldgKey.currentState + ?.value['oct_tct_cloa'], + lotNo: offlineBldgKey + .currentState?.value['lot_no'], + tdn: offlineBldgKey + .currentState?.value['l_td_arp'], + area: offlineBldgKey + .currentState?.value['area'], + surveyNo: offlineBldgKey + .currentState?.value['survey_no'], + blkNo: offlineBldgKey + .currentState?.value['blk_no'], + )); + }, + ); + }) + ], + ) + ], + ), + ), + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/offline/passo/building/add/property_appraisal.dart b/lib/screens/offline/passo/building/add/property_appraisal.dart new file mode 100644 index 0000000..a3e3e0a --- /dev/null +++ b/lib/screens/offline/passo/building/add/property_appraisal.dart @@ -0,0 +1,1043 @@ +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:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/screens/offline/passo/building/add/additional_items.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../widgets/passo/custom_button.dart'; + +class PropertyAppraisalOfflinePage extends StatefulWidget { + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + PropertyAppraisalOfflinePage(this.NextBtn, this.PrevBtn); + + @override + _PropertyAppraisalOfflinePage createState() => + _PropertyAppraisalOfflinePage(); +} + +class _PropertyAppraisalOfflinePage + 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.toString()); + } + + 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 Scaffold( + body: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is AdditionalItemsLoaded) { + return SingleChildScrollView( + child: Container( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Unit Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + offlineBldgKey + .currentState!.value['bldg_type'].unitValue + + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Building Core", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + (double.parse(offlineBldgKey + .currentState!.value['total_area']) * + double.parse(offlineBldgKey.currentState! + .value['bldg_type'].unitValue)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: const Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateAdditionalItems(state.addItem).toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateTotalConstructionCost( + (double.parse(offlineBldgKey + .currentState!.value['total_area']) * + double.parse(offlineBldgKey.currentState! + .value['bldg_type'].unitValue)), + state.addItem) + .toString(), + textAlign: TextAlign.right, + ), + ), + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Rate", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: 90, + height: 25, + child: FormBuilderTextField( + name: 'depRate', + decoration: normalTextFieldStyle("", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + depRate = double.parse(value!); + }); + }, + ), + ), + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (double.parse(offlineBldgKey + .currentState!.value['total_area']) * + double.parse(offlineBldgKey.currentState! + .value['bldg_type'].unitValue)), + state.addItem, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total % Depreciation", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '${(depRate * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (double.parse(offlineBldgKey + .currentState!.value['total_area']) * + double.parse(offlineBldgKey.currentState! + .value['bldg_type'].unitValue)), + state.addItem, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + margin: const EdgeInsets.only( + left: 20.0, right: 20.0), + 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( + offlineBldgKey.currentState + ?.value['actual_use']!, + style: const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + Container( + width: 100, + margin: const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all(5.0), + child: Text( + calculateMarketValue( + (double.parse(offlineBldgKey + .currentState! + .value[ + 'total_area']) * + double.parse(offlineBldgKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state.addItem, + depRate) + .toString(), + style: const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + Container( + width: 100, + margin: const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all(5.0), + child: Text( + assessmentLevel( + calculateMarketValue( + (double.parse(offlineBldgKey + .currentState! + .value[ + 'total_area']) * + double.parse(offlineBldgKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state.addItem, + depRate) + .toString(), + offlineBldgKey + .currentState + ?.value[ + 'actual_use']), + style: const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + Container( + width: 100, + margin: const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all(5.0), + child: Text( + assessmentValue( + calculateMarketValue( + (double.parse(offlineBldgKey.currentState!.value[ + 'total_area']) * + double.parse(offlineBldgKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state + .addItem, + depRate) + .toString(), + offlineBldgKey + .currentState + ?.value[ + 'actual_use']) + .toString(), + style: const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ) + ], + ), + ]))), + ), + ], + ), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + // final tempID = + // await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // var appraisals = PropertyAppraisal( + // id: 1, + // bldgapprDetailsId: + // tempID.getInt('tempid')! - 1, + // unitconstructCost: formKey + // .currentState! + // .value['bldg_type'] + // .unitValue, + // buildingCore: 'test', + // unitconstructSubtotal: (double.parse(formKey.currentState!.value['total_area']) * + // double.parse(formKey + // .currentState! + // .value['bldg_type'] + // .unitValue)) + // .toString(), + // depreciationRate: depRate.toString(), + // depreciationCost: calculateDepCost( + // (double.parse(formKey.currentState!.value['total_area']) * + // double.parse(formKey.currentState!.value['bldg_type'].unitValue)), + // state.items, + // depRate) + // .toString(), + // costAddItems: calculateAdditionalItems(state.items).toString(), + // addItemsSubtotal: calculateAdditionalItems(state.items).toString(), + // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), + // marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), + // totalArea: formKey.currentState!.value['total_area'], + // actualUse: "Residential"); + // context.read() + // ..add(AddPropertyAppraisal( + // appraisal: appraisals)); + } + ; + }, + ) + ], + ), + ], + ), + ), + ); + } + return Container(); + }, + )); + } +} diff --git a/lib/screens/offline/passo/building/add/property_assessment.dart b/lib/screens/offline/passo/building/add/property_assessment.dart new file mode 100644 index 0000000..5fcb1c8 --- /dev/null +++ b/lib/screens/offline/passo/building/add/property_assessment.dart @@ -0,0 +1,584 @@ +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:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; + +import '../../../../../model/passo/memoranda.dart'; +import '../../../../../model/passo/signatories.dart'; +import '../../../../../theme-data.dart/colors.dart'; + +class PropertyAssessmentOfflinePage extends StatefulWidget { + Function function; + + PropertyAssessmentOfflinePage(this.function); + + @override + _PropertyAssessmentOfflinePage createState() => + _PropertyAssessmentOfflinePage(); +} + +class _PropertyAssessmentOfflinePage + extends State { + double assessment_level = 0; + bool isTaxable = false; + bool isExempt = false; + String _memoranda = ''; + final focus = FocusNode(); + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + final memoranda = state.memo; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + return Scaffold( + body: 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: const 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, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'appraised_by', + autofocus: false, + items: state.signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + 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', + autofocus: false, + items: state.signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'apprvd_by', + autofocus: false, + items: state.signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + const 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(); + }, + )), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement', + decoration: const InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const 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'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_of_entry', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by', + decoration: const InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const 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'] ?? + // '', // Replace null with an empty string + // marketValue: '0.00', + // assessmentLevel: '0.00', + // assessedValue: '0.00', + // taxable: isTaxable, + // exempt: isExempt, + // qtr: int.parse(formKey + // .currentState!.value['qtr'] ?? + // '0'), // Replace null with '0' + // yr: int.parse( + // formKey.currentState!.value['yr'] ?? + // '0'), // Replace null with '0' + // appraisedbyName: (formKey + // .currentState! + // .value['appraised_by'] + // ?.firstname ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['appraised_by'] + // ?.middlename ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['appraised_by'] + // ?.lastname ?? + // ''), + // appraisedbyDate: formKey.currentState! + // .value['app_date'] + // as DateTime? ?? + // DateTime + // .now(), // Replace null with current date + // recommendapprName: (formKey + // .currentState! + // .value['rec_approval'] + // ?.firstname ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['rec_approval'] + // ?.middlename ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['rec_approval'] + // ?.lastname ?? + // ''), + // recommendapprDate: formKey.currentState! + // .value['rec_date'] + // as DateTime? ?? + // DateTime + // .now(), // Replace null with current date + // approvedbyName: (formKey + // .currentState! + // .value['apprvd_by'] + // ?.firstname ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['apprvd_by'] + // ?.middlename ?? + // '') + + // ' ' + + // (formKey + // .currentState! + // .value['apprvd_by'] + // ?.lastname ?? + // ''), + // memoranda: _memoranda, + // swornstatementNo: formKey.currentState! + // .value['sworn_statement'] ?? + // '', // Replace null with an empty string + // dateReceived: formKey.currentState! + // .value['date_received'] + // as DateTime? ?? + // DateTime + // .now(), // Replace null with current date + // entryDateAssessment: formKey + // .currentState! + // .value['date_of_entry'] + // as DateTime? ?? + // DateTime + // .now(), // Replace null with current date + // entryDateBy: formKey + // .currentState!.value['by'] ?? + // '', // Replace null with an empty string + // ); + + // propertyAssessments.add(ass); + + // context + // .read() + // .add(UpdatePropertyAssessment( + // assessment: + // propertyAssessments[0])); + // widget.function(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: const SizedBox( + width: 200, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + ), + const SizedBox( + height: 30, + ), + ], + ), + )) + ])); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } +} diff --git a/lib/screens/offline/passo/building/add/property_owner_info.dart b/lib/screens/offline/passo/building/add/property_owner_info.dart new file mode 100644 index 0000000..fbee3b1 --- /dev/null +++ b/lib/screens/offline/passo/building/add/property_owner_info.dart @@ -0,0 +1,143 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +import '../../../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; + +class PropertyInfoOfflinePage extends StatefulWidget { + final VoidCallback handleButtonPress; + const PropertyInfoOfflinePage(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: [ + 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 { + final tempID = await SharedPreferences.getInstance(); + // Dispatch the event to add the property_info + context.read().add( + AddTodo( + id: '1', + transCode: offlineBldgKey + .currentState!.value['transaction_code'] + ?.toString() ?? + '', + tdn: offlineBldgKey.currentState!.value['arp_td'] ?? + '', + pin: + offlineBldgKey.currentState!.value['pin'] ?? '', + owner: offlineBldgKey.currentState!.value['owner'] ?? + '', + address: + offlineBldgKey.currentState!.value['address'] ?? + '', + telno: offlineBldgKey.currentState!.value['tel_no'] ?? + '', + tin: + offlineBldgKey.currentState!.value['tin'] ?? '', + adminUser: offlineBldgKey + .currentState!.value['benificiary'] ?? + '', + adminAddress: offlineBldgKey.currentState! + .value['benificiary_address'] ?? + '', + adminTin: offlineBldgKey.currentState!.value['benificiary_tin'] ?? '', + adminTelno: offlineBldgKey.currentState!.value['benificiary_telno'] ?? '', + faasType: "BUILDING", + assessedById: '1', + assessedByName: 'Cyril'), + ); + widget.handleButtonPress(); + }, + ) + ]), + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/add/structural_material.dart b/lib/screens/offline/passo/building/add/structural_material.dart new file mode 100644 index 0000000..1dc7bd8 --- /dev/null +++ b/lib/screens/offline/passo/building/add/structural_material.dart @@ -0,0 +1,431 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:multiselect/multiselect.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/screens/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 StructuralMaterialsOfflinePage extends StatefulWidget { + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + StructuralMaterialsOfflinePage(this.NextBtn, this.PrevBtn); + + @override + _StructuralMaterialsOfflinePage createState() => + _StructuralMaterialsOfflinePage(); +} + +class _StructuralMaterialsOfflinePage + 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 StatefulBuilder(builder: (context, structuralState) { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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) { + structuralState(() { + 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: () async { + { + final tempID = await SharedPreferences.getInstance(); + + context.read().add( + AddStructuralMaterial( + id: 1, + bldgapprDetailsId: tempID.getInt('tempid')! - 1, + foundation: foundationOthers + ? formKey + .currentState!.value['other_foundation'] + .split(',') + : foundation, + columns: columOthers + ? formKey.currentState!.value['other_column'] + .split(',') + : column, + beams: beamsOthers + ? formKey.currentState!.value['other_beam'] + .split(',') + : beam, + trussFraming: tfOthers + ? formKey.currentState!.value['other_tf'] + .split(',') + : truss_framing, + roof: roofOthers + ? formKey.currentState!.value['other_roof'] + .split(',') + : roof, + flooring: flooringOthers + ? formKey + .currentState!.value['other_flooring'] + .split(',') + : flooring, + walls: wpOthers + ? formKey.currentState!.value['other_wp'] + .split(',') + : walls, + others: ["Others"])); + } + ; + }, + ) + ], + ) + ], + ), + ); + }); + } +} diff --git a/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart new file mode 100644 index 0000000..cc6ce7f --- /dev/null +++ b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart @@ -0,0 +1,596 @@ +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/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/class_components.dart'; +import '../../../../../model/passo/unit_construct.dart'; +import '../../../../../theme-data.dart/form-style.dart'; + +class AddExtraItemsEditOffline extends StatefulWidget { + final List unit; + final List options; + final int tempId; + + AddExtraItemsEditOffline(this.unit, this.options, this.tempId); + + @override + _AddExtraItemsEditOffline createState() => _AddExtraItemsEditOffline(); +} + +class _AddExtraItemsEditOffline 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 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), + 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: () { + context + .read() + .add(AddAdditionalItems( + 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')); + }, + 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/offline/passo/building/edit/additional_items_edit.dart b/lib/screens/offline/passo/building/edit/additional_items_edit.dart new file mode 100644 index 0000000..9a8daa5 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/additional_items_edit.dart @@ -0,0 +1,318 @@ +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/model/passo/class_components%20_offline.dart'; + +import '../../../../../bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/class_components.dart'; +import '../../../../../model/passo/unit_construct.dart'; +import '../../../../../utils/alerts.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../passo/Building/edit_building/AddExtraItems.dart'; + +class AdditionalItemEditPageOffline extends StatefulWidget { + final List unit; + final List options; + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + AdditionalItemEditPageOffline( + this.unit, this.options, this.tempId, this.NextBtn, this.PrevBtn); + + @override + _AdditionalItemEditPageOffline createState() => + _AdditionalItemEditPageOffline(); +} + +class _AdditionalItemEditPageOffline + 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 Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) {}, + builder: (context, state) { + final state = context.watch().state; + if (state is AdditionalItemsLoaded) { + 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(ShowAdditionalItems()); + }, + 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.addItem.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 AdditionalItemsDeletedState) { + 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 ShowAddItemsScreen) { + 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/offline/passo/building/edit/edit_building.dart b/lib/screens/offline/passo/building/edit/edit_building.dart new file mode 100644 index 0000000..e4747f6 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/edit_building.dart @@ -0,0 +1,152 @@ +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/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/additional_items_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/general_description_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/landref_location_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/structural_materials_edit.dart'; + +import '../../../../../model/passo/property_info.dart'; +import '../../../../../theme-data.dart/colors.dart'; + +class EditBuildingOffline extends StatefulWidget { + final int index; + final PropertyInfo faas; + final String title; + + const EditBuildingOffline( + {super.key, + required this.title, + required this.index, + required this.faas}); + @override + _EditBuildingOffline createState() => _EditBuildingOffline(); +} + +class _EditBuildingOffline 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 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) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + final unit = state.unit; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is ClassComponentsAdminLoaded) { + return 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: StatefulBuilder(builder: + (BuildContext context, StateSetter setState) { + return Container( + child: content( + PrevBtn, NextBtn, unit, state.classes), + ); + }), + ), + ], + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ))); + } + + // Returns the header text based on the activeStep. + Widget content(PrevBtn, NextBtn, unit, classes) { + switch (activeStep) { + case 0: + return PropertyOwnerInfoEditOffline( + widget.index, + widget.faas, + 'EDit', + PrevBtn, + NextBtn, + ); + + case 1: + return BldgLocLandRefEditOffline(widget.faas.id!, NextBtn, PrevBtn); + + case 2: + return GeneralDescriptionEditOffline(NextBtn, PrevBtn); + + case 3: + return StructuralMaterialsPageEditOffline(NextBtn, PrevBtn); + + case 4: + return AdditionalItemEditPageOffline( + 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 Container(); + // return PropertyOwnerInfoEdit( + // widget.index, widget.faas, widget.title, NextBtn, PrevBtn); + } + } +} diff --git a/lib/screens/offline/passo/building/edit/general_description_edit.dart b/lib/screens/offline/passo/building/edit/general_description_edit.dart new file mode 100644 index 0000000..7ecab77 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/general_description_edit.dart @@ -0,0 +1,381 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; + +import '../../../../../model/passo/general_description.dart'; +import '../../../../../model/passo/unit_construct.dart'; +import '../../../../../theme-data.dart/form-style.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class GeneralDescriptionEditOffline extends StatefulWidget { + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + GeneralDescriptionEditOffline(this.NextBtn, this.PrevBtn); + @override + _GeneralDescriptionEditOffline createState() => + _GeneralDescriptionEditOffline(); +} + +class _GeneralDescriptionEditOffline + extends State { + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Expanded( + child: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) async { + // if (state is GenDescLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is GenDescLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + + // final tempID = await SharedPreferences.getInstance(); + // await tempID.setInt( + // 'totalValue', int.parse(state.gendesc.totalFloorArea!)); + // await tempID.setString( + // 'actualUse', state.gendesc.actualUse!); + + // } + // if (state is GenDescErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificGeneralDescriptionLoaded) { + final gendesc = state.gendesc; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is UnitConstructLoaded) { + return FormBuilder( + key: offlineBldgEditKey, + initialValue: { + 'bldg_permit': gendesc.bldgPermit, + 'date_issued': gendesc.dateIssued.toString(), + 'cct': gendesc.cct.toString(), + 'coc_issued': + gendesc.certCompletionIssued.toString(), + 'coo_issued': + gendesc.certOccupancyIssued.toString(), + 'date_cnstructed': gendesc.dateIssued.toString(), + 'date_occupied': gendesc.dateOccupied.toString(), + 'bldg_age': gendesc.bldgAge.toString(), + 'no_of_storeys': gendesc.noStoreys.toString(), + 'area_of_1stFl': gendesc.area1Stfloor, + 'area_of_2ndFl': gendesc.area2Ndfloor, + 'area_of_3rdFl': gendesc.area3Rdfloor, + 'area_of_4thFl': gendesc.area4Thfloor, + 'total_area': gendesc.totalFloorArea.toString(), + 'actual_use': gendesc.actualUse + }, + enabled: true, + onChanged: () { + offlineBldgEditKey.currentState!.save(); + debugPrint(offlineBldgEditKey.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( + gendesc.bldgKind ?? + "Kind of Building", + "Kind of Building"), + items: state.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: () { + { + offlineBldgEditKey.currentState! + .save(); + + context.read().add(AddGendesc( + id: 1, + bldgapprDetailsId: 1, + assessedById: "1", + assessedByName: 'hhs', + bldgKind: offlineBldgEditKey + .currentState + ?.value['bldg_type'] + ?.building ?? + gendesc.bldgKind, + strucType: offlineBldgEditKey + .currentState + ?.value['bldg_type'] + ?.bldgType ?? + gendesc.strucType, + bldgPermit: offlineBldgEditKey + .currentState + ?.value['bldg_permit'], + dateIssued: offlineBldgEditKey + .currentState + ?.value['coc_issued'], + cct: offlineBldgEditKey + .currentState + ?.value['cct'], + certCompletionIssued: offlineBldgEditKey + .currentState + ?.value['coc_issued'], + certOccupancyIssued: offlineBldgEditKey + .currentState + ?.value['coo_issued'], + dateCompleted: offlineBldgEditKey.currentState?.value['date_cnstructed'], + dateOccupied: offlineBldgEditKey.currentState?.value['date_occupied'], + bldgAge: offlineBldgEditKey.currentState?.value['bldg_age']!, + noStoreys: offlineBldgEditKey.currentState?.value['no_of_storeys']!, + area1Stfloor: offlineBldgEditKey.currentState?.value['area_of_1stFl'], + area2Ndfloor: offlineBldgEditKey.currentState?.value['area_of_2ndFl'], + area3Rdfloor: offlineBldgEditKey.currentState?.value['area_of_3rdFl'], + area4Thfloor: offlineBldgEditKey.currentState?.value['area_of_4thFl'], + totalFloorArea: offlineBldgEditKey.currentState?.value['total_area'], + floorSketch: null, + actualUse: offlineBldgEditKey.currentState?.value['actual_use'])); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), + ), + ), + ); + } + return Container(); + }, + ); + } + // 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/offline/passo/building/edit/landref_location_edit.dart b/lib/screens/offline/passo/building/edit/landref_location_edit.dart new file mode 100644 index 0000000..7b096ab --- /dev/null +++ b/lib/screens/offline/passo/building/edit/landref_location_edit.dart @@ -0,0 +1,442 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; +import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; + +import '../../../../../model/passo/barangay.dart'; +import '../../../../../model/passo/bldg_loc.dart'; +import '../../../../../model/passo/city.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class BldgLocLandRefEditOffline extends StatefulWidget { + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + BldgLocLandRefEditOffline(this.tempId, this.NextBtn, this.PrevBtn); + @override + _BldgLocLandRefEditOffline createState() => _BldgLocLandRefEditOffline(); +} + +class _BldgLocLandRefEditOffline extends State { + Set seenCityCodes = Set(); + @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 LocationLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + + // if (state is LocationErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificLocationLoaded) { + final bldgloc = state.location; + return BlocConsumer( + listener: (context, state) { + // if (state is LandrefLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is LandrefErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is SpecificLandrefLoaded) { + 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 MunicipalityErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { + if (state is MunicipalitiesLoaded) { + final cityList = state.city; + 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 BarangayLoaded) { + 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(); + // } + }, builder: (context, state) { + if (state is BarangayLoaded) { + List brgyList = state.brgy; + List brgyNAmes = brgyList + .map((brgy) => brgy.barangayDescription) + .toList() + .cast(); + return FormBuilder( + key: offlineBldgEditKey, + initialValue: { + 'street': bldgloc.street ?? "", + 'province': bldgloc.province ?? "", + 'l_owner': landRef.owner, + 'oct_tct_cloa': landRef.cloaNo ?? "no", + 'survey_no': landRef.surveyNo ?? "", + 'lot_no': landRef.lotNo ?? "", + 'blk_no': landRef.blkNo ?? "", + 'l_td_arp': landRef.tdn ?? "", + 'area': landRef.area ?? "" + }, + enabled: true, + onChanged: () { + offlineBldgEditKey.currentState!.save(); + debugPrint(offlineBldgEditKey + .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( + child: 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: const Align( + alignment: Alignment.center, + child: Text( + "AGUSAN DEL NORTE", + style: + TextStyle(fontSize: 15), + ), + ), + ), + ), + const SizedBox(width: 10.0), + Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'municipality', + autofocus: false, + decoration: + normalTextFieldStyle( + bldgloc.municipality ?? + "Municipality", + "", + ), + items: uniqueItems + .map( + (city) => + DropdownMenuItem< + City>( + 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!)); + // }, + ), + ), + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDropDownField( + bldgloc.barangay, + "", + 'brgy', + brgyNAmes)), + const SizedBox(width: 10.0), + Expanded( + flex: 1, + child: customTextField( + "No. / Street", "", 'street'), + ), + + // Expanded( + // // optional flex property if flex is 1 because the default flex is 1 + // flex: 1, + // child: customDropDownField( + // bldgloc.barangay ?? "", + // "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: offlineBldgEditKey.currentState + // ?.value['street'], + // barangay: offlineBldgEditKey.currentState + // ?.value['brgy'], + // municipality: offlineBldgEditKey + // .currentState + // ?.value[ + // 'municipality'] + // ?.cityDescription ?? + // bldgloc.municipality, + // province: offlineBldgEditKey.currentState + // ?.value['province'], + // ); + // var landRefData = LandRef( + // id: widget.tempId, + // owner: offlineBldgEditKey.currentState + // ?.value['l_owner'], + // cloaNo: offlineBldgEditKey.currentState + // ?.value['oct_tct_cloa'], + // lotNo: offlineBldgEditKey.currentState + // ?.value['lot_no'], + // tdn: offlineBldgEditKey.currentState + // ?.value['l_td_arp'], + // area: offlineBldgEditKey.currentState + // ?.value['area'], + // surveyNo: offlineBldgEditKey.currentState + // ?.value['survey_no'], + // blkNo: offlineBldgEditKey.currentState + // ?.value['blk_no'], + // ); + // context.read() + // ..add(UpdateBldgLoc( + // bldg_loc: bldgLocData)) + // ..add(UpdateLandRef( + // land_ref: landRefData)); + + 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/offline/passo/building/edit/property_owner_info_edit.dart b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart new file mode 100644 index 0000000..4c657e2 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart @@ -0,0 +1,212 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +GlobalKey offlineBldgEditKey = GlobalKey(); + +class PropertyOwnerInfoEditOffline extends StatefulWidget { + final int index; + final PropertyInfo faas; + final String title; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + const PropertyOwnerInfoEditOffline( + this.index, this.faas, this.title, this.NextBtn, this.PrevBtn); + + @override + State createState() => + _PropertyOwnerInfoEditOffline(); +} + +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 _PropertyOwnerInfoEditOffline + extends State { + Map myMap = {'zero': 0, 'one': 1, 'two': 2}; + + final transaction_codes = ['New', 'Revision']; + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Expanded( + child: Column( + children: [ + FormBuilder( + key: offlineBldgEditKey, + 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: () { + offlineBldgEditKey.currentState!.save(); + debugPrint( + offlineBldgEditKey.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: offlineBldgEditKey + .currentState!.value['transaction_code'] + .toString(), + tdn: offlineBldgEditKey + .currentState!.value['arp_td'], + pin: offlineBldgEditKey + .currentState!.value['pin'], + owner: offlineBldgEditKey + .currentState!.value['owner'], + address: offlineBldgEditKey + .currentState!.value['address'], + telno: offlineBldgEditKey + .currentState!.value['tel_no'], + tin: offlineBldgEditKey + .currentState!.value['tin'], + adminUser: offlineBldgEditKey + .currentState!.value['benificiary'], + adminAddress: offlineBldgEditKey + .currentState! + .value['benificiary_address'], + adminTin: offlineBldgEditKey + .currentState!.value['benificiary_tin'], + adminTelno: offlineBldgEditKey.currentState! + .value['benificiary_telno'], + ); + + // context.read().add( + // UpdatPropertyInfo( + // property_info: property_info)); + + widget.NextBtn(); + }, + ), + ), + ])), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/edit/structural_materials_edit.dart b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart new file mode 100644 index 0000000..e4e0cdb --- /dev/null +++ b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart @@ -0,0 +1,428 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:multiselect/multiselect.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; + +import '../../../../../model/passo/structureMaterial.dart'; +import '../../../../../widgets/passo/custom_button.dart'; +import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; + +class StructuralMaterialsPageEditOffline extends StatefulWidget { + // final VoidCallback onPutStructuralMaterials; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + StructuralMaterialsPageEditOffline(this.NextBtn, this.PrevBtn); + + @override + _StructuralMaterialsPageEditOffline createState() => + _StructuralMaterialsPageEditOffline(); +} + +class _StructuralMaterialsPageEditOffline + 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 SpecificStructuralMaterialLoaded) { + setState(() { + foundation = state.materials.foundation?.split(', ') ?? []; + column = state.materials.columns?.split(', ') ?? []; + beam = state.materials.beams?.split(', ') ?? []; + truss_framing = state.materials.trussFraming?.split(', ') ?? []; + roof = state.materials.roof?.split(', ') ?? []; + flooring = state.materials.flooring?.split(', ') ?? []; + walls = state.materials.walls?.split(', ') ?? []; + // Update other local state variables here if needed + }); + } + // TODO: implement listener + }, builder: (context, state) { + if (state is SpecificStructuralMaterialLoaded) { + return SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + // Added this line + 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: [ + const 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 = StructureMaterials( + foundation: foundation.toString(), + columns: column.toString(), + beams: beam.toString(), + trussFraming: truss_framing.toString(), + roof: roof.toString(), + flooring: flooring.toString(), + walls: walls.toString(), + others: ["Others"].toString(), + ); + widget.NextBtn(); + }, + ), + ], + ) + ], + ), + ), + ); + } + // if (state is StructuralMaterialsErrorState) { + // return Text(state.error); + // } + return Container(); + }); + } +} diff --git a/lib/screens/offline/passo/building_home_offline.dart b/lib/screens/offline/passo/building_home_offline.dart new file mode 100644 index 0000000..4507902 --- /dev/null +++ b/lib/screens/offline/passo/building_home_offline.dart @@ -0,0 +1,303 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/municipalities_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/property_info.dart'; +import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; +import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/widgets/empty_data.dart'; + +import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; + +class BuildingHomeOffline extends StatelessWidget { + const BuildingHomeOffline({super.key}); + + @override + Widget build(BuildContext context) { + void deleteItem(int itemId) { + context.read().add(DeleteTodo(id: itemId)); + } + + // void triggerBlocEvent() { + // final myBloc = BlocProvider.of(context); + // myBloc.add(LoadPropertyInfo()); + // } + + return Scaffold( + body: ProgressHUD( + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder( + builder: (context, state) { + if (state is DisplayTodos) { + if (state.todo.isNotEmpty) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( + children: [ + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: state.todo.length, + itemBuilder: (BuildContext context, int index) { + return _listCard(state.todo[index], context, + index, deleteItem, state.todo.length); + }, + ), + ), + ], + ), + ); + } else { + return const EmptyData( + message: + "You don't have any building faas added. Please click + to add"); + } + } + return Container(); + }, + )), + floatingActionButton: SpeedDial( +//provide here features of your parent FAB + icon: Icons.add, + backgroundColor: primary, + heroTag: null, + useRotationAnimation: true, + activeIcon: Icons.close, + animationCurve: Curves.elasticInOut, + children: [ + SpeedDialChild( + child: const Icon( + Icons.maps_home_work_rounded, + color: primary, + ), + label: 'Building & Other Structure', + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider(providers: [ + BlocProvider( + create: (context) => CrudBloc(), + ), + BlocProvider( + create: (context) => AdditionalItemsOfflineBloc(), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => BarangayAdminBloc() + ..add( + const LoadBarangayInMunicipality(cityCode: '01')), + ), + BlocProvider( + create: (context) => ClassComponentsAdminBloc() + ..add(const LoadClassComponents()), + ), + BlocProvider( + create: (context) => UnitConstructionAdminBloc() + ..add(const LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => SignatoriesAdminBloc() + ..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider(create: (context) => LandrefLocationBloc()), + BlocProvider(create: (context) => LocationBloc()), + BlocProvider( + create: (context) => GeneralDescriptionBloc()), + BlocProvider( + create: (context) => StructuralMaterialOfflineBloc()), + BlocProvider( + create: (context) => AdditionalItemsOfflineBloc() + ..add(const LoadAdditionalItems())), + BlocProvider( + create: (context) => BldgAppraisalOfflineBloc()), + BlocProvider( + create: (context) => BldgAssessmentOfflineBloc()), + ], child: AddBuilding(deleteItem)); + })); + }), + SpeedDialChild( + child: const Icon( + Icons.forest_rounded, + color: primary, + ), + label: 'Land/Other Improvements', + onTap: () {}, + ), + 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, deleteItem, bldgLength) { + return Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + //set border radius more than 50% of height and width to make circle + ), + margin: const EdgeInsets.all(5.0), + elevation: 5, + shadowColor: Colors.grey, + child: Padding( + padding: const EdgeInsets.all(15.0), + child: InkWell( + onTap: () async { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => CrudBloc()..add(FetchTodos()), + ), + BlocProvider( + create: (context) => MunicipalitiesAdminBloc() + ..add(const LoadMunicipalities()), + ), + BlocProvider( + create: (context) => BarangayAdminBloc() + ..add(const LoadBarangayInMunicipality(cityCode: '01')), + ), + BlocProvider( + create: (context) => ClassComponentsAdminBloc() + ..add(const LoadClassComponents()), + ), + BlocProvider( + create: (context) => UnitConstructionAdminBloc() + ..add(const LoadUnitConstruct()), + ), + BlocProvider( + create: (context) => + SignatoriesAdminBloc()..add(const LoadSignatories()), + ), + BlocProvider( + create: (context) => + MemorandaAdminBloc()..add(const LoadMemoranda()), + ), + BlocProvider( + create: (context) => LandrefLocationBloc() + ..add(FetchSingleLandref(id: property_info.id!))), + BlocProvider( + create: (context) => LocationBloc() + ..add(FetchSingleLocation(id: property_info.id!))), + BlocProvider( + create: (context) => GeneralDescriptionBloc() + ..add(FetchSingleGeneralDescription( + id: property_info.id!))), + BlocProvider( + create: (context) => StructuralMaterialOfflineBloc() + ..add(FetchSingleStructuralMaterial( + id: property_info.id!))), + BlocProvider( + create: (context) => AdditionalItemsOfflineBloc() + ..add(LoadAdditionalItemsEdit( + items: const [], + id: property_info.id!))), + ], + child: EditBuildingOffline( + 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: const Icon( + Icons.maps_home_work_rounded, + color: primary, // Icon color + ), + ), + const SizedBox( + width: 20, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${property_info.owner}', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + SizedBox(height: 5), + Text( + '${property_info.tdn} - ${property_info.id}', + style: TextStyle( + fontSize: 13, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + IconButton( + onPressed: () { + deleteItem(property_info.id); + }, + icon: const Icon(Icons.delete_rounded), + color: primary, + ), + ], + ), + ), + ), + ); +} diff --git a/lib/screens/offline/passo/passo_main_dashboard.dart b/lib/screens/offline/passo/passo_main_dashboard.dart new file mode 100644 index 0000000..892dbec --- /dev/null +++ b/lib/screens/offline/passo/passo_main_dashboard.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; +import 'package:fluttericon/font_awesome5_icons.dart'; +import 'package:unit2/screens/offline/passo/admin/admin_main_screen.dart'; +import 'package:unit2/screens/offline/passo/passo_offline_dashboard.dart'; + +import '../../../theme-data.dart/colors.dart'; +import '../../unit2/homepage.dart/components/dashboard/shared_card_label.dart'; + +class PassoOfflineMainScreen extends StatelessWidget { + const PassoOfflineMainScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("PASSO Offlne Home"), + centerTitle: true, + ), + body: Padding( + padding: const EdgeInsets.all(24), + child: GridView.count( + shrinkWrap: true, + crossAxisCount: 4, + crossAxisSpacing: 8, + mainAxisSpacing: 10, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5), + children: [ + CardLabel( + icon: FontAwesome5.tools, + title: "Admin Settings", + ontap: () { + Navigator.push(context, + MaterialPageRoute(builder: ((context) { + return const AdminMainScreen(); + }))); + }), + CardLabel( + icon: FontAwesome5.eye, + title: "Field Surveyor", + ontap: () { + Navigator.push(context, + MaterialPageRoute(builder: ((context) { + return PassoOfflineDashBoard(); + }))); + }), + CardLabel( + icon: FontAwesome5.eye, + title: "Super Admin", + ontap: () { + Navigator.push(context, + MaterialPageRoute(builder: ((context) { + return PassoOfflineDashBoard(); + }))); + }) + ]))); + } +} diff --git a/lib/screens/offline/passo/passo_offline_dashboard.dart b/lib/screens/offline/passo/passo_offline_dashboard.dart new file mode 100644 index 0000000..45a1e20 --- /dev/null +++ b/lib/screens/offline/passo/passo_offline_dashboard.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'package:unit2/screens/offline/passo/building_home_offline.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/widgets/empty_data.dart'; + +import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart'; + +class PassoOfflineDashBoard extends StatefulWidget { + @override + _PassoOfflineDashBoard createState() => _PassoOfflineDashBoard(); +} + +class _PassoOfflineDashBoard extends State { + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 3, + child: Scaffold( + body: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + const 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) => CrudBloc()..add(FetchTodos()), + child: BuildingHomeOffline(), + ), + EmptyData( + message: "Sorry, this page is under construction.", + ), + EmptyData( + message: "Sorry, this page is under construction.", + ) + ], + ), + )), + ); + } +} diff --git a/lib/screens/passo/Building/add_building_components/AddExtraItems.dart b/lib/screens/passo/Building/add_building_components/AddExtraItems.dart index 2140035..37a0e6d 100644 --- a/lib/screens/passo/Building/add_building_components/AddExtraItems.dart +++ b/lib/screens/passo/Building/add_building_components/AddExtraItems.dart @@ -537,8 +537,9 @@ class _AddExtraItems extends State { _areaValue, _depValue, ), - painted: true, - secondhand: true, + painted: isPainted == true ? '1' : '0', + secondhand: + isSecondHand == true ? '1' : '0', paintedUnitval: '1', secondhandUnitval: '1'); diff --git a/lib/screens/passo/Building/add_building_components/general_description.dart b/lib/screens/passo/Building/add_building_components/general_description.dart index 05077ef..976c9ae 100644 --- a/lib/screens/passo/Building/add_building_components/general_description.dart +++ b/lib/screens/passo/Building/add_building_components/general_description.dart @@ -115,18 +115,20 @@ class _GeneralDescriptionPage extends State { 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("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: [ @@ -200,10 +202,9 @@ class _GeneralDescriptionPage extends State { 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']), + bldgAge: formKey.currentState?.value['bldg_age'], + noStoreys: + formKey.currentState?.value['no_of_storeys'], area1Stfloor: '0', area2Ndfloor: '0', area3Rdfloor: '0', diff --git a/lib/screens/passo/Building/add_building_components/property_appraisal.dart b/lib/screens/passo/Building/add_building_components/property_appraisal.dart index 7d15449..2f0061c 100644 --- a/lib/screens/passo/Building/add_building_components/property_appraisal.dart +++ b/lib/screens/passo/Building/add_building_components/property_appraisal.dart @@ -644,7 +644,7 @@ class _PropertyAppraisalPage extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Text( + child: const Text( "Cost of Additional Items", style: TextStyle( fontWeight: FontWeight.bold, @@ -653,7 +653,7 @@ class _PropertyAppraisalPage extends State { ), ), Container( - child: Text( + child: const Text( '', textAlign: TextAlign.right, ), @@ -665,7 +665,7 @@ class _PropertyAppraisalPage extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Text( + child: const Text( "Sub-total", style: TextStyle( fontWeight: FontWeight.bold, @@ -687,7 +687,7 @@ class _PropertyAppraisalPage extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Text( + child: const Text( "Total Construction Cost", style: TextStyle( fontWeight: FontWeight.bold, @@ -716,7 +716,7 @@ class _PropertyAppraisalPage extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Text( + child: const Text( "Depreciation Rate", style: TextStyle( fontWeight: FontWeight.bold, @@ -858,7 +858,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -880,7 +880,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -902,7 +902,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -924,7 +924,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -952,7 +952,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -977,7 +977,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -1009,7 +1009,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: @@ -1046,7 +1046,7 @@ class _PropertyAppraisalPage extends State { width: 100, margin: const EdgeInsets - .only( + .only( top: 15, left: 15), padding: diff --git a/lib/screens/passo/Building/add_building_components/property_assessment.dart b/lib/screens/passo/Building/add_building_components/property_assessment.dart index 127c9b0..0084998 100644 --- a/lib/screens/passo/Building/add_building_components/property_assessment.dart +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -396,7 +396,7 @@ class _PropertyAssessmentPage extends State { ), ], ), - SizedBox( + const SizedBox( height: 30, ), Row( @@ -421,14 +421,14 @@ class _PropertyAssessmentPage extends State { ), ], ), - SizedBox( + const SizedBox( height: 30, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'Date of Entry in the Rec. of Ass. :'), SizedBox( width: 100, @@ -447,7 +447,7 @@ class _PropertyAssessmentPage extends State { ), ], ), - SizedBox( + const SizedBox( height: 30, ), Row( @@ -467,7 +467,7 @@ class _PropertyAssessmentPage extends State { ), ], ), - SizedBox( + const SizedBox( height: 30, ), ElevatedButton( diff --git a/lib/screens/passo/Building/add_building_components/property_info.dart b/lib/screens/passo/Building/add_building_components/property_info.dart index 80fafaa..97f7aae 100644 --- a/lib/screens/passo/Building/add_building_components/property_info.dart +++ b/lib/screens/passo/Building/add_building_components/property_info.dart @@ -83,46 +83,44 @@ class _PropertyInfoPage extends State { 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')) - ]), + 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), CustomButton( icon: const Icon(Icons.chevron_right, color: Colors.white), onPressed: () async { try { 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()); + 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'], + faasType: "BUILDING", + ); // Dispatch the event to add the property_info context.read().add( diff --git a/lib/screens/passo/Building/edit_building/AddExtraItems.dart b/lib/screens/passo/Building/edit_building/AddExtraItems.dart index 374968d..48d353c 100644 --- a/lib/screens/passo/Building/edit_building/AddExtraItems.dart +++ b/lib/screens/passo/Building/edit_building/AddExtraItems.dart @@ -7,13 +7,14 @@ 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%20_offline.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 List options; final int tempId; AddExtraItemsEdit(this.unit, this.options, this.tempId); @@ -113,28 +114,30 @@ class _AddExtraItemsEdit extends State { items: widget.options .map((e) => DropdownMenuItem( value: e, - child: Text(e.componentName), + child: Text(e.componentName!), )) .toList(), onChanged: (value) { if (value!.minBaseUnitvalPercent != '0.00') { setState(() { - _unitValue = - double.parse(value.minBaseUnitvalPercent); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + _unitValue = double.parse( + value.minBaseUnitvalPercent!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minBaseUnitvalPercent}); } if (value.maxBaseUnitvalPercent != '0.00') { setState(() { - _unitValue = - double.parse(value.maxBaseUnitvalPercent); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + _unitValue = double.parse( + value.maxBaseUnitvalPercent!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.maxBaseUnitvalPercent}); @@ -142,10 +145,11 @@ class _AddExtraItemsEdit extends State { if (value.minUnitvalSqrmtr != '0.00') { setState(() { _unitValue = - double.parse(value.minUnitvalSqrmtr); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minUnitvalSqrmtr!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; }); formKey.currentState!.patchValue( {'unitValue': value.minUnitvalSqrmtr}); @@ -153,10 +157,12 @@ class _AddExtraItemsEdit extends State { if (value.maxUnitvalSqrmtr != '0.00') { setState(() { _unitValue = - double.parse(value.maxUnitvalSqrmtr); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxUnitvalSqrmtr!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; + ; }); formKey.currentState!.patchValue( {'unitValue': value.maxUnitvalSqrmtr}); @@ -164,10 +170,12 @@ class _AddExtraItemsEdit extends State { if (value.minAddBaseunitval != '0.00') { setState(() { _unitValue = - double.parse(value.minAddBaseunitval); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minAddBaseunitval!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; + ; }); formKey.currentState!.patchValue( {'unitValue': value.minAddBaseunitval}); @@ -175,10 +183,12 @@ class _AddExtraItemsEdit extends State { if (value.maxAddBaseunitval != '0.00') { setState(() { _unitValue = - double.parse(value.maxAddBaseunitval); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxAddBaseunitval!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; + ; }); formKey.currentState!.patchValue( {'unitValue': value.maxAddBaseunitval}); @@ -186,10 +196,12 @@ class _AddExtraItemsEdit extends State { if (value.minDeductBaserate != '0.00') { setState(() { _unitValue = - double.parse(value.minDeductBaserate); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.minDeductBaserate!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; + ; }); formKey.currentState!.patchValue( {'unitValue': value.minDeductBaserate}); @@ -197,10 +209,12 @@ class _AddExtraItemsEdit extends State { if (value.maxDeductBaserate != '0.00') { setState(() { _unitValue = - double.parse(value.maxDeductBaserate); - _className = value.componentName; - _classId = value.id; - _withoutBUCC = value.withoutBucc; + double.parse(value.maxDeductBaserate!); + _className = value.componentName!; + _classId = value.id!; + _withoutBUCC = + value.withoutBucc == '1' ? true : false; + ; }); formKey.currentState!.patchValue( {'unitValue': value.maxDeductBaserate}); @@ -548,8 +562,9 @@ class _AddExtraItemsEdit extends State { _areaValue, _depValue, ), - painted: true, - secondhand: true, + painted: isPainted == true ? '1' : '0', + secondhand: + isSecondHand == true ? '1' : '0', paintedUnitval: '1', secondhandUnitval: '1'); diff --git a/lib/screens/passo/Building/edit_building/additional_items.dart b/lib/screens/passo/Building/edit_building/additional_items.dart index 1f8ff0d..070b54a 100644 --- a/lib/screens/passo/Building/edit_building/additional_items.dart +++ b/lib/screens/passo/Building/edit_building/additional_items.dart @@ -6,6 +6,7 @@ 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%20_offline.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'; @@ -14,7 +15,7 @@ import 'package:unit2/widgets/passo/custom_button.dart'; class AdditionalItemEditPage extends StatefulWidget { final List unit; - final List options; + final List options; final int tempId; final VoidCallback NextBtn; final VoidCallback PrevBtn; diff --git a/lib/screens/passo/Building/edit_building/general_description.dart b/lib/screens/passo/Building/edit_building/general_description.dart index 6fbfc23..16c9957 100644 --- a/lib/screens/passo/Building/edit_building/general_description.dart +++ b/lib/screens/passo/Building/edit_building/general_description.dart @@ -62,9 +62,8 @@ class _GeneralDescriptionEdit extends State { final tempID = await SharedPreferences.getInstance(); await tempID.setInt( 'totalValue', int.parse(state.gendesc.totalFloorArea!)); - await tempID.setString( + await tempID.setString( 'actualUse', state.gendesc.actualUse!); - } if (state is GenDescErrorState) { final progress = ProgressHUD.of(context); @@ -313,8 +312,8 @@ class _GeneralDescriptionEdit extends State { 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']), + bldgAge: keys.currentState?.value['bldg_age'], + noStoreys: 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'], diff --git a/lib/screens/passo/Building/edit_building/property_owner_info.dart b/lib/screens/passo/Building/edit_building/property_owner_info.dart index 5a32955..4dc028b 100644 --- a/lib/screens/passo/Building/edit_building/property_owner_info.dart +++ b/lib/screens/passo/Building/edit_building/property_owner_info.dart @@ -200,32 +200,28 @@ class _PropertyOwnerInfoEdit extends State { 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()); + 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'], + ); context.read().add( UpdatPropertyInfo( diff --git a/lib/screens/passo/passo_dashboard.dart b/lib/screens/passo/passo_dashboard.dart index 2380afe..ee11660 100644 --- a/lib/screens/passo/passo_dashboard.dart +++ b/lib/screens/passo/passo_dashboard.dart @@ -21,7 +21,7 @@ class _PassoDashBoard extends State { body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ - new SliverAppBar( + const SliverAppBar( backgroundColor: primary, title: Text('Faas Dashboard'), centerTitle: true, diff --git a/lib/screens/unit2/basic-info/components/qr_image.dart b/lib/screens/unit2/basic-info/components/qr_image.dart index e799ed3..6aa76fb 100644 --- a/lib/screens/unit2/basic-info/components/qr_image.dart +++ b/lib/screens/unit2/basic-info/components/qr_image.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; -<<<<<<< HEAD -======= import 'package:flutter/src/widgets/placeholder.dart'; ->>>>>>> develop import 'package:qr_flutter/qr_flutter.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; @@ -16,12 +13,12 @@ class QRFullScreenImage extends StatelessWidget { return Scaffold( appBar: AppBar( centerTitle: true, - backgroundColor: primary,title: const Text("Profile QR Code"),), - body: Center( - child: QrImageView( - data: uuid, - size: blockSizeVertical * 50 - ), - ),); + backgroundColor: primary, + title: const Text("Profile QR Code"), + ), + body: Center( + child: QrImageView(data: uuid, size: blockSizeVertical * 50), + ), + ); } } diff --git a/lib/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart new file mode 100644 index 0000000..b848fae --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/barangay_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class BrgyAdminApiServices { + static final BrgyAdminApiServices _instance = BrgyAdminApiServices(); + static BrgyAdminApiServices get instance => _instance; + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future fetch() async { + String path = Url.instance.getBarangay(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + try { + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/class_components_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/class_components_api_services.dart new file mode 100644 index 0000000..04b476d --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/class_components_api_services.dart @@ -0,0 +1,38 @@ +import 'dart:convert'; + +import '../../../../../utils/request.dart'; +import '../../../../../utils/urls.dart'; +import 'package:http/http.dart' as http; + +class ClassComponentAdminApiServices { + static final ClassComponentAdminApiServices _instance = + ClassComponentAdminApiServices(); + static ClassComponentAdminApiServices 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); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/memoranda_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/memoranda_api_services.dart new file mode 100644 index 0000000..057a7cd --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/memoranda_api_services.dart @@ -0,0 +1,39 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class MemorandaAdminApiServices { + static final MemorandaAdminApiServices _instance = + MemorandaAdminApiServices(); + static MemorandaAdminApiServices 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); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart new file mode 100644 index 0000000..3140720 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/municipalities_api_services.dart @@ -0,0 +1,42 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'package:unit2/sevices/passo/municipality.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class MunicipalityAdminApiServices { + static final MunicipalityAdminApiServices _instance = + MunicipalityAdminApiServices(); + static MunicipalityAdminApiServices 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); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/signatories.dart b/lib/sevices/offline/offline_passo/admin/api_services/signatories.dart new file mode 100644 index 0000000..9380f46 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/signatories.dart @@ -0,0 +1,42 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'package:unit2/sevices/passo/municipality.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class SignatoriesAdminApiServices { + static final SignatoriesAdminApiServices _instance = + SignatoriesAdminApiServices(); + static SignatoriesAdminApiServices 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(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/api_services/unit_construction_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/unit_construction_api_services.dart new file mode 100644 index 0000000..c1c4d3d --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/unit_construction_api_services.dart @@ -0,0 +1,39 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class UnitConstructionAdminApiServices { + static final UnitConstructionAdminApiServices _instance = + UnitConstructionAdminApiServices(); + static UnitConstructionAdminApiServices 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); + + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + print(result); + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart new file mode 100644 index 0000000..cc29fd9 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart @@ -0,0 +1,785 @@ +import 'dart:convert'; + +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; +import 'package:unit2/model/passo/bldg_loc.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/signatories.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/barangay.dart'; +import '../../../../../model/passo/class_components _offline.dart'; +import '../../../../../model/passo/general_description.dart'; +import '../../../../../model/passo/memoranda.dart'; +import '../../../../../model/passo/property_appraisal.dart'; +import '../../../../../model/passo/property_assessment.dart'; +import '../../../../../model/passo/property_info.dart'; +import '../../../../../model/passo/structureMaterial.dart'; + +class SQLServices { + static final SQLServices instance = SQLServices._init(); + static Database? _database; + SQLServices._init(); + + Future get database async { + if (_database != null) return _database!; + + _database = await _initDB('passo.db'); + return _database!; + } + + Future _initDB(String filePath) async { + final dbPath = await getDatabasesPath(); + final path = join(dbPath, filePath); + + return await openDatabase(path, version: 1, onCreate: _createDB); + } + + Future _createDB(Database db, int version) async { + await db.execute(''' + CREATE TABLE municipalities ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + cityCode TEXT NOT NULL, + cityDescription TEXT NOT NULL + ) + '''); + await db.execute(''' + CREATE TABLE barangay ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + barangayId INTEGER NOT NULL, + barangayCode TEXT NOT NULL, + cityCode TEXT NOT NULL, + barangayDescription TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE class_components ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + componentName TEXT NOT NULL, + minBaseUnitvalPercent TEXT NOT NULL, + maxBaseUnitvalPercent TEXT NOT NULL, + minUnitvalSqrmtr TEXT NOT NULL, + maxUnitvalSqrmtr TEXT NOT NULL, + minAddBaseunitval TEXT NOT NULL, + maxAddBaseunitval TEXT NOT NULL, + minDeductBaserate TEXT NOT NULL, + maxDeductBaserate TEXT NOT NULL, + minLinearMeter TEXT NOT NULL, + maxLinearMeter TEXT NOT NULL, + minSpacing TEXT NOT NULL, + maxSpacing TEXT NOT NULL, + roughFinish TEXT NOT NULL, + highFinish TEXT NOT NULL, + withoutBucc INTEGER NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE unit_construction ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgType TEXT NOT NULL, + building TEXT NOT NULL, + unitValue TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE signatories ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + signatoryId INTEGER NOT NULL, + firstname TEXT NOT NULL, + middlename TEXT NOT NULL, + lastname TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE memoranda ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + code TEXT NOT NULL, + memoranda TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE bldg_owner ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + transCode TEXT NOT NULL, + tdn TEXT NOT NULL, + pin TEXT NOT NULL, + owner TEXT NOT NULL, + address TEXT NOT NULL, + telno TEXT NOT NULL, + tin TEXT NOT NULL, + adminUser TEXT NOT NULL, + adminAddress TEXT NOT NULL, + adminTelno TEXT NOT NULL, + adminTin TEXT NOT NULL, + faasType TEXT NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE landref ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + owner TEXT NOT NULL, + cloaNo TEXT NOT NULL, + lotNo TEXT NOT NULL, + tdn TEXT NOT NULL, + area TEXT NOT NULL, + surveyNo TEXT NOT NULL, + blkNo TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE bldgloc ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + street TEXT NOT NULL, + barangay TEXT NOT NULL, + municipality TEXT NOT NULL, + province TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE gendesc ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + bldgKind TEXT NOT NULL, + strucType TEXT NOT NULL, + bldgPermit TEXT NOT NULL, + dateIssued TEXT NOT NULL, + cct TEXT NOT NULL, + certCompletionIssued TEXT NOT NULL, + certOccupancyIssued TEXT NOT NULL, + dateCompleted TEXT NOT NULL, + dateOccupied TEXT NOT NULL, + bldgAge TEXT NOT NULL, + noStoreys TEXT NOT NULL, + area1Stfloor TEXT NOT NULL, + area2Ndfloor TEXT NOT NULL, + area3Rdfloor TEXT NOT NULL, + area4Thfloor TEXT NOT NULL, + totalFloorArea TEXT NOT NULL, + floorSketch TEXT NOT NULL, + actualUse TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE structural_materials ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + foundation TEXT NOT NULL, + columns TEXT NOT NULL, + beams TEXT NOT NULL, + trussFraming TEXT NOT NULL, + roof TEXT NOT NULL, + flooring TEXT NOT NULL, + walls TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE bldg_appraisal ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + dateCreated TEXT NOT NULL, + dateModified TEXT NOT NULL, + unitconstructCost TEXT NOT NULL, + buildingCore TEXT NOT NULL, + unitconstructSubtotal TEXT NOT NULL, + depreciationRate TEXT NOT NULL, + depreciationCost TEXT NOT NULL, + costAddItems TEXT NOT NULL, + addItemsSubtotal TEXT NOT NULL, + totalpercentDepreciation TEXT NOT NULL, + marketValue TEXT NOT NULL, + totalArea TEXT NOT NULL, + actualUse TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE bldg_assessment ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + actualUse TEXT NOT NULL, + marketValue TEXT NOT NULL, + assessmentLevel TEXT NOT NULL, + assessedValue TEXT NOT NULL, + taxable TEXT NOT NULL, + exempt TEXT NOT NULL, + qtr TEXT NOT NULL, + yr TEXT NOT NULL, + appraisedbyName TEXT NOT NULL, + appraisedbyDate TEXT NOT NULL, + recommendapprName TEXT NOT NULL, + recommendapprDate TEXT NOT NULL, + approvedbyName TEXT NOT NULL, + memoranda TEXT NOT NULL, + swornstatementNo TEXT NOT NULL, + dateReceived TEXT NOT NULL, + entryDateAssessment TEXT NOT NULL, + entryDateBy TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE additionalitems ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + classId INTEGER NOT NULL, + className TEXT NOT NULL, + structType TEXT NOT NULL, + unitValue TEXT NOT NULL, + baseUnitValue TEXT NOT NULL, + area TEXT NOT NULL, + marketValue TEXT NOT NULL, + depreciationRate TEXT NOT NULL, + adjustedMarketVal TEXT NOT NULL, + amtDepreciation TEXT NOT NULL, + painted TEXT NOT NULL, + secondhand TEXT NOT NULL, + paintedUnitval TEXT NOT NULL, + secondhandUnitval TEXT NOT NULL, + actualUse TEXT NOT NULL + ) + '''); + } + + //Municipalities + + Future createMunicipalities(City city) async { + final db = await instance.database; + + final data = { + "id": city.id, + "cityCode": city.cityCode, + "cityDescription": city.cityDescription, + }; + final id = await db.insert('municipalities', data); + return city.copy(id: id); + } + + Future> readAllMunicipalities() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('municipalities', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => City.fromJson2(json)).toList(); + } + + //Barangay + + Future createBarangay(Brgy brgy) async { + final db = await instance.database; + + final data = { + "barangayId": brgy.barangayId, + "barangayCode": brgy.barangayCode, + "cityCode": brgy.cityCode, + "barangayDescription": brgy.barangayDescription + }; + final id = await db.insert('barangay', data); + return brgy.copy(id: id); + } + + Future> readBrgyInSelectedMunicipality(cityCode) async { + final db = await instance.database; + const orderBy = 'id'; + // Use a placeholder for the WHERE clause and provide the value separately. + final params = [cityCode]; // List of values to substitute + + final result = await db.query('barangay', + orderBy: orderBy, where: 'cityCode = ?', whereArgs: params); + print('result'); + print(cityCode); + print(result.toString()); + + return result.map((json) => Brgy.fromJson2(json)).toList(); + } + + Future> readAllBarangay() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('barangay', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => Brgy.fromJson2(json)).toList(); + } + + //Class components + + Future createClassComponents( + ClassComponentsOffline classes) async { + final db = await instance.database; + + final data = { + "componentName": classes.componentName, + "minBaseUnitvalPercent": classes.minBaseUnitvalPercent, + "maxBaseUnitvalPercent": classes.maxBaseUnitvalPercent, + "minUnitvalSqrmtr": classes.minUnitvalSqrmtr, + "maxUnitvalSqrmtr": classes.maxUnitvalSqrmtr, + "minAddBaseunitval": classes.minAddBaseunitval, + "maxAddBaseunitval": classes.maxAddBaseunitval, + "minDeductBaserate": classes.minDeductBaserate, + "maxDeductBaserate": classes.maxDeductBaserate, + "minLinearMeter": classes.minLinearMeter, + "maxLinearMeter": classes.maxLinearMeter, + "minSpacing": classes.minSpacing, + "maxSpacing": classes.maxSpacing, + "roughFinish": classes.roughFinish, + "highFinish": classes.highFinish, + "withoutBucc": classes.withoutBucc + }; + final id = await db.insert('class_components', data); + return classes.copy(id: id); + } + + Future> readAllClassComponents() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('class_components', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result + .map((json) => ClassComponentsOffline.fromJson2(json)) + .toList(); + } + + //Unit construction + + Future createUnitConstruction(UnitConstruct unit) async { + final db = await instance.database; + + final data = { + "bldgType": unit.bldgType, + "building": unit.building, + "unitValue": unit.unitValue + }; + final id = await db.insert('unit_construction', data); + return unit.copy(id: id); + } + + Future> readAllUnitConstruct() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('unit_construction', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => UnitConstruct.fromJson2(json)).toList(); + } + + //Signatories + + Future createSignatories(Signatories signatories) async { + final db = await instance.database; + + final data = { + "signatoryId": signatories.signatoryId, + "firstname": signatories.firstname, + "middlename": signatories.middlename, + "lastname": signatories.lastname + }; + final id = await db.insert('signatories', data); + return signatories.copy(id: id); + } + + Future> readAllSignatories() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('signatories', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => Signatories.fromJson2(json)).toList(); + } + + // Memoranda + + Future createMemoranda(Memoranda memo) async { + final db = await instance.database; + + final data = { + "id": memo.id, + "code": memo.code, + "memoranda": memo.memoranda + }; + final id = await db.insert('memoranda', data); + return memo.copy(id: id); + } + + Future> readAllMemoranda() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('memoranda', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => Memoranda.fromJson2(json)).toList(); + } + + //BLDG Owner + + Future createBldgOwner(PropertyInfo propertyInfo) async { + final db = await instance.database; + + final data = { + "id": propertyInfo.id, + "transCode": propertyInfo.transCode, + "tdn": propertyInfo.tdn, + "pin": propertyInfo.pin, + "owner": propertyInfo.owner, + "address": propertyInfo.address, + "telno": propertyInfo.telno, + "tin": propertyInfo.tin, + "adminUser": propertyInfo.adminUser, + "adminAddress": propertyInfo.adminAddress, + "adminTelno": propertyInfo.adminTelno, + "adminTin": propertyInfo.adminTin, + "faasType": propertyInfo.faasType, + "assessedById": propertyInfo.assessedById, + "assessedByName": propertyInfo.assessedByName, + }; + final id = await db.insert('bldg_owner', data); + final tempID = await SharedPreferences.getInstance(); + print(id); + await tempID.setInt('tempid', id); + return propertyInfo.copy(id: id); + } + + Future> readAllBldgOwner() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('bldg_owner', orderBy: orderBy); + + return result.map((json) => PropertyInfo.fromJson(json)).toList(); + } + + Future deleteBldgOwner({required int id}) async { + final db = await instance.database; + + return await db.delete( + 'bldg_owner', + where: 'id = ?', + whereArgs: [id], + ); + } + + //Bldg Land Ref + Future createBldgLandRef(LandRef landref) async { + final db = await instance.database; + + final data = { + "bldgapprDetailsId": landref.bldgapprDetailsId, + "assessedById": landref.assessedById, + "assessedByName": landref.assessedByName, + "dateCreated": "000", + "dateModified": "000", + "owner": landref.owner, + "cloaNo": landref.cloaNo, + "lotNo": landref.lotNo, + "tdn": landref.tdn, + "area": landref.area, + "surveyNo": landref.surveyNo, + "blkNo": landref.blkNo + }; + final id = await db.insert('landref', data); + print(landref.copy(id: id).toJson()); + return landref.copy(id: id); + } + + // Future getLandRef({required int id}) async { + // final db = await instance.database; + // final maps = await db.query('landref', + // where: "bldgapprDetailsId = ?", whereArgs: [id], limit: 1); + // print(maps[0].toString()); + // if (maps.isNotEmpty) { + // final firstMap = maps[0]; + // return LandRef.fromJson2(firstMap); + // } else { + // return null; // No data found + // } + // } + + Future>> getLandRef(id) async { + final db = await instance.database; + int ids = id; + print('id'); + print(id); + final result = await db + .query('landref', where: 'bldgapprDetailsId = ?', whereArgs: [ids]); + + print('landref test result'); + + if (result.isNotEmpty) { + final firstRow = result[0]; + print(firstRow); + } else { + print('No data found.'); + } + + return result; + } + + Future> getAllLandRef() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('landref', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => LandRef.fromJson2(json)).toList(); + } + + //Bldg Location + Future createBldglocation(BldgLoc bldgloc) async { + final db = await instance.database; + + final data = { + "bldgapprDetailsId": bldgloc.bldgapprDetailsId, + "assessedById": bldgloc.assessedById, + "assessedByName": bldgloc.assessedByName, + "dateCreated": "000", + "dateModified": "000", + "street": bldgloc.street, + "barangay": bldgloc.barangay, + "municipality": bldgloc.municipality, + "province": bldgloc.province + }; + final id = await db.insert('bldgloc', data); + + print(id); + + return bldgloc.copy(id: id); + } + + Future>> getLocation(id) async { + final db = await instance.database; + final results = await db.query('bldgloc', + where: "bldgapprDetailsId = ?", whereArgs: [id], limit: 1); + print('loc test result'); + print(results); + + return results; + } + + //Bldg General Description + + Future createBldgGeneralDescription(GeneralDesc gendesc) async { + final db = await instance.database; + + final data = { + "bldgapprDetailsId": gendesc.bldgapprDetailsId, + "assessedById": gendesc.assessedById, + "assessedByName": gendesc.assessedByName, + "dateCreated": 'None', + "dateModified": 'None', + "bldgKind": gendesc.bldgKind, + "strucType": gendesc.strucType, + "bldgPermit": gendesc.bldgPermit, + "dateIssued": gendesc.dateIssued, + "cct": gendesc.cct, + "certCompletionIssued": gendesc.certCompletionIssued, + "certOccupancyIssued": gendesc.certOccupancyIssued, + "dateCompleted": gendesc.dateCompleted, + "dateOccupied": gendesc.dateOccupied, + "bldgAge": gendesc.bldgAge, + "noStoreys": gendesc.noStoreys, + "area1Stfloor": gendesc.area1Stfloor, + "area2Ndfloor": gendesc.area2Ndfloor, + "area3Rdfloor": gendesc.area3Rdfloor, + "area4Thfloor": gendesc.area4Thfloor, + "totalFloorArea": gendesc.totalFloorArea, + "floorSketch": 'None', + "actualUse": gendesc.actualUse + }; + final id = await db.insert('gendesc', data); + print(gendesc.copy(id: id)); + return gendesc.copy(id: id); + } + + Future>> getGeneralDescription(id) async { + final db = await instance.database; + final results = await db.query('gendesc', + where: "bldgapprDetailsId = ?", whereArgs: [id], limit: 1); + print('gendesc test result'); + print(results); + + return results; + } + + //Structural Materials + + Future createStructuralMaterials( + StructureMaterialsII materials) async { + final db = await instance.database; + + final data = { + // "id": materials.id, + "bldgapprDetailsId": materials.bldgapprDetailsId, + "foundation": materials.foundation!.join(', ').splitMapJoin(', '), + "columns": materials.columns!.join(', ').splitMapJoin(', '), + "beams": materials.beams!.join(', ').splitMapJoin(', '), + "trussFraming": materials.trussFraming!.join(', ').splitMapJoin(', '), + "roof": materials.roof!.join(', ').splitMapJoin(', '), + "flooring": materials.flooring!.join(', ').splitMapJoin(', '), + "walls": materials.walls!.join(', ').splitMapJoin(', '), + }; + final id = await db.insert('structural_materials', data); + print('gendesc test idcopy'); + print(id); + return materials.copy(id: id); + } + + Future>> getStructuralMaterials(id) async { + final db = await instance.database; + final results = await db.query('structural_materials', + where: "id = ?", whereArgs: [id], limit: 1); + print('strucmat test result'); + print(results); + + return results; + } + + //Additional Items + + Future createAdditionalItems( + AdditionalItems addItems) async { + final db = await instance.database; + + final data = { + // "id": addItems.id, + "bldgapprDetailsId": addItems.bldgapprDetailsId, + "classId": addItems.classId, + "className": addItems.className, + "structType": addItems.structType, + "unitValue": addItems.unitValue, + "baseUnitValue": addItems.baseUnitValue, + "area": addItems.area, + "marketValue": addItems.marketValue, + "depreciationRate": addItems.depreciationRate, + "adjustedMarketVal": addItems.adjustedMarketVal, + "amtDepreciation": addItems.amtDepreciation, + "painted": addItems.painted == true ? '1' : 0, + "secondhand": addItems.secondhand == true ? '1' : 0, + "paintedUnitval": addItems.paintedUnitval, + "secondhandUnitval": addItems.secondhandUnitval, + "actualUse": addItems.actualUse + }; + final id = await db.insert('additionalitems', data); + return addItems.copy(id: id); + } + + Future> readAdditionalItems() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('additionalitems', orderBy: orderBy); + + return result.map((json) => AdditionalItems.fromJson(json)).toList(); + } + + Future>> getAdditionalItems(id) async { + final db = await instance.database; + final results = await db.query('additionalitems', + where: "bldgapprDetailsId = ?", whereArgs: [id]); + print('add edit test result'); + print(results); + + return results; + } + + //Bldg Appraisal + + Future createBldgAppraisal( + PropertyAppraisal appraisal) async { + final db = await instance.database; + + final data = { + "id": appraisal.id, + "bldgapprDetailsId": appraisal.bldgapprDetailsId, + "assessedById": appraisal.assessedById, + "assessedByName": appraisal.assessedByName, + "dateCreated": appraisal.dateCreated, + "dateModified": appraisal.dateModified, + "unitconstructCost": appraisal.unitconstructCost, + "buildingCore": appraisal.buildingCore, + "unitconstructSubtotal": appraisal.unitconstructSubtotal, + "depreciationRate": appraisal.depreciationRate, + "depreciationCost": appraisal.depreciationCost, + "costAddItems": appraisal.costAddItems, + "addItemsSubtotal": appraisal.addItemsSubtotal, + "totalpercentDepreciation": appraisal.totalpercentDepreciation, + "marketValue": appraisal.marketValue, + "totalArea": appraisal.totalArea, + "actualUse": appraisal.actualUse + }; + final id = await db.insert('bldg_appraisal', data); + return appraisal.copy(id: id); + } + + //Bldg Assessment + Future createBldgAssessment( + PropertyAssessment assessment) async { + final db = await instance.database; + + final data = { + "id": assessment.id, + "bldgapprDetailsId": assessment.bldgapprDetailsId, + "actualUse": assessment.actualUse, + "marketValue": assessment.marketValue, + "assessmentLevel": assessment.assessmentLevel, + "assessedValue": assessment.assessedValue, + "taxable": assessment.taxable, + "exempt": assessment.exempt, + "qtr": assessment.qtr, + "yr": assessment.yr, + "appraisedbyName": assessment.appraisedbyName, + "appraisedbyDate": assessment.appraisedbyDate, + "recommendapprName": assessment.recommendapprName, + "recommendapprDate": assessment.recommendapprDate, + "approvedbyName": assessment.approvedbyName, + "memoranda": assessment.memoranda, + "swornstatementNo": assessment.swornstatementNo, + "dateReceived": assessment.dateReceived, + "entryDateAssessment": assessment.entryDateAssessment, + "entryDateBy": assessment.entryDateBy + }; + final id = await db.insert('bldg_assessment', data); + return assessment.copy(id: id); + } +} diff --git a/lib/sevices/offline/offline_passo/building/landref_services.dart b/lib/sevices/offline/offline_passo/building/landref_services.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/sevices/offline/offline_passo/building/location_services.dart b/lib/sevices/offline/offline_passo/building/location_services.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/sevices/offline/offline_passo/building/property_owner_info_service.dart b/lib/sevices/offline/offline_passo/building/property_owner_info_service.dart new file mode 100644 index 0000000..87ccb03 --- /dev/null +++ b/lib/sevices/offline/offline_passo/building/property_owner_info_service.dart @@ -0,0 +1,288 @@ +import 'package:path/path.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:unit2/model/passo/additional_items.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 '../../../../model/passo/todo.dart'; + +class PropertyOwnerInfoServices { + static final PropertyOwnerInfoServices instance = + PropertyOwnerInfoServices._init(); + static Database? _database; + PropertyOwnerInfoServices._init(); + + Future get database async { + if (_database != null) return _database!; + + _database = await _initDB('passo.db'); + return _database!; + } + + Future _initDB(String filePath) async { + final dbPath = await getDatabasesPath(); + final path = join(dbPath, filePath); + + return await openDatabase(path, version: 1, onCreate: _createDB); + } + + Future _createDB(Database db, int version) async { + // const idType = 'INTEGER PRIMARY KEY AUTOINCREMENT'; + // const textType = 'TEXT NOT NULL'; + // const boolType = 'BOOLEAN NOT NULL'; + // const integerType = 'INTEGER NOT NULL'; + + await db.execute(''' + CREATE TABLE items ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + transCode TEXT NOT NULL, + tdn TEXT NOT NULL, + pin TEXT NOT NULL, + owner TEXT NOT NULL, + address TEXT NOT NULL, + telno TEXT NOT NULL, + tin TEXT NOT NULL, + adminUser TEXT NOT NULL, + adminAddress TEXT NOT NULL, + adminTelno TEXT NOT NULL, + adminTin TEXT NOT NULL, + faasType TEXT NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE landref ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + owner TEXT NOT NULL, + cloaNo TEXT NOT NULL, + lotNo TEXT NOT NULL, + tdn TEXT NOT NULL, + area TEXT NOT NULL, + surveyNo TEXT NOT NULL, + blkNo TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE location ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + street TEXT NOT NULL, + barangay TEXT NOT NULL, + municipality TEXT NOT NULL, + province TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE additionalitems ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + classId TEXT NOT NULL, + className TEXT NOT NULL, + structType TEXT NOT NULL, + unitValue TEXT NOT NULL, + baseUnitValue TEXT NOT NULL, + area TEXT NOT NULL, + marketValue TEXT NOT NULL, + depreciationRate TEXT NOT NULL, + adjustedMarketVal TEXT NOT NULL, + amtDepreciation TEXT NOT NULL, + painted TEXT NOT NULL, + secondhand TEXT NOT NULL, + paintedUnitval TEXT NOT NULL, + secondhandUnitval TEXT NOT NULL, + actualUse TEXT NOT NULL + ) + '''); + } + + Future create(PropertyInfo propertyInfo) async { + final db = await instance.database; + + final data = { + "id": propertyInfo.id, + "transCode": propertyInfo.transCode, + "tdn": propertyInfo.tdn, + "pin": propertyInfo.pin, + "owner": propertyInfo.owner, + "address": propertyInfo.address, + "telno": propertyInfo.telno, + "tin": propertyInfo.tin, + "adminUser": propertyInfo.adminUser, + "adminAddress": propertyInfo.adminAddress, + "adminTelno": propertyInfo.adminTelno, + "adminTin": propertyInfo.adminTin, + "faasType": propertyInfo.faasType, + "assessedById": propertyInfo.assessedById, + "assessedByName": propertyInfo.assessedByName, + }; + final id = await db.insert('items', data); + return propertyInfo.copy(id: id); + } + + Future createLandRef(LandRef landref) async { + final db = await instance.database; + + final data = { + "id": landref.id, + "bldgapprDetailsId": landref.bldgapprDetailsId, + "assessedById": landref.assessedById, + "assessedByName": landref.assessedByName, + "cloaNo": landref.cloaNo, + "lotNo": landref.lotNo, + "tdn": landref.tdn, + "area": landref.area, + "surveyNo": landref.surveyNo, + "blkNo": landref.blkNo + }; + final id = await db.insert('landref', data); + return landref.copy(id: id); + } + + Future createLocation(BldgLoc loc) async { + final db = await instance.database; + + final data = { + "id": loc.id, + "bldgapprDetailsId": loc.bldgapprDetailsId, + "assessedById": loc.assessedById, + "assessedByName": loc.assessedByName, + "street": loc.street, + "barangay": loc.barangay, + "municipality": loc.municipality, + "province": loc.province + }; + final id = await db.insert('location', data); + return loc.copy(id: id); + } + + Future createGenDesc(GeneralDesc gendesc) async { + final db = await instance.database; + + final data = { + "id": gendesc.id, + "bldgapprDetailsId": gendesc.bldgapprDetailsId, + "assessedById": gendesc.assessedById, + "assessedByName": gendesc.assessedByName, + "dateCreated": gendesc.dateCreated, + "dateModified": gendesc.dateModified, + "bldgKind": gendesc.bldgKind, + "strucType": gendesc.strucType, + "bldgPermit": gendesc.bldgPermit, + "dateIssued": gendesc.dateIssued, + "cct": gendesc.cct, + "certCompletionIssued": gendesc.certCompletionIssued, + "certOccupancyIssued": gendesc.certOccupancyIssued, + "dateCompleted": gendesc.dateCompleted, + "dateOccupied": gendesc.dateOccupied, + "bldgAge": gendesc.bldgAge, + "noStoreys": gendesc.noStoreys, + "area1Stfloor": gendesc.area1Stfloor, + "area2Ndfloor": gendesc.area2Ndfloor, + "area3Rdfloor": gendesc.area3Rdfloor, + "area4Thfloor": gendesc.area4Thfloor, + "totalFloorArea": gendesc.totalFloorArea, + "floorSketch": gendesc.floorSketch, + "actualUse": gendesc.actualUse + }; + final id = await db.insert('location', data); + return gendesc.copy(id: id); + } + + Future createAdditionalItems( + AdditionalItems addItems) async { + final db = await instance.database; + + final data = { + "id": addItems.id, + "bldgapprDetailsId": addItems.bldgapprDetailsId, + "classId": addItems.classId, + "className": addItems.className, + "structType": addItems.structType, + "unitValue": addItems.unitValue, + "baseUnitValue": addItems.baseUnitValue, + "area": addItems.area, + "marketValue": addItems.marketValue, + "depreciationRate": addItems.depreciationRate, + "adjustedMarketVal": addItems.adjustedMarketVal, + "amtDepreciation": addItems.amtDepreciation, + "painted": addItems.painted, + "secondhand": addItems.secondhand, + "paintedUnitval": addItems.paintedUnitval, + "secondhandUnitval": addItems.secondhandUnitval, + "actualUse": addItems.actualUse + }; + final id = await db.insert('additionalitems', data); + return addItems.copy(id: id); + } + + Future readTodo({required int id}) async { + final db = await instance.database; + + final maps = await db.query( + todoTable, + columns: TodoFields.values, + where: '${TodoFields.id} = ?', + whereArgs: [id], + ); + + if (maps.isNotEmpty) { + return Todo.fromJson(maps.first); + } else { + throw Exception('ID $id not found'); + } + } + + Future> readAllTodos() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('items', orderBy: orderBy); + + return result.map((json) => PropertyInfo.fromJson(json)).toList(); + } + + Future> readAdditionalItems() async { + final db = await instance.database; + const orderBy = 'id'; + final result = await db.query('additional_items', orderBy: orderBy); + + return result.map((json) => AdditionalItems.fromJson(json)).toList(); + } + + Future update({required Todo todo}) async { + final db = await instance.database; + + return db.update( + todoTable, + todo.toJson(), + where: '${TodoFields.id} = ?', + whereArgs: [todo.id], + ); + } + + Future delete({required int id}) async { + final db = await instance.database; + + return await db.delete( + 'items', + where: 'id = ?', + whereArgs: [id], + ); + } + + Future close() async { + final db = await instance.database; + + db.close(); + } +} diff --git a/lib/utils/sql_helper.dart b/lib/utils/sql_helper.dart new file mode 100644 index 0000000..2e12f18 --- /dev/null +++ b/lib/utils/sql_helper.dart @@ -0,0 +1,58 @@ +import 'package:sqflite/sqflite.dart' as sql; +import 'package:sqflite/sqflite.dart'; + +Future _createDB(Database db, int version) async { + // const idType = 'INTEGER PRIMARY KEY AUTOINCREMENT'; + // const textType = 'TEXT NOT NULL'; + // const boolType = 'BOOLEAN NOT NULL'; + // const integerType = 'INTEGER NOT NULL'; + + await db.execute(''' + CREATE TABLE items ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + transCode TEXT NOT NULL, + tdn TEXT NOT NULL, + pin TEXT NOT NULL, + owner TEXT NOT NULL, + address TEXT NOT NULL, + telno TEXT NOT NULL, + tin TEXT NOT NULL, + adminUser TEXT NOT NULL, + adminAddress TEXT NOT NULL, + adminTelno TEXT NOT NULL, + adminTin TEXT NOT NULL, + faasType TEXT NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE landref ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + owner TEXT NOT NULL, + cloaNo TEXT NOT NULL, + lotNo TEXT NOT NULL, + tdn TEXT NOT NULL, + area TEXT NOT NULL, + surveyNo TEXT NOT NULL, + blkNo TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE location ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + assessedById TEXT NOT NULL, + assessedByName TEXT NOT NULL, + street TEXT NOT NULL, + barangay TEXT NOT NULL, + municipality TEXT NOT NULL, + province TEXT NOT NULL + ) + '''); +} diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index 17704f3..b6b3eb9 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -5,11 +5,11 @@ class Url { String host() { // return '192.168.10.183:3000'; - // return 'agusandelnorte.gov.ph'; + return 'agusandelnorte.gov.ph'; // return "192.168.10.219:3000"; // return "192.168.10.241"; // return "192.168.10.221:3004"; - return "playweb.agusandelnorte.gov.ph"; + // return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; // return "192.168.10.218:8000"; } diff --git a/lib/widgets/passo/custom_text.dart b/lib/widgets/passo/custom_text.dart new file mode 100644 index 0000000..1a3bd0f --- /dev/null +++ b/lib/widgets/passo/custom_text.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class CustomText extends StatelessWidget { + final String text; + const CustomText({Key? key, required this.text}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text( + text, + style: const TextStyle(fontSize: 21), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 2546275..70e9e47 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -25,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + animated_splash_screen: + dependency: "direct main" + description: + name: animated_splash_screen + sha256: f45634db6ec4e8cf034c53e03f3bd83898a16fe3c9286bf5510b6831dfcf2124 + url: "https://pub.dev" + source: hosted + version: "1.3.0" app_popup_menu: dependency: "direct main" description: @@ -973,6 +981,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + page_transition: + dependency: transitive + description: + name: page_transition + sha256: dee976b1f23de9bbef5cd512fe567e9f6278caee11f5eaca9a2115c19dc49ef6 + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -981,14 +997,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" - path_drawing: - dependency: transitive - description: - name: path_drawing - sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.dev" - source: hosted - version: "1.0.1" path_parsing: dependency: transitive description: @@ -1755,5 +1763,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.1.0 <4.0.0" flutter: ">=3.13.0"