146 lines
6.3 KiB
PHP
146 lines
6.3 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
// Pastikan pengguna sudah login dan merupakan Wajib Pajak
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'Wajib Pajak') {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
$notification = '';
|
|
$error = '';
|
|
|
|
// Daftar jenis pajak yang tersedia
|
|
$tax_types = [
|
|
'Pajak Hotel',
|
|
'Pajak Restoran',
|
|
'Pajak Hiburan',
|
|
'Pajak Reklame',
|
|
'Pajak Parkir',
|
|
'Pajak Air Tanah'
|
|
];
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$tax_type = $_POST['tax_type'] ?? '';
|
|
$period_month = $_POST['period_month'] ?? '';
|
|
$period_year = $_POST['period_year'] ?? '';
|
|
$gross_revenue = $_POST['gross_revenue'] ?? '';
|
|
|
|
// Validasi sederhana
|
|
if (empty($tax_type) || empty($period_month) || empty($period_year) || empty($gross_revenue)) {
|
|
$error = 'Semua field wajib diisi.';
|
|
} elseif (!is_numeric($gross_revenue) || $gross_revenue < 0) {
|
|
$error = 'Omzet kotor harus berupa angka positif.';
|
|
} else {
|
|
try {
|
|
// Asumsi tarif pajak 10% untuk semua jenis
|
|
$tax_rate = 0.10;
|
|
$tax_amount = (float)$gross_revenue * $tax_rate;
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare(
|
|
"INSERT INTO tax_reports (user_id, tax_type, period_month, period_year, gross_revenue, tax_amount)
|
|
VALUES (:user_id, :tax_type, :period_month, :period_year, :gross_revenue, :tax_amount)"
|
|
);
|
|
|
|
$stmt->execute([
|
|
':user_id' => $user_id,
|
|
':tax_type' => $tax_type,
|
|
':period_month' => $period_month,
|
|
':period_year' => $period_year,
|
|
':gross_revenue' => $gross_revenue,
|
|
':tax_amount' => $tax_amount
|
|
]);
|
|
|
|
$notification = 'Laporan pajak Anda telah berhasil diserahkan. Tarif pajak yang dikenakan adalah 10%.';
|
|
|
|
} catch (PDOException $e) {
|
|
$error = "Gagal menyimpan laporan: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lapor Pajak - 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">
|
|
</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">Dashboard</a>
|
|
<a href="lapor-pajak.php" class="active">Lapor Pajak</a>
|
|
<a href="logout.php">Logout</a>
|
|
</nav>
|
|
</aside>
|
|
<main class="main-content">
|
|
<header class="main-header">
|
|
<h1>Formulir Pelaporan Pajak</h1>
|
|
<div class="user-info">
|
|
<span><?php echo htmlspecialchars($_SESSION['user_name']); ?></span>
|
|
<span class="role-badge"><?php echo htmlspecialchars($_SESSION['user_role']); ?></span>
|
|
</div>
|
|
</header>
|
|
<section class="content-section">
|
|
<div class="card form-card">
|
|
<div class="card-body">
|
|
<?php if ($notification): ?>
|
|
<div class="alert alert-success"><?php echo $notification; ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger"><?php echo $error; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form action="lapor-pajak.php" method="POST">
|
|
<div class="form-group">
|
|
<label for="tax_type">Jenis Pajak</label>
|
|
<select id="tax_type" name="tax_type" required>
|
|
<option value="" disabled selected>-- Pilih Jenis Pajak --</option>
|
|
<?php foreach ($tax_types as $type): ?>
|
|
<option value="<?php echo htmlspecialchars($type); ?>"><?php echo htmlspecialchars($type); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="period_month">Periode Pajak</label>
|
|
<div class="period-group">
|
|
<select id="period_month" name="period_month" required>
|
|
<option value="" disabled selected>Bulan</option>
|
|
<?php for ($i = 1; $i <= 12; $i++): ?>
|
|
<option value="<?php echo $i; ?>"><?php echo date('F', mktime(0, 0, 0, $i, 10)); ?></option>
|
|
<?php endfor; ?>
|
|
</select>
|
|
<select id="period_year" name="period_year" required>
|
|
<option value="" disabled selected>Tahun</option>
|
|
<?php for ($i = date('Y'); $i >= date('Y') - 5; $i--): ?>
|
|
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
|
<?php endfor; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="gross_revenue">Total Omzet Kotor (Rupiah)</label>
|
|
<input type="number" id="gross_revenue" name="gross_revenue" placeholder="Contoh: 5000000" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<button type="submit" class="btn btn-primary btn-block">Kirim Laporan</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
</div>
|
|
</body>
|
|
</html>
|