<div class="content-wrapper">
    <div class="container-xxl flex-grow-1 container-p-y">
        <div class="row">
            <div class="col">
                <div class="card shadow">
                    <div class="card-header text-uppercase custom-header bg-primary text-bg-info fw-bold">
                        <div class="col-6">
                            <i class="menu-icon ti ti-users-group"></i>Group Leader Report
                        </div>
                    </div>
                    <div class="card-body">
                        <table class="table table-sm datatableView">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Division</th>
                                    <th>Division Head</th>
                                    <th>Village</th>
                                    <th>Village Leader</th>
                                    <th>SmallGroup</th>
                                    <th>SmallGroup Leader</th>
                                    <th>Leader Contact No</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                    $i = 1;
                                    $shownVillageIds = [];
                                ?>

                                
                                <?php $__currentLoopData = $getSmallGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $smallGroup): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php
                                        $division = $getDivision->firstWhere('id', $smallGroup->divisionId);
                                        $divisionDetail = $getDivisionDetails->firstWhere('divisionId', $smallGroup->divisionId);
                                        $divisionHead = $getAllMemberData->firstWhere('id', $divisionDetail->divisionHead ?? null);

                                        $village = $getVillage->firstWhere('id', $smallGroup->villageId);
                                        $villageDetail = $getVillageDetails->firstWhere('villageId', $smallGroup->villageId);
                                        $villageLeader = $getAllMemberData->firstWhere('id', $villageDetail->villageLeader ?? null);

                                        $sgDetail = $getSmallGroupDetails->firstWhere('smallgroupId', $smallGroup->id);
                                        $groupLeader = $getAllMemberData->firstWhere('id', $sgDetail->groupLeader ?? null);

                                        $shownVillageIds[] = $village->id ?? null;
                                    ?>
                                    <tr>
                                        <td><?php echo e($i++); ?></td>
                                        <td>
                                            <?php if($division): ?>
                                                <a href="<?php echo e(route('division_details', Crypt::encrypt($division->id))); ?>"><?php echo e($division->divisionName); ?></a>
                                            <?php else: ?>
                                                -
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($divisionHead->firstName ?? '-'); ?> <?php echo e($divisionHead->lastName ?? '-'); ?></td>
                                        <td>
                                            <?php if($village): ?>
                                                <a href="<?php echo e(route('village_details', Crypt::encrypt($village->id))); ?>"><?php echo e($village->villageName); ?></a>
                                            <?php else: ?>
                                                -
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($villageLeader->firstName ?? '-'); ?> <?php echo e($villageLeader->lastName ?? '-'); ?></td>
                                        <td>
                                            <a href="<?php echo e(route('smallgroup_details', Crypt::encrypt($smallGroup->id))); ?>"><?php echo e($smallGroup->smallGroupName); ?></a>
                                        </td>
                                        <td><?php echo e($groupLeader->firstName ?? '-'); ?> <?php echo e($groupLeader->lastName ?? '-'); ?></td>
                                        <td><?php echo e($groupLeader->phoneNumber ?? '-'); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                
                                <?php $__currentLoopData = $getVillage; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $village): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if(in_array($village->id, $shownVillageIds)) continue; ?>
                                    <?php
                                        $division = $getDivision->firstWhere('id', $village->divisionId);
                                        $divisionDetail = $getDivisionDetails->firstWhere('divisionId', $village->divisionId);
                                        $divisionHead = $getAllMemberData->firstWhere('id', $divisionDetail->divisionHead ?? null);
                                        $villageDetail = $getVillageDetails->firstWhere('villageId', $village->id);
                                        $villageLeader = $getAllMemberData->firstWhere('id', $villageDetail->villageLeader ?? null);
                                    ?>
                                    <tr>
                                        <td><?php echo e($i++); ?></td>
                                        <td>
                                            <?php if($division): ?>
                                                <a href="<?php echo e(route('division_details', Crypt::encrypt($division->id))); ?>"><?php echo e($division->divisionName); ?></a>
                                            <?php else: ?>
                                                -
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($divisionHead->firstName ?? '-'); ?> <?php echo e($divisionHead->lastName ?? '-'); ?></td>
                                        <td>
                                            <a href="<?php echo e(route('village_details', Crypt::encrypt($village->id))); ?>"><?php echo e($village->villageName); ?></a>
                                        </td>
                                        <td><?php echo e($villageLeader->firstName ?? '-'); ?> <?php echo e($villageLeader->lastName ?? '-'); ?></td>
                                        <td>-</td>
                                        <td>-</td>
                                        <td>-</td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php /**PATH /home/techhdyz/swd.technathi.cloud/resources/views/pages/allpages/reports/group_leader_report.blade.php ENDPATH**/ ?>