diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index a8561eef..04395403 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -300,7 +300,7 @@ class ConfigController extends Controller { } public function actionReset() { - if (Yii::$app->request->isAjax) { + if (Yii::$app->request->post()) { $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([ 'http' => [ 'header' => "Content-Type: application/json", @@ -330,7 +330,17 @@ class ConfigController extends Controller { ]) ] ])); + if (Yii::$app->request->post("deleteDB") === "yes") { + \Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute(); + \Yii::$app->db->createCommand()->truncateTable('list_management')->execute(); + } return Url::to(['/config']); + } else { + Yii::$app->response->format = "json"; + return [ + "title" => "Reset thiết bị", + "form" => $this->renderPartial("reset") + ]; } } diff --git a/vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/header.php b/vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/header.php index c52e5cfc..7a22ab2c 100644 --- a/vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/header.php +++ b/vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/header.php @@ -42,7 +42,7 @@ use yii\widgets\ActiveForm;