198 lines
11 KiB
PHP
198 lines
11 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
$userName = $_SESSION['user_name'] ?? 'Pengguna';
|
|
$userRole = $_SESSION['user_role'] ?? 'Tidak Dikenal';
|
|
|
|
$pdo = db();
|
|
$users = [];
|
|
$tax_reports = [];
|
|
|
|
// Fetch data based on user role
|
|
if ($userRole === 'Super Administrator') {
|
|
$stmt = $pdo->query("SELECT id, name, email, role, created_at FROM users ORDER BY created_at DESC");
|
|
$users = $stmt->fetchAll();
|
|
} elseif ($userRole === 'Wajib Pajak') {
|
|
$stmt = $pdo->prepare("SELECT * FROM tax_reports WHERE user_id = :user_id ORDER BY created_at DESC");
|
|
$stmt->execute([':user_id' => $user_id]);
|
|
$tax_reports = $stmt->fetchAll();
|
|
} elseif ($userRole === 'Petugas Pajak') {
|
|
$stmt = $pdo->query("SELECT tr.*, u.name AS taxpayer_name FROM tax_reports tr JOIN users u ON tr.user_id = u.id ORDER BY tr.created_at DESC");
|
|
$tax_reports = $stmt->fetchAll();
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dashboard - Si-Apon</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@700&family=Lato:wght@400;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
<div class="dashboard-container">
|
|
<aside class="sidebar">
|
|
<div class="sidebar-header">
|
|
<a href="index.php" class="logo">Si-Apon</a>
|
|
</div>
|
|
<nav class="sidebar-nav">
|
|
<a href="dashboard.php" class="active">Dashboard</a>
|
|
<?php if ($userRole === 'Wajib Pajak'): ?>
|
|
<a href="lapor-pajak.php">Lapor Pajak</a>
|
|
<?php endif; ?>
|
|
<?php if ($userRole === 'Petugas Pajak'): ?>
|
|
<a href="dashboard.php" class="active">Verifikasi Laporan</a>
|
|
<?php endif; ?>
|
|
<?php if ($userRole === 'Super Administrator'): ?>
|
|
<a href="#">Manajemen Pengguna</a>
|
|
<?php endif; ?>
|
|
</nav>
|
|
<div class="sidebar-footer">
|
|
<a href="logout.php">Logout</a>
|
|
</div>
|
|
</aside>
|
|
<main class="main-content">
|
|
<header class="main-header">
|
|
<h1>Selamat Datang, <?php echo htmlspecialchars($userName); ?>!</h1>
|
|
<div class="user-info">
|
|
<span class="role-badge role-<?php echo strtolower(str_replace(' ', '-', $userRole)); ?>"><?php echo htmlspecialchars($userRole); ?></span>
|
|
</div>
|
|
</header>
|
|
<section class="content-section">
|
|
<?php if ($userRole === 'Super Administrator'): ?>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Manajemen Pengguna</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Nama</th>
|
|
<th>Email</th>
|
|
<th>Peran</th>
|
|
<th>Tanggal Terdaftar</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($users)): ?>
|
|
<tr><td colspan="4">Tidak ada pengguna untuk ditampilkan.</td></tr>
|
|
<?php else: ?>
|
|
<?php foreach ($users as $user): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($user['name']); ?></td>
|
|
<td><?php echo htmlspecialchars($user['email']); ?></td>
|
|
<td><span class="badge role-<?php echo strtolower(str_replace(' ', '-', htmlspecialchars($user['role']))); ?>"><?php echo htmlspecialchars($user['role']); ?></span></td>
|
|
<td><?php echo date("d M Y", strtotime($user['created_at'])); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php elseif ($userRole === 'Petugas Pajak'): ?>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Verifikasi Laporan Pajak</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Wajib Pajak</th>
|
|
<th>Tanggal Lapor</th>
|
|
<th>Jenis Pajak</th>
|
|
<th>Total Pajak</th>
|
|
<th>Status</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($tax_reports)):
|
|
?>
|
|
<tr><td colspan="6" style="text-align: center;">Tidak ada laporan untuk diverifikasi.</td></tr>
|
|
<?php else: ?>
|
|
<?php foreach ($tax_reports as $report): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($report['taxpayer_name']); ?></td>
|
|
<td><?php echo date("d M Y", strtotime($report['created_at'])); ?></td>
|
|
<td><?php echo htmlspecialchars($report['tax_type']); ?></td>
|
|
<td>Rp <?php echo number_format($report['tax_amount'], 2, ',', '.'); ?></td>
|
|
<td><span class="badge status-<?php echo strtolower(htmlspecialchars($report['status'])); ?>"><?php echo htmlspecialchars($report['status']); ?></span></td>
|
|
<td class="actions">
|
|
<?php if ($report['status'] === 'Pending'): ?>
|
|
<a href="verifikasi-laporan.php?id=<?php echo $report['id']; ?>&action=approve" class="btn btn-success btn-sm">Setuju</a>
|
|
<a href="verifikasi-laporan.php?id=<?php echo $report['id']; ?>&action=reject" class="btn btn-danger btn-sm">Tolak</a>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php elseif ($userRole === 'Wajib Pajak'): ?>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Riwayat Laporan Pajak Anda</h3>
|
|
<a href="lapor-pajak.php" class="btn btn-primary">Lapor Pajak Baru</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Jenis Pajak</th>
|
|
<th>Periode</th>
|
|
<th>Omzet Kotor</th>
|
|
<th>Total Pajak</th>
|
|
<th>Status</th>
|
|
<th>Tanggal Lapor</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($tax_reports)): ?>
|
|
<tr><td colspan="6" style="text-align: center;">Anda belum memiliki riwayat laporan.</td></tr>
|
|
<?php else: ?>
|
|
<?php foreach ($tax_reports as $report): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($report['tax_type']); ?></td>
|
|
<td><?php echo date('F', mktime(0, 0, 0, $report['period_month'], 10)) . ' ' . $report['period_year']; ?></td>
|
|
<td>Rp <?php echo number_format($report['gross_revenue'], 2, ',', '.'); ?></td>
|
|
<td>Rp <?php echo number_format($report['tax_amount'], 2, ',', '.'); ?></td>
|
|
<td><span class="badge status-<?php echo strtolower(htmlspecialchars($report['status'])); ?>"><?php echo htmlspecialchars($report['status']); ?></span></td>
|
|
<td><?php echo date("d M Y", strtotime($report['created_at'])); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
</main>
|
|
</div>
|
|
</body>
|
|
</html>
|