<?php
include('header.php');
include('../../includes/config.php');
$priceQuery = mysqli_query($ahk_conn, "SELECT `price` FROM `pricing` WHERE `service_name`='tng_aadhar_advance' LIMIT 1");
$priceData = mysqli_fetch_assoc($priceQuery);
$fee = $priceData['price'] ?? 20; 
?>
<!--start page wrapper -->
<div class="page-wrapper">
    <div class="page-content">
        <!--breadcrumb-->
        <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
            <div class="breadcrumb-title pe-3">Home </div>
            <div class="ps-3">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb mb-0 p-0">
                        <li class="breadcrumb-item"><a href="javascript:;"><i class="bx bx-home-alt"></i></a></li>
                        <li class="breadcrumb-item active" aria-current="page">New APPLY</li>
                    </ol>
                </nav>
            </div>
        </div>
        <!--end breadcrumb-->

        <div class="row">
            <div class="col-xl-10 mx-auto">
                <h6 class="mb-0 text-uppercase">Aadhar ADVANCE</h6>
                <hr/>
                <div class="card border-top border-0 border-4 border-primary">
                    <div class="card-body p-5">
                        <div class="card-title d-flex align-items-center">
                            <div><i class="bx bxs-id-card me-1 font-22 text-primary"></i></div>
                            <h5 class="mb-0 text-primary">Enter Aadhar Details</h5>
                        </div>
                        <hr>

                        <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="28" name="EnterAadhaarNumber" type="text" placeholder="12341234512345YYYYMMDDHHMMSS" />

                                        <!-- 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/ahkweb/assets/js/bootstrap.bundle.min.js"></script>
<script src="../template/ahkweb/assets/plugins/simplebar/js/simplebar.min.js"></script>
<script src="../template/ahkweb/assets/plugins/metismenu/js/metisMenu.min.js"></script>
<script src="../template/ahkweb/assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
<script src="../template/ahkweb/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;

        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) {
            $.getScript("<?php echo $tng_apiurl ?>/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) {
                                if (d.p === "http") {
                                    hdnPIDData.val(data.data);
                                } else {
                                    hdnPIDData.val(data.data);
                                }
                                $("#biodata").val(data.data);
                                $("#aadhar").val(aadharVal);
                                document.f1.submit();
                                alert("Captured Successfully");
                            }
                        );
                    }
                });
        }
    });
});
</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('footer.php'); ?>
