Your IP : 216.73.216.79


Current Path : /var/www/html/crm/views/serverowner/
Upload File :
Current File : /var/www/html/crm/views/serverowner/index.php

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use app\models\Menu;
use app\models\ParamList;
use app\models\User;

$Menu = new Menu();
$this->title = $Menu->getmenutitle($menu_id);
?>
<div class="kt-subheader  kt-grid__item" id="kt_subheader">
    <div class="kt-container  kt-container--fluid ">
        <div class="kt-subheader__main">
            <h3 class="kt-subheader__title"><?= $this->title ?></h3>
            <div class="kt-subheader__breadcrumbs">
                <?= $Menu->getbreadcrumbs($menu_id, ''); ?>
            </div>
        </div>
    </div>
</div>
<div class="user-index">
    <div class="kt-container kt-grid__item kt-grid__item--fluid">
        <div class="kt-portlet kt-portlet--mobile">
            <div class="kt-portlet__head"><?php echo $this->render('_search', ['model' => $searchModel]); ?></div>
            <div class="kt-portlet__body p-0">
                <?=
                GridView::widget([
                    'dataProvider' => $dataProvider,
                    'tableOptions' => ['class' => 'table mb-0 table-borderless table-striped table-hover table-custom'],
                    'pager' => [
                        'firstPageLabel' => '<i class="fa fa-angle-double-left kt-font-brand"></i>',
                        'lastPageLabel' => '<i class="fa fa-angle-double-right kt-font-brand"></i>',
                        'prevPageLabel' => '<i class="fa fa-angle-left kt-font-brand"></i>',
                        'nextPageLabel' => '<i class="fa fa-angle-right kt-font-brand"></i>',
                        'maxButtonCount' => 3,
                        'options' => ['tag' => 'ul', 'class' => 'kt-pagination--brand kt-pagination__links p-3',],
                        'activePageCssClass' => 'kt-pagination__link--active',
                        'prevPageCssClass' => 'kt-pagination__link--prev',
                        'nextPageCssClass' => 'kt-pagination__link--next',
                        'firstPageCssClass' => 'kt-pagination__link--first',
                        'lastPageCssClass' => 'kt-pagination__link--last',
                    ],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                            'headerOptions' => ['class' => 'text-center', 'width' => '1%'],
                            'contentOptions' => ['class' => 'text-center'],
                        ],
                        [
                            'attribute' => 'project',
                            'headerOptions' => ['class' => 'head-sort'],
                        ],
                        [
                            'attribute' => 'updated_dt',
                            'contentOptions' => ['class' => 'text-nowrap'],
                            'format' => 'raw',
                            'value' => function ($model) {
                                return date("d M Y", strtotime($model->updated_dt));
                            },
                        ],
                        [
                            'attribute' => 'updated_by',
                            'headerOptions' => ['class' => 'text-nowrap'],
                            'value' => function ($model) {
                                $User = new User();
                                return $User->getusernickname($model->updated_by);
                            },
                        ],
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'header' => 'Action',
                            'headerOptions' => ['class' => 'text-center', 'width' => '10%'],
                            'contentOptions' => ['class' => 'text-center'],
                            'template' => '{info}&nbsp;&nbsp;&nbsp;{update}&nbsp;&nbsp;&nbsp;{delete}',
                            'buttons' => [
                                'info' => function ($url, $model) {
                                    $url = Url::to(['serverowner/view', 'uuid' => $model->uuid]);
                                    return Html::a('<span class="kt-font-brand icon-custom"><i class="fas fa-info-circle fa-lg"></i></span>', $url, ['title' => 'View Details',]);
                                },
                                'update' => function ($url, $model) {
                                    $url = Url::to(['serverowner/update', 'uuid' => $model->uuid]);
                                    return Html::a('<span class="kt-font-success icon-custom"><i class="far fa-edit fa-lg"></i></span>', $url, ['title' => 'Update',]);
                                }, 'delete' => function ($url, $model) {
                                    return '<span class="kt-font-danger icon-custom" title="Delete"><i class="far fa-trash-alt fa-lg" style="cursor:pointer;" onclick="deletedata(' . $model->id . ')"></i></span>';
                                },],
                        ],
                    ],
                ]);
                ?>
            </div>
        </div>
    </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: "index.php?r=serverowner/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        if (response === 'success') {
                            swal.fire({
                                position: 'center-center',
                                type: 'success',
                                title: 'Your data has been deleted',
                                showConfirmButton: false,
                                timer: 1500, }).then(function (result) {
                                location.reload();
                            });
                        }
                    },
                });
            }
        }
        )
    }
</script>