Subversion Repositories SmartDukaan

Rev

Rev 33845 | Rev 33885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33845 Rev 33879
Line 189... Line 189...
189
    doGetAjaxRequestHandler(context + "/updateLoiForm?loiId=" + loiId,
189
    doGetAjaxRequestHandler(context + "/updateLoiForm?loiId=" + loiId,
190
        function (response) {
190
        function (response) {
191
            $('#' + 'main-content').html(response);
191
            $('#' + 'main-content').html(response);
192
        });
192
        });
193
});
193
});
194
// $(document).on('click', ".cancel_loi", function () {
-
 
195
//     let loiId = $(this).val();
-
 
196
//     let companyName = $(this).data('company');
-
 
197
//     console.log("form id - ", loiId);
-
 
198
//     if (confirm(`Are you sure to Cancel "${companyName}" LOI`)) {
-
 
199
//         doPutAjaxRequestHandler(`${context}/cancelLoi?loiId=${loiId}`,
-
 
200
//             function (response) {
-
 
201
//                 pendingLoiForm("main-content");
-
 
202
//             });
-
 
203
//     }
-
 
204
// });
194
 
205
$(document).on('click', ".save_agree_brand_fee", function () {
195
$(document).on('click', ".save_agree_brand_fee", function () {
206
    let loiId = $(this).val();
196
    let loiId = $(this).val();
207
    var $tr = $(this).closest('tr');
197
    var $tr = $(this).closest('tr');
208
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
198
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
209
    if (confirm("Are you sure to change Agreed brand fee")) {
199
    if (confirm("Are you sure to change Agreed brand fee")) {
Line 533... Line 523...
533
        pendingLoiForm('main-content');
523
        pendingLoiForm('main-content');
534
    }
524
    }
535
 
525
 
536
 
526
 
537
});
527
});
-
 
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
}*/
-
 
544
 
-
 
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) {
-
 
552
 
-
 
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
}
538
 
597
 
539
 
598
 
540
function pendingLoiForm(domId) {
599
function pendingLoiForm(domId) {
541
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
600
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
542
        function (response) {
601
        function (response) {