<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>کشوری</title>

</head>

<body dir="rtl" style="text-align: center;">

<table>
    <thead>
    <tr>
        <th colspan="25" style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
            تاریخ دریافت گزارش: {{verta()->now()->format('Y/m/d H:i')}}
        </th>

    </tr>
    <tr>
        <th colspan="25" style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;"></th>
    </tr>
    <tr>
        <th colspan="26" style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
            تعداد و مجموع فعالیت های روزانه و جاری راهداری ثبت شده از تاریخ
            {{verta($fromDate)->format('Y/n/j')}}
            تا
            تاریخ
            {{verta($toDate)->format('Y/n/j')}}
        </th>>
    </tr>

    <tr>
        <th rowspan="3" style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">اداره کل</th>
        <th colspan="24" style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">فعالیت های انجام شده</th>
    </tr>

    <tr>
        @foreach($details as $detail)
            <th colspan="2" style="border:1px solid black;text-align:center;background-color:#C4D79B">{{ $detail->sub_item_str }}</th>
        @endforeach
    </tr>

    <tr>
        @foreach($details as $detail)
            <th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">تعداد</th>
            <th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">مجموع ({{ $detail->sub_item_unit }})</th>
        @endforeach
    </tr>

    </thead>

    <tbody>
    @foreach ($activities as $activity)
        <tr>
            <td style="border: 1px solid black;text-align: center;">{{ $activity->province_fa }}</td>

            @foreach ($details as $index => $detail)
                <td style="border: 1px solid black;text-align: center;">
                    {{ $activity->{'Count_' . ($index)} ?? '-' }}
                </td>
                <td style="border: 1px solid black;text-align: center;">
                    {{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }}
                </td>
            @endforeach
        </tr>
    @endforeach
    </tbody>
</table>

</body>

</html>