@@ -48,7 +48,7 @@ const getbasicdetails_sql = `SELECT
48
48
forms.panchayat,
49
49
forms.hamlet,
50
50
forms.id_type as idCardType,
51
- forms.id_number as IdCardNumber ,
51
+ forms.id_number as idCardNumber ,
52
52
forms.gender,
53
53
forms.spouse as fatherSpouse,
54
54
forms.type_of_households as householdType,
@@ -68,18 +68,20 @@ const getbasicdetails_sql = `SELECT
68
68
WHERE id = ?
69
69
` ;
70
70
71
- const getbankdetails_sql = ` SELECT
72
- bank_details.account_holder_name AS accountHolderName,
73
- bank_details.account_number AS accountNumber,
74
- bank_details.bank_name AS bankName,
75
- bank_details.branch,
76
- bank_details.ifsc_code AS ifscCode,
77
- bank_details.farmer_ack AS farmerAgreed
78
- FROM bank_details
79
- WHERE id = ?
71
+ const getbankdetails_sql = `SELECT
72
+ bank_details.account_holder_name AS accountHolderName,
73
+ bank_details.account_number AS accountNumber,
74
+ bank_details.bank_name AS bankName,
75
+ bank_details.branch,
76
+ bank_details.ifsc_code AS ifscCode,
77
+ bank_details.farmer_ack AS farmerAgreed,
78
+ forms.status AS formStatus
79
+ FROM bank_details
80
+ JOIN forms ON bank_details.form_id = forms.id
81
+ WHERE bank_details.id = ?
80
82
` ;
81
83
82
- const getlandownwershipdetails_sql = `SELECT
84
+ const getlandownwershipdetail_land_sql = `SELECT
83
85
form_lands.ownership AS landOwnershipType,
84
86
form_lands.well_irrigation AS hasWell,
85
87
form_lands.area_irrigated AS areaIrrigated,
@@ -93,6 +95,36 @@ const getbasicdetails_sql = `SELECT
93
95
form_lands.livestocks AS livestockCombined
94
96
FROM form_lands
95
97
WHERE form_id = ?` ;
98
+
99
+ const getlandownwershipdetail_pond_sql = `SELECT
100
+ ownership AS landOwnershipType,
101
+ well_irrigation AS hasWell,
102
+ area_irrigated AS areaIrrigated,
103
+ irrigated_lands AS irrigatedLandCombined,
104
+ patta AS pattaNumber,
105
+ total_area AS totalArea,
106
+ taluk,
107
+ firka,
108
+ revenue AS revenueVillage,
109
+ crop_season AS cropSeasonCombined,
110
+ livestocks AS livestockCombined
111
+ FROM farm_pond_details
112
+ WHERE form_id = ?` ;
113
+
114
+ const getlandownwershipdetail_plant_sql = ` SELECT
115
+ ownership AS landOwnershipType,
116
+ well_irrigation AS hasWell,
117
+ area_irrigated AS areaIrrigated,
118
+ irrigated_lands AS irrigatedLandCombined,
119
+ patta AS pattaNumber,
120
+ total_area AS totalArea,
121
+ taluk,
122
+ firka,
123
+ revenue AS revenueVillage,
124
+ crop_season AS cropSeasonCombined,
125
+ livestocks AS livestockCombined
126
+ FROM plantation_details
127
+ WHERE form_id = ?` ;
96
128
97
129
const getlandformdetails_sql = `SELECT
98
130
forms.created_at AS date,
@@ -153,8 +185,8 @@ const getbasicdetails_sql = `SELECT
153
185
exports . getpreviewspecificformData = asyncHandler ( async ( req , res ) => {
154
186
const id = req . query . form_id ;
155
187
const form_type = req . query . form_type ;
156
- console . log ( "Form ID" , id ) ;
157
- console . log ( "Form type" , typeof ( form_type ) ) ;
188
+ // console.log("Form ID",id);
189
+ // console.log("Form type",typeof(form_type));
158
190
const connection = await db . getConnection ( ) ;
159
191
160
192
try {
@@ -163,40 +195,54 @@ exports.getpreviewspecificformData = asyncHandler( async (req, res) => {
163
195
getbankdetails_sql ,
164
196
[ id ]
165
197
) ;
166
-
198
+ // console.log(bankDetails);
167
199
const [ [ basicDetails ] ] = await connection . execute (
168
200
getbasicdetails_sql ,
169
201
[ id ]
170
202
) ;
203
+
171
204
//fetch based on form type
172
205
let landDevelopment ;
206
+ let landOwnership ;
173
207
if ( form_type == 1 ) {
174
208
//fetch land form
175
209
[ [ landDevelopment ] ] = await connection . execute (
176
210
getlandformdetails_sql ,
177
211
[ id , form_type ]
178
212
) ;
213
+ [ [ landOwnership ] ] = await connection . execute (
214
+ getlandownwershipdetail_land_sql ,
215
+ [ id ]
216
+ ) ;
217
+ console . log ( "land:" , landOwnership ) ;
179
218
} else if ( form_type == 2 ) {
180
219
//fetch pond form
181
220
[ [ landDevelopment ] ] = await connection . execute (
182
221
getpondformdetails_sql ,
183
222
[ id , form_type ]
184
223
) ;
224
+ [ [ landOwnership ] ] = await connection . execute (
225
+ getlandownwershipdetail_pond_sql ,
226
+ [ id ]
227
+ ) ;
228
+ console . log ( "pond:" , landOwnership ) ;
185
229
} else if ( form_type == 3 ) {
186
230
//fetch plantation form
187
231
[ [ landDevelopment ] ] = await connection . execute (
188
232
getplantationformdetails_sql ,
189
233
[ id , form_type ]
190
234
) ;
191
- console . log ( landDevelopment ) ;
235
+ [ [ landOwnership ] ] = await connection . execute (
236
+ getlandownwershipdetail_plant_sql ,
237
+ [ id ]
238
+ ) ;
239
+ console . log ( "plantation:" , landOwnership ) ;
240
+ //console.log(landDevelopment);
192
241
} else {
193
242
return res . status ( 400 ) . json ( { error : 'Unknown form type' } ) ;
194
243
}
195
244
196
- const [ [ landOwnership ] ] = await connection . execute (
197
- getlandownwershipdetails_sql ,
198
- [ id ]
199
- ) ;
245
+
200
246
201
247
// 2. Fetch submitted files from separate table
202
248
// const [[submittedFiles]] = await connection.execute(
@@ -226,7 +272,7 @@ exports.getpreviewspecificformData = asyncHandler( async (req, res) => {
226
272
landDevelopment,
227
273
landOwnership
228
274
} ;
229
- console . log ( result ) ;
275
+ // console.log(result);
230
276
res . json ( result ) ;
231
277
232
278
} catch ( err ) {
0 commit comments