89 lines
2.7 KiB
PHP
89 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace app\helpers;
|
|
|
|
use Yii;
|
|
use yii\helpers\Html;
|
|
use yii\helpers\Url;
|
|
|
|
class UserGrid {
|
|
|
|
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 "{view} {update} {delete}";
|
|
}
|
|
|
|
public static function avatar() {
|
|
return function($model) {
|
|
return "23432";
|
|
};
|
|
}
|
|
|
|
public static function roles() {
|
|
return function($model) {
|
|
return $model->roleName;
|
|
};
|
|
}
|
|
|
|
public static function view() {
|
|
return function($url, $model) {
|
|
if (\Yii::$app->user->can("administrator")) {
|
|
return Html::button("<i class='fa fa-search'></i>", [
|
|
"class" => "btn btn-info btn-xs",
|
|
"data" => [
|
|
"toggle" => "tooltip",
|
|
"href" => Url::to(['/user/view', 'id' => $model->id])
|
|
],
|
|
"title" => Yii::t("app", "View"),
|
|
"onclick" => "user.form(this);"
|
|
]);
|
|
}
|
|
return "";
|
|
};
|
|
}
|
|
|
|
public static function update() {
|
|
return function($url, $model) {
|
|
if (\Yii::$app->user->can("administrator")) {
|
|
return Html::button("<i class='fa fa-pencil'></i>", [
|
|
"class" => "btn btn-success btn-xs",
|
|
"data" => [
|
|
"toggle" => "tooltip",
|
|
"href" => Url::to(['/user/update', 'id' => $model->id])
|
|
],
|
|
"title" => Yii::t("app", "Edit"),
|
|
"onclick" => "user.form(this);"
|
|
]);
|
|
}
|
|
return "";
|
|
};
|
|
}
|
|
|
|
public static function delete() {
|
|
return function($url, $model) {
|
|
if (\Yii::$app->user->can("administrator")) {
|
|
return Html::button("<i class='fa fa-trash'></i>", [
|
|
"class" => "btn btn-danger btn-xs",
|
|
"data" => [
|
|
"toggle" => "tooltip",
|
|
"href" => Url::to(['/user/delete', 'id' => $model->id])
|
|
],
|
|
"title" => Yii::t("app", "Delete"),
|
|
"onclick" => "user.delete(this);"
|
|
]);
|
|
}
|
|
return "";
|
|
};
|
|
}
|
|
|
|
}
|