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

статистика

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