@extends('webapp.layouts.master')

<!-- content start here -->
@section('content')

    <!-- Custom CSS -->
@section('css')
    <style>
        .date {
            font-size: 9px !important;
            padding: 0 !important;
        }

        .tbb {
            font-weight: bold;
            font-size: 16px !important;
        }

        .tnn {
            font-size: 14px !important;
        }

        .red-digit {
            color: red;
        }

        .panaChart table {
            table-layout: fixed;
            width: 100%;
        }

        .panaChart th,
        .panaChart td {
            font-size: 12px !important;
        }
    </style>
@stop

<!-- Main Start -->
<main>
    <div class="panaChart">
        <div class="container">
            <div class="panaChartTop">
                <h2>{{ $market->name }} Pana Chart</h2>
            </div>
            <div class="">
                <table class="table table-bordered table-sm text-center">
                    <thead>
                        <tr>
                            <th class="tdd">Date</th>
                            <th class="tdd">Mon</th>
                            <th class="tdd">Tue</th>
                            <th class="tdd">Wed</th>
                            <th class="tdd">Thu</th>
                            <th class="tdd">Fri</th>
                            <th class="tdd">Sat</th>
                            <th class="tdd">Sun</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($results as $result)
                            <tr>
                                <td>
                                    <p class="date">{{ $result->start_date }} <br> to <br> {{ $result->end_date }}</p>
                                </td>

                                @php
                                    $days = [
                                        'monday',
                                        'tuesday',
                                        'wednesday',
                                        'thursday',
                                        'friday',
                                        'saturday',
                                        'sunday',
                                    ];
                                @endphp

                                @foreach ($days as $day)
                                    @php
                                        $open_pana = $result->{$day . '_open_pana'};
                                        $open_digit = $result->{$day . '_open_digit'};
                                        $close_digit = $result->{$day . '_close_digit'};
                                        $close_pana = $result->{$day . '_close_pana'};

                                        $jodi = $open_digit . $close_digit;
                                        $isRedJodi = in_array($jodi, explode(',', env('RED_DIGITS')));
                                    @endphp

                                    <td>
                                        <span class="tnn {{ $isRedJodi ? 'red-digit' : '' }}">
                                            {{ $open_pana }}
                                        </span><br>

                                        <span class="tbb {{ $isRedJodi ? 'red-digit' : '' }}">
                                            {{ $jodi }}
                                        </span><br>

                                        <span class="tnn {{ $isRedJodi ? 'red-digit' : '' }}">
                                            {{ $close_pana }}
                                        </span>
                                    </td>
                                @endforeach
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</main>
@stop

<!-- JS Section -->
@section('script')
@stop
