コード例 #1
0
 public function validateMaxAvailable($attribute, $params)
 {
     $tour_date = ToursDates::findOne($this->tour_date_id);
     if ($this->{$attribute} > $tour_date->getAvailablePlaces($attribute)) {
         $this->addError($attribute, 'Max available places for this field is ' . $tour_date->getAvailablePlaces($attribute));
     }
 }
コード例 #2
0
 public function actionBookPlace($tour_date_id)
 {
     $model = new BookingsForm();
     $tour_date = ToursDates::findOne($tour_date_id);
     $query = new Query();
     $custom_fields = CustomFields::getCustomFieldsArray($tour_date->tour_id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', 'Congratulations! Places successful booked');
         return $this->redirect(['tour-details', Tours::FIELD_TOUR_ID => $tour_date->tour_id]);
     }
     return $this->render('book_place', ['model' => $model, 'tour_date' => $tour_date, 'custom_fields' => $custom_fields]);
 }
コード例 #3
0
 public function actionViewDetailsTourDate($tour_date_id)
 {
     $model = ToursDates::findOne($tour_date_id);
     $dataProvider = new ActiveDataProvider(['query' => Bookings::find()->where([Bookings::FIELD_TOUR_DATE_ID => $tour_date_id])]);
     return $this->render('details_tour_date', ['model' => $model, 'dataProvider' => $dataProvider]);
 }