@if((isset($jobApplicationVersions) && $jobApplicationVersions->count()) || !empty($showUnsavedOriginalVersion))

Version History

@if(!empty($showCreateCorrectedVersionButton)) @endif @if(!empty($showMarkFinalVersionButton) && !empty($selectedJobApplicationVersionId)) @endif
@if(!empty($showUnsavedOriginalVersion))

Original Version

{{ optional($rootJobApplication->updated_at ?? $rootJobApplication->created_at)->format('d-m-Y H:i:s') }}

Candidate

Locked

@else @foreach($jobApplicationVersions as $version)

{{ $version->is_final ? 'Final Version' : ($version->version_number == 1 ? 'Original Version' : 'Corrected Version ' . ($version->version_number - 1)) }}

{{ optional($version->edited_at ?? $version->updated_at)->format('d-m-Y H:i:s') }}

{{ optional($version->editor)->name ?? 'Candidate' }}

{{ $version->is_final ? 'Final locked copy' : ($version->is_locked ? 'Locked' : 'Editable correction') }}

@endforeach @endif
@if(!empty($showFieldChanges) && !empty($selectedJobApplicationVersion)) @php $fieldChangeRows = array_values($fieldChanges ?? []); $fieldChangesTableId = 'field-changes-table-' . $selectedJobApplicationVersion->id; $fieldChangesPaginationId = 'field-changes-pagination-' . $selectedJobApplicationVersion->id; $dateFields = ['dob', 'date_of_birth', 'date']; $yesNoFields = [ 'current_dbs', 'work_with_children', 'any_member_exist', 'disqualified', 'safeguarding_concerns', 'risk_register', 'disciplinary_actions', 'shift_work', 'disadvantage', 'criminal_prosecution', 'criminal_history_disclosure', ]; $fieldValueLabels = [ 'driver_licence' => [ '0' => 'No', '1' => 'Yes - Manual Only', '2' => 'Yes - Automatically Only', '3' => 'Yes - Both Manual & Automatic', ], ]; $formatChangeValue = function ($field, $value) use ($dateFields, $yesNoFields, $fieldValueLabels) { if (is_array($value)) { return json_encode($value); } if (isset($fieldValueLabels[$field][(string) $value])) { return $fieldValueLabels[$field][(string) $value]; } if (in_array($field, $yesNoFields, true)) { if ((string) $value === '1') { return 'Yes'; } if ((string) $value === '0') { return 'No'; } } if (in_array($field, $dateFields, true) && !empty($value) && $value !== '0000-00-00') { try { return \Carbon\Carbon::parse($value)->format('d-m-Y'); } catch (\Exception $e) { return $value; } } return $value; }; @endphp

{{ $selectedJobApplicationVersion->is_final ? 'Overall changes for final version' : 'Field Changes for ' . ($selectedJobApplicationVersion->version_number == 1 ? 'Original Version' : 'Corrected Version ' . ($selectedJobApplicationVersion->version_number - 1)) }}

@if(count($fieldChangeRows))

Total field changes: {{ count($fieldChangeRows) }}

@endif @forelse($fieldChangeRows as $index => $change) @empty @endforelse
# Field Old Value New Value Editor Timestamp
{{ $index + 1 }} {{ ucwords(str_replace('_', ' ', $change['field'])) }} {{ $formatChangeValue($change['field'], $change['old']) }} {{ $formatChangeValue($change['field'], $change['new']) }} {{ $change['editor'] }} {{ $change['timestamp'] }}
No field changes recorded for this version yet.
@if($selectedJobApplicationVersion->version_number > 1)

Revision Notes

Reason and confirmation details:
{{ $selectedJobApplicationVersion->revision_notes ?? 'Not recorded' }}

Candidate confirmed by: {{ $selectedJobApplicationVersion->revision_confirmation_method ?? 'Not recorded' }}

Confirmation received date: {{ !empty($selectedJobApplicationVersion->revision_confirmation_received_at) ? date(config('choicescrm.date_format_forms'), strtotime($selectedJobApplicationVersion->revision_confirmation_received_at)) : 'Not recorded' }}

@if(!empty($selectedJobApplicationVersion->revision_evidence_file)) @php $evidenceAllowed = ['doc', 'docx']; $evidenceExt = pathinfo($selectedJobApplicationVersion->revision_evidence_file, PATHINFO_EXTENSION); $evidencePath = 'crm/candidates/' . $selectedJobApplicationVersion->company_id . '/' . $selectedJobApplicationVersion->revision_evidence_file; @endphp

Evidence: @if(in_array($evidenceExt, $evidenceAllowed)) {{ $selectedJobApplicationVersion->revision_evidence_original_name ?? basename($selectedJobApplicationVersion->revision_evidence_file) }} @else {{ $selectedJobApplicationVersion->revision_evidence_original_name ?? basename($selectedJobApplicationVersion->revision_evidence_file) }} @endif

@endif
@endif @if(count($fieldChangeRows) > 5)
@endif @endif
@endif