<?php
include("dbConfig.php");

session_start();
if(isset($_SESSION['username']) && isset($_SESSION['name']))
{
    $username=$_SESSION['username'];
    $name=$_SESSION['name'];
}
else
{
     echo '<META http-equiv="refresh" content="0;logout.php">';
}
?>
<!DOCTYPE html>
<html>
<head>
  <title>
    
  </title>
  <meta charset="UTF-8">
  <link href="assets/img/favicon.png" rel="icon">
  <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
  <script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
<link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css'>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css'>
  <!-- Google Fonts -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700" rel="stylesheet">
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css'>

  <!-- Vendor CSS Files -->
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/ionicons/css/ionicons.min.css" rel="stylesheet">
  <link href="assets/vendor/animate.css/animate.min.css" rel="stylesheet">
  <link href="assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  <link href="assets/vendor/venobox/venobox.css" rel="stylesheet">
  <link href="assets/vendor/owl.carousel/assets/owl.carousel.min.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery.min.js"></script>
  <script src="jquery.dependent.fields.js"></script>
  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery.min.js"></script>
  
  
<script src="jquery.dependent.fields.js"></script>
<link rel="stylesheet" href="js/select2.min.css" />
<style type="text/css">
.nav-menu a {
    padding: 3px 3px;
}

.footer {
   position: fixed;
   left: 0;
   bottom: 0;
   width: 100%;
   background-color: #efe8e8;
   color: black;
   text-align: center;
   padding:4px;
   font-size:12px;
}
.footer a{
  font-weight: bold;
  color:#0c0c67;
}
  .hide {
  display: none;
}
h4{
  padding-top: 5px;
  padding-bottom: 0px;
  color:#1abfbf;
  font-weight: bold;
}
hr{
  background-color:#1abfbf;
}
span{
  color:red;
}
</style>

</head>
<body>
  <div style="text-align: center">
     <img src="assets/img/logo.png" width="100px" height="100px">
  </div>

      <header id="header">     

    <div class="container">
    <nav id="nav-menu-container">
        <ul class="nav-menu">
      <li class="menu-active">
        <a class="nav-link" style="padding:2;font-size:14px" href="index.php">Home</a>
      </li>
            <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">IPD Patients</a>
        <ul>
              <li><a href="AddPatient.php">IPD Patient Registration</a></li>
              <li><a href="AddAdvance.php">IPD add Advance</a></li>
              <li><a href="UpdateWard.php">Update Ward</a></li>
              <li><a href="IPDPatients.php">View IPD Patients</a></li>
              
        </ul>
      </li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">OPD Patients</a>
        <ul>
            <li><a href="OPDRegistration.php">OPD Patient Registration</a></li>
            <li><a href="OPDPatientsList.php">View OPD Patients Lists</a></li>
            <li><a href="OPDPatients.php">View OPD Patients Bills</a></li>
        </ul>
      </li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">Staff</a>
        <ul>
              <li><a href="AddStaff.php">Add Staff</a></li>
              <li><a href="StaffList.php">Staff List</a></li>
        </ul>
      </li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">Billing</a>
        <ul>
              <li><a href="billingId.php">Generate Consolidate Bill</a></li>
              <li><a href="InvestigationId.php">Generate Investigation Bill</a></li>
              <li><a href="FinaleBillId.php">Generate Discharge Bill</a></li>
              <li><a href="SearchBill.php">Search Bill</a></li>
        </ul>
      </li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">Particular</a>
        <ul>
              <li><a href="AddParticulars.php">Add Particulars</a></li>
              <li><a href="ViewParticulars.php">View Particulars</a></li>
        </ul>
      </li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#">Report</a>
        <ul>
               <li><a href="UploadReport.php">Upload Patient Report</a></li>
              <li><a href="DailyTrans.php">Transactions</a></li>
              <li><a href="userTrans.php">User Transactions</a></li>
              <li><a href="ViewReport.php">View Patient Reports</a></li>
              
        </ul>
      </li>
        <li class="menu-has-children">
      <a class="nav-link" style="padding:2;font-size:14px" href="examintaion.php">Add Examination</a>
      </li></li>
      <li class="menu-has-children">
        <a class="nav-link" style="padding:2;font-size:14px" href="#" style="font-size:15px"><? echo $name?></a>
        <ul>
               <li><a href="logout.php">Logout</a></li>
              <li><a href="ResetPassword.php">Reset Password</a></li>              
        </ul>
      </li>
        </ul>
      </nav><!-- #nav-menu-container -->
    </div>
  </header><!-- End Header -->   
  <section>
  <div class="row">
<div class="col-md-2"></div> 
<div class="col-md-8">
  <div class="shadow p-3 mb-5 bg-light rounded">
<form action="StorePatient.php" method="POST" enctype="multipart/form-data">
 
    

  <h2 style="text-align: center;font-weight: bold;color:#fff;background-color: #279480;padding:10px;">IPD Patient Admission</h2>

  <h4>Personal Details</h4>
  <hr>
    <div class="row">
    <div class="form-group col">
    <label for="title">Title<span>*</span></label>
    <select class="form-control" name="title" id="title" required>
        <option value="" disabled selected>Select Title</option>
        <option value="Mr">Mr</option>
        <option value="Mrs">Mrs</option>
        <option value="Miss">Miss</option>
        <option value="Master">Master</option>
        <option value="Baby">Baby</option>
    </select>
</div>

    <div class="form-group col">
      <label for="Pname">Patient Name<span>*</span></label>
      <input  class="form-control" type="text" name="Pname" id="Pname" required>
    </div>
    <div class="form-group col">
      <label for="fhname">Father/Husband Name<span></span></label>
      <input  class="form-control" type="text" name="fhname" id="fhname" >
    </div>
       

  </div>
    <div class="row">
         <div class="form-group col">
      <label for="contact1">Contact No.<span>*</span></label>
      <input  class="form-control" type="text" name="contact1" id="contact1" required>
    </div>
    <!--<div class="form-group col">-->
    <!--  <label for="contact2">Emergency Contact No.</label>-->
    <!--  <input  class="form-control" type="text" name="contact2" id="contact2">-->
    <!--</div>-->
    <!--<div class="form-group col">-->
    <!--  <label for="email">Email Id</label>-->
    <!--  <input  class="form-control" type="email" name="email" id="email">-->
    <!--</div>-->
    <div class="form-group col">
      <label for="dob">Date of Birth</label>
      <input  class="form-control" type="date" name="dob" id="dob">
    </div>    

  </div>
    <div class="row">
    <div class="form-group col">
      <label for="age">Age<span>*</span></label>
      <input  class="form-control" type="text" name="age" id="age" required>
    </div>
    <div class="form-group col">
      <label for="Gender">Gender<span>*</span></label>
      <select class="form-control" name="Gender" id="Gender" required>
        <option value="">Choose Option</option>
        <option value="Male">Male</option>
        <option value="Female">Female</option>
      </select>
    </div>
    <div class="form-group col">
      <label for="Blood">Blood Group</label>
      <select  class="form-control" name="Blood" id="Blood">
          <option value="">Choose Option</option>
          <option value="A+">A+</option>
          <option value="B+">B+</option>
          <option value="AB+">AB+</option>
          <option value="O+">O+</option>
          <option value="A-">A-</option>
          <option value="B-">B-</option>
          <option value="AB-">AB-</option>
          <option value="O-">O-</option>
      </select>
    </div>    

  </div>
    <div class="row">
    <div class="form-group col">
      <label for="Weight">Body Weight</label>
      <input  class="form-control" type="text" name="Weight" id="Weight">
    </div>
    <div class="form-group col">
      <label for="Height">Height</label>
      <input  class="form-control" type="text" name="Height" id="Height">
    </div>
        <div class="form-group col">
      <label for="Aadhaar">Aadhaar ID</label>
      <input  class="form-control" type="text" name="Aadhaar" id="Aadhaar">
    </div>

  </div>
    <div class="row">    
      <div class="form-group col">
      <label for="Address">Address<span></span></label>
      <textarea class="form-control" name="Address" id="Address" rows="6" ></textarea>
    
      <div class="form-group">
    <label for="City">City<span></span></label>
    <input class="form-control" type="text" name="City" id="City"  >
</div>

<div class="form-group">
    <label for="State">State<span>*</span></label>
    <input class="form-control" type="text" name="State" id="State" value="Karnataka" required>
</div>

      <label for="Country">Country<span>*</span></label>
      <input  class="form-control" type="text" name="Country" id="Country"  value="India"  required>
    </div>
     <div class="form-group col">
      <label for="Mark">Identification Mark</label>
      <input  class="form-control" type="text" name="Mark" id="Mark">
      <br>
      <label for="Photo">Upload Photo</label><br>
      <img src="assets/img/pimage.png" width="160px" height="130px">
      <input  class="form-control" type="file" name="Photo" id="Photo">
    </div>
  </div>
<h4>Admission Details</h4>
<hr>
  <div class="row">    
    <div class="form-group col">
      <label for="Consultant">Consultant<span>*</span></label>
      
       <select class="form-control" name="Consultant" id="Consultant" required>
    <option value="">Select</option>
    <?php 
        $docList = mysqli_query($conn, "SELECT doc_id, doc_name, doc_specialization FROM docotorslist"); 
     
        if (!$docList) {
            echo "Error: " . mysqli_error($conn); 
        } else {
           
            while ($data = mysqli_fetch_array($docList)) {
    ?>
                <option value="<?php echo $data['doc_name']; ?>"> 
                    <?php echo $data['doc_name'] ; ?>
                </option>
    <?php 
            }
        }
    ?>
</select>

    </div>
    <div class="form-group col">
      <label for="CaseType">Case Type<span>*</span></label>
      <select  class="form-control" name="CaseType" id="CaseType" required>
        <option value="">Choose Option</option>
        <option value="MLC">MLC</option>
        <option value="Non MLC">Non MLC</option>
      </select>
    </div>
         <div class="form-group col">
      <label for="WardType">Admitted Ward<span>*</span></label>
      <select  class="form-control" name="WardType" id="WardType" required>
        <option value="">Choose Option</option>
        <option value="ICU">ICU</option>
        <option value="Delux Ward">Delux Ward</option>
        <option value="Private">Private</option>
        <option value="Semi Special Ward">Semi Special Ward</option>
        <option value="General Ward">General Ward</option>
        <option value="Day care">Day care</option>
      </select>
    </div>
    <input type="hidden" name="PatientType" id="PatientType" value="IPD">

  </div>
<div class="row">
    <div class="form-group col">
        <label for="AdmitDate">Date<span>*</span></label>
        <input class="form-control" type="date" name="AdmitDate" id="AdmitDate"  required>
    </div>
    <div class="form-group col">
        <label for="AdmitTime">Time<span>*</span></label>
        <input class="form-control" type="time" name="AdmitTime" id="AdmitTime"  required>
    </div>
</div>


  
    <div class="row">    
    <div class="form-group col">
      <label for="AdvanceAmount">Advance Amount<span>*</span></label>
      <input  class="form-control" type="number" name="AdvanceAmount" id="AdvanceAmount" required>
    </div>
   <div class="form-group col">
  <label for="">Payment Mode<span>*</span></label>
  <select class="form-control" name="PaymentMode" id="PaymentMode" required>
    <option value="">Choose Option</option>
    <option value="Cash">Cash</option>
    <option value="Cash and UPI">Cash and UPI</option>
    <option value="Card">Card</option>
    <option value="UPI">UPI</option>
    <option value="Cash and Card">Cash and Card</option>
    <option value="Insurance">Insurance</option>
    <option value="ABRK">ABARK</option>
  </select>
</div>
  </div>
    <div class="row" id="InsDetails">    
    <div class="form-group col" >
      <label for="InsuranceName">Insurance Name<span>*</span></label>
      <input  class="form-control" type="text" name="InsuranceName" id="InsuranceName">
    </div>
    <div class="form-group col">
      <label for="InsuranceNo">Insurance No<span>*</span></label>
      <input  class="form-control" type="text" name="InsuranceNo" id="InsuranceNo">
    </div>

  </div>
  
   <div class="row" id="cardDetails">    
    <div class="form-group col" >
      <label for="bank">Bank Name<span>*</span></label>
      <input  class="form-control" type="text" name="bank">
    </div>
    <div class="form-group col">
      <label for="cardno">Card No<span>*</span></label>
      <input  class="form-control" type="text" name="cardno" id="cardno">
    </div>

  </div>
  
   <div class="row" id="upiCashDetails">    
    <div class="form-group col" >
      <label for="bank">Upi Amount<span></span></label>
      <input  class="form-control" type="text" name="upi">
    </div>
    <div class="form-group col">
      <label for="cardno">Cash Amount<span></span></label>
      <input  class="form-control" type="text" name="cash" id="cash">
    </div>

  </div>
  
   <div class="row" id="upiDetails">    
    <div class="form-group col" >
      <label for="upiid">Upi Transaction Id<span></span></label>
      <input  class="form-control" type="text" name="upiid">
    </div>
  </div>

</div>
<div style="text-align: center">
  <button type="submit" class="btn btn-primary" style="padding:7px 50px;">Preview</button>
<button type="button" class="btn btn-danger" style="padding:7px 50px;" onclick="history.back()">Cancel</button>
</div>
</form>
</div>
</div> 
<div class="col-md-2"></div>    
  </div>
  <section>


  <div class="footer">
        &copy; Copyright 2024 All Rights Reserved <strong>Vidyaranya Hospital PVt LTD.</strong>. | Designed by <a href="http://www.vatsinsoft.in/">Vatsin Soft</a>
      </div>
      <script src="js/select2.min.js"></script>
      <script type="text/javascript">
        $("#Consultant").select2( {
        	placeholder: "Select",
        	allowClear: true
    	
    	} );
      
$("#PaymentMode").change(function() {
  var paymentMode = $(this).val();

  // Hide all sections by default
  $('#InsDetails').hide();
  $('#cardDetails').hide();
  $('#upiCashDetails').hide();
  $('#upiDetails').hide();  // Hides UPI Amount section

  // Remove required attributes for all input fields
  $('#InsuranceName, #InsuranceNo').removeAttr('required');
  $('input[name="bank"], input[name="cardno"]').removeAttr('required');
  $('input[name="upi"], input[name="cash"]').removeAttr('required');
  $('input[name="upiid"]').removeAttr('required');  // Removes required from UPI Amount field

  if (paymentMode == "Insurance") {
    // Show insurance details and make fields required
    $('#InsDetails').show();
    $('#InsuranceName').attr('required', '');
    $('#InsuranceNo').attr('required', '');
  } else if (paymentMode == "Card") {
    // Show card details and make fields required
    $('#cardDetails').show();
    $('input[name="bank"]').attr('required', '');
    $('input[name="cardno"]').attr('required', '');
  } else if (paymentMode == "Cash and UPI") {
    // Show UPI and Cash details and make fields required
    $('#upiCashDetails').show();
    $('input[name="upi"]').attr('required', '');   // UPI ID required
    $('input[name="cash"]').attr('required', '');  // Cash amount required
  } else if (paymentMode == "UPI") {
    // Show only the UPI Amount section
    $('#upiDetails').show();  // Shows UPI Amount section
    $('input[name="upiid"]').attr('required', '');  // UPI Amount required
  }
});


$("#PaymentMode").trigger("change");
$('#Consultant').on('keypress', function (event) {   
          var regex = new RegExp("^[a-zA-Z ]+$");
          var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
          if (!regex.test(key)) {
             event.preventDefault();
             return false;
          }
          
      });
</script>
 <script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'></script>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
  <script src="assets/vendor/jquery/jquery.min.js"></script>
  <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/jquery.easing/jquery.easing.min.js"></script>
  <script src="assets/vendor/php-email-form/validate.js"></script>
  <script src="assets/vendor/wow/wow.min.js"></script>
  <script src="assets/vendor/venobox/venobox.min.js"></script>
  <script src="assets/vendor/owl.carousel/owl.carousel.min.js"></script>
  <script src="assets/vendor/jquery-sticky/jquery.sticky.js"></script>
  <script src="assets/vendor/superfish/superfish.min.js"></script>
  <script src="assets/vendor/hoverIntent/hoverIntent.js"></script>
  <script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
  <script src="assets/js/main.js"></script>
  <script src="js/select2.min.js"></script>
  
</body>
</html>
