Example #1
0
 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]);
 }
Example #2
0
 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;
 }
Example #3
0
 public function getTotalCounter()
 {
     $query = Sitecounter::find()->where(['module' => 'site']);
     $cnt = $query->count();
     return $cnt;
 }