147 lines
4.4 KiB
PHP
147 lines
4.4 KiB
PHP
<?php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
|
|
if (!isset($_SESSION['login_user'])) {
|
|
header('Location: ./');
|
|
exit;
|
|
}
|
|
|
|
// Mendapatkan IDRFID dari sesi login
|
|
$rfid = $_SESSION['login_user'];
|
|
|
|
require_once("connectDB.php");
|
|
|
|
// Koneksi ke database
|
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
|
|
// Check koneksi
|
|
if ($conn->connect_error) {
|
|
die("Koneksi gagal: " . $conn->connect_error);
|
|
}
|
|
|
|
// Query untuk mengambil data absensi sesuai dengan idrfid yang login
|
|
$sql = "SELECT * FROM data_absen WHERE idrfid = '$rfid' ORDER BY tgl DESC";
|
|
$result = $conn->query($sql);
|
|
|
|
// Menampilkan data absensi
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Dashboard - Cari RFID</title>
|
|
<link rel="stylesheet" type="text/css" href="css/userslog.css">
|
|
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
|
|
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
|
<style>
|
|
/* Custom CSS untuk form */
|
|
.form-style-5 form input[type="text"],
|
|
.form-style-5 form input[type="date"],
|
|
.form-style-5 form button {
|
|
width: 100%;
|
|
height: 40px;
|
|
}
|
|
.form-style-5 form a#download_data {
|
|
display: inline-block;
|
|
width: 100%;
|
|
height: 40px;
|
|
line-height: 40px;
|
|
text-align: center;
|
|
background-color: #007bff;
|
|
color: white;
|
|
text-decoration: none;
|
|
margin-top: 10px; /* Tambah jarak antar tombol */
|
|
}
|
|
</style>
|
|
<script src="js/jquery-2.2.3.min.js"></script>
|
|
<script>
|
|
$(document).ready(function(){
|
|
$('#search_rfid').on('click', function(){
|
|
var rfid = $('#rfid_input').val();
|
|
var start_date = $('#start_date').val();
|
|
var end_date = $('#end_date').val();
|
|
|
|
if(rfid && start_date && end_date) {
|
|
$.ajax({
|
|
url: "cari_rfid_up.php",
|
|
type: 'POST',
|
|
data: {
|
|
'rfid': rfid,
|
|
'start_date': start_date,
|
|
'end_date': end_date
|
|
}
|
|
}).done(function(data) {
|
|
$('#rfid_result').html(data);
|
|
$('#hidden_rfid').val(rfid);
|
|
});
|
|
}
|
|
});
|
|
|
|
// Tambahkan event listener ke download_data untuk menyertakan RFID dan tanggal dalam query string
|
|
$('#download_data').on('click', function() {
|
|
var rfid = $('#hidden_rfid').val();
|
|
var start_date = $('#start_date').val();
|
|
var end_date = $('#end_date').val();
|
|
|
|
if(rfid && start_date && end_date) {
|
|
window.location.href = 'excel.php?rfid=' + rfid + '&start_date=' + start_date + '&end_date=' + end_date;
|
|
} else {
|
|
alert("Cari RFID, Tanggal Awal, dan Tanggal Akhir terlebih dahulu");
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<?php include 'header.php'; ?>
|
|
<header>
|
|
<nav>
|
|
<!-- <ul>
|
|
<li><a href="users_log.php">Dashboard</a></li>
|
|
<li><a href="cari_rfid.php">Cari RFID</a></li>
|
|
</ul> -->
|
|
</nav>
|
|
</header>
|
|
<main>
|
|
<section>
|
|
<!-- Cari RFID -->
|
|
<h1 class="slideInDown animated">Cari RFID</h1>
|
|
<div class="form-style-5 slideInDown animated">
|
|
<form>
|
|
<input type="text" name="rfid_input" id="rfid_input" value="<?php echo $rfid; ?>" style="display: none;">
|
|
<input type="date" name="start_date" id="start_date" placeholder="Tanggal Awal">
|
|
<input type="date" name="end_date" id="end_date" placeholder="Tanggal Akhir">
|
|
<button type="button" id="search_rfid">Cari</button>
|
|
<input type="hidden" id="hidden_rfid" name="hidden_rfid">
|
|
<!-- <a href="#" id="download_data">Ambil Data</a> -->
|
|
</form>
|
|
</div>
|
|
<div class="tbl-header slideInRight animated">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-center">Tanggal</th>
|
|
<th class="text-center">Rfid</th>
|
|
<th class="text-center">Waktu Masuk</th>
|
|
<th class="text-center">Photo Masuk</th>
|
|
<th class="text-center">Waktu Keluar</th>
|
|
<th class="text-center">Photo Keluar</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
<div class="tbl-content slideInRight animated">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tbody id="rfid_result">
|
|
<!-- Hasil pencarian akan ditampilkan di sini -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
</body>
|
|
</html>
|