<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\bootstrap\Modal;

?>

<div class="pending-training-requests-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            [
                'attribute' => 'serial_number',
                'headerOptions' => ['style' => 'width: 10%;']
            ],
            [
                'attribute' => 'full_name',
                'headerOptions' => ['style' => 'width: 20%;']
            ],
            [
                'attribute' => 'mother_name',
                'headerOptions' => ['style' => 'width: 20%;']
            ],
            [
                'attribute' => 'create_date',
                'headerOptions' => ['style' => 'width: 20%;']
            ],
            [
                'attribute' => 'training_request_status',
                'headerOptions' => ['style' => 'width: 20%;'],
                'value' => function($model){
                    return Yii::t('app', $model->training_request_status);
                }
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'headerOptions' => ['style' => 'width: 10%;'],
                'template' => '{view} {interview} {reject}',
                'buttons' => [
                    'view' => function($url, $model){
                        return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', 
                            ['/training-requests/view', 'id' => $model->id],
                            ['title' => Yii::t('app', 'View')]);
                    },
                    'interview' => function($url, $model){
                        return Html::a('<span class="glyphicon glyphicon-user"></span>', 
                            ['/interviews/create', 'training_request_id' => $model->id],
                            ['title' => Yii::t('app', 'Make Interview')]);
                    },
                    'reject' => function($url, $model){
                        if($model->training_request_status == 'Pending'){
                            return Html::a('<span class="glyphicon glyphicon-remove"></span>', 
                                ['#'],
                                [
                                    'value' => Url::to(['/training-requests/reject-training', 'id' => $model->id, 'url' => 'Dashboard']),
                                    'title' => Yii::t('app', 'Reject'),
                                    'class' => 'reject-training-request-btn'
                                ]);
                        }
                    }
                ]
            ],
        ],
    ]); ?>
</div>

<?php 
    Modal::begin([
        'header' => '<h3>' . \Yii::t('app', 'Reject Training Request') . '</h3>',
        'id' => 'reject-training-request-modal',
        'size' => 'modal-md'
    ]);

    echo '<div id="reject-training-request-modal-content"></div>';

    Modal::end();
?>