<?php
session_start();
include "../config/db.php";

mysqli_set_charset($conn, "utf8mb4"); // IMPORTANT FIX

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

include "layout/header.php";
?>

<!-- ===== DASHBOARD HEADER ===== -->

<div class="card-box">
    <h3 style="margin:0;">👋 Welcome, <?php echo $_SESSION['name']; ?></h3>
    <p style="font-size:12px;color:#777;">Digital Panchayat Control Panel</p>
</div>

<!-- ===== SECTION: VILLAGE MANAGEMENT ===== -->

<?php if($_SESSION['role_id'] == 1){ ?>

<h5 class="section-title">🏡 Village Management</h5>
<div class="app-grid">

<a href="villages/village_data.php" class="app-item">
<i class="fa fa-map"></i><span>Village List</span>
</a>

<a href="villages/add_village.php" class="app-item">
<i class="fa fa-plus"></i><span>Add Village</span>
</a>

<a href="districts/add_district.php" class="app-item">
<i class="fa fa-plus-circle"></i><span>Add District</span>
</a>

<a href="districts/district_list.php" class="app-item">
<i class="fa fa-list"></i><span>District List</span>
</a>

<a href="blocks/add_block.php" class="app-item">
<i class="fa fa-plus"></i><span>Add Block</span>
</a>

<a href="blocks/block_list.php" class="app-item">
<i class="fa fa-list"></i><span>Block List</span>
</a>

</div>

<?php } ?>

<!-- ===== SECTION: VILLAGE WEBSITE ===== -->

<h5 class="section-title">🌐 Village Website</h5>
<div class="app-grid">

<a href="contact/contact.php" class="app-item">
<i class="fa fa-phone"></i><span>संपर्क पेज</span>
</a>

<a href="villages/about_village.php" class="app-item">
<i class="fa fa-info-circle"></i><span>गांव के बारे में</span>
</a>

<a href="villages/add_development_work.php" class="app-item">
<i class="fa fa-tools"></i><span>विकास कार्य जोड़ें</span>
</a>

<a href="villages/development_works_list.php" class="app-item">
<i class="fa fa-list"></i><span>विकास कार्य सूची</span>
</a>

<a href="departments/department_list.php" class="app-item">
<i class="fa fa-building"></i><span>विभाग</span>
</a>

<a href="villages/add_news.php" class="app-item">
<i class="fa fa-newspaper"></i><span>समाचार जोड़ें</span>
</a>

<a href="villages/news_list.php" class="app-item">
<i class="fa fa-list"></i><span>समाचार सूची</span>
</a>

<a href="special_thanks/add_special_thanks.php" class="app-item">
<i class="fa fa-heart"></i>
<span>Special Thanks Add</span>
</a>

<a href="special_thanks/special_thanks_list.php" class="app-item">
<i class="fa fa-list"></i>
<span>Special Thanks List</span>
</a>

</div>

<!-- ===== PANCHAYAT ===== -->

<h5 class="section-title">🏛 पंचायत</h5>
<div class="app-grid">

<a href="villages/add_sarpanch.php" class="app-item">
<i class="fa fa-user-tie"></i><span>सरपंच जोड़ें</span>
</a>

<a href="villages/sarpanches_list.php" class="app-item">
<i class="fa fa-list"></i><span>सरपंच सूची</span>
</a>

<a href="villages/add_member.php" class="app-item">
<i class="fa fa-user-plus"></i><span>सदस्य जोड़ें</span>
</a>

<a href="villages/members_list.php" class="app-item">
<i class="fa fa-users"></i><span>सदस्य सूची</span>
</a>

</div>

<!-- ===== BUILDINGS ===== -->

<h5 class="section-title">🏢 भवन</h5>
<div class="app-grid">

<a href="villages/add_temple.php" class="app-item">
<i class="fa fa-place-of-worship"></i><span>मंदिर जोड़ें</span>
</a>

<a href="villages/temples_list.php" class="app-item">
<i class="fa fa-list"></i><span>मंदिर सूची</span>
</a>

<a href="villages/add_chaupal.php" class="app-item">
<i class="fa fa-home"></i><span>चौपाल जोड़ें</span>
</a>

<a href="villages/chaupals_list.php" class="app-item">
<i class="fa fa-list"></i><span>चौपाल सूची</span>
</a>

<a href="villages/add_govt_building.php" class="app-item">
<i class="fa fa-building"></i><span>सरकारी भवन जोड़ें</span>
</a>

<a href="villages/govt_buildings_list.php" class="app-item">
<i class="fa fa-list"></i><span>सरकारी भवन सूची</span>
</a>

<a href="villages/add_anganwadi.php" class="app-item">
<i class="fa fa-child"></i><span>आंगनवाड़ी जोड़ें</span>
</a>

<a href="villages/anganwadi_list.php" class="app-item">
<i class="fa fa-list"></i><span>आंगनवाड़ी सूची</span>
</a>

</div>

<!-- ===== DONATIONS ===== -->

<h5 class="section-title">💰 Donations</h5>
<div class="app-grid">

<a href="donations/add_work.php" class="app-item">
<i class="fa fa-plus"></i><span>कार्य जोड़ें</span>
</a>

<a href="donations/works_list.php" class="app-item">
<i class="fa fa-list"></i><span>कार्य सूची</span>
</a>

<a href="donations/add_donor.php" class="app-item">
<i class="fa fa-user"></i><span>दाता जोड़ें</span>
</a>

<a href="donations/donors_list.php" class="app-item">
<i class="fa fa-users"></i><span>दाता सूची</span>
</a>

</div>

<!-- ===== MEDIA ===== -->

<h5 class="section-title">🎥 मीडिया</h5>
<div class="app-grid">

<a href="villages/add_slider.php" class="app-item">
<i class="fa fa-images"></i><span>स्लाइडर जोड़ें</span>
</a>

<a href="villages/sliders_list.php" class="app-item">
<i class="fa fa-list"></i><span>स्लाइडर सूची</span>
</a>

<a href="villages/create_gallery_category.php" class="app-item">
<i class="fa fa-folder"></i><span>गैलरी कैटेगरी</span>
</a>

<a href="villages/gallery_categories.php" class="app-item">
<i class="fa fa-folder"></i><span>कैटेगरी सूची</span>
</a>

<a href="villages/add_gallery_image.php" class="app-item">
<i class="fa fa-image"></i><span>फोटो जोड़ें</span>
</a>

<a href="villages/gallery_images_list.php" class="app-item">
<i class="fa fa-images"></i><span>फोटो सूची</span>
</a>

<a href="villages/add_yoututbe_video.php" class="app-item">
<i class="fa fa-video"></i><span>वीडियो जोड़ें</span>
</a>

<a href="villages/video_list.php" class="app-item">
<i class="fa fa-video"></i><span>वीडियो सूची</span>
</a>

</div>

<!-- ===== FAMILY ===== -->

<h5 class="section-title">👨‍👩‍👧‍👦 परिवार</h5>
<div class="app-grid">

<a href="families/view_families.php" class="app-item">
<i class="fa fa-users"></i><span>परिवार सूची</span>
</a>

<a href="families/add_family.php" class="app-item">
<i class="fa fa-plus"></i><span>परिवार जोड़ें</span>
</a>

</div>

<!-- ===== SCHEMES ===== -->

<h5 class="section-title">📋 योजनाएं</h5>
<div class="app-grid">

<a href="schemes/view_schemes.php" class="app-item">
<i class="fa fa-list"></i><span>योजना सूची</span>
</a>

<?php if($_SESSION['role_id']==1){ ?>
<a href="schemes/add_scheme.php" class="app-item">
<i class="fa fa-plus"></i><span>योजना जोड़ें</span>
</a>
<?php } ?>

</div>

<!-- ===== USERS ===== -->

<?php if($_SESSION['role_id']==1){ ?>
<h5 class="section-title">👤 User Management</h5>
<div class="app-grid">

<a href="users/add_user.php" class="app-item">
<i class="fa fa-user-plus"></i><span>Add User</span>
</a>

<a href="users/view_users.php" class="app-item">
<i class="fa fa-users"></i><span>Users</span>
</a>

</div>
<?php } ?>

<!-- ===== LOGOUT ===== -->

<div class="app-grid">
<a href="logout.php" class="app-item logout">
<i class="fa fa-sign-out-alt"></i>
<span>Logout</span>
</a>
</div>

<?php include "layout/footer.php"; ?>