This commit is contained in:
2020-02-01 16:47:12 +07:00
commit 4c619ad6e6
16739 changed files with 3329179 additions and 0 deletions

94
helpers/LogsGrid.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
namespace app\helpers;
use Yii;
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\common;
class LogsGrid {
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 plateIn() {
return function($model) {
$style = "width:50px";
if ($model->mod_in == 1) {
$style = "width:100%";
}
$image = $model->plate_image_in;
if (!$image) {
$image = $model->frame_image_in;
$style = "width:100%";
}
return Html::img(Yii::$app->request->hostInfo . "/data/uploads/" . $image, [
'class' => "img-thumbnail",
"style" => $style
]);
};
}
public static function cardId() {
return function($model) {
if ($model->card_id != 0) {
return sprintf("%06d", $model->card_id);
} else {
return "<i class='text-red'>Thẻ đã bị xóa!</i>";
}
};
}
public static function plateOut() {
return function($model) {
if ($model->time_out) {
$style = "width:50px";
if ($model->mod_out == 1) {
$style = "width:100%";
}
$image = $model->plate_image_out;
if (!$image) {
$image = $model->frame_image_out;
$style = "width:100%";
}
return Html::img(Yii::$app->request->hostInfo . "/data/uploads/" . $image, [
'class' => "img-thumbnail",
"style" => $style
]);
} else {
return "";
}
};
}
public static function timeIn() {
return function($model) {
$common = new common();
return $common->formatTime($model->time_in, "H:i:s d/m/Y");
};
}
public static function timeOut() {
return function($model) {
if ($model->time_out) {
$common = new common();
return $common->formatTime($model->time_out, "H:i:s d/m/Y");
} else {
return "";
}
};
}
}

88
helpers/UserGrid.php Normal file
View File

@@ -0,0 +1,88 @@
<?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::a('<i class="fa fa-trash"></i>', ['/user/delete', 'id' => $model->id], [
'class' => 'btn btn-danger btn-xs',
'title' => Yii::t("app", "Delete"),
'data' => [
'toggle' => 'tooltip',
'confirm' => "Bạn có chắc chắn muốn xóa người dùng này không?",
'method' => 'post'
]
]);
}
return "";
};
}
}

74
helpers/VehicleGrid.php Normal file
View File

@@ -0,0 +1,74 @@
<?php
namespace app\helpers;
use Yii;
use yii\helpers\Html;
use yii\helpers\Url;
class VehicleGrid {
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 driver() {
return function($model) {
$ls = explode("/", $model->driver);
return implode("</br>", $ls);
};
}
public static function telephone() {
return function($model) {
$ls = explode("/", $model->telephone);
return implode("</br>", $ls);
};
}
public static function card() {
return function($model) {
$ls = explode("/", $model->indentity_card);
return implode("</br>", $ls);
};
}
public static function update() {
return function($url, $model) {
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" => "Chỉnh sửa",
"onclick" => "_form(this);"
]);
};
}
public static function delete() {
return function($url, $model) {
return Html::a('<i class="fa fa-trash"></i>', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger btn-xs',
'title' => "Xóa",
'data' => [
'toggle' => 'tooltip',
'confirm' => "Bạn có chắc chắn muốn xóa thông tin xe này không?",
'method' => 'post'
]
]);
};
}
}