<?php

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

$this->title = 'REKAPITULASI PENGGUNA 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">REKAPITULASI PENGGUNA 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',
        


            [
                'header' => 'REKAPITULASI PENGGUNA',
                
                'format' =>'raw',
                'value' => function ($model){
                    if ($model->id_voting!=NULL) {
                        return Html::a('<span class="glyphicon glyphicon-user"></span> LIHAT REKAPITULASI PENGGUNA',Url::to(['hasil-voting/rekapitulasi-pengguna-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)
?>
