@php use Illuminate\Support\Facades\Request; $empIdEncrypted = Request::get('emp'); try { $empId = decrypt($empIdEncrypted); } catch (\Exception $e) { abort(403, 'Invalid Employee ID'); } // الحصول على اللغة من الـ request أو استخدام اللغة الحالية للتطبيق $locale = Request::get('lang', app()->getLocale()); app()->setLocale($locale); function convertToArabicNumbers($string) { $western = range(0, 9); $eastern = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; return str_replace($western, $eastern, $string); } function formatYear($date) { global $locale; if (empty($date)) { return '-'; } try { $year = \Carbon\Carbon::parse($date)->format('Y'); return $locale === 'ar' ? convertToArabicNumbers($year) : $year; } catch (\Exception $e) { return $date; } } /** * Render a compact period string: "2018 — 2020 (2 سنوات)" or "2018 — الآن" when end missing. */ function renderPeriod($start, $end, $locale = 'ar') { $startYear = formatYear($start); $endYear = empty($end) ? ($locale === 'ar' ? 'الآن' : 'Present') : formatYear($end); if ($startYear === '-') { return $endYear === ($locale === 'ar' ? 'الآن' : 'Present') ? '-' : $endYear; } // حساب عدد السنوات $years = ''; if (!empty($start)) { try { $startDate = \Carbon\Carbon::parse($start); $endDate = empty($end) ? \Carbon\Carbon::now() : \Carbon\Carbon::parse($end); // حساب الفرق الكامل بالشهور ثم تقسيمه $totalMonths = $startDate->diffInMonths($endDate); $diffYears = floor($totalMonths / 12); $diffMonths = $totalMonths % 12; if ($diffYears > 0 || $diffMonths > 0) { $parts = []; // إضافة السنوات if ($diffYears > 0) { $yearText = $locale === 'ar' ? ($diffYears == 1 ? 'سنة' : ($diffYears == 2 ? 'سنتان' : 'سنوات')) : ($diffYears == 1 ? 'year' : 'years'); $yearsNum = $locale === 'ar' ? convertToArabicNumbers($diffYears) : $diffYears; $parts[] = "{$yearsNum} {$yearText}"; } // إضافة الأشهر if ($diffMonths > 0) { $monthText = $locale === 'ar' ? ($diffMonths == 1 ? 'شهر' : ($diffMonths == 2 ? 'شهران' : 'أشهر')) : ($diffMonths == 1 ? 'month' : 'months'); $monthsNum = $locale === 'ar' ? convertToArabicNumbers($diffMonths) : $diffMonths; $parts[] = "{$monthsNum} {$monthText}"; } // دمج السنوات والأشهر $separator = $locale === 'ar' ? ' و ' : ' and '; $years = ' (' . implode($separator, $parts) . ')'; } } catch (\Exception $e) { // في حالة فشل الحساب، نكمل بدون عدد السنوات } } return $startYear . ' — ' . $endYear . $years; } $dateAr = convertToArabicNumbers(\Carbon\Carbon::now()->locale('ar')->translatedFormat('d F Y - h:i A')); $website = env('APP_URL', 'https://orascom.com'); $documentId = 'DOC-' . now()->format('Ymd-His') . '-' . Str::upper(Str::random(4)); $employee = \App\Models\User\UserEmployee::with('user')->findOrFail($empId); $cv = is_array($employee->cv) ? $employee->cv : json_decode($employee->cv, true); $full_name = $locale === 'ar' ? ($employee->full_name['ar'] ?? '') : ($employee->full_name['en'] ?? ''); $email = $employee->user?->email ?? ''; $profile_picture_path = $cv['profile_picture'] ?? null; $experience_roads = $cv['work_experience']['roads'] ?? []; $experience_airports = $cv['work_experience']['airports'] ?? []; $experience_concrete = $cv['work_experience']['concrete'] ?? []; $skills = $cv['skills'] ?? []; $phone = $employee->phone ? json_decode($employee->phone, true)[0] ?? '' : ''; $job = $locale === 'ar' ? optional($employee->jobTitle)->title_ar : optional($employee->jobTitle)->title_en; $job_title = $job ?? ($locale === 'ar' ? 'موظف' : 'Employee'); $languages = $cv['languages'] ?? []; $certificates = $cv['certificates'] ?? []; $graduation_project = $cv['graduation_project'] ?? ''; $qualification = $cv['qualification'] ?? ($employee->qualification ?? ''); $graduation_year = $cv['graduation_year'] ?? ($employee->graduation_year ?? ''); $military_status = $cv['military_status'] ?? ($employee->military_status ?? ''); $national_id = $employee->national_id ?? ''; $governorate = $locale === 'ar' ? $employee->governorate_name : ($employee->governorate_name_en ?? $employee->governorate_name); @endphp
{{ __('frontend.governorate') . ': ' . $governorate }}
@if ($employee->birth_date){{ __('frontend.birth_date') . ': ' }} {{ $locale === 'ar' ? convertToArabicNumbers($employee->birth_date->locale('ar')->translatedFormat('d F Y')) : $employee->birth_date->locale('en')->translatedFormat('d F Y') }} ({{ $locale === 'ar' ? convertToArabicNumbers($employee->birth_date->age) : $employee->birth_date->age }} {{ __('frontend.years') }} )
@endif{{ __('frontend.national_id') }}: {{ $national_id ?: '-' }}
{{ __('backend.qualification') }}: {{ $qualification ?: '-' }}
{{ __('backend.graduation_year') }}: {{ $graduation_year ?: '-' }}
{{ __('frontend.hire_date') }}: {{ $employee->hiring_date ? ($locale === 'ar' ? convertToArabicNumbers(\Carbon\Carbon::parse($employee->hiring_date)->translatedFormat('d F Y')) : \Carbon\Carbon::parse($employee->hiring_date)->translatedFormat('d F Y')) : '-' }}
{{ __('frontend.contract_date') }}: {{ $employee->contract_date ? ($locale === 'ar' ? convertToArabicNumbers(\Carbon\Carbon::parse($employee->contract_date)->translatedFormat('d F Y')) : \Carbon\Carbon::parse($employee->contract_date)->translatedFormat('d F Y')) : '-' }}
{{ __('frontend.graduation_project') }}: {{ $graduation_project }}
{{ __('backend.military_status') }}: {{ $military_status ? __("backend.{$military_status}") : '-' }}
📱 +20{{ $phone }}
📧 {{ $email }}
{{ __('frontend.no_skills') }}
@endif{{ __('frontend.no_languages') }}
@endif{{ __('frontend.no_certificates') }}
@endif📅 {{ renderPeriod($exp['start_date'], $exp['end_date'], $locale) }}
@if (!empty(trim($exp['description'] ?? '')))📝 {{ $exp['description'] }}
@endif{{ __('frontend.no_experience') }}
@endforelse📅 {{ renderPeriod($exp['start_date'], $exp['end_date'], $locale) }}
@if (!empty(trim($exp['description'] ?? '')))📝 {{ $exp['description'] }}
@endif{{ __('frontend.no_experience') }}
@endforelse📅 {{ renderPeriod($exp['start_date'], $exp['end_date'], $locale) }}
@if (!empty(trim($exp['description'] ?? '')))📝 {{ $exp['description'] }}
@endif{{ __('frontend.no_experience') }}
@endforelse