Ejemplo n.º 1
0
<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'contentOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center']], ['label' => 'Tugas Untuk', 'value' => function ($data) {
    return $data->userTo->person->first_name . ' ' . $data->userTo->person->last_name;
}, 'attribute' => 'task_to', 'headerOptions' => ['class' => 'text-center']], ['label' => 'Judul Tugas', 'value' => 'task_title', 'attribute' => 'task_title', 'headerOptions' => ['class' => 'text-center']], ['label' => 'Tanggal Mulai', 'value' => function ($data) {
    $keterangan = date('d F Y', strtotime($data->task_start));
    return $keterangan;
}, 'contentOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center']], ['label' => 'Tanggal Selesai', 'value' => function ($data) {
    $keterangan = date('d F Y', strtotime($data->task_end));
    return $keterangan;
}, 'contentOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center']], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Lampiran', 'template' => '{download}', 'contentOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center'], 'buttons' => ['download' => function ($url, $model) {
    if (!empty($model->attachment)) {
        return Html::a('<i class="fa fa-download fa-2x"></i>', Url::to(['download', 'id' => $model->id]), ['title' => 'Download Lampiran']);
    }
    return '-';
}]], ['value' => function ($model) {
    return Status::getPeriod($model->period);
}, 'attribute' => 'period', 'contentOptions' => ['class' => 'text-center'], 'header' => 'Periode', 'headerOptions' => ['class' => 'text-center']], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Status Tugas', 'template' => '{update}', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'buttons' => ['update' => function ($url, $model) {
    $taskStatus = Status::getTaskStatus($model->status);
    $taskColor = Status::getTaskColor($model->status);
    return Html::a($taskStatus, '#', ['title' => Yii::t('app', 'Status Tugas'), 'data-id' => $model->id, 'class' => 'btn ' . $taskColor . ' btn-md modal-status']);
}]], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {isi} {view} {delete}', 'contentOptions' => ['class' => 'text-center'], 'buttons' => ['isi' => function ($url, $model) {
    if ($model->task_from !== Yii::$app->user->getId()) {
        return Html::a('<i class="fa fa-bookmark"></i>', Url::to(['detail', 'id' => $model->id]), ['title' => Yii::t('app', 'Isi Tugas')]);
    }
}, 'delete' => function ($url, $model) {
    // jika tugas dari sama dengan user yang sedang login
    // maka tampilkan icon delete
    if ($model->task_from === Yii::$app->user->getId()) {
        return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Apakah anda yakin data tugas ini akan dihapus?')]);
    }
}, 'update' => function ($url, $model) {
Ejemplo n.º 2
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ListView;
use yii\widgets\DetailView;
use app\components\Status;
use app\components\Panel;
/* @var $this yii\web\View */
/* @var $model app\models\Task */
$this->title = 'Detil Tugas : ' . $model->task_title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Tasks'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Panel::begin(['title' => $this->title, 'icon' => 'fa fa-file-text-o']);
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Judul Tugas', 'value' => $model->task_title], ['label' => 'Tanggal Mulai & Selesai Tugas', 'value' => date('d F Y', strtotime($model->task_start)) . ' s.d ' . date('d F Y', strtotime($model->task_end))], ['label' => 'Lampiran', 'value' => call_user_func(function ($model) {
    if (!empty($model->attachment)) {
        return Html::a('<i class="fa fa-download fa-2x"></i>', Url::to(['download', 'id' => $model->id]), ['title' => 'Download Lampiran']);
    }
}, $model), 'format' => 'html'], ['label' => 'Status Tugas', 'value' => Status::getTaskStatus($model->status)], ['label' => 'Periode Tugas', 'value' => Status::getPeriod($model->period)], ['label' => 'Detil Tugas', 'value' => $model->task_detail, 'format' => 'html']]]);
?>
     <?php 
echo Html::a('<i class="fa fa-arrow-left"></i> ' . Yii::t('app', 'Kembali'), ['index'], ['class' => 'btn btn-lg btn-warning']);
?>

<?php 
Panel::end();