@extends('layouts.master') @section('title', 'Teaching Load Activity Log') @section('style') @endsection @section('script') @endsection @section('content') @include('layouts.header') @include('layouts.title')
{{-- ===================================================== --}} {{-- HEADER --}} {{-- ===================================================== --}}

Teaching Load Activity Log

{{ $faculty->faculty_title ?? '' }} {{ $faculty->faculty_firstname ?? '' }} {{ $faculty->faculty_lastname ?? '' }} | Academic Year {{ $teachingLoad->teaching_load_year }} / Semester {{ $teachingLoad->teaching_load_semester }}
Back to Teaching Load
{{-- ===================================================== --}} {{-- SUMMARY --}} {{-- ===================================================== --}}
Teaching Load ID
{{ $teachingLoad->teaching_load_id }}
Academic Year
{{ $teachingLoad->teaching_load_year }}
Semester
{{ $teachingLoad->teaching_load_semester }}
Current Status
@if($teachingLoad->teaching_load_status == 'Approved') Approved @elseif($teachingLoad->teaching_load_status == 'Rejected') Rejected @elseif($teachingLoad->teaching_load_status == 'Pending') Pending @else {{ $teachingLoad->teaching_load_status }} @endif
{{-- ===================================================== --}} {{-- FILTER --}} {{-- ===================================================== --}}
{{-- ===================================================== --}} {{-- TIMELINE --}} {{-- ===================================================== --}}
@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
Sync Summary — {{ ucwords($moduleLabel) }} @if($notConfigured) NOT CONFIGURED @else COMPLETED @endif
Academic Year: {{ $summary['teaching_load_year'] ?? $teachingLoad->teaching_load_year }}  |  Semester: {{ $summary['teaching_load_semester'] ?? $teachingLoad->teaching_load_semester }}  |  Trigger: {{ $summary['trigger'] ?? 'SYNC' }}
Added: {{ $summary['added'] ?? 0 }} Updated: {{ $summary['updated'] ?? 0 }} Unchanged: {{ $summary['unchanged'] ?? 0 }} Skipped: {{ $summary['skipped'] ?? 0 }}
{{ $summary['note'] ?? '' }}
@elseif(!empty($item->changed_fields))
@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 @endforeach
Field Before After
{{ $change['field'] }} {{ $oldValue === null || $oldValue === '' ? '-' : $oldValue }} {{ $newValue === null || $newValue === '' ? '-' : $newValue }}
@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
@include('layouts.footer') @endsection