/** * Execute the action */ public function execute() { parent::execute(); $room['room_id'] = \SpoonFilter::getPostValue('room_id', null, 0); $room['arrival'] = \SpoonFilter::getPostValue('arrival', null, ''); $room['departure'] = \SpoonFilter::getPostValue('departure', null, ''); $room['client_name'] = \SpoonFilter::getPostValue('client_name', null, ''); $room['client_email'] = \SpoonFilter::getPostValue('client_email', null, ''); if (!$room['arrival'] || !$room['departure'] || !$room['room_id'] || !$room['room_id']) { $this->output(self::ERROR, 'Missing values'); } $sent = FrontendBookingsModel::reserveRoom($room); if ($sent) { // output $this->output(self::OK, 'Booking sent'); } else { // output $this->output(self::ERROR, 'Error sending'); } }
/** * Execute the action */ public function execute() { parent::execute(); $hotelId = \SpoonFilter::getPostValue('hotel_id', null, 0); if (!$hotelId) { $this->output(self::ERROR, 'Missing values'); } $hotel = FrontendBookingsModel::getHotel($hotelId); if ($hotel) { $museums = FrontendBookingsModel::getMuseums($hotel['country'], $hotel['city']); $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Museums.tpl'; $museumsTpl = new Template(false); $museumsTpl->assign('hotel', $hotel); $museumsTpl->assign('museums', $museums); $html = $museumsTpl->getContent($tpl, true, true); } else { $html = ''; } // output $this->output(self::OK, $html); }
/** * Execute the action */ public function execute() { parent::execute(); $hotelId = \SpoonFilter::getPostValue('hotel_id', null, 0); $arrival = \SpoonFilter::getPostValue('arrival', null, 0); $departure = \SpoonFilter::getPostValue('departure', null, 0); if (!$hotelId && !$arrival && !$departure) { $this->output(self::ERROR, 'Missing values'); } $rooms = FrontendBookingsModel::getRooms($hotelId, $arrival, $departure); foreach ($rooms as &$room) { if ($room['available_rooms'] < 1) { $room['disabled'] = true; } } $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Rooms.tpl'; $roomsTpl = new Template(false); $roomsTpl->assign('rooms', $rooms); $html = $roomsTpl->getContent($tpl, true, true); // output $this->output(self::OK, $html); }
/** * Execute the action */ public function execute() { parent::execute(); $roomId = \SpoonFilter::getPostValue('room_id', null, 0); $room = FrontendBookingsModel::getRoom($roomId); $room['arrival'] = \SpoonFilter::getPostValue('arrival', null, ''); $room['departure'] = \SpoonFilter::getPostValue('departure', null, ''); if (!$room['arrival'] || !$room['departure'] || !$roomId) { $this->output(self::ERROR, 'Missing values'); } if (empty($room)) { $this->output(self::ERROR, 'Room not found'); } $room['stay_duration'] = floor((strtotime($room['departure']) - strtotime($room['arrival'])) / (60 * 60 * 24)); $room['total_price'] = $room['stay_duration'] * $room['price']; $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Room.tpl'; $roomTpl = new Template(false); $roomTpl->assign('room', $room); $html = $roomTpl->getContent($tpl, true, true); // output $this->output(self::OK, $html); }
private function getData() { $this->hotels = FrontendBookingsModel::getHotels(); }