
<?php $__env->startSection('css'); ?>
    <link href="<?php echo e(asset('frontend/user/assets/css/nucleo.css')); ?>" id="app-style" rel="stylesheet" type="text/css">
    <link href="<?php echo e(asset('frontend/user/assets/css/fontawesome-all.css')); ?>" id="app-style" rel="stylesheet" type="text/css">
    <link href="<?php echo e(asset('frontend/user/assets/css/argon.css')); ?>" id="app-style" rel="stylesheet" type="text/css">
    <link href="<?php echo e(asset('frontend/user/assets/css/myapp.css')); ?>" id="app-style" rel="stylesheet" type="text/css">
    
    <link rel="stylesheet" href="<?php echo e(asset('backend/plugins/select2/css/select2.min.css')); ?>">
    <link rel="stylesheet" href="<?php echo e(asset('backend/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css')); ?>">
    <style>
        .container-fluid {
            padding-right: 0px;
            padding-left: 0px;
        }
        
        .ads-rate-area{
            padding: 0.375rem 0.75rem;
            border: 1px solid #ced4da;
            border-radius: 0.25rem;
            display: flex;
            justify-content: space-between;
        }
        .ads-rate-area-active{
            border: 1px solid #31bd21 !important;
        }
        
        .package-area img{
            width: 100%;
            height: 165px;
        }
        
        .cost-area{
            background: #4285f4;
            padding: 6px 8px;
            border-radius: 3px;
            color: #ffffff;
        }
        
        .cost_currency{
            position: relative;
            bottom: 6px;
            font-size: 12px;
            margin-left: 5px;
        }
        
        .countdown {
            text-transform: uppercase;
            font-weight: bold;
        }
        
        .countdown span {
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
            font-size: 3rem;
            margin-left: 0.8rem;
        }
        
        .countdown span:first-of-type {
            margin-left: 0;
        }
        
        .countdown-circles {
            text-transform: uppercase;
            font-weight: bold;
        }
        
        .countdown-circles span {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
        }
        
        .countdown-circles span:first-of-type {
            margin-left: 0;
        }
        
        .bg-gradient-4 {
            background: #007991;
            background: -webkit-linear-gradient(to right, #007991, #78ffd6);
            background: linear-gradient(to right, #007991, #78ffd6);
        }
        
        .rounded {
            border-radius: 1rem !important;
        }
        
        .btn-demo {
            padding: 0.5rem 2rem !important;
            border-radius: 30rem !important;
            background: rgba(255, 255, 255, 0.3);
            color: #fff;
            text-transform: uppercase;
            font-weight: bold !important;
        }
        
        .btn-demo:hover, .btn-demo:focus {
            color: #fff;
            background: rgba(255, 255, 255, 0.5);
        }
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('user-content'); ?>

    <div class="card card-body mt-2 p-0" style="background-color: rgb(248, 249, 254);height: auto !important;">
        <div class="card-header">
            <b><h4><marquee bgcolor="green" style="color:white;padding: 5px;border-radius: 5px;margin-top: 10px" behavior="scroll">Do Something For Your</marquee></h4></b>
            
            <p style="background:#28B463;color: white;padding: 15px;border-radius: 5px;margin-top: 10px">
                <?php echo site_info()->lottery_notice; ?>

            </p>
        </div>
        <div class="row justify-content-center mt-2">
            <?php $__currentLoopData = $datas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-12 data-area">
                    <div class="card">
                        <div class="card-body rounded bg-gradient-4 text-white shadow text-center">
                            <div id="clock-c-<?php echo e($data->id); ?>" class="countdown py-4"></div>
                            <?php
                                $total_time = 1;
                                $to = \Carbon\Carbon::now();
                                $from = \Carbon\Carbon::parse($data->end_time);
                                
                                $years = $to->diffInYears($from);
                                $months = $to->diffInMonths($from);
                                $weeks = $to->diffInWeeks($from);
                                $days = $to->diffInDays($from);
                                $hours = $to->diffInHours($from);
                                $minutes = $to->diffInMinutes($from);
                                $seconds = $to->diffInSeconds($from);
                                
                                if($days > 0){
                                    $total_time += $total_time * $days;
                                }
                                
                                if($hours > 0){
                                    $total_time += $total_time * $hours;
                                }
                                
                                if($minutes > 0){
                                    $total_time += $total_time * $minutes;
                                }
                                
                                if($seconds > 0){
                                    $total_time += $total_time * $seconds;
                                }
                                
                                $total_time += $total_time * 1000;
                            ?>
                            
                            <script>
                                $( document ).ready(function() {
                                    function get15dayFromNow() {
                                        return new Date(new Date().valueOf() + <?php echo e($total_time); ?>);
                                    }
                                
                                    $('#clock-c-<?php echo e($data->id); ?>').countdown(get15dayFromNow(), function(event) {
                                        var $this = $(this).html(event.strftime(''
                                        + '<span class="h1 font-weight-bold l-date">%D</span> <span class="l-date-text">Days</span>'
                                        + '<span class="h1 font-weight-bold l-date">%H</span> <span class="l-date-text">Hour</span>'
                                        + '<span class="h1 font-weight-bold l-date">%M</span> <span class="l-date-text">Minutes</span>'
                                        + '<span class="h1 font-weight-bold l-date">%S</span> <span class="l-date-text">Seconds</span>'));
                                    });
                                });
                            </script>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 text-center">
                            <img style="height: 154px; width: 98%;cursor: pointer;" onclick="buySelect('<?php echo e($data->id); ?>', '<?php echo e($data->price); ?>')" src="<?php echo e(URL::to($data->image)); ?>">
                        </div>
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header text-center">
                                    Your Ticket Balance
                                </div>
                                <div class="card-body">
                                <div class="row">
                                    <div class="col-6 text-center">
                                        This Season <br> <b>0</b> Ticket
                                    </div>
                                    <div class="col-6 text-center">
                                        All Time <br><b>0</b> Ticket
                                    </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header text-center text-blue font-weight-bold">
                                    TOP 10
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table align-items-center table-flush">
                                            <thead class="thead-light">
                                                <tr>
                                                    <th scope="col">Rank</th>
                                                    <th scope="col">User Name</th>
                                                    <th scope="col">Ticket Buy</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header text-center text-green font-weight-bold">
                                    Recent Buy
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table align-items-center table-flush">
                                            <thead class="thead-light">
                                                <tr>
                                                    <th scope="col">User</th>
                                                    <th scope="col">Ticket Buy</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $__currentLoopData = recent_tickets_buyers($data->id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $buyer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if(find_user($buyer->user_id)): ?>
                                                        <tr>
                                                            <td><?php echo e(find_user($buyer->user_id)->code); ?>-<?php echo e(find_user($buyer->user_id)->name); ?></td>
                                                            <td><?php echo e(user_buy_per_lottery_tickets($data->id, $buyer->user_id)); ?></td>
                                                        </tr>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            
            <div class="modal fade" id="modalBuy" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered" role="document">
                    <div class="modal-content">
                        <div class="modal-body">
                            <h3>Are you confirm to Buy Ticket?</h3>
                            <br>
                            <input type="hidden" id="lottery_id" value="">
                            <div class="form-group">
                                <label for="balanceType">Select Balance</label>
                                <select class="form-control" id="balanceType">
                                    <option value="deposit">Deposit Balance</option>
                                    <option value="earning">Earning Balance</option>
                                </select>
                            </div>
                            <p>
                                <b>Price:</b> $<span id="txt_pkg_price">0</span>
                            </p>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="ticketAmount">Ticket Qty</label>
                                        <div class="input-group input-group-merge">
                                            <input class="form-control" placeholder="0" id="ticket_price" type="hidden" readonly="">
                                            <input class="form-control" id="ticketAmount" placeholder="Ticket Amount" type="number" min="1" step="1" onkeyup="changeTitketAmount()" oninput="if (!window.__cfRLUnblockHandlers) return false; this.value = Math.round(this.value);" required="">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="bkashDollarRateConvert">Total</label>
                                        <div class="input-group">
                                            <div class="input-group-prepend">
                                                <span class="input-group-text">$</span>
                                            </div>
                                            <input class="form-control" placeholder="0" id="bkashDollarRateConvert" type="text" readonly="">
                                        </div>
                                    </div>
                                </div>
                            </div>
            
                            <div class="alert alert-dismissible" style="display:none;" role="alert" id="topAlertMainDeposit">
                                <span class="alert-text"><strong><span id="error-text-deposit"></span></strong></span>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-success" id="btnBuyConfirm">Yes, Confirm</button>
                            <button type="button" class="btn btn-default" onclick="closeModal()">No</button>
                        </div>
                    </div>
                </div>
           </div>
        </div>
    </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <!-- Select2 -->
    <script src="<?php echo e(asset('backend/plugins/select2/js/select2.full.min.js')); ?>"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js" integrity="sha512-lteuRD+aUENrZPTXWFRPTBcDDxIGWe5uu0apPEn+3ZKYDwDaEErIK9rvR0QzUGmUQ55KFE2RqGTVoZsKctGMVw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script>
        $(function () {
            $('.select2').select2();
        });
        function filterItem(){
            var value = $('#filter_item').val().toLowerCase();
            $(".data-area").filter(function() {
                $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
            });
        }
        
        function changeTitketAmount(){
            var ticketAmount = parseFloat($('#ticketAmount').val());
            var ticket_price = parseFloat($('#ticket_price').val());
            var total = ticketAmount * ticket_price;
            $('#bkashDollarRateConvert').val(parseFloat(total));
        }
        
        function buySelect(package_id,price){
            $('#topAlertMainDeposit').hide();
            $('#lottery_id').val(package_id);
            $('#txt_pkg_price').text(price);
            $('#ticket_price').val(price);
            $('#modalBuy').modal('toggle');
        }
        
        function closeModal(){
            $('#lottery_id').val('');
            $('#modalBuy').modal('toggle');
        }
        
        $(document).on('click', '#btnBuyConfirm', function () {
            let tho = $(this);
            tho.prop('disabled', true);
            var balanceType = $('#balanceType').val();
            var ticketAmount = $('#ticketAmount').val();
            var lottery_id = $('#lottery_id').val();

            jQuery.ajax({
                url: "<?php echo e(route('user.lottery-buy-confirm')); ?>",
                type: "POST",
                data: {_token: '<?php echo e(csrf_token()); ?>',lottery_id: lottery_id,ticketAmount: ticketAmount,balanceType:balanceType},
                success: function (data) {
                    console.log(data);
                    if (data.error == 1) {
                        responseMessage(0, data.msg);
                    } else {
                        responseMessage(1, data.msg);
                        setTimeout(function(){
                            location.reload();
                        }, 2000);
                    }
                    tho.prop('disabled', false);
                },
                error: function (data) {
                    tho.prop('disabled', false);
                }
            });
        });
        
        function responseMessage(type, msg) {
            const topAlertMainDeposit = $('#topAlertMainDeposit');
            const error_text_deposit = $('#error-text-deposit');
            switch (type) {
                case 1:
                    topAlertMainDeposit.removeClass('alert-danger');
                    topAlertMainDeposit.addClass('alert-success');
                    error_text_deposit.text(msg);
                    topAlertMainDeposit.fadeIn();
                    break;
                case 0:
                    topAlertMainDeposit.removeClass('alert-success');
                    topAlertMainDeposit.addClass('alert-danger');
                    error_text_deposit.text(msg);
                    topAlertMainDeposit.fadeIn();
                break;
            }
        }
    </script>
<?php $__env->stopSection(); ?>

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