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 5c4c37e..caaa115 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 @@ -1,10 +1,23 @@ +import 'dart:convert'; + import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:intl/intl.dart'; import 'package:unit2/sevices/offline/offline_passo/admin/sql_services/sql_services.dart'; +import '../../../../../model/offline/offline_profile.dart'; +import '../../../../../model/passo/additional_items.dart'; +import '../../../../../model/passo/bldg_loc.dart'; +import '../../../../../model/passo/building_and_structure.dart'; +import '../../../../../model/passo/general_description.dart'; +import '../../../../../model/passo/land_ref.dart'; +import '../../../../../model/passo/property_assessment.dart'; import '../../../../../model/passo/property_info.dart'; +import '../../../../../model/passo/structureMaterial.dart'; import '../../../../../model/passo/todo.dart'; import '../../../../../sevices/offline/offline_passo/building/property_owner_info_service.dart'; +import 'package:http/http.dart'; +import '../../../../../utils/urls.dart'; part 'crud_event.dart'; part 'crud_state.dart'; @@ -69,5 +82,267 @@ class CrudBloc extends Bloc { await SQLServices.instance.deleteBldgOwner(id: event.id); add(const FetchTodos()); }); + on(((event, emit) async { + emit(UploadBuildingFaasLoading()); + List propertyOwner = + await SQLServices.instance.readAllBldgOwner(); + for (PropertyInfo infos in propertyOwner) { + //General Description + List> genDesc = + await SQLServices.instance.getGeneralDescription(infos.id); + List genDescList = + genDesc.map((map) => GeneralDesc.fromJson2(map)).toList(); + + GeneralDesc firstGenDesc = genDescList.first; + + //Location + List> loc = + await SQLServices.instance.getLandRef(infos.id); + + List locList = + loc.map((map) => BldgLoc.fromJson2(map)).toList(); + + BldgLoc firstLoc = locList.first; + + //Land Refeernce + List> landRef = + await SQLServices.instance.getLocation(infos.id); + + List landRefList = + landRef.map((map) => LandRef.fromJson2(map)).toList(); + + LandRef firstLandRef = landRefList.first; + + //Assessment + List> assessment = + await SQLServices.instance.getBldgAssessment(infos.id); + + List assessList = + assessment.map((map) => PropertyAssessment.fromJson2(map)).toList(); + + PropertyAssessment firstAssess = assessList.first; + + //Structural Materials + List> strucMat = + await SQLServices.instance.getStructuralMaterials(infos.id); + List strcuMatList = + strucMat.map((map) => StructureMaterials.fromJson2(map)).toList(); + + StructureMaterials firstStructMat = strcuMatList.first; + + //Additional Items + List> addItems = + await SQLServices.instance.getAdditionalItems(infos.id); + List addItemsList = + addItems.map((map) => AdditionalItems.fromJson(map)).toList(); + + //BLDG Structure + List> bldgStructure = + await SQLServices.instance.getBuildingAndStructure(infos.id); + List bldgStructureList = + bldgStructure.map((map) => BldgAndStructure.fromJson(map)).toList(); + + DateTime dateIssued = DateTime.parse(firstGenDesc.dateIssued!); + + final details = { + "assessed_by_id": event.offlineProfile.id.toString(), + "assessed_by_name": event.offlineProfile.firstName, + "date_created": "{{currentTimestamp}}", + "date_modified": "{{currentTimestamp}}", + "trans_code": infos.transCode, + "tdn": infos.tdn, + "pin": infos.pin, + "fname": infos.fname, + "mname": infos.mname, + "lname": infos.lname, + "bday": infos.bday, + "address": infos.address, + "telno": infos.telno, + "tin": infos.tin, + "admin_user": infos.adminUser, + "admin_address": infos.adminAddress, + "admin_telno": infos.adminTelno, + "admin_tin": infos.adminTin, + "faas_type": infos.faasType, + "gen_code": "5TH", + "bldgappr_location.date_created": "{{currentTimestamp}}", + "bldgappr_location.date_modified": "{{currentTimestamp}}", + "bldgappr_location.street": firstLoc.street, + "bldgappr_location.barangay": firstLoc.barangay, + "bldgappr_location.municipality": firstLoc.municipality, + "bldgappr_location.province": firstLoc.province, + "bldgappr_location.gen_code": "5TH", + "bldgappr_landref.date_created": "{{currentTimestamp}}", + "bldgappr_landref.date_modified": "{{currentTimestamp}}", + "bldgappr_landref.owner": firstLandRef.owner, + "bldgappr_landref.cloa_no": firstLandRef.cloaNo, + "bldgappr_landref.lot_no": firstLandRef.lotNo, + "bldgappr_landref.tdn": firstLandRef.tdn, + "bldgappr_landref.area": firstLandRef.area, + "bldgappr_landref.survey_no": firstLandRef.surveyNo, + "bldgappr_landref.blk_no": firstLandRef.blkNo, + "bldgappr_landref.gen_code": "5TH", + "bldgappr_generaldesc.date_created": "{{currentTimestamp}}", + "bldgappr_generaldesc.date_modified": "{{currentTimestamp}}", + "bldgappr_generaldesc.bldg_kind": firstGenDesc.bldgKind, + "bldgappr_generaldesc.struc_type": firstGenDesc.strucType, + "bldgappr_generaldesc.bldg_permit": firstGenDesc.bldgPermit, + "bldgappr_generaldesc.date_issued": DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstGenDesc.dateIssued!)), + "bldgappr_generaldesc.cct": null, + "bldgappr_generaldesc.cert_completion_issued": + DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstGenDesc.certCompletionIssued!)), + "bldgappr_generaldesc.cert_ocscupancy_issued": + DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstGenDesc.certOccupancyIssued!)), + "bldgappr_generaldesc.date_completed": DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstGenDesc.dateCompleted!)), + "bldgappr_generaldesc.date_occupied": DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstGenDesc.dateOccupied!)), + "bldgappr_generaldesc.bldg_age": firstGenDesc.bldgAge, + "bldgappr_generaldesc.no_storeys": firstGenDesc.noStoreys, + "bldgappr_generaldesc.area_1stfloor": firstGenDesc.area1Stfloor, + "bldgappr_generaldesc.area_2ndfloor": firstGenDesc.area2Ndfloor, + "bldgappr_generaldesc.area_3rdfloor": firstGenDesc.area3Rdfloor, + "bldgappr_generaldesc.area_4thfloor": firstGenDesc.area4Thfloor, + "bldgappr_generaldesc.total_floor_area": firstGenDesc.totalFloorArea, + "bldgappr_generaldesc.floor_sketch": null, + "bldgappr_generaldesc.actual_use": firstGenDesc.actualUse, + "bldgappr_generaldesc.unit_value": firstGenDesc.unitValue, + "bldgappr_generaldesc.gen_code": "5TH", + "bldgappr_struct_materials.date_created": "{{currentTimestamp}}", + "bldgappr_struct_materials.date_modified": "{{currentTimestamp}}", + "bldgappr_struct_materials.foundation": firstStructMat.foundation, + "bldgappr_struct_materials.columns": firstStructMat.columns, + "bldgappr_struct_materials.beams": firstStructMat.beams, + "bldgappr_struct_materials.truss_framing": + firstStructMat.trussFraming, + "bldgappr_struct_materials.roof": firstStructMat.roof, + "bldgappr_struct_materials.flooring": firstStructMat.flooring, + "bldgappr_struct_materials.walls": firstStructMat.walls, + "bldgappr_struct_materials.others": firstStructMat.others, + "bldgappr_struct_materials.gen_code": "5TH", + "bldgappr_property_assessment.date_created": "{{currentTimestamp}}", + "bldgappr_property_assessment.date_modified": "{{currentTimestamp}}", + "bldgappr_property_assessment.actual_use": firstAssess.actualUse, + "bldgappr_property_assessment.market_value": firstAssess.marketValue, + "bldgappr_property_assessment.assessment_level": + firstAssess.assessmentLevel, + "bldgappr_property_assessment.assessed_value": + firstAssess.assessedValue, + "bldgappr_property_assessment.taxable": firstAssess.taxable, + "bldgappr_property_assessment.exempt": firstAssess.exempt, + "bldgappr_property_assessment.qtr": firstAssess.qtr, + "bldgappr_property_assessment.yr": firstAssess.yr, + "bldgappr_property_assessment.appraisedby_name": + firstAssess.appraisedbyName, + "bldgappr_property_assessment.appraisedby_date": + DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstAssess.appraisedbyDate!)), + "bldgappr_property_assessment.recommendappr_name": + firstAssess.recommendapprName, + "bldgappr_property_assessment.recommendappr_date": + DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstAssess.recommendapprDate!)), + "bldgappr_property_assessment.approvedby_name": + firstAssess.approvedbyName, + "bldgappr_property_assessment.approvedby_date": null, + "bldgappr_property_assessment.memoranda": firstAssess.memoranda, + "bldgappr_property_assessment.swornstatement_no": + firstAssess.swornstatementNo, + "bldgappr_property_assessment.date_received": DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstAssess.dateReceived!)), + "bldgappr_property_assessment.entry_date_assessment": null, + "bldgappr_property_assessment.entry_date_by": DateFormat("yyyy-MM-dd") + .format(DateTime.parse(firstAssess.entryDateAssessment!)), + "bldgappr_property_assessment.gen_code": "5TH", + "bldgappr_rec_supersededass.date_created": "{{currentTimestamp}}", + "bldgappr_rec_supersededass.date_modified": "{{currentTimestamp}}", + "bldgappr_rec_supersededass.pin": null, + "bldgappr_rec_supersededass.tdn": null, + "bldgappr_rec_supersededass.total_assval": null, + "bldgappr_rec_supersededass.owner": null, + "bldgappr_rec_supersededass.effectivity_ass": null, + "bldgappr_rec_supersededass.page_no": null, + "bldgappr_rec_supersededass.total_marketval": null, + "bldgappr_rec_supersededass.total_area": null, + "bldgappr_rec_supersededass.rec_assessment": null, + "bldgappr_rec_supersededass.rec_taxmapping": null, + "bldgappr_rec_supersededass.rec_records": null, + "bldgappr_rec_supersededass.date": null, + "bldgappr_rec_supersededass.gen_code": "5TH" + }; + + // print(details); + + String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; + String xClientKeySecret = "unitcYqAN7GGalyz"; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + + Response details_response = await post( + Uri.parse( + 'http://${Url.instance.host()}/api/rptass_app/bldgappr_details/'), + headers: headers, + body: jsonEncode(details)); + + final datas = json.decode(details_response.body); + for (AdditionalItems items in addItemsList) { + final addItems = AdditionalItems( + id: 1, + bldgapprDetailsId: datas['data']['id'], + classId: items.classId, + className: items.className, + structType: items.structType, + unitValue: items.unitValue, + baseUnitValue: items.baseUnitValue, + area: items.area, + marketValue: items.marketValue, + depreciationRate: items.depreciationRate, + adjustedMarketVal: items.adjustedMarketVal, + amtDepreciation: items.amtDepreciation, + painted: items.painted, + secondhand: items.secondhand, + paintedUnitval: items.paintedUnitval, + secondhandUnitval: items.secondhandUnitval, + actualUse: items.actualUse, + genCode: "5TH"); + Response add_response = await post( + Uri.parse( + 'http://${Url.instance.host()}/api/rptass_app/additional_items/'), + headers: headers, + body: jsonEncode(addItems)); + } + 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); + print(bldgStruc.toJson()); + Response response = await post( + Uri.parse( + 'http://${Url.instance.host()}/api/rptass_app/bldgappr_structure/'), + headers: headers, + body: jsonEncode(bldgStruc)); + } + } + emit(PropertyInfoLoaded(propertyInfos: propertyOwner)); + })); } } 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 15853c9..0f42778 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 @@ -93,6 +93,14 @@ class FetchTodos extends CrudEvent { List get props => []; } +class UploadBuildingFaas extends CrudEvent { + final OfflineProfile offlineProfile; + const UploadBuildingFaas({required this.offlineProfile}); + + @override + List get props => [offlineProfile]; +} + class FetchSpecificTodo extends CrudEvent { final int id; const FetchSpecificTodo({required this.id}); diff --git a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart index 11058fc..4da2759 100644 --- a/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart +++ b/lib/bloc/offline/offline_passo/building/owner_info_bloc/crud_state.dart @@ -36,3 +36,8 @@ class DisplaySpecificTodo extends CrudState { @override List get props => [todo]; } + +class UploadBuildingFaasLoading extends CrudState { + @override + List get props => []; +} diff --git a/lib/screens/offline/passo/building/add/property_appraisal.dart b/lib/screens/offline/passo/building/add/property_appraisal.dart index 6af0937..3f845c5 100644 --- a/lib/screens/offline/passo/building/add/property_appraisal.dart +++ b/lib/screens/offline/passo/building/add/property_appraisal.dart @@ -522,6 +522,7 @@ class _PropertyAppraisalOfflinePage @override Widget build(BuildContext context) { + final width = MediaQuery.of(context).size.width; return Scaffold( body: BlocConsumer( @@ -572,7 +573,7 @@ class _PropertyAppraisalOfflinePage ), DataTable( columnSpacing: - MediaQuery.of(context).size.width / 3, + MediaQuery.of(context).size.width / 4, columns: [ const DataColumn( label: Text('Building Core'), @@ -651,14 +652,14 @@ class _PropertyAppraisalOfflinePage columnSpacing: MediaQuery.of(context).size.width / 3, - columns: [ - const DataColumn( + columns: const [ + DataColumn( label: Text('Additional Item'), ), - const DataColumn( + DataColumn( label: Text(''), ), - const DataColumn( + DataColumn( label: Text('Market Value'), ), ], diff --git a/lib/screens/offline/passo/building_home_offline.dart b/lib/screens/offline/passo/building_home_offline.dart index 6146d13..e437166 100644 --- a/lib/screens/offline/passo/building_home_offline.dart +++ b/lib/screens/offline/passo/building_home_offline.dart @@ -79,272 +79,32 @@ class BuildingHomeOffline extends StatelessWidget { myBloc.add(LoadLandPropertyOwner()); } - void uploadBldg() async { - List propertyOwner = - await SQLServices.instance.readAllBldgOwner(); - for (PropertyInfo infos in propertyOwner) { - //General Description - List> genDesc = - await SQLServices.instance.getGeneralDescription(infos.id); - List genDescList = - genDesc.map((map) => GeneralDesc.fromJson2(map)).toList(); - - GeneralDesc firstGenDesc = genDescList.first; - - //Location - List> loc = - await SQLServices.instance.getLandRef(infos.id); - - List locList = - loc.map((map) => BldgLoc.fromJson2(map)).toList(); - - BldgLoc firstLoc = locList.first; - - //Land Refeernce - List> landRef = - await SQLServices.instance.getLocation(infos.id); - - List landRefList = - landRef.map((map) => LandRef.fromJson2(map)).toList(); - - LandRef firstLandRef = landRefList.first; - - //Assessment - List> assessment = - await SQLServices.instance.getBldgAssessment(infos.id); - - List assessList = - assessment.map((map) => PropertyAssessment.fromJson2(map)).toList(); - - PropertyAssessment firstAssess = assessList.first; - - //Structural Materials - List> strucMat = - await SQLServices.instance.getStructuralMaterials(infos.id); - List strcuMatList = - strucMat.map((map) => StructureMaterials.fromJson2(map)).toList(); - - StructureMaterials firstStructMat = strcuMatList.first; - - //Additional Items - List> addItems = - await SQLServices.instance.getAdditionalItems(infos.id); - List addItemsList = - addItems.map((map) => AdditionalItems.fromJson(map)).toList(); - - //BLDG Structure - List> bldgStructure = - await SQLServices.instance.getBuildingAndStructure(infos.id); - List bldgStructureList = - bldgStructure.map((map) => BldgAndStructure.fromJson(map)).toList(); - - DateTime dateIssued = DateTime.parse(firstGenDesc.dateIssued!); - - final details = { - "assessed_by_id": offlineProfile.id.toString(), - "assessed_by_name": offlineProfile.firstName, - "date_created": "{{currentTimestamp}}", - "date_modified": "{{currentTimestamp}}", - "trans_code": infos.transCode, - "tdn": infos.tdn, - "pin": infos.pin, - "fname": infos.fname, - "mname": infos.mname, - "lname": infos.lname, - "bday": infos.bday, - "address": infos.address, - "telno": infos.telno, - "tin": infos.tin, - "admin_user": infos.adminUser, - "admin_address": infos.adminAddress, - "admin_telno": infos.adminTelno, - "admin_tin": infos.adminTin, - "faas_type": infos.faasType, - "gen_code": "5TH", - "bldgappr_location.date_created": "{{currentTimestamp}}", - "bldgappr_location.date_modified": "{{currentTimestamp}}", - "bldgappr_location.street": firstLoc.street, - "bldgappr_location.barangay": firstLoc.barangay, - "bldgappr_location.municipality": firstLoc.municipality, - "bldgappr_location.province": firstLoc.province, - "bldgappr_location.gen_code": "5TH", - "bldgappr_landref.date_created": "{{currentTimestamp}}", - "bldgappr_landref.date_modified": "{{currentTimestamp}}", - "bldgappr_landref.owner": firstLandRef.owner, - "bldgappr_landref.cloa_no": firstLandRef.cloaNo, - "bldgappr_landref.lot_no": firstLandRef.lotNo, - "bldgappr_landref.tdn": firstLandRef.tdn, - "bldgappr_landref.area": firstLandRef.area, - "bldgappr_landref.survey_no": firstLandRef.surveyNo, - "bldgappr_landref.blk_no": firstLandRef.blkNo, - "bldgappr_landref.gen_code": "5TH", - "bldgappr_generaldesc.date_created": "{{currentTimestamp}}", - "bldgappr_generaldesc.date_modified": "{{currentTimestamp}}", - "bldgappr_generaldesc.bldg_kind": firstGenDesc.bldgKind, - "bldgappr_generaldesc.struc_type": firstGenDesc.strucType, - "bldgappr_generaldesc.bldg_permit": firstGenDesc.bldgPermit, - "bldgappr_generaldesc.date_issued": DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstGenDesc.dateIssued!)), - "bldgappr_generaldesc.cct": null, - "bldgappr_generaldesc.cert_completion_issued": - DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstGenDesc.certCompletionIssued!)), - "bldgappr_generaldesc.cert_ocscupancy_issued": - DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstGenDesc.certOccupancyIssued!)), - "bldgappr_generaldesc.date_completed": DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstGenDesc.dateCompleted!)), - "bldgappr_generaldesc.date_occupied": DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstGenDesc.dateOccupied!)), - "bldgappr_generaldesc.bldg_age": firstGenDesc.bldgAge, - "bldgappr_generaldesc.no_storeys": firstGenDesc.noStoreys, - "bldgappr_generaldesc.area_1stfloor": firstGenDesc.area1Stfloor, - "bldgappr_generaldesc.area_2ndfloor": firstGenDesc.area2Ndfloor, - "bldgappr_generaldesc.area_3rdfloor": firstGenDesc.area3Rdfloor, - "bldgappr_generaldesc.area_4thfloor": firstGenDesc.area4Thfloor, - "bldgappr_generaldesc.total_floor_area": firstGenDesc.totalFloorArea, - "bldgappr_generaldesc.floor_sketch": null, - "bldgappr_generaldesc.actual_use": firstGenDesc.actualUse, - "bldgappr_generaldesc.unit_value": firstGenDesc.unitValue, - "bldgappr_generaldesc.gen_code": "5TH", - "bldgappr_struct_materials.date_created": "{{currentTimestamp}}", - "bldgappr_struct_materials.date_modified": "{{currentTimestamp}}", - "bldgappr_struct_materials.foundation": firstStructMat.foundation, - "bldgappr_struct_materials.columns": firstStructMat.columns, - "bldgappr_struct_materials.beams": firstStructMat.beams, - "bldgappr_struct_materials.truss_framing": - firstStructMat.trussFraming, - "bldgappr_struct_materials.roof": firstStructMat.roof, - "bldgappr_struct_materials.flooring": firstStructMat.flooring, - "bldgappr_struct_materials.walls": firstStructMat.walls, - "bldgappr_struct_materials.others": firstStructMat.others, - "bldgappr_struct_materials.gen_code": "5TH", - "bldgappr_property_assessment.date_created": "{{currentTimestamp}}", - "bldgappr_property_assessment.date_modified": "{{currentTimestamp}}", - "bldgappr_property_assessment.actual_use": firstAssess.actualUse, - "bldgappr_property_assessment.market_value": firstAssess.marketValue, - "bldgappr_property_assessment.assessment_level": - firstAssess.assessmentLevel, - "bldgappr_property_assessment.assessed_value": - firstAssess.assessedValue, - "bldgappr_property_assessment.taxable": firstAssess.taxable, - "bldgappr_property_assessment.exempt": firstAssess.exempt, - "bldgappr_property_assessment.qtr": firstAssess.qtr, - "bldgappr_property_assessment.yr": firstAssess.yr, - "bldgappr_property_assessment.appraisedby_name": - firstAssess.appraisedbyName, - "bldgappr_property_assessment.appraisedby_date": - DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstAssess.appraisedbyDate!)), - "bldgappr_property_assessment.recommendappr_name": - firstAssess.recommendapprName, - "bldgappr_property_assessment.recommendappr_date": - DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstAssess.recommendapprDate!)), - "bldgappr_property_assessment.approvedby_name": - firstAssess.approvedbyName, - "bldgappr_property_assessment.approvedby_date": null, - "bldgappr_property_assessment.memoranda": firstAssess.memoranda, - "bldgappr_property_assessment.swornstatement_no": - firstAssess.swornstatementNo, - "bldgappr_property_assessment.date_received": DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstAssess.dateReceived!)), - "bldgappr_property_assessment.entry_date_assessment": null, - "bldgappr_property_assessment.entry_date_by": DateFormat("yyyy-MM-dd") - .format(DateTime.parse(firstAssess.entryDateAssessment!)), - "bldgappr_property_assessment.gen_code": "5TH", - "bldgappr_rec_supersededass.date_created": "{{currentTimestamp}}", - "bldgappr_rec_supersededass.date_modified": "{{currentTimestamp}}", - "bldgappr_rec_supersededass.pin": null, - "bldgappr_rec_supersededass.tdn": null, - "bldgappr_rec_supersededass.total_assval": null, - "bldgappr_rec_supersededass.owner": null, - "bldgappr_rec_supersededass.effectivity_ass": null, - "bldgappr_rec_supersededass.page_no": null, - "bldgappr_rec_supersededass.total_marketval": null, - "bldgappr_rec_supersededass.total_area": null, - "bldgappr_rec_supersededass.rec_assessment": null, - "bldgappr_rec_supersededass.rec_taxmapping": null, - "bldgappr_rec_supersededass.rec_records": null, - "bldgappr_rec_supersededass.date": null, - "bldgappr_rec_supersededass.gen_code": "5TH" - }; - - // print(details); - - String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; - String xClientKeySecret = "unitcYqAN7GGalyz"; - Map headers = { - 'Content-Type': 'application/json; charset=UTF-8', - 'X-Client-Key': xClientKey, - 'X-Client-Secret': xClientKeySecret - }; - - Response details_response = await post( - Uri.parse( - 'http://${Url.instance.host()}/api/rptass_app/bldgappr_details/'), - headers: headers, - body: jsonEncode(details)); - - final datas = json.decode(details_response.body); - for (AdditionalItems items in addItemsList) { - final addItems = AdditionalItems( - id: 1, - bldgapprDetailsId: datas['data']['id'], - classId: items.classId, - className: items.className, - structType: items.structType, - unitValue: items.unitValue, - baseUnitValue: items.baseUnitValue, - area: items.area, - marketValue: items.marketValue, - depreciationRate: items.depreciationRate, - adjustedMarketVal: items.adjustedMarketVal, - amtDepreciation: items.amtDepreciation, - painted: items.painted, - secondhand: items.secondhand, - paintedUnitval: items.paintedUnitval, - secondhandUnitval: items.secondhandUnitval, - actualUse: items.actualUse, - genCode: "5TH"); - Response add_response = await post( - Uri.parse( - 'http://${Url.instance.host()}/api/rptass_app/additional_items/'), - headers: headers, - body: jsonEncode(addItems)); - } - 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); - print(bldgStruc.toJson()); - Response response = await post( - Uri.parse( - 'http://${Url.instance.host()}/api/rptass_app/bldgappr_structure/'), - headers: headers, - body: jsonEncode(bldgStruc)); - } - } - } - return Scaffold( body: ProgressHUD( backgroundColor: Colors.black87, indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: BlocBuilder( + child: BlocConsumer( + listener: (context, state) async { + if (state is UploadBuildingFaasLoading) { + 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 GenDescErrorState) { + // final progress = ProgressHUD.of(context); + // progress?.dismiss(); + // } + }, builder: (context, state) { if (state is PropertyInfoLoaded) { if (state.propertyInfos.isNotEmpty) { @@ -539,7 +299,9 @@ class BuildingHomeOffline extends StatelessWidget { ), label: 'Upload/Sync', onTap: () { - uploadBldg(); + context + .read() + .add(UploadBuildingFaas(offlineProfile: offlineProfile)); }, ), ]),