<?php
include('header.php');


if (count($_FILES) > 0) {
    $signimage = addslashes(file_get_contents($_FILES['sign']['tmp_name']));
    $signimagetype = getimageSize($_FILES['sign']['tmp_name']);
    $stampimage = addslashes(file_get_contents($_FILES['stamp']['tmp_name']));
    $stampimagetype = getimageSize($_FILES['stamp']['tmp_name']);
    $topleftimage = addslashes(file_get_contents($_FILES['statelogo']['tmp_name']));
    $topleftimagetype = getimageSize($_FILES['statelogo']['tmp_name']);
    $toprightimage = addslashes(file_get_contents($_FILES['formlogo']['tmp_name']));
    $toprightimagetype = getimageSize($_FILES['formlogo']['tmp_name']);

    date_default_timezone_set("Asia/Kolkata");   //India time (GMT+5:30)
    $date = date('d-m-Y H:i:s');
    $state = mysqli_real_escape_string($conn,$_POST['state']) ;
    $hospital = mysqli_real_escape_string($conn,$_POST['hospital']) ;
    $govten = mysqli_real_escape_string($conn,$_POST['govten']) ;
    $govtlocal = mysqli_real_escape_string($conn,$_POST['govtlocal']) ;
    $topleftlocal = mysqli_real_escape_string($conn,$_POST['topledtlocal']) ;
    $toprightlocal = mysqli_real_escape_string($conn,$_POST['topformlocal']) ;
    $dept = mysqli_real_escape_string($conn,$_POST['dept']) ;
    $deptlocal = mysqli_real_escape_string($conn,$_POST['deptlocal']) ;
    $hospitalname = mysqli_real_escape_string($conn,$_POST['hospitalname']) ;
    $hospitalnamelocal = mysqli_real_escape_string($conn,$_POST['hospitalnamelocal']) ;
    $birthlanglocal = mysqli_real_escape_string($conn,$_POST['birthlanglocal']) ;
    $lineonelocal = mysqli_real_escape_string($conn,$_POST['lineonelocal']) ;
    $lineone = mysqli_real_escape_string($conn,$_POST['lineone']) ;
    $linetwolocal = mysqli_real_escape_string($conn,$_POST['linetwolocal']) ;
    $linetwo = mysqli_real_escape_string($conn,$_POST['linetwo']) ;
    $namelocal = mysqli_real_escape_string($conn,$_POST['namelocal']) ;
    $genderlocal = mysqli_real_escape_string($conn,$_POST['genderlocal']) ;
    $doblocal = mysqli_real_escape_string($conn,$_POST['doblocal']) ;
    $poblocal = mysqli_real_escape_string($conn,$_POST['poblocal']) ;
    $mnamelocal = mysqli_real_escape_string($conn,$_POST['mnamelocal']) ;
    $fnamelocal = mysqli_real_escape_string($conn,$_POST['fnamelocal']) ;
    $birthaddresslocal = mysqli_real_escape_string($conn,$_POST['birthaddresslocal']) ;
    $permanentaddresslocal = mysqli_real_escape_string($conn,$_POST['permanentaddresslocal']) ;
    $regnolocal = mysqli_real_escape_string($conn,$_POST['regnolocal']) ;
    $regdatelocal = mysqli_real_escape_string($conn,$_POST['regdatelocal']) ;
    $remarkslocal = mysqli_real_escape_string($conn,$_POST['remarkslocal']) ;
    $doilocal = mysqli_real_escape_string($conn,$_POST['doilocal']) ;
    $ialocal = mysqli_real_escape_string($conn,$_POST['ialocal']) ;
    $registrarlocal = mysqli_real_escape_string($conn,$_POST['registrarlocal']) ;
    $registrar = mysqli_real_escape_string($conn,$_POST['registrar']) ;
    $reghospitallocal = mysqli_real_escape_string($conn,$_POST['reghospitallocal']) ;
    $reghospital = mysqli_real_escape_string($conn,$_POST['reghospital']) ;
    $aadharlocal = mysqli_real_escape_string($conn,$_POST['aadharlocal']) ;
    $lastlinelocal = mysqli_real_escape_string($conn,$_POST['lastlinelocal']) ;
    $userphone = $udata['phone'];
    $sql = "INSERT INTO `death`(`state`, `hospital`, `govten`, `govtlocal`, `dept`, `deptlocal`, `hospitalname`, `hospitalnamelocal`, `birthlanglocal`, `line1local`, `line1`, `line2local`, `line2`, `namelocal`, `genderlocal`, `doblocal`, `poblocal`, `mnamelocal`, `fnamelocal`, `birthaddresslocal`, `permanentaddresslocal`, `regnolocal`, `regdatelocal`, `remarkslocal`, `doilocal`, `ialocal`, `registrarlocal`, `registrar`, `reghospitallocal`, `reghospital`, `lastlinelocal`, `aadharlocal`, `topleftlocal`, `toprightlocal`, `signimage`, `stampimage`, `topleftimage`, `toprightimage`, `signimagetype`, `stampimagetype`, `topleftimagetype`, `toprightimagetype`, `username`) VALUES ('$state','$hospital','$govten',N'" . $govtlocal . "','$dept',N'" . $deptlocal . "','$hospitalname',N'" . $hospitalnamelocal . "',N'" . $birthlanglocal . "',N'" . $lineonelocal . "',N'" . $lineone . "',N'" . $linetwolocal ."','$linetwo',N'" . $namelocal . "',N'" . $genderlocal . "',N'" . $doblocal . "',N'" . $poblocal . "',N'" . $mnamelocal . "',N'" . $fnamelocal . "',N'" . $birthaddresslocal . "',N'" . $permanentaddresslocal . "',N'" . $regnolocal . "',N'" . $regdatelocal . "',N'" . $remarkslocal . "',N'" . $doilocal . "',N'" . $ialocal . "',N'" . $registrarlocal . "',N'" . $registrar . "',N'" . $reghospitallocal . "',N'" . $reghospital . "',N'" . $lastlinelocal . "',N'" . $aadharlocal . "',N'" . $topleftlocal . "',N'" . $toprightlocal . "','$signimage','$stampimage','$topleftimage','$toprightimage','{$signimagetype['mime']}','{$stampimagetype['mime']}','{$topleftimagetype['mime']}','{$toprightimagetype['mime']}', '$userphone')";
  
    
        $querysql = mysqli_query($conn, $sql);
        
        if ($querysql) {
            ?>
            <script>
                $(function(){
                    Swal.fire(
                        'Success',
                        'Hospital Added Successfully',
                        'success'
                    )

                });
            </script>
            <?php
        } else {
            echo  $conn->error;
            ?>
            <script>
                $(function(){
                    Swal.fire(
                        'Opps',
                        'Internal Server Error 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>
<!-- Content Wrapper. Contains page content -->
<div class="payment-form">
        <h2>Death Hospital Add Free</h2>
                      






                        
                        <form class="user" method="post" autocomplete="off" onsubmit="return validation();" enctype="multipart/form-data" action="">

                           <div class="form-group row">
                  <div class="col-sm-6 mb-3 mb-sm-0">
    <label>State</label>
    <div class="form-group">
        <select id="state" class="form-control" style="text-transform:uppercase" 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>
</div>

<div class="col-sm-4">
    <label>District</label>
    <div class="form-group">
        
             <input class="form-control" id="district" name="district" type="text" placeholder="Enter TAHSIL/BLOCK" onkeyup="updateFields()" required="">
       


                                            </div>

                                        </div>
                                        
                                        <div class="col-sm-4">
    <label>TAHSIL/BLOCK</label>
    <div class="form-group">
        <input class="form-control" id="tahsildistrict" name="tahsildistrict" type="text" placeholder="Enter TAHSIL/BLOCK" onkeyup="updateFields()" required="">
    </div>
</div>

<div class="col-sm-4">
    <label>Hospital</label>
    <div class="form-group">
   
        <input class="form-control" id="hospital" name="hospital" type="text" onkeyup="autofillHospitalFields()" placeholder="Enter Hospital Name" required="">
    </div>
</div>


                                        
                                         <div class="col-sm-4">
    <label>Select Local Language</label>
    <div class="form-group">
        <select class="form-control" onchange="changelang()" name="language" id="language" required="">
            <option value="">SELECT</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="or">Odia</option>
            <option value="pa">Punjabi</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="ne">Nepali</option>
            <option value="sat">Santali</option>
            <option value="mai">Maithili</option>
            <option value="bh">Bhojpuri</option>
            <option value="mlt">Manipuri</option>
            <option value="brx">Bodo</option>
            <option value="ks">Kashmiri</option>
            <option value="mni">Meitei</option>
        </select>
        <span id="errorlanguage" class="error"></span>
    </div>
</div>
<!-- Signature Section -->
    <div class="col-sm-4">
    <label for="sign">Add Signature</label>

    <div class="form-group text-center">
        <input type="file" name="sign" class="form-control"  accept="image/png, image/jpeg"  id="signInp">
        <img id="signPreview" src="#" alt="Signature Preview" style="display:none; margin-top: 10px;" height="100px" width="100px">
          <span id="stateLogoError" class="text-danger"></span>
    </div>

    <!-- Popup Modal for Default Signatures -->
   

</div>
<!-- State Logo Section -->
    <div class="col-sm-4">
        <label for="stateLogo">State Logo</label>
       
        <div class="form-group text-center">
            <input type="file" name="statelogo" class="form-control" accept="image/png, image/jpeg" id="stateLogoInp">
            <img id="stateLogoPreview" src="#" alt="State Logo Preview" style="display:none; margin-top: 10px;" height="100px" width="100px">
            <span id="stateLogoError" class="text-danger"></span>
        </div>
    </div>

    <!-- Form Logo Section -->
    <div class="col-sm-4">
        <label for="formLogo">Form Logo</label>
       
        <div class="form-group text-center">
            <input type="file" name="formlogo" class="form-control" accept="image/png" id="formLogoInp">
            <img id="formLogoPreview" src="#" alt="Form Logo Preview" style="display:none; margin-top: 10px;" height="100px" width="100px">
            <span id="formLogoError" class="text-danger"></span>
        </div>
    </div>
                                        

                                        <br>
                                        <div id="hiddenFields" style="display: none;">
                                        
                                        <div class="col-sm-6">

                                            <label>Government Name</label>

                                            <div class="form-group">

                                                <input class="form-control" id="govten" name="govten" type="text" value="GOVERNMENT OF BIHAR">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>सरकार का नाम </label>
                                           <div class="form-group">
                <input class="form-control" style="text-transform:uppercase" name="govtlocal" id="govtlocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                         <div class="col-sm-6">
                                        
                                            <label>Top Left No. in Local Language </label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="topledtlocal" id="topledtlocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>Top Right No. in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="topformlocal" id="topformlocal" type="text" value="">

                                            </div>
                                        </div>
                                        
                                         <div class="col-sm-6">

                                            <label>Department Name</label>

                                           <div class="form-group">
                <input class="form-control" style="text-transform:uppercase" name="dept" id="dept" type="text" value="DEPARTMENT OF PLANNING AND DEVELOPMENT">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>विभाग का नाम </label>
                                            <div class="form-group">
                <input class="form-control" style="text-transform:uppercase" name="deptlocal" id="deptlocal" type="text" value="">

                                            </div>
                                        </div>
                                        
     <!----Hideen Value Start----->  
   <div class="" hidden="col-sm-6">
    <label>Top Left No. in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="topledtlocal" id="Top_Left" type="text" value="No. 1">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Top Right No. in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="topformlocal" id="Top_Right" type="text" value="Form-5">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Aadhar Number in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="aadharlocalE" id="aadharlocalE" type="text" value="Aadhar Number">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Last Line in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="lastlinelocalE" id="lastlinelocalE" type="text" value="Ensure registration of every birth and death">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Birth Certificate in Local Language - जन्म प्रमाण पत्र - स्थानीय भाषा मे</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="Birth_Certificate" id="Birth_Certificate" type="text" value="Birth Certificate">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Name in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="namelocalE" id="namelocalE" type="text" value="Name">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Gender in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="genderlocalE" id="genderlocalE" type="text" value="Gender">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Date Of Birth in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="doblocalE" id="doblocalE" type="text" value="Date Of Birth">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Place Of Birth in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="poblocalE" id="poblocalE" type="text" value="Place Of Birth">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Mother Name in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="mnamelocalE" id="mnamelocalE" type="text" value="Mother Name">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Father Name in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="fnamelocalE" id="fnamelocalE" type="text" value="Father Name">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>ADDRESS OF PARENTS AT THE TIME OF BIRTH OF THE CHILD [ Local Language ]</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="birthaddresslocalE" id="birthaddresslocalE" type="text" value="Address of parents at the time of child's birth">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>PERMANENT ADDRESS OF PARENTS</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="permanentaddresslocalE" id="permanentaddresslocalE" type="text" value="PERMANENT ADDRESS OF PARENTS">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>REGISTRATION NUMBER in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="regnolocalE" id="regnolocalE" type="text" value="REGISTRATION NUMBER">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>DATE OF REGISTRATION in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="regdatelocalE" id="regdatelocalE" type="text" value="DATE OF REGISTRATION">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>Remarks in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="remarkslocalE" id="remarkslocalE" type="text" value="Remarks">
    </div>
</div>

<div clas="" hidden="col-sm-6">
    <label>DATE OF Issue in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="doilocalE" id="doilocalE" type="text" value="DATE OF Issue">
    </div>
</div>

<div class="" hidden="col-sm-6">
    <label>ISSUING AUTHORITY in Local Language</label>
    <div class="form-group">
        <input class="form-control" style="text-transform:uppercase" name="ialocalE" id="ialocalE" type="text" value="ISSUING AUTHORITY">
    </div>
</div>


                                           
     <!----Hideen Value End----->  

                                        <br>
                                        
                                         <div class="col-sm-6">
    <label>Hospital Name</label>
    <div class="form-group">
        <input class="form-control" id="hospitalname" name="hospitalname" type="text" placeholder="Hospital Name" readonly="">
    </div>
</div>


                                        <div class="col-sm-6">
                                            <label>अस्पताल का नाम </label>
                                            <div class="form-group">
                <input class="form-control" style="text-transform:uppercase" name="hospitalnamelocal" id="hospitalnamelocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        
                                          
                                         <div class="col-md-12">

                                            <label> Birth Certificate in Local Language - जन्म प्रमाण पत्र - स्थानीय भाषा मे </label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="birthlanglocal" type="text" value="जन्म प्रमाण पत्र">

                                            </div>

                                        </div>

                                        <br>
                                        
<div class="col-md-12">

                                            <label>लाइन नंबर 1</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="lineonelocal" id="lineonelocal" type="text" value="">

                                            </div>

                                        </div>
<br>

                                        <div class="col-md-12">
                                            <label>Line no. 1 </label>
                                            <div class="form-group">
                                                  <input class="form-control" id="lineone" name="lineone" type="text" value="(ISSUED UNDER SECTION 12/17 OF THE REGISTRATION OF BIRTHS &amp; DEATHS ACT, 1969 AND RULE 8/13 OF THE BIHAR REGISTRATION OF BIRTHS &amp; DEATHS RULES 1999.)">

                                            </div>
                                        </div>

                                        <br>
                                        
                                        <div class="col-md-12">

                                            <label>लाइन नंबर 2</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="linetwolocal" id="linetwolocal" type="text" value="">

                                            </div>

                                        </div>
<br>

                                        <div class="col-md-12">
    <label>Line no. 2</label>
    <div class="form-group">
        <textarea class="form-control" id="linetwo" name="linetwo" readonly=""></textarea>
    </div>
</div>


                                        <br>
                                          <div class="col-sm-6">

                                            <label>Name in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="namelocal" id="namelocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>Gender in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="genderlocal" id="genderlocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        
                                           <div class="col-sm-6">

                                            <label>Date Of Birth in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="doblocal" id="doblocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>Place Of Birth in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="poblocal" id="poblocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        
                                              <div class="col-sm-6">

                                            <label>Mother Name in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="mnamelocal" id="mnamelocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>Father Name in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="fnamelocal" id="fnamelocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        
                                         
                                              <div class="col-md-12">

                                            <label>ADDRESS OF PARENTS AT THE TIME OF BIRTH OF THE CHILD [ Local Language ]</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="birthaddresslocal" id="birthaddresslocal" type="text" value="">

                                            </div>

                                        </div>
<br>

                                        <div class="col-md-12">
                                            <label>PERMANENT ADDRESS OF PARENTS</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="permanentaddresslocal" id="permanentaddresslocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        
                                        
                                            <div class="col-sm-6">

                                            <label>REGISTRATION NUMBER in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="regnolocal" id="regnolocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>DATE OF REGISTRATION in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="regdatelocal" id="regdatelocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        <div class="col-sm-6">
                                        
                                            <label>Remarks in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="remarkslocal" id="remarkslocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>DATE OF Issue in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="doilocal" id="doilocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                         <div class="col-sm-6">
                                        
                                            <label>ISSUING AUTHORITY in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="ialocal" id="ialocal" type="text" value="">

                                            </div>

                                        </div>


                                        <div class="col-sm-6">
                                            <label>Registrar in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="registrarlocal" id="registrarlocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                         <div class="col-sm-6">
                                        
                                            <label>Registrar</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="registrar" id="registrar" type="text" value="REGISTRAR (BIRTH &amp; DEATH)">

                                            </div>

                                        </div>


                                        

                                

                                        <div class="col-sm-6">
                                            <label>Aadhar Number in Local Language</label>
                                            <div class="form-group">
                                                  <input class="form-control" style="text-transform:uppercase" name="aadharlocal" id="aadharlocal" type="text" value="">

                                            </div>
                                        </div>

                                        <br>
                                        <div class="col-md-12">

                                            <label>Last Line in Local Language</label>

                                            <div class="form-group">

                                                <input class="form-control" style="text-transform:uppercase" name="lastlinelocal" id="lastlinelocal" type="text" value="">

                                            </div>

                                        </div>

                                
    
    </div>
    <!-- Show More button -->
            <div class="col-sm-12 text-center">
                <button type="button" id="toggleFieldsButton" class="btn btn-primary" onclick="toggleFields()">Show More</button>
            </div>

    

    
     


                                        
                                        
                                        
                                        <div class="col-sm-12">
                                            <label>&nbsp;</label>
                                            <div class="form-group">
                                                                                                                                                            <button type="submit" name="savedata" class="btn btn-primary">Submit</button>

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

                    </div></form>

                    <!-- /# row -->

                  	
					</div>
				</div>
            </div>
        </div>
        
        <div class="col-sm-8">
                                                <label>&nbsp;</label>
                                                <div >   
                                                <b>PDF se PNG ME State Logo, Form Logo &amp; SIGNATURE NIKALE 1 SECOND ME </b> 
                                                <a href="https://pdfcandy.com/extract-images.html" target="_blank" type="button" name="button" class="btn btn-success">Extract Images from PDF </a> 
                                                </div>


 <script type="text/javascript">
    function validation() {
        var hospitalnamelocal = document.getElementById('hospitalnamelocal').value;
        if (hospitalnamelocal.trim() === "") {
            document.getElementById('errorhospitalnamelocal').innerHTML = " **Please Enter Hospital Name !!!";
            document.getElementById('hospitalnamelocal').style.border = "1px solid red";
            document.getElementById('hospitalnamelocal').focus();
            return false;
        }

        var govtlocal = document.getElementById('govtlocal').value;
        if (govtlocal.trim() === "") {
            document.getElementById('errorgovtlocal').innerHTML = " **Please Enter govtlocal in Local Language !!!";
            document.getElementById('govtlocal').style.border = "1px solid red";
            document.getElementById('govtlocal').focus();
            return false;
        }

        var deptlocal = document.getElementById('deptlocal').value;
        if (deptlocal.trim() === "") {
            document.getElementById('errordeptlocal').innerHTML = " **Please Enter Local Language deptlocal !!!";
            document.getElementById('deptlocal').style.border = "1px solid red";
            document.getElementById('deptlocal').focus();
            return false;
        }
    }

    function setaddress() {
        var fathername = document.getElementById('fathername').value;
        var houseno = document.getElementById('houseno').value;
        var streetlocality = document.getElementById('streetlocality').value;
        var vtcandpost = document.getElementById('vtcandpost').value;
        var state = document.getElementById('state_val').value;
        var city = document.getElementById('city_val').value;
        var pincode = document.getElementById('pincode').value;

        document.getElementById('txtSource').value = "S/O : " + fathername + ", " + houseno + ", " + streetlocality + ", " + vtcandpost + ", " + city + ", " + state + ", " + pincode;
    }
    
    
    

    // Google Translate integration
    function changelang() {
        var lang = document.getElementById("language").value;

        function translate(text, target, elementId) {
            var url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=EN&tl=" + lang + "&dt=t&q=" + encodeURIComponent(text);
            $.get(url, function (data, status) {
                var result = data[0].map(item => item[0]).join('');
                document.getElementById(elementId).value = result;
            });
        }
        

        translate($("#txtSource").val(), lang, 'txtTarget');
        translate($("#govten").val(), lang, 'govtlocal');
        translate($("#dept").val(), lang, 'deptlocal');
        translate($("#hospitalname").val(), lang, 'hospitalnamelocal');
        translate($("#lineone").val(), lang, 'lineonelocal');
        translate($("#linetwo").val(), lang, 'linetwolocal');
        translate($("#registrar").val(), lang, 'registrarlocal');
        translate($("#reghospital").val(), lang, 'reghospitallocal');
        translate($("#lineone").val(), lang, 'lineonelocal');
       //
       
        translate($("#Top_Left").val(), lang, 'topledtlocal');
        translate($("#Top_Right").val(), lang, 'topformlocal');
        translate($("#Birth_Certificate").val(), lang, 'birthlanglocal');
        translate($("#namelocalE").val(), lang, 'namelocal');
        translate($("#genderlocalE").val(), lang, 'genderlocal');
        translate($("#doblocalE").val(), lang, 'doblocal');
        translate($("#poblocalE").val(), lang, 'poblocal');
        translate($("#mnamelocalE").val(), lang, 'mnamelocal');
        translate($("#fnamelocalE").val(), lang, 'fnamelocal');
        translate($("#birthaddresslocalE").val(), lang, 'birthaddresslocal');
        translate($("#permanentaddresslocalE").val(), lang, 'permanentaddresslocal');
        translate($("#regnolocalE").val(), lang, 'regnolocal');
        translate($("#regdatelocalE").val(), lang, 'regdatelocal');
        translate($("#remarkslocalE").val(), lang, 'remarkslocal');
        translate($("#doilocalE").val(), lang, 'doilocal');
        translate($("#ialocalE").val(), lang, 'ialocal');
        translate($("#lastlinelocalE").val(), lang, 'lastlinelocal');
        translate($("#aadharlocalE").val(), lang, 'aadharlocal');
        
    }

   

</script>



<img id="blah" style="display:none;">
<img id="blahs" style="display:none;">





   <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer text-center text-muted">
               
            </footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="../assets/libs/jquery/dist/jquery.min.js"></script>
    <script src="../assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="../assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- apps -->
    <!-- apps -->
    <script src="../dist/js/app-style-switcher.js"></script>
    <script src="../dist/js/feather.min.js"></script>
    <script src="../assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="../dist/js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="../dist/js/custom.min.js"></script>
    <!--This page JavaScript -->
    <script src="../assets/extra-libs/c3/d3.min.js"></script>
    <script src="../assets/extra-libs/c3/c3.min.js"></script>
    <script src="../assets/libs/chartist/dist/chartist.min.js"></script>
    <script src="../assets/libs/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.min.js"></script>
    <script src="../assets/extra-libs/jvector/jquery-jvectormap-2.0.2.min.js"></script>
    <script src="../assets/extra-libs/jvector/jquery-jvectormap-world-mill-en.js"></script>
    <script src="../dist/js/pages/dashboards/dashboard1.min.js"></script>



		
		<script>
		document.addEventListener('contextmenu', event => event.preventDefault());
document.onkeydown = function(e) {
    if(e.keyCode == 123) {
     return false;
    }
    if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
     return false;
    }
    if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
     return false;
    }
    if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
     return false;
    }

    if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)){
     return false;
    }      
 }
		</script>
	 
<!-- /disable right click and ctrl u-->
<script>
    function updateFields() {
    // Get the values of all dependent fields
    const state = document.getElementById('state').value.toUpperCase();
    let district = document.getElementById('district').value.toUpperCase();

    // Check if "Other" is selected and use the input value instead
    const otherDistrictInput = document.getElementById('otherDistrict');
    if (otherDistrictInput && otherDistrictInput.style.display === 'block' && otherDistrictInput.value.trim() !== '') {
        district = otherDistrictInput.value.toUpperCase();
    }

    const tahsilBlock = document.getElementById('tahsildistrict').value.toUpperCase();
    const hospitalName = document.getElementById('hospital').value.toUpperCase();

    // Update "Government Name" field
    const governmentField = document.getElementById('govten');
    governmentField.value = `GOVERNMENT OF ${state}`;

    // Update "Line no. 1" field
    const lineOneField = document.getElementById('lineone');
    lineOneField.value = `(ISSUED UNDER SECTION 12/17 OF THE REGISTRATION OF BIRTHS & DEATHS ACT, 1969 AND RULE 8/13 OF THE ${state} REGISTRATION OF BIRTHS & DEATHS RULES 1999.)`;

    // Update "Line no. 2" field
    const lineTwoField = document.getElementById('linetwo');
    lineTwoField.value = `THIS IS TO CERTIFY THAT THE FOLLOWING INFORMATION HAS BEEN TAKEN FROM THE ORIGINAL RECORD OF BIRTH WHICH IS THE REGISTER FOR ${hospitalName || "[HOSPITAL NAME]"} OF TAHSIL/BLOCK ${tahsilBlock || "TAHSIL/BLOCK"} OF DISTRICT ${district || "DISTRICT"} OF STATE/UNION TERRITORY ${state || "STATE"}, INDIA.`;

    // Auto-fill related hospital fields
    if (hospitalName) {
        document.getElementById("hospitalname").value = hospitalName;
        document.getElementById("reghospital").value = hospitalName;
    }
}

// Add event listeners to all fields to trigger updates
document.getElementById('state').addEventListener('change', updateFields);
document.getElementById('district').addEventListener('change', updateFields);
document.getElementById('tahsildistrict').addEventListener('input', updateFields);
document.getElementById('hospital').addEventListener('input', updateFields);

// Additional listener for "Other" district input
const districtDropdown = document.getElementById('district');
districtDropdown.addEventListener('change', function () {
    const otherDistrictInput = document.getElementById('otherDistrict');
    if (this.value === 'other' && otherDistrictInput) {
        otherDistrictInput.style.display = 'block';
        otherDistrictInput.addEventListener('input', updateFields);
    } else if (otherDistrictInput) {
        otherDistrictInput.style.display = 'none';
        otherDistrictInput.value = '';
        updateFields(); // Update fields when switching back from "Other"
    }
});

</script>
<script>
document.getElementById('state').addEventListener('change', function () {
    const state = this.value.toLowerCase().replace(/ /g, ''); // Convert state name to lowercase and remove spaces
    const stateLogoPath = `statelogo/${state}.jpg`; // Path for state logo
    const formLogoPath = `statelogo/form.png`; // Common form logo path

    // Select state logo elements
    const stateLogoPreview = document.getElementById('stateLogoPreview');
    const stateLogoError = document.getElementById('stateLogoError');

    // Select form logo elements
    const formLogoPreview = document.getElementById('formLogoPreview');
    const formLogoError = document.getElementById('formLogoError');

    // Check for state logo existence and update preview
    if (doesFileExist(stateLogoPath)) {
        stateLogoPreview.src = stateLogoPath; // Set the source of the preview
        stateLogoPreview.style.display = 'block'; // Display the image preview
        stateLogoError.textContent = ''; // Clear error message
    } else {
        stateLogoPreview.style.display = 'none'; // Hide the preview
        stateLogoError.textContent = `State logo not found for ${this.value}.`; // Show error
    }

    // Check for form logo existence and update preview
    if (doesFileExist(formLogoPath)) {
        formLogoPreview.src = formLogoPath; // Set the source of the preview
        formLogoPreview.style.display = 'block'; // Display the image preview
        formLogoError.textContent = ''; // Clear error message
    } else {
        formLogoPreview.style.display = 'none'; // Hide the preview
        formLogoError.textContent = 'Form logo not found.'; // Show error
    }
});

// Utility function to check if the file exists
function doesFileExist(filePath) {
    const http = new XMLHttpRequest();
    http.open('HEAD', filePath, false); // Synchronously check file existence
    http.send();
    return http.status !== 404; // Return true if the file exists
}

</script>
<script>
    // File size validation and image preview for "Hospital Add" form
    const MAX_SIZE = 204800; // 20KB in bytes
    const ALLOWED_TYPES = ["image/png", "image/jpeg"]; // Allowed MIME types

    // Select inputs
    const stateLogoInp = document.getElementById('stateLogoInp');
    const formLogoInp = document.getElementById('formLogoInp');
    const signInp = document.getElementById('signInp');

    // Select preview elements
    const stateLogoPreview = document.getElementById('stateLogoPreview');
    const formLogoPreview = document.getElementById('formLogoPreview');
    const signPreview = document.getElementById('signPreview');

    // Validate file size and preview
    function validateFileSizeAndPreview(input, previewElement, errorMsgId) {
        const file = input.files[0];
        const errorMsg = document.getElementById(errorMsgId);

        if (file) {
            // Validate file type
            if (!ALLOWED_TYPES.includes(file.type)) {
                errorMsg.textContent = "Only PNG and JPEG images are allowed.";
                input.value = ""; // Clear the input to prevent submission
                previewElement.style.display = "none"; // Hide the preview
                return false;
            }

            // Validate file size
            if (file.size > MAX_SIZE) {
                errorMsg.textContent = "File size should not exceed 200KB.";
                input.value = ""; // Clear the input to prevent submission
                previewElement.style.display = "none"; // Hide the preview
                return false;
            }

            // Clear any previous error and show the preview
            errorMsg.textContent = ""; 
            previewElement.src = URL.createObjectURL(file); // Set preview
            previewElement.style.display = "block"; // Show the preview
            return true;
        }
    }

    // Add event listeners for each input
    stateLogoInp.addEventListener('change', () => {
        validateFileSizeAndPreview(stateLogoInp, stateLogoPreview, 'stateLogoError');
    });

    formLogoInp.addEventListener('change', () => {
        validateFileSizeAndPreview(formLogoInp, formLogoPreview, 'formLogoError');
    });

    signInp.addEventListener('change', () => {
        validateFileSizeAndPreview(signInp, signPreview, 'signError');
    });
</script>
<script>
    function toggleFields() {
        const hiddenFields = document.getElementById('hiddenFields');
        const toggleButton = document.getElementById('toggleFieldsButton');

        if (hiddenFields.style.display === 'none') {
            hiddenFields.style.display = 'block';
            toggleButton.textContent = 'Show Less';
        } else {
            hiddenFields.style.display = 'none';
            toggleButton.textContent = 'Show More';
        }
    }
</script>
<script>
document.getElementById('signInp').addEventListener('change', () => {
    const file = signInp.files[0];
    const previewElement = document.getElementById('signPreview');

    if (file) {
        previewElement.src = URL.createObjectURL(file);
        previewElement.style.display = 'block';
    } else {
        // Set default preview to blank.png
        previewElement.src = 'statelogo/blank.png';
        previewElement.style.display = 'block';
    }
});
</script>
<script>
function openSignPopup() {
    const modal = document.getElementById('signPopupModal');
    const signContainer = document.getElementById('signContainer');
    const signatureCount = document.getElementById('signatureCount');

    // Clear any previous content
    signContainer.innerHTML = '<p>Loading...</p>';

    // Fetch the list of signatures
    fetch('dt/fetch_signatures.php')
        .then(response => response.json())
        .then(data => {
            console.log(data); // Debug the fetched data
            if (data.error) {
                signContainer.innerHTML = `<p>${data.error}</p>`;
                signatureCount.textContent = '0'; // Update the count to 0
            } else if (data.length > 0) {
                signContainer.innerHTML = ''; // Clear the loading message
                signatureCount.textContent = data.length; // Update the count dynamically
                data.forEach(file => {
                    const img = document.createElement('img');
                    img.src = file;
                    img.style.height = '100px';
                    img.style.width = '100px';
                    img.style.cursor = 'pointer';
                    img.style.margin = '5px';
                    img.onclick = () => selectDefaultSign(file);
                    signContainer.appendChild(img);
                });
            } else {
                signContainer.innerHTML = '<p>No signatures found.</p>';
                signatureCount.textContent = '0'; // Update the count to 0
            }
        })
        .catch(error => {
            console.error('Error fetching signatures:', error);
            signContainer.innerHTML = '<p>Unable to load signatures.</p>';
            signatureCount.textContent = '0'; // Update the count to 0
        });

    // Show the modal
    modal.style.display = 'block';
}


function closeSignPopup() {
    document.getElementById('signPopupModal').style.display = 'none';
}
function selectDefaultSign(filePath) {
    // Set the selected file path to the hidden input field
    document.getElementById('defaultSignPath').value = filePath;

    // Update the signature preview image
    const previewElement = document.getElementById('signPreview');
    previewElement.src = filePath;
    previewElement.style.display = 'block';

    // Close the popup
    closeSignPopup();

    // Log confirmation for debugging
    console.log("Selected signature:", filePath);
}

</script>


   <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer text-center text-muted">
               
            </footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- /.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>


</body>

</html>