From: Alexander Smirnov Date: Tue, 12 Mar 2024 14:10:31 +0000 (+0300) Subject: add page statistics view X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c922df3cfeb9959ff2a19b4b36f47822d5960474;p=yii-erp24%2F.git add page statistics view --- diff --git a/erp24/actions/pages/StatisticsAction.php b/erp24/actions/pages/StatisticsAction.php new file mode 100644 index 0000000..35efa43 --- /dev/null +++ b/erp24/actions/pages/StatisticsAction.php @@ -0,0 +1,15 @@ + PageStatistics::find()->with('admin')]); + return $this->controller->render('statistics', compact('dataProvider')); + } +} \ No newline at end of file diff --git a/erp24/controllers/PagesController.php b/erp24/controllers/PagesController.php index 1509a2d..5570163 100755 --- a/erp24/controllers/PagesController.php +++ b/erp24/controllers/PagesController.php @@ -11,6 +11,7 @@ class PagesController extends \yii\web\Controller { return [ 'index' => \yii_app\actions\pages\IndexAction::class, + 'statistics' => \yii_app\actions\pages\StatisticsAction::class, ]; } } \ No newline at end of file diff --git a/erp24/records/PageStatistics.php b/erp24/records/PageStatistics.php new file mode 100644 index 0000000..90f8923 --- /dev/null +++ b/erp24/records/PageStatistics.php @@ -0,0 +1,57 @@ + 255], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'admin_id' => 'Admin ID', + 'url' => 'Url', + 'post' => 'Post-запрос', + 'created_at' => 'Created At', + ]; + } + + public function getAdmin() { + return $this->hasOne(Admin::class, ['id' => 'admin_id']); + } +} diff --git a/erp24/views/pages/statistics.php b/erp24/views/pages/statistics.php new file mode 100644 index 0000000..15f45b2 --- /dev/null +++ b/erp24/views/pages/statistics.php @@ -0,0 +1,37 @@ + + +
+ +
+ + $dataProvider, + 'columns' => [ + 'id', + [ + 'label' => 'Пользователь', + 'format' => 'html', + 'value' => function ($model) { + return $model->admin->name ?? ''; + } + ], + 'url', + [ + 'label' => 'Время', + 'format' => 'html', + 'value' => function ($model) { + return \yii_app\services\DateTimeService::formatHuman($model->created_at); + } + ], + 'post' + ] + ]);?> + +
+
diff --git a/erp24/web/index.php b/erp24/web/index.php index 20583dc..2156800 100644 --- a/erp24/web/index.php +++ b/erp24/web/index.php @@ -25,6 +25,7 @@ if ( && strpos($url, '/i/') !== 0 && strpos($url, '/debug/default/toolbar') !== 0 && strpos($url, '/assets/') !== 0 + && strpos($url, '/pages/statistics') !== 0 ) { $postJson = Yii::$app->request->post(); unset($postJson["_csrf"]);