public function soon($for = null) { if ($for) { return UserSession::findOne(['user_id' => $for->getId(), 'stop' => null]); } return SessionModel::findOne(['stop' => null]); }
public function actionIndex($sessionId = null) { if (!$sessionId) { $session = yii::$app->worksess->soon(); } else { $session = Session::findOne($sessionId); } $sessions = yii::$app->worksess->getSessions(null, $date); if ($session) { $data = yii::$app->service->getReportBySession($session); if ($session) { $date = date('Y-m-d', $session->start_timestamp); } else { $date = date('Y-m-d'); } return $this->render('index', ['data' => $data, 'date' => $date, 'session' => $session, 'sessions' => $sessions, 'sessionId' => $sessionId, 'module' => $this->module, 'currency' => $this->module->currency]); } else { return $this->render('index', ['sessions' => $sessions, 'session' => false, 'module' => $this->module]); } }