public function actionIndex($id = null, $action = null) { $model = new Sitecounter(); if ($model->load($_POST)) { $sess = array(); $sess['year'] = $_POST['Sitecounter']['year']; Yii::$app->session->set('sessStat', $sess); } // $sess = Yii::$app->session->get('sessStat'); $model->year = $sess['year']; if (!$model->year) { $model->year = date('Y'); } return $this->render('index', ['model' => $model]); }
public function searchDayBar($month, $year) { $arr = array(); $data = array(); for ($i = 1; $i <= 31; $i++) { $cnt = Sitecounter::find()->where(['module' => 'site'])->andWhere(['DAY(datetime)' => $i])->andWhere(['MONTH(datetime)' => $month])->andWhere(['YEAR(datetime)' => $year])->count(); $data[] = (int) $cnt; } $arr[] = array('name' => 'จำนวน', 'data' => $data); return $arr; }
public function getTotalCounter() { $query = Sitecounter::find()->where(['module' => 'site']); $cnt = $query->count(); return $cnt; }