Commit e56f9384 by Скуратович Александр

статистика

1 parent 718eac42
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\controllers; namespace app\controllers;
use app\components\Collection; use app\components\Collection;
use app\models\Host;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Controller; use yii\web\Controller;
...@@ -24,7 +25,7 @@ class SiteController extends Controller ...@@ -24,7 +25,7 @@ class SiteController extends Controller
'class' => AccessControl::className(), 'class' => AccessControl::className(),
'rules' => [ 'rules' => [
[ [
'actions' => ['index','logout'], 'actions' => ['index', 'logout'],
'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
], ],
...@@ -66,8 +67,13 @@ class SiteController extends Controller ...@@ -66,8 +67,13 @@ class SiteController extends Controller
{ {
//var_dump(Yii::$app->user->isGuest); //var_dump(Yii::$app->user->isGuest);
//var_dump(Yii::$app->user->identity); //var_dump(Yii::$app->user->identity);
$statistics = ['csv_date' => ''];
return $this->render('index'); $statistics['c_status'] = Host::find()->select(['COUNT(*) AS cnt', 'wis_status'])->groupBy('wis_status')->all();
$csv = Host::find()->select(['csv_date'])->orderBy('csv_date ASC')->one();
if ($csv) {
$statistics['csv_date'] = $csv['csv_date'];
}
return $this->render('index', compact('statistics'));
} }
} }
...@@ -23,6 +23,7 @@ class Host extends \yii\db\ActiveRecord ...@@ -23,6 +23,7 @@ class Host extends \yii\db\ActiveRecord
const STATUS_FREE = 1; //Свободный const STATUS_FREE = 1; //Свободный
const STATUS_BUSY = 2; //Занятый const STATUS_BUSY = 2; //Занятый
public $cnt;
/** /**
* {@inheritdoc} * {@inheritdoc}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!