Пример #1
0
 public function actionRecord()
 {
     if (Yii::$app->user->can('activityRecord')) {
         $dataProvider = [];
         $activities = Activity::getAllActivities();
         foreach ($activities as $activity) {
             $row['id'] = $activity['id'];
             $row['Activity_name'] = $activity['Activity_name'];
             $row['datetime'] = $activity['startDatetime'];
             $row['total'] = ParticipantHasActivity::getTotalJoinCountByActivityId($activity['id']);
             $row['attend'] = ParticipantHasActivity::getTotalAttendCountByActivityId($activity['id']);
             array_push($dataProvider, $row);
         }
         return $this->render('record', ['dataProvider' => $dataProvider]);
     } else {
         if (Yii::$app->user->isGuest) {
             Yii::$app->user->loginRequired();
         } else {
             throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
         }
     }
 }