public function actionMultipleGrid()
 {
     /**
      * Reservations
      */
     $reservationsQuery = Reservation::find();
     $reservationsSearchModel = new ReservationSearch();
     if (isset($_GET['ReservationSearch'])) {
         $reservationsSearchModel->load(Yii::$app->request->get());
         $reservationsQuery->joinWith(['customer']);
         $reservationsQuery->andFilterWhere(['LIKE', 'customer.name', $reservationsSearchModel->getAttribute('customer.name')]);
         $reservationsQuery->andFilterWhere(['LIKE', 'customer.surname', $reservationsSearchModel->getAttribute('customer.surname')]);
         $reservationsQuery->andFilterWhere(['id' => $reservationsSearchModel->id, 'customer_id' => $reservationsSearchModel->customer_id, 'room_id' => $reservationsSearchModel->room_id, 'price_per_day' => $reservationsSearchModel->price_per_day]);
     }
     $resultQueryAveragePricePerDay = $reservationsQuery->average('price_per_day');
     $dataProvider = new ActiveDataProvider(['query' => $reservationsQuery, 'sort' => ['sortParam' => 'reservations-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'reseravations-page-param']]);
     $reservationsDataProvider = new ActiveDataProvider(['query' => $reservationsQuery, 'sort' => ['sortParam' => 'reservations-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'reservations-page-param']]);
     /**
      * Rooms
      */
     $roomsQuery = Room::find();
     $roomsSearchModel = new Room();
     if (isset($_GET['Room'])) {
         $roomsSearchModel->load(Yii::$app->request->get());
         $roomsQuery->andFilterWhere(['id' => $roomsSearchModel->id, 'floor' => $roomsSearchModel->floor, 'room_number' => $roomsSearchModel->room_number, 'has_conditioner' => $roomsSearchModel->has_conditioner, 'has_phone' => $roomsSearchModel->has_phone, 'has_tv' => $roomsSearchModel->has_tv, 'available_from' => $roomsSearchModel->available_from]);
     }
     $roomsDataProvider = new ActiveDataProvider(['query' => $roomsQuery, 'sort' => ['sortParam' => 'rooms-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'rooms-page-param']]);
     return $this->render('multipleGrid', ['reservationsDataProvider' => $reservationsDataProvider, 'reservationsSearchModel' => $reservationsSearchModel, 'roomsDataProvider' => $roomsDataProvider, 'roomsSearchModel' => $roomsSearchModel, 'resultQueryAveragePricePerDay' => $resultQueryAveragePricePerDay]);
 }
Пример #2
0
 public function actionGrid()
 {
     $query = Reservation::find();
     $searchModel = new Reservation();
     if (isset($_GET['Reservation'])) {
         $searchModel->load(Yii::$app->request->get());
         $query->andFilterWhere(['customer_id' => isset($_GET['Reservation']['customer_id']) ? $_GET['Reservation']['customer_id'] : null]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $this->render('grid', compact('dataProvider'));
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Reservation::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'room_id' => $this->room_id, 'customer_id' => $this->customer_id, 'price_per_day' => $this->price_per_day, 'date_from' => $this->date_from, 'date_to' => $this->date_to, 'reservation_date' => $this->reservation_date]);
     return $dataProvider;
 }
Пример #4
0
 public function actionGrid()
 {
     $queryReservation = Reservation::find();
     $queryRoom = Room::find();
     $searchReservation = new ReservationSearch();
     $searchRoom = new Room();
     if (isset($_GET['ReservationSearch'])) {
         $searchReservation->load(Yii::$app->request->get());
         $queryReservation->joinWith(['customer']);
         $queryReservation->andFilterWhere(['LIKE', 'customer.surname', $searchReservation->getAttribute('customer.surname')]);
         $queryReservation->andFilterWhere(['id' => $searchReservation->id, 'room_id' => $searchReservation->room_id, 'customer_id' => $searchReservation->customer_id, 'price_per_day' => $searchReservation->price_per_day]);
     }
     $avg = $queryReservation->average('price_per_day');
     if (isset($_GET['Room'])) {
         $searchRoom->load(Yii::$app->request->get());
         $queryRoom->andFilterWhere(['id' => $searchRoom->id, 'floor' => $searchRoom->floor, 'room_number' => $searchRoom->room_number, 'has_conditioner' => $searchRoom->has_conditioner, 'has_tv' => $searchRoom->has_tv, 'has_phone' => $searchRoom->has_phone, 'available_from' => $searchRoom->available_from, 'price_per_day' => $searchRoom->price_per_day, 'description' => $searchRoom->description]);
     }
     $dataReservation = new ActiveDataProvider(['query' => $queryReservation, 'sort' => ['sortParam' => 'reservations_sort_param'], 'pagination' => ['pageSize' => 3, 'pageParam' => 'reservations_page_param']]);
     $dataRoom = new ActiveDataProvider(['query' => $queryRoom, 'sort' => ['sortParam' => 'rooms_sort_param'], 'pagination' => ['pageSize' => 3, 'pageParam' => 'rooms_sort_param']]);
     return $this->render('grid', ['dataReservation' => $dataReservation, 'dataRoom' => $dataRoom, 'searchReservation' => $searchReservation, 'searchRoom' => $searchRoom, 'averagePrice' => $avg]);
 }
 public function actionMultiGrid()
 {
     $query = Reservation::find();
     $searchModel = new ReservationSearch();
     if (isset($_GET['ReservationSearch'])) {
         $searchModel->load(\Yii::$app->request->get());
         $query->joinWith(['customer']);
         $query->andFilterWhere(['LIKE', 'customer.surname', $searchModel->getAttribute('customer.surname')]);
         $query->andFilterWhere(['id' => $searchModel->id, 'customer_id' => $searchModel->customer_id, 'room_id' => $searchModel->room_id, 'price_per_day' => $searchModel->price_per_day]);
     }
     $allAvgPc = $query->average('price_per_day');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 2]]);
     $Roomquery = \app\models\Room::find();
     $RoomsearchModel = new \app\models\Room();
     if (isset($_GET['Room'])) {
         $RoomsearchModel->load(\Yii::$app->request->get());
         $Roomquery->andFilterWhere(['id' => $RoomsearchModel->id, 'floor' => $RoomsearchModel->floor, 'room_number' => $RoomsearchModel->room_number, 'has_conditioner' => $RoomsearchModel->has_conditioner, 'has_phone' => $RoomsearchModel->has_conditioner, 'has_tv' => $RoomsearchModel->has_conditioner, 'available_from' => $RoomsearchModel->has_conditioner]);
     }
     $RoomdataProvider = new ActiveDataProvider(['query' => $Roomquery, 'sort' => ['sortParam' => 'rooms-sort'], 'pagination' => ['pageSize' => 2, 'pageParam' => 'rooms-page']]);
     return $this->render("multiGrid", ['reservationsDataProvider' => $dataProvider, 'reservationsSearchModel' => $searchModel, 'roomsDataProvider' => $RoomdataProvider, 'roomsSearchModel' => $RoomsearchModel]);
 }
Пример #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $all = $request->all();
     $rooms = json_decode($all['rrooms'], true);
     $now = date('Y-m-d H:i:s');
     $reservecode = isset($all['reserve_code']) && trim($all['reserve_code']) != '' ? $all['reserve_code'] : Reservation::generateReserveCode();
     $reservation = ["guest_id" => $all['guest_id'], "reserve_date" => $all['reserve_date'], "Partner" => $all['partner'], "pax" => $all['pax'], "pickup_time" => $all['pickup_time'], "pickup_location" => $all['pickup_location'], "notes" => $all['notes'], "reserve_fee" => $all['reserve_fee'], "card_type" => $all['cardType'], "date_created" => $now, "date_updated" => $now, "batch_number" => $all['batch_number'], "is_debit" => isset($all['is_debit']) ? 1 : 0, "card_suffix" => $all['card_suffix'], "multi_entry_approver" => ""];
     $res = Reservation::find($reservecode);
     if (is_null($res)) {
         $reservation['reserve_code'] = $reservecode;
         Reservation::create($reservation);
     } else {
         Reservation::find($reservecode)->update($reservation);
     }
     $partnerTrxn = ["booking_number" => $all['booking_number'], "payable" => $all['commission'], "transaction_date" => $all['reserve_date'], "reserve_code" => $reservecode, "result_status" => 'Confirmed', "receivable" => '0.00', "partner_name" => $all['partner'], "remarks" => $all['remarks']];
     $pt = PartnerTransaction::where(['reserve_code' => $reservecode])->get()->first();
     if (is_null($pt)) {
         PartnerTransaction::create($partnerTrxn);
     } else {
         $pt->update($partnerTrxn);
     }
     $this->saveReserveRooms($rooms, $reservecode);
     return redirect('reservations' . '?reserve_code=' . $reservecode)->with('status', 'Reservation data saved');
 }
Пример #7
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'));
 }