@php use App\General\SettingsClass; use Illuminate\Support\Facades\DB; use App\Models\User; use App\Models\Adminsettings; $logoPath = null; $companyName = env('APP_NAME', 'WMS'); $companyAddress = ''; $companyCity = ''; $companyState = ''; $companyPostCode = ''; $companyCountry = ''; $companyPhone = 'Contact Information'; $companyEmail = env('EMAIL_ADDRESS', 'support@example.com'); // Get admin settings data $admin = User::where('user_type', config('constants.user_types.admin'))->first(); if ($admin) { $settings = DB::table('adminsettings')->where('customer_id', $admin->id)->get(); // Transform into key-value pairs for easier access $settingsData = []; foreach ($settings as $setting) { $settingsData[$setting->key] = $setting->value; } // Get logo if (isset($settingsData['brand_logo_dark'])) { $logoPath = $settingsData['brand_logo_dark']; } // Get company information if (isset($settingsData['company_company_name'])) { $companyName = $settingsData['company_company_name']; } if (isset($settingsData['company_company_address'])) { $companyAddress = $settingsData['company_company_address']; } if (isset($settingsData['company_company_city'])) { $companyCity = $settingsData['company_company_city']; } if (isset($settingsData['company_company_state'])) { $companyState = $settingsData['company_company_state']; } if (isset($settingsData['company_company_post_code'])) { $companyPostCode = $settingsData['company_company_post_code']; } if (isset($settingsData['company_company_country'])) { $companyCountry = $settingsData['company_company_country']; } if (isset($settingsData['company_company_telephone'])) { $companyPhone = $settingsData['company_company_telephone']; } if (isset($settingsData['company_company_email'])) { $companyEmail = $settingsData['company_company_email']; } } // Get system date and time format settings $systemDateFormat = 'd-m-Y'; // Default format $systemTimeFormat = 'H:i'; // Default 24-hour format if ($admin) { $dateSetting = Adminsettings::where('customer_id', $admin->id)->where('key', 'system_date_format')->first(); $timeSetting = Adminsettings::where('customer_id', $admin->id)->where('key', 'system_time_format')->first(); if ($dateSetting && $dateSetting->value) { // Convert system format to Carbon format $formatMap = [ 'mm-dd-yyyy' => 'm-d-Y', 'dd-mm-yyyy' => 'd-m-Y', 'yyyy-mm-dd' => 'Y-m-d', 'mm/dd/yyyy' => 'm/d/Y', 'dd/mm/yyyy' => 'd/m/Y', 'yyyy/mm/dd' => 'Y/m/d', ]; $systemDateFormat = $formatMap[strtolower($dateSetting->value)] ?? 'd-m-Y'; } if ($timeSetting && $timeSetting->value) { // Check if the format contains AM/PM or if user prefers 12-hour format $value = strtoupper($timeSetting->value); if ( str_contains($value, 'AM') || str_contains($value, 'PM') || str_contains($value, '12') || str_contains($value, 'HOUR') ) { $systemTimeFormat = 'g:i A'; // 12-hour format with AM/PM } } } // Format full address $fullAddress = $companyAddress; if (!empty($companyCity)) { $fullAddress .= ', ' . $companyCity; } if (!empty($companyState)) { $fullAddress .= ', ' . $companyState; } if (!empty($companyPostCode)) { $fullAddress .= ' ' . $companyPostCode; } if (!empty($companyCountry)) { $fullAddress .= ', ' . $companyCountry; } // Set defaults for variables that might not be provided if (!isset($subject)) { $subject = 'Helpdesk Ticket Update'; } // Default status configuration in case it's not provided if (!isset($status_config)) { $status_config = [ 'status_text' => 'Unknown', 'color' => '#6B7280', // Gray 'background' => 'linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%)', 'icon' => '📄', 'message' => 'Ticket status information.', ]; } @endphp {{ $subject }}
@if (!empty($logoPath) && file_exists(public_path($logoPath))) WMS Logo @else

{{ $companyName }}

@endif

@if ($recipient == 'customer') Hello, {{ $ticket->name }} @else Admin Support Team Alert @endif

@if ($recipient == 'customer') @if (isset($adminCreated) && $adminCreated) New Support Ticket Created for You: {{ $status_config['status_text'] }} @else Your Ticket Update: {{ $status_config['status_text'] }} @endif @else New Support Ticket Update: {{ $status_config['status_text'] }} @endif

@if ($recipient == 'customer') @if (isset($adminCreated) && $adminCreated) Welcome! Our support team has created a ticket on your behalf to help resolve your issue. Please review the details below and feel free to respond with any additional information. @else {{ $status_config['message'] }} @endif @else This ticket requires your attention. A new reply has been added to ticket {{ $ticket->ticket_id }}. @endif

@if (isset($adminCreated) && $adminCreated && $recipient == 'customer')

📋 Ticket Created by Support Team

This ticket was created by our support team to assist you. You can reply to this email or use the ticket system to provide additional information or ask questions.

@endif

Ticket Information

Ticket ID: {{ $ticket->ticket_id }}

Subject: {{ $ticket->subject }}

Category: {{ $ticket->getRelation('category') ? $ticket->getRelation('category')->name : 'N/A' }}

Status: {{ $status_config['status_text'] }}

Created: @if (isset($formattedTicket)) {{ $formattedTicket['created_at'] }} @else {{ $ticket->created_at->format($systemDateFormat . ' ' . $systemTimeFormat) }} @endif

@if ($recipient == 'admin')

Customer Information

Name: {{ $ticket->name }}

Email: {{ $ticket->email }}

@endif