<?php
switch ($bill->generic_target_entity_type) {
    case 'Ticket':
        $ticket = \App\Models\Ticket::where('uid', $bill->generic_target_entity_uid)->first();
        ?>
        <div class="mb-1">Ticket > {{strtoupper($ticket->category)}}
            <a class="ml-2"
               native target="_blank"
               open-in-stag-popup
               mc-initer="patient-tickets"
               popup-style="tall"
               title="Ticket Details"
               href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}">
                View
            </a>
        </div>
        <div class="pl-3 text-sm">
            <div class="text-secondary mb-1">Patient: <a href="{{route('patients.view.dashboard', ['patient' => $ticket->patient])}}">{{$ticket->patient->displayName()}}</a></div>
            <div class="text-secondary mb-1">Created: {{friendlier_date_time($ticket->created_at)}}</div>
        </div>
        <?php
        break;
    case 'Appointment':
        $appointment = \App\Models\Appointment::where('uid', $bill->generic_target_entity_uid)->first();
        ?>
        <div class="mb-1">Appointment
            <a class="ml-2"
               native target="_blank"
               href="/patients/view/{{$appointment->client->uid}}/calendar/{{$appointment->uid}}">
                View
            </a>
        </div>
        <div class="pl-3 text-sm">
            <div class="text-secondary mb-1">Patient: <a href="{{route('patients.view.dashboard', ['patient' => $appointment->client])}}">{{$appointment->client->displayName()}}</a></div>
            <div class="text-secondary mb-1">Pro: {{$appointment->pro->displayName()}}</div>
            <div class="text-secondary mb-1">Date: <b>{{friendlier_date_time($appointment->raw_start_time)}}</b></div>
            <div class="text-secondary mb-1">Created: {{friendlier_date_time($appointment->created_at)}}</div>
        </div>
        <?php
        break;
    case 'ClientBDTDevice':
        $device = \App\Models\ClientBDTDevice::where('uid', $bill->generic_target_entity_uid)->first();
        ?>
        <div class="mb-1">Device > {{strtoupper($device->device->category)}}</div>
        <div class="pl-3 text-sm">
            <div class="text-secondary mb-1">Patient: <a href="{{route('patients.view.dashboard', ['patient' => $device->client])}}">{{$device->client->displayName()}}</a></div>
            <div class="text-secondary mb-1">Created: {{friendlier_date_time($device->created_at)}}</div>
        </div>
        <?php
        break;
    case 'Note':
        $note = \App\Models\Note::where('uid', $bill->generic_target_entity_uid)->first();
        ?>
        <div class="mb-1">Note
            <a class="ml-2"
               native target="_blank"
               href="/patients/view/{{$note->client->uid}}/notes/view/{{$note->uid}}">
                View
            </a>
        </div>
        <div class="pl-3 text-sm">
            <div class="text-secondary mb-1">Patient: <a href="{{route('patients.view.dashboard', ['patient' => $note->client])}}">{{$note->client->displayName()}}</a></div>
            <div class="text-secondary mb-1">Eff. Date: {{friendlier_date_time($note->effective_dateest, false)}}</div>
            <div class="text-secondary mb-1">Created: {{friendlier_date_time($note->created_at)}}</div>
        </div>
        <?php
        break;
    default:
        echo $bill->generic_target_entity_type ? $bill->generic_target_entity_type : '-';
}
?>