Your IP : 216.73.216.79


Current Path : /var/www/html/brspace/backend/modules/contentApplication/views/content-application/
Upload File :
Current File : /var/www/html/brspace/backend/modules/contentApplication/views/content-application/index.php

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use backend\modules\contentApplication\models\ContentApplicationTranslation;

$this->title = Yii::t('app', 'Links');
$this->params['breadcrumbs'][] = $this->title;

/*$this->registerJs('$(\'[data-toggle="tooltip"]\').tooltip();');
if (!empty($searchModel->application_cat)) {
    $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: "sorting?data=" + output,
                    method: "GET",
                    success: function (response) {
                        location.reload();
                    }
                });

            }
        });
    });');
}*/
?>
<div class="wrapper wrapper-content">
    <p>
        <?= Html::a('Add New', ['create'], ['class' => 'btn btn-primary']) ?>
    </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',],
                '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' => [
                            /*'sort' => function ($url, $model) use ($searchModel) {
                                if (!empty($searchModel->application_cat)) {
                                    return Html::a('<i class="fa fa-arrows"></i> Sort', ['#'], ['title' => 'Sort', 'class' => 'label label-warning label-button']);
                                } else {
                                    return '<span data-toggle="tooltip" data-placement="top" title="Please specify category to use sorting function" class="label label-default label-button"><i class="fa fa-arrows"></i> Sort</span>';
                                }
                            },*/
                            'update' => function($url, $model, $key) {
                                return Html::a('<span class="fa fa-pencil"></span> ' . Yii::t('app', 'Edit'), ['update', 'id' => $model->application_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->application_id . '\')">
                                    <i class="fa fa-trash"></i> Delete
                                </span>';
                            },
                        ],
                    ],
                    [
                        'attribute' => 'application_title',
                        'value' => function ($model) {
                            if (($modelText = ContentApplicationTranslation::findOne(['application_translation_parent_id' => $model->application_id, 'application_translation_main' => 1])) !== null) {
                                return $modelText->application_translation_title;
                            }
                        }
                    ],
                    [
                        'attribute' => 'application_cat',
                        'filter' => ArrayHelper::map(
                                (new \yii\db\Query())
                                        ->from('ref')
                                        ->where(['=', 'cat', 'APP_CAT'])
                                        ->orderBy(['descr_en' => SORT_ASC])
                                        ->all(), 'code', 'descr_en'),
                        'value' => function ($model) {
                            $ref = (new \yii\db\Query())
                                    ->from('ref')
                                    ->where(['=', 'cat', 'APP_CAT'])
                                    ->andwhere(['=', 'code', $model->application_cat])
                                    ->one();
                            if (!empty($ref))
                                return $ref['descr_en'];
                        }
                    ],
                    [
                        'attribute' => 'application_status',
                        'filter' => ArrayHelper::map(
                                (new \yii\db\Query())->select(['code', 'descr'])
                                        ->from('ref')
                                        ->where(['=', 'cat', 'CONTENT_STATUS'])
                                        ->orderBy(['sort' => SORT_ASC])
                                        ->all(), 'code', 'descr'),
                        'value' => function ($model) {
                            $ref = (new \yii\db\Query())->select(['descr'])
                                    ->from('ref')
                                    ->where(['=', 'cat', 'CONTENT_STATUS'])
                                    ->andwhere(['=', 'code', $model->application_status])
                                    ->one();
                            if (!empty($ref))
                                return $ref['descr'];
                        }
                    ],
                    'application_url',
                    //'application_sort',
                    /*[
                        'header' => 'Language',
                        'format' => 'raw',
                        'headerOptions' => ['style' => 'width:10%'],
                        'value' => function ($model) {
                            $output = '';
                            $arr = ArrayHelper::map(
                                            (new \yii\db\Query())->select(['*'])
                                                    ->from('content_application_translation')
                                                    ->orderBy(['application_translation_language' => SORT_ASC])
                                                    ->groupby(['application_translation_language'])
                                                    ->all(), 'application_translation_language', 'application_translation_language');
                            if (!empty($arr)) {
                                foreach ($arr as $code) {
                                    $ref = (new \yii\db\Query())->select(['descr'])
                                            ->from('ref')
                                            ->where(['=', 'cat', 'CONTENT_LANGUAGE'])
                                            ->andwhere(['=', 'code', $code])
                                            ->one();
                                    if (!empty($ref)) {
                                        $label_class = 'label-dark';
                                        if (($modeltranslation = ContentApplicationTranslation::findOne(['application_translation_parent_id' => $model->application_id, 'application_translation_language' => $code])) !== null) {
                                            $label_class = 'label-primary';
                                        }
                                        $output .= '<span class="label label-button ' . $label_class . '">' . $ref['descr'] . '</span>';
                                    }
                                }
                            }
                            return $output . Html::a('<i class="fa fa-plus" aria-hidden="true"></i> Translation', ['addtranslation', 'id' => $model->application_id], ['class' => 'label label-warning label-button']);
                        }
                    ],*/
                ],
            ]);
            ?>
        </div>
    </div>
    <div class="version">Version 1.0 (Last update on 4th 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/contentApplication/content-application/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>