Your IP : 216.73.216.79


Current Path : /var/www/html/mnrb/backend/modules/support/views/support-tutorial/
Upload File :
Current File : /var/www/html/mnrb/backend/modules/support/views/support-tutorial/index.php

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

$this->title = 'Tutorial';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
    <p>
        <?= Html::a('Add New', ['create'], ['class' => 'btn btn-primary']) ?>
    </p>
    <div class="ibox animated">
        <div class="mail-box b-r-md">
            <?=
            GridView::widget([
                'dataProvider' => $dataProvider,
                'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table m-b-none table-custom'],
                'layout' => "<div class='gridview-top-wrapper'><div class='row'><div class='col-sm-6'>{summary}</div><div class='col-sm-6'>{pager}</div></div></div>\n{items}\n{pager}",
                'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'header' => 'Action',
                        'template' => '{update}{delete}',
                        'headerOptions' => ['style' => 'text-align:center;width:1%;'],
                        'contentOptions' => ['style' => 'text-align:center;'],
                        'buttons' => [
                            'update' => function($url, $model, $key) {
                                return Html::a('<span class="fa fa-pencil"></span> ' . Yii::t('app', 'Edit'), ['update', 'id' => $model->support_tutorial_id], ['title' => Yii::t('app', 'Edit Data'), 'class' => 'label label-info label-button']);
                            },
                            'delete' => function ($url, $model) {
                                return '<span class="label label-danger label-button" onclick="deletedata(' . $model->support_tutorial_id . ')">
                                    <i class="fa fa-trash"></i> Delete
                                </span>';
                            },
                        ],
                    ],
                    'support_tutorial_title',
                    [
                        'attribute' => 'support_tutorial_description',
                        'format' => 'raw'
                    ],
                    [
                        'attribute' => 'support_tutorial_role',
                        'filter' => ArrayHelper::map(
                                (new \yii\db\Query())
                                        ->from('auth_item')
                                        ->where(['=', 'type', 1])
                                        ->orderBy(['name' => SORT_ASC])
                                        ->all(), 'name', 'name'),
                        'format' => 'raw',
                        'value' => function ($model) {
                            $support_tutorial_role = json_decode($model->support_tutorial_role);
                            return implode('<br>', $support_tutorial_role);
                        }
                    ],
                    [
                        'attribute' => 'support_tutorial_embeded_link',
                        'filter' => false,
                        'format' => 'raw',
                        'headerOptions' => ['style' => 'text-align:center;width:10%;'],
                        'contentOptions' => ['style' => 'text-align:center;'],
                        'value' => function ($model) {
                            return Html::a('<span class="fa fa-youtube-play"></span> ' . Yii::t('app', 'View Video'),
                                            ['../../../' . $model->support_tutorial_embeded_link], ['title' => Yii::t('app', 'View Video'),
                                        'class' => 'label label-danger label-button', 'target' => '_blank', 'style' => 'width:100%;']);
                        }
                    ],
                ],
            ]);
            ?>
        </div>
    </div>
    <div class="version">Version 1.0 (Last update on 3rd May 2023)</div>
</div>
<script>
    function deletedata(id) {
        Swal.fire({
            title: 'Are you sure to delete this data?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: "/admin/support/support-tutorial/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        if (response === 'success') {
                            swal.fire({
                                title: 'Deleted',
                                icon: 'success',
                                text: 'Data have been deleted',
                            }).then(function (result) {
                                location.reload();
                            });
                        }
                    },
                });
            }
        });
    }
</script>