

<?php $__env->startSection('content'); ?>
    <div class="container-xxl flex-grow-1 container-p-y">
        <div class="card">
            <div class="card-header">
                <div class="row align-items-center">
                    <div class="col-8">
                        <h5 class="card-title mb-0">Audit Log Details</h5>
                    </div>
                    <div class="col-4 text-end">
                        <a href="<?php echo e(route('audit-logs.index')); ?>" class="btn btn-secondary">
                            <i class="fas fa-arrow-left me-2"></i>Back to List
                        </a>
                    </div>
                </div>
                <hr />
            </div>

            <div class="card-body">
                <div class="row mb-4">
                    <div class="col-md-8">
                        <h4 class="text-primary">Log ID: #<?php echo e($auditLog->id); ?></h4>
                        <p class="text-muted">Tracked activity on the system</p>
                    </div>
                    <div class="col-md-4 text-end">
                        <?php
                            $actionColors = [
                                'created' => 'success',
                                'updated' => 'warning',
                                'deleted' => 'danger'
                            ];
                        ?>
                        <span class="badge bg-<?php echo e($actionColors[$auditLog->action] ?? 'info'); ?> fs-5">
                            <?php echo e(ucfirst($auditLog->action)); ?>

                        </span>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Table Name:</strong></label>
                        <p class="form-control-plaintext">
                            <code class="text-primary bg-light px-2 py-1 rounded"><?php echo e($auditLog->table_name); ?></code>
                        </p>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Record ID:</strong></label>
                        <p class="form-control-plaintext">
                            <span class="badge bg-secondary fs-6">#<?php echo e($auditLog->record_id); ?></span>
                        </p>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Action:</strong></label>
                        <p class="form-control-plaintext">
                            <span class="badge bg-<?php echo e($actionColors[$auditLog->action] ?? 'info'); ?> fs-6">
                                <?php echo e(ucfirst($auditLog->action)); ?>

                            </span>
                        </p>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Performed By:</strong></label>
                        <p class="form-control-plaintext">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($auditLog->user): ?>
                                <strong><?php echo e($auditLog->user->name); ?></strong>
                                <br>
                                <small class="text-muted"><?php echo e($auditLog->user->email); ?></small>
                            <?php else: ?>
                                <span class="text-muted">System</span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </p>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Timestamp:</strong></label>
                        <p class="form-control-plaintext"><?php echo e($auditLog->created_at->format('M d, Y H:i:s A')); ?></p>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label class="form-label text-muted"><strong>Log ID:</strong></label>
                        <p class="form-control-plaintext">#<?php echo e($auditLog->id); ?></p>
                    </div>

                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($auditLog->description): ?>
                    <div class="col-12 mb-3">
                        <label class="form-label text-muted"><strong>Description:</strong></label>
                        <div class="p-3 border rounded bg-light">
                            <?php echo e($auditLog->description); ?>

                        </div>
                    </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($auditLog->changes): ?>
                    <div class="col-12 mb-3">
                        <label class="form-label text-muted"><strong>Changes Made:</strong></label>
                        <div class="p-3 border rounded bg-light">
                            <?php
                                $changes = json_decode($auditLog->changes, true);
                            ?>
                            
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(is_array($changes) && count($changes) > 0): ?>
                                <div class="table-responsive">
                                    <table class="table table-sm">
                                        <thead>
                                            <tr>
                                                <th>Field</th>
                                                <th>Old Value</th>
                                                <th>New Value</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $changes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $field => $change): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <tr>
                                                    <td><strong><?php echo e($field); ?></strong></td>
                                                    <td>
                                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(is_array($change) && isset($change['old'])): ?>
                                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(is_array($change['old']) || is_object($change['old'])): ?>
                                                                <code><?php echo e(json_encode($change['old'])); ?></code>
                                                            <?php else: ?>
                                                                <?php echo e($change['old'] ?? '<span class="text-muted">Empty</span>'); ?>

                                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                                        <?php else: ?>
                                                            <span class="text-muted">N/A</span>
                                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                                    </td>
                                                    <td>
                                                        <?php if(is_array($change) && isset($change['new'])): ?>
                                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(is_array($change['new']) || is_object($change['new'])): ?>
                                                                <code><?php echo e(json_encode($change['new'])); ?></code>
                                                            <?php else: ?>
                                                                <?php echo e($change['new'] ?? '<span class="text-muted">Empty</span>'); ?>

                                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                                        <?php else: ?>
                                                            <span class="text-muted">N/A</span>
                                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                                    </td>
                                                </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </tbody>
                                    </table>
                                </div>
                            <?php else: ?>
                                <p class="text-muted mb-0">No detailed changes recorded.</p>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <!-- Action Buttons -->
                <div class="mt-4">
                    <div class="d-flex justify-content-between">
                        <div>
                            <a href="<?php echo e(route('audit-logs.index')); ?>" class="btn btn-secondary">
                                <i class="fas fa-list me-2"></i>All Audit Logs
                            </a>
                        </div>
                        <div>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(auth()->guard()->check()): ?>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(Auth::user()->is_admin): ?>
                                    <form action="<?php echo e(route('audit-logs.destroy', $auditLog)); ?>" 
                                          method="POST" 
                                          class="d-inline"
                                          onsubmit="return confirm('Are you sure you want to delete this audit log?');">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn btn-danger">
                                            <i class="fas fa-trash me-2"></i>Delete Log
                                        </button>
                                    </form>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\xampp\htdocs\digitizing-academy.lifelinehealthcare.com.pk\resources\views\audit-logs\show.blade.php ENDPATH**/ ?>