Subversion Repositories SmartDukaan

Rev

Rev 33845 | Rev 33885 | 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
 
33577 tejus.loha 23
$(document).on('click', ".submitLoiForm", function () {
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();
33658 tejus.loha 70
    let brandCommitment = [];
71
    var brandCommitmentInputs = document.querySelectorAll(".brand-commitment");
72
    brandCommitmentInputs.forEach(function (input) {
73
        var commitmentValue = parseInt(input.value);
74
        if (!isNaN(commitmentValue)) {
75
            brandCommitment.push({
76
                brandName: input.getAttribute("name"),
77
                value: commitmentValue
78
            });
79
        }
80
    });
81
    let totalCommitment = brandCommitment.reduce((total, commitment) => total + commitment.value, 0);
82
    console.log("Total Commitment Amount:", totalCommitment);
33577 tejus.loha 83
    const lessCommitReason = $('input[name="lessCommitReason"]').val();
33658 tejus.loha 84
    let minCommit = totalCommitment >= storePotential * (70 / 100);
33577 tejus.loha 85
    const agreedBrandFees = $('select[name="agreedBrandFees"]').val();
86
    console.log("agreedBrandFees - ", agreedBrandFees);
33624 tejus.loha 87
    const values = agreedBrandFees.split(/[-]/); // Split the string
88
    const brandFee = parseFloat(values[1]);
33577 tejus.loha 89
    const brandFeesCollected = $('input[name="brandFeesCollected"]').val();
90
    const paymentMode = $('select[name="paymentMode"]').val();
91
    const paymentReferenceNo = $('input[name="paymentReferenceNo"]').val();
33578 tejus.loha 92
    const feeCollectingDate = $('input[name="feeCollectingDate"]').val();
33577 tejus.loha 93
 
94
    let missingFields = [];
95
    if (!firstName) missingFields.push('First Name');
96
    if (!lastName) missingFields.push('Last Name');
97
    if (mobile.length < 10 || !mobile) {
98
        missingFields.push('Mobile number should be 10 digit');
99
    }
33658 tejus.loha 100
    if (!minCommit) {
33577 tejus.loha 101
        if (!lessCommitReason) missingFields.push('Less Commit Reason');
102
    }
103
    if (!maritalStatus) missingFields.push('Marital Status');
104
    if (maritalStatus == 1) {
105
        if (!anniversaryDate) missingFields.push('Anniversary Date');
106
    }
107
    if (!email) missingFields.push('Email');
33582 tejus.loha 108
    if (!acquiredDate) missingFields.push('Acquired date');
33577 tejus.loha 109
    if (!dob) missingFields.push('dob(Date of Birth)');
33624 tejus.loha 110
    if (age <= 18) missingFields.push('You must be at least 18 years old to Fill LOI FORM. ');
33577 tejus.loha 111
    if (!panNo) missingFields.push('Pan Number');
112
    if (!adharNo) missingFields.push('Aadhar Number');
113
    if (!gstNo) missingFields.push('GST Number');
114
    if (!bankName) missingFields.push('Bank Name');
115
    if (!ifscCode) missingFields.push('IFSC code');
116
    if (!accountNo) missingFields.push('Account Number');
117
    if (!businessType) missingFields.push('businessType');
118
    if (!companyName) missingFields.push('Company Name');
119
    if (!agreeWalletValue) missingFields.push('Agree Wallet Value');
120
    if (!storeArea) missingFields.push('storeArea');
121
    if (!storePotential) missingFields.push('Store Potential');
122
    if (!agreedBrandFees) missingFields.push('Agreed Brand Fees');
123
    if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
33845 tejus.loha 124
    if (brandFeesCollected > brandFee) missingFields.push('The collected brand fee must not exceed the agreed brand fees.');
33577 tejus.loha 125
    if (!paymentMode) missingFields.push('Payment Mode');
126
    if (!paymentReferenceNo) missingFields.push('Payment Reference No');
33578 tejus.loha 127
    if (!feeCollectingDate) missingFields.push('Fee Collecting Date');
33577 tejus.loha 128
    if (missingFields.length > 0) {
129
        alert('The following fields are required: ' + missingFields.join(', '));
130
        return;
131
    }
132
    const loiFormData = {
133
        referId: referId,
134
        businessType: businessType,
33582 tejus.loha 135
        acquiredDate: acquiredDate,
33577 tejus.loha 136
        firstName: firstName,
137
        lastName: lastName,
138
        mobile: mobile,
139
        email: email,
140
        landline: landline,
141
        dob: dob,
142
        anniversaryDate: anniversaryDate,
143
        panNo: panNo,
144
        adharNo: adharNo,
145
        gstNo: gstNo,
146
        bankName: bankName,
147
        ifscCode: ifscCode,
148
        accountNo: accountNo,
149
        companyName: companyName,
150
        gstPin: gstPin,
151
        gstState: gstState,
152
        gstCity: gstCity,
153
        gstDistrict: gstDistrict,
154
        agreeWalletValue: agreeWalletValue,
155
        storeArea: storeArea,
156
        storePotential: storePotential,
157
        lessCommitReason: lessCommitReason,
158
        agreedBrandFees: agreedBrandFees,
159
        brandFeesCollected: brandFeesCollected,
160
        paymentMode: paymentMode,
161
        paymentReferenceNo: paymentReferenceNo,
33578 tejus.loha 162
        feeCollectingTimeStamp: feeCollectingDate,
33658 tejus.loha 163
        billingAddress: billingAddress,
164
        brandCommitment: brandCommitment
33577 tejus.loha 165
    };
33658 tejus.loha 166
 
33577 tejus.loha 167
    console.log("form data - ", loiFormData);
168
    if (confirm("Are you sure to submit the form ?")) {
169
        doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, JSON.stringify(loiFormData), function (response) {
170
            console.log('responsee', response);
33507 tejus.loha 171
            if (response) {
172
                alert("Your LOI form Submitted successfully ");
173
                pendingLoiForm("main-content");
174
 
175
            } else {
176
                alert("Your LOI form not Submitted , try again ");
33845 tejus.loha 177
                doGetAjaxRequestHandler(`${context}/loiForm`,
33507 tejus.loha 178
                    function (response) {
179
                        $('#' + 'main-content').html(response);
180
                    });
181
            }
182
        });
183
    }
184
});
33578 tejus.loha 185
 
33658 tejus.loha 186
$(document).on('click', ".updateLoiForm", function () {
33507 tejus.loha 187
    let loiId = $(this).val();
188
    console.log("form id - ", loiId);
33658 tejus.loha 189
    doGetAjaxRequestHandler(context + "/updateLoiForm?loiId=" + loiId,
33507 tejus.loha 190
        function (response) {
191
            $('#' + 'main-content').html(response);
192
        });
193
});
33879 tejus.loha 194
 
33710 tejus.loha 195
$(document).on('click', ".save_agree_brand_fee", function () {
196
    let loiId = $(this).val();
197
    var $tr = $(this).closest('tr');
198
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
199
    if (confirm("Are you sure to change Agreed brand fee")) {
200
        doPutAjaxRequestHandler(`${context}/updateAgreedBrandFee?loiId=${loiId}&brandFee=${agreedBrandFee}`, function (response) {
201
            pendingLoiForm("main-content");
202
        });
203
    } else {
204
        pendingLoiForm("main-content");
205
    }
206
});
33507 tejus.loha 207
 
33658 tejus.loha 208
$(document).on('click', ".updateLoiFormDataButton", function () {
209
    console.log("updateLoiFormDataButton clicked..");
210
    let loiId = $(this).data('loiid');
211
 
212
    const firstName = $('input[name="firstName"]').val();
213
    const lastName = $('input[name="lastName"]').val();
214
    const mobile = $('input[name="mobile"]').val();
215
    const email = $('input[name="email"]').val();
216
    const landline = $('input[name="landline"]').val();
217
    const dob = $('input[name="dob"]').val();
218
    const panNo = $('input[name="panNo"]').val();
219
    const adharNo = $('input[name="adharNo"]').val();
220
    let missingFields = [];
221
    if (!firstName) missingFields.push('First Name');
222
    if (!lastName) missingFields.push('Last Name');
223
    if (mobile.length < 10 || !mobile) {
224
        missingFields.push('Mobile number should be 10 digit');
225
    }
226
    if (!dob) missingFields.push('dob(Date of Birth)');
227
    if (!panNo) missingFields.push('Pan Number');
228
    if (!adharNo) missingFields.push('Aadhar Number');
229
    if (!email) missingFields.push('Email');
230
    if (missingFields.length > 0) {
231
        alert('The following fields are required: ' + missingFields.join(', '));
232
        return;
233
    }
234
    const loiFormData = {
235
        firstName: firstName,
236
        lastName: lastName,
237
        mobile: mobile,
238
        email: email,
239
        landline: landline,
240
        dob: dob,
241
        panNo: panNo,
242
        adharNo: adharNo
243
    };
244
    console.log("loiFormData - ", loiFormData);
245
    alert("you want update ..");
246
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=${loiId}`, JSON.stringify(loiFormData), function (response) {
33507 tejus.loha 247
        pendingLoiForm("main-content");
248
    });
249
 
250
});
251
 
252
$(document).on('click', ".pending-onboarding-form", function () {
33710 tejus.loha 253
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 254
        function (response) {
255
            $('#' + 'main-content').html(response);
256
        });
257
});
258
$(document).on('click', "#addBrandFeePayment", function () {
259
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
260
    let loiId = $(this).val();
261
    console.log("form id -", loiId);
262
    for (var key in formData) {
263
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
264
            alert("The (" + key + ") value is blank please fill this field !");
265
            return false;
266
        }
267
    }
268
    let jsonData = JSON.stringify(formData);
33658 tejus.loha 269
    if (confirm("Are you sure to add payment ?")) {
33525 tejus.loha 270
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
271
            if (response) {
272
                alert("Payment add successfully...");
273
                pendingLoiForm("main-content");
33507 tejus.loha 274
 
33525 tejus.loha 275
            }
276
        });
277
    } else {
33658 tejus.loha 278
        alert("Payment is not add.");
279
 
33525 tejus.loha 280
    }
33507 tejus.loha 281
 
282
});
283
 
284
$(document).on('click', ".generateLoi", function () {
285
    let loiId = $(this).val();
286
    console.log("form id - ", loiId);
287
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
288
        function (response) {
289
            $('#' + 'main-content').html(response);
290
        });
291
});
292
 
33845 tejus.loha 293
$(document).on('click', ".mk-approve-loi", function () {
294
    let loiId = $(this).val();
295
    let companyName = $(this).data('company');
296
    let flag = $(this).data('flag');
297
    console.log("form id - ", loiId);
298
    if (flag === 1) {
299
        if (confirm(`Are you sure Approve Loi of  ${companyName} `)) {
300
            console.log("Approval");
301
            doPutAjaxRequestHandler(`${context}/approve-reject-Loi?loiId=${loiId}&flag=${true}`,
302
                function (response) {
303
                    alert("Loi Approved successfully");
304
                    pendingLoiForm("main-content");
305
                });
306
        }
307
    } else {
308
        if (confirm(`Are you sure to Reject "${companyName}" LOI`)) {
309
            console.log("reject");
310
            doPutAjaxRequestHandler(`${context}/approve-reject-Loi?loiId=${loiId}&flag=${false}`,
311
                function (response) {
312
                    pendingLoiForm("main-content");
313
                });
314
        }
315
    }
316
});
317
 
33507 tejus.loha 318
$(document).on('click', "#LOI_otp", function () {
319
    let loiId = $(this).val();
320
    console.log("loiId-", loiId);
33577 tejus.loha 321
    if (confirm("Are you sure to send OTP ?")) {
322
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
323
            function (response) {
324
                alert(response);
325
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
326
                    function (response) {
327
                        $('#' + 'main-content').html(response);
328
                    });
329
            });
330
    } else {
331
        alert("OTP not send .");
332
    }
333
 
33507 tejus.loha 334
});
335
 
336
 
337
$(document).on('click', ".onboardingFormDone", function () {
338
    let loiId = $(this).val();
339
    var loi = $(document).find(".upload-form-loi input[type=file]").val();
340
    console.log("form id - ", loiId);
341
    doPostAjaxRequestHandler(`${context}/uploadLoi?loiId=${loiId}&loi=${loi}`,
342
        function (response) {
343
            $('#' + 'main-content').html(response);
344
        });
345
});
346
 
347
//confirmPayment
33525 tejus.loha 348
$(document).on('click', ".paymentConfirmBtn", function () {
349
    let approval = $(this).data('approval');
33507 tejus.loha 350
    let bfcId = $(this).val();
33525 tejus.loha 351
    let description = "All details are correct";
352
    if (confirm("Are you sure to confirm this payment ?")) {
353
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
354
            function (response) {
33845 tejus.loha 355
                alert("Payment is confirm successfully");
33525 tejus.loha 356
                pendingLoiForm("main-content");
357
            });
358
    }
359
});
360
 
361
$(document).on('click', ".paymentRejectBtn", function () {
33507 tejus.loha 362
    let approval = $(this).data('approval');
33525 tejus.loha 363
    let bfcId = $(this).val();
364
    let description;
365
    description = prompt("Reason for rejection..");
366
    if (description !== null) {
367
        if (confirm("Are you sure to Reject this payment ?")) {
368
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
369
                function (response) {
33845 tejus.loha 370
                    alert("Payment is rejected successfully");
33525 tejus.loha 371
                    pendingLoiForm("main-content");
372
                });
373
        }
374
    } else {
375
        alert("Please mention the reason as description and try again");
376
    }
33507 tejus.loha 377
});
378
$(document).on('click', ".upload-document-form", function () {
379
    let loiId = $(this).val();
33617 tejus.loha 380
    doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 381
        function (response) {
382
            $('#' + 'main-content').html(response);
383
        });
384
});
385
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
386
    if (confirm('Confirm file upload ?')) {
387
        var fileSelector = $(this)[0];
388
        if (fileSelector != undefined
389
            && fileSelector.files[0] != undefined) {
390
            var file = this.files[0];
391
            console.log("file", file);
392
            let fileInput = $(this);
393
            console.log("fileInput", file);
394
            uploadDocument(file, function (documentId) {
395
                console.log("documentIdzzz  : ", documentId);
396
                fileInput.closest('td').find(".documentId").val(documentId);
397
            });
398
        }
399
    }
400
});
401
$(document).on('click', ".mk_docApproval", function () {
402
    let loiId = $(this).data('form_id');
403
    let docMasterId = $(this).data('doc_master_id');
404
    let flag = $(this).data('flag');
405
    console.log("flag -", flag);
406
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
407
        function (response) {
408
            alert(response);
33617 tejus.loha 409
            doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 410
                function (response) {
411
                    $('#' + 'main-content').html(response);
412
                });
413
 
414
        });
415
});
416
$(document).on('click', "#uploadDocumentbtn1", function () {
417
    if (confirm("Are you sure to upload all documents ?")) {
418
        var loiId = $(this).val();
419
        var loiDocModels = [];
420
        console.log("loiId -", loiId);
421
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
422
            var marsterId = $(this).find(".masterId").val();
423
            var docId = $(this).find(".documentId").val();
424
            var docName = $(this).find(".documentName").val();
425
            console.log("marsterId -", marsterId);
426
            var loiDocModel = {
427
                documentId: docId,
428
                documentName: docName,
429
                documentMasterId: marsterId
430
            };
431
            loiDocModels.push(loiDocModel);
432
        });
433
        console.log(loiDocModels);
434
        var loiDocModelData = JSON.stringify(loiDocModels);
435
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
436
            console.log('response-', response);
437
            pendingLoiForm("main-content");
438
        });
439
    } else {
440
        //Nothing to do
441
    }
442
 
443
 
444
});
445
 
446
$(document).on('click', ".CompletedLoiForm", function () {
33617 tejus.loha 447
    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 448
        function (response) {
449
            $('#' + 'main-content').html(response);
450
        });
451
});
452
 
453
$(document).on('click', "#createNewOnboardingPanel", function () {
454
    let loiId = $(this).val();
33710 tejus.loha 455
    //let authId = $(this).closest('tr').find('.authId').val();
33507 tejus.loha 456
 
33710 tejus.loha 457
    if (true) {
458
 
459
        doPostAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${0}`,
33507 tejus.loha 460
            function (response) {
461
                if (response) {
33710 tejus.loha 462
                    // doGetAjaxRequestHandler(`${context}/completedLoiForms`,
463
                    //     function (response) {
464
                    //         $('#' + 'main-content').html(response);
465
                    //     });
466
                    alert("it moved successfully ");
33507 tejus.loha 467
                } else {
468
                    //nothing
469
                }
470
 
471
            });
472
    } else {
473
        alert("Please choose RBM ");
474
    }
475
 
476
});
477
 
33617 tejus.loha 478
$(document).on('click', "#downloadAllLoiForm", function () {
479
    const from = $('input[name="from"]').val();
480
    const to = $('input[name="to"]').val();
481
    let missingFields = [];
482
    if (!from) missingFields.push('From date');
483
    if (!to) missingFields.push('To date');
484
    if (missingFields.length > 0) {
485
        alert('Please select : ' + missingFields.join(','));
486
        return;
487
    }
488
    console.log("From - ", from)
489
    console.log("To - ", to)
490
 
491
    window.location.href = `${context}/downloadLoiFromReport?from=${from}&to=${to}`;
492
});
33658 tejus.loha 493
$(document).on('click', ".brandFeePaymentEdit", function () {
494
    var bfcId = $(this).val();
495
    console.log("bfcId - ", bfcId);
496
    // Get the table row
497
    var $row = $(this).closest('tr');
498
    console.log("row - ", $row);
499
    var feeCollectingTimeStamp = $row.find('input[name="feeCollectingTimeStamp"]').val();
500
    var collectedAmount = $row.find('input[name="collectedAmount"]').val();
501
    var paymentReferenceNo = $row.find('input[name="paymentReferenceNo"]').val();
502
    var paymentMode = $row.find('select[name="paymentMode"]').val();
503
    const Data = {
504
        id: bfcId,
505
        feeCollectingTimeStamp: feeCollectingTimeStamp,
506
        collectedAmount: collectedAmount,
507
        paymentReferenceNo: paymentReferenceNo,
508
        paymentMode: paymentMode
509
    };
510
    var jsonData = JSON.stringify(Data);
511
    if (confirm("Are you sure to update details")) {
512
        doPostAjaxRequestWithJsonHandler(`${context}/updatePayment`, jsonData,
513
            function (response) {
33845 tejus.loha 514
                if (response) {
515
                    alert("Updated payment details are save successfully ")
516
                    pendingLoiForm('main-content');
517
                } else {
518
                    alert("Updated payment details are not save ")
519
                    pendingLoiForm('main-content');
520
                }
33658 tejus.loha 521
            });
522
    } else {
523
        pendingLoiForm('main-content');
524
    }
33617 tejus.loha 525
 
33658 tejus.loha 526
 
527
});
33879 tejus.loha 528
/*function validateOTP() {
529
    while (true) {
530
        let otp = prompt("Enter received OTP here");
531
        if (otp === null) {
532
            alert('OTP entry was cancelled. Try again.');
533
            return null;
534
        }
535
        let regex = /^[0-9]{5}$/;
536
        if (regex.test(otp)) {
537
            console.log('otp-flag-', otp);
538
            return otp;  // Return valid OTP
539
        } else {
540
            alert('Please enter a valid 5-digit numeric OTP');
541
        }
542
    }
543
}*/
33658 tejus.loha 544
 
33879 tejus.loha 545
$(document).on('click', "#confirmSign", function () {
546
    let loiId = $(this).val();
547
    // let otp = validateOTP();
548
    let otp = prompt("Enter received OTP here");
549
    console.log("loiId-", loiId, ",otp-", otp);
550
    let validateOtpUrl = `${context}/validateLoiOtp?loiId=${loiId}&provideOtp=${otp}`;
551
    if (otp != undefined || otp != null) {
33658 tejus.loha 552
 
33879 tejus.loha 553
        doPutAjaxRequestHandler(validateOtpUrl, function (response) {
554
            if (response) {
555
                const element = document.getElementById('loiPDF_content');
556
                console.log("element- ", element);
557
                const opt = {
558
                    margin: 0.5,
559
                    filename: 'document.pdf',
560
                    image: {type: 'jpeg', quality: 0.98},
561
                    html2canvas: {scale: 2, logging: true, useCORS: true},
562
                    jsPDF: {unit: 'in', format: 'letter', orientation: 'portrait'}
563
                };
564
                html2pdf().from(element).set(opt).outputPdf("arraybuffer").then(function (pdf) {
565
                    console.log("pdf- ", pdf);
566
                    const file = new Blob([pdf], {type: 'application/pdf'});
567
                    uploadDocument(file, function (documentId) {
568
                        console.log("documentIdddd-", documentId);
569
                        IdempotencyKey = uuidv4();
570
                        if (documentId > 0) {
571
                            saveLoiDoc(loiId, documentId);
572
                        } else {
573
                            alert("Something went wrong , please again to confirm otp")
574
                        }
575
                    });
576
                });
577
            }
578
        });
579
    } else {
580
        return false
581
    }
582
});
583
 
584
 
585
function saveLoiDoc(loiId, documentId) {
586
    let saveLoiDocUrl = `${context}/saveLoiDoc?loiId=` + loiId + `&loiDocId=` + documentId
587
    doPostAjaxRequestHandler(saveLoiDocUrl, function (response) {
588
        if (response) {
589
            alert("LOI has been signed successfully and sent to the registered email. Please check your email.");
590
            pendingLoiForm("main-content");
591
        } else {
592
            alert("Something went wrong , Please try again to generate Loi and Validate otp");
593
 
594
        }
595
    });
596
}
597
 
598
 
33507 tejus.loha 599
function pendingLoiForm(domId) {
33710 tejus.loha 600
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 601
        function (response) {
602
            $('#' + domId).html(response);
603
        });
604
}