language = Yii::$app->session->get("language") ? Yii::$app->session->get("language")["name"] : Yii::$app->language; if (Yii::$app->user->isGuest) return $this->redirect(['/site/login']); } 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 = Yii::t("app", "LICH_SU_HE_THONG"); $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(), "typeArray" => ListManagement::typeArray(), "genderArray" => ListManagement::genderArray(), ]); } 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(Yii::t("app", "KHONG_TIM_THAY_THONG_TIN")); } public function actionFaceComparison() { if (Yii::$app->request->post()) { $post = Yii::$app->request->post(); Yii::$app->response->format = "json"; $results = json_decode(file_get_contents("http://192.168.1.43:2305/compare", false, stream_context_create([ 'http' => [ 'header' => "Content-Type: application/json", 'method' => "POST", 'content' => json_encode([ "type" => "base64", "img0" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face1'])), "img1" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face2'])) ]) ] ])), true); return [ "type1" => number_format($results['type1']['percent'] * 100, 2), "type2" => number_format($results['type2']['percent'] * 100, 2) ]; } else { $this->view->title = Yii::t("app", "SO_SANH_MAT"); return $this->render('face-comparison', [ ]); } } public function actionUploadFace() { if (Yii::$app->request->post()) { $post = Yii::$app->request->post(); $model = new \app\models\UploadForm(); $url = $model->UploadGlobal("image" . $post['imageIndex'], ["PNG", "JPG", "JPEG", "GIF"], "comparison"); return $url; } } }