<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>Manage Other Incomes
                        </div>
                        <div class="col-6 d-flex justify-content-end">
                            <?php if($userType == 'superAdmin'): ?>
                                <button class="btn btn-success btn-sm me-2" data-bs-toggle="modal"
                                    data-bs-target="#importOtherIncomeModal"><i
                                        class="menu-icon ti ti-square-rounded-plus"></i>
                                    Import Other Income</button>
                            <?php else: ?>
                                <?php
                                    $userRolesArray = $getUserRole->pluck('roleName')->toArray();
                                ?>

                                <?php if(in_array($userType, $userRolesArray)): ?>
                                    <?php
                                        $usersDataPer = $permissions;
                                        $usersDataPer = json_decode($usersDataPer, true);
                                    ?>

                                    <?php if(in_array('importOtherIncome', $usersDataPer)): ?>
                                        <button class="btn btn-success btn-sm me-2" data-bs-toggle="modal"
                                            data-bs-target="#importOtherIncomeModal"><i
                                                class="menu-icon ti ti-square-rounded-plus"></i>
                                            Import Other Income</button>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="row mt-3">
                            <table class="table table-sm datatableView">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Id</th>
                                        <th>Name</th>
                                        <th>NIC number</th>
                                        <th>Division</th>
                                        <th>Village</th>
                                        <th>Small Group</th>
                                        <th>Profession</th>
                                        <th>Old Account Number</th>
                                        <th>Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $count = 1;
                                    ?>
                                    <?php $__currentLoopData = $getOtherIncome; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $savings): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php
                                            $encryptedId = encrypt($savings->incomId);
                                        ?>
                                        <?php if(auth()->user()->userType == 'superAdmin'): ?>
                                            <tr>
                                                <td><?php echo e($count++); ?></td>
                                                <td> <a href="<?php echo e(route('view_other_income', $encryptedId)); ?>">
                                                        <?php echo e($savings->incomId ?? 'N/A'); ?>

                                                    </a></td>
                                                <td><?php echo e($savings->member->firstName ?? 'N/A'); ?></td>
                                                <td><?php echo e($savings->member->nicNumber ?? 'N/A'); ?></td>
                                                <td>
                                                    <?php if($savings->member->divisionId == ''): ?>
                                                        -
                                                    <?php else: ?>
                                                        <?php echo e($savings->member->division->divisionName); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td>
                                                    <?php if($savings->member->villageId == ''): ?>
                                                        -
                                                    <?php else: ?>
                                                        <?php echo e($savings->member->village->villageName); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <?php if($savings->member->smallGroupId == ''): ?>
                                                    <td>-</td>
                                                <?php else: ?>
                                                    <td><?php echo e($savings->member->smallgroup->smallGroupName); ?></td>
                                                <?php endif; ?>
                                                <td><?php echo e($savings->member->profession); ?></td>
                                                <td><?php echo e($savings->member->oldAccountNumber); ?></td>

                                                <td><?php echo e($savings->totalAmount ?? 'N/A'); ?></td>

                                            </tr>
                                        <?php else: ?>
                                            <?php
                                                $divArray = auth()->user()->division;
                                                $vilArray = auth()->user()->village;
                                            ?>
                                            <?php if($divArray != '' || $divArray != null || $vilArray != '' || $vilArray != null): ?>
                                                <?php if(in_array($savings->member->divisionId, json_decode(auth()->user()->division)) &&
                                                        in_array($savings->member->villageId, json_decode(auth()->user()->village))): ?>
                                                    <tr>
                                                        <td><?php echo e($count++); ?></td>
                                                        <td> <a href="<?php echo e(route('view_other_income', $encryptedId)); ?>">
                                                                <?php echo e($savings->incomId ?? 'N/A'); ?>

                                                            </a></td>
                                                        <td><?php echo e($savings->member->firstName ?? 'N/A'); ?></td>
                                                        <td><?php echo e($savings->member->nicNumber ?? 'N/A'); ?></td>
                                                        <td>
                                                            <?php if($savings->member->divisionId == ''): ?>
                                                                -
                                                            <?php else: ?>
                                                                <?php echo e($savings->member->division->divisionName); ?>

                                                            <?php endif; ?>
                                                        </td>
                                                        <td>
                                                            <?php if($savings->member->villageId == ''): ?>
                                                                -
                                                            <?php else: ?>
                                                                <?php echo e($savings->member->village->villageName); ?>

                                                            <?php endif; ?>
                                                        </td>
                                                        <?php if($savings->member->smallGroupId == ''): ?>
                                                            <td>-</td>
                                                        <?php else: ?>
                                                            <td><?php echo e($savings->member->smallgroup->smallGroupName); ?></td>
                                                        <?php endif; ?>
                                                        <td><?php echo e($savings->member->profession); ?></td>
                                                        <td><?php echo e($savings->member->oldAccountNumber); ?></td>

                                                        <td><?php echo e($savings->totalAmount ?? 'N/A'); ?></td>

                                                    </tr>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--/ Import Other Income Modal -->
<div class="modal fade" id="importOtherIncomeModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-simple">
        <div class="modal-content">
            <div class="modal-body">
                <button type="button" class="btn-close btn-pinned" data-bs-dismiss="modal" aria-label="Close"></button>
                <div class="text-center mb-4">
                    <h4 class="mb-2">Import Other Income</h4>
                    <p>Other Income import function</p>
                </div>

                <!-- Sample Excel Download -->
                <div class="col-12 mb-3 text-center">
                    <a href="<?php echo e(asset('excelimportfile/otherincome.xlsx')); ?>" class="btn btn-outline-info" download>
                        Download Sample Excel
                    </a>
                </div>

                <!-- File Input -->
                <div class="col-12 mb-4">
                    <label class="form-label" for="txtImportFile">Choose Excel file</label>
                    <input type="file" id="txtImportFile" class="form-control" accept=".xlsx, .xls, .csv" />
                </div>

                <!-- Action Buttons -->
                <div class="col-12 text-center demo-vertical-spacing">
                    <button class="btn btn-primary me-4" id="btnImportOtherIncome">Import Other Income</button>
                    <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal" aria-label="Close">
                        Discard
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--/ Import Other Income Modal -->
<?php /**PATH /home/techhdyz/swd.technathi.cloud/resources/views/pages/allpages/otherincome/manage_other_incomes.blade.php ENDPATH**/ ?>