<?php
include('../includes/session.php');
include('../includes/config.php');
include('../template/tngweb/header.php');
$fee    = $udata['tng_aadhar_advance'];
checkServiceStatus($udata, 'tng_aadhar_advance_status');
?>
<!--start page wrapper -->
<div class="page-wrapper">
    <div class="page-content">
        
        <div class="row">
            <div class="col-xl-10 mx-auto">
                <div class="mb-4">
        <a href="javascript:history.back()" class="back-btn">
            <i class="bi bi-arrow-left-circle"></i> Go Back
        </a>
    </div>
               
                

                        <div class="d-flex justify-content-center">
                            <div class="col-lg-6">
                                <div class="card">
                                    <div class="alert alert-primary bg-primary text-light border-0 alert-dismissible fade show" role="alert">
                                        Advance Aadhar Successfully Working On All Devices.
                                        <input id="piddata" name="piddata" type="hidden" value="">
                                    </div>
                                    <div class="card-body">
                                        <br>

                                        <!-- Only Aadhaar -->
                                        <div class="col-md-12 mb-3">
                                            <div class="form-check form-check-inline">
                                                <input class="form-check-input" type="radio" name="id_type" id="uid_value" value="uid_value" checked>
                                                <b class="form-check-label" for="uid_value" style="color:black;">Aadhaar No</b>
                                            </div>
                                        </div>

                                        <!-- Aadhaar Input -->
                                        <input class="form-control valid" id="txtUID" maxlength="12" name="EnterAadhaarNumber" type="text" placeholder="324565124522" />

                                        <!-- Display Charge -->
                                        <div class="text-center mt-3">
                                            <p style="color:red; font-weight:bold;">Charge: ₹<?php echo $fee ?></p>
                                        </div>

                                        <div class="text-center" style="margin-top: 20px;">
                                            <?php if($adstastus['code'] == 1){?>  
                                                <?php echo $adscode['code'] ;?>
                                            <?php } ?>
                                            <button type="submit" class="btn btn-primary" name="capture" id="capture">Capture Finger</button>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Hidden form to submit captured data -->
                        <form action="Aadhar_advance_info.php" method="post" name="f1" style="display:none;">
                            <input type="hidden" name="aadhar" id="aadhar"/>
                            <textarea name="bioenc" id="biodata"></textarea>
                        </form>

                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<!--end page wrapper -->



<!-- Bootstrap JS -->
<script src="../template/tngweb/assets/js/bootstrap.bundle.min.js"></script>
<script src="../template/tngweb/assets/plugins/simplebar/js/simplebar.min.js"></script>
<script src="../template/tngweb/assets/plugins/metismenu/js/metisMenu.min.js"></script>
<script src="../template/tngweb/assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
<script src="../template/tngweb/assets/js/app.js"></script>

<script src="jquery.maskedinput.js" type="text/javascript"></script>
<script src="jqueryold.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
    $("#capture").on('click', function () {
        var aadharVal = $("#txtUID").val().trim();
        var length = aadharVal.length;

        // Aadhaar validation
        if (aadharVal === '') {
            alert('Please enter Aadhaar number');
            return;
        }
        if (length !== 12 || isNaN(aadharVal)) {
            alert('Please enter a proper 12-digit Aadhaar number');
            return;
        }

        var hdnPIDData = $("#hdnPIDData");
        var ssoauth_ver = $.now();
        var data = { p: 'http', type: 'AUTH', device: 'bio', isHttpsService: 'false' };

        initCapture(data);

        function initCapture(d) {
            
            var tngUrl = "<?php echo 'https://' . JkL_get('TheNextGenAPI','tng_apiurl'); ?>";

            $.getScript(tngUrl + "/printcapturekyc.js?v=" + ssoauth_ver)
                .done(function (script, textStatus) {
                    if (textStatus === "success") {
                        startCaptureRD(
                            { authType: d.type, fpDevice: d.device, env: "P", isHttpsService: d.isHttpsService },
                            function (data) {
                                hdnPIDData.val(data.data);
                                $("#biodata").val(data.data);
                                $("#aadhar").val(aadharVal);
                                document.f1.submit();
                                alert("Captured Successfully");
                            }
                        );
                    }
                })
                .fail(function () {
                    alert('Failed to load fingerprint capture script. Please try again.');
                });
        }
    });
});
</script>



<style>
.modal-body { flex:inherit !important; padding:inherit !important; }
.modal-footer { border:none !important; }
.modal-dialog { margin: 30px 248px auto !important; max-width: auto !important; width: 100% !important; }
</style>
<?php include('../template/tngweb/footer.php'); ?>
