예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Session::find();
     $query->select('s.name as service,u.name as username,u1.name as mentorname,mbb.user_id,mbb.mentor_id,mbb.service_id,mbb.id,mbb.type,mbb.status,mbb.datetime_from as date, mbb.datetime_from as time,mbb.booking_hrs,mbb.paid_from');
     $query->leftjoin('users as u', 'u.id=mbb.user_id');
     $query->leftJoin('users as u1', 'u1.id=mbb.mentor_id');
     $query->leftjoin('ms_service as s', 's.id=mbb.service_id');
     $query->where('mbb.type = "book" AND mbb.status != "C"');
     $query->orderBy('mbb.id DESC');
     $query->from('mbb as mbb ');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     $dataProvider->sort->attributes['username'] = ['asc' => ['u.name' => SORT_ASC], 'desc' => ['u.name' => SORT_DESC]];
     $dataProvider->sort->attributes['service'] = ['asc' => ['s.name' => SORT_ASC], 'desc' => ['s.name' => SORT_DESC]];
     $dataProvider->sort->attributes['mentorname'] = ['asc' => ['u1.name' => SORT_ASC], 'desc' => ['u1.name' => SORT_DESC]];
     $dataProvider->sort->attributes['date'] = ['asc' => ['mbb.datetime_from' => SORT_ASC], 'desc' => ['mbb.datetime_from' => SORT_DESC]];
     $dataProvider->sort->attributes['time'] = ['asc' => ['mbb.datetime_from' => SORT_ASC], 'desc' => ['mbb.datetime_from' => SORT_DESC]];
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['mbb.mentor_id' => $this->mentor_id, 'datetime_from' => $this->datetime_from, 'mbb.service_id' => $this->service_id, 'hourly_fee' => $this->hourly_fee, 'total_fee' => $this->total_fee, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'mbb.type', $this->type])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'mbb.status', $this->status])->andFilterWhere(['like', 'u.name', $this->username])->andFilterWhere(['like', 'u1.name', $this->mentorname])->andFilterWhere(['like', 's.name', $this->service])->andFilterWhere(['like', 'mbb.datetime_from', $this->date])->andFilterWhere(['like', 'mbb.datetime_from', $this->time])->andFilterWhere(['like', 'mbb.booking_hrs', $this->booking_hrs])->andFilterWhere(['like', 'mbb.paid_from', $this->paid_from]);
     return $dataProvider;
 }
예제 #2
0
 public function actionIndex()
 {
     $cateCount = Category::find()->count();
     $productCount = Product::find()->count();
     $onlineCount = Session::find()->where(['status' => 1])->count();
     $userCount = Session::find()->count();
     return $this->render('index', ['cateCount' => $cateCount, 'productCount' => $productCount, 'onlineCount' => $onlineCount, 'userCount' => $userCount]);
 }
예제 #3
0
 public static function logStat()
 {
     if (Yii::$app->user->isGuest && !Yii::$app->session->has('stat')) {
         $model = Session::find()->where(['id' => Yii::$app->session->id])->one();
         if ($model === null) {
             $model = new Session();
             $model->id = Yii::$app->session->id;
             $model->ip = Yii::$app->request->userIP;
             $model->user_agent = Yii::$app->request->userAgent;
             $model->created = $model->modified = time();
             $model->save();
         }
         Session::updateAll(['status' => 0], 'modified < :time', [':time' => time() - 15 * 60]);
         Yii::$app->session->set('stat', true);
     }
 }
예제 #4
0
 public function getSessionWithId($sessionId)
 {
     return Session::find($sessionId);
 }