159 lines
5.8 KiB
PHP
159 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace app\helpers;
|
|
|
|
use Yii;
|
|
use yii\helpers\Html;
|
|
use yii\helpers\Url;
|
|
|
|
class CaptureLogsGrid {
|
|
|
|
static $path = "";
|
|
|
|
public static function path() {
|
|
return self::$path;
|
|
}
|
|
|
|
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 time() {
|
|
return function($model) {
|
|
return date("H:i:s d/m/Y", $model->time);
|
|
};
|
|
}
|
|
|
|
public static function image($process = false) {
|
|
return function($model) use ($process) {
|
|
$btn = "";
|
|
if ($process)
|
|
$btn = Html::button("<i class='fa fa-reply'></i>", [
|
|
"class" => "btn btn-info btn-xs",
|
|
"style" => "position:absolute;top:0;right:0;visibility: hidden;",
|
|
"data" => [
|
|
"toggle" => "tooltip",
|
|
"href" => Url::to(["/control-logs/use-feature", "id" => $model->id])
|
|
],
|
|
"title" => "Chuyển làm ảnh mẫu",
|
|
"onclick" => "_useFeature(this);"
|
|
]);
|
|
return "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $model->image, [
|
|
"class" => "img-thumbnail",
|
|
"style" => "width: 150px;height:150px;"
|
|
]) . $btn . "</div>";
|
|
};
|
|
}
|
|
|
|
public static function status($statusArray) {
|
|
return function($model) use ($statusArray) {
|
|
return $statusArray[$model->status];
|
|
};
|
|
}
|
|
|
|
public static function confidence() {
|
|
return function($model) {
|
|
$confidence = json_decode($model->confidence, true);
|
|
// $person1_html = $person2_html = "";
|
|
// $person1 = \app\models\ListManagement::findOne($confidence['id1']);
|
|
// if ($person1) {
|
|
// $images = json_decode($person1->image, true);
|
|
// $person1_html = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
|
|
// "class" => "img-thumbnail",
|
|
// "style" => "width: 100px;height:100px;"
|
|
// ]) . "<br>" . $person1->name . " [" . $confidence['percent1'] . "]" . "</div>";
|
|
// }
|
|
// if ($confidence['id2'] !== "0" && $confidence['id2'] != $confidence['id1']) {
|
|
// $person2 = \app\models\ListManagement::findOne($confidence['id2']);
|
|
// if ($person2) {
|
|
// $images = json_decode($person2->image, true);
|
|
// $person2_html = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
|
|
// "class" => "img-thumbnail",
|
|
// "style" => "width: 100px;height:100px;"
|
|
// ]) . "<br>" . $person2->name . " [" . $confidence['percent2'] . "]" . "</div>";
|
|
// }
|
|
// }
|
|
return $confidence['percent1']; //$person1_html . $person2_html;
|
|
};
|
|
}
|
|
|
|
public static function confidenceControlLogs() {
|
|
return function($model) {
|
|
$confidence = json_decode($model->confidence, true);
|
|
return $confidence['percent1'] . ($confidence['percent2'] > 0 ? " [" . $confidence['percent2'] . "]" : "");
|
|
};
|
|
}
|
|
|
|
public static function rows() {
|
|
return function($model, $index, $widget, $grid) {
|
|
$confidence = json_decode($model->confidence, true);
|
|
$person = \app\models\ListManagement::findOne($confidence['id1']);
|
|
$images = false;
|
|
if ($person) {
|
|
$images = json_decode($person->image, true);
|
|
}
|
|
return [
|
|
"ondblclick" => "_form(this);",
|
|
"style" => "cursor: pointer;",
|
|
"data" => [
|
|
"id" => $model->id,
|
|
"img" => "/data/uploads/face/" . $model->image,
|
|
"confidence" => json_encode([
|
|
"name" => $person ? $person->name : "",
|
|
"score" => $confidence['percent1'],
|
|
"img" => isset($images[0]) ? "/data/uploads/face/" . $images[0]['url'] : ""
|
|
])
|
|
]
|
|
];
|
|
};
|
|
}
|
|
|
|
public static function rowsControlLogs() {
|
|
return function($model, $index, $widget, $grid) {
|
|
return [
|
|
"ondblclick" => "_form(this);",
|
|
"style" => "cursor: pointer;",
|
|
"data" => [
|
|
"id" => $model->id,
|
|
"img" => "/data/uploads/face/" . $model->image
|
|
]
|
|
];
|
|
};
|
|
}
|
|
|
|
public static function birthday() {
|
|
return function($model) {
|
|
$staff = $model->listManagement;
|
|
if ($staff)
|
|
return date("d/m/Y", $staff->birthday);
|
|
return "";
|
|
};
|
|
}
|
|
|
|
public static function registrationImage() {
|
|
return function($model) {
|
|
$staff = $model->listManagement;
|
|
if ($staff) {
|
|
$images = json_decode($staff->image, true);
|
|
if (count($images) > 0)
|
|
return Html::img("/data/uploads/face/" . $images[count($images) - 1]['url'], [
|
|
"class" => "img-thumbnail",
|
|
"style" => "width: 150px;height:150px;"
|
|
]);
|
|
}
|
|
return "";
|
|
};
|
|
}
|
|
|
|
}
|