<?php
    use Carbon\Carbon;
?>
<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>
                            <?php $__currentLoopData = $getMember; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $member): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($member->id == $memberId): ?>
                                    <?php echo e($member->firstName); ?> - <?php echo e($member->nicNumber); ?> -
                                    <?php echo e($member->oldAccountNumber); ?> - <?php echo e($member->newAccountNumber); ?> - Death
                                <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </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="#importDeathHistoryModal"><i
                                        class="menu-icon ti ti-square-rounded-plus"></i>
                                    Import Death history</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('ImportDeathHistory', $usersDataPer)): ?>
                                          <button class="btn btn-success btn-sm me-2" data-bs-toggle="modal"
                                    data-bs-target="#importDeathHistoryModal"><i
                                        class="menu-icon ti ti-square-rounded-plus"></i>
                                    Import Death history</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>Transection Id</th>
                                        <th>Date</th>
                                        <th>User</th>
                                        <th>Description</th>
                                        <th>Type</th>
                                        <th>Amount</th>
                                        <th>Balance</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $count = 1;
                                    ?>
                                    <?php $__currentLoopData = $getDeathHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $history): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo e($count++); ?></td>
                                            <td>
                                                <?php echo e($history->randomId); ?>

                                            </td>
                                            <td>
                                                <?php

                                                    $date = Carbon::createFromFormat(
                                                        'Y-m-d H:i:s',
                                                        $history->created_at,
                                                    );
                                                    $formattedDate = $date->format('d-m-Y h:i:s A');
                                                ?>
                                                <?php echo e($formattedDate); ?>

                                            </td>
                                            <td>
                                                <?php $__currentLoopData = $getUser; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($user->id == $history->userId): ?>
                                                        <?php echo e($user->name); ?>

                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </td>
                                            <td>
                                                <?php echo e($history->description); ?>

                                            </td>
                                            <td>
                                                <?php if($history->type == 'Credit'): ?>
                                                    <span class="badge bg-success">Credit</span>
                                                <?php else: ?>
                                                    <span class="badge bg-danger">Debit</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php echo e(number_format($history->amount, 2)); ?>

                                            </td>
                                            <td>
                                                <?php echo e(number_format($history->balance, 2)); ?>

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


<!-- Import Death History Modal -->
<div class="modal fade" id="importDeathHistoryModal" 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 Death History</h4>
                    <p>Death import function</p>
                </div>

                <!-- Sample Excel Download -->
                <div class="col-12 mb-3 text-center">
                    <a href="<?php echo e(asset('excelimportfile/deathhistory.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="btnImportDeathHistory">Import Death History</button>
                    <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal" aria-label="Close">
                        Discard
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--/ Import Death History Modal -->
<?php /**PATH /Users/anlex/Desktop/untitled folder/ngo/resources/views/pages/allpages/view_death_history.blade.php ENDPATH**/ ?>