<?php $__env->startSection('css_page_level'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page-content'); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-form/jquery.form.min.js')); ?>"></script>
<script type="text/javascript">
    var showedCommentNumber = 0;
    
    $(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: '<?php echo e($votes[0]->title); ?>'
        },
        subtitle: {
            text: '<?php echo e($votes[0]->time_start); ?> <?php echo app('translator')->get('messages.2222'); ?> <?php echo e($votes[0]->time_end); ?>'
        },
        xAxis: {
            categories: [
                '<?php echo app('translator')->get('messages.voted'); ?>',
            ],
            crosshair: true
        },
        yAxis: {
            title: {
                text: '<?php echo app('translator')->get('messages.votiesssssss'); ?>'
            },
            min: 0,
            tickPixelInterval:200
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} </b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: [




            <?php foreach($votes as $vote): ?>

                <?php foreach($vote->options as $voteoptions): ?>
                {
                    name: ' <?php echo e($voteoptions->name); ?> ',
                    <?php if(empty($VotesListCount[$voteoptions->id])): ?>
                        data: [<?php echo e(0); ?>]
                    <?php else: ?>
                        data: [<?php echo e($VotesListCount[$voteoptions->id]); ?>]
                    <?php endif; ?>
                },
                <?php endforeach; ?>

            <?php endforeach; ?>




        ]
    });
        
    $('#form_add_vote_comment').ajaxForm({
        type: "POST",
        dataType: "json",
        beforeSubmit: function () {
            var pass = $('#vote_content').val().length > 0;
            if (!pass) {
                toastr['error']('留言內容不可為空');    
            }
            
            return pass;
        },
        success: function (returnData) {
            window.location.reload();
        },
        error: function(){
            toastr['error']('留言失敗');    
        }
    });
        
    $('#readMore').click(function() {
        showComment();
    });
        
    showComment();
});
    
    function showComment() {
        showedCommentNumber += 10;
        $(".vote-comment").filter(function() {
            return  $(this).attr("vote-no") <= showedCommentNumber;
        }).show();  
        $(".vote-comment").filter(function() {
            return  $(this).attr("vote-no") > showedCommentNumber;
        }).hide();
        
        if ($(".vote-comment").length <= showedCommentNumber) {
            $('#readMore').hide();
        }
    }
</script>
            <div class="wrap-fluid" id="paper-bg">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="box">
                            <div class="box-header">
                                <!-- tools box -->
                                <div class="pull-right box-tools">
                                </div>
                                <h3 class="box-title"><i class="fontello-doc"></i>
                                    <span><?php echo app('translator')->get('messages.nei_vote'); ?></span>
                                </h3>
                            </div>
                            <!-- /.box-header -->
                            <div class="box-body">
                                <!-- /.box-body -->
                                <div class="row">
                                    <form action="/website/StoreVoteListCreate" method="POST" id="form_add_vote_list" class="form-horizontal form-bordered"  enctype="multipart/form-data">
                                    <?php foreach($votes as $vote): ?>
                                    <div class="col-md-6">
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title"><?php echo e($vote->title); ?></h3>
                                            </div>

                                            <div class="panel-body">
                                                <?php foreach($vote->options as $voteoptions): ?>

                                                    <?php if(empty($VotesListCount[$voteoptions->id])): ?>
                                                        0票(0%)
                                                    <?php else: ?>
                                                        <?php echo e($VotesListCount[$voteoptions->id]); ?>票(<?php echo e(number_format($VotesListCount[$voteoptions->id]/$VoteListCount,2)*100); ?>%)
                                                    <?php endif; ?>
                                                    <?php echo e($voteoptions->name); ?>

                                                    <br>
                                                <?php endforeach; ?>
                                            </div>

                                            <div class="panel-footer">
                                            </div>
                                           </div>
                                           <div id="container"  style=" height: 400px"></div>

                                    </div>
                                    <?php endforeach; ?>
                                    </form>
                                    <div class="col-md-6">
                                    <?=$vote->content;?>
                                    </div>

                                </div>
                                
                                <div class="row">
                                    <div class="col-md-12">
                                        <form action="<?php echo e(Route('website::StoreVoteCommentCreate')); ?>" method="POST" id="form_add_vote_comment" class="form-horizontal form-bordered"  enctype="multipart/form-data">
                                            <input type="hidden" name="vote_id" value="<?php echo e($vote_id); ?>" />
                                            <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>" />
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    <h3 class="panel-title">留言板</h3>
                                                </div>

                                                <div class="panel-body">
                                                    <div class="form-group">
                                                        <label class="col-md-2 control-label">留言內容</label>
                                                        <div class="col-md-10">
                                                            <textarea name="content" id="vote_content" class="form-control" placeholder="請輸入留言"></textarea>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="panel-footer" style="text-align: right;"><input type="submit" value="發佈留言" class="btn btn-primary" /></div>
                                           </div>
                                        </form>
                                    </div>
                                </div>
                                
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php $no = 1; ?>
                                        <?php foreach($VoteComments as $comment): ?>
                                            <div class="panel panel-default vote-comment" vote-no="<?php echo e($no++); ?>">
                                                <div class="panel-heading clearfix">
                                                    <h4 class="panel-title">
                                                        <div style="float: left;">
                                                            發表時間: <?php echo e($comment->created_at); ?>

                                                        </div>  
                                                        <div style="float: right;">
                                                            發表人: <?php echo e($comment->name); ?>

                                                        </div> 
                                                    </h4>
                                                </div>

                                                <div class="panel-body"><?php echo e($comment->content); ?></div>

                                                <div class="panel-footer"></div>
                                           </div>
                                        <?php endforeach; ?>
                                        <div class="col-md-12" style="text-align: center;">
                                            <input id="readMore" type="button" value="更多..." class="btn btn-success" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->
                    </div>
                </div>


            </div>
            <!-- #/paper bg -->
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.front', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>