From b5ef3befb40757484d1df882aa2fcac7ffe7dbe2 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Fri, 3 Jan 2025 14:33:38 +0800 Subject: [PATCH] additional changes for for image uploads --- assets/pngs/broken_lines.png | Bin 0 -> 9229 bytes assets/pngs/id-card.png | Bin 0 -> 2617 bytes .../assessment_level_bloc.dart | 53 + .../assessment_level_event.dart | 50 + .../assessment_level_state.dart | 18 + .../bldg_assessment_offline_bloc.dart | 11 +- .../general_description_bloc.dart | 13 +- .../general_description_event.dart | 2 +- .../general_description_state.dart | 12 + .../landref/landref_location_bloc.dart | 14 +- .../landref/landref_location_event.dart | 2 +- .../landref/landref_location_state.dart | 12 + .../building/location/location_bloc.dart | 14 +- .../building/location/location_state.dart | 12 + .../building/owner_info_bloc/crud_bloc.dart | 333 +- .../building/owner_info_bloc/crud_event.dart | 10 +- .../structural_material_offline_bloc.dart | 22 +- .../structural_material_offline_state.dart | 13 + .../swornstatement/sworn_statement_bloc.dart | 56 + .../swornstatement/sworn_statement_event.dart | 56 + .../swornstatement/sworn_statement_state.dart | 26 + .../property_assessment_edit_bloc.dart | 26 +- .../property_info/property_info_bloc.dart | 3 +- lib/bloc/user/user_bloc.dart | 4 + .../login_data/employee_info/department.dart | 6 +- .../employee_info/employee_info.dart | 6 +- lib/model/passo/assessment_level.dart | 84 + lib/model/passo/esignature.dart | 95 + lib/model/passo/property_info.dart | 26 +- lib/model/passo/sworn_statement.dart | 98 + lib/model/passo/valid_ids.dart | 83 + .../passo/admin/admin_main_screen.dart | 16 + .../offline/passo/admin/assessment_level.dart | 120 + .../add/AddBuildingAndStructure..dart | 31 +- .../building/add/AddExtraItemsOffline.dart | 86 +- .../passo/building/add/add_building.dart | 43 +- .../passo/building/add/drawing_pad.dart | 3 - .../passo/building/add/flutter_painter.dart | 148 +- .../building/add/general_description.dart | 3 - .../passo/building/add/imagePicker.dart | 2 - .../passo/building/add/landref_location.dart | 81 +- .../building/add/property_appraisal.dart | 1100 +++---- .../building/add/property_assessment.dart | 476 ++- .../building/add/property_owner_info.dart | 19 + .../passo/building/add/signature_and_ids.dart | 335 ++ .../building/add/structural_material.dart | 44 +- .../building/edit/AddExtraItemsEdit.dart | 2 - .../building/edit/AddExtraItemsOffline.dart | 4 - .../building/edit/additional_items_edit.dart | 55 +- .../building/edit/building_and_structure.dart | 56 +- .../passo/building/edit/edit_building.dart | 13 +- .../building/edit/flutter_painter_edit.dart | 7 +- .../edit/general_description_edit.dart | 8 +- .../building/edit/landref_location_edit.dart | 754 +++-- .../edit/property_appraisal_edit.dart | 1222 +++----- .../edit/property_assessment_edit.dart | 2749 ++++++++--------- .../edit/property_owner_info_edit.dart | 190 +- .../building/edit/signature_and_ids_edit.dart | 262 ++ .../edit/structural_materials_edit.dart | 1 - .../offline/passo/building_home_offline.dart | 58 +- .../offline/passo/passo_main_dashboard.dart | 3 - lib/sevices/login_service/auth_service.dart | 11 +- .../assessment_level_api_services.dart | 46 + .../admin/sql_services/sql_services.dart | 279 +- .../passo/building/landref_services.dart | 18 + .../property_assessment_services.dart | 2 +- lib/utils/global.dart | 12 + lib/utils/passo/post_request.dart | 29 + lib/utils/urls.dart | 16 +- pubspec.lock | 4 +- pubspec.yaml | 4 +- 71 files changed, 5492 insertions(+), 3980 deletions(-) create mode 100644 assets/pngs/broken_lines.png create mode 100644 assets/pngs/id-card.png create mode 100644 lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.dart create mode 100644 lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_event.dart create mode 100644 lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_state.dart create mode 100644 lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart create mode 100644 lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_event.dart create mode 100644 lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_state.dart create mode 100644 lib/model/passo/assessment_level.dart create mode 100644 lib/model/passo/esignature.dart create mode 100644 lib/model/passo/sworn_statement.dart create mode 100644 lib/model/passo/valid_ids.dart create mode 100644 lib/screens/offline/passo/admin/assessment_level.dart create mode 100644 lib/screens/offline/passo/building/add/signature_and_ids.dart create mode 100644 lib/screens/offline/passo/building/edit/signature_and_ids_edit.dart create mode 100644 lib/sevices/offline/offline_passo/admin/api_services/assessment_level_api_services.dart create mode 100644 lib/utils/passo/post_request.dart diff --git a/assets/pngs/broken_lines.png b/assets/pngs/broken_lines.png new file mode 100644 index 0000000000000000000000000000000000000000..3d99d02f476542a440d1d1a008bd830f096e77e1 GIT binary patch literal 9229 zcmeHNYfuwc6b_GQz|tV{P>cp28B|nkeLzJ>KqMklf{qm!ghlI!)hZ33Am#x9Wf*I4 zs)&j_+UP_ZAlT|4udL8&P>5T65FdF|BSt_75Ck^KX1kF1yTAIQGy7vFyLazB`Odlb ze&^h8wm2@9>E`O|N+1y2qPIrwAP^iArY_P9tVOo}q6+(Q$lSqnltk$+El!g1xktq(e(49S`0pt=r|j zD`KT*t>?N8uYy^cTQ4HE4`1_8MVwvWuWUWbSQ;`B)_G;Ae-ZRFNDEuT^yYoBU#^|V znheh)I5;|!-2L3Wg13n0MSXhwVOfIk)4jWQTzz}>{n>tu=@!qGLAD!`J89OkggtRO zZ1{AG>xKFDKBPjTXU&@H>?zAruZW#)_CC(-j;_1rJ`JA!Q$}8%pm)Zn;d>m20iPYD z*zhnIZ5dAX;raD>0Ny=KoBWVQ zH@^Uy8XMtmU9ij$EKGMnRaE&MG)$KsuGsg*~$Te{|@wtcj4TMz0Ht@#}jxetlYT8>Yqn%o$Yb~U*D&O~)RMD#-fOA<6 zw}d7_h>DwNK;)g`kI-&4e5bs;oX*jm3F3`^7nan3)?g78Oh**l(blxH-w6<>CZBre z(_yZ#I98{s`7{6xun2O%E07Y2GVo8HXj1h*mX0MAmTf~&L2m;oFw>Z{X(AY2^m0B42}AbS~Dw0w)yi^jhtKF$1<7 zBqjax&zM?5N20W7lxRrr5~)-w8~74kts@qEgQ7| zL*?p*rh$Melk`$r&zh5VX{LTjb?V^0KAKJ3VHD>HzVRqrZxey?7dQ|P`Nsq)v57x%i>p&ho%guegrrm^qwVE`$1!#@9u7pwQqm#2<`m-S z+7o*rCBmivoyW}3!V?N?aGuYOt3USJn1{_wbtI#0g-g4y4clE|p5XSmYh`vbG)%dQ zcJHxET*okM6)Rf{ZDy8XX0{3HXV|deF5NdwP|SVe KY-C+Ts^A}Ft_rOH literal 0 HcmV?d00001 diff --git a/assets/pngs/id-card.png b/assets/pngs/id-card.png new file mode 100644 index 0000000000000000000000000000000000000000..ae368f03e3bd282ec1e4da50a2ae0205830a86e8 GIT binary patch literal 2617 zcmb_ddpuNm8~>ddBRdjp%C#lBNK0cYLS=F(UKJa=DJdxwg~n}F+ngfTE<-4nm>1#2 zn5>C$9hqK{FoR*n(2QI&$t~p4%pRXU_1W5eKf8atzt3}?-}8LG&+|FI^E}TvC(8cN zemSfv762e;V{LgD02E@PfD9VhnAz*=kqzx{ZsRB;Bg5~t6C&<6e%43*0Z_49x}fW( zl{*knCBVulz`@reAovu)9Rvpl>!0)S_CI~f&t2b_;FG+(^YUi-pI4x})1ZifsAv!!fJR%|@GBPqMDk?fUIwmIO z=FOWV5-Bz|HZCsi?%lib@$m@>35kh`_wLMsKFrR}&dtru%gf8p&o3w_pin4& zI2=w#M@MI8Czs3R@pxTbT>^nXC=~Yg_V)Gl4Gatn4h{|t4Gj+uzkdCCWMl++Muzc+ z?~&dg3^;tq0YE5>G*))?8f6{*A9mx-4<2@O{ORW-N8L`J^Y*(+ghQjF@1&74vT~@@ z--=7Bt81C{4bNY2yL);B!oI=bx8oC&Q}3o{=jInah{e28?OXtsMc7#Gb^N7kv?qqx z;hKz2CA~t>Z-~!lYSk!#4Ameb&)GlJ`D!Z!?=qfH6-g?~`upbcWgkhVOwfh%3%(me%3hhc zhKm^8g;HB9l>x{Ki(btLKyPqdTw^0{MbwT`~f4?*X>?t5d6 zQ`8bw&6^X$6T(Tw38x;f>pvgp=zHt+8|k{0-FbLY8t-^9jgt z18gSH_j**dA8=%ZLme3#DQ4f0vCtLg_BYN@mPU=I)!IF)@FUO_hxP$AC~GY~_{SU{ zC`%o0=UoNSW@I#bz@<{9K>o`u@EP>`+(@A|l%-ljwNhkYHQAu6Pl}}vZ%6MuZb@(g zo27Ad?Vo|EG=}5~T&%XcpsaCl&jgCA2fsrNd*4>V`=^6AS)u((_Bv?265jI#Fu{Iyu)I z@U1La&j(ysBD8+{7W%q{UpEK_Qknpg!2^`SpH0mQaAj}U7ZD21F<^29*#(3w8xQH8 zCfb51jKZAgmDw8Ptf|pzHNi`F-f5=(D|-xOtp}fUDl)MuWlLd6`-um;K>6N>W!DC4p=e@imx*DIwl#-v4tG9;7Mw*R~fYHCoEYDA+(8G z+X)$pcz2Y}!aj9;@Mai`u{W$!1JL?a_^3a=6`x89uSX4=>A*M9@B11J8Sh1!ee)}kAhv52^?Qmax8zvWqL@GUP( zv@%MnHc?znAj|H>+t=QqA}f(F8w^f2g;+oPUt?)i6Zl6y!bqW%2b#u|&%Ob5u2Uyl zN0iSNfO&bE(&-lltesG*dgBuL2-KaLlHV=e?8Ln&=bCCLA)OY=KC7W)SVY$&Y!DR4 z30nUCdZfv%*+J^8vI71=^uEJP15H>L<2Qr2FCoRh8jZgmn7>6~-Ibrp1^#w60qWC- z=YQnj_CN(jp{W%4{N?LB^J@tf^}NYPTm?eO&KE{usZH|5a_c;cnE?p=4(Fb^x!=1l zULjG%qB`-0f`_U_wMUv9`CN=~zn5(r57c5q>p9W>A`K4}%R-L_@~*A^8)I{ne2g{l z^cJ1T03uy@uDG7PZIxJFxPn>Fe$boo?0~jeqdtXr_7Zy+VXBp4fs!e$^3n|sbc^D literal 0 HcmV?d00001 diff --git a/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.dart b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.dart new file mode 100644 index 0000000..4d0c8f8 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.dart @@ -0,0 +1,53 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; + +import '../../../../../model/passo/assessment_level.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'assessment_level_event.dart'; +part 'assessment_level_state.dart'; + +class AssessmentLevelBloc extends Bloc { + AssessmentLevelBloc() : super(AssessmentLevelInitial()) { + List assLevel = []; + on((event, emit) async { + assLevel = await SQLServices.instance.readAllAssessmentLevels(); + + emit(AssessmentLevelLoaded(assLevel: assLevel)); + }); + // on((event, emit) async { + // try { + // final result = + // await AssessmentLevelAdminApiServices.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.createAssessmentLevel(city); + // } + // } catch (e) { + // // Handle any errors that might occur during the API call or database insertion. + // print("Error: $e"); + // } + + // // emit(const LoadAssessmentLevel()); + // }); + on((event, emit) async { + await SQLServices.instance.createAssessmentLevel( + AssessmentLevel( + id: event.id, + classificationId: event.classificationId, + over: event.over, + notOver: event.notOver, + assessmentLevels: event.assessmentLevels, + genCode: event.genCode + ), + ); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_event.dart b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_event.dart new file mode 100644 index 0000000..db82ac8 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_event.dart @@ -0,0 +1,50 @@ +part of 'assessment_level_bloc.dart'; + +class AssessmentLevelEvent extends Equatable { + const AssessmentLevelEvent(); + + @override + List get props => []; +} + +class AddAssessmentLevel extends AssessmentLevelEvent { + final int id; + final int classificationId; + final String over; + final String notOver; + final String assessmentLevels; + final String genCode; + + const AddAssessmentLevel({ + required this.id, + required this.classificationId, + required this.over, + required this.notOver, + required this.assessmentLevels, + required this.genCode, + }); + + @override + List get props => [ + id, + classificationId, + over, + notOver, + assessmentLevels, + genCode, + ]; +} + +class LoadAssessmentLevel extends AssessmentLevelEvent { + const LoadAssessmentLevel(); + + @override + List get props => []; +} + +class AssessmentLevelSyncToDevice extends AssessmentLevelEvent { + const AssessmentLevelSyncToDevice(); + + @override + List get props => []; +} diff --git a/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_state.dart b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_state.dart new file mode 100644 index 0000000..1d47d31 --- /dev/null +++ b/lib/bloc/offline/offline_passo/admin/assessment_level/assessment_level_state.dart @@ -0,0 +1,18 @@ +part of 'assessment_level_bloc.dart'; + +class AssessmentLevelState extends Equatable { + const AssessmentLevelState(); + + @override + List get props => []; +} + +class AssessmentLevelInitial extends AssessmentLevelState {} + +class AssessmentLevelLoaded extends AssessmentLevelState { + final List assLevel; + + const AssessmentLevelLoaded({required this.assLevel}); + @override + List get props => [assLevel]; +} diff --git a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart index 5380953..cd7b60a 100644 --- a/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart @@ -1,7 +1,9 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/model/passo/property_assessment.dart'; - +import 'package:unit2/sevices/passo/building/property_assessment_services.dart'; +import 'package:http/http.dart'; import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; part 'bldg_assessment_offline_event.dart'; @@ -65,6 +67,13 @@ class BldgAssessmentOfflineBloc }); on((event, emit) async { await SQLServices.instance.updateAssessment(event.id, event.assessment); + // final tempID = await SharedPreferences.getInstance(); + // final tempID2 = tempID.getInt('tempid')! - 1; + Response response = (await PropertyAssessmentServices.instance + .updateEdit(event.assessment, event.id))!; + print('assessment'); + print(response.statusCode); + print(response.body); }); } } diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart index cec53be..3ed3d67 100644 --- a/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart @@ -2,7 +2,8 @@ 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 'package:unit2/sevices/passo/building/general_description_services.dart'; +import 'package:http/http.dart'; import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; part 'general_description_event.dart'; @@ -60,6 +61,16 @@ class GeneralDescriptionBloc on((event, emit) async { await SQLServices.instance .updateGeneralDescription(event.id, event.gendesc); + emit(GeneralDescriptionLoading()); + final state = this.state; + try { + Response response = (await GeneralDescriptionServices.instance + .update(event.gendesc, event.gendesc.id))!; + print('property_info'); + print(response.body); + } catch (e) { + emit(const GeneralDescriptionErrorState(errorMessage: '')); + } }); } } diff --git a/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart index 84b853a..98c7813 100644 --- a/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart +++ b/lib/bloc/offline/offline_passo/building/general_description/general_description_event.dart @@ -106,7 +106,7 @@ class UpdateGeneralDescription extends GeneralDescriptionEvent { final GeneralDesc gendesc; final int id; - UpdateGeneralDescription({required this.id, required this.gendesc}); + const UpdateGeneralDescription({required this.id, required this.gendesc}); @override List get props => [id, gendesc]; 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 index 3a49f3b..8c497e9 100644 --- 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 @@ -12,6 +12,11 @@ class GeneralDescriptionInitial extends GeneralDescriptionState { List get props => []; } +class GeneralDescriptionLoading extends GeneralDescriptionState { + @override + List get props => []; +} + class LocationLoaded extends GeneralDescriptionState { final List gendesc; @@ -27,3 +32,10 @@ class SpecificGeneralDescriptionLoaded extends GeneralDescriptionState { @override List get props => [gendesc]; } + +class GeneralDescriptionErrorState extends GeneralDescriptionState { + final String errorMessage; + const GeneralDescriptionErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart index e17bfde..cd96298 100644 --- a/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart @@ -1,11 +1,12 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'package:unit2/sevices/passo/building/landref_services.dart'; import '../../../../../model/passo/land_ref.dart'; import '../../../../../model/passo/todo.dart'; import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; - +import 'package:http/http.dart'; part 'landref_location_event.dart'; part 'landref_location_state.dart'; @@ -73,6 +74,17 @@ class LandrefLocationBloc on((event, emit) async { await SQLServices.instance.updateLandRef(event.id, event.landRef); + + emit(LandrefLoading()); + final state = this.state; + try { + Response response = (await LandRefServices.instance + .update(event.landRef, event.landRef.id))!; + print('property_info'); + print(response.body); + } catch (e) { + emit(LandRefErrorState(errorMessage: e.toString())); + } }); // on((event, emit) async { diff --git a/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart index fa297fb..0d22bfb 100644 --- a/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_event.dart @@ -62,7 +62,7 @@ class UpdateBldgLandRef extends LandrefLocationEvent { final LandRef landRef; final int id; - UpdateBldgLandRef({required this.id, required this.landRef}); + const UpdateBldgLandRef({required this.id, required this.landRef}); @override List get props => [id, landRef]; 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 index 4ae7a0d..701c569 100644 --- a/lib/bloc/offline/offline_passo/building/landref/landref_location_state.dart +++ b/lib/bloc/offline/offline_passo/building/landref/landref_location_state.dart @@ -12,6 +12,11 @@ class LandrefInitial extends LandrefLocationState { List get props => []; } +class LandrefLoading extends LandrefLocationState { + @override + List get props => []; +} + class LandrefLoaded extends LandrefLocationState { final List landref; @@ -27,3 +32,10 @@ class SpecificLandrefLoaded extends LandrefLocationState { @override List get props => [landref]; } + +class LandRefErrorState extends LandrefLocationState { + final String errorMessage; + const LandRefErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} diff --git a/lib/bloc/offline/offline_passo/building/location/location_bloc.dart b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart index 6988f95..a4a6db7 100644 --- a/lib/bloc/offline/offline_passo/building/location/location_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/location/location_bloc.dart @@ -1,9 +1,10 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'package:unit2/sevices/passo/building/location_landref_services.dart'; import '../../../../../model/passo/bldg_loc.dart'; - +import 'package:http/http.dart'; part 'location_event.dart'; part 'location_state.dart'; @@ -43,6 +44,17 @@ class LocationBloc extends Bloc { }); on((event, emit) async { await SQLServices.instance.updateLocation(event.id, event.bldgLoc); + + emit(LocationLoading()); + final state = this.state; + try { + Response response = (await LocationLandrefServices.instance + .update(event.bldgLoc, event.bldgLoc.id))!; + print('property_info'); + print(response.body); + } catch (e) { + emit(LocationErrorState(errorMessage: e.toString())); + } }); } } diff --git a/lib/bloc/offline/offline_passo/building/location/location_state.dart b/lib/bloc/offline/offline_passo/building/location/location_state.dart index ecc13ae..efa89de 100644 --- a/lib/bloc/offline/offline_passo/building/location/location_state.dart +++ b/lib/bloc/offline/offline_passo/building/location/location_state.dart @@ -27,3 +27,15 @@ class SpecificLocationLoaded extends LocationState { @override List get props => [location]; } + +class LocationLoading extends LocationState { + @override + List get props => []; +} + +class LocationErrorState extends LocationState { + final String errorMessage; + const LocationErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart index 74a88b0..1f1a617 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart @@ -4,9 +4,13 @@ import 'dart:io'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:intl/intl.dart'; +import 'package:unit2/model/passo/esignature.dart'; import 'package:unit2/model/passo/floor_sketch.dart'; +import 'package:unit2/model/passo/sworn_statement.dart'; import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; -import 'package:unit2/sevices/passo/building/building_services.dart'; +import 'package:unit2/sevices/passo/building/property_info_services.dart'; +import 'package:unit2/utils/global.dart'; +import 'package:unit2/utils/text_container.dart'; import '../../../../../model/offline/offline_profile.dart'; import '../../../../../model/passo/additional_items.dart'; import '../../../../../model/passo/bldg_loc.dart'; @@ -17,13 +21,13 @@ import '../../../../../model/passo/property_assessment.dart'; import '../../../../../model/passo/property_info.dart'; import '../../../../../model/passo/structureMaterial.dart'; import '../../../../../model/passo/todo.dart'; -import '../../../../../model/profile/basic_information/primary-information.dart'; -import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; +import '../../../../../model/passo/valid_ids.dart'; import 'package:http/http.dart'; import 'package:path/path.dart'; // as http; +import '../../../../../utils/passo/post_request.dart'; import '../../../../../utils/urls.dart'; part 'crud_event.dart'; part 'crud_state.dart'; @@ -55,7 +59,9 @@ class CrudBloc extends Bloc { assessedByName: event.assessedByName, dateCreated: event.dateCreated, dateModified: event.dateModified, - genCode: event.genCode), + genCode: event.genCode, + citizenship: event.citizenship, + civilStatus: event.civilStatus), ); propertyOwner.add(ownerInfo); @@ -73,11 +79,22 @@ class CrudBloc extends Bloc { on((event, emit) async { await SQLServices.instance.updateBldgOwner(event.id, event.propertyInfo); + emit(PropertyOwnerInfoLoading()); + final state = this.state; + try { + Response response = (await PropertyInfoService.instance + .update(event.propertyInfo, event.propertyInfo.id))!; + print('property_info'); + print(response.body); + } catch (e) { + emit(PropertyOwnerInfoErrorState(errorMessage: '')); + } }); on((event, emit) async { emit(PropertyOwnerInfoLoading()); propertyOwner = await SQLServices.instance.readAllBldgOwner(); + emit(PropertyInfoLoaded(propertyInfos: propertyOwner)); }); @@ -106,19 +123,21 @@ class CrudBloc extends Bloc { UploadBuildingFaas event, PropertyInfo infos) async { // Fetch data List> genDesc = - await SQLServices.instance.getGeneralDescription(infos.id); + await SQLServices.instance.getGeneralDescription(infos.id!); List> loc = - await SQLServices.instance.getLocation(infos.id); + await SQLServices.instance.getLocation(infos.id!); List> landRef = - await SQLServices.instance.getLandRef(infos.id); + await SQLServices.instance.getLandRef(infos.id!); List> assessment = - await SQLServices.instance.getBldgAssessment(infos.id); + await SQLServices.instance.getBldgAssessment(infos.id!); List> strucMat = - await SQLServices.instance.getStructuralMaterials(infos.id); + await SQLServices.instance.getStructuralMaterials(infos.id!); List> addItems = - await SQLServices.instance.getAdditionalItems(infos.id); + await SQLServices.instance.getAdditionalItems(infos.id!); List> bldgStructure = - await SQLServices.instance.getBuildingAndStructure(infos.id); + await SQLServices.instance.getBuildingAndStructure(infos.id!); + List> swornStatement = + await SQLServices.instance.getSwornStatement(infos.id!); // Parse data GeneralDesc firstGenDesc = GeneralDesc.fromJson2(genDesc.first); @@ -128,15 +147,20 @@ class CrudBloc extends Bloc { PropertyAssessment.fromJson2(assessment.first); StructureMaterials firstStructMat = StructureMaterials.fromJson2(strucMat.first); + SwornStatement firstSwornStatement = + SwornStatement.fromJson2(swornStatement.first); + + print(swornStatement.toString()); // Prepare details DateTime dateIssued = DateTime.parse(firstGenDesc.dateIssued!); final details = { "assessed_by_id": event.offlineProfile.id.toString(), - "assessed_by_name": event.offlineProfile.firstName, + "assessed_by_name": 'event.offlineProfile.firstName', "date_created": "{{currentTimestamp}}", "date_modified": "{{currentTimestamp}}", - "trans_code": '08887', + "date_sync": "{{currentTimestamp}}", + "trans_code": infos.transCode, "tdn": infos.tdn, "pin": infos.pin, "fname": infos.fname, @@ -152,8 +176,11 @@ class CrudBloc extends Bloc { "admin_tin": infos.adminTin, "faas_type": infos.faasType, "gen_code": "5TH", + "citizenship": infos.citizenship, + "civil_status": infos.civilStatus, "bldgappr_location.date_created": "{{currentTimestamp}}", "bldgappr_location.date_modified": "{{currentTimestamp}}", + "bldgappr_location.date_sync": "{{currentTimestamp}}", "bldgappr_location.street": firstLoc.street, "bldgappr_location.barangay": firstLoc.barangay, "bldgappr_location.municipality": firstLoc.municipality, @@ -161,6 +188,7 @@ class CrudBloc extends Bloc { "bldgappr_location.gen_code": "5TH", "bldgappr_landref.date_created": "{{currentTimestamp}}", "bldgappr_landref.date_modified": "{{currentTimestamp}}", + "bldgappr_landref.date_sync": "{{currentTimestamp}}", "bldgappr_landref.owner": firstLandRef.owner, "bldgappr_landref.cloa_no": firstLandRef.cloaNo, "bldgappr_landref.lot_no": firstLandRef.lotNo, @@ -171,6 +199,7 @@ class CrudBloc extends Bloc { "bldgappr_landref.gen_code": "5TH", "bldgappr_generaldesc.date_created": "{{currentTimestamp}}", "bldgappr_generaldesc.date_modified": "{{currentTimestamp}}", + "bldgappr_generaldesc.date_sync": "{{currentTimestamp}}", "bldgappr_generaldesc.bldg_kind": firstGenDesc.bldgKind, "bldgappr_generaldesc.struc_type": firstGenDesc.strucType, "bldgappr_generaldesc.bldg_permit": firstGenDesc.bldgPermit, @@ -198,6 +227,7 @@ class CrudBloc extends Bloc { "bldgappr_generaldesc.gen_code": "5TH", "bldgappr_struct_materials.date_created": "{{currentTimestamp}}", "bldgappr_struct_materials.date_modified": "{{currentTimestamp}}", + "bldgappr_struct_materials.date_sync": "{{currentTimestamp}}", "bldgappr_struct_materials.foundation": firstStructMat.foundation, "bldgappr_struct_materials.columns": firstStructMat.columns, "bldgappr_struct_materials.beams": firstStructMat.beams, @@ -209,6 +239,7 @@ class CrudBloc extends Bloc { "bldgappr_struct_materials.gen_code": "5TH", "bldgappr_property_assessment.date_created": "{{currentTimestamp}}", "bldgappr_property_assessment.date_modified": "{{currentTimestamp}}", + "bldgappr_property_assessment.date_sync": "{{currentTimestamp}}", "bldgappr_property_assessment.actual_use": firstAssess.actualUse, "bldgappr_property_assessment.market_value": firstAssess.marketValue, "bldgappr_property_assessment.assessment_level": @@ -248,23 +279,33 @@ class CrudBloc extends Bloc { "bldgappr_property_assessment.entry_date_assessment": DateFormat("yyyy-MM-dd") .format(DateTime.parse(firstAssess.entryDateAssessment!)), - "bldgappr_property_assessment.entry_date_by": " ", + "bldgappr_property_assessment.entry_date_by": "ij", "bldgappr_property_assessment.gen_code": "5TH", "bldgappr_rec_supersededass.date_created": "{{currentTimestamp}}", "bldgappr_rec_supersededass.date_modified": "{{currentTimestamp}}", + "bldgappr_rec_supersededass.date_sync": "{{currentTimestamp}}", "bldgappr_rec_supersededass.pin": " ", "bldgappr_rec_supersededass.tdn": " ", "bldgappr_rec_supersededass.total_assval": "0", - "bldgappr_rec_supersededass.owner": " ", - "bldgappr_rec_supersededass.effectivity_ass": null, + "bldgappr_rec_supersededass.owner": "0", + "bldgappr_rec_supersededass.effectivity_ass": "1992-09-08", "bldgappr_rec_supersededass.page_no": "0", "bldgappr_rec_supersededass.total_marketval": "0", "bldgappr_rec_supersededass.total_area": "0", - "bldgappr_rec_supersededass.rec_assessment": null, - "bldgappr_rec_supersededass.rec_taxmapping": " ", - "bldgappr_rec_supersededass.rec_records": " ", - "bldgappr_rec_supersededass.date": null, - "bldgappr_rec_supersededass.gen_code": "5TH" + "bldgappr_rec_supersededass.rec_assessment": "1992-09-08", + "bldgappr_rec_supersededass.rec_taxmapping": "0", + "bldgappr_rec_supersededass.rec_records": "1992-09-08", + "bldgappr_rec_supersededass.date": "1992-09-08", + "bldgappr_rec_supersededass.gen_code": "5TH", + "bldgappr_swornstatement.citizenship": + "firstSwornStatement.citizenship", + "bldgappr_swornstatement.civil_status": + "firstSwornStatement.civilStatus", + "bldgappr_swornstatement.fname": 'firstSwornStatement.fname', + "bldgappr_swornstatement.mname": 'firstSwornStatement.mname', + "bldgappr_swornstatement.lname": 'firstSwornStatement.lname', + "bldgappr_swornstatement.date_sync": "{{currentTimestamp}}", + "bldgappr_swornstatement.gen_code": "5TH" }; return details; @@ -272,14 +313,6 @@ class CrudBloc extends Bloc { Future _postAdditionalItems( Map datas, PropertyInfo infos) async { - String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; - String xClientKeySecret = "unitcYqAN7GGalyz"; - Map headers = { - 'Content-Type': 'application/json; charset=UTF-8', - 'X-Client-Key': xClientKey, - 'X-Client-Secret': xClientKeySecret - }; - List> addItems = await SQLServices.instance.getAdditionalItems(infos.id); @@ -309,8 +342,8 @@ class CrudBloc extends Bloc { genCode: "5TH"); Response addResponse = await post( Uri.parse( - 'https://${Url.instance.host()}/api/rptass_app/additional_items/'), - headers: headers, + '${Url.instance.prefixHost()}${Url.instance.host()}/api/rptass_app/additional_items/'), + headers: getHeaders(), body: jsonEncode(addItems)); print(addResponse.body); } @@ -318,82 +351,60 @@ class CrudBloc extends Bloc { Future _postBuildingStructures( Map datas, PropertyInfo infos) async { - String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; - String xClientKeySecret = "unitcYqAN7GGalyz"; - Map headers = { - 'Content-Type': 'application/json; charset=UTF-8', - 'X-Client-Key': xClientKey, - 'X-Client-Secret': xClientKeySecret - }; - List> bldgStructures = await SQLServices.instance.getBuildingAndStructure(infos.id); List bldgStructureList = bldgStructures.map((map) => BldgAndStructure.fromJson(map)).toList(); for (BldgAndStructure structure in bldgStructureList) { - final bldgStruc = BldgAndStructure( - id: 1, - bldgapprDetailsId: datas['data']['id'], - bldgArea: structure.bldgArea, - bldgType: structure.bldgType, - structType: structure.structType, - description: structure.description, - actualUse: structure.actualUse, - floorCount: structure.floorCount, - unitValue: structure.unitValue, - depRate: structure.depRate, - marketValue: structure.marketValue, - depAmount: structure.depAmount, - adjustedMarketValue: structure.adjustedMarketValue, - genCode: '5TH', - buccPercentage: structure.buccPercentage); - Response response = await post( + // Create an instance of BldgAndStructure + final bldgAndStructure = BldgAndStructure( + id: 1, + bldgapprDetailsId: datas['data']['id'], + bldgArea: structure.bldgArea, + bldgType: structure.bldgType, + structType: structure.structType, + description: structure.description, + actualUse: structure.actualUse, + floorCount: structure.floorCount, + unitValue: structure.unitValue, + depRate: structure.depRate, + marketValue: structure.marketValue, + depAmount: structure.depAmount, + adjustedMarketValue: structure.adjustedMarketValue, + genCode: '5TH', + buccPercentage: structure.buccPercentage, + ); + +// Send the POST request using the reusable function + Response addResponse = await post( Uri.parse( - 'https://${Url.instance.host()}/api/rptass_app/bldgappr_structure/'), - headers: headers, - body: jsonEncode(bldgStruc)); - print(response.body); + '${Url.instance.prefixHost()}${Url.instance.host()}${Url.instance.buildingStructure()}'), + headers: getHeaders(), + body: jsonEncode(bldgAndStructure)); + print(addResponse.body); } } Future _postBuildingDetails(Map details) async { - String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; - String xClientKeySecret = "unitcYqAN7GGalyz"; - Map headers = { - 'Content-Type': 'application/json; charset=UTF-8', - 'X-Client-Key': xClientKey, - 'X-Client-Secret': xClientKeySecret - }; - return await post( Uri.parse( - 'https://${Url.instance.host()}/api/rptass_app/bldgappr_details/'), - headers: headers, + '${Url.instance.prefixHost()}${Url.instance.host()}${Url.instance.buildingDetails()}'), + headers: getHeaders(), body: jsonEncode(details)); } Future _postFloorSketch( Map details, file) async { - String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; - String xClientKeySecret = "unitcYqAN7GGalyz"; - - // Construct the headers for the request - Map headers = { - 'Content-Type': 'multipart/form-data', - 'X-Client-Key': xClientKey, - 'X-Client-Secret': xClientKeySecret, - }; - // Create a MultipartRequest var request = MultipartRequest( 'POST', Uri.parse( - 'https://${Url.instance.host()}/api/rptass_app/bldgappr_sketch/'), + '${Url.instance.prefixHost()}${Url.instance.host()}/api/rptass_app/bldgappr_sketch/'), ); // Add the headers to the request - request.headers.addAll(headers); + request.headers.addAll(getHeaders()); // Add JSON data as a field // Add individual fields to the request @@ -417,6 +428,72 @@ class CrudBloc extends Bloc { return await Response.fromStream(streamedResponse); } + Future _postValidIds(Map details, file) async { + // Create a MultipartRequest + var request = MultipartRequest( + 'POST', + Uri.parse( + '${Url.instance.prefixHost()}${Url.instance.host()}/api/rptass_app/bldgappr_validid/'), + ); + + // Add the headers to the request + request.headers.addAll(getHeaders()); + + // Add JSON data as a field + // Add individual fields to the request + details.forEach((key, value) { + request.fields[key] = value.toString(); + }); + + // Add the floor sketch image file, if it exists + + var fileName = basename(file); + request.files.add( + await MultipartFile.fromPath( + 'id_attachment', // Field name in the API + file, + filename: fileName, + ), + ); + + // Send the request and get the response + var streamedResponse = await request.send(); + return await Response.fromStream(streamedResponse); + } + + Future _postESignature(Map details, file) async { + // Create a MultipartRequest + var request = MultipartRequest( + 'POST', + Uri.parse( + '${Url.instance.prefixHost()}${Url.instance.host()}/api/rptass_app/bldgappr_signatures/'), + ); + + // Add the headers to the request + request.headers.addAll(getHeaders()); + + // Add JSON data as a field + // Add individual fields to the request + details.forEach((key, value) { + request.fields[key] = value.toString(); + }); + + // Add the floor sketch image file, if it exists + + var fileName = basename(file); + request.files.add( + await MultipartFile.fromPath( + 'sign_attachment', // Field name in the API + file, + filename: fileName, + ), + ); + + // Send the request and get the response + var streamedResponse = await request.send(); + return await Response.fromStream(streamedResponse); + } + Future _uploadImage(data, infos) async { // Create a map with the required fields @@ -447,6 +524,93 @@ class CrudBloc extends Bloc { } } + Future _uploadValidIds(data, infos) async { + // Fetch all valid IDs associated with the infos.id (bldgapprDetailsId) + List> floorSketchList = + await SQLServices.instance.getValidIds(infos.id); + + print('floor sketch lis lenght'); + print(floorSketchList.length); + + // Check if the list is not empty + if (floorSketchList.isEmpty) { + print('No valid IDs found for bldgapprDetailsId: ${infos.id}'); + return; + } + + // Declare validIdRecord outside the loop so it's accessible in the catch block + ValidIds? validIdRecord; + + // Loop through each valid ID in the list + for (var sketch in floorSketchList) { + try { + // Parse each record into a ValidIds object + validIdRecord = ValidIds.fromJson(sketch); + print('Processing Valid ID: ${validIdRecord.toJson()}'); + + // Read the image file associated with the valid ID + var file = File(validIdRecord.validIds!); + + // Construct the payload (detailsMap) for the API + Map detailsMap = { + "bldgappr_details_id": data['data']['id'], // int8 NOT NULL + "date_created": + DateTime.now().toIso8601String(), // timestamptz NULL + "id_attachment": + validIdRecord.validIds!, // Path to the valid ID image + "gen_code": "5TH", // Fixed gen code + }; + + // Send the data via POST request + Response response = await _postValidIds(detailsMap, file.path); + + // Check the response status + if (response.statusCode == 201) { + print('Upload successful for ID: ${validIdRecord.validIds!}'); + } else { + print( + 'Upload failed for ID: ${validIdRecord.validIds!} with status: ${response.statusCode}'); + } + } catch (e) { + // Handle and log errors for each individual valid ID upload attempt + print('Error uploading ID: ${validIdRecord?.validIds!} - Error: $e'); + } + } + } + + Future _uploadESignature(data, infos) async { + // Create a map with the required fields + + List> floorSketch = + await SQLServices.instance.getESignature(infos.id); + + // Parse data + ESignature firstFs = ESignature.fromJson(floorSketch.first); + print('E Signature'); + print(firstFs.toJson()); + var file = File(firstFs.signAttachment!); + Map detailsMap = { + "bldgappr_details_id": data['data']['id'], // int8 NOT NULL + "date_created": DateTime.now().toIso8601String(), + "date_modified": DateTime.now().toIso8601String(), // timestamptz NULL + "sign_attachment": firstFs.signAttachment!, // text NULL + "gen_code": "5TH", // varchar(20) NOT NULL + }; + + try { + Response response = await _postESignature(detailsMap, file.path); + print(response.body); + + if (response.statusCode == 201) { + print('Upload successful'); + } else { + print('Upload failed with status: ${response.statusCode}'); + } + } catch (e) { + print('Error: $e'); + } + } + on((event, emit) async { emit(UploadBuildingFaasLoading()); try { @@ -456,15 +620,18 @@ class CrudBloc extends Bloc { for (PropertyInfo infos in propertyOwner) { if (infos.dateSynced == null) { final details = await _prepareBuildingDetails(event, infos); - + print(details.toString()); Response detailsResponse = await _postBuildingDetails(details); final datas = json.decode(detailsResponse.body); + print("Upload API response"); print(datas); await _postAdditionalItems(datas, infos); await _postBuildingStructures(datas, infos); await _uploadImage(datas, infos); + await _uploadValidIds(datas, infos); + await _uploadESignature(datas, infos); if (detailsResponse.statusCode == 201) { final detailsInfo = PropertyInfo( diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart index 0f42778..c6a099d 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_event.dart @@ -26,6 +26,8 @@ class AddTodo extends CrudEvent { final String dateCreated; final String dateModified; final String genCode; + final String civilStatus; + final String citizenship; const AddTodo( {required this.id, @@ -48,7 +50,9 @@ class AddTodo extends CrudEvent { required this.assessedByName, required this.dateCreated, required this.dateModified, - required this.genCode}); + required this.genCode, + required this.citizenship, + required this.civilStatus}); @override List get props => [ @@ -72,7 +76,9 @@ class AddTodo extends CrudEvent { assessedByName, dateCreated, dateModified, - genCode + genCode, + citizenship, + civilStatus ]; } diff --git a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart index 92e505e..ef43cf5 100644 --- a/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart +++ b/lib/bloc/offline/offline_passo/building/structural_materials_offline.dart/structural_material_offline_bloc.dart @@ -1,10 +1,12 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/sevices/passo/building/structural_material_services.dart'; import '../../../../../model/passo/structural_materials_ii.dart'; import '../../../../../model/passo/structureMaterial.dart'; import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; - +import 'package:http/http.dart'; part 'structural_material_offline_event.dart'; part 'structural_material_offline_state.dart'; @@ -52,6 +54,24 @@ class StructuralMaterialOfflineBloc extends Bloc((event, emit) async { await SQLServices.instance .updateStructuralMaterial(event.id, event.materials); + + final state = this.state; + emit(StructuralMaterialOfflineState()); + try { + final tempID = await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')! - 1); + Response response = (await StrucMaterialServices.instance + .update(event.materials, event.materials.id))!; + print('struc Material'); + print(response.body); + if (response.statusCode == 200) { + emit(StructuralMaterialErrorState(errorMessage: '200')); + } else { + emit(StructuralMaterialErrorState(errorMessage: 'not 200')); + } + } catch (e) { + emit(StructuralMaterialErrorState(errorMessage: e.toString())); + } }); } } 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 index 41ef1f3..d51fb12 100644 --- 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 @@ -12,6 +12,12 @@ class StructuralMaterialOfflineInitial extends StructuralMaterialOfflineState { List get props => []; } +class StructuralMaterialLoading extends StructuralMaterialOfflineState { + @override + List get props => []; +} + + class StructuralMaterialLoaded extends StructuralMaterialOfflineState { final List materials; @@ -27,3 +33,10 @@ class SpecificStructuralMaterialLoaded extends StructuralMaterialOfflineState { @override List get props => [materials]; } + +class StructuralMaterialErrorState extends StructuralMaterialOfflineState { + final String errorMessage; + const StructuralMaterialErrorState({required this.errorMessage}); + @override + List get props => [errorMessage]; +} diff --git a/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart new file mode 100644 index 0000000..d351b29 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart @@ -0,0 +1,56 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:unit2/model/passo/sworn_statement.dart'; + +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +part 'sworn_statement_event.dart'; +part 'sworn_statement_state.dart'; + +class SwornStatementBloc + extends Bloc { + SwornStatementBloc() : super(SwornStatementInitial()) { + on((event, emit) async { + try { + final sworn = await SQLServices.instance.createSwornStatement( + SwornStatement( + bldgapprDetailsId: event.bldgapprDetailsId, + citizenship: event.citizenship, + civilStatus: event.civilStatus, + fname: event.fname, + mname: event.mname, + lname: event.lname, + genCode: event.genCode)); + + // Emit success state with the created sworn statement + print(sworn.toJson()); + } catch (error) { + // Emit failure state if something goes wrong + print(error.toString()); + } + }); + + on((event, emit) async { + List> result = + await SQLServices.instance.getSwornStatement(event.id); + + if (result.isNotEmpty) { + List swornList = + result.map((map) => SwornStatement.fromJson(map)).toList(); + + // Choose a specific element from locationList + SwornStatement firstSworn = + swornList.first; // You can change this to select a specific item + + print('sworn test result'); + print(firstSworn); + emit(SpecificSwornStatementLoaded(swornStatement: firstSworn)); + } else { + print('No data found.'); + } + }); + on((event, emit) async { + await SQLServices.instance.updateSwornStatement(event.id, event.sworn); + }); + } +} diff --git a/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_event.dart b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_event.dart new file mode 100644 index 0000000..a93b1cb --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_event.dart @@ -0,0 +1,56 @@ +part of 'sworn_statement_bloc.dart'; + +class SwornStatementEvent extends Equatable { + const SwornStatementEvent(); + + @override + List get props => []; +} + +class AddSwornStatement extends SwornStatementEvent { + final int bldgapprDetailsId; + final String citizenship; + final String civilStatus; + final String fname; + final String mname; + final String lname; + final String genCode; + + const AddSwornStatement( + {required this.bldgapprDetailsId, + required this.citizenship, + required this.civilStatus, + required this.fname, + required this.mname, + required this.lname, + required this.genCode}); + + @override + List get props => [ + bldgapprDetailsId, + citizenship, + civilStatus, + fname, + mname, + lname, + genCode + ]; +} + +class FetchSingleSwornStatement extends SwornStatementEvent { + final int id; + const FetchSingleSwornStatement({required this.id}); + + @override + List get props => [id]; +} + +class UpdateSwornStatement extends SwornStatementEvent { + final SwornStatement sworn; + final int id; + + UpdateSwornStatement({required this.id, required this.sworn}); + + @override + List get props => [id, sworn]; +} \ No newline at end of file diff --git a/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_state.dart b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_state.dart new file mode 100644 index 0000000..6ec2017 --- /dev/null +++ b/lib/bloc/offline/offline_passo/building/swornstatement/sworn_statement_state.dart @@ -0,0 +1,26 @@ +part of 'sworn_statement_bloc.dart'; + +class SwornStatementState extends Equatable { + const SwornStatementState(); + + @override + List get props => []; +} + +class SwornStatementLoaded extends SwornStatementState { + final List swornStatement; + + const SwornStatementLoaded({required this.swornStatement}); + @override + List get props => [swornStatement]; +} + +class SwornStatementInitial extends SwornStatementState {} + +class SpecificSwornStatementLoaded extends SwornStatementState { + final SwornStatement swornStatement; + + const SpecificSwornStatementLoaded({required this.swornStatement}); + @override + List get props => [swornStatement]; +} diff --git a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart index c09cf14..ba9a7d8 100644 --- a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart +++ b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart @@ -42,18 +42,18 @@ class PropertyAssessmentEditBloc emit(PropertyAssessmentEditLoaded(globalPropertyAssessmentEdit)); } }); - on((event, emit) async { - final tempID = await SharedPreferences.getInstance(); - final tempID2 = tempID.getInt('tempid')! - 1; - http.Response response = (await PropertyAssessmentServices.instance - .updateEdit(event.assessmentsEdit, tempID2))!; - print('assessment'); - print(response.statusCode); - print(response.body); - // if (response.statusCode == 201) { - // final faas = await PropertyInfoRepository.getUsers(); - // emit(FaasLoaded(faas)); - // } - }); + // on((event, emit) async { + // final tempID = await SharedPreferences.getInstance(); + // final tempID2 = tempID.getInt('tempid')! - 1; + // http.Response response = (await PropertyAssessmentServices.instance + // .updateEdit(event.assessmentsEdit, tempID2))!; + // print('assessment'); + // print(response.statusCode); + // print(response.body); + // // if (response.statusCode == 201) { + // // final faas = await PropertyInfoRepository.getUsers(); + // // emit(FaasLoaded(faas)); + // // } + // }); } } diff --git a/lib/bloc/passo/bulding/property_info/property_info_bloc.dart b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart index fd49f51..27aa072 100644 --- a/lib/bloc/passo/bulding/property_info/property_info_bloc.dart +++ b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart @@ -8,7 +8,6 @@ import 'package:unit2/model/passo/general_description.dart'; import 'package:unit2/model/passo/land_ref.dart'; import 'package:unit2/model/passo/property_info.dart'; import 'package:unit2/model/passo/structural_materials_ii.dart'; -import 'package:unit2/sevices/passo/building/general_description_services.dart'; import 'package:unit2/sevices/passo/building/property_info_services.dart'; import 'package:http/http.dart' as http; @@ -141,7 +140,7 @@ class PropertyInfoBloc extends Bloc { (await PropertyInfoService.instance.remove(event.id)); print(response.statusCode); if (response.statusCode == 200) { - emit(BuildingFaasDeletedState(success: true)); + emit(const BuildingFaasDeletedState(success: true)); } }); } diff --git a/lib/bloc/user/user_bloc.dart b/lib/bloc/user/user_bloc.dart index 3f686ad..3d403bd 100644 --- a/lib/bloc/user/user_bloc.dart +++ b/lib/bloc/user/user_bloc.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:bloc/bloc.dart'; +import 'package:dio/dio.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:unit2/model/login_data/user_info/assigned_area.dart'; @@ -86,11 +87,14 @@ class UserBloc extends Bloc { password = event.password; bool? availableOffline; List offlineCards = []; + try { Map response = await AuthService.instance .webLogin(username: event.username, password: event.password); + if (response['status'] == true) { UserData userData = UserData.fromJson(response['data']); + print('test'); Role? estPointPerson; if (userData.user?.login?.user?.roles != null && userData.user!.login!.user!.roles!.isNotEmpty) { diff --git a/lib/model/login_data/employee_info/department.dart b/lib/model/login_data/employee_info/department.dart index 59755b6..75d7ba1 100644 --- a/lib/model/login_data/employee_info/department.dart +++ b/lib/model/login_data/employee_info/department.dart @@ -15,14 +15,14 @@ class Department { String? code; Head? head; String? name; - int? acronym; + String? acronym; int? parentStationId; String? fullCode; factory Department.fromJson(Map json) => Department( id: json["id"], code: json["code"], - head:json["head"]==null?null:Head.fromJson(json["head"]), + head: json["head"] == null ? null : Head.fromJson(json["head"]), name: json["name"], acronym: json["acronym"], parentStationId: json["parent_station_id"], @@ -38,4 +38,4 @@ class Department { "parent_station_id": parentStationId, "full_code": fullCode, }; -} \ No newline at end of file +} diff --git a/lib/model/login_data/employee_info/employee_info.dart b/lib/model/login_data/employee_info/employee_info.dart index 20166df..6048f2e 100644 --- a/lib/model/login_data/employee_info/employee_info.dart +++ b/lib/model/login_data/employee_info/employee_info.dart @@ -25,8 +25,9 @@ class EmployeeInfo { empid: json["empid"], classid: json["classid"], uuid: json["uuid"], - office: json["office"]==null?null:Office.fromJson(json["office"]), - profile: json["profile"]==null?null:Profile.fromJson(json["profile"]), + office: json["office"] == null ? null : Office.fromJson(json["office"]), + profile: + json["profile"] == null ? null : Profile.fromJson(json["profile"]), ); Map toJson() => { @@ -38,4 +39,3 @@ class EmployeeInfo { "profile": profile!.toJson(), }; } - diff --git a/lib/model/passo/assessment_level.dart b/lib/model/passo/assessment_level.dart new file mode 100644 index 0000000..b15c128 --- /dev/null +++ b/lib/model/passo/assessment_level.dart @@ -0,0 +1,84 @@ +// To parse this JSON data, do +// +// final assessmentLevel = assessmentLevelFromMap(jsonString); + +import 'dart:convert'; + +AssessmentLevel assessmentLevelFromMap(String str) => + AssessmentLevel.fromMap(json.decode(str)); + +String assessmentLevelToMap(AssessmentLevel data) => json.encode(data.toMap()); + +class AssessmentLevel { + final int? id; + final int? classificationId; + final String? over; + final String? notOver; + final String? assessmentLevels; + final String? genCode; + + AssessmentLevel({ + this.id, + this.classificationId, + this.over, + this.notOver, + this.assessmentLevels, + this.genCode, + }); + + AssessmentLevel copyWith({ + int? id, + int? classificationId, + String? over, + String? notOver, + String? assessmentLevels, + String? genCode, + }) { + return AssessmentLevel( + id: id ?? this.id, + classificationId: classificationId ?? this.classificationId, + over: over ?? this.over, + notOver: notOver ?? this.notOver, + assessmentLevels: assessmentLevels ?? this.assessmentLevels, + genCode: genCode ?? this.genCode, + ); + } + + factory AssessmentLevel.fromMap(Map json) => AssessmentLevel( + id: json["id"], + classificationId: json["classification_id"], + over: json["over"], + notOver: json["not_over"], + assessmentLevels: json["assessment_levels"], + genCode: json["gen_code"], + ); + + factory AssessmentLevel.fromJson(Map json) => + AssessmentLevel( + id: json["id"], + classificationId: json["classification_id"], + over: json["over"], + notOver: json["not_over"], + assessmentLevels: json["assessment_levels"], + genCode: json["gen_code"], + ); + + factory AssessmentLevel.fromJson2(Map json) => + AssessmentLevel( + id: json["id"], + classificationId: json["classificationId"], + over: json["over"], + notOver: json["notOver"], + assessmentLevels: json["assessmentLevels"], + genCode: json["genCode"], + ); + + Map toMap() => { + "id": id, + "classification_id": classificationId, + "over": over, + "not_over": notOver, + "assessment_levels": assessmentLevels, + "gen_code": genCode, + }; +} diff --git a/lib/model/passo/esignature.dart b/lib/model/passo/esignature.dart new file mode 100644 index 0000000..21c83d7 --- /dev/null +++ b/lib/model/passo/esignature.dart @@ -0,0 +1,95 @@ +// To parse this JSON data, do +// +// final eSignature = eSignatureFromJson(jsonString); + +import 'dart:convert'; + +ESignature eSignatureFromJson(String str) => + ESignature.fromJson(json.decode(str)); + +String eSignatureToJson(ESignature data) => json.encode(data.toJson()); + +class ESignature { + int? bldgapprDetailsId; + String? signAttachment; + String? dateCreated; + String? dateModified; + String? genCode; + + ESignature({ + this.bldgapprDetailsId, + this.signAttachment, + this.dateCreated, + this.dateModified, + this.genCode, + }); + + ESignature copy({ + int? bldgapprDetailsId, + String? signAttachment, + String? dateCreated, + String? dateModified, + String? genCode, + }) { + return ESignature( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + signAttachment: signAttachment ?? this.signAttachment, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + genCode: genCode ?? this.genCode, + ); + } + + ESignature copyWith({ + int? bldgapprDetailsId, + String? signAttachment, + String? dateCreated, + String? dateModified, + String? genCode, + }) => + ESignature( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + signAttachment: signAttachment ?? this.signAttachment, + dateCreated: dateCreated ?? this.dateCreated, + dateModified: dateModified ?? this.dateModified, + genCode: genCode ?? this.genCode, + ); + + factory ESignature.fromJson(Map json) => ESignature( + bldgapprDetailsId: json["bldgappr_details_id"], + signAttachment: json["sign_attachment"], + dateCreated: json["date_created"], + dateModified: json["date_modified"], + genCode: json["gen_code"], + ); + + Map toJson() => { + "bldgappr_details_id": bldgapprDetailsId, + "sign_attachment": signAttachment, + "date_created": dateCreated, + "date_modified": dateModified, + "gen_code": genCode, + }; + + // Define the fromMap method to convert a Map into an ESignature object + factory ESignature.fromMap(Map map) { + return ESignature( + bldgapprDetailsId: map['bldgapprDetailsId'] as int?, + signAttachment: map['signAttachment'] as String?, + dateCreated: map['dateCreated'] as String?, + dateModified: map['dateModified'] as String?, + genCode: map['genCode'] as String?, + ); + } + + // You can also add a toMap method if needed for converting back to Map + Map toMap() { + return { + 'bldgapprDetailsId': bldgapprDetailsId, + 'signAttachment': signAttachment, + 'dateCreated': dateCreated, + 'dateModified': dateModified, + 'genCode': genCode, + }; + } +} diff --git a/lib/model/passo/property_info.dart b/lib/model/passo/property_info.dart index 4815c54..d12b95f 100644 --- a/lib/model/passo/property_info.dart +++ b/lib/model/passo/property_info.dart @@ -32,6 +32,8 @@ class PropertyInfo { final String? faasType; final String? genCode; final String? dateSynced; + final String? civilStatus; + final String? citizenship; PropertyInfo( {this.id, @@ -55,7 +57,9 @@ class PropertyInfo { this.adminTin, this.faasType, this.genCode, - this.dateSynced}); + this.dateSynced, + this.citizenship, + this.civilStatus}); PropertyInfo copy( {int? id, @@ -76,7 +80,9 @@ class PropertyInfo { String? adminTin, String? faasType, String? genCode, - String? dateSynced}) => + String? dateSynced, + String? civilStatus, + String? citizenship}) => PropertyInfo( id: id ?? this.id, assessedById: assessedById ?? this.assessedById, @@ -99,7 +105,9 @@ class PropertyInfo { adminTin: adminTin ?? this.adminTin, faasType: faasType ?? this.faasType, genCode: genCode ?? this.genCode, - dateSynced: dateSynced ?? this.dateSynced); + dateSynced: dateSynced ?? this.dateSynced, + citizenship: citizenship ?? this.citizenship, + civilStatus: civilStatus ?? this.civilStatus); factory PropertyInfo.fromJson(Map json) => PropertyInfo( id: json["id"], @@ -155,7 +163,9 @@ class PropertyInfo { adminTin: json["adminTin"], faasType: json["faasType"], genCode: json["genCode"], - dateSynced: json["dateSynced"]); + dateSynced: json["dateSynced"], + citizenship: json["citizenship"], + civilStatus: json["civil_status"]); factory PropertyInfo.fromMap(Map map) => PropertyInfo( id: map["id"], @@ -179,7 +189,9 @@ class PropertyInfo { adminTin: map["adminTin"], faasType: map["faasType"], genCode: map["genCode"], - dateSynced: map["dateSynced"]); + dateSynced: map["dateSynced"], + citizenship: map["citizenship"], + civilStatus: map["civilStatus"]); Map toJson() => { "id": id, @@ -203,6 +215,8 @@ class PropertyInfo { "admin_tin": adminTin, "faas_type": faasType, "gen_code": genCode, - "dateSynced": dateSynced + "dateSynced": dateSynced, + "civilStatus": civilStatus, + "citizenship": citizenship }; } diff --git a/lib/model/passo/sworn_statement.dart b/lib/model/passo/sworn_statement.dart new file mode 100644 index 0000000..e8b06b4 --- /dev/null +++ b/lib/model/passo/sworn_statement.dart @@ -0,0 +1,98 @@ +// To parse this JSON data, do +// +// final swornStatement = swornStatementFromJson(jsonString); + +import 'dart:convert'; + +SwornStatement swornStatementFromJson(String str) => + SwornStatement.fromJson(json.decode(str)); + +String swornStatementToJson(SwornStatement data) => json.encode(data.toJson()); + +class SwornStatement { + final int? bldgapprDetailsId; + final String? citizenship; + final String? civilStatus; + final String? fname; + final String? mname; + final String? lname; + final String? genCode; + + SwornStatement({ + this.bldgapprDetailsId, + this.citizenship, + this.civilStatus, + this.fname, + this.mname, + this.lname, + this.genCode, + }); + + SwornStatement copyWith({ + int? bldgapprDetailsId, + String? citizenship, + String? civilStatus, + String? fname, + String? mname, + String? lname, + String? genCode, + }) => + SwornStatement( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + citizenship: citizenship ?? this.citizenship, + civilStatus: civilStatus ?? this.civilStatus, + fname: fname ?? this.fname, + mname: mname ?? this.mname, + lname: lname ?? this.lname, + genCode: genCode ?? this.genCode, + ); + + SwornStatement copy({ + final int? bldgapprDetailsId, + final String? citizenship, + final String? civilStatus, + final String? fname, + final String? mname, + final String? lname, + final String? genCode, + }) => + SwornStatement( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + citizenship: citizenship ?? this.citizenship, + civilStatus: civilStatus ?? this.civilStatus, + fname: fname ?? this.fname, + mname: mname ?? this.mname, + lname: lname ?? this.lname, + genCode: genCode ?? this.genCode, + ); + + factory SwornStatement.fromJson(Map json) => SwornStatement( + bldgapprDetailsId: json["bldgappr_details_id"], + citizenship: json["citizenship"], + civilStatus: json["civil"], + fname: json["fname"], + mname: json["mname"], + lname: json["lname"], + genCode: json["gen_code"], + ); + + factory SwornStatement.fromJson2(Map json) => SwornStatement( + bldgapprDetailsId: json["bldgappr_details_id"], + citizenship: json["citizenship"], + civilStatus: json["civil"], + fname: json["fname"], + mname: json["mname"], + lname: json["lname"], + genCode: json["gen_code"], + ); + + Map toJson() => { + "bldgappr_details_id": bldgapprDetailsId, + "citizenship": citizenship, + "civil": civilStatus, + "fname": fname, + "mname": mname, + "lname": lname, + "gen_code": genCode, + }; +} diff --git a/lib/model/passo/valid_ids.dart b/lib/model/passo/valid_ids.dart new file mode 100644 index 0000000..5d61b3e --- /dev/null +++ b/lib/model/passo/valid_ids.dart @@ -0,0 +1,83 @@ +// To parse this JSON data, do +// +// final floorSketch = floorSketchFromJson(jsonString); + +import 'dart:convert'; + +ValidIds floorSketchFromJson(String str) => ValidIds.fromJson(json.decode(str)); + +String floorSketchToJson(ValidIds data) => json.encode(data.toJson()); + +class ValidIds { + int? bldgapprDetailsId; + String? dateCreated; + String? validIds; + String? genCode; + + ValidIds({ + this.bldgapprDetailsId, + this.dateCreated, + this.validIds, + this.genCode, + }); + + ValidIds copy( + {int? bldgapprDetailsId, + String? dateCreated, + String? validIds, + String? genCode}) { + return ValidIds( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + dateCreated: dateCreated ?? this.dateCreated, + validIds: validIds ?? this.validIds, + genCode: genCode ?? this.genCode, + ); + } + + ValidIds copyWith({ + int? bldgapprDetailsId, + String? dateCreated, + String? validIds, + String? genCode, + }) => + ValidIds( + bldgapprDetailsId: bldgapprDetailsId ?? this.bldgapprDetailsId, + dateCreated: dateCreated ?? this.dateCreated, + validIds: validIds ?? this.validIds, + genCode: genCode ?? this.genCode, + ); + + factory ValidIds.fromJson(Map json) => ValidIds( + bldgapprDetailsId: json["bldgappr_details_id"], + dateCreated: json["date_created"], + validIds: json["id_attachment"], + genCode: json["gen_code"], + ); + + Map toJson() => { + "bldgappr_details_id": bldgapprDetailsId, + "date_created": dateCreated, + "valid_ids": validIds, + "gen_code": genCode, + }; + + // Define the fromMap method to convert a Map into a ValidIds object + factory ValidIds.fromMap(Map map) { + return ValidIds( + bldgapprDetailsId: map['bldgapprDetailsId'] as int?, + validIds: map['validIds'] as String?, + dateCreated: map['dateCreated'] as String?, + genCode: map['genCode'] as String?, + ); + } + + // You can also add a toMap method if needed for converting back to Map + Map toMap() { + return { + 'bldgapprDetailsId': bldgapprDetailsId, + 'validIds': validIds, + 'dateCreated': dateCreated, + 'genCode': genCode, + }; + } +} diff --git a/lib/screens/offline/passo/admin/admin_main_screen.dart b/lib/screens/offline/passo/admin/admin_main_screen.dart index 7b19068..3848906 100644 --- a/lib/screens/offline/passo/admin/admin_main_screen.dart +++ b/lib/screens/offline/passo/admin/admin_main_screen.dart @@ -1,6 +1,7 @@ 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/assessment_level/assessment_level_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/barangay_admin/barangay_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.dart/class_components_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/land_subclassification/land_subclassification_bloc.dart'; @@ -12,6 +13,7 @@ import 'package:unit2/bloc/offline/offline_passo/admin/type_of_location/type_of_ import 'package:unit2/bloc/offline/offline_passo/admin/type_of_road/type_of_road_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/value_adjustments/value_adjustments_bloc.dart'; +import 'package:unit2/screens/offline/passo/admin/assessment_level.dart'; import 'package:unit2/screens/offline/passo/admin/barangay.dart'; import 'package:unit2/screens/offline/passo/admin/class_components.dart'; import 'package:unit2/screens/offline/passo/admin/globalSyncService.dart'; @@ -65,6 +67,20 @@ class _AdminMainScreen extends State { ), body: ListView( children: [ + MainMenu( + icon: Elusive.wrench, + title: "Assessment Levels", + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => + AssessmentLevelBloc()..add(LoadAssessmentLevel()), + child: AssessmentLevelAdminPage(), + ); + })); + }), + const Divider(), MainMenu( icon: Elusive.wrench, title: "Municipalities", diff --git a/lib/screens/offline/passo/admin/assessment_level.dart b/lib/screens/offline/passo/admin/assessment_level.dart new file mode 100644 index 0000000..024acde --- /dev/null +++ b/lib/screens/offline/passo/admin/assessment_level.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/api_services/assessment_level_api_services.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; + +import '../../../../model/passo/assessment_level.dart'; +import '../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; + +class AssessmentLevelAdminPage extends StatefulWidget { + const AssessmentLevelAdminPage(); + + @override + _AssessmentLevelAdminPage createState() => _AssessmentLevelAdminPage(); +} + +class _AssessmentLevelAdminPage extends State { + final items = []; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primary, + title: const Text("Assessment Levels"), + centerTitle: true, + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 15), + ), + onPressed: () async { + // try { + final result = await AssessmentLevelApiServices.instance.fetch(); + + // Assuming result is a List of JSON objects, convert them to AssessmentLevel objects. + final assessmentLevels = + result.map((json) => AssessmentLevel.fromJson(json)).toList(); + + // Insert each AssessmentLevel object into the local database. + for (AssessmentLevel level in assessmentLevels) { + print(level.assessmentLevels); + print(level.genCode); + await SQLServices.instance.createAssessmentLevel(level); + } + + context.read().add(LoadAssessmentLevel()); + // } 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 if needed + }, + builder: (context, state) { + if (state is AssessmentLevelLoaded) { + return Column(children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(15.0), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columns: [ + const DataColumn( + label: Text('Classification ID'), + ), + const DataColumn( + label: Text('Over'), + ), + const DataColumn( + label: Text('Not Over'), + ), + const DataColumn( + label: Text('Assessment Levels'), + ), + const DataColumn( + label: Text('Gen Code'), + ), + ], + rows: state.assLevel.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.classificationId + .toString())), // Display classificationId + DataCell(Text(dataRow.over ?? + 'N/A')), // Use a default value if 'over' is null + DataCell(Text(dataRow.notOver ?? + 'N/A')), // Use a default value if 'notOver' is null + DataCell(Text(dataRow.assessmentLevels ?? + 'N/A')), // Use a default value if 'assessmentLevels' is null + DataCell(Text(dataRow.genCode ?? + 'N/A')), // Use a default value if 'genCode' is null + ], + ); + }).toList(), + ), + ) + ], + ), + ), + ), + ) + ]); + } + + return Container(); + }, + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart b/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart index 142d952..73ec6fd 100644 --- a/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart +++ b/lib/screens/offline/passo/building/add/AddBuildingAndStructure..dart @@ -14,7 +14,6 @@ import 'package:unit2/model/passo/building_and_structure.dart'; import '../../../../../model/passo/unit_construct.dart'; import '../../../../../theme-data.dart/form-style.dart'; -import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; // Function to get stored building type Future getStoredBldgType() async { @@ -30,7 +29,7 @@ Future getStoredBldgType() async { class AddBuildingAndStructureOffline extends StatefulWidget { final OfflineProfile offlineProfile; - AddBuildingAndStructureOffline(this.offlineProfile); + const AddBuildingAndStructureOffline(this.offlineProfile); @override _AddBuildingAndStructureOffline createState() => @@ -176,9 +175,7 @@ class _AddBuildingAndStructureOffline errorText: "This field is required"), searchInputDecoration: normalTextFieldStyle( - _unitConstruct!.bldgType + - ' - ' + - _unitConstruct!.building, + '${_unitConstruct.bldgType} - ${_unitConstruct!.building}', "") .copyWith( suffixIcon: @@ -196,20 +193,18 @@ class _AddBuildingAndStructureOffline const SizedBox( height: 10, ), - Container( - child: FormBuilderTextField( - name: 'unit_value', - decoration: normalTextFieldStyle("Unit Value", ""), - validator: FormBuilderValidators.compose([]), - keyboardType: TextInputType.phone, - onChanged: (value) { - // setState(() { - // _areaValue = int.parse(value!); - // }); - }, - ), + FormBuilderTextField( + name: 'unit_value', + decoration: normalTextFieldStyle("Unit Value", ""), + validator: FormBuilderValidators.compose([]), + keyboardType: TextInputType.phone, + onChanged: (value) { + // setState(() { + // _areaValue = int.parse(value!); + // }); + }, ), - SizedBox( + const SizedBox( height: 10, ), Row( diff --git a/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart index 4a6009b..ffd727e 100644 --- a/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart +++ b/lib/screens/offline/passo/building/add/AddExtraItemsOffline.dart @@ -12,13 +12,9 @@ import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.da import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import 'package:unit2/model/offline/offline_profile.dart'; -import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/class_components%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'; -import 'package:unit2/utils/text_container.dart'; -import 'package:unit2/widgets/error_state.dart'; // Function to get stored building type Future getStoredBldgType() async { @@ -392,15 +388,11 @@ class _AddExtraItemsOffline extends State { suggestions: state.unit .map((UnitConstruct unit) => SearchFieldListItem( - _unitConstruct.bldgType + - ' - ' + - _unitConstruct.building, + '${_unitConstruct.bldgType} - ${_unitConstruct.building}', item: unit, child: ListTile( title: Text( - _unitConstruct.bldgType + - ' - ' + - _unitConstruct.building, + '${_unitConstruct.bldgType} - ${_unitConstruct.building}', overflow: TextOverflow.ellipsis, ), @@ -411,9 +403,7 @@ class _AddExtraItemsOffline extends State { errorText: "This field is required"), searchInputDecoration: normalTextFieldStyle( - _unitConstruct.bldgType + - ' - ' + - _unitConstruct.building, + '${_unitConstruct.bldgType} - ${_unitConstruct.building}', "") .copyWith( suffixIcon: const Icon( @@ -473,7 +463,7 @@ class _AddExtraItemsOffline extends State { ) ], ), - SizedBox( + const SizedBox( height: 10, ), Row( @@ -503,44 +493,40 @@ class _AddExtraItemsOffline extends State { 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), + 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, ), - child: Align( - alignment: Alignment.center, - child: Text(' - ' + - _notPaintedUnitVal - .toString() + - '%')), + borderRadius: + BorderRadius.circular(5.0), ), - ], - ), + child: Align( + alignment: Alignment.center, + child: Text( + ' - $_notPaintedUnitVal%')), + ), + ], ), const SizedBox(height: 10), const Text('Uses second hand materials?'), diff --git a/lib/screens/offline/passo/building/add/add_building.dart b/lib/screens/offline/passo/building/add/add_building.dart index d01fb99..3eb157d 100644 --- a/lib/screens/offline/passo/building/add/add_building.dart +++ b/lib/screens/offline/passo/building/add/add_building.dart @@ -1,24 +1,20 @@ 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:shared_preferences/shared_preferences.dart'; import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/building_and_structure.dart'; -import 'package:unit2/screens/offline/passo/building/add/drawing_pad.dart'; import 'package:unit2/screens/offline/passo/building/add/flutter_painter.dart'; -import 'package:unit2/screens/offline/passo/building/add/imagePicker.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/signature_and_ids.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'; import '../../../../../utils/alerts.dart'; GlobalKey offlineBldgKey = GlobalKey(); @@ -33,7 +29,7 @@ class AddBuilding extends StatefulWidget { class _AddBuilding extends State { int activeStep = 0; // Initial step set to 5. - int upperBound = 7; + int upperBound = 8; List foundation = []; List column = []; @@ -67,6 +63,12 @@ class _AddBuilding extends State { }); } + void Skipto9() { + setState(() { + activeStep = 8; // Set activeStep directly to 9 + }); + } + void updateFoundation(List updatedList) { setState(() { foundation = updatedList; @@ -190,10 +192,10 @@ class _AddBuilding extends State { ), body: Column(children: [ NumberStepper( - numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9], + numbers: const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], stepPadding: 5, activeStepColor: primary, - numberStyle: TextStyle(color: Colors.white), + numberStyle: const TextStyle(color: Colors.white), lineColor: primary, // activeStep property set to activeStep variable defined above. activeStep: activeStep, @@ -217,7 +219,7 @@ class _AddBuilding extends State { }, autovalidateMode: AutovalidateMode.disabled, child: Container( - child: content(PrevBtn, NextBtn), + child: content(PrevBtn, NextBtn, Skipto9), ), ); }), @@ -227,7 +229,7 @@ class _AddBuilding extends State { ); } - Widget content(PrevBtn, NextBtn) { + Widget content(PrevBtn, NextBtn, Skipto9) { switch (activeStep) { case 0: return PropertyInfoOfflinePage(NextBtn, widget.offlineProfile); @@ -248,18 +250,15 @@ class _AddBuilding extends State { updatedBldgKind, updatedBldgType); case 3: - return FlutterDraw(); + return const FlutterDraw(); case 4: - return BuildingAndStructureOfflinePage( - PrevBtn, NextBtn, widget.offlineProfile); - - case 5: return StatefulBuilder( builder: (context, StateSetter setInnerState) => StructuralMaterialsOfflinePage( PrevBtn, NextBtn, + Skipto9, foundationOthers: foundationOthers, columOthers: columOthers, beamsOthers: beamsOthers, @@ -289,7 +288,9 @@ class _AddBuilding extends State { updateFlooringOthers: updateFlooringOthers, updateWpOthers: updateWpOthers, )); - + case 5: + return BuildingAndStructureOfflinePage( + PrevBtn, NextBtn, widget.offlineProfile); case 6: return AdditionalItemOfflinePage( PrevBtn, NextBtn, widget.offlineProfile); @@ -300,10 +301,16 @@ class _AddBuilding extends State { case 8: return PropertyAssessmentOfflinePage( - onCloseTransaction, widget.offlineProfile); + onCloseTransaction, + widget.offlineProfile, + PrevBtn, + NextBtn, + ); + case 9: + return SignatureAndIds(widget.offlineProfile, onCloseTransaction); default: - return Text("Property Info"); + return const Text("Property Info"); } } diff --git a/lib/screens/offline/passo/building/add/drawing_pad.dart b/lib/screens/offline/passo/building/add/drawing_pad.dart index 8f7d2c2..548ad13 100644 --- a/lib/screens/offline/passo/building/add/drawing_pad.dart +++ b/lib/screens/offline/passo/building/add/drawing_pad.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'dart:ui' as ui; @@ -10,8 +9,6 @@ import 'package:flutter_drawing_board/flutter_drawing_board.dart'; import 'package:flutter_drawing_board/paint_contents.dart'; import 'package:flutter_drawing_board/paint_extension.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:unit2/utils/request_permission.dart'; import 'package:http/http.dart'; import 'package:unit2/utils/urls.dart'; // Removed 'as http' diff --git a/lib/screens/offline/passo/building/add/flutter_painter.dart b/lib/screens/offline/passo/building/add/flutter_painter.dart index 20ccb54..6551ec5 100644 --- a/lib/screens/offline/passo/building/add/flutter_painter.dart +++ b/lib/screens/offline/passo/building/add/flutter_painter.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'dart:io'; import 'dart:ui'; -import 'package:http/http.dart'; // Removed 'as http' -import 'package:path/path.dart'; // For basename function -import 'dart:convert'; +// Removed 'as http' +// For basename function import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_painter_v2/flutter_painter.dart'; import 'package:flutter_painter_v2/flutter_painter_extensions.dart'; import 'package:flutter_painter_v2/flutter_painter_pure.dart'; @@ -20,8 +20,6 @@ import 'package:phosphor_flutter/phosphor_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/model/passo/floor_sketch.dart'; -import 'package:unit2/utils/urls.dart'; - import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; class FlutterDraw extends StatefulWidget { @@ -47,34 +45,8 @@ class _FlutterPainterExampleState extends State { final String imagePath = '/data/user/0/com.app.rpass/cache/182.png'; static const List imageLinks = [ - "https://i.imgur.com/btoI5OX.png", - "https://i.imgur.com/EXTQFt7.png", - "https://i.imgur.com/EDNjJYL.png", - "https://i.imgur.com/uQKD6NL.png", - "https://i.imgur.com/cMqVRbl.png", - "https://i.imgur.com/1cJBAfI.png", - "https://i.imgur.com/eNYfHKL.png", - "https://i.imgur.com/c4Ag5yt.png", - "https://i.imgur.com/GhpCJuf.png", - "https://i.imgur.com/XVMeluF.png", - "https://i.imgur.com/mt2yO6Z.png", - "https://i.imgur.com/rw9XP1X.png", - "https://i.imgur.com/pD7foZ8.png", - "https://i.imgur.com/13Y3vp2.png", - "https://i.imgur.com/ojv3yw1.png", - "https://i.imgur.com/f8ZNJJ7.png", - "https://i.imgur.com/BiYkHzw.png", - "https://i.imgur.com/snJOcEz.png", - "https://i.imgur.com/b61cnhi.png", - "https://i.imgur.com/FkDFzYe.png", - "https://i.imgur.com/P310x7d.png", - "https://i.imgur.com/5AHZpua.png", - "https://i.imgur.com/tmvJY4r.png", - "https://i.imgur.com/PdVfGkV.png", - "https://i.imgur.com/1PRzwBf.png", - "https://i.imgur.com/VeeMfBS.png", + "assets/pngs/broken_lines.png", // Ensure the file path is correct ]; - @override void initState() { super.initState(); @@ -103,6 +75,19 @@ class _FlutterPainterExampleState extends State { initBackground(); } + Future _fileExists(String path) async { + return File(path).exists(); + } + + Future _loadImageFromAsset(String assetPath) async { + final Completer completer = Completer(); + final ByteData data = await rootBundle.load(assetPath); + ui.decodeImageFromList(data.buffer.asUint8List(), (ui.Image img) { + completer.complete(img); + }); + return completer.future; + } + /// Fetches image from an [ImageProvider] (in this example, [NetworkImage]) /// to use it as a background void initBackground() async { @@ -110,21 +95,37 @@ class _FlutterPainterExampleState extends State { final floorSketchSaved = prefs.getBool('floorSketchSaved') ?? false; final tempID = prefs.getInt('tempid'); - print(floorSketchSaved); + print('FloorSketchSaved: $floorSketchSaved, TempID: $tempID'); ui.Image image; - if (floorSketchSaved && tempID != null) { - final String imagePath = '/data/user/0/com.app.rpass/cache/$tempID.png'; - image = await _loadImageFromPath(imagePath); - } else { - image = await const AssetImage('assets/pngs/white_bg.png').image; - } + try { + if (floorSketchSaved && tempID != null) { + final String imagePath = '/data/user/0/com.app.rpass/cache/$tempID.png'; + print('Checking file: $imagePath'); + if (await _fileExists(imagePath)) { + print('File exists. Loading from path.'); + image = await _loadImageFromPath(imagePath); + } else { + print('File does not exist. Falling back to default.'); + image = await _loadImageFromAsset('assets/pngs/white_bg.png'); + } + } else { + print('Loading default background from assets.'); + image = await _loadImageFromAsset('assets/pngs/white_bg.png'); + } - setState(() { - backgroundImage = image; - controller.background = image.backgroundDrawable; - }); + setState(() { + backgroundImage = image; + controller.background = image.backgroundDrawable; + print('Background image set successfully.'); + }); + } catch (e) { + print('Error loading background image: $e'); + setState(() { + backgroundImage = null; // Fallback for rendering + }); + } } /// Updates UI when the focus changes @@ -226,7 +227,7 @@ class _FlutterPainterExampleState extends State { child: FloatingActionButton( heroTag: 'btn1', child: const Icon( - PhosphorIcons.imageFill, + PhosphorIcons.download, ), onPressed: () => renderAndDisplayImage(context), ), @@ -448,7 +449,7 @@ class _FlutterPainterExampleState extends State { ), ], ), - ] + ], ], ), ), @@ -594,14 +595,30 @@ class _FlutterPainterExampleState extends State { } void addSticker(BuildContext context) async { + // Select the image link from the dialog final imageLink = await showDialog( - context: context, - builder: (context) => const SelectStickerImageDialog( - imagesLinks: imageLinks, - )); + context: context, + builder: (context) => const SelectStickerImageDialog( + imagesLinks: imageLinks, + ), + ); + if (imageLink == null) return; - controller.addImage( - await NetworkImage(imageLink).image, const Size(100, 100)); + + // Use AssetImage for the asset + final AssetImage assetImage = AssetImage(imageLink); + + // Resolve the ImageProvider to get the actual image + final ImageStream stream = assetImage.resolve(const ImageConfiguration()); + final Completer completer = Completer(); + stream.addListener(ImageStreamListener((ImageInfo info, bool _) { + completer.complete(info); + })); + + final ImageInfo imageInfo = await completer.future; + + // Add the image to the controller + controller.addImage(imageInfo.image, const Size(100, 100)); } void setFreeStyleStrokeWidth(double value) { @@ -816,3 +833,32 @@ class SelectStickerImageDialog extends StatelessWidget { ); } } + +class GridPainter extends CustomPainter { + final double gridSize; + final Paint gridPaint; + + GridPainter(this.gridSize) + : gridPaint = Paint() + ..color = Colors.grey.withOpacity(0.5) + ..strokeWidth = 1; + + @override + void paint(Canvas canvas, Size size) { + for (double x = 0; x < size.width; x += gridSize) { + canvas.drawLine(Offset(x, 0), Offset(x, size.height), gridPaint); + } + for (double y = 0; y < size.height; y += gridSize) { + canvas.drawLine(Offset(0, y), Offset(size.width, y), gridPaint); + } + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => false; +} + +Offset snapToGrid(Offset point, double gridSize) { + final x = (point.dx / gridSize).round() * gridSize; + final y = (point.dy / gridSize).round() * gridSize; + return Offset(x, y); +} diff --git a/lib/screens/offline/passo/building/add/general_description.dart b/lib/screens/offline/passo/building/add/general_description.dart index b9f0f2d..eb49aaf 100644 --- a/lib/screens/offline/passo/building/add/general_description.dart +++ b/lib/screens/offline/passo/building/add/general_description.dart @@ -2,8 +2,6 @@ import 'dart:convert'; 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:form_builder_validators/form_builder_validators.dart'; import 'package:searchfield/searchfield.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -12,7 +10,6 @@ import 'package:unit2/bloc/offline/offline_passo/building/general_description/ge import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.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'; diff --git a/lib/screens/offline/passo/building/add/imagePicker.dart b/lib/screens/offline/passo/building/add/imagePicker.dart index 814833e..3114be7 100644 --- a/lib/screens/offline/passo/building/add/imagePicker.dart +++ b/lib/screens/offline/passo/building/add/imagePicker.dart @@ -2,10 +2,8 @@ import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:http/http.dart'; // Removed 'as http' import 'package:path/path.dart'; // For basename function -import 'dart:convert'; import 'dart:io'; -import 'package:unit2/model/location/purok.dart'; import 'package:unit2/utils/urls.dart'; class ImagePickerScreen extends StatefulWidget { diff --git a/lib/screens/offline/passo/building/add/landref_location.dart b/lib/screens/offline/passo/building/add/landref_location.dart index 6c379df..712664c 100644 --- a/lib/screens/offline/passo/building/add/landref_location.dart +++ b/lib/screens/offline/passo/building/add/landref_location.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package: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'; @@ -145,46 +144,46 @@ class _LandRefLocationOfflinePage extends State { fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.left), ), - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( - children: [ - SizedBox( - width: 50, // Adjust the width as needed - height: 50, // Adjust the height as needed - child: Checkbox( - checkColor: Colors.white, - value: sameOwner, - onChanged: (bool? value) { - setState(() { - sameOwner = value!; - offlineBldgKey.currentState! - .patchValue({ - 'l_owner': offlineBldgKey.currentState - ?.value['fname'] + - ' ' + - offlineBldgKey.currentState - ?.value['mname'] + - ' ' + - offlineBldgKey - .currentState?.value['lname'] - }); - offlineBldgKey.currentState! - .patchValue({ - 'l_td_arp': offlineBldgKey - .currentState?.value['arp_td'] - }); - }); - }, - ), - ), - Text('Same building owner') - ], - ), - // Other widgets in the column - ], - ), + // Column( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Row( + // children: [ + // SizedBox( + // width: 50, // Adjust the width as needed + // height: 50, // Adjust the height as needed + // child: Checkbox( + // checkColor: Colors.white, + // value: sameOwner, + // onChanged: (bool? value) { + // setState(() { + // sameOwner = value!; + // offlineBldgKey.currentState! + // .patchValue({ + // 'l_owner': offlineBldgKey.currentState + // ?.value['fname'] + + // ' ' + + // offlineBldgKey.currentState + // ?.value['mname'] + + // ' ' + + // offlineBldgKey + // .currentState?.value['lname'] + // }); + // offlineBldgKey.currentState! + // .patchValue({ + // 'l_td_arp': offlineBldgKey + // .currentState?.value['arp_td'] + // }); + // }); + // }, + // ), + // ), + // Text('Same building owner') + // ], + // ), + // // Other widgets in the column + // ], + // ), customTextField( "Land Owner", "", 'l_owner', TextInputType.text), Row( diff --git a/lib/screens/offline/passo/building/add/property_appraisal.dart b/lib/screens/offline/passo/building/add/property_appraisal.dart index 49f5a41..6dd6423 100644 --- a/lib/screens/offline/passo/building/add/property_appraisal.dart +++ b/lib/screens/offline/passo/building/add/property_appraisal.dart @@ -1,19 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/assessment_level/assessment_level_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/building_and_structure/building_and_structure_bloc.dart'; import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; -import 'package:unit2/screens/offline/passo/building/add/additional_items.dart'; -import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; -import 'package:unit2/theme-data.dart/form-style.dart'; import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/assessment_level.dart'; import '../../../../../model/passo/building_and_structure.dart'; import '../../../../../widgets/passo/custom_button.dart'; @@ -41,422 +36,73 @@ class _PropertyAppraisalOfflinePage String _memoranda = ''; final focus = FocusNode(); - String assessmentLevel(marketValues, property_class) { - final marketValue = 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; + String mapClassificationToPropertyClass(int classificationId) { + switch (classificationId) { + case 1: + return "Residential"; + case 2: + return "Agricultural"; + case 3: + return "Commercial"; + case 4: + return "Industrial"; + case 5: + return "Mineral"; + case 6: + return "Timberland"; default: + return "Unknown"; // Handle unexpected cases } - return ''; } - double assessmentValue(marketValues, property_class) { - final marketValue = 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: + double calculateAssessmentValue( + double marketValue, String propertyClass, List levels) { + // Filter assessment levels based on the property class + final relevantLevels = levels + .where((level) => + mapClassificationToPropertyClass(level.classificationId ?? 0) == + propertyClass) + .toList(); + + // Find the matching range + for (final level in relevantLevels) { + final over = double.tryParse(level.over ?? "0") ?? 0.0; + final notOver = double.tryParse(level.notOver ?? "0") ?? double.infinity; + final assessmentPercentage = + double.tryParse(level.assessmentLevels ?? "0") ?? 0.0; + + if (marketValue > over && marketValue <= notOver) { + return marketValue * (assessmentPercentage / 100); + } } - return 0; + + // Return 0 if no match is found + return 0.0; + } + + double calculateAssessmentLevel( + double marketValue, String propertyClass, List levels) { + // Filter assessment levels based on the property class + final relevantLevels = levels + .where((level) => + mapClassificationToPropertyClass(level.classificationId ?? 0) == + propertyClass) + .toList(); + + // Find the matching range and assessment level + for (final level in relevantLevels) { + final over = double.tryParse(level.over ?? "0") ?? 0.0; + final notOver = double.tryParse(level.notOver ?? "0") ?? double.infinity; + final assessmentPercentage = + double.tryParse(level.assessmentLevels ?? "0") ?? 0.0; + + if (marketValue > over && marketValue <= notOver) { + return assessmentPercentage; // Return assessment level (percentage) + } + } + + // Return 0.0 if no match is found + return 0.0; } _calculateMarketValue( @@ -492,34 +138,6 @@ class _PropertyAppraisalOfflinePage return total; } - // calculateMarketValue(buildingCost, additionalItems, dep) { - // double sum = 0; - // double depreciation = 0; - // double total = 0; - - // sum = buildingCost + calculateAdditionalItems(additionalItems); - - // depreciation = sum * dep; - - // total = sum - depreciation; - - // return total; - // } - - // calculateDepCost(buildingCost, additionalItems, dep) { - // double sum = 0; - // double depreciation = 0; - // double total = 0; - - // sum = buildingCost + calculateAdditionalItems(additionalItems); - - // depreciation = sum * dep; - - // total = sum - depreciation; - - // return depreciation; - // } - @override Widget build(BuildContext context) { final width = MediaQuery.of(context).size.width; @@ -537,156 +155,164 @@ class _PropertyAppraisalOfflinePage }, builder: (context, state) { if (state is BuildingAndStructureLoaded) { - return SingleChildScrollView( - padding: const EdgeInsets.all(20), - 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: 20), - textAlign: TextAlign.left), - ), - Row( - mainAxisSize: MainAxisSize.min, + final bldgAndStructure = state.bldgAndStructure; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is AssessmentLevelLoaded) { + return SingleChildScrollView( + padding: const EdgeInsets.all(20), + child: Column( children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text('BUILDING & STRUCTURE', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context).size.width / 4, - columns: [ - const DataColumn( - label: Text('Building Core'), - ), - const DataColumn( - label: Text(''), - ), - const DataColumn( - label: Text('Market Value'), - ), - ], - rows: [ - ...state.bldgAndStructure - .map((dataRow) { - return DataRow(cells: [ - DataCell(Text(dataRow.structType!)), - DataCell(Text("")), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format(double.parse(dataRow - .adjustedMarketValue - .toString()!)), - )) - ]); - }), - DataRow(cells: [ - DataCell(Text('Total', + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + textAlign: TextAlign.left), + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'BUILDING & STRUCTURE', style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 15, - color: Colors.red))), - DataCell(Text('')), - DataCell( - Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format(_totalMarketValueBLDG( - state.bldgAndStructure)), - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15, - color: Colors.red)), - ) - ]), - ], - ) - ], - )), - ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text('ADDITIONAL ITEMS', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context).size.width / - 3, - columns: const [ - DataColumn( - label: Text('Additional Item'), - ), - DataColumn( - label: Text(''), - ), - DataColumn( - label: Text('Market Value'), - ), - ], - rows: [ - ...addItem.map((dataRow) { - return DataRow(cells: [ - DataCell( - Text(dataRow.className!)), + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable( + columnSpacing: MediaQuery.of(context) + .size + .width / + 4, + columns: [ + const DataColumn( + label: Text('Building Core'), + ), + const DataColumn( + label: Text(''), + ), + const DataColumn( + label: Text('Market Value'), + ), + ], + rows: [ + ...bldgAndStructure.map((dataRow) { + return DataRow(cells: [ + DataCell( + Text(dataRow.structType!)), + DataCell(Text("")), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse(dataRow + .adjustedMarketValue + .toString()!)), + )) + ]); + }), + DataRow(cells: [ + DataCell(Text('Total', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 15, + color: Colors.red))), DataCell(Text('')), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱") - .format(double.parse(dataRow - .marketValue - .toString()!)) - .toString(), - )) - ]); - }).toList(), - DataRow( - // color: MaterialStateColor.resolveWith( - // (states) { - // // Use a color for the DataRow, for example, Colors.blue - // return Colors.redAccent; - // }), - cells: [ + DataCell( + Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + _totalMarketValueBLDG( + bldgAndStructure)), + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 15, + color: Colors.red)), + ) + ]), + ], + ) + ], + )), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('ADDITIONAL ITEMS', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable( + columnSpacing: + MediaQuery.of(context) + .size + .width / + 3, + columns: const [ + DataColumn( + label: Text('Additional Item'), + ), + DataColumn( + label: Text(''), + ), + DataColumn( + label: Text('Market Value'), + ), + ], + rows: [ + ...addItem.map((dataRow) { + return DataRow(cells: [ + DataCell( + Text(dataRow.className!)), + DataCell(Text('')), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format(double.parse( + dataRow.marketValue + .toString()!)) + .toString(), + )) + ]); + }).toList(), + DataRow(cells: [ DataCell(Text('Total', style: TextStyle( fontWeight: @@ -709,175 +335,151 @@ class _PropertyAppraisalOfflinePage color: Colors.red)), ) ]), - ]), - ], - )), + ]), + ], + )), + ), + ], ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text('PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context).size.width / - 6, - columns: const [ - DataColumn( - label: Text('Actual Use'), - ), - DataColumn( - label: Text('Market Value'), - ), - DataColumn( - label: Text('Ass. Level'), - ), - DataColumn( - label: Text('Ass. Value'), - ), - ], - rows: [ - DataRow( - cells: [ - DataCell(Text(offlineBldgKey - .currentState - ?.value['actual_use'] ?? - "")), - DataCell(Text(NumberFormat - .currency( - locale: 'en-PH', - symbol: "₱") - .format(_calculateMarketValue( - addItem, - state - .bldgAndStructure)))), - DataCell( - Text( - assessmentLevel( - _calculateMarketValue( - addItem, - state - .bldgAndStructure), - offlineBldgKey + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15), + textAlign: TextAlign.left), + ), + DataTable( + columnSpacing: + MediaQuery.of(context) + .size + .width / + 6, + columns: const [ + DataColumn( + label: Text('Actual Use'), + ), + DataColumn( + label: Text('Market Value'), + ), + DataColumn( + label: Text('Ass. Level'), + ), + DataColumn( + label: Text('Ass. Value'), + ), + ], + rows: [ + DataRow( + cells: [ + DataCell(Text(offlineBldgKey .currentState ?.value[ - 'actual_use']), - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱") - .format(double.parse( - assessmentValue( + 'actual_use'] ?? + "")), + DataCell(Text(NumberFormat + .currency( + locale: 'en-PH', + symbol: "₱") + .format( + _calculateMarketValue( + addItem, + bldgAndStructure)))), + DataCell( + Text( + calculateAssessmentLevel( _calculateMarketValue( addItem, - state - .bldgAndStructure), + bldgAndStructure), offlineBldgKey .currentState ?.value[ - 'actual_use']) + 'actual_use'], + state.assLevel) .toString(), - )) - .toString(), - )), - ], - ), - ]) - ], - )), + style: const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), + ), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format(double.parse( + calculateAssessmentValue( + _calculateMarketValue( + addItem, + bldgAndStructure), + offlineBldgKey + .currentState + ?.value[ + 'actual_use'], + state + .assLevel) + .toString(), + )) + .toString(), + )), + ], + ), + ]) + ], + )), + ), + ], + ), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + widget.NextBtn(); + } + ; + }, + ) + ], ), ], ), - const SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - { - // final tempID = - // await SharedPreferences.getInstance(); - // print(tempID.getInt('tempid')); - // context.read().add(AddBldgAppraisal( - // id: 1, - // bldgapprDetailsId: tempID.getInt('tempid')!, - // assessedById: '1', - // assessedByName: 'ad', - // dateCreated: '00', - // dateModified: '00', - // unitconstructCost: offlineBldgKey - // .currentState - // ?.value['bldg_type'] - // .unitValue, - // buildingCore: 'test', - // unitconstructSubtotal: - // (double.parse(offlineBldgKey.currentState!.value['total_area']) * - // double.parse(offlineBldgKey - // .currentState! - // .value['bldg_type'] - // .unitValue)) - // .toString(), - // depreciationRate: depRate.toString(), - // depreciationCost: calculateDepCost( - // (double.parse(offlineBldgKey.currentState!.value['total_area']) * - // double.parse(offlineBldgKey.currentState?.value['bldg_type'].unitValue)), - // addItem, - // depRate) - // .toString(), - // costAddItems: calculateAdditionalItems(addItem).toString(), - // addItemsSubtotal: calculateAdditionalItems(addItem).toString(), - // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), - // marketValue: calculateMarketValue((double.parse(offlineBldgKey.currentState!.value['total_area']) * double.parse(offlineBldgKey.currentState!.value['bldg_type'].unitValue)), addItem, depRate).toString(), - // totalArea: offlineBldgKey.currentState!.value['total_area'], - // actualUse: "Residential")); - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ], - ), - ); + ); + } + return Container(); + }); } return Container(); }, diff --git a/lib/screens/offline/passo/building/add/property_assessment.dart b/lib/screens/offline/passo/building/add/property_assessment.dart index 79625ea..71a036d 100644 --- a/lib/screens/offline/passo/building/add/property_assessment.dart +++ b/lib/screens/offline/passo/building/add/property_assessment.dart @@ -1,15 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:searchfield/searchfield.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; +import 'package:unit2/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart'; import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/building/add/add_building.dart'; -import 'package:accordion/accordion.dart'; -import 'package:accordion/controllers.dart'; import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; import '../../../../../bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; @@ -19,15 +17,17 @@ import '../../../../../model/passo/additional_items.dart'; import '../../../../../model/passo/building_and_structure.dart'; import '../../../../../model/passo/memoranda.dart'; import '../../../../../model/passo/signatories.dart'; -import '../../../../../theme-data.dart/colors.dart'; -import '../../../../../theme-data.dart/form-style.dart'; -import 'package:intl/intl.dart'; // Import the intl package + +import '../../../../../widgets/passo/custom_button.dart'; // Import the intl package class PropertyAssessmentOfflinePage extends StatefulWidget { Function function; final OfflineProfile offlineProfile; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; - PropertyAssessmentOfflinePage(this.function, this.offlineProfile); + PropertyAssessmentOfflinePage( + this.function, this.offlineProfile, this.NextBtn, this.PrevBtn); @override _PropertyAssessmentOfflinePage createState() => @@ -39,6 +39,8 @@ class _PropertyAssessmentOfflinePage double assessment_level = 0; bool isTaxable = false; bool isExempt = false; + bool isOwner = false; + bool isRepresentative = false; String _memoranda = ""; String _notes = ""; String appraised_by = ""; @@ -52,7 +54,7 @@ class _PropertyAssessmentOfflinePage final appraisedByFocus = FocusNode(); final recByFocus = FocusNode(); final apprvdByFocus = FocusNode(); - + final civilStatus = ["Single", "Married", "Divorced", "Separated", "Widowed"]; final quarter = ['1st', '2nd', '3rd', '4th']; TextEditingController memorandaController = TextEditingController(); @@ -496,6 +498,7 @@ class _PropertyAssessmentOfflinePage @override Widget build(BuildContext context) { var width = MediaQuery.of(context).size.width; + return BlocConsumer( listener: (context, state) { // TODO: implement listener @@ -632,14 +635,128 @@ class _PropertyAssessmentOfflinePage .number)), ], ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Row( + children: [ + const Text('Owner'), + Checkbox( + checkColor: + Colors.white, + value: isOwner, + onChanged: + (bool? value) { + setState(() { + isOwner = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text( + 'Representative'), + Checkbox( + checkColor: + Colors.white, + value: isRepresentative, + onChanged: + (bool? value) { + setState(() { + isRepresentative = + value!; + }); + }, + ) + ], + ), + ], + ), ], ), const SizedBox( height: 10, ), + Visibility( + visible: isRepresentative, + child: Row( + children: [ + Expanded( + child: customTextField( + 'First Name', + '', + 'r_fname', + TextInputType.text), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: customTextField( + 'Middle Name', + '', + 'r_mname', + TextInputType.text), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: customTextField( + 'Last Name', + '', + 'r_lname', + TextInputType.text), + ) + ], + ), + ), + const SizedBox( + height: 10, + ), + Visibility( + visible: isRepresentative, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDropDownField( + "Civil Status", + "", + "r_civilStatus", + civilStatus), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Citizenship", + "", + 'r_citizenship', + TextInputType.text), + ), + ]), + ), + const SizedBox( + height: 20, + ), const Divider( thickness: 2, ), + const SizedBox( + height: 20, + ), Row( children: [ SizedBox( @@ -1340,122 +1457,235 @@ class _PropertyAssessmentOfflinePage const SizedBox( height: 30, ), - ElevatedButton( - onPressed: () async { - final tempID = - await SharedPreferences - .getInstance(); - print( - tempID.getInt('tempid')! - 1); - // final List - // propertyAssessments = []; - DateTime? appDate = offlineBldgKey - .currentState! - .value['app_date']; - DateTime? recDate = offlineBldgKey - .currentState! - .value['rec_date']; - DateTime? approveDate = - offlineBldgKey.currentState! - .value['approve_date']; - DateTime? dateReceived = - offlineBldgKey.currentState! - .value['date_received']; - DateTime? entryDate = - offlineBldgKey.currentState! - .value['date_of_entry']; - String appDateString = - appDate != null - ? appDate.toString() - : ''; - String recDateString = - recDate != null - ? recDate.toString() - : ''; - String approveDateString = - approveDate != null - ? approveDate.toString() - : ''; - String receivedDateString = - recDate != null - ? recDate.toString() - : ''; - String entryDateString = - recDate != null - ? recDate.toString() - : ''; - context.read().add( - AddBldgAssessment( - id: 1, - bldgapprDetailsId: tempID - .getInt('tempid')!, - assessedById: widget - .offlineProfile.id - .toString(), - assessedByName: widget - .offlineProfile - .firstName!, - dateCreated: '', - dateModified: '', - actualUse: offlineBldgKey.currentState!.value['actual_use'] ?? - '', // Replace null with an empty string - marketValue: - _calculateMarketValue(addItem, state.bldgAndStructure) - .toString(), - assessmentLevel: assessmentLevel( - _calculateMarketValue( - addItem, - state - .bldgAndStructure), - offlineBldgKey - .currentState - ?.value['actual_use']), - assessedValue: assessmentValue(_calculateMarketValue(addItem, state.bldgAndStructure), offlineBldgKey.currentState?.value['actual_use']).toString(), - taxable: isTaxable == true ? '1' : '0', - exempt: isExempt == true ? '1' : '0', - qtr: offlineBldgKey.currentState!.value['qtr'] ?? '0', // Replace null with '0' - yr: int.parse(offlineBldgKey.currentState!.value['yr'] ?? '0'), // Replace null with '0' - appraisedbyName: appraised_by, - appraisedbyDate: appDateString, // Replace null with current date - recommendapprName: rec_by, - recommendapprDate: recDateString, // Replace null with current date - approvedbyName: approved_by, - approvedbyDate: approveDateString, - memoranda: _memoranda, - note: _notes, - swornstatementNo: offlineBldgKey.currentState!.value['sworn_statement'] ?? " ", // Replace null with an empty string - dateReceived: receivedDateString, - // Replace null with current date - entryDateAssessment: entryDateString, - // Replace null with current date - entryDateBy: widget.offlineProfile.firstName!, - genCode: '5th', - appraisedbyDesignation: appraised_by_designation, - approvedbyDesignation: approved_by_designation, - recommendapprDesignation: rec_by_designation - // Replace null with an empty string - )); - // print('assess'); - // print((asses)); - - widget.function(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: primary, - foregroundColor: Colors.red), - child: const Padding( - padding: EdgeInsets.all(15.0), - child: Align( - alignment: Alignment.center, - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, - ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon( + Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, ), - ), + CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + final prefs = + await SharedPreferences + .getInstance(); + final tempID = + prefs.getInt('tempid')!; + + // Simplified date retrieval + Map + dateFields = { + 'app_date': offlineBldgKey + .currentState! + .value['app_date'], + 'rec_date': offlineBldgKey + .currentState! + .value['rec_date'], + 'approve_date': + offlineBldgKey + .currentState! + .value[ + 'approve_date'], + 'date_received': + offlineBldgKey + .currentState! + .value[ + 'date_received'], + 'date_of_entry': + offlineBldgKey + .currentState! + .value[ + 'date_of_entry'], + }; + + String formatDate( + DateTime? date) => + date?.toString() ?? ''; + + // Extracted Strings for date fields + String appDateString = + formatDate(dateFields[ + 'app_date']); + String recDateString = + formatDate(dateFields[ + 'rec_date']); + String approveDateString = + formatDate(dateFields[ + 'approve_date']); + String receivedDateString = + formatDate(dateFields[ + 'date_received']); + String entryDateString = + formatDate(dateFields[ + 'date_of_entry']); + + // Assessment Calculation + double calculatedMarketValue = + _calculateMarketValue( + addItem, + state + .bldgAndStructure); + String marketValue = + calculatedMarketValue + .toString(); + String assessedValue = + assessmentValue( + calculatedMarketValue, + offlineBldgKey + .currentState + ?.value[ + 'actual_use']) + .toString(); + String assessmentLevelString = + assessmentLevel( + calculatedMarketValue, + offlineBldgKey + .currentState + ?.value[ + 'actual_use']); + + context + .read< + BldgAssessmentOfflineBloc>() + .add(AddBldgAssessment( + id: 1, + bldgapprDetailsId: + tempID, + assessedById: widget + .offlineProfile.id + .toString(), + assessedByName: widget + .offlineProfile + .firstName!, + dateCreated: '', + dateModified: '', + actualUse: offlineBldgKey + .currentState! + .value[ + 'actual_use'] ?? + '', + marketValue: + marketValue, + assessmentLevel: + assessmentLevelString, + assessedValue: + assessedValue, + taxable: isTaxable + ? '1' + : '0', + exempt: isExempt + ? '1' + : '0', + qtr: offlineBldgKey + .currentState! + .value['qtr'] ?? + '0', + yr: int.parse(offlineBldgKey + .currentState! + .value['yr'] ?? + '0'), + appraisedbyName: + appraised_by, + appraisedbyDate: + appDateString, + recommendapprName: + rec_by, + recommendapprDate: + recDateString, + approvedbyName: + approved_by, + approvedbyDate: + approveDateString, + memoranda: _memoranda, + note: _notes, + swornstatementNo: offlineBldgKey + .currentState! + .value[ + 'sworn_statement'] ?? + " ", + dateReceived: + receivedDateString, + entryDateAssessment: + entryDateString, + entryDateBy: widget + .offlineProfile + .firstName!, + genCode: '5th', + appraisedbyDesignation: + appraised_by_designation, + approvedbyDesignation: + approved_by_designation, + recommendapprDesignation: + rec_by_designation, + )); + + context + .read< + SwornStatementBloc>() + .add( + AddSwornStatement( + bldgapprDetailsId: + tempID, + fname: isRepresentative + ? offlineBldgKey + .currentState! + .value[ + 'r_fname'] + : offlineBldgKey + .currentState! + .value['fname'], + mname: isRepresentative + ? offlineBldgKey + .currentState! + .value[ + 'r_mname'] + : offlineBldgKey + .currentState! + .value['mname'], + lname: isRepresentative + ? offlineBldgKey + .currentState! + .value[ + 'r_lname'] + : offlineBldgKey + .currentState! + .value['lname'], + citizenship: isRepresentative + ? offlineBldgKey + .currentState! + .value[ + 'r_citizenship'] + : offlineBldgKey + .currentState! + .value[ + 'citizenship'], + civilStatus: isRepresentative + ? offlineBldgKey + .currentState! + .value[ + 'r_civilStatus'] + : offlineBldgKey + .currentState! + .value[ + 'civil_status'], + genCode: '5TH', + ), + ); + widget.PrevBtn; + }, + ), + ], ), ], ), diff --git a/lib/screens/offline/passo/building/add/property_owner_info.dart b/lib/screens/offline/passo/building/add/property_owner_info.dart index 69b49ad..271cc57 100644 --- a/lib/screens/offline/passo/building/add/property_owner_info.dart +++ b/lib/screens/offline/passo/building/add/property_owner_info.dart @@ -21,6 +21,7 @@ class PropertyInfoOfflinePage extends StatefulWidget { class _PropertyInfoPage extends State { int tempId = 0; final transaction_codes = ['New', 'Revision']; + final civilStatus = ["Single", "Married", "Divorced", "Separated", "Widowed"]; final DateTime now; final String formatter; bool isOptional = false; @@ -86,6 +87,22 @@ class _PropertyInfoPage extends State { "Last Name", "", 'lname', TextInputType.text), ) ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDropDownField( + "Civil Status", "", "civil_status", civilStatus), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Citizenship", "", 'citizenship', TextInputType.text), + ), + ]), customDatTimePicker("Birthday", "", "bday"), customTextField("Address", "", 'address', TextInputType.text), Column( @@ -218,6 +235,8 @@ class _PropertyInfoPage extends State { assessedByName: widget.offlineProfile.firstName!, dateCreated: formatter, dateModified: ' ', + citizenship: offlineBldgKey.currentState!.value['citizenship'] ?? ' ', + civilStatus: offlineBldgKey.currentState!.value['civil_status'] ?? ' ', genCode: '5th'), ); widget.handleButtonPress(); diff --git a/lib/screens/offline/passo/building/add/signature_and_ids.dart b/lib/screens/offline/passo/building/add/signature_and_ids.dart new file mode 100644 index 0000000..660a5d7 --- /dev/null +++ b/lib/screens/offline/passo/building/add/signature_and_ids.dart @@ -0,0 +1,335 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; +import 'package:image_picker/image_picker.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:signature/signature.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/model/passo/esignature.dart'; +import 'package:unit2/model/passo/valid_ids.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'dart:ui' as ui; +import 'dart:typed_data'; +import 'package:path_provider/path_provider.dart'; + +class SignatureAndIds extends StatefulWidget { + final OfflineProfile offlineProfile; + Function function; + SignatureAndIds(this.offlineProfile, this.function); + + @override + _SignatureAndIds createState() => _SignatureAndIds(); +} + +class _SignatureAndIds extends State { + List _images = []; // List to hold multiple images + final ImagePicker _picker = ImagePicker(); + SignatureController? _signatureController; + + @override + void initState() { + _signatureController = SignatureController( + penStrokeWidth: 3, + penColor: Colors.black87, + ); + super.initState(); + } + + @override + void dispose() { + _signatureController!.dispose(); + super.dispose(); + } + +// Function to pick multiple images from the gallery + Future _pickImages() async { + final List? pickedFiles = await _picker.pickMultiImage(); + + // Ensure picked files are within the limit + if (pickedFiles != null && pickedFiles.length + _images.length <= 6) { + // Convert to unique File instances and add to _images + List newImages = + pickedFiles.map((pickedFile) => File(pickedFile.path)).toList(); + + setState(() { + _images.addAll(newImages); + }); + + // Save each image individually + for (var imageFile in newImages) { + await _saveImageToDatabase(imageFile); + } + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('You can only select up to 6 images.'), + )); + } + } + +// Function to save image information to the database + Future _saveImageToDatabase(File imageFile) async { + int? bldgapprDetailsId = await _getBldgapprDetailsId(); + String dateNw = DateTime.now().toIso8601String(); + + ValidIds validID = ValidIds( + bldgapprDetailsId: bldgapprDetailsId, + validIds: imageFile.path, // Image path + dateCreated: dateNw, // Current date + genCode: "5TH", // Fixed gen code + ); + + await _saveOrUpdateValidIds(bldgapprDetailsId!, validID); + } + +// Function to check whether to create or update the database record + Future _saveOrUpdateValidIds( + int bldgapprDetailsId, ValidIds validID) async { + final List> existingIds = + await SQLServices.instance.getValidIds(bldgapprDetailsId); + + print('existng IDS'); + print(existingIds.length); + + await SQLServices.instance.createValidIds(validID); + } + + // Function to capture multiple images (up to 5) from the camera + Future _captureImage() async { + if (_images.length < 6) { + final XFile? image = await _picker.pickImage(source: ImageSource.camera); + + if (image != null) { + setState(() { + _images.add(File(image.path)); + }); + + await _saveImageToDatabase(File(image.path)); + } + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('You can only select up to 6 images.'), + )); + } + } + + // Function to save image information to the database + // Future _saveImageToDatabase(File imageFile) async { + // int? bldgapprDetailsId = await _getBldgapprDetailsId(); + // String dateNw = DateTime.now().toIso8601String(); + + // ValidIds validID = ValidIds( + // bldgapprDetailsId: bldgapprDetailsId, + // validIds: imageFile.path, // Image path + // dateCreated: dateNw, // Current date + // genCode: "5TH", // Fixed gen code + // ); + + // await _saveOrUpdateValidIds(bldgapprDetailsId!, validID); + // } + + // // Function to check whether to create or update the database record + // Future _saveOrUpdateValidIds( + // int bldgapprDetailsId, ValidIds validID) async { + // final List> existingIds = + // await SQLServices.instance.getValidIds(bldgapprDetailsId); + + // await SQLServices.instance.createValidIds(validID); + + // } + + Future _getBldgapprDetailsId() async { + final prefs = await SharedPreferences.getInstance(); + final tempID = prefs.getInt('tempid'); + return tempID; + } + + Future _saveSignature() async { + if (_signatureController!.isNotEmpty) { + try { + final ui.Image? image = await _signatureController?.toImage(); + final ByteData? byteData = + await image?.toByteData(format: ui.ImageByteFormat.png); + final Uint8List pngBytes = byteData!.buffer.asUint8List(); + + final directory = await getApplicationDocumentsDirectory(); + final String path = '${directory.path}/signature.png'; + + final File imgFile = File(path); + await imgFile.writeAsBytes(pngBytes); + print('Signature saved at: $path'); + + int? bldgapprDetailsId = await _getBldgapprDetailsId(); + String dateNw = DateTime.now().toIso8601String(); + + final ESignature eSignature = ESignature( + bldgapprDetailsId: bldgapprDetailsId, + signAttachment: path, // Use the saved signature path + dateCreated: dateNw, + dateModified: dateNw, + genCode: "5TH", + ); + + await SQLServices.instance.createESignature(eSignature); + return path; + } catch (e) { + print('Error saving signature: $e'); + return null; + } + } + return null; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: + const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), + child: const Text( + 'ID AND SIGNATUREs', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left, + ), + ), + Row( + children: [ + Expanded( + child: Column( + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.45, + height: MediaQuery.of(context).size.height * 0.6, + child: _images.isNotEmpty + ? ListView.builder( + itemCount: _images.length, + itemBuilder: (context, index) { + return Image.file(_images[index]); + }, + ) + : Image.asset('assets/pngs/id-card.png'), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: () { + _pickImages(); + }, + icon: const Icon(Icons.image, color: Colors.red), + ), + IconButton( + onPressed: () { + _captureImage(); + }, + icon: + const Icon(Icons.camera_alt, color: Colors.red), + ), + ], + ), + ], + ), + ), + Expanded( + child: Column( + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.45, + height: MediaQuery.of(context).size.height * 0.6, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.black, + width: 0.1, + ), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 1, + blurRadius: 5, + offset: Offset(0, 1), + ), + ], + ), + child: Signature( + controller: _signatureController!, + backgroundColor: Colors.white, + ), + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8.0), + color: Colors.grey[300], + child: const Text( + 'Signature', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: () { + _saveSignature(); + }, + icon: const Icon(Icons.check, color: Colors.red), + ), + IconButton( + onPressed: () { + _signatureController?.undo(); + }, + icon: const Icon(Icons.undo, color: Colors.red), + ), + IconButton( + onPressed: () { + _signatureController?.redo(); + }, + icon: const Icon(Icons.redo, color: Colors.red), + ), + IconButton( + onPressed: () { + _signatureController?.clear(); + }, + icon: const Icon(Icons.clear_rounded, + color: Colors.red), + ), + ], + ), + ], + ), + ), + ], + ), + Center( + child: Container( + margin: EdgeInsets.only(top: 30.0), + width: MediaQuery.of(context).size.width * 0.75, + height: 50, + child: ElevatedButton( + onPressed: () { + widget.function(); + }, + child: Text("SUBMIT"), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/add/structural_material.dart b/lib/screens/offline/passo/building/add/structural_material.dart index 981f5fa..e599d38 100644 --- a/lib/screens/offline/passo/building/add/structural_material.dart +++ b/lib/screens/offline/passo/building/add/structural_material.dart @@ -1,11 +1,8 @@ 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/offline/passo/building/add/add_building.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; @@ -20,6 +17,7 @@ class MaterialOption { class StructuralMaterialsOfflinePage extends StatefulWidget { final VoidCallback PrevBtn; final VoidCallback NextBtn; + final VoidCallback Skipto9; final List foundation; final List column; @@ -55,7 +53,8 @@ class StructuralMaterialsOfflinePage extends StatefulWidget { StructuralMaterialsOfflinePage( this.PrevBtn, - this.NextBtn, { + this.NextBtn, + this.Skipto9, { Key? key, required this.foundation, required this.column, @@ -127,6 +126,43 @@ class _StructuralMaterialsOfflinePage style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.left), ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Positioned( + top: 40, // Adjust as needed to place it below the Text widget + right: 10, // Aligns to the right + child: TextButton( + onPressed: () { + widget.Skipto9(); + }, + style: TextButton.styleFrom( + backgroundColor: Colors.red, // Button background color + primary: Colors.white, // Text color + padding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(8), // Rounded corners + ), + ), + child: const Row( + mainAxisSize: MainAxisSize + .min, // Ensures button size adjusts to content + children: [ + Text( + 'Skip to step 9', + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.bold), + ), + SizedBox(width: 8), // Space between text and icon + Icon(Icons.skip_next), + ], + ), + ), + ), + ], + ), Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'FOUNDATION', diff --git a/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart index 02515b0..6fce80a 100644 --- a/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart +++ b/lib/screens/offline/passo/building/edit/AddExtraItemsEdit.dart @@ -7,8 +7,6 @@ import 'package:searchfield/searchfield.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import 'package:unit2/model/passo/class_components%20_offline.dart'; -import '../../../../../model/passo/additional_items.dart'; -import '../../../../../model/passo/class_components.dart'; import '../../../../../model/passo/unit_construct.dart'; import '../../../../../theme-data.dart/form-style.dart'; diff --git a/lib/screens/offline/passo/building/edit/AddExtraItemsOffline.dart b/lib/screens/offline/passo/building/edit/AddExtraItemsOffline.dart index ab2e5e7..340ad11 100644 --- a/lib/screens/offline/passo/building/edit/AddExtraItemsOffline.dart +++ b/lib/screens/offline/passo/building/edit/AddExtraItemsOffline.dart @@ -10,12 +10,8 @@ import 'package:unit2/bloc/offline/offline_passo/admin/class_components_admin.da import 'package:unit2/bloc/offline/offline_passo/admin/unit_construction/unit_construction_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import 'package:unit2/model/offline/offline_profile.dart'; -import 'package:unit2/model/passo/additional_items.dart'; -import 'package:unit2/model/passo/class_components.dart'; import 'package:unit2/model/passo/unit_construct.dart'; 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 { final OfflineProfile offlineProfile; diff --git a/lib/screens/offline/passo/building/edit/additional_items_edit.dart b/lib/screens/offline/passo/building/edit/additional_items_edit.dart index 68aaace..5183511 100644 --- a/lib/screens/offline/passo/building/edit/additional_items_edit.dart +++ b/lib/screens/offline/passo/building/edit/additional_items_edit.dart @@ -8,7 +8,6 @@ import 'package:unit2/screens/offline/passo/building/edit/AddExtraItemsEdit.dart import '../../../../../bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart'; import '../../../../../model/passo/additional_items.dart'; -import '../../../../../model/passo/class_components.dart'; import '../../../../../model/passo/unit_construct.dart'; import '../../../../../utils/alerts.dart'; import '../../../../../widgets/passo/custom_button.dart'; @@ -82,32 +81,40 @@ class _AdditionalItemEditPageOffline 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, + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, ), - Icon( - // <-- Icon - Icons.add, - size: 24.0, + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), + SizedBox( + width: + 10), // Adjust the width to control spacing between buttons + ], ), SingleChildScrollView( scrollDirection: Axis.horizontal, diff --git a/lib/screens/offline/passo/building/edit/building_and_structure.dart b/lib/screens/offline/passo/building/edit/building_and_structure.dart index 1a20ffc..0472355 100644 --- a/lib/screens/offline/passo/building/edit/building_and_structure.dart +++ b/lib/screens/offline/passo/building/edit/building_and_structure.dart @@ -92,7 +92,7 @@ class _BuildingAndStructureOfflinePage ], ), ), - ) + ), ])))) ]); } @@ -113,32 +113,40 @@ class _BuildingAndStructureOfflinePage fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.left), ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - ), - onPressed: () { - context - .read() - .add(ShowBuildingAndStructure()); - }, - child: const Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text('ADD ITEM'), // <-- Text - SizedBox( - width: 5, + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, ), - Icon( - // <-- Icon - Icons.add, - size: 24.0, + onPressed: () { + context + .read() + .add(ShowBuildingAndStructure()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('ADD ITEM'), // <-- Text + SizedBox( + width: 5, + ), + Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), + SizedBox( + width: + 10), // Adjust the width to control spacing between buttons + ], ), SingleChildScrollView( scrollDirection: Axis.horizontal, diff --git a/lib/screens/offline/passo/building/edit/edit_building.dart b/lib/screens/offline/passo/building/edit/edit_building.dart index 372f7fb..f9dd733 100644 --- a/lib/screens/offline/passo/building/edit/edit_building.dart +++ b/lib/screens/offline/passo/building/edit/edit_building.dart @@ -15,6 +15,7 @@ import 'package:unit2/screens/offline/passo/building/edit/landref_location_edit. import 'package:unit2/screens/offline/passo/building/edit/property_appraisal_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/property_assessment_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; +import 'package:unit2/screens/offline/passo/building/edit/signature_and_ids_edit.dart'; import 'package:unit2/screens/offline/passo/building/edit/structural_materials_edit.dart'; import 'package:unit2/utils/alerts.dart'; @@ -46,7 +47,7 @@ class _EditBuildingOffline extends State { // THE FOLLOWING TWO VARIABLES ARE REQUIRED TO CONTROL THE STEPPER. int activeStep = 0; // Initial step set to 5. - int upperBound = 8; // upperBound MUST BE total number of icons minus 1. + int upperBound = 9; // upperBound MUST BE total number of icons minus 1. void PrevBtn() { setState(() { @@ -171,7 +172,8 @@ class _EditBuildingOffline extends State { 6, 7, 8, - 9 + 9, + 10 ], activeStepColor: primary, numberStyle: @@ -255,7 +257,12 @@ class _EditBuildingOffline extends State { case 8: return PropertyAssessmentEditOfflinePage( widget.faas.id!, onSAveAll, widget.offlineProfile); - + case 9: + return EditSignatureAndIds( + widget.offlineProfile, + onSAveAll, + widget.faas.id!, + ); default: return Container(); // return PropertyOwnerInfoEdit( diff --git a/lib/screens/offline/passo/building/edit/flutter_painter_edit.dart b/lib/screens/offline/passo/building/edit/flutter_painter_edit.dart index d089a67..d3c9a28 100644 --- a/lib/screens/offline/passo/building/edit/flutter_painter_edit.dart +++ b/lib/screens/offline/passo/building/edit/flutter_painter_edit.dart @@ -2,9 +2,8 @@ import 'dart:async'; import 'dart:io'; import 'dart:ui'; -import 'package:http/http.dart'; // Removed 'as http' -import 'package:path/path.dart'; // For basename function -import 'dart:convert'; +// Removed 'as http' +// For basename function import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -20,8 +19,6 @@ import 'package:phosphor_flutter/phosphor_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/model/passo/floor_sketch.dart'; -import 'package:unit2/utils/urls.dart'; - import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; class FlutterDrawEdit extends StatefulWidget { diff --git a/lib/screens/offline/passo/building/edit/general_description_edit.dart b/lib/screens/offline/passo/building/edit/general_description_edit.dart index fc170e3..e372428 100644 --- a/lib/screens/offline/passo/building/edit/general_description_edit.dart +++ b/lib/screens/offline/passo/building/edit/general_description_edit.dart @@ -1,18 +1,11 @@ -import 'dart:convert'; - 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: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/edit/edit_building.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'; @@ -113,6 +106,7 @@ class _GeneralDescriptionEditOffline fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.left), ), + const SizedBox(height: 15), Container( margin: const EdgeInsets.only( left: 0, top: 10, right: 0, bottom: 0), diff --git a/lib/screens/offline/passo/building/edit/landref_location_edit.dart b/lib/screens/offline/passo/building/edit/landref_location_edit.dart index 1158c04..74fc01b 100644 --- a/lib/screens/offline/passo/building/edit/landref_location_edit.dart +++ b/lib/screens/offline/passo/building/edit/landref_location_edit.dart @@ -8,7 +8,6 @@ import 'package:unit2/bloc/offline/offline_passo/admin/municipalities_admin/muni import 'package:unit2/bloc/offline/offline_passo/building/landref/landref_location_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/location/location_bloc.dart'; import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; -import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; import 'package:unit2/theme-data.dart/form-style.dart'; import '../../../../../model/passo/barangay.dart'; @@ -53,438 +52,373 @@ class _BldgLocLandRefEditOffline extends 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(); - // } - }, + listener: (context, state) {}, 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 = {}; + MunicipalitiesAdminState>( + listener: (context, state) {}, + 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: 20), - child: const Text('BUILDING LOCATION', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.center), - ), - 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', - TextInputType.text), - ), - - // 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: 20), - child: const Text('LAND REFERENCE', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.center), - ), - customTextField("Land Owner", "", - 'l_owner', TextInputType.text), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "OCT/TCT/CLOA No.", - "", - 'oct_tct_cloa', - TextInputType.phone), - ), - 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', - TextInputType.phone)) - ]), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Lot No.", - "", - 'lot_no', - TextInputType.phone), - ), - 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', - TextInputType.phone)) - ]), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "TD / ARP No.", - "", - 'l_td_arp', - TextInputType.phone), - ), - 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', - TextInputType.phone)) - ]), - SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, + // 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(); + } + }, 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: [ - CustomButton( - icon: const Icon( - Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'BUILDING LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.center), ), - CustomButton( - icon: const Icon( - Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - var bldgLocData = BldgLoc( - id: widget.tempId, - bldgapprDetailsId: - widget.tempId, - assessedById: '1', - assessedByName: 'cyril', - street: offlineBldgEditKey - .currentState - ?.value['street'] ?? - bldgloc.street, - barangay: offlineBldgEditKey - .currentState - ?.value['brgy'] ?? - bldgloc.barangay, - municipality: offlineBldgEditKey - .currentState - ?.value[ - 'municipality'] - ?.cityDescription ?? - bldgloc.municipality, - province: offlineBldgEditKey - .currentState - ?.value['province'] ?? - bldgloc.province, - ); - var landRefData = LandRef( - id: widget.tempId, - bldgapprDetailsId: - widget.tempId, - assessedById: '1', - assessedByName: 'cyril', - owner: offlineBldgEditKey - .currentState - ?.value['l_owner'] ?? - landRef.owner, - cloaNo: offlineBldgEditKey + const SizedBox(height: 15), + 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(), + ), + ), + ]), + 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', + TextInputType.text), + ), + ]), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('LAND REFERENCE', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.center), + ), + customTextField("Land Owner", "", + 'l_owner', TextInputType.text), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "OCT/TCT/CLOA No.", + "", + 'oct_tct_cloa', + TextInputType.phone), + ), + 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', + TextInputType.phone)) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Lot No.", + "", + 'lot_no', + TextInputType.phone), + ), + 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', + TextInputType.phone)) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "TD / ARP No.", + "", + 'l_td_arp', + TextInputType.phone), + ), + 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', + TextInputType.phone)) + ]), + 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, + bldgapprDetailsId: + widget.tempId, + assessedById: '1', + assessedByName: 'cyril', + street: offlineBldgEditKey + .currentState + ?.value[ + 'street'] ?? + bldgloc.street, + barangay: offlineBldgEditKey + .currentState + ?.value['brgy'] ?? + bldgloc.barangay, + municipality: offlineBldgEditKey .currentState ?.value[ - 'oct_tct_cloa'] ?? - landRef.cloaNo, - lotNo: offlineBldgEditKey - .currentState - ?.value['lot_no'] ?? - landRef.lotNo, - tdn: offlineBldgEditKey - .currentState - ?.value['l_td_arp'] ?? - landRef.tdn, - area: offlineBldgEditKey - .currentState - ?.value['area'] ?? - landRef.area, - surveyNo: offlineBldgEditKey + 'municipality'] + ?.cityDescription ?? + bldgloc.municipality, + province: offlineBldgEditKey + .currentState + ?.value[ + 'province'] ?? + bldgloc.province, + ); + var landRefData = LandRef( + id: widget.tempId, + bldgapprDetailsId: + widget.tempId, + assessedById: '1', + assessedByName: 'cyril', + owner: offlineBldgEditKey + .currentState + ?.value[ + 'l_owner'] ?? + landRef.owner, + cloaNo: offlineBldgEditKey + .currentState + ?.value[ + 'oct_tct_cloa'] ?? + landRef.cloaNo, + lotNo: offlineBldgEditKey + .currentState + ?.value[ + 'lot_no'] ?? + landRef.lotNo, + tdn: offlineBldgEditKey + .currentState + ?.value[ + 'l_td_arp'] ?? + landRef.tdn, + area: offlineBldgEditKey .currentState - ?.value[ - 'survey_no'] ?? - landRef.surveyNo, - blkNo: offlineBldgEditKey - .currentState - ?.value['blk_no'] ?? - landRef.blkNo, - ); - context - .read() - .add(UpdateBldgLoc( - id: widget.tempId, - bldgLoc: bldgLocData)); - context - .read() - .add(UpdateBldgLandRef( - id: widget.tempId, - landRef: landRefData)); + ?.value['area'] ?? + landRef.area, + surveyNo: offlineBldgEditKey + .currentState + ?.value[ + 'survey_no'] ?? + landRef.surveyNo, + blkNo: offlineBldgEditKey + .currentState + ?.value[ + 'blk_no'] ?? + landRef.blkNo, + ); + context + .read() + .add(UpdateBldgLoc( + id: widget.tempId, + bldgLoc: + bldgLocData)); + context + .read< + LandrefLocationBloc>() + .add(UpdateBldgLandRef( + id: widget.tempId, + landRef: + landRefData)); - widget.NextBtn(); - } - ; - }, + widget.NextBtn(); + } + ; + }, + ) + ], ) ], - ) - ], + ), + ), ), - ), - ), - ); + ); + } + + return Container(); + }); } - // 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_appraisal_edit.dart b/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart index 4a6cacf..3f31691 100644 --- a/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart +++ b/lib/screens/offline/passo/building/edit/property_appraisal_edit.dart @@ -1,22 +1,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/assessment_level/assessment_level_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/building_and_structure/building_and_structure_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/general_description/general_description_bloc.dart'; -import 'package:unit2/model/passo/property_appraisal.dart'; -import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; -import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart'; +import 'package:unit2/bloc/sos/sos_bloc.dart'; import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/assessment_level.dart'; import '../../../../../model/passo/building_and_structure.dart'; -import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../widgets/passo/custom_button.dart'; class PropertyAppraisalEditPageOffline extends StatefulWidget { @@ -98,422 +93,73 @@ class _PropertyAppraisalEditPage return sum; } - String assessmentLevel(marketValues, property_class) { - final marketValue = double.parse(marketValues); - switch (property_class) { - case 'Residential': - if (marketValue < 175000) { - // setState(() { - // assessment_level = 0; - // }); - return '0 '; - } else if (marketValue < 300000 && marketValue > 175000) { - // setState(() { - // assessment_level = 0.10; - // }); - return '10 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.20; - // }); - return '20 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.25; - // }); - return '25 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } - break; - case 'Agricultural': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; - case 'Commercial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - } - break; - case 'Industrial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - return '80 '; - } - break; - case 'Mineral': - break; - case 'Timberland': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue < 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; + String mapClassificationToPropertyClass(int classificationId) { + switch (classificationId) { + case 1: + return "Residential"; + case 2: + return "Agricultural"; + case 3: + return "Commercial"; + case 4: + return "Industrial"; + case 5: + return "Mineral"; + case 6: + return "Timberland"; default: + return "Unknown"; // Handle unexpected cases } - 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: + double calculateAssessmentValue( + double marketValue, String? propertyClass, List levels) { + // Filter assessment levels based on the property class + final relevantLevels = levels + .where((level) => + mapClassificationToPropertyClass(level.classificationId ?? 0) == + propertyClass) + .toList(); + + // Find the matching range + for (final level in relevantLevels) { + final over = double.tryParse(level.over ?? "0") ?? 0.0; + final notOver = double.tryParse(level.notOver ?? "0") ?? double.infinity; + final assessmentPercentage = + double.tryParse(level.assessmentLevels ?? "0") ?? 0.0; + + if (marketValue > over && marketValue <= notOver) { + return marketValue * (assessmentPercentage / 100); + } } - return 0; + + // Return 0 if no match is found + return 0.0; + } + + double calculateAssessmentLevel( + double marketValue, String? propertyClass, List levels) { + // Filter assessment levels based on the property class + final relevantLevels = levels + .where((level) => + mapClassificationToPropertyClass(level.classificationId ?? 0) == + propertyClass) + .toList(); + + // Find the matching range and assessment level + for (final level in relevantLevels) { + final over = double.tryParse(level.over ?? "0") ?? 0.0; + final notOver = double.tryParse(level.notOver ?? "0") ?? double.infinity; + final assessmentPercentage = + double.tryParse(level.assessmentLevels ?? "0") ?? 0.0; + + if (marketValue > over && marketValue <= notOver) { + return assessmentPercentage; // Return assessment level (percentage) + } + } + + // Return 0.0 if no match is found + return 0.0; } _calculateMarketValue( @@ -572,376 +218,408 @@ class _PropertyAppraisalEditPage // TODO: implement listener }, builder: (context, state) { if (state is BuildingAndStructureLoaded) { - return SingleChildScrollView( - padding: EdgeInsets.all(20), - 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: 20), - textAlign: TextAlign.left), - ), - Row( - mainAxisSize: MainAxisSize.min, + final bldgAndStructure = state.bldgAndStructure; + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is AssessmentLevelLoaded) { + return SingleChildScrollView( + padding: EdgeInsets.all(20), + child: Column( children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text( - 'BUILDING & STRUCTURE', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context) - .size - .width / - 3, - columns: [ - const DataColumn( - label: Text('Building Core'), - ), - const DataColumn( - label: Text(''), - ), - const DataColumn( - label: Text('Market Value'), - ), - ], - rows: [ - ...state.bldgAndStructure - .map((dataRow) { - return DataRow(cells: [ - DataCell(Text( - dataRow.actualUse!)), - DataCell(Text("")), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format(double.parse( - dataRow - .adjustedMarketValue - .toString()!)), - )) - ]); - }), - DataRow(cells: [ - DataCell(Text('Total', + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + textAlign: TextAlign.left), + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'BUILDING & STRUCTURE', style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 15, - color: Colors.red))), - DataCell(Text('')), - DataCell( - Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format( - _totalMarketValueBLDG( - state - .bldgAndStructure)), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 15, - color: Colors.red)), - ) - ]), - ], - ) - ], - )), - ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text( - 'ADDITIONAL ITEMS', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context) - .size - .width / - 3, - columns: [ - const DataColumn( - label: - Text('Additional Item'), - ), - const DataColumn( - label: Text(''), - ), - const DataColumn( - label: Text('Market Value'), - ), - ], - rows: [ - ...addItem.map((dataRow) { - return DataRow(cells: [ - DataCell(Text( - dataRow.className!)), + fontSize: 15), + textAlign: + TextAlign.left), + ), + DataTable( + columnSpacing: + MediaQuery.of(context) + .size + .width / + 3, + columns: [ + const DataColumn( + label: + Text('Building Core'), + ), + const DataColumn( + label: Text(''), + ), + const DataColumn( + label: + Text('Market Value'), + ), + ], + rows: [ + ...bldgAndStructure + .map((dataRow) { + return DataRow(cells: [ + DataCell(Text(dataRow + .actualUse!)), + DataCell(Text("")), + DataCell(Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(double.parse( + dataRow + .adjustedMarketValue + .toString()!)), + )) + ]); + }), + DataRow(cells: [ + DataCell(Text('Total', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 15, + color: + Colors.red))), DataCell(Text('')), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱") - .format(double - .parse(dataRow - .marketValue - .toString()!)) - .toString(), - )) - ]); - }).toList(), - DataRow( - // color: MaterialStateColor.resolveWith( - // (states) { - // // Use a color for the DataRow, for example, Colors.blue - // return Colors.redAccent; - // }), - cells: [ - DataCell(Text('Total', + DataCell( + Text( + NumberFormat + .currency( + locale: 'en-PH', + symbol: "₱", + ).format( + _totalMarketValueBLDG( + bldgAndStructure)), style: TextStyle( fontWeight: FontWeight .bold, fontSize: 15, color: Colors - .red))), - DataCell(Text('')), - DataCell( - Text( - NumberFormat - .currency( - locale: 'en-PH', - symbol: "₱", - ).format( - _totalMarketValue( - addItem)), - style: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 15, - color: Colors - .red)), - ) - ]), - ]), - ], - )), + .red)), + ) + ]), + ], + ) + ], + )), + ), + ], ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text( - 'PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 15), - textAlign: TextAlign.left), - ), - DataTable( - columnSpacing: - MediaQuery.of(context) - .size - .width / - 6, - columns: const [ - DataColumn( - label: Text('Actual Use'), - ), - DataColumn( - label: Text('Market Value'), - ), - DataColumn( - label: Text('Ass. Level'), - ), - DataColumn( - label: Text('Ass. Value'), - ), - ], - rows: [ - DataRow( - cells: [ - DataCell(Text( - genDesc.actualUse ?? - "")), - DataCell(Text(NumberFormat - .currency( - locale: - 'en-PH', - symbol: "₱") - .format(_calculateMarketValue( - addItem, - state - .bldgAndStructure)))), - DataCell( - Text( - assessmentLevel( - _calculateMarketValue( - addItem, - state - .bldgAndStructure) - .toString(), - genDesc - .actualUse) - .toString(), - style: - const TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'ADDITIONAL ITEMS', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 15), + textAlign: + TextAlign.left), + ), + DataTable( + columnSpacing: + MediaQuery.of(context) + .size + .width / + 3, + columns: [ + const DataColumn( + label: Text( + 'Additional Item'), + ), + const DataColumn( + label: Text(''), + ), + const DataColumn( + label: Text( + 'Market Value'), ), - DataCell(Text( - NumberFormat.currency( - locale: 'en-PH', - symbol: "₱") - .format(double.parse(assessmentValue( - _calculateMarketValue( - addItem, - state - .bldgAndStructure) - .toString(), - genDesc - .actualUse) - .toString())) - .toString(), - )), ], - ), - ]) - ], - )), + rows: [ + ...addItem.map((dataRow) { + return DataRow(cells: [ + DataCell(Text(dataRow + .className!)), + DataCell(Text('')), + DataCell(Text( + NumberFormat.currency( + locale: + 'en-PH', + symbol: "₱") + .format(double + .parse(dataRow + .marketValue + .toString()!)) + .toString(), + )) + ]); + }).toList(), + DataRow( + // color: MaterialStateColor.resolveWith( + // (states) { + // // Use a color for the DataRow, for example, Colors.blue + // return Colors.redAccent; + // }), + cells: [ + DataCell(Text( + 'Total', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: + 15, + color: Colors + .red))), + DataCell(Text('')), + DataCell( + Text( + NumberFormat + .currency( + locale: + 'en-PH', + symbol: "₱", + ).format( + _totalMarketValue( + addItem)), + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: + 15, + color: Colors + .red)), + ) + ]), + ]), + ], + )), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 15), + textAlign: + TextAlign.left), + ), + DataTable( + columnSpacing: + MediaQuery.of(context) + .size + .width / + 6, + columns: const [ + DataColumn( + label: + Text('Actual Use'), + ), + DataColumn( + label: Text( + 'Market Value'), + ), + DataColumn( + label: + Text('Ass. Level'), + ), + DataColumn( + label: + Text('Ass. Value'), + ), + ], + rows: [ + DataRow( + cells: [ + DataCell(Text(genDesc + .actualUse ?? + "")), + DataCell(Text(NumberFormat + .currency( + locale: + 'en-PH', + symbol: + "₱") + .format(_calculateMarketValue( + addItem, + bldgAndStructure)))), + DataCell( + Text( + calculateAssessmentLevel( + _calculateMarketValue( + addItem, + bldgAndStructure), + genDesc + .actualUse, + state + .assLevel) + .toString(), + style: + const TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + DataCell(Text( + NumberFormat.currency( + locale: + 'en-PH', + symbol: "₱") + .format(double.parse(calculateAssessmentValue( + _calculateMarketValue( + addItem, + bldgAndStructure), + genDesc + .actualUse, + state + .assLevel) + .toString())) + .toString(), + )), + ], + ), + ]) + ], + )), + ), + ], + ), + const SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon( + Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + // final tempID = + // await SharedPreferences.getInstance(); + // print(tempID.getInt('tempid')); + // context.read().add(AddBldgAppraisal( + // id: 1, + // bldgapprDetailsId: tempID.getInt('tempid')!, + // assessedById: '1', + // assessedByName: 'ad', + // dateCreated: '00', + // dateModified: '00', + // unitconstructCost: offlineBldgKey + // .currentState + // ?.value['bldg_type'] + // .unitValue, + // buildingCore: 'test', + // unitconstructSubtotal: + // (double.parse(offlineBldgKey.currentState!.value['total_area']) * + // double.parse(offlineBldgKey + // .currentState! + // .value['bldg_type'] + // .unitValue)) + // .toString(), + // depreciationRate: depRate.toString(), + // depreciationCost: calculateDepCost( + // (double.parse(offlineBldgKey.currentState!.value['total_area']) * + // double.parse(offlineBldgKey.currentState?.value['bldg_type'].unitValue)), + // addItem, + // depRate) + // .toString(), + // costAddItems: calculateAdditionalItems(addItem).toString(), + // addItemsSubtotal: calculateAdditionalItems(addItem).toString(), + // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), + // marketValue: calculateMarketValue((double.parse(offlineBldgKey.currentState!.value['total_area']) * double.parse(offlineBldgKey.currentState!.value['bldg_type'].unitValue)), addItem, depRate).toString(), + // totalArea: offlineBldgKey.currentState!.value['total_area'], + // actualUse: "Residential")); + widget.NextBtn(); + } + ; + }, + ) + ], ), ], ), - const SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon( - Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - { - // final tempID = - // await SharedPreferences.getInstance(); - // print(tempID.getInt('tempid')); - // context.read().add(AddBldgAppraisal( - // id: 1, - // bldgapprDetailsId: tempID.getInt('tempid')!, - // assessedById: '1', - // assessedByName: 'ad', - // dateCreated: '00', - // dateModified: '00', - // unitconstructCost: offlineBldgKey - // .currentState - // ?.value['bldg_type'] - // .unitValue, - // buildingCore: 'test', - // unitconstructSubtotal: - // (double.parse(offlineBldgKey.currentState!.value['total_area']) * - // double.parse(offlineBldgKey - // .currentState! - // .value['bldg_type'] - // .unitValue)) - // .toString(), - // depreciationRate: depRate.toString(), - // depreciationCost: calculateDepCost( - // (double.parse(offlineBldgKey.currentState!.value['total_area']) * - // double.parse(offlineBldgKey.currentState?.value['bldg_type'].unitValue)), - // addItem, - // depRate) - // .toString(), - // costAddItems: calculateAdditionalItems(addItem).toString(), - // addItemsSubtotal: calculateAdditionalItems(addItem).toString(), - // totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), - // marketValue: calculateMarketValue((double.parse(offlineBldgKey.currentState!.value['total_area']) * double.parse(offlineBldgKey.currentState!.value['bldg_type'].unitValue)), addItem, depRate).toString(), - // totalArea: offlineBldgKey.currentState!.value['total_area'], - // actualUse: "Residential")); - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ], - ), - ); + ); + } + return Container(); + }); } return Container(); }); diff --git a/lib/screens/offline/passo/building/edit/property_assessment_edit.dart b/lib/screens/offline/passo/building/edit/property_assessment_edit.dart index 73b0ed2..2088e0f 100644 --- a/lib/screens/offline/passo/building/edit/property_assessment_edit.dart +++ b/lib/screens/offline/passo/building/edit/property_assessment_edit.dart @@ -4,20 +4,19 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; -import 'package:intl/intl.dart'; import 'package:searchfield/searchfield.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/memoranda/memoranda_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/admin/signatories/signatories_admin_bloc.dart'; import 'package:unit2/bloc/offline/offline_passo/building/assessment_offline/bldg_assessment_offline_bloc.dart'; +import 'package:unit2/model/passo/sworn_statement.dart'; import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import '../../../../../bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart'; import '../../../../../model/offline/offline_profile.dart'; import '../../../../../model/passo/memoranda.dart'; import '../../../../../model/passo/property_assessment.dart'; -import '../../../../../model/passo/property_assessment_edit.dart'; import '../../../../../model/passo/signatories.dart'; -import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; class PropertyAssessmentEditOfflinePage extends StatefulWidget { @@ -36,6 +35,8 @@ class _PropertyAssessmentEditOfflinePage double assessment_level = 0; bool isTaxable = false; bool isExempt = false; + bool isOwner = false; + bool isRepresentative = false; String _memoranda = ''; String _notes = ""; String appraised_by = ""; @@ -50,1482 +51,1390 @@ class _PropertyAssessmentEditOfflinePage final recByFocus = FocusNode(); final apprvdByFocus = FocusNode(); final quarter = ['1st', '2nd', '3rd', '4th']; + final civilStatus = ["Single", "Married", "Divorced", "Separated", "Widowed"]; TextEditingController memorandaController = TextEditingController(); TextEditingController noteController = TextEditingController(); - String assessmentLevel(marketValues, property_class) { - final marketValue = double.parse(marketValues); - switch (property_class) { - case 'Residential': - if (marketValue < 175000) { - // setState(() { - // assessment_level = 0; - // }); - return '0 '; - } else if (marketValue < 300000 && marketValue > 175000) { - // setState(() { - // assessment_level = 0.10; - // }); - return '10 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.20; - // }); - return '20 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.25; - // }); - return '25 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } - break; - case 'Agricultural': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; - case 'Commercial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - } - break; - case 'Industrial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - return '80 '; - } - break; - case 'Mineral': - break; - case 'Timberland': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue < 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; - default: - } - return ''; - } - - double assessmentValue(marketValues, property_class) { - final marketValue = double.parse(marketValues); - switch (property_class) { - case 'Residential': - if (marketValue < 175000) { - // setState(() { - // assessment_level = 0; - // }); - return marketValue * 0; - } else if (marketValue < 300000 && marketValue > 175000) { - // setState(() { - // assessment_level = 0.10; - // }); - return marketValue * 0.10; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.20; - // }); - return marketValue * 0.20; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.25; - // }); - return marketValue * 0.25; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } - break; - case 'Agricultural': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return marketValue * 0.45; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 750000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.55; - // }); - return marketValue * 0.55; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return marketValue * 0.65; - } else if (marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } - break; - case 'Commercial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return marketValue * 0.75; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - } - break; - case 'Industrial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return marketValue * 0.75; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - return marketValue * 0.80; - } - break; - case 'Mineral': - break; - case 'Timberland': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return marketValue * 0.45; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.55; - // }); - return marketValue * 0.55; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return marketValue * 0.65; - } else if (marketValue < 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } - break; - default: - } - return 0; - } - @override Widget build(BuildContext context) { var width = MediaQuery.of(context).size.width; return ProgressHUD( - padding: const EdgeInsets.all(24), - backgroundColor: Colors.black87, - indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: - BlocConsumer( - listener: (context, state) { - // if (state is PropertyAssessmentEditLoading) { - // final progress = ProgressHUD.of(context); - // progress!.showWithText("Please wait..."); - // } - if (state is SpecificBldgAssessmentLoaded) { - setState(() { - isTaxable = state.assessment.taxable == '1' ? true : false; - isExempt = state.assessment.exempt == '1' ? true : false; - memorandaController.text = state.assessment.memoranda; - _memoranda = state.assessment.memoranda; - noteController.text = state.assessment.note; - _notes = state.assessment.note; - appraised_by_designation = - state.assessment.appraisedbyDesignation!; - rec_by_designation = state.assessment.recommendapprDesignation!; - approved_by_designation = state.assessment.approvedbyDesignation!; - }); - } - // if (state is PropertyAssessmentEditErrorState) { - // final progress = ProgressHUD.of(context); - // progress?.dismiss(); - // } - }, - builder: (context, state) { - if (state is SpecificBldgAssessmentLoaded) { - final assessment = state.assessment; - return BlocConsumer( + 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 SpecificSwornStatementLoaded) { + final sworn = state.swornStatement; + return BlocConsumer( listener: (context, state) { - // if (state is SignatoriesLoading) { + // if (state is PropertyAssessmentEditLoading) { // final progress = ProgressHUD.of(context); // progress!.showWithText("Please wait..."); // } - - // if (state is SignatoriesErrorState) { + if (state is SpecificBldgAssessmentLoaded) { + setState(() { + isTaxable = state.assessment.taxable == '1' ? true : false; + isExempt = state.assessment.exempt == '1' ? true : false; + memorandaController.text = state.assessment.memoranda; + _memoranda = state.assessment.memoranda; + noteController.text = state.assessment.note; + _notes = state.assessment.note; + appraised_by_designation = + state.assessment.appraisedbyDesignation!; + rec_by_designation = + state.assessment.recommendapprDesignation!; + approved_by_designation = + state.assessment.approvedbyDesignation!; + }); + } + // if (state is PropertyAssessmentEditErrorState) { // final progress = ProgressHUD.of(context); // progress?.dismiss(); // } }, builder: (context, state) { - if (state is SignatoriesLoaded) { - final signatories = state.signatories; - - return BlocConsumer( + if (state is SpecificBldgAssessmentLoaded) { + final assessment = state.assessment; + return BlocConsumer( listener: (context, state) { - // if (state is MemorandaLoading) { + // if (state is SignatoriesLoading) { // final progress = ProgressHUD.of(context); // progress!.showWithText("Please wait..."); // } - // if (state is MemorandaLoaded) { - // final progress = ProgressHUD.of(context); - // progress?.dismiss(); - // } - // if (state is MemorandaErrorState) { + + // if (state is SignatoriesErrorState) { // final progress = ProgressHUD.of(context); // progress?.dismiss(); // } }, builder: (context, state) { - if (state is MemorandaLoaded) { - final memoranda = state.memo; - final note = state.memo; - return Padding( - padding: const EdgeInsets.all(20.0), - child: FormBuilder( - key: offlineBldgEditKey, - initialValue: { - 'qtr': assessment.qtr?.toString() ?? '', - 'yr': assessment.yr?.toString() ?? '', - 'app_date': - assessment.appraisedbyDate?.toString() ?? '', - 'rec_date': - assessment.recommendapprDate?.toString() ?? - '', - 'sworn_statement': - assessment.swornstatementNo ?? '', - 'date_received': - assessment.dateReceived?.toString() ?? '', - 'date_of_entry': - assessment.entryDateAssessment?.toString() ?? - '', - 'approve_date': - assessment.approvedbyDate?.toString() ?? '', - }, - enabled: true, - onChanged: () { - offlineBldgEditKey.currentState!.save(); - debugPrint(offlineBldgEditKey.currentState!.value - .toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: Column( - children: [ - Container( - margin: - const EdgeInsets.fromLTRB(0, 20, 0, 20), - child: const Text( - 'PROPERTY ASSESSMENT cont..', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - ), - textAlign: TextAlign.left, - ), - ), - Expanded( - child: Container( - margin: const EdgeInsets.symmetric( - horizontal: 20), - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Row( - children: [ - const Text('Taxable'), - Checkbox( - checkColor: Colors.white, - value: isTaxable, - onChanged: (bool? value) { - setState(() { - isTaxable = value!; - }); - }, - ) - ], - ), - Row( - children: [ - const Text('Exempt'), - Checkbox( - checkColor: Colors.white, - value: isExempt, - onChanged: (bool? value) { - setState(() { - isExempt = value!; - }); - }, - ) - ], - ), - ], + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + + return BlocConsumer( + listener: (context, state) { + // if (state is MemorandaLoading) { + // final progress = ProgressHUD.of(context); + // progress!.showWithText("Please wait..."); + // } + // if (state is MemorandaLoaded) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + // if (state is MemorandaErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + final memoranda = state.memo; + final note = state.memo; + return Padding( + padding: const EdgeInsets.all(20.0), + child: FormBuilder( + key: offlineBldgEditKey, + initialValue: { + 'qtr': assessment.qtr?.toString() ?? '', + 'yr': assessment.yr?.toString() ?? '', + 'app_date': assessment.appraisedbyDate + ?.toString() ?? + '', + 'rec_date': assessment.recommendapprDate + ?.toString() ?? + '', + 'sworn_statement': + assessment.swornstatementNo ?? '', + 'date_received': + assessment.dateReceived?.toString() ?? + '', + 'date_of_entry': assessment + .entryDateAssessment + ?.toString() ?? + '', + 'approve_date': + assessment.approvedbyDate.toString() ?? + '', + 'r_fname': sworn.fname ?? '', + 'r_mname': sworn.mname ?? '', + 'r_lname': sworn.lname ?? '', + 'r_civilStatus': + sworn.civilStatus?.toString() ?? '', + 'r_citizenship': sworn.citizenship ?? '' + }, + enabled: true, + onChanged: () { + offlineBldgEditKey.currentState!.save(); + debugPrint(offlineBldgEditKey + .currentState!.value + .toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Column( + children: [ + Container( + margin: const EdgeInsets.fromLTRB( + 0, 20, 0, 20), + child: const Text( + 'PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, ), - Column( - children: [ - const SizedBox( - height: 20, - ), - const Text( - 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT / SWORN STATEMENT:', - style: TextStyle( - fontWeight: - FontWeight.bold), - ), - const SizedBox( - height: 20, - ), - SingleChildScrollView( - scrollDirection: - Axis.horizontal, - child: Row( + textAlign: TextAlign.left, + ), + ), + Expanded( + child: Container( + margin: const EdgeInsets.symmetric( + horizontal: 20), + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + Row( mainAxisAlignment: MainAxisAlignment .spaceAround, children: [ - SizedBox( - width: 90, - height: 50, - child: - customDropDownField( - 'Qtr', - '', - 'qtr', - quarter)), - SizedBox( - width: 10, + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: + Colors.white, + value: isTaxable, + onChanged: + (bool? value) { + setState(() { + isTaxable = + value!; + }); + }, + ) + ], ), - SizedBox( - width: 100, - height: 50, - child: customTextField( - 'Sworn Statement No.', - '', - 'sworn_statement', - TextInputType - .number)), - SizedBox( - width: 10, + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: + Colors.white, + value: isExempt, + onChanged: + (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], ), - SizedBox( - width: 90, - height: 50, - child: customTextField( - 'Year', - '', - 'yr', - TextInputType - .number)), ], ), - ), - ], - ), - const SizedBox( - height: 10, - ), - Divider( - thickness: 2, - ), - Row( - children: [ - const SizedBox( - width: 10, - ), - Expanded( - child: SizedBox( - width: width / 2 - 100, - height: 50, - child: customDatTimePicker( - 'Date Received', - '', - 'date_received')), - ), - const SizedBox( - width: 20, - ), - Expanded( - child: SizedBox( - width: width / 2 - 100, - height: 50, - child: customDatTimePicker( - 'Date of Entry', - '', - 'date_of_entry')), - ) - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPRAISED/ASSESSED BY:', - style: TextStyle( - fontWeight: FontWeight.bold), - textAlign: TextAlign.start, - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row(children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - const Text('Name'), - Container( - padding: - EdgeInsets.fromLTRB( - 20, 0, 0, 0), - margin: const EdgeInsets - .fromLTRB(0, 10, 0, 0), - width: 250, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here + Column( + children: [ + const SizedBox( + height: 20, ), - child: SearchField( - itemHeight: 65, - hint: assessment - .appraisedbyName, - suggestions: signatories - .map((Signatories - signatories) => - SearchFieldListItem( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', - item: - signatories, - child: - ListTile( - title: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', - overflow: - TextOverflow - .ellipsis, - textAlign: - TextAlign - .center, - ), - ))) - .toList(), - - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - searchStyle: TextStyle(), - - ////agency suggestion tap - focusNode: - appraisedByFocus, - suggestionState: - Suggestion.expand, - onSuggestionTap: - (appraised) { - setState(() { - appraised_by = - "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; - appraised_by_designation = - appraised.item! - .designation; - }); - appraisedByFocus - .unfocus(); - }, + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT / SWORN STATEMENT:', + style: TextStyle( + fontWeight: + FontWeight.bold), ), - ), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Designation'), - Container( - padding: - EdgeInsets.fromLTRB( - 10, 15, 10, 10), - margin: const EdgeInsets - .fromLTRB( - 0, 10, 0, 0), - width: 250, - height: 50, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here - ), - child: Text( - appraised_by_designation - .toUpperCase(), - style: TextStyle( - fontSize: 15), - textAlign: - TextAlign.center, - )), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Date'), - Container( - width: 100, - child: - customDatTimePicker( - '', - '', - 'app_date')), - ], - ), - ]), - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'RECOMMENDING APPROVAL:', - style: TextStyle( - fontWeight: - FontWeight.bold), - )), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row(children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - const Text('Name'), - Container( - padding: - EdgeInsets.fromLTRB( - 20, 0, 0, 0), - margin: const EdgeInsets - .fromLTRB(0, 10, 0, 0), - width: 250, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here + const SizedBox( + height: 20, ), - child: SearchField( - itemHeight: 65, - hint: assessment - .recommendapprName, - suggestions: signatories - .map((Signatories - signatories) => - SearchFieldListItem( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', - item: - signatories, - child: - ListTile( - title: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', - overflow: - TextOverflow - .ellipsis, - textAlign: - TextAlign - .center, - ), - ))) - .toList(), - - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - searchStyle: TextStyle(), - - ////agency suggestion tap - focusNode: recByFocus, - suggestionState: - Suggestion.expand, - onSuggestionTap: - (appraised) { - setState(() { - rec_by = - "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; - rec_by_designation = - appraised.item! - .designation; - }); - recByFocus.unfocus(); - }, - ), - ), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Designation'), - Container( - padding: - EdgeInsets.fromLTRB( - 10, 15, 10, 10), - margin: const EdgeInsets - .fromLTRB( - 0, 10, 0, 0), - width: 250, - height: 50, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here - ), - child: Text( - rec_by_designation - .toUpperCase(), - style: TextStyle( - fontSize: 15), - textAlign: - TextAlign.center, - )), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Date'), - Container( - width: 100, - child: - customDatTimePicker( - '', - '', - 'rec_date')), - ], - ), - ]), - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPROVED BY:', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row(children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - const Text('Name'), - Container( - padding: - EdgeInsets.fromLTRB( - 20, 0, 0, 0), - margin: const EdgeInsets - .fromLTRB(0, 10, 0, 0), - width: 250, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here - ), - child: SearchField( - itemHeight: 65, - hint: assessment - .approvedbyName, - suggestions: signatories - .map((Signatories - signatories) => - SearchFieldListItem( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', - item: - signatories, - child: - ListTile( - title: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', - overflow: - TextOverflow - .ellipsis, - textAlign: - TextAlign - .center, - ), - ))) - .toList(), - - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - searchStyle: TextStyle(), - - ////agency suggestion tap - focusNode: apprvdByFocus, - suggestionState: - Suggestion.expand, - onSuggestionTap: - (appraised) { - setState(() { - approved_by = - "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; - approved_by_designation = - appraised.item! - .designation; - }); - apprvdByFocus.unfocus(); - }, - ), - ), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Designation'), - Container( - padding: - EdgeInsets.fromLTRB( - 10, 15, 10, 10), - margin: const EdgeInsets - .fromLTRB( - 0, 10, 0, 0), - width: 250, - height: 50, - decoration: BoxDecoration( - border: Border.all( - color: Colors - .grey, // You can set the color here - width: - 0.9, // You can set the width here - ), - borderRadius: - BorderRadius.circular( - 5), // Set the border radius here - ), - child: Text( - approved_by_designation - .toUpperCase(), - style: TextStyle( - fontSize: 15), - textAlign: - TextAlign.center, - )), - ], - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text('Date'), - Container( - width: 100, - child: - customDatTimePicker( - '', - '', - 'approve_date')), - ], - ), - ]), - ), - 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: 50, - child: SearchField( - itemHeight: 200, - controller: memorandaController, - suggestions: memoranda - .map( - (Memoranda memoranda) => - SearchFieldListItem( - '${memoranda.memoranda}', - item: - memoranda, // Change: Use individual Memoranda object - child: ListTile( - title: Text( - '${memoranda.memoranda}', - overflow: - TextOverflow - .visible, - ), - ), - )) - .toList(), - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - // searchInputDecoration: - // normalTextFieldStyle("Memoranda", "") - // .copyWith( - // suffixIcon: - // const Icon(Icons.arrow_drop_down), - // contentPadding: EdgeInsets.symmetric( - // vertical: 15.0, horizontal: 16.0), - // border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(10.0), - // borderSide: BorderSide( - // color: - // Colors.grey, // Adjust border color - // ), - // ), - // focusedBorder: OutlineInputBorder( - // borderRadius: BorderRadius.circular(10.0), - // borderSide: BorderSide( - // color: Colors - // .blue, // Adjust focused border color - // ), - // ), - // ), - focusNode: focuss, - suggestionState: - Suggestion.expand, - suggestionDirection: - SuggestionDirection.up, - onSuggestionTap: (memoranda) { - setState(() { - _memoranda = - memorandaController - .text; - }); - focus.unfocus(); - }, - )), - Container( - alignment: Alignment.center, - padding: EdgeInsets.all(10), - child: Column( - children: [ - TextField( - controller: - memorandaController, - keyboardType: - TextInputType.multiline, - maxLines: 7, - decoration: InputDecoration( - focusedBorder: - OutlineInputBorder( - borderSide: BorderSide( - width: 1, - color: Colors - .redAccent)), - disabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - width: 1, - color: Colors.grey, - ), - borderRadius: - BorderRadius.circular( - 5), - ), - enabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - color: Colors.grey, - width: 1, - ), - borderRadius: - BorderRadius.circular( - 5), - ), - ), - ), - ], - ), - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'NOTE: ', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - const SizedBox( - height: 30, - ), - SizedBox( - width: 400, - height: 50, - child: SearchField( - itemHeight: 200, - controller: noteController, - suggestions: note - .map((Memoranda note) => - SearchFieldListItem( - '${note.memoranda}', - item: - note, // Change: Use individual Memoranda object - child: ListTile( - title: Text( - '${note.memoranda}', - overflow: - TextOverflow - .visible, - ), + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + SizedBox( + width: 90, + height: 50, + child: + customDropDownField( + 'Qtr', + '', + 'qtr', + quarter)), + SizedBox( + width: 10, ), - )) - .toList(), - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - searchInputDecoration: - InputDecoration().copyWith( - suffixIcon: const Icon( - Icons.arrow_drop_down), + SizedBox( + width: 100, + height: 50, + child: customTextField( + 'Sworn Statement No.', + '', + 'sworn_statement', + TextInputType + .number)), + SizedBox( + width: 10, + ), + SizedBox( + width: 90, + height: 50, + child: customTextField( + 'Year', + '', + 'yr', + TextInputType + .number)), + ], + ), + ), + ], ), - focusNode: focus, - suggestionState: - Suggestion.expand, - suggestionDirection: - SuggestionDirection.up, - onSuggestionTap: (memoranda) { - setState(() { - _notes = - noteController.text; - }); - focus.unfocus(); - }, - )), - Container( - alignment: Alignment.center, - padding: EdgeInsets.all(10), - child: Column( - children: [ - TextField( - controller: noteController, - keyboardType: - TextInputType.multiline, - maxLines: 7, - decoration: InputDecoration( - focusedBorder: - OutlineInputBorder( - borderSide: BorderSide( - width: 1, + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Row( + children: [ + const Text('Owner'), + Checkbox( + checkColor: + Colors.white, + value: isOwner, + onChanged: + (bool? value) { + setState(() { + isOwner = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text( + 'Representative'), + Checkbox( + checkColor: + Colors.white, + value: + isRepresentative, + onChanged: + (bool? value) { + setState(() { + isRepresentative = + value!; + }); + }, + ) + ], + ), + ], + ), + const SizedBox( + height: 10, + ), + Row( + children: [ + Expanded( + child: customTextField( + 'First Name', + '', + 'r_fname', + TextInputType.text), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: customTextField( + 'Middle Name', + '', + 'r_mname', + TextInputType.text), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: customTextField( + 'Last Name', + '', + 'r_lname', + TextInputType.text), + ) + ], + ), + const SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ + Expanded( + flex: 1, + child: + customDropDownField( + "Civil Status", + "", + "r_civilStatus", + civilStatus), + ), + const SizedBox( + width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Citizenship", + "", + 'r_citizenship', + TextInputType.text), + ), + ]), + const SizedBox( + height: 10, + ), + Divider( + thickness: 2, + ), + Row( + children: [ + const SizedBox( + width: 10, + ), + Expanded( + child: SizedBox( + width: + width / 2 - 100, + height: 50, + child: customDatTimePicker( + 'Date Received', + '', + 'date_received')), + ), + const SizedBox( + width: 20, + ), + Expanded( + child: SizedBox( + width: + width / 2 - 100, + height: 50, + child: customDatTimePicker( + 'Date of Entry', + '', + 'date_of_entry')), + ) + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: + Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle( + fontWeight: + FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row(children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + const Text('Name'), + Container( + padding: EdgeInsets + .fromLTRB( + 20, 0, 0, 0), + margin: + const EdgeInsets + .fromLTRB( + 0, 10, 0, 0), + width: 250, + decoration: + BoxDecoration( + border: Border.all( + color: Colors + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: SearchField( + itemHeight: 65, + hint: assessment + .appraisedbyName, + suggestions: + signatories + .map((Signatories signatories) => SearchFieldListItem( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', + item: + signatories, + child: + ListTile( + title: + Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: + TextAlign.center, + ), + ))) + .toList(), + + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + searchStyle: + TextStyle(), + + ////agency suggestion tap + focusNode: + appraisedByFocus, + suggestionState: + Suggestion + .expand, + onSuggestionTap: + (appraised) { + setState(() { + appraised_by = + "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; + appraised_by_designation = + appraised + .item! + .designation; + }); + appraisedByFocus + .unfocus(); + }, + ), + ), + ], + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Designation'), + Container( + padding: + EdgeInsets.fromLTRB( + 10, + 15, + 10, + 10), + margin: + const EdgeInsets + .fromLTRB(0, + 10, 0, 0), + width: 250, + height: 50, + decoration: + BoxDecoration( + border: + Border.all( color: Colors - .redAccent)), - disabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - width: 1, - color: Colors.grey, - ), - borderRadius: - BorderRadius.circular( - 5), + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: Text( + appraised_by_designation + .toUpperCase(), + style: TextStyle( + fontSize: 15), + textAlign: + TextAlign + .center, + )), + ], ), - enabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - color: Colors.grey, - width: 1, - ), - borderRadius: - BorderRadius.circular( - 5), + const SizedBox( + width: 10, ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Date'), + Container( + width: 100, + child: + customDatTimePicker( + '', + '', + 'app_date')), + ], + ), + ]), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: + Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: TextStyle( + fontWeight: + FontWeight.bold), + )), + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row(children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + const Text('Name'), + Container( + padding: EdgeInsets + .fromLTRB( + 20, 0, 0, 0), + margin: + const EdgeInsets + .fromLTRB( + 0, 10, 0, 0), + width: 250, + decoration: + BoxDecoration( + border: Border.all( + color: Colors + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: SearchField( + itemHeight: 65, + hint: assessment + .recommendapprName, + suggestions: + signatories + .map((Signatories signatories) => SearchFieldListItem( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', + item: + signatories, + child: + ListTile( + title: + Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: + TextAlign.center, + ), + ))) + .toList(), + + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + searchStyle: + TextStyle(), + + ////agency suggestion tap + focusNode: + recByFocus, + suggestionState: + Suggestion + .expand, + onSuggestionTap: + (appraised) { + setState(() { + rec_by = + "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; + rec_by_designation = + appraised + .item! + .designation; + }); + recByFocus + .unfocus(); + }, + ), + ), + ], + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Designation'), + Container( + padding: + EdgeInsets.fromLTRB( + 10, + 15, + 10, + 10), + margin: + const EdgeInsets + .fromLTRB(0, + 10, 0, 0), + width: 250, + height: 50, + decoration: + BoxDecoration( + border: + Border.all( + color: Colors + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: Text( + rec_by_designation + .toUpperCase(), + style: TextStyle( + fontSize: 15), + textAlign: + TextAlign + .center, + )), + ], + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Date'), + Container( + width: 100, + child: + customDatTimePicker( + '', + '', + 'rec_date')), + ], + ), + ]), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: + Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: + FontWeight.bold, + ), + )), + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row(children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + const Text('Name'), + Container( + padding: EdgeInsets + .fromLTRB( + 20, 0, 0, 0), + margin: + const EdgeInsets + .fromLTRB( + 0, 10, 0, 0), + width: 250, + decoration: + BoxDecoration( + border: Border.all( + color: Colors + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: SearchField( + itemHeight: 65, + hint: assessment + .approvedbyName, + suggestions: + signatories + .map((Signatories signatories) => SearchFieldListItem( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}', + item: + signatories, + child: + ListTile( + title: + Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname!}', + overflow: + TextOverflow.ellipsis, + textAlign: + TextAlign.center, + ), + ))) + .toList(), + + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + searchStyle: + TextStyle(), + + ////agency suggestion tap + focusNode: + apprvdByFocus, + suggestionState: + Suggestion + .expand, + onSuggestionTap: + (appraised) { + setState(() { + approved_by = + "${appraised.item?.firstname} ${appraised.item?.middlename} ${appraised.item?.lastname}"; + approved_by_designation = + appraised + .item! + .designation; + }); + apprvdByFocus + .unfocus(); + }, + ), + ), + ], + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Designation'), + Container( + padding: + EdgeInsets.fromLTRB( + 10, + 15, + 10, + 10), + margin: + const EdgeInsets + .fromLTRB(0, + 10, 0, 0), + width: 250, + height: 50, + decoration: + BoxDecoration( + border: + Border.all( + color: Colors + .grey, // You can set the color here + width: + 0.9, // You can set the width here + ), + borderRadius: + BorderRadius + .circular( + 5), // Set the border radius here + ), + child: Text( + approved_by_designation + .toUpperCase(), + style: TextStyle( + fontSize: 15), + textAlign: + TextAlign + .center, + )), + ], + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text('Date'), + Container( + width: 100, + child: customDatTimePicker( + '', + '', + 'approve_date')), + ], + ), + ]), + ), + 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: 50, + child: SearchField( + itemHeight: 200, + controller: + memorandaController, + suggestions: memoranda + .map((Memoranda + memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow + .visible, + ), + ), + )) + .toList(), + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle("Memoranda", "") + // .copyWith( + // suffixIcon: + // const Icon(Icons.arrow_drop_down), + // contentPadding: EdgeInsets.symmetric( + // vertical: 15.0, horizontal: 16.0), + // border: OutlineInputBorder( + // borderRadius: BorderRadius.circular(10.0), + // borderSide: BorderSide( + // color: + // Colors.grey, // Adjust border color + // ), + // ), + // focusedBorder: OutlineInputBorder( + // borderRadius: BorderRadius.circular(10.0), + // borderSide: BorderSide( + // color: Colors + // .blue, // Adjust focused border color + // ), + // ), + // ), + focusNode: focuss, + suggestionState: + Suggestion.expand, + suggestionDirection: + SuggestionDirection + .up, + onSuggestionTap: + (memoranda) { + setState(() { + _memoranda = + memorandaController + .text; + }); + focus.unfocus(); + }, + )), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(10), + child: Column( + children: [ + TextField( + controller: + memorandaController, + keyboardType: + TextInputType + .multiline, + maxLines: 7, + decoration: + InputDecoration( + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + width: + 1, + color: + Colors.redAccent)), + disabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + width: 1, + color: + Colors.grey, + ), + borderRadius: + BorderRadius + .circular( + 5), + ), + enabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + color: + Colors.grey, + width: 1, + ), + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), + ], + ), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: + Alignment.centerLeft, + child: Text( + 'NOTE: ', + style: TextStyle( + fontWeight: + FontWeight.bold, + ), + )), + const SizedBox( + height: 30, + ), + SizedBox( + width: 400, + height: 50, + child: SearchField( + itemHeight: 200, + controller: + noteController, + suggestions: note + .map((Memoranda + note) => + SearchFieldListItem( + '${note.memoranda}', + item: + note, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${note.memoranda}', + overflow: + TextOverflow + .visible, + ), + ), + )) + .toList(), + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + searchInputDecoration: + InputDecoration() + .copyWith( + suffixIcon: const Icon( + Icons + .arrow_drop_down), + ), + focusNode: focus, + suggestionState: + Suggestion.expand, + suggestionDirection: + SuggestionDirection + .up, + onSuggestionTap: + (memoranda) { + setState(() { + _notes = + noteController + .text; + }); + focus.unfocus(); + }, + )), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(10), + child: Column( + children: [ + TextField( + controller: + noteController, + keyboardType: + TextInputType + .multiline, + maxLines: 7, + decoration: + InputDecoration( + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + width: + 1, + color: + Colors.redAccent)), + disabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + width: 1, + color: + Colors.grey, + ), + borderRadius: + BorderRadius + .circular( + 5), + ), + enabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + color: + Colors.grey, + width: 1, + ), + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), + ], + ), + ), + const SizedBox( + height: 30, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width, + child: ElevatedButton( + style: ElevatedButton + .styleFrom( + backgroundColor: + primary, + foregroundColor: + Colors.red), + child: const SizedBox( + width: 200, + height: 50, + child: Align( + alignment: + Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: + TextAlign.center, + ), + ), + ), + onPressed: () { + offlineBldgEditKey + .currentState! + .save(); + var ass = + PropertyAssessment( + id: 1, + bldgapprDetailsId: + widget.tempId, + assessedById: widget + .offlineProfile.id + .toString(), + assessedByName: widget + .offlineProfile + .firstName!, + dateCreated: "None", + dateModified: "None", + actualUse: assessment + .actualUse, + marketValue: '0.0', + assessmentLevel: '0.0', + assessedValue: "1.0", + taxable: + isTaxable == true + ? '1' + : '0', + exempt: isExempt == true + ? '1' + : '0', + qtr: offlineBldgEditKey + .currentState! + .value['qtr'], + yr: offlineBldgEditKey + .currentState! + .value['yr'], + appraisedbyName: + appraised_by == "" + ? assessment + .appraisedbyName + : appraised_by, + appraisedbyDate: + offlineBldgEditKey + .currentState! + .value[ + 'app_date'] + .toString(), + recommendapprName: + rec_by == "" + ? assessment + .recommendapprName + : rec_by, + recommendapprDate: + offlineBldgEditKey + .currentState! + .value[ + 'rec_date'] + .toString(), + approvedbyName: + approved_by == "" + ? assessment + .approvedbyName + : approved_by, + approvedbyDate: + offlineBldgEditKey + .currentState! + .value[ + 'approve_date'] + .toString(), + memoranda: _memoranda, + note: _notes, + swornstatementNo: + offlineBldgEditKey + .currentState! + .value[ + 'sworn_statement'], + dateReceived: + offlineBldgEditKey + .currentState! + .value[ + 'date_received'] + .toString(), + entryDateAssessment: + offlineBldgEditKey + .currentState! + .value[ + 'date_of_entry'] + .toString(), + entryDateBy: "none", + genCode: '5th', + appraisedbyDesignation: + appraised_by_designation == + "" + ? assessment + .appraisedbyDesignation + : appraised_by_designation, + approvedbyDesignation: + approved_by_designation == + "" + ? assessment + .approvedbyDesignation + : approved_by_designation, + recommendapprDesignation: + rec_by_designation == + "" + ? assessment + .recommendapprDesignation + : rec_by_designation, + ); + + context + .read< + BldgAssessmentOfflineBloc>() + .add( + UpdateBldgAssessment( + id: widget + .tempId, + assessment: + ass)); + + var sworn = + SwornStatement( + bldgapprDetailsId: + widget.tempId, + fname: isRepresentative + ? offlineBldgEditKey + .currentState! + .value[ + 'r_fname'] + : offlineBldgEditKey + .currentState! + .value['fname'], + mname: isRepresentative + ? offlineBldgEditKey + .currentState! + .value[ + 'r_mname'] + : offlineBldgEditKey + .currentState! + .value['mname'], + lname: isRepresentative + ? offlineBldgEditKey + .currentState! + .value[ + 'r_lname'] + : offlineBldgEditKey + .currentState! + .value['lname'], + citizenship: isRepresentative + ? offlineBldgEditKey + .currentState! + .value[ + 'r_citizenship'] + : offlineBldgEditKey + .currentState! + .value[ + 'citizenship'], + civilStatus: isRepresentative + ? offlineBldgEditKey + .currentState! + .value[ + 'r_civilStatus'] + : offlineBldgEditKey + .currentState! + .value[ + 'civil_status'], + genCode: '5TH', + ); + context + .read< + SwornStatementBloc>() + .add( + UpdateSwornStatement( + id: widget + .tempId, + sworn: sworn), + ); + + widget.onSAve(); + }, ), ), ], ), ), - const SizedBox( - height: 30, - ), - SizedBox( - width: MediaQuery.of(context) - .size - .width, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: primary, - foregroundColor: Colors.red), - child: const SizedBox( - width: 200, - height: 50, - child: Align( - alignment: Alignment.center, - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, - ), - ), - ), - onPressed: () { - offlineBldgEditKey.currentState! - .save(); - var ass = PropertyAssessment( - id: 1, - bldgapprDetailsId: - widget.tempId, - assessedById: widget - .offlineProfile.id - .toString(), - assessedByName: widget - .offlineProfile - .firstName!, - dateCreated: "None", - dateModified: "None", - actualUse: - assessment.actualUse, - marketValue: '0.0', - assessmentLevel: '0.0', - assessedValue: "1.0", - taxable: isTaxable == true - ? '1' - : '0', - exempt: isExempt == true - ? '1' - : '0', - qtr: offlineBldgEditKey - .currentState! - .value['qtr'], - yr: offlineBldgEditKey - .currentState! - .value['yr'], - appraisedbyName: appraised_by == "" - ? assessment - .appraisedbyName - : appraised_by, - appraisedbyDate: - offlineBldgEditKey.currentState!.value['app_date'].toString(), - recommendapprName: rec_by == "" ? assessment.recommendapprName : rec_by, - recommendapprDate: offlineBldgEditKey.currentState!.value['rec_date'].toString(), - approvedbyName: approved_by == "" ? assessment.approvedbyName : approved_by, - approvedbyDate: offlineBldgEditKey.currentState!.value['approve_date'].toString(), - memoranda: _memoranda, - note: _notes, - swornstatementNo: offlineBldgEditKey.currentState!.value['sworn_statement'], - dateReceived: offlineBldgEditKey.currentState!.value['date_received'].toString(), - entryDateAssessment: offlineBldgEditKey.currentState!.value['date_of_entry'].toString(), - entryDateBy: "none", - genCode: '5th', - appraisedbyDesignation: appraised_by_designation == "" ? assessment.appraisedbyDesignation : appraised_by_designation, - approvedbyDesignation: approved_by_designation == "" ? assessment.approvedbyDesignation : approved_by_designation, - recommendapprDesignation: rec_by_designation == "" ? assessment.recommendapprDesignation : rec_by_designation); - - context - .read< - BldgAssessmentOfflineBloc>() - .add(UpdateBldgAssessment( - id: widget.tempId, - assessment: ass)); - - widget.onSAve(); - }, - ), - ), - ], - ), - ), + ), + ) + ], ), - ) - ], - ), - ), + ), + ); + } + + return Container(); + }, ); } - // if (state is MemorandaErrorState) { - // return SomethingWentWrong( - // message: state.error, - // onpressed: () { - // context - // .read() - // .add(const LoadMemoranda()); - // }, - // ); - // } + return Container(); }, ); } - // if (state is SignatoriesErrorState) { - // return SomethingWentWrong( - // message: state.error, - // onpressed: () { - // context - // .read() - // .add(const LoadSignatories()); - // }, - // ); - // } + return Container(); }, ); } - // if (state is PropertyAssessmentEditErrorState) { - // return SomethingWentWrong( - // message: state.error, - // onpressed: () { - // context.read().add( - // LoadPropertyAssessmentEdit( - // assessmentsEdit: PropertyAssessmentEdit(), - // id: widget.tempId)); - // }, - // ); - // } return Container(); - }, - ), - ); + })); } } diff --git a/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart index 581331c..e524e6e 100644 --- a/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart +++ b/lib/screens/offline/passo/building/edit/property_owner_info_edit.dart @@ -42,7 +42,8 @@ class _PropertyOwnerInfoEditOffline Map myMap = {'zero': 0, 'one': 1, 'two': 2}; final transaction_codes = ['New', 'Revision']; - + final civilStatus = ["Single", "Married", "Divorced", "Separated", "Widowed"]; + bool isOptional = false; @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -67,6 +68,8 @@ class _PropertyOwnerInfoEditOffline 'benificiary_telno': widget.faas.adminTelno, 'benificiary_address': widget.faas.adminAddress, 'benificiary_tin': widget.faas.adminTin, + 'citizenship': widget.faas.citizenship, + "civil_status": widget.faas.civilStatus }, enabled: true, onChanged: () { @@ -81,10 +84,10 @@ class _PropertyOwnerInfoEditOffline Container( margin: const EdgeInsets.only( left: 0, top: 20, right: 0, bottom: 10), - child: Row( + child: const Row( children: [ Expanded( - child: const Text( + child: Text( 'PROPERTY OWNER INFO', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18), @@ -94,29 +97,6 @@ class _PropertyOwnerInfoEditOffline ], ), ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - ), - onPressed: () {}, - child: const Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text('SAVE'), // <-- Text - SizedBox( - width: 5, - ), - Icon( - // <-- Icon - Icons.save, - size: 24.0, - ), - ], - ), - ), - ), const SizedBox(height: 15), customDropDownField( widget.faas.transCode ?? "Transaction Code", @@ -162,57 +142,119 @@ class _PropertyOwnerInfoEditOffline "Last Name", "", 'lname', TextInputType.text), ) ]), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDropDownField( + widget.faas.civilStatus ?? + "Civil Status", // Use empty string if null + "", + "civil_status", + civilStatus), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Citizenship", "", + 'citizenship', TextInputType.text), + ), + ]), customDatTimePicker("Birthday", "", "bday"), customTextField( "Address", "", 'address', TextInputType.text), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Tel No.", "", 'tel_no', TextInputType.phone), - ), - 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', TextInputType.phone)) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Administrator / Benificial User", - "", - 'benificiary', - TextInputType.text), - ), - 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', TextInputType.phone)) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField("Address", "", - 'benificiary_address', TextInputType.text), - ), - 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', TextInputType.phone)) - ]), + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + children: [ + SizedBox( + width: 50, // Adjust the width as needed + height: 50, // Adjust the height as needed + child: Checkbox( + checkColor: Colors.white, + value: isOptional, + onChanged: (bool? value) { + setState(() { + isOptional = value!; + }); + }, + ), + ), + Text('Show optional information') + ], + ), + // Other widgets in the column + ], + ), + Visibility( + visible: isOptional, + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Tel No.", "", + 'tel_no', TextInputType.phone), + ), + 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', + TextInputType.phone)) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Administrator / Benificial User", + "", + 'benificiary', + TextInputType.text), + ), + 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', + TextInputType.phone)) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Address", + "", + 'benificiary_address', + TextInputType.text), + ), + 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', + TextInputType.phone)) + ]), + ], + )), const SizedBox(height: 25), SizedBox( width: MediaQuery.of(context).size.width, diff --git a/lib/screens/offline/passo/building/edit/signature_and_ids_edit.dart b/lib/screens/offline/passo/building/edit/signature_and_ids_edit.dart new file mode 100644 index 0000000..e590a84 --- /dev/null +++ b/lib/screens/offline/passo/building/edit/signature_and_ids_edit.dart @@ -0,0 +1,262 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; +import 'package:image_picker/image_picker.dart'; +import 'package:signature/signature.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:unit2/model/offline/offline_profile.dart'; +import 'package:unit2/model/passo/esignature.dart'; +import 'package:unit2/model/passo/valid_ids.dart'; +import '../../../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'dart:ui' as ui; +import 'dart:typed_data'; + +class EditSignatureAndIds extends StatefulWidget { + final OfflineProfile offlineProfile; + final Function function; + final int faasId; // Assuming widget.faas.id! is of type int + + EditSignatureAndIds(this.offlineProfile, this.function, this.faasId); + + @override + _EditSignatureAndIds createState() => _EditSignatureAndIds(); +} + +class _EditSignatureAndIds extends State { + bool _isEditingSignature = false; // State for editing signature + File? _image; + SignatureController? _signatureController; + final ImagePicker _picker = ImagePicker(); + + ValidIds? _validIds; // For storing fetched ValidIds record + ESignature? _eSignature; // For storing fetched ESignature record + + @override + void initState() { + super.initState(); + _signatureController = SignatureController( + penStrokeWidth: 3, + penColor: Colors.black87, + exportBackgroundColor: Colors.white, + ); + + _loadValidIdsAndSignature(widget.faasId); + } + + Future _loadValidIdsAndSignature(int faasId) async { + try { + // Fetch ValidIds using faasId + List> validIdsList = + await SQLServices.instance.getValidIds(faasId); + if (validIdsList.isNotEmpty) { + setState(() { + _validIds = ValidIds.fromJson(validIdsList.first); + _image = File(_validIds!.validIds!); // Load the image if it exists + }); + } + + // Fetch ESignature using faasId + List> signatureList = + await SQLServices.instance.getESignature(faasId); + if (signatureList.isNotEmpty) { + setState(() { + _eSignature = ESignature.fromJson(signatureList.first); + }); + } + } catch (e) { + print("Error loading ValidIds or Signature: $e"); + } + } + + Future _pickImage() async { + final XFile? image = await _picker.pickImage(source: ImageSource.gallery); + + if (image != null) { + setState(() { + _image = File(image.path); + }); + + // Update the ValidIds record + if (_validIds != null) { + _validIds!.validIds = image.path; + + // You may also want to update the database at this point + await SQLServices.instance + .updateValidIds(_validIds!.bldgapprDetailsId ?? 0, _validIds!); + } + } + } + + Future _captureImage() async { + final XFile? image = await _picker.pickImage(source: ImageSource.camera); + + if (image != null) { + setState(() { + _image = File(image.path); + }); + + // Update the ValidIds record + if (_validIds != null) { + _validIds!.validIds = image.path; + + // You may also want to update the database at this point + await SQLServices.instance + .updateValidIds(_validIds!.bldgapprDetailsId ?? 0, _validIds!); + } + } + } + + Future _saveSignature() async { + if (_signatureController!.isNotEmpty) { + try { + final ui.Image? image = await _signatureController?.toImage(); + final ByteData? byteData = + await image?.toByteData(format: ui.ImageByteFormat.png); + final Uint8List pngBytes = byteData!.buffer.asUint8List(); + + final directory = await getApplicationDocumentsDirectory(); + final String path = '${directory.path}/signature_${widget.faasId}.png'; + + final File imgFile = File(path); + await imgFile.writeAsBytes(pngBytes); + + // Update or create the signature record in the database + if (_eSignature != null) { + _eSignature!.signAttachment = path; // Update existing signature + await SQLServices.instance + .updateESignature(widget.faasId, _eSignature!); + } else { + // Create a new signature if not exists + final ESignature newSignature = ESignature( + bldgapprDetailsId: widget.faasId, + signAttachment: path, + dateCreated: DateTime.now().toIso8601String(), + dateModified: DateTime.now().toIso8601String(), + genCode: "5TH", + ); + await SQLServices.instance.createESignature(newSignature); + } + } catch (e) { + print('Error saving signature: $e'); + } + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: + const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), + child: const Text( + 'EDIT ID AND SIGNATURE', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left, + ), + ), + Row( + children: [ + Expanded( + child: Column( + children: [ + // ID section + SizedBox( + width: MediaQuery.of(context).size.width * 0.45, + height: MediaQuery.of(context).size.height * 0.6, + child: _image != null + ? Image.file(_image!) + : Image.asset('assets/pngs/id-card.png'), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: _pickImage, + icon: const Icon(Icons.image, color: Colors.red), + ), + IconButton( + onPressed: _captureImage, + icon: + const Icon(Icons.camera_alt, color: Colors.red), + ), + ], + ), + ], + ), + ), + Expanded( + child: Column( + children: [ + // Signature section + SizedBox( + width: MediaQuery.of(context).size.width * 0.45, + height: MediaQuery.of(context).size.height * 0.6, + child: _isEditingSignature + ? Signature( + controller: _signatureController!, + backgroundColor: Colors.white, + ) + : (_eSignature != null && + _eSignature!.signAttachment != null) + ? Image.file(File(_eSignature!.signAttachment!)) + : Container( + color: Colors.grey[300], + child: const Center( + child: Text('No Signature Available'), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: () { + if (_isEditingSignature) { + _saveSignature(); // Save the signature if editing + } + setState(() { + _isEditingSignature = + !_isEditingSignature; // Toggle editing state + if (!_isEditingSignature) { + _signatureController + ?.clear(); // Clear the signature pad + } + }); + }, + icon: const Icon(Icons.edit, color: Colors.red), + ), + IconButton( + onPressed: () { + _signatureController + ?.clear(); // Clear the signature pad + }, + icon: const Icon(Icons.clear, color: Colors.red), + ), + ], + ), + ], + ), + ), + ], + ), + Center( + child: Container( + margin: const EdgeInsets.only(top: 30.0), + width: MediaQuery.of(context).size.width * 0.75, + height: 50, + child: ElevatedButton( + onPressed: () { + widget.function(); // Call the passed function + }, + child: const Text("SUBMIT"), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/offline/passo/building/edit/structural_materials_edit.dart b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart index 4e31dcd..d59679a 100644 --- a/lib/screens/offline/passo/building/edit/structural_materials_edit.dart +++ b/lib/screens/offline/passo/building/edit/structural_materials_edit.dart @@ -5,7 +5,6 @@ import 'package:unit2/bloc/offline/offline_passo/building/structural_materials_o import 'package:unit2/model/passo/structural_materials_ii.dart'; import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; -import '../../../../../model/passo/structureMaterial.dart'; import '../../../../../widgets/passo/custom_button.dart'; import '../../../../../widgets/passo/custom_formBuilder_fields.dart'; diff --git a/lib/screens/offline/passo/building_home_offline.dart b/lib/screens/offline/passo/building_home_offline.dart index 5bfa662..9cb7386 100644 --- a/lib/screens/offline/passo/building_home_offline.dart +++ b/lib/screens/offline/passo/building_home_offline.dart @@ -1,12 +1,9 @@ -import 'dart:convert'; -import 'dart:io'; - 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:intl/intl.dart'; +import 'package:unit2/bloc/offline/offline_passo/admin/assessment_level/assessment_level_bloc.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'; @@ -21,18 +18,13 @@ import 'package:unit2/bloc/offline/offline_passo/building/general_description/ge 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/bloc/offline/offline_passo/building/swornstatement/sworn_statement_bloc.dart'; import 'package:unit2/model/offline/offline_profile.dart'; import 'package:unit2/model/passo/additional_items.dart'; -import 'package:unit2/model/passo/bldg_loc.dart'; import 'package:unit2/model/passo/building_and_structure.dart'; -import 'package:unit2/model/passo/building_details.dart'; -import 'package:unit2/model/passo/land_ref.dart'; -import 'package:unit2/model/passo/property_appraisal.dart'; -import 'package:unit2/model/passo/property_assessment.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/add/drawing_pad.dart'; -import 'package:unit2/screens/offline/passo/building/add/flutter_painter.dart'; import 'package:unit2/screens/offline/passo/building/edit/edit_building.dart'; import 'package:unit2/screens/offline/passo/land/add/add_land.dart'; import 'package:unit2/theme-data.dart/colors.dart'; @@ -52,14 +44,7 @@ import '../../../bloc/offline/offline_passo/land/land_property_owner_bloc/land_p import '../../../bloc/offline/offline_passo/land/land_property_signture/land_property_signature_bloc.dart'; import '../../../bloc/offline/offline_passo/land/other_improvements/other_improvements_bloc.dart'; import '../../../bloc/offline/offline_passo/land/value_adjustment/value_adjustment_bloc.dart'; -import '../../../model/passo/general_description.dart'; -import '../../../model/passo/structureMaterial.dart'; -import '../../../sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; import '../../../utils/alerts.dart'; -import 'package:http/http.dart'; -import 'package:date_format/date_format.dart'; - -import '../../../utils/urls.dart'; class BuildingHomeOffline extends StatelessWidget { final OfflineProfile offlineProfile; @@ -91,17 +76,6 @@ class BuildingHomeOffline extends StatelessWidget { final progress = ProgressHUD.of(context); progress!.showWithText("Syncing data 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 PropertyInfoLoaded) { final progress = ProgressHUD.of(context); progress?.dismiss(); @@ -195,7 +169,8 @@ class BuildingHomeOffline extends StatelessWidget { const LoadBarangayInMunicipality(cityCode: '01')), ), BlocProvider( - create: (context) => BuildingAndStructureBloc()), + create: (context) => BuildingAndStructureBloc() + ..add(const LoadBuildingAndStructure())), BlocProvider( create: (context) => ClassComponentsAdminBloc() ..add(const LoadClassComponents()), @@ -225,6 +200,13 @@ class BuildingHomeOffline extends StatelessWidget { create: (context) => BldgAppraisalOfflineBloc()), BlocProvider( create: (context) => BldgAssessmentOfflineBloc()), + BlocProvider( + create: (context) => SwornStatementBloc(), + ), + BlocProvider( + create: (context) => AssessmentLevelBloc() + ..add(const LoadAssessmentLevel()), + ), ], child: AddBuilding(triggerLoadBldgFaas, offlineProfile)); })); }), @@ -355,7 +337,7 @@ Card _listCard(PropertyInfo property_info, context, index, deleteItem, return MultiBlocProvider( providers: [ BlocProvider( - create: (context) => CrudBloc()..add(FetchTodos()), + create: (context) => CrudBloc()..add(const FetchTodos()), ), BlocProvider( create: (context) => MunicipalitiesAdminBloc() @@ -412,6 +394,14 @@ Card _listCard(PropertyInfo property_info, context, index, deleteItem, ..add(LoadBuildingAndStructureEdit( bldgAndStructure: const [], id: property_info.id!))), + BlocProvider( + create: (context) => SwornStatementBloc() + ..add(FetchSingleSwornStatement(id: property_info.id!)), + ), + BlocProvider( + create: (context) => + AssessmentLevelBloc()..add(const LoadAssessmentLevel()), + ) ], child: EditBuildingOffline( index: index, @@ -455,17 +445,17 @@ Card _listCard(PropertyInfo property_info, context, index, deleteItem, ), textAlign: TextAlign.left, ), - SizedBox(height: 5), + const SizedBox(height: 5), Text( 'TDN: ${property_info.tdn}', - style: TextStyle( + style: const TextStyle( fontSize: 13, ), textAlign: TextAlign.left, ), Text( - 'Uploaded on: ${property_info.dateSynced == null ? '--' : property_info.dateSynced}', - style: TextStyle( + 'Uploaded on: ${property_info.dateSynced ?? '--'}', + style: const TextStyle( fontSize: 13, ), textAlign: TextAlign.left, diff --git a/lib/screens/offline/passo/passo_main_dashboard.dart b/lib/screens/offline/passo/passo_main_dashboard.dart index 1ae54b3..51dd364 100644 --- a/lib/screens/offline/passo/passo_main_dashboard.dart +++ b/lib/screens/offline/passo/passo_main_dashboard.dart @@ -1,7 +1,4 @@ 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/model/offline/offline_profile.dart'; import 'package:unit2/screens/offline/passo/admin/admin_main_screen.dart'; diff --git a/lib/sevices/login_service/auth_service.dart b/lib/sevices/login_service/auth_service.dart index d2b3d79..c0547fe 100644 --- a/lib/sevices/login_service/auth_service.dart +++ b/lib/sevices/login_service/auth_service.dart @@ -51,9 +51,9 @@ class AuthService { } } - Future> qrLogin({String? uuid, String? password}) async { - - Map responseStatus = {}; + Future> qrLogin( + {String? uuid, String? password}) async { + Map responseStatus = {}; Map body = { 'uuid': uuid!, 'password': password!, @@ -66,10 +66,9 @@ class AuthService { try { http.Response response = await Request.instance .postRequest(path: path, param: {}, headers: baseHeaders, body: body); - - Map data = jsonDecode(response.body); - responseStatus = data; + Map data = jsonDecode(response.body); + responseStatus = data; } catch (e) { throw (e.toString()); } diff --git a/lib/sevices/offline/offline_passo/admin/api_services/assessment_level_api_services.dart b/lib/sevices/offline/offline_passo/admin/api_services/assessment_level_api_services.dart new file mode 100644 index 0000000..2039028 --- /dev/null +++ b/lib/sevices/offline/offline_passo/admin/api_services/assessment_level_api_services.dart @@ -0,0 +1,46 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:unit2/model/passo/assessment_level.dart'; +import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import 'package:unit2/utils/request.dart'; +import 'package:unit2/utils/urls.dart'; +import 'package:http/http.dart' as http; + +class AssessmentLevelApiServices { + static final AssessmentLevelApiServices _instance = + AssessmentLevelApiServices(); + static AssessmentLevelApiServices get instance => _instance; + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + Future>> fetch() async { + String path = Url.instance.getAssessmentLevel(); + 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); + print(response.body); // Print for debugging + + if (response.statusCode == 200) { + // Directly parse the JSON as a list of maps + final List> result = + List>.from(jsonDecode(response.body)); + print(result); // Print result for debugging + return result; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw Exception(e.toString()); + } + } +} diff --git a/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart index 2d3d0b6..6d62768 100644 --- a/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart +++ b/lib/sevices/offline/offline_passo/admin/sql_services/sql_services.dart @@ -6,6 +6,7 @@ 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/esignature.dart'; import 'package:unit2/model/passo/land_property_assessment.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_ref.dart'; @@ -14,11 +15,13 @@ import 'package:unit2/model/passo/signatories.dart'; import 'package:unit2/model/passo/structural_materials_ii.dart'; import 'package:unit2/model/passo/type_of_road.dart'; import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/model/passo/valid_ids.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/assessment_level.dart'; import '../../../../../model/passo/barangay.dart'; import '../../../../../model/passo/building_and_structure.dart'; import '../../../../../model/passo/class_components _offline.dart'; @@ -36,6 +39,7 @@ import '../../../../../model/passo/property_appraisal.dart'; import '../../../../../model/passo/property_assessment.dart'; import '../../../../../model/passo/property_info.dart'; import '../../../../../model/passo/structureMaterial.dart'; +import '../../../../../model/passo/sworn_statement.dart'; import '../../../../../model/passo/trees_improvements.dart'; import '../../../../../model/passo/type_of_location.dart'; @@ -129,6 +133,17 @@ class SQLServices { ) '''); + await db.execute(''' + CREATE TABLE assessment_level ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + classificationId INTEGER NOT NULL, + over TEXT NOT NULL, + notOver TEXT NOT NULL, + assessmentLevels TEXT NOT NULL, + genCode TEXT NOT NULL + ) + '''); + await db.execute(''' CREATE TABLE land_classification ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, @@ -189,6 +204,27 @@ class SQLServices { ) '''); + await db.execute(''' + CREATE TABLE bldg_valid_ids ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgappr_details_id INTEGER NOT NULL, + date_created TEXT NOT NULL, + id_attachment TEXT NOT NULL, + gen_code TEXT NOT NULL + ) + '''); + + await db.execute(''' + CREATE TABLE e_signature ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgappr_details_id INTEGER NOT NULL, + sign_attachment TEXT NOT NULL, + date_created TEXT NOT NULL, + date_modified TEXT NOT NULL, + gen_code TEXT NOT NULL + ) + '''); + await db.execute(''' CREATE TABLE value_adjustments ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, @@ -225,7 +261,9 @@ class SQLServices { dateCreated TEXT NOT NULL, dateModified TEXT NOT NULL, gen_code TEXT, - dateSynced TEXT + dateSynced TEXT, + citizenship TEXT, + civil_status TEXT ) '''); @@ -397,6 +435,19 @@ class SQLServices { ) '''); + await db.execute(''' + CREATE TABLE sworn_statement ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + bldgapprDetailsId INTEGER NOT NULL, + citizenship TEXT NOT NULL, + civil TEXT NOT NULL, + fname TEXT NOT NULL, + mname TEXT NOT NULL, + lname TEXT NOT NULL, + gen_code TEXT + ) + '''); + await db.execute(''' CREATE TABLE additionalitems ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, @@ -576,6 +627,34 @@ class SQLServices { return result.map((json) => City.fromJson2(json)).toList(); } + //Assessment Level + + Future createAssessmentLevel( + AssessmentLevel assessmentLevel) async { + final db = await instance.database; + + final data = { + "classificationId": assessmentLevel.classificationId, + "over": assessmentLevel.over, + "notOver": assessmentLevel.notOver, + "assessmentLevels": assessmentLevel.assessmentLevels, + "genCode": assessmentLevel.genCode, + }; + + final id = await db.insert('assessment_level', data); + return assessmentLevel.copyWith(id: id); + } + + Future> readAllAssessmentLevels() async { + final db = await instance.database; + const orderBy = 'id'; + + final result = await db.query('assessment_level', orderBy: orderBy); + print('result'); + print(result.toString()); + + return result.map((json) => AssessmentLevel.fromJson2(json)).toList(); + } //Barangay @@ -908,6 +987,8 @@ class SQLServices { "assessedByName": propertyInfo.assessedByName, "dateCreated": "000", "dateModified": "000", + "citizenship": propertyInfo.citizenship, + "civil_status": propertyInfo.civilStatus }; final id = await db.insert('bldg_owner', data); final tempID = await SharedPreferences.getInstance(); @@ -946,7 +1027,9 @@ class SQLServices { "assessedByName": propertyInfo.assessedByName, "dateCreated": "000", "dateModified": "000", - "dateSynced": propertyInfo.dateSynced + "dateSynced": propertyInfo.dateSynced, + "citizenship": propertyInfo.citizenship, + "civil_status": propertyInfo.civilStatus }; final result = @@ -1219,6 +1302,131 @@ class SQLServices { return results; } + //E signature + + Future createESignature(ESignature eSignature) async { + final db = await instance.database; + + final data = { + "bldgappr_details_id": eSignature.bldgapprDetailsId, + "sign_attachment": eSignature.signAttachment, + "date_created": eSignature.dateCreated, + "date_modified": eSignature.dateModified, + "gen_code": eSignature.genCode, + }; + + final id = await db.insert('e_signature', data); + return eSignature.copy(bldgapprDetailsId: id); + } + + Future>> getESignature(bldgapprDetailsId) async { + final db = await instance.database; + final results = await db.query( + 'e_signature', + where: "bldgappr_details_id = ?", + whereArgs: [bldgapprDetailsId], + limit: 1, + ); + + print('eSignature query result:'); + print(results); + + return results; + } + + Future updateESignature(int id, ESignature eSignature) async { + final db = await instance.database; + + final data = { + "bldgappr_details_id": eSignature.bldgapprDetailsId, + "sign_attachment": eSignature.signAttachment, + "date_created": eSignature.dateCreated, + "date_modified": eSignature.dateModified, + "gen_code": eSignature.genCode, + }; + + final result = await db.update( + 'e_signature', + data, + where: "id = ?", + whereArgs: [id], + ); + + if (result > 0) { + print('eSignature Updated Successfully'); + } else { + throw Exception('Failed to update eSignature.'); + } + + return result; + } + + // Valid IDS + + Future>> getValidIds(int bldgapprDetailsId) async { + final db = await instance.database; + + // Query the database for the valid ID with the provided bldgappr_details_id + final results = await db.query( + 'bldg_valid_ids', + where: "bldgappr_details_id = ?", + whereArgs: [bldgapprDetailsId], + limit: 10, // Limit the query to return only one result + ); + + // Debugging output to print the results + print('Valid IDs query result:'); + print(results); + + return results; + } + + Future createValidIds(ValidIds validID) async { + final db = await instance.database; + + final data = { + // "id": treesImprovements.id, + "bldgappr_details_id": validID.bldgapprDetailsId, + "date_created": validID.dateCreated, + "id_attachment": validID.validIds, + "gen_code": "5TH" + }; + print('Valid IDs insert result:'); + print(data); + final id = await db.insert('bldg_valid_ids', data); + return validID.copy(bldgapprDetailsId: id); + } + + Future updateValidIds(int id, ValidIds validID) async { + final db = await instance.database; + + final data = { + "bldgappr_details_id": validID.bldgapprDetailsId, + "date_created": validID.dateCreated, + "id_attachment": validID.validIds, + "gen_code": validID.genCode + }; + + final result = await db + .update('bldg_valid_ids', data, where: "id = ?", whereArgs: [id]); + + if (result > 0) { + print('Valid ID Updated Successfully'); + } else { + throw Exception('Failed to update Valid ID.'); + } + return result; + } + + Future>> getFloorValidIds(id) async { + final db = await instance.database; + final results = await db.query('bldg_valid_ids', + where: "bldgappr_details_id = ?", whereArgs: [id], limit: 1); + print('valid ids test result'); + print(results); + + return results; + } //Structural Materials @@ -1562,6 +1770,73 @@ class SQLServices { return result; } + //Sworn Statement + + Future createSwornStatement( + SwornStatement swornStatement) async { + final db = await instance.database; + print("Sworn"); + print(swornStatement.toJson()); + final data = { + "bldgapprDetailsId": swornStatement.bldgapprDetailsId, + "citizenship": swornStatement.citizenship, + "civil": swornStatement.civilStatus, + "fname": swornStatement.fname, + "mname": swornStatement.mname, + "lname": swornStatement.lname, + "gen_code": swornStatement.genCode, + }; + + final id = await db.insert('sworn_statement', data); + return swornStatement.copy(bldgapprDetailsId: id); + } + + Future>> getSwornStatement( + bldgapprDetailsId) async { + print("Sworn ID"); + print(bldgapprDetailsId); + final db = await instance.database; + + final result = await db.query( + 'sworn_statement', + where: "bldgapprDetailsId = ?", + whereArgs: [bldgapprDetailsId], + limit: 1, // Assuming only one record per `bldgappr_details_id` + ); + + print('Sworn Statement fetched: $result'); + return result; + } + + Future updateSwornStatement( + int bldgapprDetailsId, SwornStatement swornStatement) async { + final db = await instance.database; + + final data = { + "citizenship": swornStatement.citizenship, + "civil": swornStatement.civilStatus, + "fname": swornStatement.fname, + "mname": swornStatement.mname, + "lname": swornStatement.lname, + "gen_code": swornStatement.genCode, + }; + + final result = await db.update( + 'sworn_statement', + data, + where: "bldgapprDetailsId = ?", + whereArgs: [bldgapprDetailsId], + ); + + if (result > 0) { + print('Sworn Statement updated successfully.'); + } else { + throw Exception('Failed to update Sworn Statement.'); + } + + return result; + } + //Land Property Owner Future createLandOwner( diff --git a/lib/sevices/passo/building/landref_services.dart b/lib/sevices/passo/building/landref_services.dart index ef90ba5..07bc98b 100644 --- a/lib/sevices/passo/building/landref_services.dart +++ b/lib/sevices/passo/building/landref_services.dart @@ -41,4 +41,22 @@ class LandRefServices { throw e.toString(); } } + + Future update(LandRef data, id) async { + String path = "${Url.instance.propertyInfo()}$id/"; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: {}); + } catch (e) { + throw e.toString(); + } + return response; + } } diff --git a/lib/sevices/passo/building/property_assessment_services.dart b/lib/sevices/passo/building/property_assessment_services.dart index a18da40..d0e4a66 100644 --- a/lib/sevices/passo/building/property_assessment_services.dart +++ b/lib/sevices/passo/building/property_assessment_services.dart @@ -134,7 +134,7 @@ class PropertyAssessmentServices { } Future updateEdit( - PropertyAssessmentEdit assessment, id) async { + PropertyAssessment assessment, id) async { String path = Url.instance.propertyAssessment(); Map headers = { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/utils/global.dart b/lib/utils/global.dart index 91ebce2..3f3e36a 100644 --- a/lib/utils/global.dart +++ b/lib/utils/global.dart @@ -19,6 +19,7 @@ String? globalMiddleName; DateTime? globalBday; String? globalSex; Profile? globalCurrentProfile; + ///offline data bool? globalOfflineAvailable; OfflineProfile? globalOfflineProfile; @@ -26,3 +27,14 @@ OfflineProfile? globalOfflineProfile; Box? CREDENTIALS; Box? SOS; Box? OFFLINE; + +Map getHeaders() { + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + + return { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret, + }; +} diff --git a/lib/utils/passo/post_request.dart b/lib/utils/passo/post_request.dart new file mode 100644 index 0000000..99beb4a --- /dev/null +++ b/lib/utils/passo/post_request.dart @@ -0,0 +1,29 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; +import 'package:flutter/material.dart'; + +// Reusable function to send a POST request +Future postRequest({ + required String url, + required Map headers, + required Map body, +}) async { + try { + final response = await http.post( + Uri.parse(url), + headers: headers, + body: jsonEncode(body), + ); + + if (response.statusCode == 201) { + print('Post request successful'); + } else { + print('Failed to post: ${response.statusCode}'); + } + + return response; + } catch (e) { + print('Error: $e'); + return null; + } +} diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index eb57b81..f818bce 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -7,12 +7,12 @@ class Url { // // // return '192.168.10.183:3000'; return 'agusandelnorte.gov.ph'; // return "192.168.10.219:3000"; - // return "192.168.10.241"; - // return "192.168.10.185"; + // return "192.168.80.110"; + // return "192.168.10.118"; // return "192.168.10.221:3004"; // return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; - // return "192.168.80.21:8000"; + // return "192.168.80.20:8000"; // return "192.168.10.247"; // return "playcensys.agusandelnorte.gov.ph"; // return "10.10.10.110:8000"; @@ -20,7 +20,7 @@ class Url { } String prefixHost() { - return "http"; + return "https://"; // return "http"; } @@ -372,6 +372,10 @@ class Url { return "/api/rptass_app/bldgappr_details/"; } + String buildingStructure() { + return "/api/rptass_app/bldgappr_structure/"; + } + String generalDescription() { return "/api/rptass_app/bldgappr_gendesc/"; } @@ -412,6 +416,10 @@ class Url { return "/api/rptass_app/agusan_city/"; } + String getAssessmentLevel() { + return "/api/rptass_app/bldgappr_assessment_levels/"; + } + String getSignatories() { return "/api/rptass_app/signatories/"; } diff --git a/pubspec.lock b/pubspec.lock index 1b51c18..f5b5c53 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1537,10 +1537,10 @@ packages: dependency: "direct main" description: name: signature - sha256: d95143b8e310b395ea0be59a46bb69fa24106cb6ec79815fc56fd320268e24e6 + sha256: "8056e091ad59c2eb5735fee975ec649d0caf8ce802bb1ffb1e0955b00a6d0daa" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.5.0" simple_chips_input: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index db2c360..93949de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,7 @@ dependencies: flutter_progress_hud: ^2.0.2 barcode_scan2: ^4.2.1 qr_flutter: ^4.0.0 - signature: ^5.4.0 + signature: ^5.5.0 awesome_dialog: ^3.0.2 system_info2: ^2.0.4 flutter_bloc: ^8.0.0 @@ -148,6 +148,8 @@ flutter: - assets/pngs/ - assets/fonts/ - assets/ + - assets/pngs/white_bg.png + - assets/pngs/broken_lines.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see -- 2.34.1