@extends('layouts.head_office_app') @section('title', 'Case ' . $case->id) @section('sub-header') @include('head_office.case_manager.notes.sub-header') @endsection @section('content') @php use Illuminate\Support\Facades\Auth; $headOffice = Auth::guard('web')->user()->selected_head_office; $record = $case->link_case_with_form()->withoutGlobalScope('lean')->first(); $updated_records = $record->all_linked_records()->last(); if (isset($updated_records)) { $questionsJson = json_decode($updated_records->raw_form, true); $updated_form = $updated_records; } else { $questionsJson = json_decode($record->raw_form, true); $updated_form = $record; } @endphp
@include('layouts.error')

Form:

{{$case->form_name ?? ' '}}

Created

{{$case->created_at->format('d M Y, h:i a')}}

@if (isset($case->getReporter()->id) && $case->getReporter()->email != 'external@qitech.com') Reported by

{{$case->getReporter()->name ?? 'External User'}}

Reported from @else Reported from @endif

getReporter()->id) && $case->getReporter()->email != 'external@qitech.com') title="{{$case->location_full_address}}"@endif> @if (isset($case->saved_loc)) {{ isset($case->saved_loc->location_id) ? $case->saved_loc->location_id : $case->saved_loc->trading_name}} @else {{ isset($case->location->location_id) ? $case->location->location_id : $case->location_name}} @endif

Last Updated

{{ $case->updated_at->diffForHumans() }}

@php $jsonData = isset($updated_form->json_submission) ? json_decode($updated_form->json_submission, true) : null; @endphp
{{--
@if (isset($data_objects)&&!empty($data_objects))
@foreach ($data_objects as $index => $data)
@endforeach
@endif
--}} @include('head_office.case_manager.notes.angular_form_emed')
@if (count($record->get_modifications(true)) != 0)
@php $modifications = collect($record->get_modifications(true))->sortByDesc('created_at'); @endphp @foreach ($modifications as $modification) @php $json = isset($modification->modified_data) ? json_decode($modification->modified_data, true) : []; @endphp
{{ $modification->user->name }} Modified a response {{ $modification->created_at->diffForHumans() }}
    @foreach ($json as $id => $changes) @php // Function to extract values if (!function_exists('extractValues')) { function extractValues($value) { if (is_array($value) && !empty($value)) { $flattened = []; foreach ($value as $item) { if (is_array($item)) { if (!empty($item['vtm']['vtm_string'])) { $flattened[] = $item['vtm']['vtm_string']; } if (!empty($item['other'])) { $flattened[] = $item['other']; } } else { $flattened[] = (string) $item; } } return !empty($flattened) ? implode(', ', $flattened) : null; } return !empty($value) ? (string) $value : null; } } // Extract values $original_value = extractValues($changes['original']['value'] ?? null); $modified_value = extractValues($changes['modified']['value'] ?? null); // Skip rendering if both values are empty if (empty($original_value) && empty($modified_value)) { continue; } // Get details or fallback $details = !empty($original_value) ? $record->get_question_details_by_id($id, $modification->parent_record_id, $original_value) : null; $modified_details = !empty($modified_value) ? $record->get_question_details_by_id($id, $modification->parent_record_id, $modified_value) : null; if (empty($details) && !empty($original_value)) { $details = $original_value; } if (empty($modified_details) && !empty($modified_value)) { $modified_details = $modified_value; } // Format results $result = is_array($details) && !empty($details) ? implode(', ', array_map('strval', $details)) : ($details ?? 'N/A'); $modified_result = is_array($modified_details) && !empty($modified_details) ? implode(', ', array_map('strval', $modified_details)) : ($modified_details ?? 'N/A'); @endphp
  • Question: {{ $changes['original']['label'] ?? 'Unknown' }}
    Response: {{ $result ?? 'N/A' }} {{ $modified_result ?? 'N/A' }}
  • @endforeach
@endforeach
@else

No modifications!

@endif
@if (count($case->link_case_with_form->updates))
{{ $case->link_case_with_form->form->name }}
Updates
Case ID: {{ $case->id }}
Location: {{ $case->location_name }}
Printed By: {{ Auth::guard('web')->user()->name }}
Printed Date: {{ Carbon::now()->format(config('app.dateFormat')) }} {{ Carbon::now()->format(config('app.timeFormat')) }}
@php $updates = $case->link_case_with_form->updates()->orderBy('id','desc')->get() @endphp @foreach ($updates as $key => $update)
{{ optional($update->user)->name }} Updated {{ $update->created_at->diffForHumans() }} {{ $update->created_at->format(config('app.dateFormat')) }} {{ $update->created_at->format(config('app.timeFormat')) }}
{!! $update->update !!}
@endforeach
@endif
@endsection @section('styles') @endsection @section('scripts') @endsection