public function actionInfoWindow($userSessionId)
 {
     $session = UserSession::findOne($userSessionId);
     $stat = yii::$app->order->getStatByDatePeriod($session->start, $session->stop);
     $orders = Order::findAll(['date' > $session->start, 'date' < $session->stop]);
     return $this->renderPartial('info-window', ['module' => yii::$app->getModule('order'), 'session' => $session, 'stat' => $stat, 'orders' => $orders]);
 }
Example #2
0
 public function getSecondsBySession($for = null, $session)
 {
     if ($for) {
         $sum = UserSession::find()->where(['session_id' => $session->id, 'user_id' => $for->getId()])->sum('stop_timestamp-start_timestamp');
         if ($sum === null) {
             if ($sess = UserSession::find()->where(['session_id' => $session->id, 'user_id' => $for->getId()])->one()) {
                 $sum = time() - $sess->start_timestamp;
             }
         }
     } else {
         $sum = SessionModel::find()->where(['session_id' => $session->id])->sum('stop_timestamp-start_timestamp');
         if ($sum === null) {
             if ($sess = SessionModel::find()->where(['session_id' => $session->id])->one()) {
                 $sum = time() - $sess->start_timestamp;
             }
         }
     }
     return $sum;
 }
Example #3
0
 public function getUserSessions()
 {
     return $this->hasMany(UserSession::className(), ['session_id' => 'id']);
 }