| Current Path : /var/www/html/brspace/backend/modules/documentAutomation/views/documents/ |
| Current File : /var/www/html/brspace/backend/modules/documentAutomation/views/documents/index.php |
<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\ActionColumn;
use yii\grid\GridView;
$this->title = 'Documents';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<p>
<?= Html::a(Yii::t('app', 'Add New'), ['selecttemplate'], ['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',],
'summary' => '',
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
'headerOptions' => ['style' => 'text-align:center;width:5%'],
'contentOptions' => ['style' => 'text-align:center;'],
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'template' => '{pdf}{update}{delete}',
'headerOptions' => ['style' => 'text-align:center;width:1%;'],
'contentOptions' => ['style' => 'text-align:center;'],
'buttons' => [
'pdf' => function ($url, $model) {
return Html::a('<span class="fa fa-download"></span> Document', [
'downloadpdf',
'id' => $model->id
], ['title' => 'Download', 'target' => '_blank', '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>';
},
],
],
'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/documents/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>