Subversion Repositories SmartDukaan

Rev

Rev 33909 | Rev 34107 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33507 tejus.loha 1
$(document).on('click', ".onboarding-form1", function () {
33845 tejus.loha 2
    doGetAjaxRequestHandler(`${context}/loiForm`,
33507 tejus.loha 3
        function (response) {
4
            $('#' + 'main-content').html(response);
5
        });
6
});
7
 
33577 tejus.loha 8
 
9
$(document).on('change', "#maritalStatus", function () {
10
    let maritalStatus = $(this).val();
11
    console.log("maritalStatus - " + maritalStatus);
12
    if (maritalStatus == 1) {
13
        $(".loiAnniversaryDate").removeClass('hide-model');
14
        $(".loiAnniversaryDate").addClass('show-model');
15
    } else {
16
        $(".loiAnniversaryDate").removeClass('show-model');
17
        $(".loiAnniversaryDate").addClass('hide-model');
18
    }
19
 
20
});
21
 
33578 tejus.loha 22
 
33885 tejus.loha 23
$(document).on('click', ".mk_submit_loi_form", function () {
33577 tejus.loha 24
    // Gather input values
25
    const referId = $('select[name="referId"]').val();
26
    const billingAddress = $('select[name="billingAddress"]').val();
33582 tejus.loha 27
    const acquiredDate = $('input[name="acquiredDate"]').val();
33577 tejus.loha 28
    const firstName = $('input[name="firstName"]').val();
29
    const lastName = $('input[name="lastName"]').val();
30
    const mobile = $('input[name="mobile"]').val();
33780 tejus.loha 31
 
32
    // validate email pattern
33
    const emailValue = $('input[name="email"]').val();
34
    var email;
35
    if (emailValue.length > 0) {
36
        if (isValidEmail(emailValue)) {
37
            email = emailValue;
38
        } else {
39
            alert("Please check your Email Address");
40
            return;
41
        }
42
    }
33577 tejus.loha 43
    const landline = $('input[name="landline"]').val();
44
    const dob = $('input[name="dob"]').val();
33624 tejus.loha 45
    var today = new Date();
46
    var birthDate = new Date(dob);
47
    var age = today.getFullYear() - birthDate.getFullYear();
48
    var monthDiff = today.getMonth() - birthDate.getMonth();
49
 
50
    if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
51
        age--;
52
    }
33577 tejus.loha 53
    var maritalStatus = $('select[name="maritalStatus"]').val();
54
    const anniversaryDate = $('input[name="anniversaryDate"]').val();
55
    const panNo = $('input[name="panNo"]').val();
56
    const adharNo = $('input[name="adharNo"]').val();
57
    const gstNo = $('input[name="gstNo"]').val();
58
    const bankName = $('input[name="bankName"]').val();
59
    const ifscCode = $('input[name="ifscCode"]').val();
60
    const accountNo = $('input[name="accountNo"]').val();
61
    const businessType = $('select[name="businessType"]').val();
62
    const companyName = $('input[name="companyName"]').val();
63
    const gstPin = $('input[name="gstPin"]').val();
64
    const gstState = $('input[name="gstState"]').val();
65
    const gstCity = $('input[name="gstCity"]').val();
66
    const gstDistrict = $('input[name="gstDistrict"]').val();
67
    const agreeWalletValue = $('select[name="agreeWalletValue"]').val();
68
    const storeArea = $('input[name="storeArea"]').val();
69
    const storePotential = $('input[name="storePotential"]').val();
33909 tejus.loha 70
    const finCode = $('input[name="finCode"]').val();
33658 tejus.loha 71
    let brandCommitment = [];
72
    var brandCommitmentInputs = document.querySelectorAll(".brand-commitment");
73
    brandCommitmentInputs.forEach(function (input) {
74
        var commitmentValue = parseInt(input.value);
75
        if (!isNaN(commitmentValue)) {
76
            brandCommitment.push({
77
                brandName: input.getAttribute("name"),
78
                value: commitmentValue
79
            });
80
        }
81
    });
82
    let totalCommitment = brandCommitment.reduce((total, commitment) => total + commitment.value, 0);
83
    console.log("Total Commitment Amount:", totalCommitment);
33577 tejus.loha 84
    const lessCommitReason = $('input[name="lessCommitReason"]').val();
33658 tejus.loha 85
    let minCommit = totalCommitment >= storePotential * (70 / 100);
33577 tejus.loha 86
    const agreedBrandFees = $('select[name="agreedBrandFees"]').val();
87
    console.log("agreedBrandFees - ", agreedBrandFees);
33624 tejus.loha 88
    const values = agreedBrandFees.split(/[-]/); // Split the string
89
    const brandFee = parseFloat(values[1]);
33577 tejus.loha 90
    const brandFeesCollected = $('input[name="brandFeesCollected"]').val();
91
    const paymentMode = $('select[name="paymentMode"]').val();
92
    const paymentReferenceNo = $('input[name="paymentReferenceNo"]').val();
33578 tejus.loha 93
    const feeCollectingDate = $('input[name="feeCollectingDate"]').val();
33885 tejus.loha 94
    const paymentAttachment = $('input[name="paymentAttachment"]').val();
33577 tejus.loha 95
 
96
    let missingFields = [];
97
    if (!firstName) missingFields.push('First Name');
98
    if (!lastName) missingFields.push('Last Name');
99
    if (mobile.length < 10 || !mobile) {
100
        missingFields.push('Mobile number should be 10 digit');
101
    }
33658 tejus.loha 102
    if (!minCommit) {
33577 tejus.loha 103
        if (!lessCommitReason) missingFields.push('Less Commit Reason');
104
    }
105
    if (!maritalStatus) missingFields.push('Marital Status');
106
    if (maritalStatus == 1) {
107
        if (!anniversaryDate) missingFields.push('Anniversary Date');
108
    }
109
    if (!email) missingFields.push('Email');
33582 tejus.loha 110
    if (!acquiredDate) missingFields.push('Acquired date');
33577 tejus.loha 111
    if (!dob) missingFields.push('dob(Date of Birth)');
33624 tejus.loha 112
    if (age <= 18) missingFields.push('You must be at least 18 years old to Fill LOI FORM. ');
33577 tejus.loha 113
    if (!panNo) missingFields.push('Pan Number');
114
    if (!adharNo) missingFields.push('Aadhar Number');
115
    if (!gstNo) missingFields.push('GST Number');
116
    if (!bankName) missingFields.push('Bank Name');
117
    if (!ifscCode) missingFields.push('IFSC code');
118
    if (!accountNo) missingFields.push('Account Number');
119
    if (!businessType) missingFields.push('businessType');
120
    if (!companyName) missingFields.push('Company Name');
121
    if (!agreeWalletValue) missingFields.push('Agree Wallet Value');
122
    if (!storeArea) missingFields.push('storeArea');
123
    if (!storePotential) missingFields.push('Store Potential');
124
    if (!agreedBrandFees) missingFields.push('Agreed Brand Fees');
125
    if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
33845 tejus.loha 126
    if (brandFeesCollected > brandFee) missingFields.push('The collected brand fee must not exceed the agreed brand fees.');
33577 tejus.loha 127
    if (!paymentMode) missingFields.push('Payment Mode');
128
    if (!paymentReferenceNo) missingFields.push('Payment Reference No');
33578 tejus.loha 129
    if (!feeCollectingDate) missingFields.push('Fee Collecting Date');
33885 tejus.loha 130
    if (!paymentAttachment) missingFields.push('Payment screenshot ');
33577 tejus.loha 131
    if (missingFields.length > 0) {
132
        alert('The following fields are required: ' + missingFields.join(', '));
133
        return;
134
    }
135
    const loiFormData = {
136
        referId: referId,
137
        businessType: businessType,
33582 tejus.loha 138
        acquiredDate: acquiredDate,
33577 tejus.loha 139
        firstName: firstName,
140
        lastName: lastName,
141
        mobile: mobile,
142
        email: email,
143
        landline: landline,
144
        dob: dob,
145
        anniversaryDate: anniversaryDate,
146
        panNo: panNo,
147
        adharNo: adharNo,
148
        gstNo: gstNo,
149
        bankName: bankName,
150
        ifscCode: ifscCode,
151
        accountNo: accountNo,
152
        companyName: companyName,
153
        gstPin: gstPin,
154
        gstState: gstState,
155
        gstCity: gstCity,
156
        gstDistrict: gstDistrict,
157
        agreeWalletValue: agreeWalletValue,
158
        storeArea: storeArea,
159
        storePotential: storePotential,
33909 tejus.loha 160
        financeCode: finCode,
33577 tejus.loha 161
        lessCommitReason: lessCommitReason,
162
        agreedBrandFees: agreedBrandFees,
163
        brandFeesCollected: brandFeesCollected,
164
        paymentMode: paymentMode,
165
        paymentReferenceNo: paymentReferenceNo,
33578 tejus.loha 166
        feeCollectingTimeStamp: feeCollectingDate,
33885 tejus.loha 167
        paymentAttachment: paymentAttachment,
33658 tejus.loha 168
        billingAddress: billingAddress,
169
        brandCommitment: brandCommitment
33577 tejus.loha 170
    };
33658 tejus.loha 171
 
33577 tejus.loha 172
    console.log("form data - ", loiFormData);
173
    if (confirm("Are you sure to submit the form ?")) {
174
        doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, JSON.stringify(loiFormData), function (response) {
175
            console.log('responsee', response);
33507 tejus.loha 176
            if (response) {
177
                alert("Your LOI form Submitted successfully ");
178
                pendingLoiForm("main-content");
179
 
180
            } else {
181
                alert("Your LOI form not Submitted , try again ");
33845 tejus.loha 182
                doGetAjaxRequestHandler(`${context}/loiForm`,
33507 tejus.loha 183
                    function (response) {
184
                        $('#' + 'main-content').html(response);
185
                    });
186
            }
187
        });
188
    }
189
});
33578 tejus.loha 190
 
33658 tejus.loha 191
$(document).on('click', ".updateLoiForm", function () {
33507 tejus.loha 192
    let loiId = $(this).val();
193
    console.log("form id - ", loiId);
33658 tejus.loha 194
    doGetAjaxRequestHandler(context + "/updateLoiForm?loiId=" + loiId,
33507 tejus.loha 195
        function (response) {
196
            $('#' + 'main-content').html(response);
197
        });
198
});
33879 tejus.loha 199
 
33710 tejus.loha 200
$(document).on('click', ".save_agree_brand_fee", function () {
201
    let loiId = $(this).val();
202
    var $tr = $(this).closest('tr');
203
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
34085 tejus.loha 204
    var brandType = $tr.find('select[name="brandType"]').val();
205
    console.log('brandType ', brandType);
33710 tejus.loha 206
    if (confirm("Are you sure to change Agreed brand fee")) {
34085 tejus.loha 207
        doPutAjaxRequestHandler(`${context}/updateAgreedBrandFee?loiId=${loiId}&brandFee=${agreedBrandFee}&storeType=${brandType}`, function (response) {
33710 tejus.loha 208
            pendingLoiForm("main-content");
209
        });
210
    } else {
211
        pendingLoiForm("main-content");
212
    }
213
});
33507 tejus.loha 214
 
33658 tejus.loha 215
$(document).on('click', ".updateLoiFormDataButton", function () {
216
    console.log("updateLoiFormDataButton clicked..");
217
    let loiId = $(this).data('loiid');
218
    const firstName = $('input[name="firstName"]').val();
219
    const lastName = $('input[name="lastName"]').val();
220
    const mobile = $('input[name="mobile"]').val();
221
    const email = $('input[name="email"]').val();
222
    const landline = $('input[name="landline"]').val();
223
    const dob = $('input[name="dob"]').val();
224
    const panNo = $('input[name="panNo"]').val();
225
    const adharNo = $('input[name="adharNo"]').val();
226
    let missingFields = [];
227
    if (!firstName) missingFields.push('First Name');
228
    if (!lastName) missingFields.push('Last Name');
229
    if (mobile.length < 10 || !mobile) {
230
        missingFields.push('Mobile number should be 10 digit');
231
    }
232
    if (!dob) missingFields.push('dob(Date of Birth)');
233
    if (!panNo) missingFields.push('Pan Number');
234
    if (!adharNo) missingFields.push('Aadhar Number');
235
    if (!email) missingFields.push('Email');
236
    if (missingFields.length > 0) {
237
        alert('The following fields are required: ' + missingFields.join(', '));
238
        return;
239
    }
240
    const loiFormData = {
241
        firstName: firstName,
242
        lastName: lastName,
243
        mobile: mobile,
244
        email: email,
245
        landline: landline,
246
        dob: dob,
247
        panNo: panNo,
248
        adharNo: adharNo
249
    };
250
    console.log("loiFormData - ", loiFormData);
251
    alert("you want update ..");
252
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=${loiId}`, JSON.stringify(loiFormData), function (response) {
33507 tejus.loha 253
        pendingLoiForm("main-content");
254
    });
255
 
256
});
257
 
258
$(document).on('click', ".pending-onboarding-form", function () {
33710 tejus.loha 259
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 260
        function (response) {
261
            $('#' + 'main-content').html(response);
262
        });
263
});
264
$(document).on('click', "#addBrandFeePayment", function () {
265
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
266
    let loiId = $(this).val();
267
    console.log("form id -", loiId);
268
    for (var key in formData) {
269
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
270
            alert("The (" + key + ") value is blank please fill this field !");
271
            return false;
272
        }
273
    }
274
    let jsonData = JSON.stringify(formData);
33658 tejus.loha 275
    if (confirm("Are you sure to add payment ?")) {
33525 tejus.loha 276
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
277
            if (response) {
278
                alert("Payment add successfully...");
279
                pendingLoiForm("main-content");
33507 tejus.loha 280
 
33525 tejus.loha 281
            }
282
        });
283
    } else {
33658 tejus.loha 284
        alert("Payment is not add.");
285
 
33525 tejus.loha 286
    }
33507 tejus.loha 287
 
288
});
289
 
290
$(document).on('click', ".generateLoi", function () {
291
    let loiId = $(this).val();
292
    console.log("form id - ", loiId);
293
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
294
        function (response) {
295
            $('#' + 'main-content').html(response);
296
        });
297
});
298
 
34085 tejus.loha 299
// $(document).on('change', 'select[name="pageSize"]', function () {
300
//     let pageSize = $(this).val();
301
//     console.log("pageSize - ", pageSize);
302
//     doGetAjaxRequestHandler(`${context}/pendingLoiForm?pageSize=${pageSize}&pageNumber=${1}`,
303
//         function (response) {
304
//             $('#' + 'main-content').html(response);
305
//         });
306
// });
307
 
33845 tejus.loha 308
$(document).on('click', ".mk-approve-loi", function () {
309
    let loiId = $(this).val();
310
    let companyName = $(this).data('company');
311
    let flag = $(this).data('flag');
312
    console.log("form id - ", loiId);
313
    if (flag === 1) {
314
        if (confirm(`Are you sure Approve Loi of  ${companyName} `)) {
315
            console.log("Approval");
316
            doPutAjaxRequestHandler(`${context}/approve-reject-Loi?loiId=${loiId}&flag=${true}`,
317
                function (response) {
318
                    alert("Loi Approved successfully");
319
                    pendingLoiForm("main-content");
320
                });
321
        }
322
    } else {
323
        if (confirm(`Are you sure to Reject "${companyName}" LOI`)) {
324
            console.log("reject");
325
            doPutAjaxRequestHandler(`${context}/approve-reject-Loi?loiId=${loiId}&flag=${false}`,
326
                function (response) {
327
                    pendingLoiForm("main-content");
328
                });
329
        }
330
    }
331
});
332
 
33507 tejus.loha 333
$(document).on('click', "#LOI_otp", function () {
334
    let loiId = $(this).val();
335
    console.log("loiId-", loiId);
33577 tejus.loha 336
    if (confirm("Are you sure to send OTP ?")) {
337
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
338
            function (response) {
339
                alert(response);
340
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
341
                    function (response) {
342
                        $('#' + 'main-content').html(response);
343
                    });
344
            });
345
    } else {
346
        alert("OTP not send .");
347
    }
348
 
33507 tejus.loha 349
});
350
 
351
//confirmPayment
33525 tejus.loha 352
$(document).on('click', ".paymentConfirmBtn", function () {
353
    let approval = $(this).data('approval');
33507 tejus.loha 354
    let bfcId = $(this).val();
33525 tejus.loha 355
    let description = "All details are correct";
356
    if (confirm("Are you sure to confirm this payment ?")) {
357
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
358
            function (response) {
33845 tejus.loha 359
                alert("Payment is confirm successfully");
33525 tejus.loha 360
                pendingLoiForm("main-content");
361
            });
362
    }
363
});
364
 
365
$(document).on('click', ".paymentRejectBtn", function () {
33507 tejus.loha 366
    let approval = $(this).data('approval');
33525 tejus.loha 367
    let bfcId = $(this).val();
368
    let description;
369
    description = prompt("Reason for rejection..");
370
    if (description !== null) {
371
        if (confirm("Are you sure to Reject this payment ?")) {
372
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
373
                function (response) {
33845 tejus.loha 374
                    alert("Payment is rejected successfully");
33525 tejus.loha 375
                    pendingLoiForm("main-content");
376
                });
377
        }
378
    } else {
379
        alert("Please mention the reason as description and try again");
380
    }
33507 tejus.loha 381
});
382
$(document).on('click', ".upload-document-form", function () {
383
    let loiId = $(this).val();
33617 tejus.loha 384
    doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 385
        function (response) {
386
            $('#' + 'main-content').html(response);
387
        });
388
});
389
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
390
    if (confirm('Confirm file upload ?')) {
391
        var fileSelector = $(this)[0];
392
        if (fileSelector != undefined
393
            && fileSelector.files[0] != undefined) {
394
            var file = this.files[0];
395
            console.log("file", file);
396
            let fileInput = $(this);
397
            console.log("fileInput", file);
398
            uploadDocument(file, function (documentId) {
399
                console.log("documentIdzzz  : ", documentId);
400
                fileInput.closest('td').find(".documentId").val(documentId);
401
            });
402
        }
403
    }
404
});
33885 tejus.loha 405
 
406
$(document).on('input', 'table#OnboardingDocumentTable input[type=file],table#mk_brand-fee-collection-details input[type=file]', function () {
407
    if (confirm('Confirm file upload ?')) {
408
        var fileSelector = $(this)[0];
409
        if (fileSelector != undefined
410
            && fileSelector.files[0] != undefined) {
411
            var file = this.files[0];
412
            console.log("file", file);
413
            let fileInput = $(this);
414
            console.log("fileInput", file);
415
            uploadDocument(file, function (documentId) {
416
                console.log("documentIdzzz  : ", documentId);
417
                fileInput.closest('td').find(".documentId").val(documentId);
418
            });
419
        }
420
    }
421
});
422
 
423
$(document).on('input', '#payment-sc-doc', function () {
424
    if (confirm('Confirm file upload ?')) {
425
        var file = this.files[0];
426
        uploadDocument(file, function (documentId) {
427
            $('#payment-sc-docId').val(documentId);
428
        });
429
    }
430
});
431
 
432
 
33507 tejus.loha 433
$(document).on('click', ".mk_docApproval", function () {
434
    let loiId = $(this).data('form_id');
435
    let docMasterId = $(this).data('doc_master_id');
436
    let flag = $(this).data('flag');
437
    console.log("flag -", flag);
438
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
439
        function (response) {
440
            alert(response);
33617 tejus.loha 441
            doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 442
                function (response) {
443
                    $('#' + 'main-content').html(response);
444
                });
445
 
446
        });
447
});
448
$(document).on('click', "#uploadDocumentbtn1", function () {
449
    if (confirm("Are you sure to upload all documents ?")) {
450
        var loiId = $(this).val();
451
        var loiDocModels = [];
452
        console.log("loiId -", loiId);
453
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
454
            var marsterId = $(this).find(".masterId").val();
455
            var docId = $(this).find(".documentId").val();
456
            var docName = $(this).find(".documentName").val();
457
            console.log("marsterId -", marsterId);
458
            var loiDocModel = {
459
                documentId: docId,
460
                documentName: docName,
461
                documentMasterId: marsterId
462
            };
463
            loiDocModels.push(loiDocModel);
464
        });
465
        console.log(loiDocModels);
466
        var loiDocModelData = JSON.stringify(loiDocModels);
467
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
468
            console.log('response-', response);
469
            pendingLoiForm("main-content");
470
        });
471
    } else {
472
        //Nothing to do
473
    }
474
 
475
 
476
});
477
 
478
$(document).on('click', ".CompletedLoiForm", function () {
33617 tejus.loha 479
    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 480
        function (response) {
481
            $('#' + 'main-content').html(response);
482
        });
483
});
484
 
485
$(document).on('click', "#createNewOnboardingPanel", function () {
486
    let loiId = $(this).val();
33710 tejus.loha 487
    //let authId = $(this).closest('tr').find('.authId').val();
33507 tejus.loha 488
 
33710 tejus.loha 489
    if (true) {
490
 
491
        doPostAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${0}`,
33507 tejus.loha 492
            function (response) {
493
                if (response) {
33710 tejus.loha 494
                    // doGetAjaxRequestHandler(`${context}/completedLoiForms`,
495
                    //     function (response) {
496
                    //         $('#' + 'main-content').html(response);
497
                    //     });
498
                    alert("it moved successfully ");
33507 tejus.loha 499
                } else {
500
                    //nothing
501
                }
502
 
503
            });
504
    } else {
505
        alert("Please choose RBM ");
506
    }
507
 
508
});
509
 
33617 tejus.loha 510
$(document).on('click', "#downloadAllLoiForm", function () {
511
    const from = $('input[name="from"]').val();
512
    const to = $('input[name="to"]').val();
513
    let missingFields = [];
514
    if (!from) missingFields.push('From date');
515
    if (!to) missingFields.push('To date');
516
    if (missingFields.length > 0) {
517
        alert('Please select : ' + missingFields.join(','));
518
        return;
519
    }
520
    console.log("From - ", from)
521
    console.log("To - ", to)
522
 
523
    window.location.href = `${context}/downloadLoiFromReport?from=${from}&to=${to}`;
524
});
33658 tejus.loha 525
$(document).on('click', ".brandFeePaymentEdit", function () {
526
    var bfcId = $(this).val();
527
    console.log("bfcId - ", bfcId);
528
    // Get the table row
529
    var $row = $(this).closest('tr');
530
    console.log("row - ", $row);
531
    var feeCollectingTimeStamp = $row.find('input[name="feeCollectingTimeStamp"]').val();
532
    var collectedAmount = $row.find('input[name="collectedAmount"]').val();
533
    var paymentReferenceNo = $row.find('input[name="paymentReferenceNo"]').val();
534
    var paymentMode = $row.find('select[name="paymentMode"]').val();
33885 tejus.loha 535
    var documentId = $row.find('input[name="documentId"]').val();
536
 
33658 tejus.loha 537
    const Data = {
538
        id: bfcId,
539
        feeCollectingTimeStamp: feeCollectingTimeStamp,
540
        collectedAmount: collectedAmount,
541
        paymentReferenceNo: paymentReferenceNo,
33885 tejus.loha 542
        attachment: documentId,
33658 tejus.loha 543
        paymentMode: paymentMode
544
    };
545
    var jsonData = JSON.stringify(Data);
546
    if (confirm("Are you sure to update details")) {
547
        doPostAjaxRequestWithJsonHandler(`${context}/updatePayment`, jsonData,
548
            function (response) {
33845 tejus.loha 549
                if (response) {
550
                    alert("Updated payment details are save successfully ")
551
                    pendingLoiForm('main-content');
552
                } else {
553
                    alert("Updated payment details are not save ")
554
                    pendingLoiForm('main-content');
555
                }
33658 tejus.loha 556
            });
557
    } else {
558
        pendingLoiForm('main-content');
559
    }
33617 tejus.loha 560
 
33658 tejus.loha 561
 
562
});
33879 tejus.loha 563
/*function validateOTP() {
564
    while (true) {
565
        let otp = prompt("Enter received OTP here");
566
        if (otp === null) {
567
            alert('OTP entry was cancelled. Try again.');
568
            return null;
569
        }
570
        let regex = /^[0-9]{5}$/;
571
        if (regex.test(otp)) {
572
            console.log('otp-flag-', otp);
573
            return otp;  // Return valid OTP
574
        } else {
575
            alert('Please enter a valid 5-digit numeric OTP');
576
        }
577
    }
578
}*/
33658 tejus.loha 579
 
33879 tejus.loha 580
$(document).on('click', "#confirmSign", function () {
581
    let loiId = $(this).val();
582
    // let otp = validateOTP();
583
    let otp = prompt("Enter received OTP here");
584
    console.log("loiId-", loiId, ",otp-", otp);
585
    let validateOtpUrl = `${context}/validateLoiOtp?loiId=${loiId}&provideOtp=${otp}`;
586
    if (otp != undefined || otp != null) {
33658 tejus.loha 587
 
33879 tejus.loha 588
        doPutAjaxRequestHandler(validateOtpUrl, function (response) {
589
            if (response) {
590
                const element = document.getElementById('loiPDF_content');
591
                console.log("element- ", element);
592
                const opt = {
593
                    margin: 0.5,
594
                    filename: 'document.pdf',
595
                    image: {type: 'jpeg', quality: 0.98},
596
                    html2canvas: {scale: 2, logging: true, useCORS: true},
597
                    jsPDF: {unit: 'in', format: 'letter', orientation: 'portrait'}
598
                };
599
                html2pdf().from(element).set(opt).outputPdf("arraybuffer").then(function (pdf) {
600
                    console.log("pdf- ", pdf);
601
                    const file = new Blob([pdf], {type: 'application/pdf'});
602
                    uploadDocument(file, function (documentId) {
603
                        console.log("documentIdddd-", documentId);
604
                        IdempotencyKey = uuidv4();
605
                        if (documentId > 0) {
606
                            saveLoiDoc(loiId, documentId);
607
                        } else {
608
                            alert("Something went wrong , please again to confirm otp")
609
                        }
610
                    });
611
                });
612
            }
613
        });
614
    } else {
615
        return false
616
    }
617
});
618
 
619
 
620
function saveLoiDoc(loiId, documentId) {
621
    let saveLoiDocUrl = `${context}/saveLoiDoc?loiId=` + loiId + `&loiDocId=` + documentId
622
    doPostAjaxRequestHandler(saveLoiDocUrl, function (response) {
623
        if (response) {
624
            alert("LOI has been signed successfully and sent to the registered email. Please check your email.");
625
            pendingLoiForm("main-content");
626
        } else {
627
            alert("Something went wrong , Please try again to generate Loi and Validate otp");
628
        }
629
    });
630
}
631
 
632
 
33507 tejus.loha 633
function pendingLoiForm(domId) {
33710 tejus.loha 634
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 635
        function (response) {
636
            $('#' + domId).html(response);
637
        });
638
}
34085 tejus.loha 639
 
640
/*
641
function createPagination(containerId, totalPages, currentPage = 1, onPageChange = null) {
642
    const $container = $('#' + containerId);
643
    $container.empty(); // Clear the container
644
 
645
    // Helper Function to Render Pagination
646
    function renderPagination(currentPage) {
647
        $container.empty();
648
 
649
        // Previous Button
650
        const $prevButton = $('<button>')
651
            .text('Previous')
652
            .click(() => handlePageChange(currentPage > 1 ? currentPage - 1 : totalPages)); // Loop to last page if on the first page
653
        $container.append($prevButton);
654
 
655
        // First Page
656
        const $firstPageButton = $('<button>')
657
            .text('1')
658
            .addClass(currentPage === 1 ? 'active' : '')
659
            .click(() => handlePageChange(1));
660
        $container.append($firstPageButton);
661
 
662
        // Ellipsis Before Current Pages
663
        if (currentPage > 3) {
664
            $container.append($('<span>').text('...'));
665
        }
666
 
667
        // Dynamic Pages Around Current Page
668
        for (let i = Math.max(2, currentPage - 1); i <= Math.min(totalPages - 1, currentPage + 1); i++) {
669
            const $pageButton = $('<button>')
670
                .text(i)
671
                .addClass(currentPage === i ? 'active' : '')
672
                .click(() => handlePageChange(i));
673
            $container.append($pageButton);
674
        }
675
 
676
        // Ellipsis Before Last Page
677
        if (currentPage < totalPages - 2) {
678
            $container.append($('<span>').text('...'));
679
        }
680
 
681
        // Last Page
682
        if (totalPages > 1) {
683
            const $lastPageButton = $('<button>')
684
                .text(totalPages)
685
                .addClass(currentPage === totalPages ? 'active' : '')
686
                .click(() => handlePageChange(totalPages));
687
            $container.append($lastPageButton);
688
        }
689
 
690
        // Next Button
691
        const $nextButton = $('<button>')
692
            .text('Next')
693
            .click(() => handlePageChange(currentPage < totalPages ? currentPage + 1 : 1)); // Loop to first page if on the last page
694
        $container.append($nextButton);
695
    }
696
 
697
    // Handle Page Change
698
    function handlePageChange(selectedPage) {
699
        if (onPageChange) {
700
            onPageChange(selectedPage); // Trigger the callback with the selected page
701
        }
702
        renderPagination(selectedPage); // Re-render pagination
703
    }
704
 
705
    // Initial Render
706
    renderPagination(currentPage);
707
}*/