<?php 
    include('loginsession.php');
    error_reporting(E_ALL);
    $filename = __FILE__;  //---Nama file saat ini
    if (strlen(__FILE__) > 48) {$filename = substr(__FILE__, 48);}
    $save = mysqli_query($conn, "INSERT INTO novia_abc_user_logs (userid,filename) VALUES ('$userini_id','$filename')");
//-------------
?>

<!DOCTYPE>
<html>
<head>
	<title>FREKWENSI KUNJUNGAN 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>
<?php
$no = 0;


$today1 = date("Y");


?>


	<table width="100%" cellpadding="5">
		<tr class="dua">
			<td width="25%" style="padding-top : 5 px;" align="center";>
				<a style = "font-family: 'Heebo' sans-serif; font-size:25px;"><?php echo "MR Pasien ".$today1; ?><a>
			</td>
			<td width="20%"><a href="index.php" title="Kembali ke halaman awal"><button style="padding : 10px; width:100%">HOME</button></a></td>
			<td width="20%"><a href="visit-daily.php?tanggal=<?php echo $today;?>" title="Lihat Pasien Bulan ini"><button style="padding : 10px; width:100%">DAY</button></a></td>
		</tr>
	</table>
	<table width="100%" cellpadding="5">
		<tr class="head" align="left">
			<th width="5%">No</th>
			<th width="10%">MR</th>
			<th width="22%">Nama</th>
			<th width="22%">Frekwensi</th>
		</tr>
	
	

<?php 
//$sql = "SELECT DISTINCT mr FROM novia_abc_visit ORDER BY mr ASC";
$sql = "SELECT DISTINCT mr FROM novia_abc_visit ORDER BY id DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
		
			$no++;
			$y = 2;
			$result1 = fmod($no,$y);
			if ( $result1 == 0 ) $sty = "dua";
			if ( $result1 == 1 ) $sty = "satu";
			//$total_stok += $row["biaya"];
			
			$imr = $row["mr"];
			$sql_1 = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM novia_abc_biodata where mr='$imr'"));
			$namo = $sql_1['name'];
			$phone_wa = $sql_1['phone_wa'];
			$phone_home = $sql_1['phone_home'];
			$street_address = $sql_1['street_address'];
			$kelurahan = $sql_1['kelurahan'];
			$kecamatan = $sql_1['kelurahan'].", ".$sql_1['kecamatan'];
			$city = $sql_1['city'];
			$state = $sql_1['state'];
			$kode_pos = $sql_1['kode_pos'];
			$email = $sql_1['email'];
			$firstcome = $sql_1['firstcome'];
			$birthday = $sql_1['birthday'];
			$note = $sql_1['note'];
			$freq = $sql_1['freq'];

			//$save = mysqli_query($conn, "INSERT INTO novia_abc_contact (id, mr, name, phone_wa, phone_home, street_address, kelurahan, kecamatan, city, state, kode_pos, email, firstcome, birthday, note) 
			//VALUES ('$no','$imr','$namo','$phone_wa','$phone_home','$street_address','$kelurahan','$kecamatan', '$city', '$state', '$kode_pos', '$email', '$firstcome', '$birthday', '$note')");
			
			
				?>
				
				<tr class=<?php echo $sty; ?>>
					<td><?php echo $no; ?>.</td>
					<td align="left"><a <a href="status-view.php?id=<?php echo $row["mr"];?>" title="Lihat Status Pasien"><?php echo $imr; ?></a></td>
					<td align="left"><a <a href="status-view.php?id=<?php echo $row["mr"];?>" title="Lihat Status Pasien"><?php echo $sql_1["name"]; ?></a></td>
					<td align="left"><a <a href="status-view.php?id=<?php echo $row["mr"];?>" title="Lihat Status Pasien"><?php echo $sql_1["freq"]; ?></a></td>
					
				</tr>
				<?php
			}
		} else {
			//echo "0 results";
	}
?>
</table>

</body>
</html>
