/**
  * Finds the Tour model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tour the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findTour($id)
 {
     if (($model = Tour::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Updates an existing TourField model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $tourModel = \app\models\Tour::findOne(['id' => $model->tour_id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'id' => $model->tour_id, 'tourModel' => $tourModel]);
     }
 }
示例#3
0
 public function actionTour($id)
 {
     /** @var Tour $model */
     $model = Tour::findOne(['id' => $id]);
     if ($model === null) {
         throw new NotFoundHttpException("Такого тура не существует");
     } else {
         $provider = new ActiveDataProvider(['query' => $model->getCouples()]);
         return $this->render('list', ['provider' => $provider, 'tour' => $model]);
     }
 }
示例#4
0
文件: AddForm.php 项目: zlapot/site
 public function upgrade($id)
 {
     $tour = Tour::findOne($id);
     $tour->name = $this->name;
     $tour->org = $this->org;
     $tour->tel = $this->tel;
     $tour->address = $this->address;
     $tour->info = $this->info;
     $tour->site = $this->site;
     $tour->save(false);
     return $tour ? $tour : null;
 }
示例#5
0
 public function actionUpdate($id)
 {
     $model = new AddForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $tour = $model->upgrade($id);
         if (!$tour) {
             Yii::$app->session->setFlash('error', 'Ошибка при валидации');
             Yii::error('Ошибка при валидации');
             return $this->goHome();
         }
     }
     $tour = Tour::findOne($id);
     return $this->render('update', ['model' => $model, 'tour' => $tour]);
 }
示例#6
0
 public function actionDelete($id)
 {
     $request = Yii::$app->request;
     $tour = null;
     if ($id != null) {
         $tour_field = TourFields::findOne($id);
         if ($tour_field != null) {
             $tour = Tour::findOne($tour_field->tour_id);
             $tour_field->delete();
             Yii::$app->getSession()->setFlash('message', Yii::t('app', "Custom field #{$tour_field->id} deleted."));
         }
     }
     if ($tour) {
         return $this->redirect("/tour/{$tour->id}");
     } else {
         return $this->redirect("/tour");
     }
 }
示例#7
0
 public function add($id)
 {
     $order = new Order();
     $order->id_tour = $id;
     $order->id_user = Yii::$app->user->id;
     $order->name = $this->name;
     $order->tel = $this->tel;
     $order->count = $this->count;
     $order->email = $this->email;
     $order->info = $this->info;
     $order->date_tour = $this->date_tour;
     $order->date = date('Y-m-d h:m:s');
     $order->status = $this->status;
     $tour = Tour::findOne($id);
     $order->id_owner = $tour->id_user;
     $order->tour_name = $tour->name;
     $order->save(false);
     return $order ? $order : null;
 }
示例#8
0
 public function upload($id)
 {
     if ($this->validate()) {
         $it = 0;
         foreach ($this->imageFiles as $file) {
             $path = 'uploads/' . $id . 'n' . $it . '.' . $file->extension;
             $file->saveAs($path);
             $gallery = new Gallery();
             $gallery->id_tour = $id;
             $gallery->path = $path;
             $gallery->save(false);
             ++$it;
         }
         $img = Tour::findOne(['id' => $id]);
         $img->image = 'uploads/' . $id . 'n0' . '.' . $this->imageFiles[0]->extension;
         $img->save(false);
         return true;
     } else {
         return false;
     }
 }
示例#9
0
 public function actionTour($id)
 {
     $tour = Tour::findOne($id);
     return $this->render('tour', ['tour' => $tour]);
 }
示例#10
0
文件: Tour.php 项目: zlapot/site
 public function del($id)
 {
     $tour = Tour::findOne($id);
     $tour->delete();
 }
 public function actionBook($id)
 {
     $noPostData = true;
     $tourTitle = Tour::findOne($id)->title;
     $modelBook = new \app\models\Book();
     $modelTourFields = \app\models\TourField::find()->where(['tour_id' => $id])->orderBy('position')->all();
     $modelBookValues = $this->getBookValuesArray(count($modelTourFields));
     //print '<pre>'; print_r(Yii::$app->request->post()); die();
     $BookValues = Yii::$app->request->post('BookValues');
     $ValuesType = Yii::$app->request->post('ValuesType');
     $Date = Yii::$app->request->post('Date');
     if ($BookValues && $ValuesType) {
         $noPostData = false;
     }
     if (!$noPostData && Tour::validateReservationData($BookValues, $ValuesType)) {
         if ($BookValues && $Date && $this->bookTour($modelBook, $id, $Date, $modelBookValues, $BookValues, $modelTourFields)) {
             return $this->redirect(['list']);
         }
     } else {
         return $this->render('book', ['modelBookValues' => $modelBookValues, 'modelTourFields' => $modelTourFields, 'modelBook' => $modelBook, 'tourTitle' => $tourTitle, 'success' => $noPostData]);
     }
 }