@extends('layouts.app') @section('title', 'View Employee') @section('content')

Employee Details

View employee information

Employee Information
Basic Information
ID
{{ $employee->id }}
Employee ID
{{ $employee->employee_id }}
Name
{{ $employee->name }}
Email
{{ $employee->email }}
Office Phone
{{ $employee->phone ?: '-' }}
Personal Contact
{{ $employee->personal_contact_number ?: '-' }}
Gender
{{ ucfirst($employee->gender ?: '-') }}
Marital Status
{{ ucfirst($employee->marital_status ?: '-') }}
Date of Birth
{{ $employee->date_of_birth ? $employee->date_of_birth->format('M d, Y') : '-' }}
NID Number
{{ $employee->nid_number ?: '-' }}
Job Information
Position
{{ $employee->position }}
Department
@if($employee->department_id && $employee->department) {{ $employee->department->name }} @else - @endif
Branch
@if($employee->branch) {{ $employee->branch->name }} @else - @endif
Hire Date
{{ $employee->hire_date->format('M d, Y') }}
Salary
BDT{{ number_format($employee->salary, 2) }}
Employment Duration
@php $duration = $employee->hire_date->diffInDays(now()); $years = floor($duration / 365); $months = floor(($duration % 365) / 30); $days = $duration % 30; @endphp @if($years > 0) {{ $years }} year{{ $years > 1 ? 's' : '' }}, {{ $months }} month{{ $months > 1 ? 's' : '' }} @elseif($months > 0) {{ $months }} month{{ $months > 1 ? 's' : '' }}, {{ $days }} day{{ $days > 1 ? 's' : '' }} @else {{ $days }} day{{ $days > 1 ? 's' : '' }} @endif
Status
@if($employee->status) Active @else Inactive @endif
@if($employee->address)
Address
Address
{{ $employee->address }}
@endif
System Information
Created At
{{ $employee->created_at->format('M d, Y H:i A') }}
Updated At
{{ $employee->updated_at->format('M d, Y H:i A') }}
Last Updated
@php $lastUpdated = $employee->updated_at->diffForHumans(); @endphp {{ $lastUpdated }}
@if($employee->creator)
Created By
{{ $employee->creator->name }}
@endif @if($employee->updater)
Updated By
{{ $employee->updater->name }}
@endif
Record ID
{{ $employee->id }}
@if(isset($assignedTickets) && $assignedTickets->count() > 0)
Assigned Tickets
@foreach($assignedTickets as $ticket) @endforeach
Ticket # Reseller Priority Status Assign To Assign To Duration Category Assigned At Created At Actions
{{ $ticket->ticket_number }} {{ $ticket->user->reseller->company_name ?? $ticket->user->name ?? 'N/A' }} {{ ucfirst($ticket->priority) }} @php $statusLabel = in_array($ticket->status, ['resolved', 'closed']) ? 'Solved' : ucfirst(str_replace('_', ' ', $ticket->status)); @endphp @if($ticket->status == 'in_progress') @else {{ $statusLabel }} @endif @php // Get current active assignment for this employee $currentAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', $employee->id) ->where('is_active', true) ->first(); // Check if there's a previous assignment (inactive) - means ticket was forwarded $hasPreviousAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', '!=', $employee->id) ->where('is_active', false) ->exists(); $forwardedTo = null; $forwardedBy = null; $assignedBy = null; if ($currentAssignment) { // Get user name who assigned/forwarded it if ($currentAssignment->assigned_by) { $assignedByUser = \App\Models\User::find($currentAssignment->assigned_by); $assignedBy = $assignedByUser ? $assignedByUser->name : 'N/A'; } if ($hasPreviousAssignment) { // Ticket was forwarded $forwardedTo = $employee->name; $forwardedBy = $assignedBy; } } @endphp @if($currentAssignment) @if($hasPreviousAssignment && $forwardedTo && $forwardedBy) @else @endif @else N/A @endif @php $assignedAtForDuration = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', $employee->id) ->orderBy('assigned_at', 'desc') ->value('assigned_at'); $durationBadge = 'N/A'; $startIso = null; $endIso = null; $isStatic = false; if ($assignedAtForDuration) { $assignedAtCarbon = \Carbon\Carbon::parse($assignedAtForDuration); if (in_array($ticket->status, ['resolved','closed']) && ($ticket->resolved_at || $ticket->closed_at)) { $endAt = \Carbon\Carbon::parse($ticket->resolved_at ?? $ticket->closed_at); $isStatic = true; } else { $endAt = now(); } $startIso = $assignedAtCarbon->toIso8601String(); $endIso = $endAt->toIso8601String(); $diff = $assignedAtCarbon->diff($endAt); $durationBadge = sprintf('%dd:%dh:%dm:%ds', $diff->days, $diff->h, $diff->i, $diff->s); } @endphp {{ $durationBadge }} {{ $ticket->category->name ?? 'N/A' }} @php $assignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', $employee->id) ->where('is_active', true) ->first(); @endphp @if($assignment && $assignment->assigned_at) {{ \Carbon\Carbon::parse($assignment->assigned_at)->diffForHumans() }} @else N/A @endif {{ $ticket->created_at->format('Y-m-d H:i') }} @php // Get current active assignment for this employee $currentAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', $employee->id) ->where('is_active', true) ->first(); // Check if there's a previous assignment (inactive) - means ticket was forwarded $hasPreviousAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('employee_id', '!=', $employee->id) ->where('is_active', false) ->exists(); $forwardedTo = null; $forwardedBy = null; $assignedBy = null; if ($currentAssignment) { // Get user name who assigned/forwarded it if ($currentAssignment->assigned_by) { $assignedByUser = \App\Models\User::find($currentAssignment->assigned_by); $assignedBy = $assignedByUser ? $assignedByUser->name : 'N/A'; } if ($hasPreviousAssignment) { // Ticket was forwarded $forwardedTo = $employee->name; $forwardedBy = $assignedBy; } } @endphp @if($currentAssignment) @if($hasPreviousAssignment && $forwardedTo && $forwardedBy) {{-- Forward button for forwarded tickets --}} @else {{-- Assign button for new/directly assigned tickets --}} @endif @endif View
@endif
All Tickets
@forelse($allTickets as $ticket) @php // Calculate duration from created_at to resolved_at/closed_at or now $createdAt = \Carbon\Carbon::parse($ticket->created_at); if ($ticket->resolved_at || $ticket->closed_at) { $endAt = \Carbon\Carbon::parse($ticket->resolved_at ?? $ticket->closed_at); } else { $endAt = now(); } $diff = $createdAt->diff($endAt); $solvedDuration = sprintf('%dd:%dh:%dm:%ds', $diff->days, $diff->h, $diff->i, $diff->s ); // Get assigned employee names $assignedEmployees = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('is_active', true) ->join('employees', 'reseller_ticket_employee_assignments.employee_id', '=', 'employees.id') ->pluck('employees.name') ->toArray(); $assignedUsersText = !empty($assignedEmployees) ? implode(', ', $assignedEmployees) : 'Not Assigned'; // Determine button text and color $hasAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->exists(); $hasInactiveAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('is_active', false) ->exists(); if ($ticket->status === 'resolved' || $ticket->status === 'closed') { $buttonText = 'Solved'; $buttonColor = '#6c757d'; } elseif ($hasInactiveAssignment) { $buttonText = 'Forwarded'; $buttonColor = '#28a745'; } elseif ($hasAssignment) { $buttonText = 'Re-Assign'; $buttonColor = '#007bff'; } else { $buttonText = 'Assign'; $buttonColor = '#007bff'; } @endphp @empty @endforelse
Ticket # Reseller Problem Priority Status Assign To Duration Created At Actions
{{ $ticket->ticket_number }} @if($ticket->user->reseller && $ticket->user->reseller->name) {{ $ticket->user->reseller->name }} @elseif($ticket->user->company_name) {{ $ticket->user->company_name }} @else {{ $ticket->user->name ?? 'N/A' }} @endif {{ $ticket->category->name ?? ($ticket->description ? Str::limit($ticket->description, 30) : 'N/A') }} @php $priorityColors = [ 'low' => '#6c757d', 'medium' => '#17a2b8', 'high' => '#ffc107', 'urgent' => '#dc3545' ]; $priorityColor = $priorityColors[$ticket->priority] ?? '#6c757d'; @endphp {{ ucfirst($ticket->priority) }} @php $statusLabel = in_array($ticket->status, ['resolved', 'closed']) ? 'Solved' : ucfirst(str_replace('_', ' ', $ticket->status)); @endphp {{ $statusLabel }} {{ $buttonText }} @php $startIso = \Carbon\Carbon::parse($ticket->created_at)->toIso8601String(); $isStatic = ($ticket->resolved_at || $ticket->closed_at) ? true : false; $endIso = $isStatic ? \Carbon\Carbon::parse($ticket->resolved_at ?? $ticket->closed_at)->toIso8601String() : null; @endphp {{ $solvedDuration }} {{ $ticket->created_at->format('Y-m-d H:i') }} View
No tickets found
{{ $allTickets->links() }}
{{-- Solved Modal for each assigned ticket (in progress) --}} @if(isset($assignedTickets) && $assignedTickets->count() > 0) @foreach($assignedTickets as $ticket) @if($ticket->status == 'in_progress') @endif @endforeach @endif {{-- Assign/Forward Modal for each assigned ticket --}} @if(isset($assignedTickets) && $assignedTickets->count() > 0) @foreach($assignedTickets as $ticket) @php $currentAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->where('is_active', true) ->first(); $currentDepartmentId = $currentAssignment ? $currentAssignment->department_id : null; $currentEmployeeId = $currentAssignment ? $currentAssignment->employee_id : null; $hasExistingAssignment = DB::table('reseller_ticket_employee_assignments') ->where('reseller_ticket_id', $ticket->id) ->exists(); $departments = \App\Models\Department::where('is_active', true)->orderBy('name')->get(); $employees = $currentDepartmentId ? \App\Models\Employee::where('department_id', $currentDepartmentId)->where('status', true)->orderBy('name')->get() : collect(); @endphp @endforeach @endif
@section('styles') @endsection @section('scripts') @endsection @endsection