gioi han so mau cho 1 doi tuong
This commit is contained in:
parent
40df99acd9
commit
fc0f2ccc0f
|
@ -2,5 +2,6 @@
|
|||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
"maxLogs" => 100000
|
||||
"maxLogs" => 100000,
|
||||
"maxPicture" => 5
|
||||
];
|
||||
|
|
|
@ -108,6 +108,8 @@ class ListManagementController extends Controller {
|
|||
$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 ($value['url'] === $url)
|
||||
|
@ -135,6 +137,7 @@ class ListManagementController extends Controller {
|
|||
file_get_contents("http://localhost:2305/update-feature");
|
||||
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 {
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
|
@ -169,7 +172,8 @@ class ListManagementController extends Controller {
|
|||
"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"
|
||||
"image" => count($images) > 0 ? "/data/uploads/face/" . $images[0]['url'] : "/images/user2-160x160.jpg",
|
||||
"canUpload" => count($images) >= Yii::$app->params['maxPicture'] ? false : true
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -372,21 +376,23 @@ class ListManagementController extends Controller {
|
|||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
foreach ($data['images'] as $key => $value) {
|
||||
$key = common::generateRandomString();
|
||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||
$img = file_get_contents($value);
|
||||
if ($img !== "null") {
|
||||
file_put_contents($targetPath . "/" . $fileName, $img);
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$ft[] = [
|
||||
"url" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
if ($key < Yii::$app->params['maxPicture']) {
|
||||
$key = common::generateRandomString();
|
||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||
$img = file_get_contents($value);
|
||||
if ($img !== "null") {
|
||||
file_put_contents($targetPath . "/" . $fileName, $img);
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$ft[] = [
|
||||
"url" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
||||
|
@ -427,13 +433,19 @@ class ListManagementController extends Controller {
|
|||
foreach ($results as $key => $value) {
|
||||
$images = [];
|
||||
foreach ($value['images'] as $k => $v) {
|
||||
$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, "features" => $v['features']];
|
||||
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,
|
||||
"features" => $v['features'],
|
||||
"features512" => isset($v['features512']) ? $v['features512'] : []
|
||||
];
|
||||
}
|
||||
}
|
||||
$model = ListManagement::findOne(['code' => $value['code']]);
|
||||
if ($model) {
|
||||
|
|
|
@ -58,11 +58,10 @@
|
|||
'value' => \app\helpers\CaptureLogsGrid::confidence()
|
||||
],
|
||||
[
|
||||
'attribute' => 'remark',
|
||||
'attribute' => 'sync_status',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
'sync_status'
|
||||
]
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
|
|
|
@ -55,8 +55,13 @@ function _save(e) {
|
|||
id: $("input[name='CaptureLogsID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
alert("Đã thêm dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
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);
|
||||
|
|
|
@ -60,6 +60,10 @@ function _formModified(e) {
|
|||
},
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user