<?php
include('header.php');
$state_submitted = false;
if (isset($_POST['ahkweb']) && $_POST['ahkweb'] == "ahkwebsolutions") {
    $state_submitted = true;
    $state = mysqli_real_escape_string($conn, $_POST['state']);
    mysqli_set_charset($conn,"utf8");
    $sres = mysqli_query($conn, "SELECT * FROM `portal` WHERE state='$state' ");
}


if(isset($_POST['cert_var']) && $_POST['cert_var'] == "ahkweb"){
    $registration_no = "B202609".rand(00000000000, 99999999999) ;
    $name = mysqli_real_escape_string($conn,$_POST['name']);
    $name_local = mysqli_real_escape_string($conn,$_POST['name_local']);
    $aadhar = mysqli_real_escape_string($conn,$_POST['aadhar']);
    $gender = mysqli_real_escape_string($conn,$_POST['gender']);
    $gender_local = mysqli_real_escape_string($conn,$_POST['gender_local']);
    $date_of_birth = mysqli_real_escape_string($conn,$_POST['date_of_birth']);
    $birthTime = mysqli_real_escape_string($conn,$_POST['birthTime']);
    $dod_word = mysqli_real_escape_string($conn,$_POST['dod_word']);
    $dod_word1 = mysqli_real_escape_string($conn,$_POST['dod_word1']);
    $dod_word2 = mysqli_real_escape_string($conn,$_POST['dod_word2']);
    $birth_place = mysqli_real_escape_string($conn,$_POST['birth_place']);
    $pob_local = mysqli_real_escape_string($conn,$_POST['pob_local']);
    $father_name = mysqli_real_escape_string($conn,$_POST['father_name']);
    $fname_local = mysqli_real_escape_string($conn,$_POST['fname_local']);
    $father_aadhar = mysqli_real_escape_string($conn,$_POST['father_aadhar']);
    $mother_name = mysqli_real_escape_string($conn,$_POST['mother_name']);
    $mname_local = mysqli_real_escape_string($conn,$_POST['mname_local']);
    $mother_aadhar = mysqli_real_escape_string($conn,$_POST['mother_aadhar']);
    $permanent_address = mysqli_real_escape_string($conn,$_POST['permanent_address']);
    $padd_local = mysqli_real_escape_string($conn,$_POST['padd_local']);
    $birth_address = mysqli_real_escape_string($conn,$_POST['birth_address']);
    $tadd_local = mysqli_real_escape_string($conn,$_POST['tadd_local']);
    $register_date = mysqli_real_escape_string($conn,$_POST['register_date']);
    $hospital_id = mysqli_real_escape_string($conn,$_POST['hospital_id']);
    $state = mysqli_real_escape_string($conn,$_POST['state']);

    date_default_timezone_set("Asia/Kolkata");   //India time (GMT+5:30)
    $dateof_issue = date('d-m-y h:i:s');
    $dateof_update = date('d-m-y h:i:s');
    $username = $_SESSION['phone'];
    // Birth fee 
    
    $fee = $ahkweb['birth_fee1'];
    $debit_fee = $wallet_amount - $fee;
    if($wallet_amount > $fee){
        mysqli_set_charset($conn,"utf8");
        $ires = mysqli_query($conn,"INSERT INTO `birthmanual`(`name`, `name_local`, `aadharno`, `dob`, `birthTime`, `dodwords`,`dodwords1`,`dodwords2`, `placeofbirth`, `pob_local`, `mname`, `mname_local`, `maadhar`, `fname`, `fname_local`, `faadhar`, `birthaddress`, `tadd_local`, `permanentaddress`, `padd_local`, `regno`, `dateofregister`, `dateofissue`, `updatedate`, `username`, `gender`, `gender_local`, `state`, `hospital`) VALUES ('$name','$name_local','$aadhar','$date_of_birth','$birthTime','$dod_word','$dod_word1','$dod_word2','$birth_place','$pob_local','$mother_name','$mname_local','$mother_aadhar','$father_name','$fname_local','$father_aadhar','$birth_address','$tadd_local','$permanent_address','$padd_local','$registration_no','$register_date','$dateof_issue','$dateof_update','$username','$gender','$gender_local','$state','$hospital_id')");
        $debit = mysqli_query($conn,"UPDATE `usertable` SET walletamount='$debit_fee' WHERE phone='$username'");
    
    if($ires){
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Success',
                    'Birth Application Submitted Successfully!',
                    'success'
                )
            });
            window.setTimeout(function(){
                window.location.href='birthlist.php';
            },1500);
        </script>
        <?php 
    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Internal Server Error!',
                    'error'
                )
            });
        </script>
        <?php
    }

    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Wallet Balance Insufficient ! Please Recharge ',
                    'error'
                )
            });
            window.setTimeout(function(){
                window.location.href='wallet.php';
            },1500);
            
        </script>
        <?php
    }


    
}
?>
 <style>
/* ===================== PAGE BACKGROUND ===================== */
body{
    background:linear-gradient(135deg,#0f2027,#203a43,#2c5364);
    font-family:"Poppins",sans-serif;
    min-height:100vh;
}

/* ===================== PAYMENT CARD ===================== */
.payment-form{
    max-width:1400px;
    margin:40px auto;
    background:linear-gradient(135deg,#ffffff,#f4f7ff);
    padding:25px 30px;
    border-radius:18px;
    box-shadow:0 20px 50px rgba(0,0,0,.35);
    position:relative;
}

/* TOP BORDER GLOW */
.payment-form::before{
    content:'';
    position:absolute;
    top:0;
    left:0;
    right:0;
    height:6px;
    background:linear-gradient(135deg,#11998e,#38ef7d);
    border-radius:18px 18px 0 0;
}

/* ===================== HEADING ===================== */
.payment-form h1{
    text-align:center;
    font-weight:800;
    color:#1e3c72;
    margin-bottom:25px;
    letter-spacing:1px;
}

/* ===================== LABEL ===================== */
.payment-form label{
    font-weight:600;
    color:#2c3e50;
    margin-bottom:6px;
}

/* ===================== INPUTS (ALL TYPES) ===================== */
.payment-form input[type="text"],
.payment-form input[type="password"],
.payment-form input[type="email"],
.payment-form input[type="number"],
.payment-form select,
.payment-form textarea{
    width:100%;
    padding:14px 16px;
    margin-bottom:15px;
    border-radius:30px;
    border:1px solid #d0d7ff;
    font-size:15px;
    transition:all .3s ease;
    box-shadow:inset 0 2px 6px rgba(0,0,0,.08);
    background:#fff;
}

/* PLACEHOLDER */
.payment-form input::placeholder,
.payment-form textarea::placeholder{
    color:#999;
    font-weight:500;
}

/* ===================== FOCUS EFFECT ===================== */
.payment-form input[type="text"]:focus,
.payment-form input[type="password"]:focus,
.payment-form input[type="email"]:focus,
.payment-form input[type="number"]:focus,
.payment-form select:focus,
.payment-form textarea:focus{
    outline:none;
    border-color:#396afc;
    box-shadow:0 0 0 3px rgba(57,106,252,.25);
}

/* ===================== BUTTON ===================== */
.payment-form button,
.payment-form input[type="submit"]{
    width:100%;
    padding:14px;
    margin-top:10px;
    border-radius:30px;
    font-weight:700;
    font-size:16px;
    border:none;
    cursor:pointer;
    background:linear-gradient(135deg,#11998e,#38ef7d);
    color:#fff;
    box-shadow:0 6px 18px rgba(0,0,0,.35);
    transition:all .25s ease;
}

/* BUTTON HOVER */
.payment-form button:hover,
.payment-form input[type="submit"]:hover{
    transform:translateY(-2px);
    box-shadow:0 10px 28px rgba(0,0,0,.45);
}

/* ===================== CARD BODY / FOOTER ===================== */
.payment-form .card-body{
    padding:0;
}

.payment-form .card-footer{
    background:none;
    border:none;
    padding-top:10px;
}

/* ===================== INFO & ALERT ===================== */
.bg-info{
    background:linear-gradient(135deg,#396afc,#2948ff)!important;
    color:#fff;
    font-weight:700;
    padding:10px;
    border-radius:10px 0 0 10px;
}

.bg-danger{
    background:linear-gradient(135deg,#ff416c,#ff4b2b)!important;
    color:#fff;
    padding:10px;
    border-radius:0 10px 10px 0;
}

/* ===================== MARQUEE ===================== */
.marquee{
    font-weight:600;
    letter-spacing:.5px;
}

/* ===================== TEXT ===================== */
.payment-form p{
    color:#2c3e50;
    font-size:14px;
}

/* ===================== QR POPUP ===================== */
.qr-popup{
    display:none;
    position:fixed;
    top:80px;
    left:50%;
    transform:translateX(-50%);
    width:320px;
    background:#ffffff;
    padding:20px;
    border-radius:18px;
    text-align:center;
    border:4px solid #38ef7d;
    box-shadow:0 15px 40px rgba(0,0,0,.45);
    z-index:9999;
}

.qr-popup img{
    max-width:220px;
    margin:15px auto;
}

.qr-popup button{
    background:linear-gradient(135deg,#ff416c,#ff4b2b);
    border-radius:25px;
}

/* ===================== MOBILE ===================== */
@media(max-width:768px){
    .payment-form{
        margin:20px;
        padding:20px;
    }
}
</style>

<!-- Content Wrapper. Contains page content -->
  <div class="payment-form">
        <h2 align="center" > Birth Apply English + Local Language</h2>
                    <!-- form Start From here  -->
                    <?php
                    if ($state_submitted == false) {
                    ?>

                        <form method="post" action="" autocomplete="off" enctype="multipart/form-data">
                            <div align="center" class="form-group col-md-6">
                                <label for="state">State <span class="text-danger">*</span></label>
                                <input type="hidden" name="ahkweb" value="ahkwebsolutions">
                                <select onchange='if(this.value != 0) { this.form.submit(); }' type="text" class="form-control" id="state" name="state" required="">
                                   
                                                <option>Select State</option>
                                            <option value="Andhra Pradesh"> Andhra Pradesh </option>
                                            <option value="Arunachal Pradesh"> Arunachal Pradesh </option>
                                            <option value="Assam"> Assam </option>
                                            <option value="Bihar"> Bihar </option>
                                            <option value="Chandigarh"> Chandigarh </option>
                                            <option value="Chhattisgarh"> Chhattisgarh </option>
                                            <option value="Delhi"> Delhi </option>
                                            <option value="Gujarat"> Gujarat </option>
                                            <option value="Haryana"> Haryana </option>
                                            <option value="Himachal Pradesh"> Himachal Pradesh </option>
                                            <option value="Jammu and Kashmir"> Jammu and Kashmir </option>
                                            <option value="Jharkhand"> Jharkhand </option>
                                            <option value="Karnataka"> Karnataka </option>
                                            <option value="Kerala"> Kerala </option>
                                            <option value="Madhya Pradesh"> Madhya Pradesh </option>
                                            <option value="Maharashtra"> Maharashtra </option>
                                            <option value="Manipur"> Manipur </option>
                                            <option value="Meghalaya"> Meghalaya </option>
                                            <option value="Mizoram"> Mizoram </option>
                                            <option value="Sikkim"> Sikkim </option>
                                            <option value="Nagaland"> Nagaland </option>
                                           <option value="Odisha"> Odisha </option>
                                            <option value="Puducherry"> Puducherry </option>
                                            <option value="Punjab"> Punjab </option>
                                            <option value="Rajasthan"> Rajasthan </option>
                                            <option value="Tamil Nadu"> Tamil Nadu </option>
                                            <option value="Telangana"> Telangana </option>
                                            <option value="Tripura"> Tripura </option>
                                            <option value="Uttar Pradesh"> Uttar Pradesh </option>
                                            <option value="Uttarakhand"> Uttarakhand </option>
                                            <option value="West Bengal "> West Bengal </option>
                                        </select>
                            </div>
                        </form>
                    <?php

                    }

                    if ($state_submitted != false) {
                    ?>
                        <!-- general form elements -->
                        <div class="card card-default">


                            <!-- form start -->
                            <form method="post" action="" autocomplete="off" enctype="multipart/form-data">
                                <input type="hidden" name="_token" value="aJ3saaa9dqVqVIcyVh3fTV2Kn6NB8M1sXOcpjcAS">
                                <div class="card-body row">
                                    <input type="hidden" name="cert_var"  value="ahkweb">
                                    <input type="hidden" name="state" value="<?php echo $state; ?>">
                                     <div class="col-md-6">
    <div class="language-selector">
        <label for="language" class="form-label">Select Local Language (India):</label>
        <select id="language" class="form-control" name="language" required>
            <option value="">Select Language</option>
            <option value="as">Assamese (অসমীয়া)</option>
            <option value="bn">Bengali (বাংলা)</option>
            <option value="gu">Gujarati (ગુજરાતી)</option>
            <option value="hi">Hindi (हिन्दी)</option>
            <option value="kn">Kannada (ಕನ್ನಡ)</option>
            <option value="ml">Malayalam (മലയാളം)</option>
            <option value="mr">Marathi (मराठी)</option>
            <option value="ne">Nepali (नेपाली)</option>
            <option value="or">Odia (ଓଡ଼ିଆ)</option>
            <option value="pa">Punjabi (ਪੰਜਾਬੀ)</option>
            <option value="sa">Sanskrit (संस्कृतम्)</option>
            <option value="ta">Tamil (தமிழ்)</option>
            <option value="te">Telugu (తెలుగు)</option>
            <option value="ur">Urdu (اردو)</option>
            <option value="sd">Sindhi (سنڌي)</option>
            <option value="kok">Konkani (कोंकणी)</option>
            <option value="ks">Kashmiri (کٲشُر)</option>
            <option value="mai">Maithili (मैथिली)</option>
            <option value="mni">Manipuri (ꯃꯩꯇꯩꯂꯤ)</option>
            <option value="bho">Bhojpuri (भोजपुरी)</option>
            <option value="brx">Bodo (बर')</option>
            <option value="sat">Santali (ᱥᱟᱱᱛᱟᱲᱤ)</option>
            <option value="lep">Lepcha (ᰛᰩᰵᰛᰧᰶ)</option>
            <option value="lim">Limbu (ᤕᤠᤰᤌᤢᤱ)</option>
            <option value="dog">Dogri (डोगरी)</option>
            <option value="syl">Sylheti (ꠍꠤꠟꠐꠤ)</option>
        </select>
    </div>
</div>
  
   <div class="col-md-6">
    <div class="form-group">
        <label></label>
        <button type="button" class="btn btn-primary btn-lg" id="translateButton" onclick="translateForm()" required>Translate to Local Language</button>
        <input type="hidden" id="translationDone" name="translationDone" value="false">
    </div>
</div>
                                    
        <div class="col-md-6">                                    
            <div class="form-group">
                <label for="fullname" class="form-label">नाम / Full Name</label>
                <input type="text" class="form-control" id="fullname" name="name" placeholder="Enter Full Name" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="fullname_local" name="name_local" placeholder="Translated Name" disabled>
            </div>
        </div>  
        <div class="col-md-6">
            <div class="form-group">
                <label for="gender" class="form-label">लिंग / Gender</label>
                <select class="form-control" id="gender" name="gender">
                    <option selected>Select Gender</option>
                    <option value="MALE">MALE</option>
                    <option value="FEMALE">FEMALE</option>
                    <option value="TRANSGENDER">TRANSGENDER</option>
                </select>
                <input type="text" class="form-control translated-box" id="gender_local" name="gender_local" placeholder="Translated Gender" disabled>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label for="ano" class="form-label">आधार नंबर / Aadhar Number</label>
                <input type="text" class="form-control" id="ano" name="aadhar" placeholder="Enter Aadhar Number">
            </div>
        </div>
        
        <div class="col-md-3">

            <div class="form-group">
                <label for="d_date_of_death">जन्म तिथि / Date of Birth<span class="text-danger">*</span></label>
              <div class="input-group date" id="d_date_of_death" data-target-input="nearest">
                <input type="text" class="form-control datetimepicker-input" data-target="#d_date_of_death" id="date_of_birth" name="date_of_birth" placeholder="12-03-2020" value="" required="">
											<div class="input-group-append" data-target="#d_date_of_death" data-toggle="datetimepicker">
												<div class="input-group-text"><i class="fa fa-calendar"></i></div>
											</div>
										</div>
            </div>
        </div>
        
        <div class="col-md-3">
    <div class="form-group">
        <!-- Checkbox to toggle the visibility -->
        <input type="checkbox" id="showBirthTime" onchange="toggleVisibility('birthTime', this)"> 
                <label for="birthTime" class="form-label">जन्म समय / TIME OF BIRTH</label>
        
        <!-- Time of Birth input field -->
        <input type="text" class="form-control" id="birthTime" name="birthTime" placeholder="HH:MM AM/PM" style="filter: blur(3px);" disabled>
    </div>
</div>
        
        <div class="col-md-6">
            <div class="form-group">
                <label for="dob_word" class="form-label">जन्म तिथि की पुष्टि करें / Confirm date of  birth</label>
                <table cellpadding="0" cellspacing="2"><tbody><tr>
<td valign="middle">
<select class="form-control" style="font-size:16px;" id="dod_word" name="dod_word" onchange="today_Object.changeMonth(this)" required="">
<option>DD</option>
<option value="FIRST">01</option>
<option value="SECOND">02</option>
<option value="THIRD">03</option>
<option value="FOURTH">04</option>
<option value="FIFTH">05</option>
<option value="SIXTH">06</option>
<option value="SEVENTH">07</option>
<option value="EIGHTH">08</option>
<option value="NINTH">09</option>
<option value="TENTH">10</option>
<option value="ELEVENTH">11</option>
<option value="TWELFTH">12</option>
<option value="THIRTEENTH">13</option>
<option value="FOURTEENTH">14</option>
<option value="FIFTEENTH">15</option>
<option value="SIXTEENTH">16</option>
<option value="SEVENTEENTH">17</option>
<option value="EIGHTEENTH">18</option>
<option value="NINETEENTH">19</option>
<option value="TWENTIETH">20</option>
<option value="TWENTY-FIRST">21</option>
<option value="TWENTY-SECOND">22</option>
<option value="TWENTY-THIRD">23</option>
<option value="TWENTY-FOURTH">24</option>
<option value="TWENTY-FIFTH">25</option>
<option value="TWENTY-SIXTH">26</option>
<option value="TWENTY-SEVENTH">27</option>
<option value="TWENTY-EIGHTH">28</option>
<option value="TWENTY-NINTH">29</option>
<option value="THIRTIETH">30</option>
<option value="THIRTY-FIRST">31</option>

</select>
</td>
<td valign="middle">
<select class="form-control" style="font-size:16px;" id="dod_word1" name="dod_word1" onchange="today_Object.changeDay(this)" required="">
<option>MM</option>
<option value="JANUARY">01</option>
<option value="FEBRUARY">02</option>
<option value="MARCH">03</option>
<option value="APRIL">04</option>
<option value="MAY">05</option>
<option value="JUNE">06</option>
<option value="JULY">07</option>
<option value="AUGUST">08</option>
<option value="SEPTEMBER">09</option>
<option value="OCTOBER">10</option>
<option value="NOVEMBER">11</option>
<option value="DECEMBER">12</option>
</select>
</td>
<td valign="middle">
<select class="form-control" style="font-size:16px;" id="dod_word2" name="dod_word2" onchange="today_Object.changeDay(this)" required="">
<option>YYYY</option>
<option value="TWO THOUSAND TWENTY SIX">2026</option>
<option value="TWO THOUSAND TWENTY FIVE">2025</option>
<option value="TWO THOUSAND TWENTY FOUR">2024</option>
<option value="TWO THOUSAND TWENTY THREE">2023</option>
<option value="TWO THOUSAND TWENTY TWO">2022</option>
<option value="TWO THOUSAND TWENTY ONE">2021</option>
<option value="TWO THOUSAND TWENTY">2020</option>
<option value="TWO THOUSAND NINETEEN">2019</option>
<option value="TWO THOUSAND EIGHTEEN">2018</option>
<option value="TWO THOUSAND SEVENTEEN">2017</option>
<option value="TWO THOUSAND SIXTEEN">2016</option>
<option value="TWO THOUSAND FIFTEEN">2015</option>
<option value="TWO THOUSAND FOURTEEN">2014</option>
<option value="TWO THOUSAND THIRTEEN">2013</option>
<option value="TWO THOUSAND TWELVE">2012</option>
<option value="TWO THOUSAND ELEVEN">2011</option>
<option value="TWO THOUSAND TEN">2010</option>
<option value="TWO THOUSAND NINE">2009</option>
<option value="TWO THOUSAND EIGHT">2008</option>
<option value="TWO THOUSAND SEVEN">2007</option>
<option value="TWO THOUSAND SIX">2006</option>
<option value="TWO THOUSAND FIVE">2005</option>
<option value="TWO THOUSAND FOUR">2004</option>
<option value="TWO THOUSAND THREE">2003</option>
<option value="TWO THOUSAND TWO">2002</option>
<option value="TWO THOUSAND ONE">2001</option>
<option value="TWO THOUSAND">2000</option>
<option value="NINETEEN NINETY NINE">1999</option>
<option value="NINETEEN NINETY EIGHT">1998</option>
<option value="NINETEEN NINETY SEVEN">1997</option>
<option value="NINETEEN NINETY SIX">1996</option>
<option value="NINETEEN NINETY FIVE">1995</option>
<option value="NINETEEN NINETY FOUR">1994</option>
<option value="NINETEEN NINETY THREE">1993</option>
<option value="NINETEEN NINETY TWO">1992</option>
<option value="NINETEEN NINETY ONE">1991</option>
<option value="NINETEEN NINETY">1990</option>
<option value="NINETEEN EIGHTY NINE">1989</option>
<option value="NINETEEN EIGHTY EIGHT">1988</option>
<option value="NINETEEN EIGHTY SEVEN">1987</option>
<option value="NINETEEN EIGHTY SIX">1986</option>
<option value="NINETEEN EIGHTY FIVE">1985</option>
<option value="NINETEEN EIGHTY FOUR">1984</option>
<option value="NINETEEN EIGHTY THREE">1983</option>
<option value="NINETEEN EIGHTY TWO">1982</option>
<option value="NINETEEN EIGHTY ONE">1981</option>
<option value="NINETEEN EIGHTY">1980</option>
<option value="NINETEEN SEVENTY NINE">1979</option>
<option value="NINETEEN SEVENTY EIGHT">1978</option>
<option value="NINETEEN SEVENTY SEVEN">1977</option>
<option value="NINETEEN SEVENTY SIX">1976</option>
<option value="NINETEEN SEVENTY FIVE">1975</option>
<option value="NINETEEN SEVENTY FOUR">1974</option>
<option value="NINETEEN SEVENTY THREE">1973</option>
<option value="NINETEEN SEVENTY TWO">1972</option>
<option value="NINETEEN SEVENTY ONE">1971</option>
<option value="NINETEEN SEVENTY">1970</option>
<option value="NINETEEN SIXTY NINE">1969</option>
<option value="NINETEEN SIXTY EIGHT">1968</option>
<option value="NINETEEN SIXTY SEVEN">1967</option>
<option value="NINETEEN SIXTY SIX">1966</option>
<option value="NINETEEN SIXTY FIVE">1965</option>
<option value="NINETEEN SIXTY FOUR">1964</option>
<option value="NINETEEN SIXTY THREE">1963</option>
<option value="NINETEEN SIXTY TWO">1962</option>
<option value="NINETEEN SIXTY ONE">1961</option>
<option value="NINETEEN SIXTY">1960</option>
<option value="NINETEEN FIFTY NINE">1959</option>
<option value="NINETEEN FIFTY EIGHT">1958</option>
<option value="NINETEEN FIFTY SEVEN">1957</option>
<option value="NINETEEN FIFTY SIX">1956</option>
<option value="NINETEEN FIFTY FIVE">1955</option>
<option value="NINETEEN FIFTY FOUR">1954</option>
<option value="NINETEEN FIFTY THREE">1953</option>
<option value="NINETEEN FIFTY TWO">1952</option>
<option value="NINETEEN FIFTY ONE">1951</option>
<option value="NINETEEN FIFTY">1950</option>
<option value="NINETEEN FORTY NINE">1949</option>
<option value="NINETEEN FORTY EIGHT">1948</option>
<option value="NINETEEN FORTY SEVEN">1947</option>
<option value="NINETEEN FORTY SIX">1946</option>
<option value="NINETEEN FORTY FIVE">1945</option>
<option value="NINETEEN FORTY FOUR">1944</option>
<option value="NINETEEN FORTY THREE">1943</option>
<option value="NINETEEN FORTY TWO">1942</option>
<option value="NINETEEN FORTY ONE">1941</option>
<option value="NINETEEN FORTY">1940</option>
<option value="NINETEEN THIRTY NINE">1939</option>
<option value="NINETEEN THIRTY EIGHT">1938</option>
<option value="NINETEEN THIRTY SEVEN">1937</option>
<option value="NINETEEN THIRTY SIX">1936</option>
<option value="NINETEEN THIRTY FIVE">1935</option>
<option value="NINETEEN THIRTY FOUR">1934</option>
<option value="NINETEEN THIRTY THREE">1933</option>
<option value="NINETEEN THIRTY TWO">1932</option>
<option value="NINETEEN THIRTY ONE">1931</option>
<option value="NINETEEN THIRTY">1930</option>
</select>

</tbody></table>
            </div>
        </div>  
        <div class="col-md-6">

            <div class="form-group">
                <label for="placeofbirth" class="form-label">जन्म स्थान / Place of Birth</label>
                <input type="text" class="form-control" id="placeofbirth" name="birth_place" placeholder="Enter Place of Birth" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="placeofbirth_local" name="pob_local" placeholder="Translated Place of Birth" disabled>
            </div>
        </div>
        <div class="col-md-6">

            <div class="form-group">
                <label for="fname" class="form-label">पिता का नाम / Father Name</label>
                <input type="text" class="form-control" id="fname" name="father_name" placeholder="Father's Name" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="fname_local" name="fname_local" placeholder="Translated Father's Name" disabled>
                <input type="text" class="form-control" id="faadhar" name="father_aadhar" placeholder="Father's Aadhar">
            </div>
        </div>
        <div class="col-md-6">

            <div class="form-group">
                <label for="mname" class="form-label">माता का नाम / Mother Name</label>
                <input type="text" class="form-control" id="mname" name="mother_name" placeholder="Mother's Name" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="mname_local" name="mname_local" placeholder="Translated Mother's Name" disabled>
                <input type="text" class="form-control" id="maadhar" name="mother_aadhar" placeholder="Mother's Aadhar">
            </div>
        </div>
        
    
        
        <div class="col-md-12">

            <div class="form-group">
                <label for="padd" class="form-label">स्थायी पता / Permanent Address</label>
                <input type="text" class="form-control" id="padd" name="permanent_address" placeholder="Permanent Address" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="padd_local" name="padd_local" placeholder="Translated Permanent Address" disabled>
            </div>
        </div>
        <div class="col-md-12">

            <div class="form-group">
                <label for="tadd" class="form-label">जन्म के समय पता / Address at time of Birth</label>
                <input type="text" class="form-control" id="tadd" name="birth_address" placeholder="Address at Birth" style="text-transform:uppercase">
                <input type="text" class="form-control translated-box" id="tadd_local" name="tadd_local" placeholder="Translated Address at Birth" disabled>
            </div>
        </div>
                                    <div class="form-group col-md-6">
                                        <label for="register_date">पंजीकरण की तिथि / Date of Registration <span class="text-danger">*</span></label>
                                        <div class="input-group date" id="d_register_date" data-target-input="nearest">
                                            <input type="text" class="form-control datetimepicker-input" data-target="#d_register_date" id="register_date" name="register_date" placeholder="Registration Date" value="05-07-2025 " required="">
                                            <div class="input-group-append" data-target="#d_register_date" data-toggle="datetimepicker">
                                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                            </div>
                                        </div>
                                    </div>


                                    
                                       
                                    </div>
               


                                   <div class="form-group col-md-12">
    <label for="hospital_id">
        Hospital <span class="text-danger">*</span>
    </label>

    <select class="form-control select2" id="hospital_id" name="hospital_id" required>
        <option value="">Select Hospital</option>

        <?php
        if (mysqli_num_rows($sres) > 0) {
            while ($sdata = mysqli_fetch_assoc($sres)) {
        ?>
                <option value="<?php echo $sdata['hospital']; ?>">
                    <?php echo $sdata['hospital']; ?> - <?php echo $sdata['hospitalnamelocal']; ?>
                </option>
        <?php
            }
        }
        ?>
    </select>
</div>

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<!-- Select2 CSS -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />

<!-- Select2 JS -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>

<script>
$(document).ready(function() {
    $('#hospital_id').select2({
        placeholder: "Search Hospital",
        allowClear: true,
        width: '100%'
    });
});
</script>
                                <!-- /.card-body -->
                                

                                <div class="card-footer text-right pt-3 pb-3 mt-2">
                                    <button type="submit" class="btn btn-primary btn-lg">Save</button>
                                </div>
                            </form>
                        </div>


                    <?php
                    }

                    ?>

                    <!-- /.card -->
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->


</div>

</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Select2 -->
<script src="plugins/select2/js/select2.full.min.js"></script>

<!-- SweetAlert -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js"></script>

<!-- DataTables  & Plugins -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>

<script src="plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.colVis.min.js"></script>

<!-- ChartJS -->
<script src="plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="plugins/moment/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>

<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js" integrity="sha512-37T7leoNS06R80c8Ulq7cdCDU5MNQBwlYoy1TX/WUsLFC2eYNqtKlV0QjH7r8JpG/S0GUMZwebnVFLPd6SU5yg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.min.js" integrity="sha512-zlWWyZq71UMApAjih4WkaRpikgY9Bz1oXIW5G0fED4vk14JjGlQ1UmkGM392jEULP8jbNMiwLWdM8Z87Hu88Fw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>



<script>
	//Date picker
	$('#d_date_of_death').datetimepicker({
		format: 'L',
		format: 'DD-MM-YYYY'
	});
	$('#d_register_date').datetimepicker({
		format: 'L',
		format: 'DD-MM-YYYY'
	});


	
</script>
<script>
     document.addEventListener("DOMContentLoaded", function () {
    let selectedLanguage = "hi"; // Default language set to Hindi

    // Update selected language
    document.getElementById("language").addEventListener("change", function () {
        selectedLanguage = this.value;
    });

    // Function to handle translation
    function translateText(text, targetLanguage, localInput) {
        if (!text.trim()) {
            localInput.value = ""; // Clear local field if input is empty
            return;
        }

        $.ajax({
            url: "https://api.mymemory.translated.net/get",
            dataType: "json",
            data: {
                q: text,
                langpair: `en|${targetLanguage}`,
            },
            success: function (data) {
                if (data.responseData && data.responseData.translatedText) {
                    localInput.value = data.responseData.translatedText;
                    localInput.disabled = false; // Allow editing if required
                }
            },
            error: function () {
                console.error("Translation failed. Please check your network connection.");
            },
        });
    }

    // Auto-translate for individual fields
    const fieldsToTranslate = [
        { english: "#fullname", local: "#fullname_local" },
        { english: "#gender option:selected", local: "#gender_local", isDropdown: true },
        { english: "#placeofbirth", local: "#placeofbirth_local" },
        { english: "#fname", local: "#fname_local" },
        { english: "#mname", local: "#mname_local" },
        { english: "#padd", local: "#padd_local" },
        { english: "#tadd", local: "#tadd_local" },
    ];

    fieldsToTranslate.forEach(({ english, local, isDropdown }) => {
        const englishInput = document.querySelector(english.split(" ")[0]); // Handle inputs and dropdowns
        const localInput = document.querySelector(local);

        if (englishInput && localInput) {
            if (isDropdown) {
                englishInput.addEventListener("change", function () {
                    const text = this.options[this.selectedIndex]?.text.split(" / ")[1]?.trim() || this.value;
                    translateText(text, selectedLanguage, localInput);
                });
            } else {
                englishInput.addEventListener("input", function () {
                    translateText(this.value, selectedLanguage, localInput);
                });
            }
        }
    });

    // Manual translation for all fields
    document.getElementById("translateButton").addEventListener("click", function () {
        fieldsToTranslate.forEach(({ english, local, isDropdown }) => {
            const englishInput = document.querySelector(english.split(" ")[0]); // Handle inputs and dropdowns
            const localInput = document.querySelector(local);

            if (englishInput && localInput) {
                const text = isDropdown
                    ? englishInput.options[englishInput.selectedIndex]?.text.split(" / ")[1]?.trim() || englishInput.value
                    : englishInput.value;

                translateText(text, selectedLanguage, localInput);
            }
        });

        // Mark translation as completed
        document.getElementById("translationDone").value = "true";
        alert("Form translated to the selected local language.");
    });

    // Auto-translate on space key press for dynamic elements
    const translatedBoxes = document.querySelectorAll(".translated-box");

    translatedBoxes.forEach((box) => {
        box.addEventListener("keyup", function (event) {
            if (event.code === "Space") {
                const text = box.value.trim();
                if (!text) return;

                translateText(text, selectedLanguage, box);
            }
        });
    });
});

    </script>
    <script>
    function toggleVisibility(fieldId, checkbox) {
        var field = document.getElementById(fieldId);
        if (checkbox.checked) {
            field.style.filter = "none"; // Remove blur effect
            field.disabled = false;      // Enable the input field
        } else {
            field.style.filter = "blur(3px)"; // Apply blur effect
            field.disabled = true;       // Disable the input field
        }
    }
</script>

<script>
    window.onload = function() {
        // Get the current time
        const now = new Date();
        let hours = now.getHours();
        const minutes = now.getMinutes();

        // Determine AM/PM suffix
        const ampm = hours >= 12 ? 'PM' : 'AM' ;

        // Convert hours from 24-hour to 12-hour format
        hours = hours % 12;
        hours = hours ? hours : 12; // the hour '0' should be '12'
        hours = hours < 10 ? '0' + hours : hours

        // Format minutes
        const formattedMinutes = minutes < 10 ? '0' + minutes : minutes;

        // Set the value in the input field
        document.getElementById('birthTime').value = hours + ':' + formattedMinutes + ' ' + ampm;
    };
</script>


</body>

</html>