| Current Path : /var/www/html/ekursusv2/frontend/runtime/frontendpage/ |
| Current File : /var/www/html/ekursusv2/frontend/runtime/frontendpage/167_1778554517009061500-content-428.php |
<?php
/*** CONTENT_ID-428***/
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\data\ActiveDataProvider;
use yii\widgets\ActiveForm;
use frontend\models\Staff;
$keyword = Yii::$app->getRequest()->getQueryParam('keyword');
if(!empty(Yii::$app->getRequest()->getQueryParam('action')) && Yii::$app->getRequest()->getQueryParam('action') == 'delete'){
$id = Yii::$app->getRequest()->getQueryParam('id');
if (($model = Staff::findOne($id)) !== null) {
if($model->delete()){
echo "<script>
Swal.fire({
icon: 'success',
title: 'Berjaya',
html: 'Data telah dihapuskan',
}).then((result) => {
window.location.href = '/portal-main/staff-list';
});
</script>";
}
}
}
$query = Staff::find()->where(['=','staff_company_id',Yii::$app->user->identity->id]);
if(!empty($keyword)){
$query->andFilterWhere(['OR',
['like', 'staff_name', $keyword],
['like', 'staff_ic_no', $keyword],
['like', 'staff_position', $keyword],
]);
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => ['defaultOrder' => ['staff_id' => SORT_DESC]],
'pagination' => ['pageSize' => false,'route' => 'portal-main/staff-list'],
]);
echo '<style>
.staff-image{
width : 50px;
height : 50px;
float:left;
border-radius:50%;
border:1px solid #ccc;
background-size:cover;
background-repeat:no-repeat;
background-position:center center;
margin-right:10px;
}
.table tbody tr td{vertical-align:middle;}
</style>
<div class="page-title-box d-flex align-items-center justify-content-between">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="/portal-main/dashboard">Utama</a></li>
<li class="breadcrumb-item active">Profil Kakitangan</li>
</ol>
</div>
<div class="card table-responsive">
<div class="card-body">';
$form = ActiveForm::begin(['action' => ['portal-main/staff-list'], 'method' => 'get',]);
echo '<div class="row">
<div class="col-sm-4">'.Html::input('text','keyword',$keyword, $options=['class'=>'form-control','placeholder'=>'Masukkan kata kunci untuk carian']).'</div>
<div class="col-sm-4">
'.Html::submitButton(Yii::t('app', 'Cari'), ['class' => 'btn btn-outline-primary waves-effect waves-light']).'
'.Html::a(Yii::t('app', 'Set Semula'),['portal-main/staff-list'], ['class' => 'btn btn-outline-primary waves-effect waves-light']).'
<a href="/portal-main/staff-form" class="btn btn-primary waves-effect waves-light">Tambah Kakitangan</a>
</div>
</div>';
ActiveForm::end();
echo GridView::widget([
'dataProvider' => $dataProvider,
'summary' => '',
'emptyText'=>'Rekod Tidak Dijumpai.',
'tableOptions' => ['class' => 'table table-striped table-bordered table-custom mt-3'],
'columns' => [
['class' => 'yii\grid\SerialColumn', 'contentOptions' => ['class' => 'text-center', 'width' => '1%'],],
[
'attribute'=>'staff_name',
'format'=>'raw',
'value' => function ($model) {
$output = '<div style="background-image:url(/'.$model->staff_img_url.')" class="staff-image"></div>';
$output.= '<div style="margin-top:10px;">'.$model->staff_name.'</div>';
if ($model->staff_blacklisted_status == 1)
$output.= '<span style="color:red;"><b>* Di senarai hitam</b></span>';
return $output;
}
],
'staff_ic_no',
'staff_position',
[
'attribute' => 'staff_status',
'value' => function ($model) {
return \backend\modules\refdynawebv2\models\Ref::getDesc('ACTIVE_STATUS', $model->staff_status);
}
],
[
'header' => 'Tindakan',
'class' => 'yii\grid\ActionColumn',
'headerOptions' => ['class' => 'text-center text-nowrap', 'width' => '10%'],
'contentOptions' => ['class' => 'text-center text-nowrap', 'width' => '10%'],
'template' => '{info}{update}{delete}',
'buttons' => [
'update' => function ($url, $model) {
return Html::a('<i class="mdi mdi-pencil-outline"></i>', ['portal-main/staff-form',
'id' => $model->staff_id,
], ['title' => 'Update', 'class' => 'action_link']);
},
'delete' => function ($url, $model) {
return Html::a('<i class="mdi mdi-trash-can-outline"></i>', null, [
'title' => 'Delete',
'class' => 'action_link',
'href' => 'javascript:void(0);',
'onclick' => 'deleteconfirm('.$model->staff_id.')',
]);
},
]
],
],
]);
echo '</div>
</div>';
echo "<script>
function deleteconfirm(id){
Swal.fire({
title: 'Anda pasti untuk hapuskan data ini?',
text: 'Data tidak boleh dikembalikan!',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, teruskan!',
cancelButtonText: 'Batal',
}).then((result) => {
if (result.isConfirmed) {
window.location.href = '/portal-main/staff-list?action=delete&id='+id;
}
});
}
</script>";
?>