Compare commits
77 Commits
master
...
dev_DTD_ol
Author | SHA1 | Date | |
---|---|---|---|
b3bca79f55 | |||
9ceb3567c9 | |||
2c722a1ee9 | |||
70d60ff51e | |||
c02733be18 | |||
924d23dad0 | |||
b006af4e1f | |||
1b1162f3c2 | |||
bf93f6c9d0 | |||
aaa6de6f9c | |||
e45e08f372 | |||
c353c25abf | |||
92541936d1 | |||
6d87d47d68 | |||
3f22f89654 | |||
32939a05cb | |||
5cefdb8031 | |||
74135e96de | |||
8cb9cd30bc | |||
cc41875ad2 | |||
5472f6ef77 | |||
aa811a40dd | |||
3b247f9f25 | |||
3611390586 | |||
09604d1cb8 | |||
d296533184 | |||
cb6c8fba32 | |||
c9d0c24218 | |||
ddcf67ba9c | |||
dc75b88bd8 | |||
86afa3a430 | |||
18ffc9c6f4 | |||
22f3a3f650 | |||
b26814bb97 | |||
492651570e | |||
999df32e09 | |||
9cca411720 | |||
45be07f772 | |||
ef59255c52 | |||
d0f17afc39 | |||
fc0f2ccc0f | |||
40df99acd9 | |||
3f289ddc9d | |||
bba20c9c17 | |||
df644d539d | |||
5bb7d519fc | |||
ef08b20d16 | |||
27e58bf5e1 | |||
4d6f1cbed8 | |||
04d467a73c | |||
0095c2c133 | |||
6cbe36d04f | |||
9bdfb205f6 | |||
fc347376d3 | |||
8530a33542 | |||
237f658e16 | |||
5d5de05f85 | |||
e27b8de414 | |||
483e0fa349 | |||
94215e4e80 | |||
fbc48fca53 | |||
7ff0f1b976 | |||
75073b956d | |||
24e3347d43 | |||
ee3c869d71 | |||
3a34cc43c8 | |||
ed4b8a0144 | |||
4cb2f77598 | |||
f694e9fe71 | |||
811ed32e04 | |||
3ef04dfb5a | |||
0c9bbd3314 | |||
df39cdf602 | |||
4187fc7239 | |||
6030ccd0a5 | |||
efb4113001 | |||
73b44eb2af |
23
assets/CaptureLogsAsset.php
Normal file
23
assets/CaptureLogsAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class CaptureLogsAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/capture-logs.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
23
assets/ControlLogsAsset.php
Normal file
23
assets/ControlLogsAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class ControlLogsAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/control-logs.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
23
assets/ListManagementAsset.php
Normal file
23
assets/ListManagementAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class ListManagementAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/list-management.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
|
@ -10,6 +10,9 @@ namespace app\commands;
|
|||
|
||||
use yii\console\Controller;
|
||||
use yii\console\ExitCode;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\ListManagement;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This command echoes the first argument that you have entered.
|
||||
|
@ -28,32 +31,34 @@ class SyncController extends Controller {
|
|||
*/
|
||||
public function actionIndex() {
|
||||
if ($this->is_connected()) {
|
||||
$sync = \app\models\SyncUrl::find()->one();
|
||||
if ($sync) {
|
||||
$logs = \app\models\FaceLogs::find()->all();
|
||||
foreach ($logs as $key => $value) {
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"camera_id" => $value->camera_id,
|
||||
"confidence" => $value->confidence,
|
||||
"enable_door" => $value->enable_door,
|
||||
"encoded_person_image" => $value->encoded_person_image,
|
||||
"frametime" => $value->frametime,
|
||||
"id" => $value->face_id,
|
||||
"image" => $value->image,
|
||||
"name" => $value->name,
|
||||
"person_id" => $value->person_id,
|
||||
"status" => $value->status,
|
||||
"stt" => $value->stt,
|
||||
"timezone" => $value->timezone
|
||||
]),
|
||||
]
|
||||
];
|
||||
file_get_contents($sync->data, false, stream_context_create($options));
|
||||
$value->delete();
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
$ls = CaptureLogs::find()->andWhere(['<>', 'staff_id', 0])->andWhere(['sync_status' => null])->all();
|
||||
foreach ($ls as $key => $value) {
|
||||
$staffInfo = ListManagement::findOne($value->staff_id);
|
||||
$res = json_decode(file_get_contents("https://" . $ip . "/api/box/oem_face_recognition", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)),
|
||||
'camera_id' => strval($id_camera),
|
||||
'frametime' => date("Y-m-d H:i:s", $value->time + 60 * 60 * 7),
|
||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||
"person_id" => "123",
|
||||
"timezone" => "+7"
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
if ($res['status'] == 10000) {
|
||||
$value->sync_status = 1;
|
||||
$value->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
"maxLogs" => 100000,
|
||||
"maxPicture" => 5,
|
||||
"version" => "1.0.7"
|
||||
];
|
||||
|
|
|
@ -5,6 +5,10 @@ namespace app\controllers;
|
|||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\helpers\FileHelper;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\ListManagement;
|
||||
use app\models\common;
|
||||
|
||||
/**
|
||||
* CardController implements the CRUD actions for Card model.
|
||||
|
@ -51,4 +55,450 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionGetLogs() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
|
||||
$key = common::generateRandomString();
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
$fileName = "face_" . $key . "_" . $time . ".png";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
file_put_contents($targetPath . "/" . $fileName, base64_decode($post['image']));
|
||||
|
||||
$totalsLogs = CaptureLogs::find()->count();
|
||||
if ($totalsLogs >= \Yii::$app->params['maxLogs']) {
|
||||
$lastLogs = CaptureLogs::find()->orderBy(["id" => SORT_ASC])->limit(1)->one();
|
||||
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $lastLogs->image);
|
||||
$lastLogs->delete();
|
||||
}
|
||||
|
||||
$model = new CaptureLogs();
|
||||
$logs = $model->create([
|
||||
"Staff" => $post["id"],
|
||||
"Time" => $time,
|
||||
"Image" => $fileName,
|
||||
"Confidence" => json_encode($post["confidence"])
|
||||
]);
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "https://dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
if ($this->is_connected($ip) && $logs) {
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
$logsInfo = CaptureLogs::findOne($logs);
|
||||
$staffInfo = ListManagement::findOne($post['id']);
|
||||
$tk = "";
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token)
|
||||
$tk = $token->data;
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)),
|
||||
'camera_id' => strval($id_camera),
|
||||
'frametime' => date("Y-m-d H:i:s", $time),
|
||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||
"person_id" => "123",
|
||||
"timezone" => "+7"
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
if ($res['status'] == 10000) {
|
||||
$logsInfo->sync_status = 1;
|
||||
$logsInfo->save();
|
||||
}
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return ["status" => "success"];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionGetAllFeatures($offset = 0, $limit = 10) {
|
||||
$listManagement = ListManagement::find()->limit($limit)->offset($offset)->all();
|
||||
$allFeatures = [];
|
||||
foreach ($listManagement as $key => $value) {
|
||||
$features = json_decode($value->image, true);
|
||||
// $f = [];
|
||||
// foreach ($features as $k => $v) {
|
||||
// $f[] = $v['features'];
|
||||
// if (isset($v['features512']))
|
||||
// if (count($v['features512']))
|
||||
// $f[] = $v['features512'];
|
||||
// }
|
||||
// $allFeatures[] = [
|
||||
// "id" => $value->id,
|
||||
// "name" => $this->convert_vi_to_en($value->name),
|
||||
// "features" => $f
|
||||
// ];
|
||||
$feature1 = $feature2 = [];
|
||||
foreach ($features as $k => $v) {
|
||||
$feature1[] = $v['features'];
|
||||
if (isset($v['features512']))
|
||||
if (count($v['features512']))
|
||||
$feature2[] = $v['features512'];
|
||||
}
|
||||
$allFeatures[] = [
|
||||
"id" => $value->id,
|
||||
"name" => $this->convert_vi_to_en($value->name),
|
||||
"feature1" => $feature1,
|
||||
"feature2" => $feature2
|
||||
];
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return $allFeatures;
|
||||
}
|
||||
|
||||
public function actionData() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
return ListManagement::find()->orderBy(['last_modified' => SORT_DESC])->all();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionFullData() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$lists = ListManagement::find()->andWhere(["IN", "code", Yii::$app->request->post()])->orderBy(['last_modified' => SORT_DESC])->all();
|
||||
$res = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$f = [];
|
||||
$features = json_decode($value->image, true);
|
||||
foreach ($features as $k => $v) {
|
||||
$f[] = ["url" => base64_encode(file_get_contents(Yii::getAlias('@webroot') . "/data/uploads/face/" . $v['url'])), "features" => $v['features']];
|
||||
}
|
||||
$res[] = [
|
||||
"id" => $value->id,
|
||||
"code" => $value->code,
|
||||
"type" => $value->type,
|
||||
"name" => $value->name,
|
||||
"gender" => $value->gender,
|
||||
"birthday" => $value->birthday,
|
||||
"telephone" => $value->telephone,
|
||||
"department" => $value->address,
|
||||
"time" => $value->time,
|
||||
"images" => $f
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionGetAllImage() {
|
||||
Yii::$app->response->format = "json";
|
||||
$lists = ListManagement::find()->orderBy(['id' => SORT_DESC])->all();
|
||||
$res = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$f = [];
|
||||
$features = json_decode($value->image, true);
|
||||
foreach ($features as $k => $v) {
|
||||
$f[] = Yii::$app->request->hostInfo . "/data/uploads/face/" . $v['url'];
|
||||
}
|
||||
$res[] = [
|
||||
"id" => $value->id,
|
||||
"code" => $value->code,
|
||||
"type" => $value->type,
|
||||
"name" => $value->name,
|
||||
"gender" => $value->gender,
|
||||
"birthday" => $value->birthday,
|
||||
"telephone" => $value->telephone,
|
||||
"address" => $value->address,
|
||||
"time" => $value->time,
|
||||
"image" => $f
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function actionResetData() {
|
||||
// return file_get_contents("https://bischool.beetai.com/view/image/5f7c1b22dfe5aaf427a6dfa1");
|
||||
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
|
||||
}
|
||||
|
||||
public function convert_vi_to_en($str) {
|
||||
$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", "a", $str);
|
||||
$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", "e", $str);
|
||||
$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", "i", $str);
|
||||
$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", "o", $str);
|
||||
$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", "u", $str);
|
||||
$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", "y", $str);
|
||||
$str = preg_replace("/(đ)/", "d", $str);
|
||||
$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", "A", $str);
|
||||
$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", "E", $str);
|
||||
$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", "I", $str);
|
||||
$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", "O", $str);
|
||||
$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", "U", $str);
|
||||
$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", "Y", $str);
|
||||
$str = preg_replace("/(Đ)/", "D", $str);
|
||||
//$str = str_replace(" ", "-", str_replace("&*#39;","",$str));
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getCurrentTime() {
|
||||
$time = microtime();
|
||||
$time = explode(' ', $time);
|
||||
return $time[1] + $time[0];
|
||||
}
|
||||
|
||||
public function actionAutoGenFeature() {
|
||||
Yii::$app->response->format = "json";
|
||||
if (!$this->check512())
|
||||
return ["status" => false];
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
if (!$updating) {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "updating",
|
||||
'data' => "false"
|
||||
]);
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
}
|
||||
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
|
||||
if ($updating->data === "true") {
|
||||
if ($currentCache['n_128'] == $currentCache['n_512']) {
|
||||
$updating->data = "false";
|
||||
$updating->save();
|
||||
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
|
||||
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
|
||||
return ["status" => false];
|
||||
} else {
|
||||
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating";
|
||||
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
|
||||
return ["status" => false];
|
||||
}
|
||||
}
|
||||
|
||||
if ($currentCache['n_128'] == $currentCache['n_512']) {
|
||||
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
|
||||
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
|
||||
return ["status" => false];
|
||||
}
|
||||
|
||||
$updating->data = "true";
|
||||
$updating->save();
|
||||
|
||||
$processTime = [];
|
||||
set_time_limit(0);
|
||||
$lists = ListManagement::find()->all();
|
||||
foreach ($lists as $key => $value) {
|
||||
$extract = false;
|
||||
$images = json_decode($value->image, true);
|
||||
$newImgs = [];
|
||||
$temp = [];
|
||||
foreach ($images as $k => $v) {
|
||||
if (!isset($v['features512']) || (isset($v['features512']) && count($v['features512']) == 0)) {
|
||||
$start = $this->getCurrentTime();
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url'], "type" => "raw"]
|
||||
],
|
||||
"type" => "512"
|
||||
]), true);
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp[] = round(($finish - $start), 4);
|
||||
$v['features512'] = $features['results'][0]['feature512'];
|
||||
$extract = true;
|
||||
}
|
||||
$newImgs[] = $v;
|
||||
}
|
||||
if ($extract) {
|
||||
$processTime['extract'] = $temp;
|
||||
$start = $this->getCurrentTime();
|
||||
$value->image = json_encode($newImgs);
|
||||
$value->save();
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["updateDB"] = round(($finish - $start), 4);
|
||||
$txt = "\n" . json_encode($processTime);
|
||||
file_put_contents(date('Ymd') . ".txt", $txt, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
$updating->data = "false";
|
||||
$updating->save();
|
||||
return ["status" => true];
|
||||
}
|
||||
|
||||
public function actionSync() {
|
||||
Yii::$app->response->format = "json";
|
||||
if ($this->is_connected()) {
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "https://dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
$ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all();
|
||||
|
||||
$tk = "";
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token)
|
||||
$tk = $token->data;
|
||||
foreach ($ls as $key => $value) {
|
||||
$staffInfo = ListManagement::findOne($value->staff_id);
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)),
|
||||
'camera_id' => strval($id_camera),
|
||||
'frametime' => date("Y-m-d H:i:s", $value->time),
|
||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||
"person_id" => "123",
|
||||
"timezone" => "+7"
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
if ($res['status'] == 10000) {
|
||||
$value->sync_status = 1;
|
||||
$value->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ["status" => true];
|
||||
}
|
||||
|
||||
function is_connected($ip = "google.com") {
|
||||
$connected = @fsockopen($ip, 80);
|
||||
//website, port (try 80 or 443)
|
||||
if ($connected) {
|
||||
$is_conn = true; //action when connected
|
||||
fclose($connected);
|
||||
} else {
|
||||
$is_conn = false; //action in connection failure
|
||||
}
|
||||
return $is_conn;
|
||||
}
|
||||
|
||||
public function actionGetNumberPerson() {
|
||||
return ListManagement::find()->count();
|
||||
}
|
||||
|
||||
public function actionGetTotalFeature() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
$start = $this->getCurrentTime();
|
||||
$statistics = ListManagement::statisticFeatures();
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime = round(($finish - $start), 4);
|
||||
return [
|
||||
"statistics" => $statistics,
|
||||
"processTime" => $processTime
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCurrentCache() {
|
||||
return file_get_contents("http://localhost:2305/current-cache");
|
||||
}
|
||||
|
||||
public function actionSaveToken() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token) {
|
||||
$token->data = $post['token'];
|
||||
$token->save();
|
||||
} else {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "token",
|
||||
'data' => $post['token']
|
||||
]);
|
||||
}
|
||||
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
|
||||
if ($version) {
|
||||
$version->data = $post['version'];
|
||||
$version->save();
|
||||
} else {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "version",
|
||||
'data' => $post['version']
|
||||
]);
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function check512() {
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if (!$tempConfig['status'])
|
||||
return false;
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0)
|
||||
return false;
|
||||
|
||||
$checkConfig = json_decode(file_get_contents("http://localhost:4004/ReadConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'path' => $engineConfig['data']['engines'][0]['path']
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
|
||||
if (!$checkConfig['status'])
|
||||
return false;
|
||||
|
||||
$config_json = "";
|
||||
if ($checkConfig['status']) {
|
||||
$config_json = json_decode($checkConfig['data'], true);
|
||||
$check512 = $config_json['feature']['type2']['enable'];
|
||||
if ($check512 !== "0")
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
// $updating = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
$updating = \app\models\SyncUrl::find()->all();
|
||||
foreach ($updating as $key => $value) {
|
||||
echo $value->key_config . " " . $value->data . "<br>";
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
public function actionReGenFeature() {
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
if (!$updating) {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "updating",
|
||||
'data' => "false"
|
||||
]);
|
||||
} else {
|
||||
if ($this->check512()) {
|
||||
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
|
||||
if ($currentCache['n_128'] == $currentCache['n_512']) {
|
||||
$updating->data = "true";
|
||||
} else {
|
||||
$updating->data = "false";
|
||||
}
|
||||
} else
|
||||
$updating->data = "false";
|
||||
$updating->save();
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return ["data" => "reset updating flag"];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
114
controllers/CaptureLogsController.php
Normal file
114
controllers/CaptureLogsController.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\CaptureLogsSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use app\models\ListManagement;
|
||||
|
||||
/**
|
||||
* CaptureLogsController implements the CRUD actions for CaptureLogs model.
|
||||
*/
|
||||
class CaptureLogsController extends Controller {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex($from = "", $to = "", $all = false) {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', "00:00 " . date("d/m/Y")), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', "23:59 " . date("d/m/Y")), 'U');
|
||||
if ($from !== "" && $to !== "") {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', $from), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
|
||||
}
|
||||
|
||||
$this->view->title = "Lịch sử hệ thống";
|
||||
$searchModel = new CaptureLogsSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
if (!$all)
|
||||
$dataProvider->query->andWhere(["capture_logs.staff_id" => 0]);
|
||||
$dataProvider->query->andWhere(["BETWEEN", "capture_logs.time", $f, $t]);
|
||||
|
||||
// $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
// 'http' => [
|
||||
// 'header' => "Content-Type: application/json",
|
||||
// 'method' => "POST"
|
||||
// ]
|
||||
// ])), true);
|
||||
// $data = json_decode($tempConfig['data'], true);
|
||||
// $last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
|
||||
// if (!is_object($last))
|
||||
// $last = (object) ['id' => 0];
|
||||
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'statusArray' => CaptureLogs::$statusArray,
|
||||
'f' => $f,
|
||||
't' => $t,
|
||||
// 'idAuto' => $idAuto,
|
||||
"staffArray" => ListManagement::staffArray()
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionView($id) {
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCreate() {
|
||||
$model = new CaptureLogs();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionUpdate($id) {
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionDelete($id) {
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
if (($model = CaptureLogs::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ class ConfigController extends Controller {
|
|||
}
|
||||
|
||||
public $config_json = [
|
||||
"lang" => "vi",
|
||||
"lang" => "vi",
|
||||
"camera" => [
|
||||
"auto_check" => 1,
|
||||
"num_cam" => 2,
|
||||
|
@ -162,7 +162,7 @@ class ConfigController extends Controller {
|
|||
* @return mixed
|
||||
*/
|
||||
public function actionIndex() {
|
||||
$this->view->title = "Cấu hình thiết bị";
|
||||
$this->view->title = "Cấu hình máy chủ";
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
|
@ -207,9 +207,12 @@ class ConfigController extends Controller {
|
|||
$cfgData = $post['config'];
|
||||
$config_json = [];
|
||||
foreach ($cfgData as $key => $value) {
|
||||
if (is_numeric($value['data'])) {
|
||||
$value['data'] = floatval($value['data']);
|
||||
}
|
||||
// if (is_numeric($value['data'])) {
|
||||
// $value['data'] = floatval($value['data']);
|
||||
// }
|
||||
$value['data'] = trim(strip_tags($value['data']));
|
||||
$value['data'] = str_replace(' ', '', $value['data']);
|
||||
$value['data'] = preg_replace('/\s+/', ' ', $value['data']);
|
||||
|
||||
$pr = explode("|", $value['parent']);
|
||||
if (count($pr) == 1) {
|
||||
|
@ -297,37 +300,55 @@ class ConfigController extends Controller {
|
|||
}
|
||||
|
||||
public function actionReset() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if ($tempConfig['status']) {
|
||||
if ($tempConfig['data'] !== "") {
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0) {
|
||||
$path = "";
|
||||
if (Yii::$app->request->post()) {
|
||||
if (Yii::$app->request->post("resetDevice") === "true") {
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if ($tempConfig['status']) {
|
||||
if ($tempConfig['data'] !== "") {
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0) {
|
||||
$path = "";
|
||||
} else {
|
||||
$path = $engineConfig['data']['engines'][0]['path'];
|
||||
}
|
||||
} else {
|
||||
$path = $engineConfig['data']['engines'][0]['path'];
|
||||
$path = "";
|
||||
}
|
||||
} else {
|
||||
$path = "";
|
||||
}
|
||||
} else {
|
||||
$path = "";
|
||||
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'path' => $path
|
||||
])
|
||||
]
|
||||
]));
|
||||
}
|
||||
if (Yii::$app->request->post("deleteDB") === "true") {
|
||||
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
|
||||
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));
|
||||
try {
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
} catch (\Exception $exc) {
|
||||
|
||||
}
|
||||
}
|
||||
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'path' => $path
|
||||
])
|
||||
]
|
||||
]));
|
||||
return Url::to(['/config']);
|
||||
} else {
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => "Reset thiết bị",
|
||||
"form" => $this->renderPartial("reset")
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,4 +389,42 @@ class ConfigController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionCauHinhThietBi() {
|
||||
$this->view->title = "Cấu hình thiết bị";
|
||||
return $this->render('device', [
|
||||
"server_api" => \app\models\SyncUrl::findOne(['key_config' => 'server_api']),
|
||||
"device_id" => \app\models\SyncUrl::findOne(['key_config' => 'device_id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSaveConfig() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->post();
|
||||
$server_api = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
if ($server_api) {
|
||||
$server_api->data = $post['server_api'];
|
||||
$server_api->save();
|
||||
} else {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => 'server_api',
|
||||
'data' => $post['server_api']
|
||||
]);
|
||||
}
|
||||
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
if ($device_id) {
|
||||
$device_id->data = $post['device_id'];
|
||||
$device_id->save();
|
||||
} else {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => 'device_id',
|
||||
'data' => $post['device_id']
|
||||
]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
145
controllers/ControlLogsController.php
Normal file
145
controllers/ControlLogsController.php
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\CaptureLogsSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use app\models\ListManagement;
|
||||
use yii\helpers\FileHelper;
|
||||
use app\models\common;
|
||||
|
||||
/**
|
||||
* CaptureLogsController implements the CRUD actions for CaptureLogs model.
|
||||
*/
|
||||
class ControlLogsController extends Controller {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex($from = "", $to = "", $name = "", $type = "all", $gender = "all", $id = "") {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', "00:00 " . date("d/m/Y")), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', "23:59 " . date("d/m/Y")), 'U');
|
||||
if ($from !== "" && $to !== "") {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', $from), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
|
||||
}
|
||||
|
||||
$this->view->title = "Danh sách nhận diện";
|
||||
$searchModel = new CaptureLogsSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
$dataProvider->query->andWhere(["<>", "capture_logs.staff_id", 0]);
|
||||
$dataProvider->query->andWhere(["BETWEEN", "capture_logs.time", $f, $t]);
|
||||
if ($id !== "")
|
||||
$dataProvider->query->andWhere(["LIKE", "list_management.code", $id]);
|
||||
if ($name !== "")
|
||||
$dataProvider->query->andWhere(["LIKE", "list_management.name", $name]);
|
||||
if ($type !== "all")
|
||||
$dataProvider->query->andWhere(["list_management.type" => $type]);
|
||||
if ($gender !== "all")
|
||||
$dataProvider->query->andWhere(["list_management.gender" => $gender]);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'statusArray' => CaptureLogs::$statusArray,
|
||||
'f' => $f,
|
||||
't' => $t,
|
||||
'typeArray' => ListManagement::$typeArray,
|
||||
'genderArray' => ListManagement::$genderArray
|
||||
]);
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
if (($model = CaptureLogs::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionUseFeature($id) {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
$model = $this->findModel($id);
|
||||
$listManagement = ListManagement::findOne($model->staff_id);
|
||||
if ($listManagement) {
|
||||
$url = $model->image;
|
||||
$images = json_decode($listManagement->image, true);
|
||||
if (count($images) >= \Yii::$app->params['maxPicture'])
|
||||
return ["status" => false, "text" => "Mỗi đối tượng chỉ nhận tối đa " . \Yii::$app->params['maxPicture'] . " hình ảnh mẫu"];
|
||||
$add = true;
|
||||
foreach ($images as $key => $value) {
|
||||
if (isset($value['urlOld']) && $value['urlOld'] === $url)
|
||||
$add = false;
|
||||
}
|
||||
if ($add) {
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$img = file_get_contents("http://localhost/data/uploads/face/" . $url);
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
if (!$this->resizeImg($img, $fileTarget))
|
||||
$fileName = $url;
|
||||
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$images[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $url,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
$listManagement->image = json_encode($images);
|
||||
$listManagement->last_modified = time();
|
||||
$listManagement->save();
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $listManagement->id,
|
||||
"name" => common::convert_vi_to_en($listManagement->name),
|
||||
"features" => $listManagement->allFeatures
|
||||
]);
|
||||
return ["status" => true];
|
||||
}
|
||||
return ["status" => false, "text" => "Hình ảnh này đã được chọn làm mẫu cho đối tượng này!"];
|
||||
}
|
||||
return ["status" => false, "text" => "Đối tượng không tồn tại!"];
|
||||
}
|
||||
}
|
||||
|
||||
public function resizeImg($img, $fileTarget) {
|
||||
$im = imagecreatefromstring($img);
|
||||
$width = imagesx($im);
|
||||
$height = imagesy($im);
|
||||
$newwidth = 224;
|
||||
$newheight = 224;
|
||||
if ($width > $newwidth && $height > $newheight) {
|
||||
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
||||
imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
imagejpeg($thumb, $fileTarget);
|
||||
imagedestroy($thumb);
|
||||
imagedestroy($im);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
755
controllers/ListManagementController.php
Normal file
755
controllers/ListManagementController.php
Normal file
|
@ -0,0 +1,755 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\ListManagement;
|
||||
use app\models\ListManagementSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\common;
|
||||
use yii\helpers\FileHelper;
|
||||
|
||||
/**
|
||||
* ListMamagementController implements the CRUD actions for ListMamagement model.
|
||||
*/
|
||||
class ListManagementController extends Controller {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex($from = "", $to = "", $name = "", $type = "all", $gender = "all", $id = "") {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', "00:00 " . date("d/m/Y")), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', "23:59 " . date("d/m/Y")), 'U');
|
||||
$this->view->title = "Quản lý mẫu";
|
||||
$searchModel = new ListManagementSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
if ($from !== "" && $to !== "") {
|
||||
$f = date_format(date_create_from_format('H:i d/m/Y', $from), 'U');
|
||||
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
|
||||
$dataProvider->query->andWhere(["BETWEEN", "time", $f, $t]);
|
||||
}
|
||||
if ($id !== "")
|
||||
$dataProvider->query->andWhere(["LIKE", "code", $id]);
|
||||
if ($name !== "")
|
||||
$dataProvider->query->andWhere(["LIKE", "name", $name]);
|
||||
if ($type !== "all")
|
||||
$dataProvider->query->andWhere(["type" => $type]);
|
||||
if ($gender !== "all")
|
||||
$dataProvider->query->andWhere(["gender" => $gender]);
|
||||
$dataProvider->query->orderBy(["time" => SORT_DESC]);
|
||||
|
||||
// $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
// 'http' => [
|
||||
// 'header' => "Content-Type: application/json",
|
||||
// 'method' => "POST"
|
||||
// ]
|
||||
// ])), true);
|
||||
// $data = json_decode($tempConfig['data'], true);
|
||||
// $last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
|
||||
// if (!is_object($last))
|
||||
// $last = (object) ['id' => 0];
|
||||
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
if (!$updating) {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "updating",
|
||||
'data' => "false"
|
||||
]);
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
}
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'f' => $f,
|
||||
't' => $t,
|
||||
'typeArray' => ListManagement::$typeArray,
|
||||
'genderArray' => ListManagement::$genderArray,
|
||||
// 'idAuto' => $idAuto,
|
||||
"staffArray" => ListManagement::staffArray(),
|
||||
"updating" => $updating
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAdd() {
|
||||
$model = new ListManagement();
|
||||
Yii::$app->response->format = "json";
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$check = ListManagement::findOne(['code' => $data['code']]);
|
||||
if ($check)
|
||||
return ["status" => false];
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $data['image'], "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$data['image'] = json_encode([
|
||||
[
|
||||
"url" => $data['image'],
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
]
|
||||
]);
|
||||
$model->create($data);
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCreate() {
|
||||
$model = new ListManagement();
|
||||
Yii::$app->response->format = "json";
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$listManagement = ListManagement::findOne(['code' => $data['code']]);
|
||||
$url = CaptureLogs::findOne($data['id'])->image;
|
||||
if ($listManagement) {
|
||||
$images = json_decode($listManagement->image, true);
|
||||
if (count($images) >= \Yii::$app->params['maxPicture'])
|
||||
return ["status" => false, "text" => "Mỗi đối tượng chỉ nhận tối đa " . \Yii::$app->params['maxPicture'] . " hình ảnh mẫu"];
|
||||
$add = true;
|
||||
foreach ($images as $key => $value) {
|
||||
if (isset($value['urlOld']) && $value['urlOld'] === $url)
|
||||
$add = false;
|
||||
}
|
||||
if ($add) {
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$img = file_get_contents("http://localhost/data/uploads/face/" . $url);
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
if (!$this->resizeImg($img, $fileTarget))
|
||||
$fileName = $url;
|
||||
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$images[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $url,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
$listManagement->type = $data['type'];
|
||||
$listManagement->name = $data['name'];
|
||||
$listManagement->gender = $data['gender'];
|
||||
$listManagement->birthday = $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U');
|
||||
$listManagement->telephone = $data['telephone'];
|
||||
$listManagement->address = $data['address'];
|
||||
$listManagement->image = json_encode($images);
|
||||
$listManagement->last_modified = time();
|
||||
$listManagement->save();
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $listManagement->id,
|
||||
"name" => common::convert_vi_to_en($listManagement->name),
|
||||
"features" => $listManagement->allFeatures
|
||||
]);
|
||||
return ["status" => true];
|
||||
}
|
||||
return ["status" => false, "text" => "Hình ảnh này đã được chọn làm mẫu cho đối tượng này!"];
|
||||
} else {
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$img = file_get_contents("http://localhost/data/uploads/face/" . $url);
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
if (!$this->resizeImg($img, $fileTarget))
|
||||
$fileName = $url;
|
||||
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$data['image'] = json_encode([
|
||||
[
|
||||
"url" => $fileName,
|
||||
"urlOld" => $url,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
]
|
||||
]);
|
||||
$model->create($data);
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function actionFormUpdate() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$ListManagement = $this->findModel($data['id']);
|
||||
$images = json_decode($ListManagement->image, true);
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"type" => $ListManagement->type,
|
||||
"code" => $ListManagement->code,
|
||||
"name" => $ListManagement->name,
|
||||
"gender" => $ListManagement->gender,
|
||||
"birthday" => date("d/m/Y", $ListManagement->birthday),
|
||||
"telephone" => $ListManagement->telephone,
|
||||
"address" => $ListManagement->address,
|
||||
"image" => count($images) > 0 ? "/data/uploads/face/" . $images[0]['url'] : "/images/user2-160x160.jpg",
|
||||
"canUpload" => count($images) >= Yii::$app->params['maxPicture'] ? false : true
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpdate() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$model = $this->findModel($data['id']);
|
||||
$check = ListManagement::findOne(['code' => $data['code']]);
|
||||
if ($check && $check->id != $model->id)
|
||||
return false;
|
||||
if ($data['image'] !== "") {
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$img = file_get_contents("http://localhost/data/uploads/face/" . $data['image']);
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
if (!$this->resizeImg($img, $fileTarget))
|
||||
$fileName = $data['image'];
|
||||
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$images = json_decode($model->image, true);
|
||||
$images[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $data['image'],
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
$model->image = json_encode($images);
|
||||
}
|
||||
$model->code = $data['code'];
|
||||
$model->type = $data['type'];
|
||||
$model->name = $data['name'];
|
||||
$model->gender = $data['gender'];
|
||||
$model->birthday = $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U');
|
||||
$model->telephone = $data['telephone'];
|
||||
$model->address = $data['address'];
|
||||
$model->last_modified = time();
|
||||
$model->save();
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionDelete() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$model = $this->findModel($data['id']);
|
||||
$images = json_decode($model->image, true);
|
||||
foreach ($images as $k => $v) {
|
||||
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
|
||||
}
|
||||
common::updateFeature([
|
||||
"cmd" => "delete",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => []
|
||||
]);
|
||||
$model->delete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionDeleteFeature() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$model = $this->findModel($data['id']);
|
||||
$images = json_decode($model->image, true);
|
||||
$features = [];
|
||||
foreach ($images as $key => $value) {
|
||||
if ($value['url'] !== $data['image'])
|
||||
$features[] = $value;
|
||||
else {
|
||||
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value['url']);
|
||||
}
|
||||
}
|
||||
$model->image = json_encode($features);
|
||||
$model->save();
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
if (($model = ListManagement::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionBatchDelete() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
Yii::$app->response->format = "json";
|
||||
foreach ($data['lists'] as $key => $value) {
|
||||
$staff = ListManagement::findOne($value);
|
||||
if ($staff) {
|
||||
$images = json_decode($staff->image, true);
|
||||
foreach ($images as $k => $v) {
|
||||
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
|
||||
}
|
||||
if (count($data['lists']) <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "delete",
|
||||
"id" => $staff->id,
|
||||
"name" => common::convert_vi_to_en($staff->name),
|
||||
"features" => []
|
||||
]);
|
||||
$staff->delete();
|
||||
}
|
||||
}
|
||||
if (count($data['lists']) > 10)
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpload() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$model = new common();
|
||||
Yii::$app->response->format = "json";
|
||||
$url = $model->UploadFile("AnhNhanVien", ["PNG", "JPG", "JPEG", "GIF"], "temp");
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/" . $url, "type" => "crop"]
|
||||
]
|
||||
]), true);
|
||||
unlink("/var/www/html/BiFace_Server_Lite/web/" . $url);
|
||||
if ($features['results'][0]['crop'] === "") {
|
||||
return ["status" => false];
|
||||
} else {
|
||||
$key = common::generateRandomString();
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
file_put_contents($targetPath . "/" . $fileName, base64_decode($features['results'][0]['crop']));
|
||||
return ["status" => true, "url" => $fileName, "dataPath" => "data/uploads/face/"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function actionFormSync() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$results = json_decode(file_get_contents("http://" . $data['ip'] . "/api/data", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode(ListManagement::nameArray())
|
||||
]
|
||||
])), true);
|
||||
$filters = [];
|
||||
foreach ($results as $key => $value) {
|
||||
$filters[$value['code']] = $value['code'] . " - " . $value['name'] . " - " . $value['address'];
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => $data['ip'],
|
||||
"form" => $this->renderPartial("list", [
|
||||
"results" => $results,
|
||||
"typeArray" => ListManagement::$typeArray,
|
||||
"filters" => $filters,
|
||||
"ip" => $data['ip']
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncFromServer() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "https://dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
|
||||
$datas = json_decode(file_get_contents($ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => $id_camera,
|
||||
"ids_staff" => []
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
$filters = [];
|
||||
foreach ($datas['data'] as $key => $value) {
|
||||
$filters[$value['code']] = $value['code'] . " - " . $value['name'] . " - " . $value['department'];
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => "<i class='fa fa-download'></i> Đồng bộ từ máy chủ",
|
||||
"form" => $this->renderPartial("list-server", [
|
||||
"datas" => $datas['data'],
|
||||
"filters" => $filters,
|
||||
"allID" => ListManagement::getAllID()
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentTime() {
|
||||
$time = microtime();
|
||||
$time = explode(' ', $time);
|
||||
return $time[1] + $time[0];
|
||||
}
|
||||
|
||||
public function actionSyncFeature() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$processTime = [];
|
||||
$totalStart = $this->getCurrentTime();
|
||||
$totals = intval(Yii::$app->request->post("totals"));
|
||||
// $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
// $ip = "https://dev-dc.beetai.com";
|
||||
// if ($server_ip)
|
||||
// $ip = $server_ip->data;
|
||||
// $device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
// $id_camera = 209;
|
||||
// if ($device_id)
|
||||
// $id_camera = intval($device_id->data);
|
||||
// $start = $this->getCurrentTime();
|
||||
// $res = json_decode(file_get_contents($ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||
// 'http' => [
|
||||
// 'header' => "Content-Type: application/json",
|
||||
// 'method' => "POST",
|
||||
// 'content' => json_encode([
|
||||
// "id_camera" => $id_camera,
|
||||
// "ids_staff" => [strval(Yii::$app->request->post("id"))]
|
||||
// ])
|
||||
// ]
|
||||
// ])), true);
|
||||
// $finish = $this->getCurrentTime();
|
||||
// $processTime["requestToAPI"] = round(($finish - $start), 4);
|
||||
|
||||
$data = Yii::$app->request->post("id"); //$res['data'][0];
|
||||
$ft = [];
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$extractFeature = [];
|
||||
if (isset($data['images'])) {
|
||||
foreach ($data['images'] as $key => $value) {
|
||||
if ($key < Yii::$app->params['maxPicture']) {
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$start = $this->getCurrentTime();
|
||||
$img = false;
|
||||
try {
|
||||
$img = file_get_contents(str_replace("&", "&", $value));
|
||||
// $img = file_get_contents($value);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["getIMG"] = round(($finish - $start), 4);
|
||||
if ($img && $img !== "null") {
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
$start = $this->getCurrentTime();
|
||||
if (!$this->resizeImg($img, $fileTarget)) {
|
||||
file_put_contents($fileTarget, $img);
|
||||
}
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["saveIMG"] = round(($finish - $start), 4);
|
||||
$start = $this->getCurrentTime();
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
],
|
||||
"type" => "128"
|
||||
]), true);
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["extract"] = round(($finish - $start), 4);
|
||||
$ft[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => []//isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
}
|
||||
$extractFeature[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
$processTime["extractFeature"] = $extractFeature;
|
||||
$start = $this->getCurrentTime();
|
||||
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["getLM"] = round(($finish - $start), 4);
|
||||
if ($model) {
|
||||
$model->name = $data['name'];
|
||||
$model->address = $data['department'];
|
||||
$model->image = json_encode($ft);
|
||||
$model->last_modified = time();
|
||||
$model->save();
|
||||
if ($totals <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
} else {
|
||||
$start = $this->getCurrentTime();
|
||||
$model = new ListManagement();
|
||||
$model->create([
|
||||
'code' => strval($data['idStaff']),
|
||||
'type' => "wl",
|
||||
'name' => $data['name'],
|
||||
'image' => json_encode($ft),
|
||||
'gender' => "Male",
|
||||
'birthday' => "",
|
||||
'telephone' => "",
|
||||
'address' => $data['department']
|
||||
]);
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["insertDB"] = round(($finish - $start), 4);
|
||||
if ($totals <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "create",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
}
|
||||
$totalFinish = $this->getCurrentTime();
|
||||
$processTime["total"] = round(($totalFinish - $totalStart), 4);
|
||||
$processTime["id"] = strval($data['idStaff']);
|
||||
return $processTime; //["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncFeatureFromDevice() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$data = Yii::$app->request->post();
|
||||
$totals = intval($data['totals']);
|
||||
$results = json_decode(file_get_contents("http://" . $data['ip'] . "/api/full-data", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([$data['id']])
|
||||
]
|
||||
])), true);
|
||||
foreach ($results as $key => $value) {
|
||||
$images = [];
|
||||
$imagesReverse = array_reverse($value['images']);
|
||||
foreach ($imagesReverse as $k => $v) {
|
||||
if ($k < Yii::$app->params['maxPicture']) {
|
||||
$key = common::generateRandomString();
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
file_put_contents($targetPath . "/" . $fileName, base64_decode($v['url']));
|
||||
$images[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $fileName,
|
||||
"features" => $v['features'],
|
||||
"features512" => isset($v['features512']) ? $v['features512'] : []
|
||||
];
|
||||
}
|
||||
}
|
||||
$model = ListManagement::findOne(['code' => $value['code']]);
|
||||
if ($model) {
|
||||
$model->type = $value['type'];
|
||||
$model->name = $value['name'];
|
||||
$model->image = json_encode($images);
|
||||
$model->gender = $value['gender'];
|
||||
$model->birthday = $value['birthday'];
|
||||
$model->telephone = $value['telephone'];
|
||||
$model->address = $value['department'];
|
||||
$model->save();
|
||||
if ($totals <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
} else {
|
||||
$model = new ListManagement();
|
||||
$model->create([
|
||||
'code' => $value['code'],
|
||||
'type' => $value['type'],
|
||||
'name' => $value['name'],
|
||||
'image' => json_encode($images),
|
||||
'gender' => $value['gender'],
|
||||
'birthday' => date("d/m/Y", $value['birthday']),
|
||||
'telephone' => $value['telephone'],
|
||||
'address' => $value['department'],
|
||||
'time' => $value['time']
|
||||
]);
|
||||
if ($totals <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "create",
|
||||
"id" => $model->id,
|
||||
"name" => common::convert_vi_to_en($model->name),
|
||||
"features" => $model->allFeatures
|
||||
]);
|
||||
}
|
||||
}
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpdateFeature() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
file_get_contents("http://localhost:2305/update-feature?total=" . ListManagement::find()->count());
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionChooseStaff() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->post();
|
||||
$staff = ListManagement::findOne(['code' => $post['code']]);
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"name" => $staff->name,
|
||||
"gender" => $staff->gender,
|
||||
"birthday" => date("d/m/Y", $staff->birthday),
|
||||
"telephone" => $staff->telephone,
|
||||
"department" => $staff->address
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncToServer() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
$datas = ListManagement::find()->orderBy(["code" => SORT_ASC])->all();
|
||||
$filters = [];
|
||||
foreach ($datas as $key => $value) {
|
||||
$filters[$value->code] = $value->code . " - " . $value->name . " - " . $value->address;
|
||||
}
|
||||
return [
|
||||
"title" => "<i class='fa fa-upload'></i> Đồng bộ lên máy chủ",
|
||||
"form" => $this->renderPartial("list-to-server", [
|
||||
"datas" => $datas,
|
||||
"filters" => $filters
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncFeatureToServer() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "https://dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
|
||||
$StaffInfo = ListManagement::findOne(["code" => Yii::$app->request->post("id")]);
|
||||
$lsImgs = json_decode($StaffInfo->image, true);
|
||||
$images = [];
|
||||
foreach ($lsImgs as $key => $value) {
|
||||
try {
|
||||
$images[] = base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value['url']));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
$items = [
|
||||
"name" => $StaffInfo->name,
|
||||
"code" => $StaffInfo->code,
|
||||
"department" => $StaffInfo->address,
|
||||
"birthday" => date("Y-m-d", $StaffInfo->birthday),
|
||||
"gender" => $StaffInfo == "Male" ? 1 : 0,
|
||||
"telephone" => $StaffInfo->telephone,
|
||||
"images" => $images
|
||||
];
|
||||
$start = $this->getCurrentTime();
|
||||
try {
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/data_sync_pro", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => $id_camera,
|
||||
"items" => [$items]
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime = round(($finish - $start), 4);
|
||||
return $processTime; //$res; //["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function resizeImg($img, $fileTarget) {
|
||||
$im = imagecreatefromstring($img);
|
||||
$width = imagesx($im);
|
||||
$height = imagesy($im);
|
||||
$newwidth = 224;
|
||||
$newheight = 224;
|
||||
if ($width > $newwidth && $height > $newheight) {
|
||||
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
||||
imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
imagejpeg($thumb, $fileTarget);
|
||||
imagedestroy($thumb);
|
||||
imagedestroy($im);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
return file_get_contents("http://minio1.beetai.com/biface-school/origin/385/454_20201126101221879048.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin%2F20201230%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201230T081350Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=df7586a01bb128c0585edd87d1024b1ddb33483fd335e81238103fd2467b4772");
|
||||
}
|
||||
|
||||
}
|
158
helpers/CaptureLogsGrid.php
Normal file
158
helpers/CaptureLogsGrid.php
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?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 = isset($confidence['id1']) ? \app\models\ListManagement::findOne($confidence['id1']) : false;
|
||||
$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" => isset($confidence['percent1']) ? $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 "";
|
||||
};
|
||||
}
|
||||
|
||||
}
|
89
helpers/ListManagementGrid.php
Normal file
89
helpers/ListManagementGrid.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace app\helpers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class ListManagementGrid {
|
||||
|
||||
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 birthday() {
|
||||
return function($model) {
|
||||
return date("d/m/Y", $model->birthday);
|
||||
};
|
||||
}
|
||||
|
||||
public static function image() {
|
||||
return function($model) {
|
||||
$images = json_decode($model->image, true);
|
||||
$return = [];
|
||||
foreach ($images as $key => $value) {
|
||||
$removeBtn = Html::button("<i class='fa fa-remove'></i>", [
|
||||
"class" => "btn btn-danger btn-xs",
|
||||
"style" => "position:absolute;top:0;right:0;visibility: hidden;",
|
||||
"onclick" => "_deleteFeature(this);",
|
||||
"data-img" => $value['url'],
|
||||
"data-id" => $model->id,
|
||||
"data-href" => Url::to(["/list-management/delete-feature"])
|
||||
]);
|
||||
$return[] = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $value['url'], [
|
||||
"class" => "img-thumbnail",
|
||||
"style" => "width: 100px;height:100px;"
|
||||
]) . $removeBtn . "</div>";
|
||||
}
|
||||
return implode(" ", $return);
|
||||
};
|
||||
}
|
||||
|
||||
public static function type($typeArray) {
|
||||
return function($model) use ($typeArray) {
|
||||
return $typeArray[$model->type];
|
||||
};
|
||||
}
|
||||
|
||||
public static function gender($genderArray) {
|
||||
return function($model) use ($genderArray) {
|
||||
return $genderArray[$model->gender];
|
||||
};
|
||||
}
|
||||
|
||||
public static function rows() {
|
||||
return function($model, $index, $widget, $grid) {
|
||||
return [
|
||||
"ondblclick" => "_menu(this);",
|
||||
"style" => "cursor: pointer;",
|
||||
"data" => [
|
||||
"id" => $model->id
|
||||
]
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
}
|
83
models/CaptureLogs.php
Normal file
83
models/CaptureLogs.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "capture_logs".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $staff_id
|
||||
* @property int $time
|
||||
* @property string $image
|
||||
* @property int $status
|
||||
* @property string $remark
|
||||
* @property string $confidence
|
||||
* @property int $sync_status
|
||||
*/
|
||||
class CaptureLogs extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'capture_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['staff_id', 'time', 'status', 'sync_status'], 'integer'],
|
||||
[['image', 'remark', 'confidence'], 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'time' => 'Thời gian',
|
||||
'image' => 'Hình ảnh',
|
||||
'status' => 'Status',
|
||||
'remark' => 'Remark',
|
||||
'staff_name' => "Name",
|
||||
'staff_image' => "Hình ảnh đăng kí",
|
||||
'confidence' => 'Độ tin cậy',
|
||||
'sync_status' => 'Trạng thái đồng bộ'
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'staff_id' => $data['Staff'],
|
||||
'time' => $data['Time'],
|
||||
'image' => $data["Image"],
|
||||
'status' => 0,
|
||||
'remark' => '',
|
||||
'confidence' => $data["Confidence"]
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static $statusArray = [
|
||||
0 => "Unknown",
|
||||
1 => "List management"
|
||||
];
|
||||
|
||||
public function getListManagement() {
|
||||
return $this->hasOne(ListManagement::className(), ["id" => "staff_id"]);
|
||||
}
|
||||
|
||||
}
|
74
models/CaptureLogsSearch.php
Normal file
74
models/CaptureLogsSearch.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\CaptureLogs;
|
||||
|
||||
/**
|
||||
* CaptureLogsSearch represents the model behind the search form of `app\models\CaptureLogs`.
|
||||
*/
|
||||
class CaptureLogsSearch extends CaptureLogs {
|
||||
|
||||
public $staff_name;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['id', 'time', 'status'], 'integer'],
|
||||
[['image', 'remark', 'staff_name', 'confidence'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios() {
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params) {
|
||||
$query = CaptureLogs::find();
|
||||
$query->joinWith("listManagement");
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' => ['defaultOrder' => ['time' => SORT_DESC]],
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'time' => $this->time,
|
||||
'status' => $this->status,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'image', $this->image])
|
||||
->andFilterWhere(['like', 'remark', $this->remark]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
165
models/ListManagement.php
Normal file
165
models/ListManagement.php
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "list_management".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $code
|
||||
* @property string $type
|
||||
* @property string $name
|
||||
* @property string $image
|
||||
* @property string $gender
|
||||
* @property int $birthday
|
||||
* @property string $telephone
|
||||
* @property string $address
|
||||
* @property int $time
|
||||
* @property int $last_modified
|
||||
*/
|
||||
class ListManagement extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'list_management';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['type', 'name', 'gender', 'telephone', 'address', 'image', 'code'], 'string'],
|
||||
[['birthday', 'time', 'last_modified'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'code' => 'ID',
|
||||
'type' => 'Loại',
|
||||
'name' => 'Tên',
|
||||
'image' => 'Hình ảnh đăng kí',
|
||||
'gender' => 'Giới tính',
|
||||
'birthday' => 'Ngày sinh',
|
||||
'telephone' => 'Điện thoại',
|
||||
'address' => 'Đơn vị',
|
||||
'time' => 'Thời gian đăng kí',
|
||||
'last_modified' => 'Last Modified'
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'code' => $data['code'],
|
||||
'type' => $data['type'],
|
||||
'name' => $data['name'],
|
||||
'image' => $data['image'],
|
||||
'gender' => $data['gender'],
|
||||
'birthday' => $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U'),
|
||||
'telephone' => $data['telephone'],
|
||||
'address' => $data['address'],
|
||||
'time' => time(),
|
||||
'last_modified' => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static $typeArray = [
|
||||
"wl" => "Whitelist",
|
||||
"bl" => "Blacklist"
|
||||
];
|
||||
public static $genderArray = [
|
||||
"Male" => "Nam",
|
||||
"Female" => "Nữ"
|
||||
];
|
||||
|
||||
public static function nameArray() {
|
||||
$res = [""];
|
||||
$ls = self::find()->all();
|
||||
foreach ($ls as $key => $value) {
|
||||
$res[] = $value->name;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function getAllID() {
|
||||
$res = [];
|
||||
$ls = self::find()->all();
|
||||
foreach ($ls as $key => $value) {
|
||||
$res[] = $value->code;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function staffArray() {
|
||||
$res = [];
|
||||
$ls = self::find()->all();
|
||||
foreach ($ls as $key => $value) {
|
||||
$res[$value->code] = $value->code . " - " . $value->name;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getAllFeatures() {
|
||||
$features = json_decode($this->image, true);
|
||||
// $f = [];
|
||||
// foreach ($features as $k => $v) {
|
||||
// $f[] = $v['features'];
|
||||
// if (isset($v['features512']))
|
||||
// if (count($v['features512']))
|
||||
// $f[] = $v['features512'];
|
||||
// }
|
||||
$feature1 = $feature2 = [];
|
||||
foreach ($features as $k => $v) {
|
||||
$feature1[] = $v['features'];
|
||||
if (isset($v['features512']))
|
||||
if (count($v['features512']))
|
||||
$feature2[] = $v['features512'];
|
||||
}
|
||||
return [
|
||||
"feature1" => $feature1,
|
||||
"feature2" => $feature2
|
||||
];
|
||||
}
|
||||
|
||||
public static function statisticFeatures() {
|
||||
$lists = self::find()->all();
|
||||
$total128 = $total512 = $totalImg = $img = 0;
|
||||
foreach ($lists as $key => $value) {
|
||||
$images = json_decode($value->image, true);
|
||||
if (count($images) > 0)
|
||||
$totalImg++;
|
||||
$img += count($images);
|
||||
foreach ($images as $k => $v) {
|
||||
if (isset($v['features']) && count($v['features']) > 0)
|
||||
$total128++;
|
||||
if (isset($v['features512']) && count($v['features512']) > 0)
|
||||
$total512++;
|
||||
}
|
||||
}
|
||||
return [
|
||||
"total" => count($lists),
|
||||
"totalImg" => $totalImg,
|
||||
"img" => $img,
|
||||
"128" => $total128,
|
||||
"512" => $total512
|
||||
];
|
||||
}
|
||||
|
||||
}
|
72
models/ListManagementSearch.php
Normal file
72
models/ListManagementSearch.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\ListManagement;
|
||||
|
||||
/**
|
||||
* ListMamagementSearch represents the model behind the search form of `app\models\ListManagement`.
|
||||
*/
|
||||
class ListManagementSearch extends ListManagement {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['id', 'birthday'], 'integer'],
|
||||
[['type', 'name', 'gender', 'telephone', 'address'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios() {
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params) {
|
||||
$query = ListManagement::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'birthday' => $this->birthday,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'type', $this->type])
|
||||
->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'gender', $this->gender])
|
||||
->andFilterWhere(['like', 'telephone', $this->telephone])
|
||||
->andFilterWhere(['like', 'address', $this->address]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ use Yii;
|
|||
* This is the model class for table "sync_url".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $key_config
|
||||
* @property string $data
|
||||
*/
|
||||
class SyncUrl extends \yii\db\ActiveRecord {
|
||||
|
@ -25,7 +26,7 @@ class SyncUrl extends \yii\db\ActiveRecord {
|
|||
public function rules() {
|
||||
return [
|
||||
[['data'], 'required'],
|
||||
[['data'], 'string'],
|
||||
[['data', 'key_config'], 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -36,12 +37,14 @@ class SyncUrl extends \yii\db\ActiveRecord {
|
|||
return [
|
||||
'id' => 'ID',
|
||||
'data' => 'Data',
|
||||
'key_config' => 'Key Config'
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'data' => $data['url'],
|
||||
'key_config' => $data['key_config'],
|
||||
'data' => $data['data'],
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
|
|
|
@ -59,7 +59,7 @@ class common extends \yii\db\ActiveRecord {
|
|||
// $now = time();
|
||||
// $range = $now - $time;
|
||||
// if ($range > 60 * 60 * 12) {
|
||||
return date($format, $time);
|
||||
return date($format, $time);
|
||||
// } else {
|
||||
// return Yii::$app->formatter->asRelativeTime($time);
|
||||
// }
|
||||
|
@ -171,4 +171,53 @@ class common extends \yii\db\ActiveRecord {
|
|||
return $visible;
|
||||
}
|
||||
|
||||
public static function requestToEngine($path, $data) {
|
||||
return file_get_contents("http://localhost:2305" . $path, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode($data)
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
public static function updateFeature($datas) {
|
||||
return file_get_contents("http://localhost:2305/update-person", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode($datas)
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
public static function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
public static function convert_vi_to_en($str) {
|
||||
$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", "a", $str);
|
||||
$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", "e", $str);
|
||||
$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", "i", $str);
|
||||
$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", "o", $str);
|
||||
$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", "u", $str);
|
||||
$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", "y", $str);
|
||||
$str = preg_replace("/(đ)/", "d", $str);
|
||||
$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", "A", $str);
|
||||
$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", "E", $str);
|
||||
$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", "I", $str);
|
||||
$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", "O", $str);
|
||||
$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", "U", $str);
|
||||
$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", "Y", $str);
|
||||
$str = preg_replace("/(Đ)/", "D", $str);
|
||||
//$str = str_replace(" ", "-", str_replace("&*#39;","",$str));
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
copy.src.files=false
|
||||
copy.src.on.open=false
|
||||
copy.src.target=
|
||||
remote.connection=bf_local-799e1d
|
||||
remote.connection=BiFace-99bab6
|
||||
remote.directory=/BiFace_Server_Lite
|
||||
remote.upload=ON_SAVE
|
||||
run.as=REMOTE
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/E:/BiFace_Server_Lite/controllers/ConfigController.php</file>
|
||||
</group>
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
|
||||
use yii\widgets\Breadcrumbs;
|
||||
use dmstr\widgets\Alert;
|
||||
|
||||
?>
|
||||
<div class="content-wrapper">
|
||||
<!-- <section class="content-header">
|
||||
<?=
|
||||
Breadcrumbs::widget(
|
||||
<?=
|
||||
Breadcrumbs::widget(
|
||||
[
|
||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||
]
|
||||
) ?>
|
||||
)
|
||||
?>
|
||||
</section>-->
|
||||
|
||||
<section class="content" style="padding: 0 0 15px 0;">
|
||||
|
@ -21,8 +22,12 @@ use dmstr\widgets\Alert;
|
|||
</div>
|
||||
|
||||
<footer class="main-footer">
|
||||
<div class="pull-right hidden-xs" style="margin-top: 10px;">
|
||||
<!--<b>Hotline</b> <a href="tel:0912461556">091.246.1556</a>-->
|
||||
<div class="pull-right hidden-xs">
|
||||
<b>Version: </b>
|
||||
<?php
|
||||
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
|
||||
echo $version ? $version->data : Yii::$app->params["version"];
|
||||
?>
|
||||
</div>
|
||||
<!--<strong>Copyright © 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.-->
|
||||
<strong>Copyright © 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved.
|
||||
|
|
|
@ -36,19 +36,29 @@ use yii\widgets\ActiveForm;
|
|||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config']); ?>">
|
||||
<li class="<?php if (Yii::$app->controller->id == "config") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config/cau-hinh-thiet-bi']); ?>">
|
||||
<i class="fa fa-cogs"></i> Cấu hình
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/dashboard']); ?>">
|
||||
<i class="fa fa-database"></i> Dữ liệu
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.resetForm(this);return false;">
|
||||
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.reset(this);return false;">
|
||||
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||
<li class="<?php if (Yii::$app->controller->id == "list-management") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/list-management']); ?>">
|
||||
<i class="fa fa-list"></i> Quản lý mẫu
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "capture-logs") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/capture-logs']); ?>">
|
||||
<i class="fa fa-camera"></i> Lịch sử hệ thống
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "control-logs") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/control-logs']); ?>">
|
||||
<i class="fa fa-database"></i> Danh sách nhận diện
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
168
views/capture-logs/index.tpl
Normal file
168
views/capture-logs/index.tpl
Normal file
|
@ -0,0 +1,168 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\CaptureLogsAsset"}
|
||||
{CaptureLogsAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.row{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
.select2-container {
|
||||
width: 100% !important;
|
||||
}
|
||||
.select2-container--default .select2-selection--single, .select2-selection .select2-selection--single{
|
||||
border-color: green;
|
||||
}
|
||||
</style>
|
||||
<input type="hidden" value="{Url::to(['/capture-logs'])}" name="URL">
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'layout'=> \app\helpers\CaptureLogsGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\CaptureLogsGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'time',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::time()
|
||||
],
|
||||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::image()
|
||||
],
|
||||
[
|
||||
'attribute' => 'confidence',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'format' => "raw",
|
||||
'value' => \app\helpers\CaptureLogsGrid::confidence()
|
||||
],
|
||||
[
|
||||
'attribute' => 'sync_status',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
]
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-right: 30px;">
|
||||
<h4>Tìm kiếm dữ liệu</h4>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Từ</label>
|
||||
<input type="text" class="form-control datepicker" value="{$f|date_format:"H:i d/m/Y"}" name="From">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Đến</label>
|
||||
<input type="text" class="form-control datepicker" value="{$t|date_format:"H:i d/m/Y"}" name="To">
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/capture-logs'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<div>
|
||||
<input type="checkbox" name="AllData" style="width: inherit;" {if Yii::$app->request->get("all")}checked=""{/if}> Hiển thị toàn bộ dữ liệu
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
Quản lý mẫu
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;">
|
||||
<div class='feature-img'>
|
||||
<img src="" class="img-thumbnail" id="closest-img" style="width: 100px;height:100px;">
|
||||
<br>
|
||||
<i id="closest-name"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Danh sách</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Type">
|
||||
<option value="wl">White list</option>
|
||||
<option value="bl">Black list</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">ID</div>
|
||||
<div class="col-md-8">
|
||||
<select name='Code' id='Code' onchange="chooseStaff(this);" data-href="{Url::to("/list-management/choose-staff")}">
|
||||
<option value=""></option>
|
||||
{html_options options=$staffArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Tên</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Giới tính</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Gender">
|
||||
<option value="Male">Nam</option>
|
||||
<option value="Female">Nữ</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Ngày sinh</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Birthday" id="birthday">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Điện thoại</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Telephone">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Đơn vị</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Address">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="hidden" value="" name="CaptureLogsID">
|
||||
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Lưu</button>
|
||||
<button onclick="_close();">Hủy</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
|
@ -142,18 +142,25 @@
|
|||
<div class="container-fluid">
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-8">
|
||||
<div class="mt-element-step">
|
||||
<div class="row step-thin">
|
||||
<div class="col-md-6 bg-grey mt-step-col active">
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">1</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||
Cấu hình thiết bị
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||
</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">2</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||
Cấu hình máy chủ
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||
</div>
|
||||
<div class="col-md-6 bg-grey mt-step-col active">
|
||||
<div class="mt-step-number bg-white font-grey">2</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col active">
|
||||
<div class="mt-step-number bg-white font-grey">3</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||
Cấu hình nhận diện
|
||||
</div>
|
||||
|
|
71
views/config/device.tpl
Normal file
71
views/config/device.tpl
Normal file
|
@ -0,0 +1,71 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\ConfigAsset"}
|
||||
{ConfigAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.input-group-addon{
|
||||
width: 100px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.input-group{
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<div class="container-fluid">
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mt-element-step">
|
||||
<div class="row step-thin">
|
||||
<div class="col-md-4 bg-grey mt-step-col active">
|
||||
<div class="mt-step-number bg-white font-grey">1</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||
Cấu hình thiết bị
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||
</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">2</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||
Cấu hình máy chủ
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||
</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">3</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||
Cấu hình nhận diện
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Engine config</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Server API</div>
|
||||
<input type="input" class="form-control" name="server_api" value="{$server_api->data|default:""}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Device ID</div>
|
||||
<input type="input" class="form-control" name="device_id" value="{$device_id->data|default:""}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-primary" onclick="SaveConfigDevice(this);" data-href="{Url::to(['save-config'])}">
|
||||
<i class="fa fa-floppy-o"></i> Lưu lại
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
|
@ -16,18 +16,25 @@
|
|||
<div class="container-fluid">
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-8">
|
||||
<div class="mt-element-step">
|
||||
<div class="row step-thin">
|
||||
<div class="col-md-6 bg-grey mt-step-col active">
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">1</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||
Cấu hình thiết bị
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||
</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col active">
|
||||
<div class="mt-step-number bg-white font-grey">2</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||
Cấu hình máy chủ
|
||||
</div>
|
||||
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||
</div>
|
||||
<div class="col-md-6 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">2</div>
|
||||
<div class="col-md-4 bg-grey mt-step-col">
|
||||
<div class="mt-step-number bg-white font-grey">3</div>
|
||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||
Cấu hình nhận diện
|
||||
</div>
|
||||
|
|
11
views/config/reset.tpl
Normal file
11
views/config/reset.tpl
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="text-left">
|
||||
<input type="checkbox" name="DeleteDatabase" checked="" style="width: inherit;"> Xóa dữ liệu lưu trữ trong thiết bị
|
||||
<br>
|
||||
<input type="checkbox" name="ResetDevice" checked="" style="width: inherit;"> Reset cấu hình thiết bị
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-danger" onclick="common.reset(this);" data-href="{yii\helpers\Url::to(['/config/reset'])}">
|
||||
Đồng ý
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Hủy bỏ</button>
|
||||
</div>
|
120
views/control-logs/index.tpl
Normal file
120
views/control-logs/index.tpl
Normal file
|
@ -0,0 +1,120 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\ControlLogsAsset"}
|
||||
{ControlLogsAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.row{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
.feature-img{
|
||||
display:inline-block;
|
||||
position: relative;
|
||||
}
|
||||
.feature-img:hover .btn{
|
||||
visibility: visible !important;
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'layout'=> \app\helpers\CaptureLogsGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\CaptureLogsGrid::rowsControlLogs(),
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' => 'id',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'time',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::time()
|
||||
],
|
||||
[
|
||||
'attribute' => 'staff_image',
|
||||
'format' => 'raw',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:15%'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::registrationImage()
|
||||
],
|
||||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:15%'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::image(true)
|
||||
],
|
||||
[
|
||||
'attribute' => 'confidence',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::confidenceControlLogs()
|
||||
],
|
||||
'listManagement.name',
|
||||
'listManagement.gender',
|
||||
'listManagement.telephone',
|
||||
[
|
||||
'attribute' => 'listManagement.birthday',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::birthday()
|
||||
],
|
||||
'listManagement.address',
|
||||
'sync_status'
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-right: 30px;">
|
||||
<h4>Tìm kiếm dữ liệu</h4>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Từ</label>
|
||||
<input type="text" class="form-control datepicker" value="{$f|date_format:"H:i d/m/Y"}" name="From">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Đến</label>
|
||||
<input type="text" class="form-control datepicker" value="{$t|date_format:"H:i d/m/Y"}" name="To">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">ID</label>
|
||||
<input type="text" class="form-control" value="{Yii::$app->request->get("id")}" name="IDSearch">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Tên</label>
|
||||
<input type="text" class="form-control" value="{Yii::$app->request->get("name")}" name="NameSearch">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Loại</label>
|
||||
<select class="form-control" name="TypeSearch">
|
||||
<option value="all">Tất cả</option>
|
||||
{html_options options=$typeArray selected=Yii::$app->request->get("type")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Giới tính</label>
|
||||
<select class="form-control" name="GenderSearch">
|
||||
<option value="all">Tất cả</option>
|
||||
{html_options options=$genderArray selected=Yii::$app->request->get("gender")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/control-logs'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
309
views/list-management/index.tpl
Normal file
309
views/list-management/index.tpl
Normal file
|
@ -0,0 +1,309 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\ListManagementAsset"}
|
||||
{ListManagementAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.row{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
.feature-img{
|
||||
display:inline-block;
|
||||
position: relative;
|
||||
}
|
||||
.feature-img:hover .btn{
|
||||
visibility: visible !important;
|
||||
}
|
||||
.table > tbody > tr.delete-choose > td{
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
}
|
||||
.select2-container {
|
||||
width: 100% !important;
|
||||
}
|
||||
#form-add-staff .select2-container--default .select2-selection--single, .select2-selection .select2-selection--single{
|
||||
border-color: green;
|
||||
}
|
||||
.select2-container--default .select2-selection--single, .select2-selection .select2-selection--single{
|
||||
height: 34px !important;
|
||||
}
|
||||
</style>
|
||||
<input type="hidden" value="{Url::to(["/list-management/add"])}" name="create_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/update"])}" name="update_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/sync-feature"])}" name="sync_feature_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/sync-feature-to-server"])}" name="sync_feature_to_server_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/sync-feature-from-device"])}" name="sync_feature_from_device_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/update-feature"])}" name="update_feature_url">
|
||||
<input type="hidden" value="{Url::to(["/api/get-total-feature"])}" name="get_total_feature_url">
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'layout'=> \app\helpers\ListManagementGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\ListManagementGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' => 'code',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'type',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::type($typeArray)
|
||||
],
|
||||
[
|
||||
'attribute' => 'name',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'gender',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::gender($genderArray)
|
||||
],
|
||||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'value' => \app\helpers\ListManagementGrid::image()
|
||||
],
|
||||
[
|
||||
'attribute' => 'time',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::time()
|
||||
],
|
||||
[
|
||||
'attribute' => 'birthday',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::birthday()
|
||||
],
|
||||
[
|
||||
'attribute' => 'telephone',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'address',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
]
|
||||
],
|
||||
'pager' => [
|
||||
'firstPageLabel' => "<i class='fa fa-backward'></i>",
|
||||
'lastPageLabel' => "<i class='fa fa-forward'></i>",
|
||||
'nextPageLabel' => "<i class='fa fa-chevron-right'></i>",
|
||||
'prevPageLabel' => "<i class='fa fa-chevron-left'></i>",
|
||||
'maxButtonCount' => 5
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-right: 30px;">
|
||||
<h4>Tìm kiếm dữ liệu</h4>
|
||||
{*<div class="form-group">
|
||||
<label class="control-label">Từ</label>
|
||||
<input type="text" class="form-control datepicker" value="{$f|date_format:"H:i d/m/Y"}" name="From">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Đến</label>
|
||||
<input type="text" class="form-control datepicker" value="{$t|date_format:"H:i d/m/Y"}" name="To">
|
||||
</div>*}
|
||||
<div class="form-group">
|
||||
<label class="control-label">ID</label>
|
||||
<input type="text" class="form-control" value="{Yii::$app->request->get("id")}" name="IDSearch">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Tên</label>
|
||||
<input type="text" class="form-control" value="{Yii::$app->request->get("name")}" name="NameSearch">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Loại</label>
|
||||
<select class="form-control" name="TypeSearch">
|
||||
<option value="all">Tất cả</option>
|
||||
{html_options options=$typeArray selected=Yii::$app->request->get("type")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Giới tính</label>
|
||||
<select class="form-control" name="GenderSearch">
|
||||
<option value="all">Tất cả</option>
|
||||
{html_options options=$genderArray selected=Yii::$app->request->get("gender")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/list-management'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<div>
|
||||
<input type="checkbox" name="BatchDelete" style="width: inherit;"> Xóa nhiều dữ liệu
|
||||
<br>
|
||||
<div class="hidden" id="delete-btn-group">
|
||||
<div class="text-center">
|
||||
<button onclick="checkAll(true);">Chọn toàn bộ trang</button>
|
||||
<button onclick="checkAll(false);">Bỏ chọn</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-danger" onclick="batchDelete(this);" data-href="{Url::to(['/list-management/batch-delete'])}">Xác nhận xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<h4>Đồng bộ với máy chủ</h4>
|
||||
<div class="text-center">
|
||||
{*<button class="btn btn-info" onclick="_form();">
|
||||
<i class="fa fa-plus-circle"></i> Thêm mới
|
||||
</button>*}
|
||||
<button class="btn btn-info btn-block" onclick="_syncFromServerForm(this);" data-href="{Url::to(['/list-management/sync-from-server'])}">
|
||||
<i class="fa fa-download"></i> Đồng bộ từ máy chủ
|
||||
</button>
|
||||
<button class="btn btn-success btn-block" onclick="_syncToServerForm(this);" data-href="{Url::to(['/list-management/sync-to-server'])}">
|
||||
<i class="fa fa-upload"></i> Đồng bộ lên máy chủ
|
||||
</button>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<h4>Đồng bộ từ thiết bị khác</h4>
|
||||
<div class="form-group" id="ip">
|
||||
<div class="input-group">
|
||||
<input type="text" value="" class="form-control" name="SyncIP" placeholder="Nhập ip thiết bị">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-info" onclick="_syncForm(this);" data-href="{Url::to(['form-sync'])}">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block hidden"></span>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<table class="table table-bordered" style="background: #fff;">
|
||||
<tr>
|
||||
<td>Số người có ảnh / tổng</td>
|
||||
<td class="text-right" id="totalPeople">
|
||||
{*<b class="text-red">{$statistics.totalImg}</b>/<b>{$statistics.total}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Đặc trưng 1</td>
|
||||
<td class="text-right" id="total128">
|
||||
{* <b class="text-red">{$statistics.128}</b>/<b>{$statistics.img}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Đặc trưng 2
|
||||
{if $updating->data==="true"}
|
||||
<label class="label label-danger" id="updating-label">Đang cập nhật ...</label>
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-right" id="total512">
|
||||
{* <b class="text-red">{$statistics.512}</b>/<b>{$statistics.img}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 300px;position: absolute;" id="menu" class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
Operation menu
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_closeMenu();"></i>
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<button onclick="_formModified(this);" data-href='{Url::to(["/list-management/form-update"])}'>Modified list</button>
|
||||
<button onclick="_delete(this);" data-href="{Url::to(["/list-management/delete"])}">Delete list</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
List management
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;">
|
||||
<div class="" id="upload-btn">
|
||||
<input type="file" name="AnhNhanVien" id="AnhNhanVien">
|
||||
<input type="hidden" name="AnhNhanVienUrl" value="">
|
||||
<input type="hidden" name="url_upload_staff_image" value="{Url::to(['upload'])}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Type</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Type">
|
||||
{html_options options=$typeArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row hidden">
|
||||
<div class="col-md-4 text-right">ID</div>
|
||||
<div class="col-md-8" id="form-add-staff">
|
||||
<select name='Code' id='Code' onchange="chooseStaff(this);" data-href="{Url::to("/list-management/choose-staff")}">
|
||||
<option value=""></option>
|
||||
{html_options options=$staffArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Name</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Gender</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Gender">
|
||||
{html_options options=$genderArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Birthday</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Birthday" id="birthday">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Telephone</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Telephone">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Department</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Address">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="hidden" value="" name="ListManagementID">
|
||||
<button onclick="_update(this);" data-href='{Url::to(["/list-management/update"])}' id="save-btn">Save</button>
|
||||
<button onclick="_close();">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
89
views/list-management/list-server.tpl
Normal file
89
views/list-management/list-server.tpl
Normal file
|
@ -0,0 +1,89 @@
|
|||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Tìm kiếm</div>
|
||||
<select class="form-control" id="filter-from-server" onchange="filters(this);">
|
||||
<option value=""></option>
|
||||
{html_options options=$filters}
|
||||
</select>
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" data-toggle="tooltip" title="Hủy bỏ tìm kiếm" onclick="removeFilters();">
|
||||
<i class="fa fa-remove"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="max-height: 750px;overflow-y: auto;">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Tên</th>
|
||||
<th>Đơn vị</th>
|
||||
<th>Hình ảnh đăng kí</th>
|
||||
<th>Code</th>
|
||||
<th>Company ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sync-lists">
|
||||
{foreach from=$datas item=arr}
|
||||
<tr id="filters-{$arr.code}" onclick="choooseToSync(this);" style="cursor: pointer;" class="filters {if !in_array($arr.idStaff,$allID)}not-in-list{/if}" data-stt="false" data-id="{trim($arr.idStaff)}">
|
||||
<td>
|
||||
<div id="full-data-{trim($arr.idStaff)}" class="hidden">{json_encode($arr)}</div>
|
||||
{$arr.idStaff}
|
||||
{if in_array($arr.idStaff,$allID)}
|
||||
<i class="fa fa-check-circle text-green"></i>
|
||||
{/if}
|
||||
</td>
|
||||
<td>{$arr.name}</td>
|
||||
<td>{$arr.department}</td>
|
||||
<td>
|
||||
{foreach from=$arr.images item=img key=k}
|
||||
{if $k<Yii::$app->params['maxPicture']}
|
||||
<div class='feature-img'>
|
||||
<img src="{$img}" class="img-thumbnail" style="width: 100px;height:100px;">
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>{$arr.code}</td>
|
||||
<td>{$arr.id_company}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<i class="fa fa-info-circle"></i> Đã lựa chọn <b class="text-red" id="totals-choose">0</b> đối tượng.
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="hidden" id="progress-form">
|
||||
Đồng bộ <b id="progress-current" class="text-green">0</b>/<b id="progress-totals" class="text-red">0</b> đối tượng.
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-primary progress-bar-striped" id='progress' role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
||||
0%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5 text-right">
|
||||
<button class="btn btn-default btn-select" onclick="checkAllNotInList();">
|
||||
Chọn đối tượng chưa tồn tại
|
||||
</button>
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(true);">
|
||||
Chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(false);">
|
||||
Bỏ chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-primary" onclick="_syncFromServer();">
|
||||
<i class="fa fa-refresh"></i> Đồng bộ
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-remove"></span> Đóng lại</button>
|
||||
</div>
|
||||
</div>
|
81
views/list-management/list-to-server.tpl
Normal file
81
views/list-management/list-to-server.tpl
Normal file
|
@ -0,0 +1,81 @@
|
|||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Tìm kiếm</div>
|
||||
<select class="form-control" id="filter-from-server" onchange="filters(this);">
|
||||
<option value=""></option>
|
||||
{html_options options=$filters}
|
||||
</select>
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" data-toggle="tooltip" title="Hủy bỏ tìm kiếm" onclick="removeFilters();">
|
||||
<i class="fa fa-remove"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="max-height: 750px;overflow-y: auto;">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Tên</th>
|
||||
<th>Giới tính</th>
|
||||
<th>Hình ảnh đăng kí</th>
|
||||
<th>Ngày sinh</th>
|
||||
<th>Điện thoại</th>
|
||||
<th>Đơn vị</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sync-lists">
|
||||
{foreach from=$datas item=arr}
|
||||
<tr id="filters-{$arr.code}" class="filters" onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr->code}">
|
||||
<td>{$arr->code}</td>
|
||||
<td>{$arr->name}</td>
|
||||
<td>{$arr->gender}</td>
|
||||
<td>
|
||||
{$images = json_decode($arr->image, true)}
|
||||
{foreach from=$images item=img}
|
||||
<div class='feature-img'>
|
||||
<img src="/data/uploads/face/{$img.url}" class="img-thumbnail" style="width: 100px;height:100px;">
|
||||
</div>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>{$arr->birthday|date_format:"%d/%m/%Y"}</td>
|
||||
<td>{$arr->telephone}</td>
|
||||
<td>{$arr->address}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<i class="fa fa-info-circle"></i> Đã lựa chọn <b class="text-red" id="totals-choose">0</b> đối tượng.
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="hidden" id="progress-form">
|
||||
Đồng bộ <b id="progress-current" class="text-green">0</b>/<b id="progress-totals" class="text-red">0</b> đối tượng.
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-primary progress-bar-striped" id='progress' role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
||||
0%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(true);">
|
||||
Chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(false);">
|
||||
Bỏ chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-primary" onclick="_syncToServer();">
|
||||
<i class="fa fa-refresh"></i> Đồng bộ
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-remove"></span> Đóng lại</button>
|
||||
</div>
|
||||
</div>
|
85
views/list-management/list.tpl
Normal file
85
views/list-management/list.tpl
Normal file
|
@ -0,0 +1,85 @@
|
|||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Tìm kiếm</div>
|
||||
<select class="form-control" id="filter-from-server" onchange="filters(this);">
|
||||
<option value=""></option>
|
||||
{html_options options=$filters}
|
||||
</select>
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" data-toggle="tooltip" title="Hủy bỏ tìm kiếm" onclick="removeFilters();">
|
||||
<i class="fa fa-remove"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="max-height: 750px;overflow-y: auto;">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Loại</th>
|
||||
<th>Tên</th>
|
||||
<th>Giới tính</th>
|
||||
<th>Hình ảnh đăng kí</th>
|
||||
<th>Thời gian đăng kí</th>
|
||||
<th>Ngày sinh</th>
|
||||
<th>Điện thoại</th>
|
||||
<th>Đơn vị</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sync-lists">
|
||||
{foreach from=$results item=arr}
|
||||
<tr id="filters-{$arr.code}" class="filters" onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.code}">
|
||||
<td>{$arr.code}</td>
|
||||
<td>{$typeArray[$arr.type]}</td>
|
||||
<td>{$arr.name}</td>
|
||||
<td>{$arr.gender}</td>
|
||||
<td>
|
||||
{$images = json_decode($arr.image, true)}
|
||||
{foreach from=$images item=img}
|
||||
<div class='feature-img'>
|
||||
<img src="http://{$ip}/data/uploads/face/{$img.url}" class="img-thumbnail" style="width: 100px;height:100px;">
|
||||
</div>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>{$arr.time|date_format:"H:i:s d/m/Y"}</td>
|
||||
<td>{$arr.birthday|date_format:"d/m/Y"}</td>
|
||||
<td>{$arr.telephone}</td>
|
||||
<td>{$arr.address}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<i class="fa fa-info-circle"></i> Đã lựa chọn <b class="text-red" id="totals-choose">0</b> đối tượng.
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="hidden" id="progress-form">
|
||||
Đồng bộ <b id="progress-current" class="text-green">0</b>/<b id="progress-totals" class="text-red">0</b> đối tượng.
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-primary progress-bar-striped" id='progress' role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
||||
0%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(true);">
|
||||
Chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-default btn-select" onclick="checkAllSync(false);">
|
||||
Bỏ chọn tất cả
|
||||
</button>
|
||||
<button class="btn btn-primary" onclick="_sync();">
|
||||
<i class="fa fa-refresh"></i> Đồng bộ
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-remove"></span> Đóng lại</button>
|
||||
</div>
|
||||
</div>
|
|
@ -673,4 +673,8 @@ body::-webkit-scrollbar {
|
|||
}
|
||||
.font-grey-cascade {
|
||||
color: #95A5A6!important;
|
||||
}
|
||||
|
||||
.skin-blue .main-header .navbar .nav>li>a{
|
||||
font-size:23px !important;
|
||||
}
|
BIN
web/images/user2-160x160.jpg
Normal file
BIN
web/images/user2-160x160.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
97
web/js/capture-logs.js
Normal file
97
web/js/capture-logs.js
Normal file
|
@ -0,0 +1,97 @@
|
|||
$(function () {
|
||||
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
|
||||
common.dateTimePickerDay("birthday");
|
||||
$("#Code").select2();
|
||||
$("input[name='AllData']").change(function () {
|
||||
if ($('input[name=AllData]').is(':checked')) {
|
||||
window.location = $("input[name='URL']").val() + "?all=true" + "&from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
} else {
|
||||
window.location = $("input[name='URL']").val() + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function _search(e) {
|
||||
var all = "";
|
||||
if ($('input[name=AllData]').is(':checked')) {
|
||||
all = "&all=true";
|
||||
}
|
||||
window.location = $(e).attr("data-href") + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val() + all;
|
||||
}
|
||||
|
||||
function _form(e) {
|
||||
$("#form").removeClass("hidden");
|
||||
$("input[name='CaptureLogsID']").val($(e).attr("data-id"));
|
||||
$("#FaceImage").attr("src", $(e).attr("data-img"));
|
||||
var confidence = JSON.parse($(e).attr("data-confidence"));
|
||||
$("#closest-img").attr("src", confidence.img);
|
||||
$("#closest-name").html(confidence.name + " [" + confidence.score + "]");
|
||||
}
|
||||
|
||||
function _close() {
|
||||
$("#form").addClass("hidden");
|
||||
}
|
||||
|
||||
function _save(e) {
|
||||
var code = $("select[name='Code']").val();
|
||||
if (code === "") {
|
||||
alert("Hãy chọn đối tượng!");
|
||||
return;
|
||||
}
|
||||
var name = $("input[name='Name']").val();
|
||||
if (name === "") {
|
||||
alert("Hãy nhập tên!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
code: code,
|
||||
name: name,
|
||||
type: $("select[name='Type']").val(),
|
||||
gender: $("select[name='Gender']").val(),
|
||||
birthday: $("input[name='Birthday']").val(),
|
||||
telephone: $("input[name='Telephone']").val(),
|
||||
address: $("input[name='Address']").val(),
|
||||
id: $("input[name='CaptureLogsID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data.status) {
|
||||
alert("Đã thêm dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
} else {
|
||||
alert(data.text);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function chooseStaff(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
code: $(e).val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
$("input[name='Name']").val(data.name);
|
||||
$("select[name='Gender']").val(data.gender);
|
||||
$("input[name='Birthday']").val(data.birthday);
|
||||
$("input[name='Telephone']").val(data.telephone);
|
||||
$("input[name='Address']").val(data.department);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -241,6 +241,14 @@ common.dateTimePickerHour = function (id) {
|
|||
format: 'HH:mm'
|
||||
});
|
||||
};
|
||||
common.dateTimePickerByClass = function (cls, format) {
|
||||
$('.' + cls).datetimepicker({
|
||||
locale: 'vi',
|
||||
ignoreReadonly: true,
|
||||
sideBySide: true,
|
||||
format: format
|
||||
});
|
||||
};
|
||||
common.checkAll = function (id, cls) {
|
||||
$('#' + id).on('ifChecked', function (event) {
|
||||
$('.' + cls).iCheck('check');
|
||||
|
@ -279,12 +287,46 @@ common.success = function (id) {
|
|||
$("#" + id).addClass("has-success").removeClass("has-error");
|
||||
$("#" + id).find(".help-block").addClass("hidden");
|
||||
};
|
||||
common.resetForm = function (e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("href"),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpen(data.form, false, data.title);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
};
|
||||
common.reset = function (e) {
|
||||
if (confirm("Bạn có chắc chắn muốn reset thiết bị về cấu hình mặc định không?")) {
|
||||
var deleteDB = false;
|
||||
var resetDevice = false;
|
||||
if ($("input[name='DeleteDatabase']").is(':checked'))
|
||||
deleteDB = true;
|
||||
if ($("input[name='ResetDevice']").is(':checked'))
|
||||
resetDevice = true;
|
||||
if (!deleteDB && !resetDevice) {
|
||||
alert("Hãy lựa chọn thao tác!");
|
||||
return;
|
||||
}
|
||||
var confirmText = "";
|
||||
if (deleteDB)
|
||||
confirmText = "Bạn có chắc chắn muốn xóa dữ liệu lưu trữ trong thiết bị không?";
|
||||
if (resetDevice)
|
||||
confirmText = "Bạn có chắc chắn muốn reset cấu hình thiết bị không?";
|
||||
if (confirm(confirmText)) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("href"),
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
deleteDB: deleteDB,
|
||||
resetDevice: resetDevice
|
||||
},
|
||||
success: function (data) {
|
||||
window.location = data;
|
||||
},
|
||||
|
@ -295,6 +337,12 @@ common.reset = function (e) {
|
|||
});
|
||||
}
|
||||
};
|
||||
common.validateIp = function (Ip) {
|
||||
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(Ip)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* =========================
|
||||
*/
|
||||
|
|
|
@ -56,6 +56,7 @@ function saveStep1(e) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveStep2(e) {
|
||||
var cfgLists = $(".editform");
|
||||
var cfg = [];
|
||||
|
@ -86,4 +87,34 @@ function saveStep2(e) {
|
|||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SaveConfigDevice(e) {
|
||||
var server_api = $("input[name='server_api']").val();
|
||||
var device_id = $("input[name='device_id']").val();
|
||||
if (server_api === "" || device_id === "") {
|
||||
alert("Hãy nhập đủ thông tin");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
server_api: server_api,
|
||||
device_id: device_id
|
||||
},
|
||||
success: function (data) {
|
||||
if (data) {
|
||||
notification.success("Đã lưu cấu hình!", 2000);
|
||||
} else {
|
||||
notification.success("Lưu cấu hình thất bại!", 2000);
|
||||
}
|
||||
common.modalBlock(false);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
35
web/js/control-logs.js
Normal file
35
web/js/control-logs.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
$(function () {
|
||||
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
|
||||
});
|
||||
|
||||
function _search(e) {
|
||||
var location = $(e).attr("data-href") + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
location = location + "&id=" + $("input[name='IDSearch']").val();
|
||||
location = location + "&name=" + $("input[name='NameSearch']").val();
|
||||
location = location + "&type=" + $("select[name='TypeSearch']").val();
|
||||
location = location + "&gender=" + $("select[name='GenderSearch']").val();
|
||||
window.location = location;
|
||||
}
|
||||
|
||||
function _useFeature(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $(e).val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data.status) {
|
||||
alert("Đã thêm hình ảnh mẫu!");
|
||||
} else {
|
||||
alert(data.text);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
633
web/js/list-management.js
Normal file
633
web/js/list-management.js
Normal file
|
@ -0,0 +1,633 @@
|
|||
var x = 0, y = 0;
|
||||
$(function () {
|
||||
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
|
||||
common.dateTimePickerDay("birthday");
|
||||
$("tr").bind("click", function (event) {
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
});
|
||||
$("input[name='BatchDelete']").change(function () {
|
||||
if (this.checked) {
|
||||
$("#delete-btn-group").removeClass("hidden");
|
||||
} else {
|
||||
$("tr").removeClass("delete-choose");
|
||||
$("#delete-btn-group").addClass("hidden");
|
||||
}
|
||||
});
|
||||
btnImage();
|
||||
$("#Code").select2();
|
||||
getTotalFeature();
|
||||
});
|
||||
function _search(e) {
|
||||
var location = $(e).attr("data-href"); // + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
location = location + "?id=" + $("input[name='IDSearch']").val();
|
||||
location = location + "&name=" + $("input[name='NameSearch']").val();
|
||||
location = location + "&type=" + $("select[name='TypeSearch']").val();
|
||||
location = location + "&gender=" + $("select[name='GenderSearch']").val();
|
||||
window.location = location;
|
||||
}
|
||||
|
||||
function _close() {
|
||||
$("#form").addClass("hidden");
|
||||
}
|
||||
|
||||
function _menu(e) {
|
||||
var isDelete = $("input[name='BatchDelete']").is(':checked');
|
||||
if (isDelete) {
|
||||
if ($(e).hasClass("delete-choose"))
|
||||
$(e).removeClass("delete-choose");
|
||||
else
|
||||
$(e).addClass("delete-choose");
|
||||
$("#menu").addClass("hidden");
|
||||
} else {
|
||||
$("input[name='ListManagementID']").val($(e).attr("data-id"));
|
||||
$("#menu").css({top: y, left: x}).removeClass("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function _closeMenu() {
|
||||
$("#menu").addClass("hidden");
|
||||
}
|
||||
|
||||
function _formModified(e) {
|
||||
_closeMenu();
|
||||
$("#form").removeClass("hidden");
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $("input[name='ListManagementID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data.canUpload)
|
||||
$("#upload-btn").removeClass("hidden");
|
||||
else
|
||||
$("#upload-btn").addClass("hidden");
|
||||
$("select[name='Type']").val(data.type);
|
||||
$("select[name='Code']").val(data.code);
|
||||
$("input[name='Name']").val(data.name);
|
||||
$("select[name='Gender']").val(data.gender);
|
||||
$("input[name='Birthday']").val(data.birthday);
|
||||
$("input[name='Telephone']").val(data.telephone);
|
||||
$("input[name='Address']").val(data.address);
|
||||
$("#FaceImage").attr("src", data.image);
|
||||
$("#save-btn").attr("onclick", "_update(this);");
|
||||
$("#save-btn").attr("data-href", $("input[name='update_url']").val());
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _update(e) {
|
||||
var code = $("select[name='Code']").val();
|
||||
if (code === "") {
|
||||
alert("Hãy chọn đối tượng!");
|
||||
return;
|
||||
}
|
||||
var name = $("input[name='Name']").val();
|
||||
if (name === "") {
|
||||
alert("Hãy nhập tên!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
code: code,
|
||||
name: name,
|
||||
type: $("select[name='Type']").val(),
|
||||
gender: $("select[name='Gender']").val(),
|
||||
birthday: $("input[name='Birthday']").val(),
|
||||
telephone: $("input[name='Telephone']").val(),
|
||||
address: $("input[name='Address']").val(),
|
||||
id: $("input[name='ListManagementID']").val(),
|
||||
image: $("input[name='AnhNhanVienUrl']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data) {
|
||||
alert("Cập nhật dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
} else
|
||||
alert("Mã đối tượng đã tồn tại!");
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _delete(e) {
|
||||
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $("input[name='ListManagementID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _deleteFeature(e) {
|
||||
if (confirm("Bạn có chắc chắn muốn xóa ảnh này không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
image: $(e).attr("data-img"),
|
||||
id: $(e).attr("data-id")
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
$(e).closest("div").remove();
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkAll(status) {
|
||||
if (status)
|
||||
$("tr").addClass("delete-choose");
|
||||
else
|
||||
$("tr").removeClass("delete-choose");
|
||||
}
|
||||
|
||||
function batchDelete(e) {
|
||||
var check = $(".delete-choose");
|
||||
if (check.length == 0) {
|
||||
alert("Hãy chọn dữ liệu để xóa!");
|
||||
return;
|
||||
}
|
||||
var lists = [];
|
||||
$.each($(".delete-choose"), function () {
|
||||
if ($(this).attr("data-id") !== "")
|
||||
lists.push($(this).attr("data-id"));
|
||||
});
|
||||
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
lists: lists
|
||||
},
|
||||
success: function (data) {
|
||||
alert("Đã xóa dữ liệu!");
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _form() {
|
||||
$("#form").removeClass("hidden");
|
||||
$("#upload-btn").removeClass("hidden");
|
||||
$("#FaceImage").attr("src", "/images/user2-160x160.jpg");
|
||||
$("#save-btn").attr("onclick", "_create(this);");
|
||||
$("#save-btn").attr("data-href", $("input[name='create_url']").val());
|
||||
$("input[name='Code']").val($("input[name='isAuto']").val());
|
||||
$("input[name='Name']").val("");
|
||||
$("input[name='Birthday']").val("");
|
||||
$("input[name='Telephone']").val("");
|
||||
$("input[name='Address']").val("");
|
||||
}
|
||||
|
||||
function btnImage() {
|
||||
var fData = {
|
||||
UploadImage: true
|
||||
};
|
||||
fData[common.csrfParam] = common.csrf;
|
||||
new afuButton({
|
||||
uploadURI: $("input[name='url_upload_staff_image']").val(),
|
||||
formData: fData,
|
||||
wrap: {
|
||||
tagName: 'div',
|
||||
classes: ''
|
||||
},
|
||||
fileExtension: '.png,.jpg,.jpeg,.gif',
|
||||
fileSizeLimit: 1,
|
||||
classes: 'btn btn-default btn-xs',
|
||||
fakeInputContent: '<span class=\'fa fa-file-image-o\'></span> Chọn hình ảnh',
|
||||
onUploaded: function (data) {
|
||||
var res = JSON.parse(data);
|
||||
if (res.status) {
|
||||
$("#FaceImage").attr("src", "/" + res.dataPath + res.url);
|
||||
$("input[name='AnhNhanVienUrl']").val(res.url);
|
||||
common.uploadBlock(false);
|
||||
} else {
|
||||
alert("Hình ảnh không nhận diện được khuôn mặt");
|
||||
}
|
||||
}
|
||||
}).addInstance('AnhNhanVien');
|
||||
}
|
||||
|
||||
function _create(e) {
|
||||
var code = $("select[name='Code']").val();
|
||||
if (code === "") {
|
||||
alert("Hãy chọn đối tượng!");
|
||||
return;
|
||||
}
|
||||
var name = $("input[name='Name']").val();
|
||||
if (name === "") {
|
||||
alert("Hãy nhập tên!");
|
||||
return;
|
||||
}
|
||||
var image = $("input[name='AnhNhanVienUrl']").val();
|
||||
if (image === "") {
|
||||
alert("Hãy tải lên hình ảnh");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
code: code,
|
||||
name: name,
|
||||
type: $("select[name='Type']").val(),
|
||||
gender: $("select[name='Gender']").val(),
|
||||
birthday: $("input[name='Birthday']").val(),
|
||||
telephone: $("input[name='Telephone']").val(),
|
||||
address: $("input[name='Address']").val(),
|
||||
image: image
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
if (data.status) {
|
||||
alert("Cập nhật dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
} else
|
||||
alert("Mã đối tượng đã tồn tại!");
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _syncForm(e) {
|
||||
var ip = $("input[name='SyncIP']").val();
|
||||
if (ip === "") {
|
||||
common.error("ip", "Hãy nhập địa chỉ ip thiết bị muốn đồng bộ");
|
||||
return;
|
||||
}
|
||||
if (!common.validateIp(ip)) {
|
||||
common.error("ip", "Sai định dạng ip");
|
||||
return;
|
||||
}
|
||||
common.success("ip");
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
ip: ip
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpenFullScreen(data.form, data.title);
|
||||
$("#filter-from-server").select2({
|
||||
placeholder: "Tìm kiếm theo ID hoặc tên"
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
alert("Không có kết nối tới thiết bị");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function choooseToSync(e) {
|
||||
var stt = $(e).attr("data-stt");
|
||||
if (stt === "false") {
|
||||
$(e).addClass("success");
|
||||
$(e).attr("data-stt", "true");
|
||||
$("#totals-choose").html(parseInt($("#totals-choose").html()) + 1);
|
||||
} else {
|
||||
$(e).removeClass("success");
|
||||
$(e).attr("data-stt", "false");
|
||||
$("#totals-choose").html(parseInt($("#totals-choose").html()) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAllSync(stt) {
|
||||
if (stt) {
|
||||
$("#sync-lists").find("tr").addClass("success").attr("data-stt", "true");
|
||||
$("#totals-choose").html($("#sync-lists").find("tr").length);
|
||||
} else {
|
||||
$("#sync-lists").find("tr").removeClass("success").attr("data-stt", "false");
|
||||
$("#totals-choose").html("0");
|
||||
}
|
||||
}
|
||||
|
||||
function checkAllNotInList() {
|
||||
$("#sync-lists").find("tr").removeClass("success").attr("data-stt", "false");
|
||||
$(".not-in-list").addClass("success").attr("data-stt", "true");
|
||||
$("#totals-choose").html($(".not-in-list").length);
|
||||
}
|
||||
|
||||
var progress = 0;
|
||||
var totals = 0;
|
||||
function _sync() {
|
||||
var lists = [];
|
||||
$.each($("#sync-lists").find(".success"), function () {
|
||||
lists.push($(this).attr("data-id"));
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Không có dữ liệu đồng bộ!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$("#progress-totals").html(lists.length);
|
||||
$("#progress-form").removeClass("hidden");
|
||||
totals = lists.length;
|
||||
syncFeatureFromDevice(lists[0], lists);
|
||||
}
|
||||
|
||||
function syncFeatureFromDevice(id, fullData) {
|
||||
$.ajax({
|
||||
url: $("input[name='sync_feature_from_device_url']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id,
|
||||
ip: $("input[name='SyncIP']").val(),
|
||||
totals: totals
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data, progress);
|
||||
progress++;
|
||||
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
|
||||
var percent = parseInt(progress / totals * 100);
|
||||
$("#progress").attr("aria-valuenow", percent);
|
||||
$("#progress").attr("style", "width: " + percent + "%");
|
||||
$("#progress").html(percent + "%");
|
||||
if (percent >= 100) {
|
||||
common.modalBlock(false);
|
||||
if (totals > 10) {
|
||||
updateFeature();
|
||||
progress = 0;
|
||||
} else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
} else {
|
||||
syncFeatureFromDevice(fullData[progress], fullData);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
alert("Mất kết nối tới thiết bị");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _syncFromServerForm(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpenFullScreen(data.form, data.title);
|
||||
$("#filter-from-server").select2({
|
||||
placeholder: "Tìm kiếm theo ID hoặc tên"
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _syncFromServer() {
|
||||
var lists = [];
|
||||
$.each($("#sync-lists").find(".success"), function () {
|
||||
var id = $(this).attr("data-id");
|
||||
lists.push(JSON.parse($("#full-data-" + id).html()));
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Không có dữ liệu đồng bộ!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$("#progress-totals").html(lists.length);
|
||||
$("#progress-form").removeClass("hidden");
|
||||
totals = lists.length;
|
||||
syncFeature(lists[0], lists);
|
||||
}
|
||||
|
||||
function syncFeature(id, fullData) {
|
||||
$.ajax({
|
||||
url: $("input[name='sync_feature_url']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id,
|
||||
totals: totals
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data, progress);
|
||||
progress++;
|
||||
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
|
||||
var percent = parseInt(progress / totals * 100);
|
||||
$("#progress").attr("aria-valuenow", percent);
|
||||
$("#progress").attr("style", "width: " + percent + "%");
|
||||
$("#progress").html(percent + "%");
|
||||
if (percent >= 100) {
|
||||
common.modalBlock(false);
|
||||
if (totals > 10) {
|
||||
updateFeature();
|
||||
progress = 0;
|
||||
} else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
} else {
|
||||
syncFeature(fullData[progress], fullData);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateFeature() {
|
||||
$.ajax({
|
||||
url: $("input[name='update_feature_url']").val(),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function chooseStaff(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
code: $(e).val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
$("input[name='Name']").val(data.name);
|
||||
$("select[name='Gender']").val(data.gender);
|
||||
$("input[name='Birthday']").val(data.birthday);
|
||||
$("input[name='Telephone']").val(data.telephone);
|
||||
$("input[name='Address']").val(data.department);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _syncToServerForm(e) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpenFullScreen(data.form, data.title);
|
||||
$("#filter-from-server").select2({
|
||||
placeholder: "Tìm kiếm theo ID hoặc tên"
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var progressToServer = 0;
|
||||
var totalsToServer = 0;
|
||||
function _syncToServer() {
|
||||
var lists = [];
|
||||
$.each($("#sync-lists").find(".success"), function () {
|
||||
lists.push($(this).attr("data-id"));
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Không có dữ liệu đồng bộ!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$("#progress-totals").html(lists.length);
|
||||
$("#progress-form").removeClass("hidden");
|
||||
totalsToServer = lists.length;
|
||||
syncFeatureToServer(lists[0], lists);
|
||||
}
|
||||
var error = 0;
|
||||
function syncFeatureToServer(id, fullData) {
|
||||
$.ajax({
|
||||
url: $("input[name='sync_feature_to_server_url']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
// if (data.status != 10000) {
|
||||
// error++;
|
||||
// console.log(error);
|
||||
// }
|
||||
progressToServer++;
|
||||
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
|
||||
var percent = parseInt(progressToServer / totalsToServer * 100);
|
||||
$("#progress").attr("aria-valuenow", percent);
|
||||
$("#progress").attr("style", "width: " + percent + "%");
|
||||
$("#progress").html(percent + "%");
|
||||
if (percent >= 100) {
|
||||
common.modalBlock(false);
|
||||
setTimeout(function () {
|
||||
alert("Đồng bộ dữ liệu hoàn thành");
|
||||
window.location.reload(true);
|
||||
}, 2000)
|
||||
} else {
|
||||
syncFeatureToServer(fullData[progressToServer], fullData);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function filters(e) {
|
||||
var id = $(e).val();
|
||||
if (id === "") {
|
||||
$(".filters").removeClass("hidden");
|
||||
$(".btn-select").removeClass("hidden");
|
||||
checkAllSync(false);
|
||||
} else {
|
||||
$(".filters").addClass("hidden");
|
||||
$("#filters-" + id).removeClass("hidden");
|
||||
$(".btn-select").addClass("hidden");
|
||||
checkAllSync(false);
|
||||
choooseToSync($("#filters-" + id));
|
||||
}
|
||||
}
|
||||
|
||||
function removeFilters() {
|
||||
$(".filters").removeClass("hidden");
|
||||
$(".btn-select").removeClass("hidden");
|
||||
$("#filter-from-server").val('').trigger('change');
|
||||
checkAllSync(false);
|
||||
}
|
||||
|
||||
function getTotalFeature() {
|
||||
$.ajax({
|
||||
url: $("input[name='get_total_feature_url']").val(),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
$("#totalPeople").html(`<b class="text-red">` + data.statistics.totalImg + `</b>/<b>` + data.statistics.total + `</b>`);
|
||||
$("#total128").html(`<b class="text-red">` + data.statistics["128"] + `</b>/<b>` + data.statistics.img + `</b>`);
|
||||
$("#total512").html(`<b class="text-red">` + data.statistics["512"] + `</b>/<b>` + data.statistics.img + `</b>`);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function reGenFeature(e) {
|
||||
$.ajax({
|
||||
url: $(e).attr("href"),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
// window.location.reload(true);
|
||||
$("#updating-label").removeClass("hidden");
|
||||
$(e).addClass("hidden");
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user