<div class="jumbotron">
  <div class="container">
    <div class="row">
        <div class="col-sm-8 col-xs-8">
        <p>Period <span><?php echo e($lastResult['periodid'] + 1); ?></span></p>
        </div>
        <div class="col-sm-3 col-xs-4">
        <div class="couterDiv" >
            <div class="couterInner">
                <p>Count Down</p>
                <ul id="countdown">
                    <!--<li> <span class="days">00</span>
                    <p class="timeRefDays">days</p>
                    </li>-->
                    <li> <span class="hours">00</span>
                    <!--<p class="timeRefHours">hours</p>-->
                    </li>
                    <li> <span class="minutes">00</span>
                    <!--<p class="timeRefMinutes">minutes</p>-->
                    </li>
                    <!--<li> <span class="seconds">00</span>
                    <p class="timeRefSeconds">seconds</p>
                    </li>-->
                    </ul>
            </div>
        </div>
</div>
    </div>
    <div class="row">
        <div class="col-sm-4 col-xs-4 result">
            <p>PrePeriod <span><?php echo e($lastResult['periodid']); ?></span></p>
        </div>
        <div class="col-sm-4 col-xs-4 price-section">
        <?php
            $textColor = 'Red';
        ?>
        <?php if(trim($lastResult['resulttype']) == 'random'): ?>
            <?php if(strtolower($lastResult['randomcolor']) == 'green'): ?>
                <?php  $textColor = 'Green'; ?>
            <?php elseif(strtolower($lastResult['randomcolor']) == 'green++violet' || strtolower($lastResult['randomcolor']) == 'red+violet' || strtolower($lastResult['randomcolor']) == 'green & violet'): ?>
                <?php  $textColor = 'VioletGreen'; ?>
            <?php elseif(strtolower($lastResult['randomcolor']) == 'red++violet'  || strtolower($lastResult['randomcolor']) == 'red+violet'|| strtolower($lastResult['randomcolor']) == 'red & violet'): ?>
                <?php  $textColor = 'VioletRed'; ?>
            <?php endif; ?>
        <?php endif; ?>
        <?php if(trim($lastResult['resulttype']) == 'real'): ?>
            <?php if(strtolower($lastResult['color']) == 'green'): ?>
                <?php  $textColor = 'Green'; ?>
            <?php elseif(strtolower($lastResult['color']) == 'green++violet' || strtolower($lastResult['color']) == 'red+violet' || strtolower($lastResult['color']) == 'green & violet'): ?>
                <?php  $textColor = 'VioletGreen'; ?>
            <?php elseif(strtolower($lastResult['color']) == 'red++violet' || strtolower($lastResult['color']) == 'red+violet'  || strtolower($lastResult['color']) == 'red & violet'): ?>
                <?php  $textColor = 'VioletRed'; ?>
            <?php endif; ?>
        <?php endif; ?>
            <p>Result <span class="item<?php echo e($textColor); ?>" style="font-size:16px"><?php echo e($lastResult['resulttype'] == 'random' ? $lastResult['randomresult'] : $lastResult['result']); ?></span></p>
        </div>
        <div class="col-sm-4 col-xs-4">
            <p>OpenPrice <span class="text-<?php echo e($textColor); ?>"><?php echo e($lastResult['randomprice']); ?></span></p>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-4 col-xs-4 result text-Red">
            <p>Red <span><?php echo e($totalCounts['red']); ?></span></p>
        </div>
        <div class="col-sm-4 col-xs-4 price-section text-Green">
            <p>Green <span><?php echo e($totalCounts['green']); ?></span></p>
        </div>
        <div class="col-sm-4 col-xs-4 text-Violet">
            <p>Violet <span><?php echo e($totalCounts['violet']); ?></span></p>
        </div>
    </div>
  </div>
</div>

<div class="container-fluid bg-3 text-center">
    <div class="">
        <div class="row">
             <div class="col-sm-12 text-right" style="margin-bottom:20px;">
             <div class="btn-group" role="group" aria-label="Basic example">
                <button type="button" class="btn btn-<?php echo e($ShowPeriod == 2?'success':'primary'); ?> changeBts button2" onclick="changeLayout(2)">ShowPeriod</button>
                <button type="button" class="btn btn-<?php echo e($ShowPeriod == 1?'success':'primary'); ?> changeBts button1" onclick="changeLayout(1)">ShowOpenNum</button>
            </div>
        </div>
        </div>
        <div class="row">
            <div class="heading">
                <div class="resultHead">
                    <?php
                    if($mxColumn > 0){
                        for($i = 1; $i <= $mxColumn; $i++){
                    ?>
                        <div class="head-item"><?php echo e($i); ?></div>
                    <?php
                        }
                    }
                    ?>
                </div>
            </div>
            <div class="results">
            <div class="resultBox">
            <?php
                if(count($resultData) > 0){
                ?>
                    <?php $__currentLoopData = $resultData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $result): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="resultRow">
                    <?php
                    if($mxColumn > 0){
                        for($i = 0; $i < $mxColumn; $i++){
                        ?>
                            <div class="rowItem">
                            <?php if(isset($result[$i])): ?>
                            <?php
                                $textColor = 'Red';
                            ?>
                            <?php if(trim($result[$i]['resulttype']) == 'random'): ?>
                                <?php if(strtolower($result[$i]['randomcolor']) == 'green'): ?>
                                    <?php  $textColor = 'Green'; ?>
                                <?php elseif(strtolower($result[$i]['randomcolor']) == 'green++violet' ||  strtolower($result[$i]['randomcolor']) == 'green+violet' || strtolower($result[$i]['randomcolor']) == 'green & violet'): ?>
                                    <?php  $textColor = 'VioletGreen'; ?>
                                <?php elseif(strtolower($result[$i]['randomcolor']) == 'red++violet' ||  strtolower($result[$i]['randomcolor']) == 'red+violet'  || strtolower($result[$i]['randomcolor']) == 'red & violet'): ?>
                                    <?php  $textColor = 'VioletRed'; ?>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if(trim($result[$i]['resulttype']) == 'real'): ?>
                                <?php if(strtolower($result[$i]['color']) == 'green'): ?>
                                    <?php  $textColor = 'Green'; ?>
                                <?php elseif(strtolower($result[$i]['color']) == 'green++violet' || strtolower($result[$i]['color']) == 'green+violet' || strtolower($result[$i]['color']) == 'green & violet'): ?>
                                    <?php  $textColor = 'VioletGreen'; ?>
                                <?php elseif(strtolower($result[$i]['color']) == 'red++violet' || strtolower($result[$i]['color']) == 'red+violet' || strtolower($result[$i]['color']) == 'red & violet'): ?>
                                    <?php  $textColor = 'VioletRed'; ?>
                                <?php endif; ?>
                            <?php endif; ?>

                                <span class="item<?php echo e($textColor); ?> showData showData1"><?php echo e($result[$i]['resulttype'] == 'random' ? $result[$i]['randomresult']:$result[$i]['result']); ?></span>
                                <span class="item<?php echo e($textColor); ?> showData showData2"><?php echo e(substr($result[$i]['periodid'], -3)); ?></span>
                            <?php else: ?>
                                &nbsp;
                            <?php endif; ?>
                            </div>
                        <?php
                        }
                    }
                    ?>
                    </div>


                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php
                }
                ?>
            </div>
            </div>
        </div>
    </div>
</div><br><br>

<div class="container-fluid bg-3 text-center">
    <div class="">
        <div class="row" >
                <div class="col-sm-12 text-left" style="margin-bottom:20px;">
                <div class="btn-group" role="group" aria-label="Basic example">
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 3?'success':'primary'); ?> changeRDBts rdButton3" onclick="changeRD(3,2)">Rd.3</button>
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 4?'success':'primary'); ?> changeRDBts rdButton4" onclick="changeRD(4,2)">Rd.4</button>
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 5?'success':'primary'); ?> changeRDBts rdButton5" onclick="changeRD(5,2)">Rd.5</button>
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 6?'success':'primary'); ?> changeRDBts rdButton6" onclick="changeRD(6,2)">Rd.6</button>
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 7?'success':'primary'); ?> changeRDBts rdButton7" onclick="changeRD(7,2)">Rd.7</button>
                    <button type="button" class="btn btn-<?php echo e($ShowRD == 8?'success':'primary'); ?> changeRDBts rdButton8" onclick="changeRD(8,2)">Rd.8</button>
                </div>
                </div>
        </div>
        <div class="row" id="bottomTable">
            <div class="heading">
                <div class="resultHead">
                    <?php
                        for($i = 1; $i <= $ShowRD; $i++){
                    ?>
                        <div class="head-item"><?php echo e($i); ?></div>
                    <?php
                    }
                    ?>
                </div>
            </div>
            <div class="results">
            <div class="resultBox">
            <?php
                if(count($results) > 0){
                ?>
                <?php
                    $i = 1;
                ?>
                <div class="resultRow">
                    <?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $result): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="rowItem">
                            <?php if(isset($result)): ?>
                            <?php
                                $textColor = 'Red';
                            ?>
                            <?php if(trim($result['resulttype']) == 'random'): ?>
                                <?php if($result['randomcolor'] == 'green'): ?>
                                    <?php  $textColor = 'Green'; ?>
                                <?php elseif(strtolower($result['randomcolor']) == 'green++violet' || strtolower($result['randomcolor']) == 'green+violet' || strtolower($result['randomcolor']) == 'green & violet'): ?>
                                    <?php  $textColor = 'VioletGreen'; ?>
                                <?php elseif(strtolower($result['randomcolor']) == 'red++violet' || strtolower($result['randomcolor']) == 'red+violet' || strtolower($result['randomcolor']) == 'red & violet'): ?>

                                    <?php  $textColor = 'VioletRed'; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                            <?php if(trim($result['resulttype']) == 'real'): ?>
                                <?php if($result['color'] == 'green'): ?>
                                    <?php  $textColor = 'Green'; ?>
                                <?php elseif($result['color'] == 'green++violet'): ?>
                                    <?php  $textColor = 'VioletGreen'; ?>
                                <?php elseif($result['color'] == 'red++violet'): ?>
                                    <?php  $textColor = 'VioletRed'; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                                <span class="item<?php echo e($textColor); ?> showData showData1"><?php echo e(trim($result['resulttype']) == 'random' ? $result['randomresult'] : $result['result']); ?></span>
                                <span class="item<?php echo e($textColor); ?> showData showData2"><?php echo e(substr($result['periodid'], -3)); ?></span>
                            <?php else: ?>
                                &nbsp;
                            <?php endif; ?>
                            </div>

                            <?php if($i % $ShowRD == 0): ?>
                            </div>
                            <div class="resultRow">
                            <?php endif; ?>
                            <?php
                                $i++;
                            ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>

                <?php
                }
                ?>
            </div>
            </div>
        </div>
    </div>
</div><br><br>

<div class="container-fluid bg-3">
    <div class="">
        <div class="row">
            <div class="col-sm-12">
                <?php
                    $totalRec = count($results);
                    $redPercnt = $greenPercnt = $violetPercnt = 0;
                    if($totalCounts['red'] > 0){ $redPercnt = number_format(floatval($totalCounts['red'] / $totalRec)*100,2); }
                    if($totalCounts['green'] > 0){ $greenPercnt = number_format(floatval($totalCounts['green'] / $totalRec)*100,2); }
                    if($totalCounts['violet'] > 0){ $violetPercnt = number_format(floatval($totalCounts['violet'] / $totalRec)*100,2); }
                ?>
                <div class="progress">
                    <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuenow="<?php echo e($redPercnt); ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo e($redPercnt); ?>%">
                        <span class="sr-only"><?php echo e($totalCounts['red']); ?> : red</span>
                    </div>
                </div>

                <div class="progress">
                    <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="<?php echo e($greenPercnt); ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo e($greenPercnt); ?>%">
                        <span class="sr-only"><?php echo e($totalCounts['green']); ?> : Green</span>
                    </div>
                </div>

                <div class="progress">
                    <div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuenow="<?php echo e($violetPercnt); ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo e($violetPercnt); ?>%">
                        <span class="sr-only"><?php echo e($totalCounts['violet']); ?> : violet</span>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div><br><br>
<input type="hidden" name="counter" id="counter" class="form-control" >
<input type="hidden" id="changeLayoutRow" value="<?php echo e($ShowPeriod); ?>">
<input type="hidden" id="ShowRDRow" value="<?php echo e($ShowRD); ?>">
<script>
    <?php if($ShowPeriod == 2): ?>
        $(document).ready(function(){
            var changeLayoutRow = $('#changeLayoutRow').val();
            changeLayout(changeLayoutRow);
        });
    <?php endif; ?>
    <?php if($ShowRD == 3): ?>
        $(document).ready(function(){
            var ShowRDRow = $('#ShowRDRow').val();
            changeRD(ShowRDRow, 1);
        });
    <?php endif; ?>

    function changeLayout(rowId){
        $('.changeBts').removeClass('btn-success').addClass('btn-primary');
        $('.button'+rowId).addClass('btn-success');
        $('.showData').hide();
        $('.showData'+rowId).show();
        $('#changeLayoutRow').val(rowId);
        $.ajax({
            type: 'POST',
            url: '<?php echo e(url("/set-show-period")); ?> ',
            data: {"_token": "<?php echo e(csrf_token()); ?>", rowId:rowId},
            success: function(msg){
            }
        });

    }
     function changeRD(columNo, time){
        $('.changeRDBts').removeClass('btn-success').addClass('btn-primary');
        $('.rdButton'+columNo).addClass('btn-success');
        $.ajax({
            type: 'POST',
            url: '<?php echo e(url("/get-column-records")); ?> ',
            data: {"_token": "<?php echo e(csrf_token()); ?>", columNo:columNo},
            success: function(msg){
                $('#bottomTable').html(msg);
                var changeLayoutRow = $('#changeLayoutRow').val();
                changeLayout(changeLayoutRow);
                if(time == 1){ $('.resultBox').animate({scrollLeft: 1000000000}, 500); }
            }
        });
    }

    //countdown
 	/*var timer2 = "03:00";
	var interval = setInterval(function() {

        var timer = timer2.split(':');
        //by parsing integer, I avoid all extra string processing
        var minutes = parseInt(timer[0], 10);
        var seconds = parseInt(timer[1], 10);
        if(minutes == 0 && seconds == 0){return false;}
        --seconds;
        minutes = (seconds < 0) ? --minutes : minutes;
        if (minutes < 0) clearInterval(interval);
            seconds = (seconds < 0) ? 59 : seconds;
            seconds = (seconds < 10) ? '0' + seconds : seconds;
            //minutes = (minutes < 10) ?  minutes : minutes;
            $('.hours').html(minutes);
            $('.minutes').html(seconds);
            timer2 = minutes + ':' + seconds;
            if(timer2 == '0:02'){
               location.reload();
               return false;
            }

	}, 1000);*/

    $(document).ready(function () {

   var x = setInterval(function() {
            start_count_down();
        }, 1e3);
   });

    function start_count_down() {
        $(".showload").hide();
        $(".none").show();
        var countDownDate = Date.parse(new Date) / 1e3;
        var now = new Date().getTime();
        var distance = 180 - countDownDate % 180;
        //alert(distance);
        var i = distance / 60,
        n = distance % 60,
        o = n / 10,
        s = n % 10;
        var minutes = Math.floor(i);
        var seconds = ('0'+Math.floor(n)).slice(-2);
        document.getElementById("countdown").innerHTML = "<li> <span class='hours'>0"+Math.floor(minutes)+"</span></li><li> <span class='minutes'>"+seconds+"</span></li>";
        document.getElementById("counter").value = distance;
        if(minutes <= 0 && seconds <= 1){
            setTimeout(function(){location.reload();},10000);
               return false;
            }

}


</script>
<style>
.progress-bar-warning {
    background-color: #e839f1;
}
.sr-only {
    overflow: initial;
    clip: auto;
    width: auto;
}
</style>
<?php /**PATH /home/onogrow/webapps/onogrow/onoindex/index/resources/views/get_results.blade.php ENDPATH**/ ?>