@extends('layouts.vertical', ['title' => 'Gestión #' . $ticket->id]) @section('css') @vite([ 'node_modules/select2/dist/css/select2.min.css', 'node_modules/quill/dist/quill.core.css', 'node_modules/quill/dist/quill.snow.css', 'node_modules/quill/dist/quill.bubble.css' ]) @endsection @section('content')
@include('layouts.shared.page-title', [ 'breadcrumbs' => [ ['title' => 'CRM', 'url' => url('/dashabord')], ['title' => 'Gestiones', 'url' => url('/tickets/list')], ['title' => 'Gestión #' . $ticket->id], ] ])
@php $ticketOpen = in_array($ticket->status, [1, 2, 5]); // Mostrar "Cerrar Gestión" solo si el estado es 1, 2 o 5 @endphp @if($ticket->status == 3) Reabrir Gestión @elseif($ticketOpen) Cerrar Gestión @endif

{{$ticket->title}} @isset($ticket->subtitle) - {{$ticket->subtitle}} @endisset

@if (optional($ticket->getClient)->avatar == null) @else @endif

@php $typeClient = optional($ticket->getClient)->type; $clientId = optional($ticket->getClient)->id; $clientName = ($typeClient == 2) ? optional($ticket->getClient)->business_comercial_name : optional($ticket->getClient)->name . ' ' . optional($ticket->getClient)->name2 . ' ' . optional($ticket->getClient)->lastname . ' ' . optional($ticket->getClient)->lastname2; $legalRepresentative = optional($ticket->getClient)->name . ' ' . optional($ticket->getClient)->name2 . ' ' . optional($ticket->getClient)->lastname . ' ' . optional($ticket->getClient)->lastname2; @endphp @if(getPermission(Auth::user()->permissions, 'clients_edit')) {{ $clientName }} @else {{ $clientName }} @endif @if ($typeClient == 2)
Representante Legal: {{ $legalRepresentative }} @endif

@php $categoryId = optional(optional(optional($ticket->getPolicy)->getBranch)->getCategory)->id; $policyId = optional($ticket->getPolicy)->policy_id; $policyUrl = url('/policy/insurers/' . optional($ticket->getPolicy)->id); @endphp @switch($categoryId) @case(1) @break @case(2) @break @case(3) @break @endswitch @if(!empty($policyId)) {{ $policyId }} @else (Poliza no asignada) @endif

@php $categoryId = optional(optional(optional($ticket->getPolicy)->getBranch)->getCategory)->id; $categoryPolicy = optional($ticket->getPolicy)->category_policy; $insurer = ''; switch ($categoryPolicy) { case '1': $insurer = optional($ticket->getInsurerLife)->name; break; case '2': $insurer = optional($ticket->getInsurerVehicle)->brand . ' - ' . optional($ticket->getInsurerVehicle)->placa; break; case '3': $insurer = optional($ticket->getInsurerDamage)->name; break; } // Si no hay asegurado asignado, mostrar "(Asegurado no asignado)" $showIcon = !empty($insurer); if (!$showIcon) { $insurer = '(Asegurado no asignado)'; } @endphp

@if($showIcon) @switch($categoryId) @case(1) @break @case(2) @break @case(3) @break @default @endswitch @endif {!! $insurer !!}

@if (optional($ticket->getSupervisor)->avatar == null) @else @endif

{{optional($ticket->getSupervisor)->name}}

@if (optional($ticket->getUser)->avatar == null) @else @endif

{{optional($ticket->getUser)->name}}

{{$ticket->created_at->format('d/m/Y')}}

@php // Si el ticket tiene un estado relacionado en la tabla tickets_status, usa sus valores. $statusName = optional($ticket->getStatus)->ticket_status_name ?? 'Estado desconocido'; $statusClass = optional($ticket->getStatus)->ticket_status_class ?? 'badge-secondary'; // Clase CSS por defecto si no existe. switch ($ticket->status) { case 1: // Abierto break; case 2: // Seguimiento break; case 3: // Cerrado break; case 5: // Retrasado break; } @endphp

{{ $statusName }}

@switch($ticket->priority) @case(1) Urgente @break @case(2) Media @break @case(3) Baja @break @endswitch

@if($ticketOpen)
@endif

{!!$ticket->desc!!}

Seguimientos ({{ count($tickets_det) }})

@if($ticketOpen)
@csrf
{{ old('text') }}
@endif @foreach ($tickets_det as $ticket_det)
@if (optional($ticket_det->getUser)->avatar == null) @else @endif
{{ optional($ticket_det->getUser)->name }} {{ ucfirst($ticket_det->created_at->diffForHumans()) }}

{!! $ticket_det->text !!}

@if(count($ticket_det->getFiles) > 0)
Archivos adjuntos:
@foreach ($ticket_det->getFiles as $file) @php $fileData = json_decode($file->url_file, true); $isUploadError = isset($fileData['upload']) && $fileData['upload'] == 'error'; $fileUrl = getFileUrl($file->url_file); $fileName = pathinfo($fileUrl, PATHINFO_BASENAME); $fileExt = strtolower(pathinfo($fileUrl, PATHINFO_EXTENSION)); $icon = 'bi-file-earmark'; // Icono por defecto y color $color = 'text-secondary'; // Color por defecto // Asignar icono y color según la extensión del archivo $icons = [ 'pdf' => ['icon' => 'bi-file-earmark-pdf', 'color' => 'text-danger'], 'doc' => ['icon' => 'bi-file-earmark-word', 'color' => 'text-info'], 'docx' => ['icon' => 'bi-file-earmark-word', 'color' => 'text-info'], 'xls' => ['icon' => 'bi-file-earmark-excel', 'color' => 'text-success'], 'xlsx' => ['icon' => 'bi-file-earmark-excel', 'color' => 'text-success'], 'ppt' => ['icon' => 'bi-file-earmark-ppt', 'color' => 'text-warning'], 'pptx' => ['icon' => 'bi-file-earmark-ppt', 'color' => 'text-warning'], 'zip' => ['icon' => 'bi-file-earmark-zip', 'color' => 'text-warning'], 'rar' => ['icon' => 'bi-file-earmark-zip', 'color' => 'text-secondary'], 'jpg' => ['icon' => 'bi-file-earmark-image', 'color' => 'text-info'], 'jpeg' => ['icon' => 'bi-file-earmark-image', 'color' => 'text-info'], 'png' => ['icon' => 'bi-file-earmark-image', 'color' => 'text-info'], 'gif' => ['icon' => 'bi-file-earmark-image', 'color' => 'text-info'], 'mp3' => ['icon' => 'bi-file-earmark-music', 'color' => 'text-dark'], 'wav' => ['icon' => 'bi-file-earmark-music', 'color' => 'text-dark'], 'mp4' => ['icon' => 'bi-file-earmark-play', 'color' => 'text-dark'], 'avi' => ['icon' => 'bi-file-earmark-play', 'color' => 'text-dark'], 'txt' => ['icon' => 'bi-file-earmark-text', 'color' => 'text-muted'] ]; if (array_key_exists($fileExt, $icons)) { $icon = $icons[$fileExt]['icon']; $color = $icons[$fileExt]['color']; } // Obtener el tamaño del archivo usando size_kb y size_mb $fileSizeKB = isset($fileData['size_kb']) ? (float) $fileData['size_kb'] : null; $fileSizeMB = isset($fileData['size_mb']) ? (float) $fileData['size_mb'] : null; $fileSizeText = 'Tamaño desconocido'; if ($fileSizeKB !== null && $fileSizeMB !== null) { $fileSizeText = $fileSizeMB >= 1 ? $fileSizeMB . ' MB' : $fileSizeKB . ' KB'; } @endphp
@if ($isUploadError) ERROR DE SUBIDA @else {{ $fileName }}

{{ $fileSizeText }}

@endif
@if (!$isUploadError) @endif
@endforeach
@endif
@endforeach
@endsection @section('script') @vite([ 'resources/js/pages/form-advanced.init.js', 'resources/js/pages/form-quilljs.init.js' ]) @endsection