MIF_E31211896/cetak_riwayat.php

123 lines
3.1 KiB
PHP

<?php
session_start();
require_once 'functions.php';
if (!isset($_SESSION['login_user'])) {
header('Location: login.php');
exit;
}
$user = $_SESSION['login_user'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Riwayat Konsultasi</title>
<link rel="stylesheet" type="text/css" href="path/to/bootstrap.css">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
color: #333;
}
.container {
margin: 0 auto;
padding: 20px;
border: 1px solid #ddd;
background: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h2 {
text-align: center;
margin-bottom: 30px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f4f4f4;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
.btn {
display: inline-block;
padding: 10px 20px;
font-size: 14px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
text-align: center;
text-decoration: none;
margin-top: 20px;
}
@media print {
.btn {
display: none;
}
.container {
box-shadow: none;
border: none;
}
}
</style>
</head>
<body>
<div class="container">
<h2>Riwayat Konsultasi</h2>
<table>
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>Email</th>
<th>No. Hp</th>
<th>Jenis Kelamin</th>
<th>Usia</th>
<th>Alamat</th>
<th>Tanggal Konsultasi</th>
<th>Hasil Konsultasi</th>
<th>Kepercayaan (%)</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$rows = $db->get_results("SELECT * FROM tb_hasil WHERE user='$user' ORDER BY tanggal_konsultasi DESC");
foreach ($rows as $row): ?>
<tr>
<td class="text-center"><?=$no++; ?></td>
<td><?=$row->nama; ?></td>
<td><?=$row->email; ?></td>
<td><?=$row->no_hp; ?></td>
<td><?=$row->jk; ?></td>
<td><?=$row->usia; ?></td>
<td><?=$row->alamat; ?></td>
<td><?=$row->tanggal_konsultasi; ?></td>
<td><?=$row->hasil_konsultasi; ?></td>
<td class="text-right"><?=$row->kepercayaan; ?>%</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<a href="javascript:window.print()" class="btn">Cetak Riwayat Konsultasi</a>
</div>
</body>
</html>