<?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">';
}


if(isset($_POST['Pname'])){
    $title=$_POST['title'];
$Pname=$_POST['Pname'];
$fhname=$_POST['fhname'];
$contact1=$_POST['contact1'];
// $contact2=$_POST['contact2'];
// $email=$_POST['email'];
$dob=$_POST['dob'];
$age=$_POST['age'];
$gender=$_POST['Gender'];
$blood=$_POST['Blood'];
$wt=$_POST['Weight'];
$height=$_POST['Height'];
$Aadhaar=$_POST['Aadhaar'];
$Address=$_POST['Address'];
$Address.=", ".$_POST['City'];
$Address.=", ".$_POST['State'];
$Address.=", ".$_POST['Country'];
$Mark=$_POST['Mark'];
$CaseType=$_POST['CaseType'];
$Consultant=$_POST['Consultant'];
$PatientType=$_POST['PatientType'];
$WardType=$_POST['WardType'];
$AdmitDate=$_POST['AdmitDate'];
$AdmitTime=$_POST['AdmitTime'];
$AdvanceAmount=$_POST['AdvanceAmount'];  
$PaymentMode=$_POST['PaymentMode'];
$InsuranceName=$_POST['InsuranceName'];
$InsuranceNo=$_POST['InsuranceNo'];
$bank = $_POST['bank'] ?? '';
$cardno = $_POST['cardno'] ?? '';
$bank_a = $_POST['bank-a'] ?? '';
$cardno_a = $_POST['cardno-a'] ?? '';
$cash_a = $_POST['cash-a'] ?? '';
$card_a = $_POST['card-a'] ?? '';
$upi=$_POST['upi'];
$cash=$_POST['cash'];
$upiid=$_POST['upiid'];
$Photo=$_FILE['Photo'];
$fileName=$_FILES['Photo']['name'];
                        $fileTmpName=$_FILES['Photo']['tmp_name'];
                        $fileSize=$_FILES['Photo']['size'];
                        $fileError=$_FILES['Photo']['error'];
                        $fileType=$_FILES['Photo']['type'];

                        $fileExt=explode('.',$fileName);
                        $fileActualExt=strtolower(end($fileExt));
                        $allowed=array('jpg','jpeg','png','JPG','JPEG','PNG');

                        if(in_array($fileActualExt, $allowed))
                        {
                            if($fileError ===0){
                                if($fileSize<=3000000){
                                    $PfileNameNew=uniqid('',true).".".$fileActualExt;

    
                                    $fileDestination = 'assets/PatientPhotos/'.$PfileNameNew;
                                    move_uploaded_file($fileTmpName, $fileDestination);  
                                }
                                else{
                                    echo "Your File Size is large";
                                }

                            }else{
                                    echo "Error Uploading File";
                                }
                            
                        }





}
?>

<!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>
</head>
<body>

<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">
	<h2>Patient Information</h2>
	<table class="table table-striped">
	    	<tr>
		<td>Title</td>
		<td><?php echo $title;?></td>
	</tr>
	<tr>
		<td>Name</td>
		<td><?php echo $Pname;?></td>
	</tr>
	<tr>
		<td>Father/Husband Name</td>
		<td><?php echo $fhname;?></td>
	</tr>
	<tr>
		<td>Contact No.</td>
		<td><?php echo $contact1;?></td>
	</tr>
	<!--<tr>-->
	<!--	<td>Emergency Contact No.</td>-->
	<!--	<td><?php echo $contact2;?></td>-->
	<!--</tr>-->
	<!--<tr>-->
	<!--	<td>Email Id</td>-->
	<!--	<td><?php echo $email;?></td>-->
	<!--</tr>-->
	<tr>
		<td>Date of Birth</td>
		<td><?php echo $dob;?></td>
	</tr>
	<tr>
		<td>Age</td>
		<td><?php echo $age;?></td>
	</tr>
	<tr>
		<td>Gender</td>
		<td><?php echo $gender;?></td>
	</tr>
	<tr>
		<td>Blood Group</td>
		<td><?php echo $blood;?></td>
	</tr>
	<tr>
		<td>Body Weight</td>
		<td><?php echo $wt;?></td>
	</tr>
	<tr>
		<td>Height</td>
		<td><?php echo $height;?></td>
	</tr>
	<tr>
		<td>Aadhaar ID</td>
		<td><?php echo $Aadhaar;?></td>
	</tr>
	<tr>
		<td>Address</td>
		<td><?php echo $Address;?></td>
	</tr>
	<tr>
		<td>Identification Mark</td>
		<td><?php echo $Mark;?></td>
	</tr>
	<tr>
		<td>Consultant</td>
		<td><?php echo $Consultant;?></td>
	</tr>
	<tr>
		<td>Patient Type</td>
		<td><?php echo $PatientType;?></td>
	</tr>
	<tr>
		<td>Case Type</td>
		<td><?php echo $CaseType;?></td>
	</tr>
	<tr>
		<td>Admitted Ward</td>
		<td><?php echo $WardType;?></td>
	</tr>
	
	<tr>
		<td>Admit Date</td>
		<td><?php echo $AdmitDate;?></td>
	</tr>
	<tr>
		<td>Admit Time</td>
		<td><?php echo $AdmitTime;?></td>
	</tr>
	<tr>
		<td>Advance Amount</td>
		<td><?php echo $AdvanceAmount;?></td>
	</tr>
	<tr>
		<td>Payment Mode</td>
		<td><?php echo $PaymentMode;?></td>
	</tr>
<?php
if ($PaymentMode == "Insurance") {
    echo "<tr><td>Insurance Name / Number</td>";
    echo "<td>$InsuranceName, $InsuranceNo</td></tr>";
}

if ($PaymentMode == "Card") {
    echo "<tr><td>Bank Name / Card Number</td>";
    echo "<td>$bank, $cardno</td></tr>";
}

if ($PaymentMode == "Cash and UPI") {
    echo "<tr><td>Cash Amount / UPI ID</td>";
    echo "<td>$cash, $upi</td></tr>";
}

if ($PaymentMode == "Cash and Card") {
	echo "<tr><td>Bank Name / Card Number</td>";
	echo "<td>$bank, $cardno</td></tr>";
	echo "<tr><td>Cash Amount / Card Amount</td>";
	echo "<td>$cash_a, $card_a</td></tr>";
}

// Add the condition for UPI Only mode
if ($PaymentMode == "UPI") {
    echo "<tr><td>UPI Amount</td>";
    echo "<td>$upiid</td></tr>";  // Display UPI amount
}

if ($PfileNameNew != "") {
    echo "<tr><td>Patient Photo</td>";
    echo "<td><img src=\"assets/PatientPhotos/$PfileNameNew\" width=\"70px\" height=\"70px\"></td></tr>";
}
?>


</table>
<form action="store.php" method="POST" enctype="multipart/form-data">
     <input type="hidden" name="title" value="<?php echo $title;?>">
	 <input type="hidden" name="Pname" value="<?php echo $Pname;?>">
	 <input type="hidden" name="fhname" value="<?php echo $fhname;?>">
	 <input type="hidden" name="contact1" value="<?php echo $contact1;?>">
	 <input type="hidden" name="contact2" value="<?php echo $contact2;?>">
	 <input type="hidden" name="email" value="<?php echo $email;?>">
	 <input type="hidden" name="age" value="<?php echo $age;?>">
	 <input type="hidden" name="dob" value="<?php echo $dob;?>">
	 <input type="hidden" name="Gender" value="<?php echo $gender;?>">
	 <input type="hidden" name="Blood" value="<?php echo $blood;?>">
	 <input type="hidden" name="Weight" value="<?php echo $wt;?>">
	 <input type="hidden" name="Height" value="<?php echo $height;?>">
	 <input type="hidden" name="Aadhaar" value="<?php echo $Aadhaar;?>">
	 <input type="hidden" name="Address" value="<?php echo $Address;?>">
	 <input type="hidden" name="Mark" value="<?php echo $Mark;?>">
	 <input type="hidden" name="Photo" value="<?php echo $PfileNameNew;?>">
	 <input type="hidden" name="Consultant" value="<?php echo $Consultant;?>">
	 <input type="hidden" name="PatientType" value="<?php echo $PatientType;?>">
	 <input type="hidden" name="WardType" value="<?php echo $WardType;?>">
	 <input type="hidden" name="CaseType" value="<?php echo $CaseType;?>">
	 <input type="hidden" name="AdmitDate" value="<?php echo $AdmitDate;?>">
	 <input type="hidden" name="AdmitTime" value="<?php echo $AdmitTime;?>">
	 <input type="hidden" name="AdAmount" value="<?php echo $AdvanceAmount;?>">
	 <input type="hidden" name="PaymentMode" value="<?php echo $PaymentMode;?>">
	 <input type="hidden" name="InsuranceName" value="<?php echo $InsuranceName;?>">
	 <input type="hidden" name="InsuranceNo" value="<?php echo $InsuranceNo;?>">
	 <input type="hidden" name="bank" value="<?php echo $bank;?>">
	 <input type="hidden" name="cardno" value="<?php echo $cardno;?>">
	 
	 <input type="hidden" name="upi" value="<?php echo $upi;?>">
	 <input type="hidden" name="cash" value="<?php echo $cash;?>">
	 <input type="hidden" name="upiid" value="<?php echo $upiid;?>">
	 
	 <input type="hidden" name="bank-a" value="<?php echo $bank_a; ?>">
	 <input type="hidden" name="cardno-a" value="<?php echo $cardno_a; ?>">
	 <input type="hidden" name="cash-a" value="<?php echo $cash_a; ?>	
	 <input type="hidden" name="card-a" value="<?php echo $card_a; ?>">
	 
     <input type="hidden" name="preparedby" value="<?php echo $name;?>">
	 <button type="submit" class="btn btn-primary">Confirm and Save</button>
	 <button type="button" class="btn btn-danger" onclick="history.back()" style="padding:7px 50px;">Edit</button>
</form>
		</div>
		<div class="col-md-2"></div>
	</div>
</div>
</section>
 <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>
</body>
</html>
