Пример #1
0
 public function getRoomApproveList()
 {
     /** @var Collection $collection */
     $collection = \Yii::$app->get('mongodb')->getCollection(Participant::collectionName());
     $list = $collection->aggregate([['$match' => ['confirmPersonId' => $this->_id, 'log.status' => Participant::STATUS_CONSIDIRATION]], ['$unwind' => '$log'], ['$match' => ['log.status' => Participant::STATUS_CONSIDIRATION]], ['$project' => ['name' => 1, 'request' => '$log.requestId']]]);
     foreach ($list as $key => $value) {
         $list[$key]['request'] = VksRequest::findOne(['_id' => $value['request']]);
     }
     return $list;
 }
Пример #2
0
 public function actionApproveBooking($roomId, $requestId, $status = Participant::STATUS_APPROVE)
 {
     $request = Request::findOne(['_id' => $requestId]);
     if (!$request instanceof Request) {
         throw new NotFoundHttpException("Заявка на бронирование не найдена.");
     }
     $model = new ApproveRoomForm(['approvedRoomId' => $roomId, 'request' => $request]);
     if ($status === Participant::STATUS_CANCEL) {
         $model->scenario = ApproveRoomForm::SCENARIO_CANCEL_ROOM;
     }
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         if ($status === Participant::STATUS_APPROVE) {
             $model->approveRoom($roomId);
         } elseif ($status === Participant::STATUS_CANCEL) {
             $model->cancelRoom($roomId);
         }
         return $this->redirect(['user/booking-approve-list']);
     }
     return $this->render('approve-room', ['model' => $model]);
 }