<?php 
    include('loginsession.php');
    error_reporting(E_ALL);
    $filename = __FILE__;
    if (strlen(__FILE__) > 48) {$filename = substr(__FILE__, 48);}
    $save = mysqli_query($conn, "INSERT INTO novia_abc_user_logs (userid,filename) VALUES ('$userini_id','$filename')");
//-------------
if(isset($_GET['id'])){
    $IDR = $_GET['id'];
}
$tgl = date("Y-m-d");
$no = 0;
$nu = 0;
$b = mysqli_fetch_array(mysqli_query($conn, "SELECT mr, name, birthday FROM novia_abc_biodata where id='$_GET[id]'"));
$vmr = $b['mr'];

//Script Umur
$sa = date("Y");
$si = $b['birthday'];
$dti = new DateTime($si);
$currdate_ = $dti->format('Y');
$umur = $sa-$currdate_;
if ($umur > 150) $umur1 = "";
if ($umur < 150) $umur1 = " (".$umur.")";
//--------

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//ID" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="id">
<head>
	<title>STATUS PASIEN</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="css/style.css">
	<link href="images/balance.ico" rel="icon" type="image/icon" />
	<style>
		a { text-decoration: none; color:inherit;}
		a:hover {color:#FF00FF;}   /* Mouse over link */
    </style>	
</head>

<body>
	<table width="100%" max-width="600px" cellpadding="5" align="center">
		<tbody>
			<tr class="dua">
				<td width="14%"><a href="status-view.php?id=<?php echo $_GET['id']-1;?>" title="Lihat pasien dengan MR yang lebih kecil"><button style="padding : 10px; width:100%"> < </button></a></td>
				<td width="21%"><a href="biodata.php?id=<?php echo $_GET['id'];?>" title="Edit data pasien"><button style="padding : 10px; width:100%">BIODATA</button></a></td>
				<td width="30%"><a href="index.php?id=<?php echo $_GET['id'];?>" title="Kembali ke halaman awal"><button style="padding : 10px; width:100%">HOME</button></a></td>
				<td width="21%"><a href="daftar_mundur.php?mr=<?php echo $IDR;?>" title="Isi Status Pasien"><button style="padding : 10px; width:100%">DAFTAR MUNDUR</button></a></td>
				<td width="14%"><a href="status-view.php?id=<?php echo $_GET['id']+1;?>" title="Lihat pasien dengan MR yang lebih besar"><button style="padding : 10px; width:100%"> > </button></a></td>
			</tr>
		</tbody>
	</table>

	<table width="100%" cellpadding="5">
    <tr class="satu">
		<td colspan="13" style='text-transform:uppercase' align="center">
			<h1><?php echo "STATUS - ".$b['mr']; ?> - <?php echo $b['name'].$umur1;?></h1>
		</td>
	</tr>
		<tr class="head" align="left">
			<th width="5%">No</th>
			<th width="10%">Tanggal</th>
			<th width="5%">TDA</th>
			<th width="5%">TDB</th>
			<th width="5%">Nadi</th>
			<th width="5%">BB</th>			
			<th width="35%">Anamnesa Pemeriksaan Diagnosa</th>
			<th width="20%">Tindakan</th>
			<th width="5%">Jarum</th>
			<th width="5%">Procain</th>
			<th width="5%">Colagen</th>
			<th width="5%">Tation</th>	
			<th width="10%">Biaya</th>
		</tr>

<?php
$sql = "SELECT * FROM novia_abc_visit ORDER BY date_ ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
		$sdt1 = $row["date_"];
		$dt2 = new DateTime($sdt1);
        $date1 = $dt2->format('Y');
        $date2 = $dt2->format('d M Y');
		/*
		$nameOfDay = date('D', strtotime($date2));
		if ( $nameOfDay == 'Mon' ) $hari = 'SENIN';
		if ( $nameOfDay == 'Tue' ) $hari = 'SELASA';
		if ( $nameOfDay == 'Wed' ) $hari = 'RABU';
		if ( $nameOfDay == 'Thu' ) $hari = 'KAMIS';
		if ( $nameOfDay == 'Fri' ) $hari = 'JUMAT';
		if ( $nameOfDay == 'Sat' ) $hari = 'SABTU';
		if ( $nameOfDay == 'Sun' ) $hari = 'MINGGU';*/
		
$bulan = new DateTime($date2);
$Hari = $bulan->format('l');
$hari = $HARI[$Hari];
$lastcome = "";

		if ( $row["mr"] == $IDR){
			if ( $date1 >= 2000 ){
				$nu++;
			}
			$no++;
			$lastcome = $row["date_"];
			$y = 2;
			$result1 = fmod($no,$y);
			if ( $result1 == 0 ) $sty = "dua";
			if ( $result1 == 1 ) $sty = "satu";
?>
			<tr class=<?php echo $sty; ?>>
				<td><?php echo $no; ?>.</td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $hari." ".$date2; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["sistole"]; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["diastole"]; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["pulse"]; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["weight"]; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["anamnesa"]; ?></a></td>
				<td align="left"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien "><?php echo $row["tindakan"]; ?></a></td>
				
				<td align="center"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["pin"]; ?></a></td>
				<td align="center"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["procain"]; ?></a></td>
				<td align="center"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["colagen"]; ?></a></td>
				<td align="center"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien"><?php echo $row["tation"]; ?></a></td>
				
				<td align="right"><a href="status-view-edit.php?imr=<?php echo $row["mr"]."-".$tgl."-".$row["id"];?>" title="Edit Kunjungan Pasien "><?php echo $row["biaya"]; ?></a></td>
			</tr>
<?php
			}
		}
		//$emr = $row["mr"];
		$save=mysqli_query($conn, "UPDATE novia_abc_biodata SET lastcome='$lastcome', freq='$nu' where mr='$IDR'");
	} else {}
?>
</table>
</body>
</html>
