<?php
require'../connections/conn.php';
$app=$_GET['app_id'];
$p="select * from `appointment`,`patient` where `appointment`.`p_id`=`patient`.`p_id` and app_id=$app";
$r=$conn->query($p);

while($row=mysqli_fetch_array($r))
{
	$name=$row['p_name'];
	$date=$row['date'];
	$treat=$row['treatment'];
	$age=$row['p_age'];
}?>

<html>
<head>

<style>

.button-30 {
  align-items: center;
  appearance: none;
  background-color: #FCFCFD;
  border-radius: 4px;
  border-width: 0;
  box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px,rgba(45, 35, 66, 0.3) 0 7px 13px -3px,#D6D6E7 0 -3px 0 inset;
  box-sizing: border-box;
  color: #36395A;
  cursor: pointer;
  display: inline-flex;
  font-family: "JetBrains Mono",monospace;
  height: 48px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  overflow: hidden;
  padding-left: 16px;
  padding-right: 16px;
  position: relative;
  text-align: left;
  text-decoration: none;
  transition: box-shadow .15s,transform .15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  will-change: box-shadow,transform;
  font-size: 18px;
}

.button-30:focus {
  box-shadow: #D6D6E7 0 0 0 1.5px inset, rgba(45, 35, 66, 0.4) 0 2px 4px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset;
}

.button-30:hover {
  box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset;
  transform: translateY(-2px);
}

.button-30:active {
  box-shadow: #D6D6E7 0 3px 7px inset;
  transform: translateY(2px);
}

</style>


<script language="javascript">
        function printdiv(printpage) {
            var headstr = "<body>";
            var footstr = "</body>";
            var newstr = document.all.item(printpage).innerHTML;
            var oldstr = document.body.innerHTML;
            document.body.innerHTML = headstr + newstr + footstr;
            window.print();
            document.body.innerHTML = oldstr;
            return false;
        }
    </script>
</head>
<body>
	
	
	<br><br>
	<center>
 
	<div id="div_print" width=100%>
				<table style="margin-top:190px">
					<tr>
						<td width="50px">Name:</td>
						<td width="200px"><?php echo $name;?></td>
						<td width="40px">Age:</td>
						<td width="100px"><?php 
						$dateOfBirth = $age;
						$today = date("Y-m-d");
						$diff = date_diff(date_create($dateOfBirth), date_create($today));
						echo $diff->format('%y')." Years";
						?></td>
						<td width="50px">Date:</td>
						<td width="100px">
						<?php 
						$unixTime = strtotime($date);

						
						$newDate = date("d-m-Y", $unixTime);
						echo $newDate;
						?>
						</td>
					</tr>
				</table>
				<hr>
					
					<textarea cols=50 rows=20 style="font-size:18;text-align:left; border-style: none; border-color: Transparent; overflow: auto;">
						<?php echo $treat;?>
					</textarea><br>
				
	</div>
		<input name="b_print" type="button" class="button-30" onClick="printdiv('div_print');" value=" Print ">
					<a class="button-30" href="home.php">Done</a>
      </center>
		
	
	
		
		
		</body>
		</html>