<style>
    body {
        background-color: #132439 !important;
    }

    /* width */
    #div-cotas::-webkit-scrollbar {
        width: 10px;
    }

    /* Track */
    #div-cotas::-webkit-scrollbar-track {
        box-shadow: inset 0 0 5px grey;
        border-radius: 10px;
    }

    /* Handle */
    #div-cotas::-webkit-scrollbar-thumb {
        background: #28a745 !important;
        border-radius: 10px;
    }

    /* Handle on hover */
    #div-cotas::-webkit-scrollbar-thumb:hover {
        background: #28a745 !important;
    }
</style>
<?php $__env->startSection('title', 'Page Title'); ?>
<?php $__env->startSection('sidebar'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="container">
        <div class="title">
            <h3 style="color: #fff;">MINHAS RESERVAS</h3>
        </div>

        <div class="row mb-4">
            <div class="col-md-12">
                <label style="color: #fff">Selecione a Rifa</label>
                <select name="" id="" class="form-control" onchange="showHideReservas(this)">
                    <option value="0">Mostrar Todas</option>
                    <?php $__currentLoopData = $rifas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $rifa): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>"><?php echo e($rifa); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
        <div class="row" style="margin-bottom: 130px;">
            <?php $__currentLoopData = $reservas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reserva): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-7 row-rifa rifa-<?php echo e($reserva->rifa()->id); ?>" style="margin-bottom: 20px;">
                    <div class="card" style="border: none;background: #020f1e;">
                        <div class="card-body" style="background-color: #020f1e;">
                            <h5 class="card-title" style="color: #fff;"><i class="bi bi-cash"></i> Informações da Reserva
                            </h5>
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td style="color: #fff;">Participante:
                                            <?php echo e($reserva->name); ?></td>
                                        <td style="color: #fff;"></td>
                                    </tr>
                                    <tr>
                                        <td style="color: #fff;">Telefone:
                                            <?php echo e($reserva->telephone); ?></td>
                                        <td style="color: #fff;"></td>
                                    </tr>
                                    <tr>
                                        <td style="color: #fff;">
                                            Meu(s) bilhete(s) pago(s):
                                            <?php echo e($reserva->pagos + $reserva->reservados); ?> COTAS
                                            <div id="div-cotas" style="max-height: 200px;overflow: auto;">
                                                <?php if($reserva->rifa()->modo_de_jogo == 'numeros'): ?>
                                                    <?php $__currentLoopData = $reserva->pagos(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $numPago): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <span class="badge text-bg-success" style=""><i
                                                                class="fa fa-check"></i> <?php echo e($numPago); ?> </span>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php else: ?>
                                                    <?php $__currentLoopData = $reserva->pagos(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $numPago): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <span class="badge text-bg-success" style=""><i
                                                                class="fa fa-check"></i> <?php echo e($numPago->grupoFazendinha()); ?> </span>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </div>
                                        </td>

                                    </tr>
                                    <tr>
                                        <td style="color: #fff;">
                                            Meu(s) bilhete(s) aguardando pagamento:<br><br>
                                            COTAS:
                                            <?php if($reserva->rifa()->type_raffles == 'automatico'): ?>
                                                Números serão gerados após o pagamento!
                                            <?php else: ?>
                                                <?php $__currentLoopData = $reserva->reservados(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $numRes): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <span class="badge text-bg-warning" style=""><i
                                                            class="fa fa-clock"></i> <?php echo e($numRes); ?> </span>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>

                                            <?php if($reserva->qtdReservados() > 0): ?>
                                                <br>
                                                <a href="<?php echo e(route('pagarReserva', $reserva->id)); ?>"
                                                    class="btn btn-sm btn-success mt-2">Pagar</a>
                                            <?php endif; ?>
                                        </td>
                                        <td></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="col-md-5 row-rifa rifa-<?php echo e($reserva->rifa()->id); ?>" style="margin-bottom: 20px;">
                    <div class="card checkout" style="border: none;background: #020f1e;">
                        <div class="card-body" style="background-color: #020f1e;">
                            <h5 class="card-title" style="color: #fff;"><i class="bi bi-trophy"></i> Informações do Sorteio
                            </h5>
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td style="color: #fff;">Sorteio:</td>
                                        <td style="color: #fff;"><?php echo e($reserva->rifa()->name); ?></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
        //aqui vai sempre ser a hora atual
        var startDate = new Date();
        //como exemplo vou definir a data de fim com base na data atual
        var endDate = new Date();
        endDate.setDate(endDate.getDate() + 1);

        //aqui é a diferenca entre as datas, basicamente é com isso que voce calcula o tempo restante
        var dateDiff;
        var days, hours, minutes, seconds;
        var $day = $('#dias');
        var $hour = $('#horas');
        var $minute = $('#minutos');
        var $second = $('#segundos');
        var $debug = $('#debug');
        var timer;

        function showHideReservas(element) {
            var selected = element.value;
            document.querySelectorAll('.row-rifa').forEach((el) => {
                el.classList.add('d-none')
            });

            if(selected == 0){
                document.querySelectorAll('.row-rifa').forEach((el) => {
                    el.classList.remove('d-none')
                });
            }
            else{
                document.querySelectorAll(`.rifa-${selected}`).forEach((el) => {
                    el.classList.remove('d-none')
                });
            }

            // document.querySelectorAll('.row-rifa').forEach((el) => 
            //     console.log(el);
            // );
        }

        function update() {
            dateDiff = endDate - startDate;
            dateDiff = dateDiff / 1000;

            seconds = Math.floor((dateDiff % 60));

            dateDiff = dateDiff / 60;
            minutes = Math.floor((dateDiff % 60));

            dateDiff = dateDiff / 60;
            hours = Math.floor((dateDiff % 24));

            days = Math.floor(dateDiff / 24);

            $day.text(days);
            $hour.text(hours);
            $minute.text(minutes);
            $second.text(seconds);

            startDate.setSeconds(startDate.getSeconds() + 1);
        }
        update();
        timer = setInterval(update, 1000);
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/comprarifa/public_html/resources/views/minhas-reservas.blade.php ENDPATH**/ ?>