gioi han so mau cho 1 doi tuong
This commit is contained in:
parent
40df99acd9
commit
fc0f2ccc0f
|
@ -2,5 +2,6 @@
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'adminEmail' => 'admin@example.com',
|
'adminEmail' => 'admin@example.com',
|
||||||
"maxLogs" => 100000
|
"maxLogs" => 100000,
|
||||||
|
"maxPicture" => 5
|
||||||
];
|
];
|
||||||
|
|
|
@ -108,6 +108,8 @@ class ListManagementController extends Controller {
|
||||||
$url = CaptureLogs::findOne($data['id'])->image;
|
$url = CaptureLogs::findOne($data['id'])->image;
|
||||||
if ($listManagement) {
|
if ($listManagement) {
|
||||||
$images = json_decode($listManagement->image, true);
|
$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;
|
$add = true;
|
||||||
foreach ($images as $key => $value) {
|
foreach ($images as $key => $value) {
|
||||||
if ($value['url'] === $url)
|
if ($value['url'] === $url)
|
||||||
|
@ -135,6 +137,7 @@ class ListManagementController extends Controller {
|
||||||
file_get_contents("http://localhost:2305/update-feature");
|
file_get_contents("http://localhost:2305/update-feature");
|
||||||
return ["status" => true];
|
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 {
|
} else {
|
||||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||||
"image_paths" => [
|
"image_paths" => [
|
||||||
|
@ -169,7 +172,8 @@ class ListManagementController extends Controller {
|
||||||
"birthday" => date("d/m/Y", $ListManagement->birthday),
|
"birthday" => date("d/m/Y", $ListManagement->birthday),
|
||||||
"telephone" => $ListManagement->telephone,
|
"telephone" => $ListManagement->telephone,
|
||||||
"address" => $ListManagement->address,
|
"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,6 +376,7 @@ class ListManagementController extends Controller {
|
||||||
$targetPath = $RootFolder . "/face";
|
$targetPath = $RootFolder . "/face";
|
||||||
FileHelper::createDirectory($targetPath, 0777);
|
FileHelper::createDirectory($targetPath, 0777);
|
||||||
foreach ($data['images'] as $key => $value) {
|
foreach ($data['images'] as $key => $value) {
|
||||||
|
if ($key < Yii::$app->params['maxPicture']) {
|
||||||
$key = common::generateRandomString();
|
$key = common::generateRandomString();
|
||||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||||
$img = file_get_contents($value);
|
$img = file_get_contents($value);
|
||||||
|
@ -389,6 +394,7 @@ class ListManagementController extends Controller {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
||||||
if ($model) {
|
if ($model) {
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
|
@ -427,13 +433,19 @@ class ListManagementController extends Controller {
|
||||||
foreach ($results as $key => $value) {
|
foreach ($results as $key => $value) {
|
||||||
$images = [];
|
$images = [];
|
||||||
foreach ($value['images'] as $k => $v) {
|
foreach ($value['images'] as $k => $v) {
|
||||||
|
if ($k < Yii::$app->params['maxPicture']) {
|
||||||
$key = common::generateRandomString();
|
$key = common::generateRandomString();
|
||||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||||
$targetPath = $RootFolder . "/face";
|
$targetPath = $RootFolder . "/face";
|
||||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||||
FileHelper::createDirectory($targetPath, 0777);
|
FileHelper::createDirectory($targetPath, 0777);
|
||||||
file_put_contents($targetPath . "/" . $fileName, base64_decode($v['url']));
|
file_put_contents($targetPath . "/" . $fileName, base64_decode($v['url']));
|
||||||
$images[] = ["url" => $fileName, "features" => $v['features']];
|
$images[] = [
|
||||||
|
"url" => $fileName,
|
||||||
|
"features" => $v['features'],
|
||||||
|
"features512" => isset($v['features512']) ? $v['features512'] : []
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$model = ListManagement::findOne(['code' => $value['code']]);
|
$model = ListManagement::findOne(['code' => $value['code']]);
|
||||||
if ($model) {
|
if ($model) {
|
||||||
|
|
|
@ -58,11 +58,10 @@
|
||||||
'value' => \app\helpers\CaptureLogsGrid::confidence()
|
'value' => \app\helpers\CaptureLogsGrid::confidence()
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'remark',
|
'attribute' => 'sync_status',
|
||||||
'contentOptions' => ['class' => 'text-center'],
|
'contentOptions' => ['class' => 'text-center'],
|
||||||
'headerOptions' => ['class' => 'text-center']
|
'headerOptions' => ['class' => 'text-center']
|
||||||
],
|
]
|
||||||
'sync_status'
|
|
||||||
]
|
]
|
||||||
])}
|
])}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -55,8 +55,13 @@ function _save(e) {
|
||||||
id: $("input[name='CaptureLogsID']").val()
|
id: $("input[name='CaptureLogsID']").val()
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
common.modalBlock(false);
|
||||||
|
if (data.status) {
|
||||||
alert("Đã thêm dữ liệu thành công!");
|
alert("Đã thêm dữ liệu thành công!");
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
|
} else {
|
||||||
|
alert(data.text);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
common.modalBlock(false);
|
common.modalBlock(false);
|
||||||
|
|
|
@ -60,6 +60,10 @@ function _formModified(e) {
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
common.modalBlock(false);
|
common.modalBlock(false);
|
||||||
|
if (data.canUpload)
|
||||||
|
$("#upload-btn").removeClass("hidden");
|
||||||
|
else
|
||||||
|
$("#upload-btn").addClass("hidden");
|
||||||
$("select[name='Type']").val(data.type);
|
$("select[name='Type']").val(data.type);
|
||||||
$("select[name='Code']").val(data.code);
|
$("select[name='Code']").val(data.code);
|
||||||
$("input[name='Name']").val(data.name);
|
$("input[name='Name']").val(data.name);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user