@php $locale = $locale ?? app()->getLocale(); $isRTL = $locale === 'ar'; // Translation array $translations = [ 'ar' => [ 'title' => 'تقرير زيارة الصيانة', 'generated' => 'تم الإنشاء', 'report_id' => 'رقم التقرير', 'visit_information' => 'معلومات الزيارة', 'visit_number' => 'رقم الزيارة', 'status' => 'الحالة', 'project' => 'المشروع', 'asset' => 'الأصل', 'scheduled_date' => 'تاريخ الجدولة', 'completed_date' => 'تاريخ الإكمال', 'assigned_technicians' => 'الفنيون المعينون', 'name' => 'الاسم', 'responsibility' => 'المسؤولية', 'work_performed' => 'العمل المنفذ', 'observations' => 'الملاحظات', 'recommendations' => 'التوصيات', 'cost_information' => 'معلومات التكلفة', 'total_cost' => 'التكلفة الإجمالية', 'approval_information' => 'معلومات الموافقة', 'approved_at' => 'تمت الموافقة في', 'approved_by' => 'وافق عليه', 'approval_notes' => 'ملاحظات الموافقة', 'rejection_information' => 'معلومات الرفض', 'rejected_at' => 'تم الرفض في', 'rejected_by' => 'رفضه', 'rejection_reason' => 'سبب الرفض', 'comments' => 'التعليقات', 'footer_text' => 'هذا تقرير زيارة صيانة رسمي. يرجى الاحتفاظ به للسجلات.', 'system_generated' => 'تم إنشاؤه بواسطة النظام', 'sar' => 'ريال سعودي', ], 'en' => [ 'title' => 'MAINTENANCE VISIT REPORT', 'generated' => 'Generated', 'report_id' => 'Report ID', 'visit_information' => 'Visit Information', 'visit_number' => 'Visit Number', 'status' => 'Status', 'project' => 'Project', 'asset' => 'Asset', 'scheduled_date' => 'Scheduled Date', 'completed_date' => 'Completed Date', 'assigned_technicians' => 'Assigned Technicians', 'name' => 'Name', 'responsibility' => 'Responsibility', 'work_performed' => 'Work Performed', 'observations' => 'Observations', 'recommendations' => 'Recommendations', 'cost_information' => 'Cost Information', 'total_cost' => 'Total Cost', 'approval_information' => 'Approval Information', 'approved_at' => 'Approved At', 'approved_by' => 'Approved By', 'approval_notes' => 'Approval Notes', 'rejection_information' => 'Rejection Information', 'rejected_at' => 'Rejected At', 'rejected_by' => 'Rejected By', 'rejection_reason' => 'Rejection Reason', 'comments' => 'Comments', 'footer_text' => 'This is an official maintenance visit report. Please retain for your records.', 'system_generated' => 'System Generated', 'sar' => 'SAR', ], ]; $t = $translations[$locale] ?? $translations['en']; @endphp {{ $t['title'] }} - {{ $report->id }}

🔧 {{ $t['title'] }}

{{ $t['generated'] }}: {{ $generated_at->format('d/m/Y H:i') }} {{ $t['report_id'] }}: #{{ $report->id }}
{{ $t['visit_information'] }}
{{ $t['visit_number'] }}
{{ $visit->visit_number ?? 'N/A' }}
{{ $t['status'] }}
{{ $report->status?->value ?? ($isRTL ? 'قيد الانتظار' : 'Pending') }}
{{ $t['project'] }}
@php $projectName = 'N/A'; if ($project) { // Handle multilingual names (JSON array) or direct string if (is_array($project->name ?? null)) { $projectName = $project->name[app()->getLocale()] ?? $project->name['ar'] ?? $project->name['en'] ?? 'N/A'; } elseif (is_string($project->name ?? null) && !empty($project->name)) { $projectName = $project->name; } elseif (method_exists($project, 'getLocalizedName')) { $projectName = $project->getLocalizedName() ?? 'N/A'; } } @endphp {{ $projectName }}
{{ $t['asset'] }}
@php $assetName = 'N/A'; if ($asset) { // Handle multilingual names (JSON array) or direct string if (is_array($asset->name ?? null)) { $assetName = $asset->name[app()->getLocale()] ?? $asset->name['ar'] ?? $asset->name['en'] ?? 'N/A'; } elseif (is_string($asset->name ?? null) && !empty($asset->name)) { $assetName = $asset->name; } elseif (method_exists($asset, 'getLocalizedName')) { $assetName = $asset->getLocalizedName() ?? 'N/A'; } } @endphp {{ $assetName }}
{{ $t['scheduled_date'] }}
{{ $visit->scheduled_at?->format('d/m/Y H:i') ?? 'N/A' }}
{{ $t['completed_date'] }}
{{ $visit->completed_at?->format('d/m/Y H:i') ?? 'N/A' }}
@if($technicians && $technicians->count() > 0)
{{ $t['assigned_technicians'] }}
@foreach($technicians as $technician) @endforeach
{{ $t['name'] }} {{ $t['responsibility'] }}
{{ $technician->name }} {{ $technician->pivot->responsibility ?? 'N/A' }}
@endif @if($report->work_performed)
{{ $t['work_performed'] }}
{{ $report->work_performed }}
@endif @if($report->observations)
{{ $t['observations'] }}
{{ $report->observations }}
@endif @if($report->recommendations)
{{ $t['recommendations'] }}
{{ $report->recommendations }}
@endif @if($report->total_cost)
{{ $t['cost_information'] }}
{{ $t['total_cost'] }}: {{ number_format($report->total_cost, 2) }} {{ $t['sar'] }}
@endif @if($report->approved_at)
{{ $t['approval_information'] }}
{{ $t['approved_at'] }}
{{ $report->approved_at->format('d/m/Y H:i') }}
{{ $t['approved_by'] }}
{{ $report->approvedBy?->name ?? 'N/A' }}
@if($report->approval_notes)
{{ $t['approval_notes'] }}
{{ $report->approval_notes }}
@endif
@endif @if($report->rejected_at)
{{ $t['rejection_information'] }}
{{ $t['rejected_at'] }}
{{ $report->rejected_at->format('d/m/Y H:i') }}
{{ $t['rejected_by'] }}
{{ $report->rejectedBy?->name ?? 'N/A' }}
@if($report->rejection_reason)
{{ $t['rejection_reason'] }}
{{ $report->rejection_reason }}
@endif
@endif @if($comments && $comments->count() > 0)
{{ $t['comments'] }}
@foreach($comments as $comment)
{{ $comment->created_at->format('d/m/Y H:i') }} - {{ $comment->created_by ? \App\Domains\Core\User\Models\User::find($comment->created_by)?->name : 'Unknown' }}
{{ $comment->comment }}
@endforeach
@endif