<?php

if($village['show_special_thanks_home'] != 1){
    return;
}

/* FETCH TOP */
$top_data = mysqli_query($conn,"
SELECT * FROM special_thanks
WHERE village_id='$village_id'
AND show_on_home=1
AND position='top'
ORDER BY display_order ASC
LIMIT 4
");

/* FETCH BOTTOM */
$bottom_data = mysqli_query($conn,"
SELECT * FROM special_thanks
WHERE village_id='$village_id'
AND show_on_home=1
AND position='bottom'
ORDER BY display_order ASC
LIMIT 4
");

/* CHECK ANY DATA */
if(mysqli_num_rows($top_data) == 0 && mysqli_num_rows($bottom_data) == 0){
    return;
}
?>

<h2 class="section-title">विशेष धन्यवाद</h2>

<!-- 🔥 WRAPPER START -->
<div class="special-thanks-section">

<?php while($row=mysqli_fetch_assoc($top_data)){ ?>

<div class="thanks-item">

    <div class="sarpanch-box">

        <div class="sarpanch-image">
            <?php if($row['image']){ ?>
            <img src="/digital_panchayat/uploads/special_thanks/<?php echo $row['image']; ?>">
            <?php } ?>
        </div>

        <div class="sarpanch-text">

            <h3><?php echo htmlspecialchars($row['name']); ?></h3>

            <p style="color:#777;">
                <?php echo htmlspecialchars($row['designation']); ?>
            </p>

            <p>
                <?php echo substr(strip_tags($row['description']),0,180); ?>...
                <br><br>

                <a href="special_thanks_detail.php?id=<?php echo $row['id']; ?>" class="view-btn">
                    पूरा पढ़ें →
                </a>
            </p>

        </div>

    </div>

</div>

<?php } ?>


<?php while($row=mysqli_fetch_assoc($bottom_data)){ ?>

<div class="thanks-item">

    <div class="sarpanch-box">

        <div class="sarpanch-image">
            <?php if($row['image']){ ?>
            <img src="/digital_panchayat/uploads/special_thanks/<?php echo $row['image']; ?>">
            <?php } ?>
        </div>

        <div class="sarpanch-text">

            <h3><?php echo htmlspecialchars($row['name']); ?></h3>

            <p style="color:#777;">
                <?php echo htmlspecialchars($row['designation']); ?>
            </p>

            <p>
                <?php echo substr(strip_tags($row['description']),0,180); ?>...
                <br><br>

                <a href="special_thanks_detail.php?id=<?php echo $row['id']; ?>" class="view-btn">
                    पूरा पढ़ें →
                </a>
            </p>

        </div>

    </div>

</div>

<?php } ?>

</div>
<!-- 🔥 WRAPPER END -->