public function actionDatePicker()
 {
     $reservationUpdated = false;
     $reservation = Reservation::findOne(1);
     if (isset($_POST['Reservation'])) {
         $reservation->load(Yii::$app->request->post());
         $reservation->date_from = Yii::$app->formatter->asDate(date_create_from_format('d/m/Y', $reservation->date_from), 'php:Y-m-d');
         $reservation->date_to = Yii::$app->formatter->asDate(date_create_from_format('d/m/Y', $reservation->date_to), 'php:Y-m-d');
         $reservationUpdated = $reservation->save();
     }
     return $this->render('datePicker', ['reservation' => $reservation, 'reservationUpdated' => $reservationUpdated]);
 }
 public function actionDetailDependentDropdown()
 {
     $showDetail = false;
     $model = new Reservation();
     if (isset($_POST['Reservation'])) {
         $model->load(Yii::$app->request->post());
         if (isset($_POST['Reservation']['id']) && $_POST['Reservation']['id'] != null) {
             $model = Reservation::findOne($_POST['Reservation']['id']);
             $showDetail = true;
         }
     }
     return $this->render('detailDependentDropdown', ['model' => $model, 'showDetail' => $showDetail]);
 }
Beispiel #3
0
 public function actionIndexWithRelationships()
 {
     $room_id = Yii::$app->request->get('room_id', null);
     $reservation_id = Yii::$app->request->get('reservation_id', null);
     $customer_id = Yii::$app->request->get('customer_id', null);
     $roomSelected = null;
     $reservationSelected = null;
     $customerSelected = null;
     if ($room_id != null) {
         $roomSelected = Room::findOne($room_id);
         $rooms = array($roomSelected);
         $reservations = $roomSelected->reservations;
         $customers = $roomSelected->customers;
     } elseif ($reservation_id != null) {
         $reservationSelected = Reservation::findOne($reservation_id);
         $rooms = array($reservationSelected->room);
         $reservations = array($reservationSelected);
         $customers = array($reservationSelected->customer);
     } elseif ($customer_id != null) {
         $customerSelected = Customer::findOne($customer_id);
         $rooms = $customerSelected->rooms;
         $reservations = $customerSelected->reservations;
         $customers = array($customerSelected);
     } else {
         $rooms = Room::find()->all();
         $reservations = Reservation::find()->all();
         $customers = Customer::find()->all();
     }
     return $this->render('indexWithRelationShips', compact('roomSelected', 'reservationSelected', 'customerSelected', 'rooms', 'reservations', 'customers'));
 }
 /**
  * Finds the Reservation model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Reservation the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Reservation::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }