<?php
session_start();
require_once 'functions.php';

if (!isset($_SESSION['login_user'])) {
    header('Location: login.php');
    exit;
}

$user = $_SESSION['login_user'];
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>Program Sistem Pakar Diagnosa</title>
    <link href="assets/css/yeti-bootstrap.min.css" rel="stylesheet"/>
    <link href="assets/css/general.css" rel="stylesheet"/>
    <link href="assets/css/select2.min.css" rel="stylesheet"/>
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>    
    <script src="assets/js/select2.min.js"></script>   
    <style type="text/css">
    .hi{
background-image: linear-gradient(rgba(0, 0, 0, 0.5),rgba(0, 0, 0, 0.5)), url('vitaminbg.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }
.dark{
  background-color: #000;
  color: #000;
}
.page-header{
    color: #fff;
}
.latar{
        background-color: #636e72;
    }
    .tambah{
        background-color:   #353b48;
    }
    .tambah:hover{
        background-color:   #718093;
        color: #fff;
    }
     .edit{
        background-color: #2f3640;
    }
    .edit:hover{
        background-color:   #718093;
        color: #fff;
    }
    </style>      
  </head>
<body class='dark hi'>
<div class="page-header">
    <h1 style="color: #fff;" align="center"><b>Riwayat Konsultasi</b></h1>
</div>



<div class="panel panel-default">
<div class="panel-heading" align="right">        
        <form class="form-inline">
        <a href="cetak_riwayat.php" target="_blank" class="btn btn-primary">Cetak Riwayat Konsultasi</a>
        </form>
    </div>
<div class="table-responsive">
        <table class="table table-bordered table-hover table-striped">
            <tr style="background-color: #535c68; color: #fff;">
                <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>
        <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><?=$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><?=$row->kepercayaan; ?>%</td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>
