<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {{-- <title>Invoice Data Report</title> --}}
</head>
<body>

<div style="text-align: center; font-weight: bold;">
    {{ $company }}
</div>
<br>
<p>{!! $greeting !!}</p>

<table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0">
    <tr>
        <th width="30%">Title</th>
        <th width="40%">Details</th>
    </tr>
    <tr>
        <td>Requested Date Time</td>
        <td style="text-align: center;">{{ $request->created_at->format('d-m-Y H:i:s') }}</td>
    </tr>
    <tr>
        <td>Plant Name</td>
        <td style="text-align: center;">{{ $request->plant->name ?? $request->plant_id }}</td>
    </tr>
    <tr>
        <td>Item Code</td>
        <td style="text-align: center;">{{ $request->item->code ?? $request->code }}</td>
    </tr>
    <tr>
        <td>Description</td>
        <td style="text-align: center;">{{ $request->item->description ?? $request->description }}</td>
    </tr>
    <tr>
        <td>Job Number</td>
        <td style="text-align: center;">{{ $request->aufnr }}</td>
    </tr>
    <tr>
        <td>Model Type</td>
        <td style="text-align: center;">{{ $request->model_type }}</td>
    </tr>
    <tr>
        <td>Work Flow ID</td>
        <td style="text-align: center;">{{ $request->work_flow_id }}</td>
    </tr>
</table>
<br>
@if($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Characteristic')
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
    <tr>
        <th>Characteristics Name</th>
        <th>SAP Value</th>
        <th>Update Value</th>
        {{-- <th>Work Flow ID</th> --}}
    </tr>

    @forelse ($tableData as $char)
        <tr>
            {{-- <td>{{ $char['characteristic_name'] ?? '-' }}</td> --}}
            <td style="text-align: center;">{{ strtoupper($char['characteristic_name'] ?? '-') }}</td>
            <td style="text-align: center;">{{ $char['current_value'] ?? '-' }}</td>
            <td style="text-align: center;">{{ $char['update_value'] ?? '-' }}</td>
            {{-- <td style="text-align: center;">{{ $char['work_flow_id'] ?? '-' }}</td> --}}
            {{-- @if ($loop->first)
                <td rowspan="{{ count($tableData) }} "style="text-align: center; vertical-align: middle;">
                    {{ $char['work_flow_id'] ?? '-' }}
                </td>
            @endif --}}
        </tr>
    @empty
        <tr>
            <td colspan="4">No Characteristics Found</td>
        </tr>
    @endforelse
</table>
<br>
<table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0">
    <tr>
        <th>Approver Name</th>
        <th>Approve Status</th>
    </tr>

        @if($level == 2)
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                    <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
                </td>
            </tr>
        @elseif ($level == 3)
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name2 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status2 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                    <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    {{-- <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; --}}
                    <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
                </td>
            </tr>
        @else
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
            </td>
        </tr>

        @endif
</table>
@elseif($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Quality')
{{-- <table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0"> --}}
<table style="margin-left: 3%; " border="1" width="30%" cellpadding="6" cellspacing="0">

    <tr>
        <th colspan="2" style="text-align: center; font-weight: bold;">
            TEMPLATE CHARACTERISTICS
        </th>
    </tr>
    <tr>
        <th>Name</th>
        <th>Value</th>
    </tr>

    @forelse ($tableData as $key => $value)
        <tr>
            <td style="text-align: center;">{{ strtoupper($key) }}</td>
            <td style="text-align: center;">{{ $value }}</td>
        </tr>
    @empty
        <tr>
            <td colspan="2">No Characteristics Found</td>
        </tr>
    @endforelse
</table>
<br>
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
    <tr>
        <th>Approver Name</th>
        <th>Approve Status</th>
    </tr>

        @if($level == 2)
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                    <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
                </td>
            </tr>
        @elseif ($level == 3)
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverNameFromMaster->name2 }}</td>
                <td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status2 ?? '-') }}</td>
            </tr>
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                    <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                    {{-- <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; --}}
                    <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
                </td>
            </tr>
        @else
            <tr>
                <td style="text-align: center;">{{ $approverName }}</td>
                <td style="text-align: center;">
                <a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
                &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
                &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
            </td>
        </tr>

        @endif
</table>
@endif

<p>{!! $wishes !!}</p>
</div>
</body>
</html>
