66 lines
2.0 KiB
PHP
66 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace app\helpers;
|
|
|
|
use Yii;
|
|
use yii\helpers\Html;
|
|
use yii\helpers\Url;
|
|
use app\models\common;
|
|
|
|
class CommonGrid {
|
|
|
|
public static function engineNameFunc() {
|
|
return function ($data) {
|
|
return $data->app->app_name;
|
|
};
|
|
}
|
|
|
|
public static function getLayout() {
|
|
return "{items}<div class='row'><div class='col-md-4'>{summary}</div><div class='col-md-8 text-right'>{pager}</div></div>";
|
|
}
|
|
|
|
public static function actionTemplate() {
|
|
return "{update} {delete}";
|
|
}
|
|
|
|
public static function createdAt() {
|
|
return function($model) {
|
|
$common = new common();
|
|
return $common->formatTime($model->created_at, "H:i d/m/Y");
|
|
};
|
|
}
|
|
|
|
public static function modifiedAt() {
|
|
return function($model) {
|
|
$common = new common();
|
|
return $common->formatTime($model->modified_at, "H:i d/m/Y");
|
|
};
|
|
}
|
|
|
|
public static function update($obj) {
|
|
return function($url, $model) use ($obj) {
|
|
return Html::button("<i class='fa fa-pencil'></i>", [
|
|
'class' => 'btn btn-success btn-xs',
|
|
'data' => ['toggle' => 'tooltip', 'href' => Url::to(['update', 'id' => $model->id])],
|
|
'title' => Yii::t('app', 'Chỉnh sửa'),
|
|
'onclick' => "common.form(this, '{$obj}');"
|
|
]);
|
|
};
|
|
}
|
|
|
|
public static function delete($deleteConfirmMess) {
|
|
return function($url, $model) use ($deleteConfirmMess) {
|
|
return Html::a('<i class="fa fa-trash"></i>', ['delete', 'id' => $model->id], [
|
|
'class' => 'btn btn-danger btn-xs',
|
|
'title' => Yii::t("app", "Xóa"),
|
|
'data' => [
|
|
'toggle' => 'tooltip',
|
|
'confirm' => $deleteConfirmMess,
|
|
'method' => 'post'
|
|
]
|
|
]);
|
|
};
|
|
}
|
|
|
|
}
|