| Current Path : /var/www/html/crm/views/invoicetransfer/ |
| Current File : /var/www/html/crm/views/invoicetransfer/index.php |
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use app\models\Menu;
use app\models\Company;
use app\models\Invoice;
use yii\helpers\ArrayHelper;
use app\models\User;
$Menu = new Menu();
$this->title = $Menu->getmenutitle($menu_id);
$Company = new Company();
if (!empty($searchModel->searchcompany))
$this->title .= ' - ' . $Company->getname2($searchModel->searchcompany);
?>
<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="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' => '5%'],
'contentOptions' => ['class' => 'text-center'],
], [
'attribute' => 'doc_dt',
'headerOptions' => ['class' => 'head-sort'],
'format' => 'raw',
'value' => function ($model) {
return date("d M Y", strtotime($model->doc_dt));
},
], [
'attribute' => 'payment_due',
'format' => 'raw',
'value' => function ($model) {
$output = '';
if (!empty($model->payment_due))
$output = date("d M Y", strtotime($model->payment_due));
return $output;
},
],
[
'attribute' => 'invoice_no',
'headerOptions' => ['class' => 'head-sort'],
], [
'attribute' => 'customer_name',
'headerOptions' => ['class' => 'head-sort'],
], [
'attribute' => 'payment_status',
'format' => 'raw',
'value' => function ($model) {
$output = $model->payment_status;
if ($model->payment_status == 'Pending')
$output .= ' <i onclick="updatepaymentstatus(' . $model->id . ')" class="fas fa-check-square fa-lg kt-font-success" title="Update payment status to Paid"></i>';
return $output;
},
], [
'header' => 'Amount',
'headerOptions' => ['class' => 'head-sort'],
'value' => function ($model) {
return 'MYR ' . number_format((float) $model->grandtotal, 2, '.', ',');
},
], [
'attribute' => 'sales_pic',
'format' => 'raw',
'value' => function ($model) {
$User = new User();
return $User->getusername($model->sales_pic);
},
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'headerOptions' => ['class' => 'text-center', 'width' => '10%'],
'contentOptions' => ['class' => 'text-center'],
'template' => '{download} {update} {delete}',
'buttons' => [
'download' => function ($url, $model) {
$url = Url::to(['invoicetransfer/download', 'uuid' => $model->uuid]);
return Html::a('<span class="kt-font-brand icon-custom"><i class="fas fa-file-download fa-lg"></i></span>', $url, ['target' => '_blank', 'title' => 'Download',]);
},
'update' => function ($url, $model) {
$url = Url::to(['invoicetransfer/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',]);
}, 'log' => function ($url, $model) {
$url = Url::to(['invoicetransfer/log', 'uuid' => $model->uuid]);
return Html::a('<span class="kt-font-warning icon-custom"><i class="fas fa-history fa-lg"></i></span>', $url, ['title' => 'Change Log',]);
}, 'delete' => function ($url, $model) {
return '<span class="kt-font-danger icon-custom" title="Delete Product"><i class="far fa-trash-alt" style="cursor:pointer;" onclick="deleteinvoice(' . $model->id . ')"></i></span>';
},],
],
],
]);
?>
</div>
</div>
</div>
</div>
<script>
function updatepaymentstatus(id) {
Swal.fire({
title: 'Are you sure to update this invoice payment status?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, update it!'
}).then((result) => {
if (result.value) {
$.ajax({
url: "index.php?r=invoicetransfer/updatepaymentstatus",
method: "POST",
data: {"id": id},
success: function (response) {
if (response === 'success') {
swal.fire({
position: 'center-center',
type: 'success',
title: 'Payment status has been updated',
showConfirmButton: false,
timer: 1500,
}).then(function (result) {
location.reload();
});
}
},
});
}
}
);
}
function deleteinvoice(id) {
Swal.fire({
title: 'Are you sure to delete this Invoice?',
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=invoicetransfer/delete",
method: "POST",
data: {"id": id},
success: function (response) {
if (response === 'success') {
swal.fire({
position: 'center-center',
type: 'success',
title: 'You Invoice has been deleted',
showConfirmButton: false,
timer: 1500, }).then(function (result) {
location.reload();
});
}
},
});
}
}
)
}
</script>