Your IP : 216.73.216.79


Current Path : /var/www/html/learn/backend/modules/learning/views/learning-chapter/
Upload File :
Current File : /var/www/html/learn/backend/modules/learning/views/learning-chapter/index.php

<?php

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

$this->title = Yii::t('app', 'Manage Chapter');
$this->params['breadcrumbs'][] = 'Manage Interactive Learning';
$this->params['breadcrumbs'][] = $this->title;
$this->registerCssFile('@web/plugins/jquery-ui.css');
$this->registerJsFile('@web/plugins/jquery-ui.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
$this->registerJs('$(document).ready(function() {
    var fixHelper = function fixWidthHelper(e, ui){
        ui.children().each(function() {
            $(this).width($(this).width());
        });
        return ui;
    }
    
        $(".table-custom tbody").sortable({
            helper: fixHelper,
            update: function (event, ui) {
                var output = "";
                $(".table-custom tbody tr").each(function (i) {
                    var data = $(this).attr("data-key");
                    output += data + ",";
                });

                $.ajax({
                    url: "sortingchapter?data=" + output,
                    method: "GET",
                    success: function (response) {
                        location.reload();
                    }
                });

            }
        });
    });');
?>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Choose Chapter Type</h4>
            </div>
            <div class="modal-body">
                <a class='btn btn-info btn-block' href='createtext?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>Text</a>
                <a class='btn btn-info btn-block' href='createimage?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>Images</a>
                <a class='btn btn-info btn-block' href='createvideo?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>Video</a>
                <a class='btn btn-info btn-block' href='createpowerpoint?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>Powerpoint</a>
                <a class='btn btn-info btn-block' href='createpdf?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>PDF</a>
                <a class='btn btn-info btn-block' href='createquiz?main_id=<?= Yii::$app->getRequest()->getQueryParam('main_id') ?>'>Quiz</a>
            </div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <p>
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
            Create Chapter
        </button>
    </p>
    <div class="ibox animated fadeInRightx">
        <div class="mail-box b-r-md">
            <?=
            GridView::widget([
                'dataProvider' => $dataProvider,
                'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table table-hover table-mail table-custom',],
                'summary' => '',
                'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],
                    'chapter_title',
                    [
                        'attribute' => 'chapter_type',
                        'filter' => ArrayHelper::map(
                                (new \yii\db\Query())->select(['code', 'descr_en'])
                                        ->from('ref')
                                        ->where(['=', 'cat', 'CHAPTER_TYPE'])
                                        ->orderBy(['descr_en' => SORT_ASC])
                                        ->all(), 'code', 'descr_en'),
                        'value' => function ($model) {
                            $ref = (new \yii\db\Query())->select(['descr_en'])
                                    ->from('ref')
                                    ->where(['=', 'cat', 'CHAPTER_TYPE'])
                                    ->andwhere(['=', 'code', $model->chapter_type])
                                    ->one();
                            if (!empty($ref))
                                return $ref['descr_en'];
                        }
                    ],
                    [
                        'attribute' => 'chapter_status',
                        'filter' => ArrayHelper::map(
                                (new \yii\db\Query())->select(['code', 'descr_en'])
                                        ->from('ref')
                                        ->where(['=', 'cat', 'LEARNING_STATUS'])
                                        ->orderBy(['descr_en' => SORT_ASC])
                                        ->all(), 'code', 'descr_en'),
                        'value' => function ($model) {
                            $ref = (new \yii\db\Query())->select(['descr_en'])
                                    ->from('ref')
                                    ->where(['=', 'cat', 'LEARNING_STATUS'])
                                    ->andwhere(['=', 'code', $model->chapter_status])
                                    ->one();
                            if (!empty($ref))
                                return $ref['descr_en'];
                        }
                    ],
                    'chapter_time',
                    'chapter_sort',
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'header' => 'Action',
                        'template' => '{view} {update} {sort}',
                        'headerOptions' => ['style' => 'text-align:center;width:10%'],
                        'contentOptions' => ['style' => 'text-align:center;'],
                        'buttons' => [
                            'sort' => function ($url, $model) {
                                return Html::a('<i class="fa fa-arrows"></i>', ['#'], ['title' => 'Sort', 'class' => 'action_link']);
                            },
                            'update' => function ($url, $model) {
                                $page_id = '';
                                if ($model->chapter_type == 'teks')
                                    $page_id = 'updatetext';
                                if ($model->chapter_type == 'imej')
                                    $page_id = 'updateimage';
                                if ($model->chapter_type == 'video')
                                    $page_id = 'updatevideo';
                                if ($model->chapter_type == 'powerpoint')
                                    $page_id = 'updatepowerpoint';
                                if ($model->chapter_type == 'pdf')
                                    $page_id = 'updatepdf';
                                if ($model->chapter_type == 'kuiz')
                                    $page_id = 'updatequiz';

                                return Html::a('<i class="glyphicon glyphicon-pencil"></i>', [$page_id, 'chapter_id' => $model->chapter_id], ['title' => 'Update']);
                            },
                        ],
                    ],
                ],
            ]);
            ?>
        </div>
    </div>
</div>