@extends('layouts.report-print')

@section('content')
    <table class="report-info">
        <tr>
            <td>{{ __('Employee') }}:</td>
            <td>{{ $employee->first_name }} {{ $employee->last_name }} ({{ $employee->employee_code }})</td>
            <td>{{ __('Date Range') }}:</td>
            <td>{{ $start }} {{ __('to') }} {{ $end }}</td>
        </tr>
        <tr>
            <td>{{ __('Department') }}:</td>
            <td>{{ optional($employee->department)->name ?? 'N/A' }}</td>
            <td>{{ __('Total Worked') }}:</td>
            <td>{{ floor($totals['worked'] / 60) }}h {{ $totals['worked'] % 60 }}m</td>
        </tr>
        <tr>
            <td>{{ __('Position') }}:</td>
            <td>{{ optional($employee->designation)->name ?? 'N/A' }}</td>
            <td>{{ __('Total Overtime') }}:</td>
            <td>{{ floor($totals['ot'] / 60) }}h {{ $totals['ot'] % 60 }}m</td>
        </tr>
    </table>

    <table class="data-table">
        <thead>
            <tr>
                <th>{{ __('Date') }}</th>
                <th>{{ __('Shift') }}</th>
                <th>{{ __('First In') }}</th>
                <th>{{ __('Last Out') }}</th>
                <th>{{ __('Status') }}</th>
                <th>{{ __('Worked') }}</th>
                <th>{{ __('Overtime') }}</th>
                <th>{{ __('Lateness') }}</th>
            </tr>
        </thead>
        <tbody>
            @foreach($rows as $row)
                <tr>
                    <td>{{ \Carbon\Carbon::parse($row->date)->format('Y-m-d') }}</td>
                    <td>{{ optional($row->shift)->name ?? 'Default' }}</td>
                    <td>{{ $row->first_in ? \Carbon\Carbon::parse($row->first_in)->format('H:i') : '--:--' }}</td>
                    <td>{{ $row->last_out ? \Carbon\Carbon::parse($row->last_out)->format('H:i') : '--:--' }}</td>
                    <td>{{ ucfirst($row->status) }}</td>
                    <td>{{ floor($row->minutes_worked / 60) }}h {{ $row->minutes_worked % 60 }}m</td>
                    <td>{{ floor($row->overtime_minutes / 60) }}h {{ $row->overtime_minutes % 60 }}m</td>
                    <td>{{ $row->minutes_late }}m</td>
                </tr>
            @endforeach
            @if($rows->isEmpty())
                <tr>
                    <td colspan="8" style="text-align: center;">{{ __('No records found.') }}</td>
                </tr>
            @endif
        </tbody>
    </table>
@endsection