| Current Path : /var/www/html/crm/views/assetdetails/ |
| Current File : /var/www/html/crm/views/assetdetails/index.php.20210824 |
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use app\models\Menu;
use app\models\AssetCategory;
use app\models\AssetLog;
$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, ''); ?>
<span class="kt-subheader__breadcrumbs-separator"></span><span class="kt-subheader__breadcrumbs-link"><?= $this->title ?> List</span>
</div>
</div>
</div>
</div>
<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">
<p style="position:absolute;margin-top:0.5em;margin-left:1em;">* Status and location are based on latest log record</p>
<?=
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' => '5%'],
'contentOptions' => ['class' => 'text-center'],
], [
'attribute' => 'img_url',
'format' => 'raw',
'headerOptions' => ['class' => 'text-center', 'width' => '1%'],
'contentOptions' => ['class' => 'text-center'],
'value' => function ($model) {
$output = 'images/no-image.png';
if (!empty($model->img_url))
$output = 'uploads/asset/' . $model->img_url;
return '
<a data-toggle="modal" data-target="#modal'.$model->id.'" style="cursor:pointer;">
<img src="' . $output . '" height="50">
</a>
<div class="modal fade" id="modal'.$model->id.'" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body p-0">
<img src="' . $output . '" style="max-width:100%;">
</div>
</div>
</div>
</div>';
},
],
[
'attribute' => 'name',
'headerOptions' => ['class' => 'head-sort'],
], [
'header' => 'Serial No',
'format' => 'raw',
'value' => function ($model) {
return $model->getserialnumber($model->id);
},
], [
'attribute' => 'cat',
'value' => function ($model) {
$AssetCategory = new AssetCategory();
return $AssetCategory->getname($model->cat);
},
], [
'attribute' => 'asset_value',
'headerOptions' => ['class' => 'head-sort'],
'value' => function ($model) {
return 'MYR ' . number_format((float) $model->asset_value, 2, '.', ',');
},
], [
'attribute' => 'purchase_dt',
'format' => 'raw',
'value' => function ($model) {
$output = '';
if (!empty($model->purchase_dt))
$output = date("d M Y", strtotime($model->purchase_dt));
return $output;
},
], [
'header' => 'Status',
'format' => 'raw',
'value' => function ($model) {
$AssetLog = new AssetLog();
return $AssetLog->getstatus($model->id);
},
], [
'header' => 'Location',
'format' => 'raw',
'value' => function ($model) {
$AssetLog = new AssetLog();
return $AssetLog->getlocation($model->id);
},
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'headerOptions' => ['class' => 'text-center'],
'contentOptions' => ['class' => 'text-center'],
'template' => '{barcode} {view} {log} {update} {delete}',
'buttons' => [
'barcode' => function ($url, $model) {
$url = 'https://barcode.tec-it.com/barcode.ashx?data='.$model->getserialnumber($model->id).'&code=Code128';
return Html::a('<span class="kt-font-danger icon-custom"><i class="fas fa-print fa-lg"></i></span>', $url, ['title' => 'Print Barcode', 'target' => '_blank']);
},
'view' => function ($url, $model) {
$url = Url::to(['assetdetails/view', 'uuid' => $model->uuid]);
return Html::a('<span class="kt-font-brand icon-custom"><i class="fas fa-info fa-lg"></i></span>', $url, ['title' => 'Details',]);
}, 'log' => function ($url, $model) {
$url = Url::to(['assetlog/index', 'asset_id' => $model->id]);
return Html::a('<span class="kt-font-warning icon-custom"><i class="fas fa-calendar-alt fa-lg"></i></span>', $url, ['title' => 'Log',]);
}, 'update' => function ($url, $model) {
$url = Url::to(['assetdetails/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>
<?php $this->registerJs("setleftmenu(63,64,'');"); ?>
<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=assetdetails/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>