Subversion Repositories SmartDukaan

Rev

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

Rev 33871 Rev 33879
Line 3... Line 3...
3
<html lang="en">
3
<html lang="en">
4
 
4
 
5
<head>
5
<head>
6
    <meta charset="UTF-8">
6
    <meta charset="UTF-8">
7
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
-
 
9
    <title>LOI Of SMART DUKAAN</title>
8
    <title>LOI Of SMART DUKAAN</title>
10
    <style>
9
    <style>
11
        @media print {
10
        @media print {
12
            .header dark-bg {
11
            .header dark-bg {
13
                display: none;
12
                display: none;
Line 20... Line 19...
20
    </style>
19
    </style>
21
</head>
20
</head>
22
 
21
 
23
 
22
 
24
<body>
23
<body>
25
<div id="content">
24
<div id="loiPDF_content">
26
    <div id="page1" style="page-break-after: always;">
25
    <div id="page1" style="page-break-after: always;">
27
        <div>
26
        <div>
28
            <img src="${rc.contextPath}/resources/images/SMART%20DUKAAN%20LOGO.jpg" alt="smart dukaan logo "
27
            <img src="${rc.contextPath}/resources/images/SMART%20DUKAAN%20LOGO.jpg" alt="smart dukaan logo "
29
                 style="margin-bottom: 2%;
28
                 style="margin-bottom: 2%;
30
    width: 80%;
29
    width: 80%;
Line 458... Line 457...
458
 
457
 
459
</html>
458
</html>
460
<style>
459
<style>
461
 
460
 
462
</style>
461
</style>
463
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.2/html2pdf.bundle.min.js"></script>
-
 
464
 
462
 
465
<script>
463
<script>
466
    function printDiv() {
464
    function printDiv() {
467
        console.log('printdiv')
465
        console.log('printdiv')
468
        var printContents = document.getElementById("content").innerHTML;
466
        var printContents = document.getElementById("loiPDF_content").innerHTML;
469
        var originalContents = document.body.innerHTML;
467
        var originalContents = document.body.innerHTML;
470
        document.body.innerHTML = printContents;
468
        document.body.innerHTML = printContents;
471
        window.print();
469
        window.print();
472
        document.body.innerHTML = originalContents;
470
        document.body.innerHTML = originalContents;
473
    }
471
    }
474
 
-
 
475
    function validateOTP() {
-
 
476
        while (true) {
-
 
477
            let otp = prompt("Enter received OTP here");
-
 
478
            if (otp === null) {
-
 
479
                alert('OTP entry was cancelled. Try again.');
-
 
480
                return null;
-
 
481
            }
-
 
482
            let regex = /^[0-9]{5}$/;
-
 
483
            if (regex.test(otp)) {
-
 
484
                console.log('otp-flag-', otp);
-
 
485
                return otp;  // Return valid OTP
-
 
486
            } else {
-
 
487
                alert('Please enter a valid 5-digit numeric OTP');
-
 
488
            }
-
 
489
        }
-
 
490
    }
-
 
491
 
-
 
492
    $(document).on('click', "#confirmSign", function () {
-
 
493
        let loiId = $(this).val();
-
 
494
        let otp = validateOTP();
-
 
495
        console.log("loiId-", loiId, ",otp-", otp);
-
 
496
        let validateOtpUrl = `${context}/validateLoiOtp?loiId=${loiId}&provideOtp=${otp}`;
-
 
497
        if (otp != undefined) {
-
 
498
 
-
 
499
            doPutAjaxRequestHandler(validateOtpUrl, function (response) {
-
 
500
                if (response) {
-
 
501
                    const element = document.getElementById('content');
-
 
502
                    console.log("element- ", element);
-
 
503
                    const opt = {
-
 
504
                        margin: 0.5,
-
 
505
                        filename: 'document.pdf',
-
 
506
                        image: {type: 'jpeg', quality: 0.98},
-
 
507
                        html2canvas: {scale: 2, logging: true, useCORS: true},
-
 
508
                        jsPDF: {unit: 'in', format: 'letter', orientation: 'portrait'}
-
 
509
                    };
-
 
510
                    html2pdf().from(element).set(opt).outputPdf("arraybuffer").then(function (pdf) {
-
 
511
                        console.log("pdf- ", pdf);
-
 
512
                        const file = new Blob([pdf], {type: 'application/pdf'});
-
 
513
                        uploadDocument(file, function (documentId) {
-
 
514
                            console.log("documentIdddd-", documentId);
-
 
515
                            if (documentId > 0) {
-
 
516
                                saveLoiDoc(loiId, documentId);
-
 
517
                                pendingLoiForm("main-content");
-
 
518
                            } else {
-
 
519
                                alert("Something went wrong , please again to confirm otp")
-
 
520
                            }
-
 
521
                        });
-
 
522
                    });
-
 
523
                }
-
 
524
            });
-
 
525
        }
-
 
526
    });
-
 
527
 
-
 
528
    function saveLoiDoc(loiId, documentId) {
-
 
529
        let saveLoiDocUrl = `${context}/saveLoiDoc?loiId=` + loiId + `&loiDocId=` + documentId
-
 
530
        doPostAjaxRequestHandler(saveLoiDocUrl, function (response) {
-
 
531
            if (response) {
-
 
532
                alert("LOI has been signed successfully and sent to the registered email. Please check your email.");
-
 
533
            } else {
-
 
534
                alert("Something went wrong , Please try again to generate Loi and Validate otp");
-
 
535
 
-
 
536
            }
-
 
537
        });
-
 
538
    }
-
 
539
</script>
-
 
540
 
-
 
541
</script>
472
</script>
542
473