@extends('layouts.app') @section('title', 'Document Details') @section('page-header')

Document Details

Back @if($document->created_by === auth()->id() || auth()->user()->isAdmin()) Edit @endif @if($document->document_status != 'Archived') @endif
@endsection @section('content') @php use Illuminate\Support\Facades\Storage; $filePath = $document->file_path; $fileUrl = $filePath ? Storage::url($filePath) : null; $fileExtension = $filePath ? pathinfo($filePath, PATHINFO_EXTENSION) : null; $fileName = $filePath ? basename($filePath) : null; $fileSize = null; if ($filePath && Storage::disk('public')->exists($filePath)) { $fileSize = Storage::disk('public')->size($filePath); $fileSize = number_format($fileSize / 1024, 2) . ' KB'; } $fileIcon = match(strtolower($fileExtension ?? '')) { 'pdf' => 'fa-file-pdf text-danger', 'doc', 'docx' => 'fa-file-word text-primary', 'xls', 'xlsx' => 'fa-file-excel text-success', 'ppt', 'pptx' => 'fa-file-powerpoint text-warning', default => 'fa-file text-secondary', }; $formatDate = function($date) { if (!$date) return 'N/A'; if ($date instanceof \DateTime) return $date->format('Y-m-d H:i'); if (is_string($date)) return date('Y-m-d H:i', strtotime($date)); return 'N/A'; }; $formatDateOnly = function($date) { if (!$date) return 'N/A'; if ($date instanceof \DateTime) return $date->format('Y-m-d'); if (is_string($date)) return date('Y-m-d', strtotime($date)); return 'N/A'; }; @endphp @if(session('success')) @endif @if(session('error')) @endif
{{ $document->document_title }}

{{ $document->document_code }}

{{ $document->document_type }}

@if($document->currentVersion) {{ $document->currentVersion->version_number }} ({{ $document->currentVersion->revision_number }}) @else {{ $document->version_number }} @endif

@php $statusColors = [ 'Draft' => 'secondary', 'Under Review' => 'warning', 'Approved' => 'success', 'Archived' => 'dark', 'Rejected' => 'danger', 'Request_Changes' => 'warning' ]; @endphp {{ $document->document_status }}

@if($document->archived_at)

{{ $formatDate($document->archived_at) }}

@endif

@php $trainingColors = [ 'Pending' => 'secondary', 'Completed' => 'success' ]; @endphp {{ $document->training_status }}

{{ $document->source_type }}

{{ $document->creator->name ?? 'N/A' }}

{{ $formatDate($document->created_at) }}

{{ $formatDate($document->updated_at) }}

@if($document->workflow)
Workflow Information

Workflow: {{ $document->workflow->workflow_name }}

Code: {{ $document->workflow->workflow_code }}

Steps: {{ $document->workflow->steps()->count() }}

@if($document->workflow_instance_id) View Approval Status @endif
@endif @if($document->effective_date || $document->review_date)
@if($document->effective_date)

{{ $formatDateOnly($document->effective_date) }}

@endif @if($document->review_date)

{{ $formatDateOnly($document->review_date) }}

@endif
@endif
@if($filePath)
Uploaded Document
{{ $fileName }}
{{ strtoupper($fileExtension) }} File @if($fileSize) | Size: {{ $fileSize }} @endif
@if(strtolower($fileExtension) == 'pdf')
Document Preview
Open in New Tab
@endif
@endif
Document Management
Document Reviews

{{ $document->reviews->count() }} reviews

@if(auth()->user()->isSuperAdmin() || auth()->user()->can('documents', 'review')) View Reviews Add Review @endif
Document Distributions

{{ $document->distributions->count() }} distributions

@if(auth()->user()->isSuperAdmin() || auth()->user()->can('documents', 'distribute')) View Distributions Distribute @endif
Document Acknowledgements

{{ $document->acknowledgements->count() }} acknowledgements

@if(auth()->user()->isSuperAdmin() || auth()->user()->can('documents', 'acknowledge')) View Acknowledgements Acknowledge @endif
Version History
{{ $document->version_number }}
@if($document->versions && $document->versions->count() > 0)
@foreach($document->versions as $version) @endforeach
Version Revision Status Prepared By Effective Date Created At
{{ $version->version_number }} @if($document->current_version_id == $version->document_versions_id) Current @endif {{ $version->revision_number }} @php $versionStatusColors = [ 'draft' => 'secondary', 'under_review' => 'warning', 'approved' => 'success', 'obsolete' => 'dark', 'archived' => 'info' ]; @endphp {{ ucfirst(str_replace('_', ' ', $version->status)) }} {{ $version->preparedBy->name ?? 'N/A' }} {{ $formatDateOnly($version->effective_date) }} {{ $formatDate($version->created_at) }}
@else

No version history available

@endif
@if($document->reviews && $document->reviews->count() > 0)
Document Reviews
@foreach($document->reviews as $review) @endforeach
Reviewer Review Date Status Recommendation Comments
{{ $review->reviewer->name ?? 'N/A' }} {{ $formatDateOnly($review->review_date) }} @php $reviewStatusColors = [ 'pending' => 'secondary', 'in_progress' => 'warning', 'completed' => 'success', 'overdue' => 'danger', 'cancelled' => 'dark' ]; @endphp {{ ucfirst(str_replace('_', ' ', $review->review_status)) }} {{ $review->recommendation_type ? ucfirst($review->recommendation_type) : 'N/A' }} {{ $review->comments ?? '-' }}
@endif @if($document->distributions && $document->distributions->count() > 0)
Document Distributions
@foreach($document->distributions as $distribution) @endforeach
Department User Distributed At Acknowledged Status
{{ $distribution->department->department_name ?? 'N/A' }} {{ $distribution->user->name ?? 'N/A' }} {{ $formatDate($distribution->distributed_at) }} @if($distribution->acknowledgement_required) @if($distribution->acknowledgements->count() > 0) Acknowledged @else Pending @endif @else Not Required @endif @php $distributionStatusColors = [ 'pending' => 'secondary', 'delivered' => 'info', 'acknowledged' => 'success', 'expired' => 'danger', 'cancelled' => 'dark' ]; @endphp {{ ucfirst($distribution->status) }}
@endif @if($document->acknowledgements && $document->acknowledgements->count() > 0)
Document Acknowledgements
@foreach($document->acknowledgements as $acknowledgement) @endforeach
User Acknowledged At Status Comments
{{ $acknowledgement->user->name ?? 'N/A' }} {{ $formatDate($acknowledgement->acknowledged_at) }} {{ ucfirst($acknowledgement->status) }} {{ $acknowledgement->comments ? Str::limit($acknowledgement->comments, 50) : '-' }}
@endif
@if($filePath)
Quick File Access

{{ $fileName }}

View File Download File @if(strtolower($fileExtension) == 'pdf') Open in New Tab @endif
@endif
Approval Status
@if($document->document_status === 'Draft')

This document is in draft mode

@if($document->created_by === auth()->id() || auth()->user()->isAdmin())
@csrf
@endif
@elseif($document->document_status === 'Under Review')
Loading...

Under Review

Waiting for approval

@elseif($document->document_status === 'Approved')
Approved
@if($document->workflow && $document->workflow->instances()->first())

Approval Date: {{ $formatDate($document->workflow->instances()->first()->completed_at) }}

@endif
@elseif($document->document_status === 'Archived')
Archived

This document has been archived

@if($document->archived_at)

Archived on: {{ $formatDate($document->archived_at) }}

@endif @if($document->created_by === auth()->id() || auth()->user()->isAdmin())
@csrf @method('PATCH')
@endif
@elseif($document->document_status === 'Rejected')
Rejected
@if($document->created_by === auth()->id() || auth()->user()->isAdmin())
@csrf
@endif
@endif
Quick Actions
@if($filePath) View File @endif @if($document->workflow_instance_id) View Approval @endif @if($document->document_status === 'Approved') @endif @if($document->document_status != 'Archived' && ($document->created_by === auth()->id() || auth()->user()->isAdmin())) @endif @if($document->document_status === 'Approved' && ($document->created_by === auth()->id() || auth()->user()->isAdmin())) Create New Version @endif @if($document->created_by === auth()->id() || auth()->user()->isAdmin()) Edit Document
@csrf @method('DELETE')
@endif
Electronic Signatures
@if($document->electronicSignatures && $document->electronicSignatures->count() > 0) @foreach($document->electronicSignatures as $signature)
@if($signature->user && $signature->user->employee && $signature->user->employee->employee_signature) Signature @endif

{{ $signature->user->name ?? 'Unknown' }}

{{ $signature->signature_type }}

{{ $formatDate($signature->signed_at) }}

{{ substr($signature->signature_hash, 0, 16) }}...

@endforeach @else

No signatures recorded yet

@endif
Version Summary

{{ $document->version_number }}

Current Version


{{ $document->versions->count() }}
Total Versions
{{ $document->reviews->count() }}
Reviews
@endsection @push('styles') @endpush @push('scripts') @endpush