@extends('layouts.head_office_app') @section('title', 'Records') @section('subHeader') {{-- @dd(Session::has('success'), Session::has('error'), Session::get('success'), Session::get('error')) --}} @php use App\Models\HeadOffices\CaseManager\HeadOfficeCase; use App\Models\User; if(isset($record->location)){ $location = $record->location; $reported_location = isset($record->recorded_case) ? $record->recorded_case->saved_loc : $location; } @endphp @endsection @section('content')
Back
@php use Carbon\Carbon; $editingState = $record->form->allow_editing_state; // "minutes", "hour", "day", "week", or "always" $editingTime = (int) $record->form->allow_editing_time; // If editing is always allowed $canEdit = false; if ($editingState === 'always') { $canEdit = true; } else { $createdAt = \Carbon\Carbon::parse($record->created_at); $currentTime = \Carbon\Carbon::now(); switch ($editingState) { case 'minutes': $allowedUntil = $createdAt->addMinutes($editingTime); break; case 'hour': $allowedUntil = $createdAt->addHours($editingTime); break; case 'day': $allowedUntil = $createdAt->addDays($editingTime); break; case 'week': $allowedUntil = $createdAt->addWeeks($editingTime); break; default: $allowedUntil = null; break; } if (isset($allowedUntil)) { $canEdit = $currentTime->lessThanOrEqualTo($allowedUntil); } } @endphp
@if ($record->form->allow_editing_state !== 'disable' && is_null($record->all_linked_records()->last()->id) != true && isset($record->recorded_case->id) && $record->recorded_case->status !== 'closed' && $canEdit) @if ( isset($location->organization_setting_assignment->organization_setting)) Modify Report @else Modify Report @endif @endif
@csrf
@php $data_objects = []; if ($record->raw_form) { $updated_records = $record->all_linked_records()->last(); if (isset($updated_records->raw_form)) { $data_objects = $updated_records->get_form_data(); } else { $data_objects = $record->get_form_data(); } } @endphp
@foreach ($data_objects as $data) @if (!empty($data['value']))

{{ $data['label'] }}

@if(is_array($data['value'])) @dd($data['value']); @endif {{ $data['value'] }}

@endif @endforeach
{{-- @php $jsonData = isset($record->json_submission) ? json_decode($record->json_submission,true) : null; @endphp @if ($jsonData) @foreach ($jsonData['mandatory_questions'] as $index => $data) @if ($data)

{{ $data['label'] }}:

@endif @endforeach @else --}} {{--

No Valid Data found

@endif --}} {{-- @if ($record->recorded_case && count($record->recorded_case->root_cause_analysis) > 0) @foreach ($record->recorded_case->root_cause_analysis as $request) @if (!$request->status) {{ $request->root_cause_analysis_type }} @endif @endforeach @endif --}}
@if ($record->form->allow_responder_update && count($record->updates) != 0)
@endif
{{-- @dd($record->recorded_case->new_tasks) --}} @if (isset($record->recorded_case)) @foreach ($record->recorded_case->new_tasks as $taskItem) {{-- @dd($taskItem); --}}
{{ $taskItem->title ?? 'No Title' }}
{{ $taskItem->priority ?? 'No Priority' }} • {{ $taskItem->due_date ?? 'No Due Date' }} • Assigned to {{ $taskItem->assign_to ?? 'No Assignee' }}
@livewire('task-status', ['task' => $taskItem->id])
Updated {{ $taskItem->updated_at ? $taskItem->updated_at->diffForHumans() : 'Unknown Date' }}
@endforeach @endif

{{ $record->form->name }}

Description:
{{ $record->form->note }}
Submitted:
{{ $record->created_at->format('d M Y (D) h:i a') }}
Completed By:
{{ $record->location->trading_name }}
,{{ isset($record->created_by) ? ($record->created_by->first_name . ' ' . $record->created_by->surname) : 'Quick login' }}
@if ($record->form->allow_responder_update)
@foreach ($record->updates as $key => $update)
{{ optional($update->user)->name }} Updated {{ $update->created_at->diffForHumans() }} {{ $update->created_at->format('d M Y (D) h:i a') }}
{!! $update->update !!}
@endforeach @if ($record->form->update_time_left($record->created_at)['allowed'] == false && $record->form->allow_update_state != 'open')

Unfortunately, the time period to submit further updates has passed. Please submit another form if you need to provide further information.

@elseif (isset($record->recorded_case) && $record->recorded_case->status == 'closed' && $record->form->allow_update_state != 'open')

Case is Closed

@else
{{ $record->form->allow_responder_update == true ? 'Provide an Update' : 'Updates Not Allowed' }} You can provide any new updates to the team investigating this case
@csrf
@foreach ($record->documents ?? [] as $doc)
  •  {{$doc->document->original_file_name()}}
  • @endforeach
    Select documents/images to upload

    Drop files here
    form->allow_responder_update == true ? '' : 'disabled' }} type="file" name="file" multiple value="" class="form-control commentMultipleFiles">
    @endif
    @else

    This form does not allow updates. Please submit another form if you need to provide further information.

    @endif
    @if (count($record->get_modifications()) != 0)
    @php $modifications = collect($record->get_modifications())->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
    root
    @if (count($record->getCaseFeedbacks()) != 0) @foreach ($record->getCaseFeedbacks() as $feedback) @php $case_ids = isset($feedback->case_ids) ? json_decode($feedback->case_ids, true) : null; @endphp
    headoffice logo

    Date

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

    Reported

    @isset($case_ids) @foreach ($case_ids as $case_id) @php $case = HeadOfficeCase::find($case_id)->first(); @endphp

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

    {{ $case->incident_type }}

    {{ $case->location_name }}

    @endforeach @endisset
    @if ($feedback->is_feedback_location)

    Feedback by {{ $feedback->HeadOffice->name() }}

    {!! isset($feedback->feedback_location) ? $feedback->feedback_location : $feedback->HeadOffice->name() . ' ' . "did'nt provided any feedback" !!}

    @endif
    @endforeach @else

    No Feedbacks at the moment 🙂!

    @endif
    @endsection @section('scripts') @if(Session::has('success')) @endif @if(Session::has('error')) @endif @endsection