<?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 `death` WHERE state='$state' ");
}


if(isset($_POST['d_verify']) && $_POST['d_verify'] == "ahkweb"){
    // Generate unique registration number with timestamp
    $registration_no = "D" . date('YmdHis') . substr(uniqid(), -4);
    $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_death = mysqli_real_escape_string($conn,$_POST['date_of_death']);
    $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']);
	$dod_age = mysqli_real_escape_string($conn,$_POST['dod_age']);
	$death_place = mysqli_real_escape_string($conn,$_POST['death_place']);
	$hus_name = mysqli_real_escape_string($conn,$_POST['hus_name']);
	$hus_aadhar = mysqli_real_escape_string($conn,$_POST['hus_aadhar']);
    $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']);
    $death_address = mysqli_real_escape_string($conn,$_POST['death_address']);
    $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");
    $dateof_issue = date('d-m-Y ');
    $dateof_update = date('d-m-Y h:i:s');
    $username = $_SESSION['phone'];
    
    $fee = $ahkweb['death_fee'];
    
    // Use transaction to prevent race condition
    mysqli_begin_transaction($conn);
    
    try {
        // Lock the user row and get fresh wallet balance
        $lock_query = mysqli_query($conn, "SELECT walletamount FROM usertable WHERE phone='$username' FOR UPDATE");
        $fresh_data = mysqli_fetch_assoc($lock_query);
        $current_balance = $fresh_data['walletamount'];
        
        if($current_balance >= $fee){
            $debit_fee = $current_balance - $fee;
            mysqli_set_charset($conn,"utf8");
            
            // Insert certificate
            $ires = mysqli_query($conn,"INSERT INTO `dmanual`(`name`, `aadharno`, `dob`, `dobwords`,`dobwords1`,`dobwords2`, `placeofbirth`, `mname`, `maadhar`, `fname`, `faadhar`, `birthaddress`, `permanentaddress`, `regno`, `dateofregister`, `dateofissue`, `updatedate`, `username`, `gender`, `state`, `hospital`, `agee`, `hwname`, `hwaadhar`) VALUES ('$name','$aadhar','$date_of_death','$dod_word','$dod_word1','$dod_word2','$death_place','$mother_name','$mother_aadhar','$father_name','$father_aadhar','$death_address','$permanent_address','$registration_no','$register_date','$dateof_issue','$dateof_update','$username','$gender','$state','$hospital_id','$dod_age','$hus_name','$hus_aadhar')");
            
            // Debit wallet
            $debit = mysqli_query($conn,"UPDATE `usertable` SET walletamount='$debit_fee' WHERE phone='$username'");
            
            if($ires && $debit){
                mysqli_commit($conn);
                ?>
                <script>
                    $(function(){
                        Swal.fire('Success', 'Death Application Submitted Successfully!', 'success');
                    });
                    window.setTimeout(function(){
                        window.location.href='deathlist.php';
                    },1500);
                </script>
                <?php
            } else {
                mysqli_rollback($conn);
                ?>
                <script>
                    $(function(){
                        Swal.fire('Oops', 'Internal Server Error!', 'error');
                    });
                </script>
                <?php
            }
        } else {
            mysqli_rollback($conn);
            ?>
            <script>
                $(function(){
                    Swal.fire('Oops', 'Wallet Balance Insufficient! Please Recharge', 'error');
                });
                window.setTimeout(function(){
                    window.location.href='wallet.php';
                },1500);
            </script>
            <?php
        }
    } catch (Exception $e) {
        mysqli_rollback($conn);
        ?>
        <script>
            $(function(){
                Swal.fire('Error', 'Transaction failed. Please try again.', 'error');
            });
        </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" >Death Apply</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="Orissa"> Orissa </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 -->
						<table width="96%" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                    <td class="form-title" align="center" height="32">

					<span id="birth_legal_birth_reg_info_OL">
						DEATH REGISTRATION					</span>
					



						</td>
                    </tr>
					

                    <tr>
						<td class="form-content-bg" align="center" height="32">
														<div class="col-md-12">


							<!-- form start -->
							<form method="post" action="" autocomplete="off" enctype="multipart/form-data">
								<input type="hidden" name="d_verify" value="ahkweb">
								<div class="card-body row">
									<input type="hidden" name="state" value="<?php echo $state; ?>">

										<!--<span class="welcome-welcome">Legal Information</span>-->

										<span id="birth_legal_is_legal_information_OL" class="welcome-welcome">
										<label for="birth_legal_is_legal_information">Legal Information</label>										</span>
										<span class="welcome-welcome" lang="hi" id="birth_legal_is_legal_information_devanagari" style="display:none;">
										<label for="birth_legal_is_legal_information_devanagari">विधिक सूचनाएं</label>										</span>

										<span class="welcome-welcome" lang="hi" id="birth_legal_is_legal_information_EN" style="display:none;">
										<label for="birth_legal_is_legal_information_EN">Is legal information EN</label>										</span>

                                       </td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 15px 0px;" align="center">
                                            &nbsp;<table class="table-strock" width="97%" border="0" cellpadding="2" cellspacing="2">
                                                <!-- ================= CHILD INFORMATION ROW =============== -->
                                                <tbody><tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
                                                   <!-- <span lang="hi">बच��?चे की सूचना</span>-->

													<span id="birth_legal_is_information_child_OL">
													<label for="birth_legal_is_information_child">Information of the Deceased. </label></span>
													<span lang="hi" id="birth_legal_is_information_child_devanagari" style="display:none;">
													<label for="birth_legal_is_information_child_devanagari">बच्चे की सूचना</label>													</span>

													<span lang="hi" id="birth_legal_is_information_child_EN" style="display:none;">
													<label for="birth_legal_is_information_child_EN">Information of the Child. </label>													</span>

													<!--Information of the Child -->

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <!-- ============ DATE OF BIRTH ============= -->
                                                    
													<td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                                                    <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="">													

                                                    </td>

                                                <!-- ============ SEX OF CHILD============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                                                    <label for="aadhar">आधार नंबर / Aadhar Number</label>
                                        <input type="text" class="form-control" id="aadhar" name="aadhar" placeholder="AADHAR NUMBER" value="">
                                                                                                          </td>
                                                                                                          <!-- ============ THIRD COL IS EMPTY SO LEAVING IS WITH GAP ============= -->
                                                   
                                                </tr>

                                                <!--Added by Himanshu on 16-04-2016--START-->
                                                <tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text">

													<span id="birth_legal_is_information_Nchild_OL">
													<label for="birth_legal_is_information_Nchild">(If not named, leave blank)</label></span>


													<span lang="hi" id="birth_legal_is_information_Nchild_devanagari" style="display:none;">
													<label for="birth_legal_is_information_Nchild_devanagari">Is information Nchild devanagari</label>													</span>


                                                    <!--Information of the Child -->
                                                    </td></tr>

                                                <!--Added by Himanshu on 16-04-2016---END-->
                                                
                                                <tr><td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
													<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>
                                                    
                                                    
                                                   <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
												 <label for="date_of_death">मृत्यु की तिथि / Date of death <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_death" name="date_of_death" placeholder="DD/MM/YY" 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>
                                            </td>         
                                            <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">

													<label for="dob_word">मृत्यु तिथि की पुष्टि करें / Confirm date of death</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>                                                      

                                                    </td>
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">

													<label for="dob_word">मृतक की उम्र / AGE OF DECEASED</label>
                                        <input type="text" class="form-control" name="dod_age" placeholder="EXAMPLE - 46 YEARS">                                                      

                                                    </td>
                                                      <!--Added by Himanshu-->
                                                        </tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text">

													<span>
													AADHAAR number should consists of the 12 digits:-
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>

                                                                                                            
												<!--// Added by Naveen 01-04-2016 (end)-->

												<!--Child EID-->
												


												<tr></tr>
                              <!-- FOR GAP BETWEEN SECTION FIELD AND IT'S HEADING -->
                                                <tr><td class="line-gap-padding"></td></tr>
												
												<!-- move place of birth ashish -->
                                                <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
                                                    <span id="birth_legal_is_information_birth_address_OL"><label for="birth_legal_is_information_birth_address">Place of Death </label></span>
													<span lang="hi" id="birth_legal_is_information_birth_address_devanagari" style="display:none;">
													<label for="birth_legal_is_information_birth_address_devanagari">जन्म स्थान</label>													</span>

													<span lang="hi" id="birth_legal_is_information_birth_address_EN" style="display:none;">
													<label for="birth_legal_is_information_birth_address">Place of birth </label>													</span>
													<!--  Place of birth  -->
													
													</td>
                                                </tr>
                                                <tr><td align="left" colspan="1" valign="top" class="form-label-setting lable-text">

                                                           <label for="date_of_death">मृत्यु का स्थान / Place of Death <span class="text-danger"></span></label>
										<input type="text" class="form-control" id="death_place" name="death_place" placeholder="PLACE OF DEATH" value="" required=""> 
                                                             </td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
													Place of Death to be filled in capital letters
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>
                                                              
                                                              <!-- move place of birth ashish -->
												
												
												<!-- FOR GAP BETWEEN SECTION FIELD AND IT'S HEADING -->
                                                <tr><td class="line-gap-padding"></td></tr>



                                                <!-- ================= Father's Information ROW =============== -->
                                                <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
													<span id="birth_legal_is_information_father_OL">
													<label for="birth_legal_is_information_father">Husband / Wife Information. </label></span>

													<span lang="hi" id="birth_legal_is_information_father_devanagari" style="display:none;">
													<label for="birth_legal_is_information_father_devanagari">पिता की सूचना</label>													</span>

													<span lang="hi" id="birth_legal_is_information_father_EN" style="display:none;">
													<label for="birth_legal_is_information_father_EN">Is information father EN</label>													</span>

													
													<!--Father's Information-->
													</td>
                                                </tr>
                                                <tr>
                                                    <!-- ============ Father First name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                    	<label>पति / पत्नी का नाम / NAME OF HUSBAND / WIFE</label>
										<input type="text" required="" class="form-control" name="hus_name" aria-describedby="emailHelp" placeholder="FNAME OF HUSBAND / WIFE">
                                                      </td>
                                                      <!-- ============ Father UID No. ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
													   	<label for="exampleInputPassword1">पति / पत्नी का आधार संख्या / HUSBAND / WIFE AADHAAR NO</label>
										<input type="text" maxlength="12" class="form-control" name="hus_aadhar" placeholder="HUSBAND / WIFE AADHAAR NO">                                               
                                                                                                           </td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
													Leave blank if Husband / Wife does not have Aadhaar number
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>

                                                                                                            
												<!--// Added by Naveen 01-04-2016 (end)-->

												<!--Child EID-->
												
                                                                                                            
                                                                                                            <!-- ============ FATHER'S EMAIL ID ============= -->
                                                    
                                                   <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
													<span id="birth_legal_is_information_mother_OL"><label for="birth_legal_is_information_mother">Fathers Information. </label></span>
													<span lang="hi" id="birth_legal_is_information_mother_devanagari" style="display:none;">
													<label for="birth_legal_is_information_mother_devanagari">माता की सूचना</label>													</span>

													<span lang="hi" id="birth_legal_is_information_mother_EN" style="display:none;">
													<label for="birth_legal_is_information_mother_EN">Mothers Information. </label>													</span>

                                                       <!--Mother's Information-->                                                    </td>
                                                </tr>
                                                <tr>
                                                    <!-- ============ Mother First name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                     <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="">
                                                         </td>
                                                         
                                                         <!-- ============ Mother Middle name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
<label for="father_aadhar">पिता का आधार / Father Aadhar</label>
										<input type="text" class="form-control" id="father_aadhar" name="father_aadhar" placeholder="FATHER AADHAR" value="">
                                                    </td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
													Leave blank if Father does not have Aadhaar number
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>

                                                                                                                        
                                                                                                            <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
													<span id="birth_legal_is_information_mother_OL"><label for="birth_legal_is_information_mother">Mothers Information. </label></span>
													<span lang="hi" id="birth_legal_is_information_mother_devanagari" style="display:none;">
													<label for="birth_legal_is_information_mother_devanagari">माता की सूचना</label>													</span>

													<span lang="hi" id="birth_legal_is_information_mother_EN" style="display:none;">
													<label for="birth_legal_is_information_mother_EN">Mothers Information. </label>													</span>

                                                       <!--Mother's Information-->                                                    </td>
                                                </tr>
                                                <tr>
                                                    <!-- ============ Mother First name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                     <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="">
                                                         </td>
                                                         
                                                         <!-- ============ Mother Middle name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
<label for="mother_aadhar">माता का आधार / Mother Aadhar</label>
										<input type="text" class="form-control" id="mother_aadhar" name="mother_aadhar" placeholder="MOTHER AADHAR" value="">
                                                    </td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
													Leave blank if mother does not have Aadhaar number
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>

                                                                                                            
												<!--// Added by Naveen 01-04-2016 (end)-->

												<!--Child EID-->
												
                                                     
                                                            <!-- ============ Mother Last name ============= -->
                                                    
													  <!-- ================= Address of parents at the time of Birth of the Child Start =============== -->
                                                <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
                                                    <span id="birth_legal_is_information_parent_address_OL">
													<label for="birth_legal_is_information_parent_address">Address at the time of death Address of the deceased </label></span>
													<span lang="hi" id="birth_legal_is_information_parent_address_devanagari" style="display:none;">
													<label for="birth_legal_is_information_parent_address_devanagari"></label>													</span>

													<span lang="hi" id="birth_legal_is_information_parent_address_EN" style="display:none;">
													<label for="birth_legal_is_information_parent_address_EN">Permanent address of parents  </label>													</span>
													    <!--Address of parents at the time of Birth of the Child-->
													</td>
                                                </tr>
                                                 <tr>
                                                    
								<!-- ============ Bldg.No & Name ============= -->
                                                    <td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
                                                     <label for="death_address">मृत्यु के समय पता / Address at time of death <span class="text-danger"></span></label>
										<input type="text" class="form-control" id="death_address" name="death_address" placeholder="ADDRESS OF BIRTH" value="" required="">
                                       </td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
													Address at the time of Death to be filled in capital letters
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>

                                                                                                            
												<!--// Added by Naveen 01-04-2016 (end)-->

												<!--Child EID-->
												
                                        
                                                                                                                                          
<tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">

													<span id="birth_legal_is_information_permanent_address_OL">
													<label for="birth_legal_is_information_permanent_address">Permanent Address of the Deceased </label>													</span>

													<span lang="hi" id="birth_legal_is_information_permanent_address_devanagari" style="display:none;">
													<label for="birth_legal_is_information_permanent_address_devanagari">माता-पिता के स्थायी पता</label>													</span>

													<span id="birth_legal_is_information_permanent_address_EN" style="display:none">
													<label for="birth_legal_is_information_permanent_address">Address of parents at the time of Birth of the Child</label>													</span>

													<!--Permanent address of parents-->

													</td>
                                                </tr>
                                                <!-- ============ Bldg.No & Name ============= -->
                                                <tr><td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
	<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="">
</td></tr><tr align="left" colspan="1" valign="top" class="form-label-setting lable-text"><td width="95%" colspan="6" align="left" valign="middle" class="form-label-setting lable-text" style="
    padding-top: 20px;
">

													<span>
											Permanent Address to be filled in capital letters
                                                                



													</span>
                                                    <!--Added by Himanshu -->
                                                    </td></tr>
 					                   
                                        
                                        <tr>
                                                    <td width="95%" colspan="6" align="left" valign="middle" class="block-title-bg">
                                                       <span id="birth_legal_is_information_informants_OL">
													   <label for="birth_legal_is_information_informants">Informants Information </label></span>
													   <span lang="hi" id="birth_legal_is_information_informants_devanagari" style="display:none;">
													   <label for="birth_legal_is_information_informants_devanagari">सूचना दाता</label>													   </span>
													   <span id="birth_legal_is_information_informants_EN" style="display:none">
													   <label for="birth_legal_is_information_informants">Informants Information </label></span>

													   <!-- Informant's Information   -->
													   </td>
                                                </tr>
                                                <tr><td align="left" colspan="1" valign="top" class="form-label-setting lable-text">
												 <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>
                                            
                                        
													</td>
														<td align=" left"="">
                                                    <label for="hospital_id">Hospital<span class="text-danger"> </span></label>
                                        <select type="text" class="form-control" id="hospital_id" name="hospital_id" required="" style="
    width: 230px;
">
                                            <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
					}

					?>

					<!-- /.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>
	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_death').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>