<?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 = "B2025095034700".rand(0000, 9999);
    $name = mysqli_real_escape_string($conn,$_POST['name']);
    $aadhar = mysqli_real_escape_string($conn,$_POST['aadhar']);
    $gender = mysqli_real_escape_string($conn,$_POST['gender']);
    $date_of_birth = mysqli_real_escape_string($conn,$_POST['date_of_birth']);
    $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']);
    $father_name = mysqli_real_escape_string($conn,$_POST['father_name']);
    $father_aadhar = mysqli_real_escape_string($conn,$_POST['father_aadhar']);
    $mother_name = mysqli_real_escape_string($conn,$_POST['mother_name']);
    $mother_aadhar = mysqli_real_escape_string($conn,$_POST['mother_aadhar']);
    $permanent_address = mysqli_real_escape_string($conn,$_POST['permanent_address']);
    $birth_address = mysqli_real_escape_string($conn,$_POST['birth_address']);
    $register_date = mysqli_real_escape_string($conn,$_POST['register_date']);
    $hospital_id = mysqli_real_escape_string($conn,$_POST['hospital_id']);
        $unitname = mysqli_real_escape_string($conn,$_POST['unitname']);
    $unitcode = mysqli_real_escape_string($conn,$_POST['unitcode']); 
    $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');
    $dateof_update = date('d-m-Y h:i:s');
    $username = $_SESSION['phone'];
    // Birth fee 
    
    $fee = $ahkweb['birth_fee'];
    $debit_fee = $wallet_amount - $fee;
    if($wallet_amount > $fee){
        mysqli_set_charset($conn,"utf8");
        $ires = mysqli_query($conn,"INSERT INTO `birthmanual`(`name`, `aadharno`, `dob`, `dodwords`,`dodwords1`,`dodwords2`, `placeofbirth`, `mname`, `maadhar`, `fname`, `faadhar`, `birthaddress`, `permanentaddress`, `regno`, `dateofregister`, `unitname`, `unitcode`, `dateofissue`, `updatedate`, `username`, `gender`, `state`, `hospital`) VALUES ('$name','$aadhar','$date_of_birth','$dod_word','$dod_word1','$dod_word2','$birth_place','$mother_name','$mother_aadhar','$father_name','$father_aadhar','$birth_address','$permanent_address','$registration_no','$register_date','$unitname','$unitcode','$dateof_issue','$dateof_update','$username','$gender','$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>
        .payment-form {
            max-width: 90%;
            margin: auto;
            background: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgb(0 0 0 / 80%);
        }

        .payment-form input {
            width: calc(100% - 20px);
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .payment-form button {
            width: 100%;
            padding: 10px;
            background: #28a745;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .payment-form button:hover {
            background: #218838;
        }

        .qr-popup {
            display: none;
            position: fixed;
            top: 70px;
            left: 50%;
            transform: translateX(-50%);
            width: 300px;
            background: rgb(255, 255, 255);
            justify-content: center;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            color: #181818;
            border: 5px solid #28a745;
            /* Add a 5px border with green color */
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
            /* Optional: Add a shadow for better styling */
        }

        .qr-popup img {
            max-width: 200px;
            margin: 10px auto;
        }

        .qr-popup button {
            margin-top: 10px;
            padding: 10px;
            background: #dc3545;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
                <!-- left column -->
                <div class="payment-form">
        <h2 align="center" >Birth Apply Only English</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="row">
            <div class="form-group col-md-6">
                    <!-- form Start From here  -->
                    <form method="post" action="" autocomplete="off" enctype="multipart/form-data">
                                
                                    <input type="hidden" name="cert_var"  value="ahkweb">
                                    <input type="hidden" name="state" value="<?php echo $state; ?>">									
                                                      
                                    
                                   <div class="row">
                                <div class="form-group col-md-6">
                                       <label for="name">नाम / Full Name <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="name" name="name" placeholder="FULL NAME" value="" required="">	
                                        <input type="text" class="form-control" id="aadhar" name="aadhar" placeholder="AADHAR NUMBER" value="">												
                                           </div>
                                                 
                                      

                                           <div class="row">
                                <div class="form-group col-md-6">

												 <label for="date_of_birth">जन्म तिथि / Date of birth <span class="text-danger"> </span></label>
                                        <div class="input-group date" id="d_date_of_birth" data-target-input="nearest">
                                           <input type="text" class="form-control datetimepicker-input" data-target="#d_date_of_birth" id="date_of_birth" name="date_of_birth" placeholder="DD/MM/YYYY" value="" required="">
                                            <div class="input-group-append" data-target="#d_date_of_birth" data-toggle="datetimepicker">
                                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                            </div>
                                        </div>
                                          
                                           <div class="row">
                                <div class="form-group col-md-6">
													<label for="gender">लिंग / Gender <span class="text-danger"> </span></label>
                                                    <select class="form-control" id="gender" name="gender" required="">
                                            <option value="">-- Select Gender --</option>
                                            <option value="Male">  पुरुष / MALE      </option>
                                            <option value="Female"> महिला / FEMALE </option>
                                            <option value="Other">Transgender / ट्रांसजेंडर												

                                                    </option></select></td>
                                                    
                                               </div>      
                                                       
                                           <div class="row">
                                <div class="form-group col-md-6">

													<label for="dod_word">जन्म तिथि की पुष्टि करें / 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 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>
</td>

<td valign="middle">
<a id="today_ID_Link" href="javascript:today_Object.show()" onmouseover="return today_Object.iconHover(true)" onmouseout="return today_Object.iconHover(false)"></a>&nbsp;<span id="today_ID" style="position:absolute;visibility:hidden;margin-top: 32px;margin-left:-189px;width:189px;background-color:white;border:1px solid dimgray;" onmouseover="today_Object.handleTimer(true)" onmouseout="today_Object.handleTimer(false)">
<table width="189" cellspacing="0" cellpadding="1">
<tbody><tr style="background-color:buttonface;">
<td id="today_Previous_ID" style="cursor:default" align="center" class="calendarDateInput" onclick="today_Object.previous.go()" onmousedown="VirtualButton(this,true)" onmouseup="VirtualButton(this,false)" onmouseover="return today_Object.previous.hover(this,true)" onmouseout="return today_Object.previous.hover(this,false)" title="February"><img src="/img/prev.gif"></td>
<td id="today_Current_ID" style="cursor:pointer" align="center" class="calendarDateInput" colspan="5" onclick="today_Object.displayed.goCurrent()" onmouseover="self.status='Click to view March 2023';return true;" onmouseout="self.status='';return true;" title="Show Current Month">March 2023</td>
<td id="today_Next_ID" style="cursor:default" align="center" class="calendarDateInput" onclick="today_Object.next.go()" onmousedown="VirtualButton(this,true)" onmouseup="VirtualButton(this,false)" onmouseover="return today_Object.next.hover(this,true)" onmouseout="return today_Object.next.hover(this,false)" title="April"><img src="/img/next.gif"></td></tr>
<tr>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">S</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">M</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">T</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">W</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">T</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">F</td>
<td width="27" align="center" class="calendarDateInput" style="height:24;width:27;font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">S</td>
</tr>
</tbody></table>

</span></td>
</tr>
</tbody></table>                                                      
                                                <div class="row">
                                        <div class="form-group col-md-6">

                                                           <label for="date_of_birth">जन्म स्थान / Place of Birth <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="birth_place" name="birth_place" placeholder="PLACE OF BIRTH" value="" required="">  
                                                            </div>

												 <div class="row">
                                        <div class="form-group col-md-6">
                                                    <label for="father_name">पिता का नाम / Father Name <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="father_name" name="father_name" placeholder="FATHER NAME" value="" required="">
                                        <input type="text" class="form-control" id="father_aadhar" name="father_aadhar" placeholder="FATHER AADHAR NUMBER" value="">
                                                     </div>
                                                      
                                              <div class="row">
                                        <div class="form-group col-md-6">
                                                     <label for="mother_name">माता का नाम / Mother Name <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="mother_name" name="mother_name" placeholder="MOTHER NAME" value="" required="">
                                        <input type="text" class="form-control" id="mother_aadhar" name="mother_aadhar" placeholder="MOTHER AADHAR NUMBER" value="">
                                                         </div>
                                                         
                                                        
                                                    
													   <div class="row">
                                        <div class="form-group col-md-6">
													
                                                     <label for="birth_address">जन्म के समय पता/Address at time of birth <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="birth_address" name="birth_address" placeholder="ADDRESS OF BIRTH" value="" required="">
                                        </div>

											  <div class="row">
                                        <div class="form-group col-md-6">		
                                     <label for="permanent_address">स्थायी पता / Permanent Address <span class="text-danger"> </span></label>
                                        <input type="text" class="form-control" id="permanent_address" name="permanent_address" placeholder="PERMANENT ADDRESS" value="" required="">
                                           </div>

												<div class="row">
                                        <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="DD/MM/YYYY" value="" 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 class="form-group col-md-6">
                                        <label for="unitname">पंजीकरण की इकाई का नाम / Unit Name of Registration <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" name="unitname" style="text-transform:uppercase" placeholder="Gram Panchayat">
                                           
                                           
                                        </div>
                                    </div>
                     <?php 
                    $unitcode = str_pad(rand(0, 99999), 5, '0', STR_PAD_LEFT); 
                    ?>

                                     <div class="form-group col-md-6">
    <label for="unitcode">पंजीकरण की इकाई कोड / Unit Code of Registration <span class="text-danger">*</span></label>
    <input type="text" class="form-control" name="unitcode" placeholder="56983" style="text-transform:uppercase" value="<?php echo $unitcode; ?>">
      </div>
    


                                        
													<div class="form-group col-md-12">
                                        <label for="hospital_id">Hospital <span class="text-danger">*</span></label>
                                        <select type="text" class="form-control" 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>

                                </div>
                                <!-- /.card-body -->

                                 </div><table width="25%" border="0" cellpadding="2" cellspacing="2">
                                                            <tbody>
                                                                <tr>
                                                                    <td>
                                                                        <input name="submit" type="submit" id="submit" value="Save" class="btn" tabindex="61">                                                                    </td>
                                                                    <td>
                                                                        <input class="btn" tabindex="62" value="Cancel" type="button" onclick="document.location.href='/dashboard/index.php';">                                                                    </td>
                                                                </tr>
                            </form>
                        </div>

                    <?php
                    }

                    ?>

<!-- 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>
    function alertMessage(type, message) {
        if (type == 'error') {
            type = 'danger';
        }

        return "<div class='alert alert-" + type + " alert-dismissible'> <a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> " + message + " </div>";
    }
</script>

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


    function getHospitalsByStateId() {
        var state_id = $("#state_id").val();
        $.ajax({
            type: "POST",
            url: "http://crsorgiup.co.in/admin/getHospitalsByStateId",
            data: {
                state_id: state_id,
                "_token": "aJ3saaa9dqVqVIcyVh3fTV2Kn6NB8M1sXOcpjcAS"
            },
            beforeSend: function(data) {
                $(".main-loader").show();
            },
            success: function(response) {
                setTimeout(function() {
                    $(".main-loader").hide();
                    var obj;
                    try {
                        obj = JSON.parse(response);

                        if (obj.status == 'success') {

                            var records = obj.records;

                            var row_html = "<option value=''>Select Hospital</option>";

                            for (i = 0; i < records.length; i++) {
                                var row = records[i];
                                row_html += "<option value='" + row.id + "'>" + row.name + "</option>";
                            }
                            $("#hospital_id").html(row_html);

                        } else {

                            $.toast({
                                heading: '',
                                text: obj.message,
                                position: 'top-right',
                                stack: false,
                                icon: 'error',
                                loader: false
                            });

                        }
                    } catch (err) {

                        $.toast({
                            heading: '',
                            text: 'Some error occurred, please try again.',
                            position: 'top-right',
                            stack: false,
                            icon: 'error',
                            loader: false
                        });

                    }
                }, 100);
            },
            error: function() {
                $(".main-loader").hide();

                $.toast({
                    heading: '',
                    text: 'Some error occurred, please try again.',
                    position: 'top-right',
                    stack: false,
                    icon: 'error',
                    loader: false
                });

            }

        });
    }
</script>

</body>

</html>