diff --git a/controllers/ListManagementController.php b/controllers/ListManagementController.php index 58e47178..c4d0a513 100644 --- a/controllers/ListManagementController.php +++ b/controllers/ListManagementController.php @@ -307,8 +307,80 @@ class ListManagementController extends Controller { } } - public function actionTest() { - return base64_encode(file_get_contents("http://api.demo.beetai.com/view/image/5fd0845d9a4eb65bcfb0ea3b")); + public function actionSyncFromServer() { + if (Yii::$app->request->isAjax) { + $datas = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST", + 'content' => json_encode([ + "id_camera" => 209, + "ids_staff" => [] + ]) + ] + ])), true); + Yii::$app->response->format = "json"; + return [ + "title" => " Đồng bộ từ máy chủ", + "form" => $this->renderPartial("list-server", [ + "datas" => $datas['data'] + ]) + ]; + } + } + + public function actionSyncFeature() { + if (Yii::$app->request->post()) { + Yii::$app->response->format = "json"; + $res = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST", + 'content' => json_encode([ + "id_camera" => 209, + "ids_staff" => [strval(Yii::$app->request->post("id"))] + ]) + ] + ])), true); + $data = $res['data'][0]; + $ft = []; + $RootFolder = Yii::getAlias('@webroot') . "/data/uploads"; + $targetPath = $RootFolder . "/face"; + FileHelper::createDirectory($targetPath, 0777); + foreach ($data['images'] as $key => $value) { + $key = common::generateRandomString(); + $fileName = "face_" . $key . "_" . time() . ".png"; + file_put_contents($targetPath . "/" . $fileName, file_get_contents($value)); + $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']]; + } + + $model = new ListManagement(); + $model->create([ + 'code' => $data['idStaff'], + 'type' => "wl", + 'name' => $data['name'], + 'image' => json_encode($ft), + 'gender' => "", + 'birthday' => "", + 'telephone' => "", + 'address' => "" + ]); +// file_get_contents("http://localhost:2305/update-feature"); + return ["status" => true]; + } + } + + public function actionUpdateFeature() { + if (Yii::$app->request->isAjax) { + Yii::$app->response->format = "json"; + file_get_contents("http://localhost:2305/update-feature"); + return ["status" => true]; + } } } diff --git a/views/list-management/index.tpl b/views/list-management/index.tpl index 7cddb904..1f49eb4c 100644 --- a/views/list-management/index.tpl +++ b/views/list-management/index.tpl @@ -28,6 +28,8 @@ + +
ID | +Name | +Department | +Registration Image | +Code | +Company ID | +
---|---|---|---|---|---|
{$arr.idStaff} | +{$arr.name} | +{$arr.department} | +
+ {foreach from=$arr.images item=img}
+
+
+ {/foreach}
+ |
+ {$arr.code} | +{$arr.id_company} | +