<?php $__env->startSection('title', 'Admin Activity Logs'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="page-header d-print-none">
        <div class="row align-items-center">
            <div class="col">
                <h2 class="page-title">
                    <span class="text-muted">Admin Activity Logs</span>
                </h2>
            </div>
        </div>
    </div>
</div>

<div class="page-wrapper">
    <div class="container-fluid">
        <!-- Activity Summary Cards -->
        <div class="row mb-3">
            <div class="col-md-3">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div class="subheader">Total Activities</div>
                            <div class="ms-auto">
                                <div class="h2 m-0"><?php echo e($summary['total']); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div class="subheader">Created</div>
                            <div class="ms-auto">
                                <div class="h2 m-0 text-success"><?php echo e($summary['created']); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div class="subheader">Updated</div>
                            <div class="ms-auto">
                                <div class="h2 m-0 text-info"><?php echo e($summary['updated']); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div class="subheader">Deleted</div>
                            <div class="ms-auto">
                                <div class="h2 m-0 text-danger"><?php echo e($summary['deleted']); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Filters Card -->
        <div class="card mb-3">
            <div class="card-header">
                <h3 class="card-title">Filter Activity Logs</h3>
            </div>
            <div class="card-body">
                <form method="GET" action="<?php echo e(route('super-admin.activity-logs.index')); ?>" class="row g-3">
                    <div class="col-md-3">
                        <label class="form-label">Admin User</label>
                        <select name="user_id" class="form-select">
                            <option value="">All Admins</option>
                            <?php $__currentLoopData = $admins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($admin->id); ?>" <?php echo e(request('user_id') == $admin->id ? 'selected' : ''); ?>>
                                    <?php echo e($admin->name); ?> (<?php echo e($admin->email); ?>)
                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Action</label>
                        <select name="action" class="form-select">
                            <option value="">All Actions</option>
                            <option value="created" <?php echo e(request('action') == 'created' ? 'selected' : ''); ?>>Created</option>
                            <option value="updated" <?php echo e(request('action') == 'updated' ? 'selected' : ''); ?>>Updated</option>
                            <option value="deleted" <?php echo e(request('action') == 'deleted' ? 'selected' : ''); ?>>Deleted</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Model Type</label>
                        <select name="model_type" class="form-select">
                            <option value="">All Types</option>
                            <?php $__currentLoopData = $modelTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($type); ?>" <?php echo e(request('model_type') == $type ? 'selected' : ''); ?>>
                                    <?php echo e($type); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Start Date</label>
                        <input type="date" name="start_date" class="form-control" value="<?php echo e(request('start_date')); ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">End Date</label>
                        <input type="date" name="end_date" class="form-control" value="<?php echo e(request('end_date')); ?>">
                    </div>
                    <div class="col-md-3 d-flex gap-2 align-items-end">
                        <button type="submit" class="btn btn-primary">Filter</button>
                        <a href="<?php echo e(route('super-admin.activity-logs.index')); ?>" class="btn btn-secondary">Reset</a>
                        <a href="<?php echo e(route('super-admin.activity-logs.export', request()->query())); ?>" class="btn btn-success" title="Export to CSV">
                            <i class="ti ti-download"></i> Export
                        </a>
                    </div>
                </form>
            </div>
        </div>

        <!-- Activity Logs Table -->
        <div class="card">
            <div class="table-responsive">
                <table class="table table-vcenter card-table">
                    <thead>
                        <tr>
                            <th>Admin</th>
                            <th>Action</th>
                            <th>Model Type</th>
                            <th>Model ID</th>
                            <th>Description</th>
                            <th>Date & Time</th>
                            <th>IP Address</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $activityLogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="text-nowrap">
                                    <div class="d-flex align-items-center">
                                        <div>
                                            <div class="font-weight-medium"><?php echo e($log->user->name); ?></div>
                                            <small class="text-muted"><?php echo e($log->user->email); ?></small>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <?php if($log->action == 'created'): ?>
                                        <span class="badge bg-success">Created</span>
                                    <?php elseif($log->action == 'updated'): ?>
                                        <span class="badge bg-info">Updated</span>
                                    <?php elseif($log->action == 'deleted'): ?>
                                        <span class="badge bg-danger">Deleted</span>
                                    <?php else: ?>
                                        <span class="badge bg-secondary"><?php echo e(ucfirst($log->action)); ?></span>
                                    <?php endif; ?>
                                </td>
                                <td class="text-nowrap"><?php echo e($log->model_type ?? 'N/A'); ?></td>
                                <td class="text-nowrap"><?php echo e($log->model_id ?? '-'); ?></td>
                                <td><?php echo e($log->description); ?></td>
                                <td class="text-nowrap">
                                    <div><?php echo e($log->created_at->format('M d, Y')); ?></div>
                                    <small class="text-muted"><?php echo e($log->created_at->format('H:i:s')); ?></small>
                                </td>
                                <td class="text-nowrap" title="<?php echo e($log->user_agent); ?>">
                                    <code class="text-xs"><?php echo e($log->ip_address); ?></code>
                                </td>
                                <td>
                                    <a href="<?php echo e(route('super-admin.activity-logs.admin-activity', $log->user_id)); ?>"
                                       class="btn btn-sm btn-info"
                                       title="View all activities of this admin">
                                        <i class="ti ti-eye"></i> View Admin
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="8" class="text-center py-4">No activity logs found</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <?php if($activityLogs->count() > 0): ?>
                <div class="card-footer d-flex align-items-center">
                    <div class="ms-auto">
                        <?php echo e($activityLogs->links()); ?>

                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\startup sabbir\Desktop\jannat\accounting-system\resources\views/admin/activity-logs/index.blade.php ENDPATH**/ ?>