| Current Path : /var/www/html/brspace/backend/modules/documentAutomation/views/template/ |
| Current File : /var/www/html/brspace/backend/modules/documentAutomation/views/template/index.php |
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\documentAutomation\models\TemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Templates';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<p>
<?= Html::a(Yii::t('app', 'Add New'), ['create'], ['class' => 'btn btn-primary']) ?>
</p>
<div class="ibox animated fadeInRight">
<div class="mail-box b-r-md">
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'tableOptions' => ['class' => 'table',],
'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',
'headerOptions' => ['style' => 'text-align:center;width:5%'],
'contentOptions' => ['style' => 'text-align:center;'],
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'template' => '{content}{update}{delete}',
'headerOptions' => ['style' => 'text-align:center;width:1%;'],
'contentOptions' => ['style' => 'text-align:center;'],
'buttons' => [
'content' => function ($url, $model) {
return Html::a('<span class="fa fa-pencil"></span> Template',
['updatecontent', 'id' => $model->id],
['title' => 'Update Template', 'data-pjax' => '0','class' => 'label label-success label-button']);
},
'update' => function($url, $model, $key) {
return Html::a('<span class="fa fa-pencil"></span> ' . Yii::t('app', 'Edit'), ['update', 'id' => $model->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->id . '\')">
<i class="fa fa-trash"></i> Delete
</span>';
},
],
],
[
'headerOptions' => ['style' => 'width:15%'],
'attribute' => 'thumbnail',
'filter' => false,
'format' => 'raw',
'value' => function ($model) {
if (!empty($model->thumbnail))
return '<img style="width:100px;border:1px solid #ccc;" src="../../../' . $model->thumbnail . '"/>';
else
return '<img style="width:100px;" src="../../images/noimage.jpg"/>';
}
],
'title',
],
]);
?>
</div>
</div>
<div class="version">Version 1.0 (Last update on 4th June 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/documentAutomation/template/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>