<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\bootstrap\Modal;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\MVotingSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'HASIL VOTING';
$this->params['breadcrumbs'][] = $this->title;
?>

<?php
        
    Modal::begin([
        'header' => '<center><h4>DATA VOTING</h4></center>',
        'id' => 'modal-data',
        'size' => 'modal-lg',
        'options' => [
              'tabindex' => false, 
          ],
    ]);

    echo '<div id="content-modal-data"></div>';
    Modal::end();
?>

<div class="mvoting-index">

    <center><h3><b class="text-danger">HASIL VOTING</b></h3></center>


    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'nama_voting',
            //'periode_awal',
            //'periode_tutup',
            [
                'attribute' => 'status_aktif',
                'format' =>'raw',
                'value' => function ($model){
                    if ($model->status_aktif==1) {
                        return '<b><span class="label label-primary">AKTIF</span></b>';
                    }else{
                        return '<b><span class="label label-danger">TIDAK AKTIF</span></b>';
                    }
                }
            ],


            [
                'header' => 'HASIL VOTING',
                
                'format' =>'raw',
                'value' => function ($model){
                    if ($model->id_voting!=NULL) {
                        return Html::a('<span class="glyphicon glyphicon-stats"></span> LIHAT HASIL VOTING',Url::to(['hasil-voting/hasil-voting','id_voting'=>$model->id_voting]),['data-pjax' => 0, 'class' => 'btn btn-default btn-sm',
                                        'title' => 'LIHAT HASIL VOTING',]);
                    }else{
                        return "-";
                    }
                }

                
            ],


        ],
    ]); ?>


</div>

<?php
 
$script = <<< JS
    $(function () {
        $('#modalButton').click(function () {
            $('#modal-data').modal('show')
                .find('#content-modal-data')
                .load($(this).attr('value'));
        });
        
    });
    
    
    
JS;
$this->registerJs($script)
?>
