<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\listView;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Satpam */

$this->title = 'Data Satpam';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="satpam-index">

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

    <p>
        <?= Html::a('Create Satpam', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
   

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

            //'satpam_id',
            'total_absen',            
            //'deleted',
            // 'deleted_at',
            // 'deleted_by',
            // 'created_at',
            // 'created_by',
            // 'updated_at',
            // 'updated_by',
            // 'pegawai_id',

            ['class' => 'common\components\ToolsColumn',
                'template' => '{view} {update} {delete}',// {edit} {cancel}',
                'header' => 'Aksi',
                'buttons' => [
                    'view' => function ($url, $model){
                        return ToolsColumn::renderCustomButton($url, $model, 'View Detail', 'fa fa-eye');
                    },
                    'update' => function ($url, $model){
                        return ToolsColumn::renderCustomButton($url, $model, 'Update', 'fa fa-gear');

                        // if($model->status_oleh_hrd == "Accepted" || $model->status_oleh_hrd == "Rejected")
                        //     return "";
                        // //return ToolsColumn::renderCustomButton($url, $model, 'Accepts', 'fa fa-check');
                        // else
                        //     return ToolsColumn::renderCustomButton($url, $model, 'Accept', 'fa fa-check');
                    },
                    // 'delete' => function ($url, $model){
                    //     return ToolsColumn::renderCustomButton($url, $model, 'Delete', 'fa fa-trash');
                    //     // if($model->status_oleh_hrd == "Rejected" || $model->status_oleh_hrd == "Accepted")
                        //     return "";
                        // else
                        //     return ToolsColumn::renderCustomButton($url, $model, 'Reject', 'fa fa-close');
                    //},
                    // 'print' => function ($url, $model){
                    //     return ToolsColumn::renderCustomButton($url, $model, 'Print Form IB', 'fa fa-print');
                    // }
                ],
                'urlCreator' => function ($action, $model, $key, $index){
                    if ($action === 'view') {
                        return Url::toRoute(['view', 'id' => $key]);
                    }else if ($action === 'update') {
                        return Url::toRoute(['update', 'id' => $key]);
                    }else if ($action === 'delete') {
                        return Url::toRoute(['delete', 'id' => $key]);
                    }
                    // else if ($action === 'print') {
                    //     return Url::toRoute(['print-by-mahasiswa', 'id' => $key]);
                    // }

                }

            ],
        ],                
    ]); ?>

</div>