@forelse($timeline as $item)
{{-- ================================================= --}}
{{-- DATA LOG --}}
{{-- ================================================= --}}
@if($item->event_group == 'DATA')
@php
$dataAction =
strtoupper(
$item->activity_type
?? ''
);
$moduleLabel =
str_replace(
'_',
' ',
$item->module
?? ''
);
@endphp
DATA
{{ $dataAction }}
{{ ucwords($moduleLabel) }}
@if(!empty($item->created_at))
{{ \Carbon\Carbon::parse($item->created_at)->format('d/m/Y H:i:s') }}
@endif
Performed by:
@if(($item->actor_type ?? 'USER') == 'SYSTEM')
System (Auto Sync)
@else
{{ $item->actor_name }}
@endif
@if(($item->actor_type ?? 'USER') == 'SYSTEM')
SYSTEM
@endif
{{-- One collapsible area per DATA event; summary and actor stay visible. --}}
View Details
Hide Details
@if(!empty($item->changed_fields) && is_countable($item->changed_fields))
({{ count($item->changed_fields) }} fields)
@endif
Module:
{{ $item->module ?? '-' }}
|
@if(($item->activity_type ?? '') === 'sync_summary')
Teaching Load ID:
@else
Record ID:
@endif
{{ $item->key_id ?? '-' }}
{{-- ============================================= --}}
{{-- BEFORE / AFTER --}}
{{-- ============================================= --}}
@if(($item->activity_type ?? '') === 'sync_summary')
@php
$summary = $item->new_data_array ?? [];
$notConfigured = ($summary['sync_status'] ?? '') === 'NOT_CONFIGURED';
@endphp
@elseif(!empty($item->changed_fields))
|
Field
|
Before
|
After
|
@foreach($item->changed_fields as $change)
@php
$oldValue =
$change['old'];
$newValue =
$change['new'];
if (
is_array($oldValue)
||
is_object($oldValue)
) {
$oldValue =
json_encode(
$oldValue,
JSON_UNESCAPED_UNICODE
);
}
if (
is_array($newValue)
||
is_object($newValue)
) {
$newValue =
json_encode(
$newValue,
JSON_UNESCAPED_UNICODE
);
}
@endphp
|
{{ $change['field'] }}
|
{{ $oldValue === null || $oldValue === '' ? '-' : $oldValue }}
|
{{ $newValue === null || $newValue === '' ? '-' : $newValue }}
|
@endforeach
@elseif(!empty($item->source))
{{-- Log เก่า ไม่มี OLD_DATA / NEW_DATA --}}
{{ $item->source }}
@endif
{{-- ================================================= --}}
{{-- WORKFLOW LOG --}}
{{-- ================================================= --}}
@elseif($item->event_group == 'WORKFLOW')
@php
$workflowAction =
$item->flow_action
?? '-';
$workflowLabelMap = [
'SUBMIT_FOR_REVIEW'
=> 'Submitted for Secretary Review',
'RESUBMIT_FOR_REVIEW'
=> 'Resubmitted for Secretary Review',
'RECOMMEND_APPROVAL'
=> 'Review / Approval Recommended',
'RECOMMEND_REJECTION'
=> 'Return / Rejection Recommended',
'COMPLETE_REVIEW'
=> 'Secretary Review Completed',
'SEND_TO_APPROVAL'
=> 'Sent to Approval Workflow',
'APPROVE'
=> 'Approved',
'APPROVE_FINAL'
=> 'Final Approval',
'REJECT_RETURN'
=> 'Returned to Previous Step',
'REJECT_FINAL'
=> 'Rejected'
];
$workflowLabel =
$workflowLabelMap[
$workflowAction
]
??
ucwords(
strtolower(
str_replace(
'_',
' ',
$workflowAction
)
)
);
@endphp
WORKFLOW
{{ $workflowLabel }}
@if(!empty($item->created_at))
{{ \Carbon\Carbon::parse($item->created_at)->format('d/m/Y H:i:s') }}
@endif
Performed by:
{{ $item->actor_name }}
{{-- Approval steps, status and comments appear on demand. --}}
View Details
Hide Details
Step:
{{ $item->flow_order ?? '-' }}
@if(!empty($item->flow_actor))
|
Role:
{{ $item->flow_actor }}
@endif
@if(!empty($item->flow_from_order) || !empty($item->flow_to_order))
Route:
Step
{{ $item->flow_from_order ?? '-' }}
Step
{{ $item->flow_to_order ?? 'End' }}
@endif
@if(!empty($item->flow_result))
Result:
{{ $item->flow_result }}
@endif
@if(!empty($item->flow_status_before) || !empty($item->flow_status_after))
Status:
{{ $item->flow_status_before ?? '-' }}
{{ $item->flow_status_after ?? '-' }}
@endif
@if(!empty($item->flow_comment))
Comment:
{{ $item->flow_comment }}
@endif
@endif
@empty
No activity history found.
@endforelse