<?php
require 'holidays_script.php';
?>

<!DOCTYPE html>
<html>
<head>

<title>Public Holidays</title>

<script src="https://cdn.tailwindcss.com"></script>

</head>

<body class="flex h-screen bg-gray-100">

<?php include '../sidebar.php'; ?>

<div class="flex-1 p-8 overflow-y-auto" id="main-content">

<h1 class="text-3xl font-bold mb-6">

🎉 Public Holidays

</h1>

<?php if(isset($_GET['saved'])): ?>

<div class="bg-green-100 text-green-700 p-4 rounded-lg mb-6">

Holiday Added Successfully

</div>

<?php endif; ?>

<div class="grid lg:grid-cols-3 gap-6">

<div class="bg-white p-6 rounded-xl shadow">

<h2 class="font-bold mb-4">

Add Holiday

</h2>

<form method="POST">

<div class="mb-4">

<label class="block mb-2">

Holiday Name

</label>

<input
type="text"
name="holiday_name"
required
class="w-full border p-3 rounded-lg">

</div>

<div class="mb-4">

<label class="block mb-2">

Holiday Date

</label>

<input
type="date"
name="holiday_date"
required
class="w-full border p-3 rounded-lg">

</div>

<div class="mb-4">

<label class="flex items-center gap-2">

<input
type="checkbox"
name="is_recurring"
checked>

Recurring Every Year

</label>

</div>

<button
class="bg-blue-600 text-white px-6 py-3 rounded-lg">

Save Holiday

</button>

</form>

</div>

<div class="lg:col-span-2">

<div class="bg-white rounded-xl shadow overflow-hidden">

<table class="w-full">

<thead class="bg-gray-100">

<tr>

<th class="p-4 text-left">

Holiday

</th>

<th class="p-4">

Date

</th>

<th class="p-4">

Recurring

</th>

<th class="p-4">

Action

</th>

</tr>

</thead>

<tbody>

<?php foreach($holidays as $holiday): ?>

<tr class="border-b">

<td class="p-4">

<?= htmlspecialchars(
$holiday['holiday_name']
) ?>

</td>

<td class="p-4 text-center">

<?= date(
'd M Y',
strtotime(
$holiday['holiday_date']
)
) ?>

</td>

<td class="p-4 text-center">

<?= $holiday['is_recurring']
? 'Yes'
: 'No'
?>

</td>

<td class="p-4 text-center">

<a
href="?delete=<?= $holiday['id'] ?>"
onclick="return confirm('Delete Holiday?')"
class="bg-red-600 text-white px-3 py-2 rounded">

Delete

</a>

</td>

</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>

</div>

</div>

</body>
</html>