Ejemplo n.º 1
2
  public Long getBookingSlotsLeft(TimeSlot timeSlot, Offer offer, List<Booking> confirmedBookings) {
    checkForBookedCourts(timeSlot, confirmedBookings, true);

    Long bookingSlotsLeft = offer.getMaxConcurrentBookings();
    for (Booking existingBooking : timeSlot.getBookings()) {
      if (existingBooking.getOffer().equals(offer)) {
        bookingSlotsLeft--;
      }
    }
    return bookingSlotsLeft;
  }
Ejemplo n.º 2
0
 public void sendBookingConfirmation(HttpServletRequest request, Booking booking)
     throws MailException, IOException {
   Mail mail = new Mail();
   mail.setSubject(msg.get("BookingSuccessfulMailSubject"));
   mail.setBody(
       msg.get(
           "BookingSuccessfulMailBody",
           new Object[] {
             booking.getPlayer().toString(),
             FormatUtils.DATE_MEDIUM.print(booking.getBookingDate()),
             FormatUtils.TIME_HUMAN_READABLE.print(booking.getBookingTime()),
             booking.getName(),
             msg.get(booking.getPaymentMethod().toString()),
             booking.getAmount(),
             booking.getCurrency(),
             CANCELLATION_POLICY_DEADLINE,
             RequestUtil.getBaseURL(request)
                 + "/bookings/booking/"
                 + booking.getUUID()
                 + "/cancel",
             RequestUtil.getBaseURL(request) + "/invoices/booking/" + booking.getUUID(),
             RequestUtil.getBaseURL(request)
           }));
   mail.addRecipient(booking.getPlayer());
   mailUtils.send(mail, request);
 }
Ejemplo n.º 3
0
 private Object[] getDetailBody(HttpServletRequest request, Booking booking) {
   return new Object[] {
     booking.getPlayer().toString(),
     FormatUtils.DATE_HUMAN_READABLE.print(booking.getBookingDate()),
     FormatUtils.TIME_HUMAN_READABLE.print(booking.getBookingTime()),
     booking.getName(),
     msg.get(booking.getPaymentMethod().toString()),
     booking.getAmount(),
     booking.getCurrency(),
     RequestUtil.getBaseURL(request) + "/invoices/booking/" + booking.getUUID(),
     RequestUtil.getBaseURL(request) + "/admin/reports/booking/" + booking.getId()
   };
 }
Ejemplo n.º 4
0
 public void sendNewBookingNotification(HttpServletRequest request, Booking booking)
     throws MailException, IOException {
   List<Contact> contactsToNotifyOnBooking = contactDAO.findAllForBookings();
   if (!contactsToNotifyOnBooking.isEmpty()) {
     Mail mail = new Mail();
     mail.setSubject(
         msg.get(
             "BookingSuccessfulMailSubjectAdmin",
             new Object[] {
               FormatUtils.DATE_HUMAN_READABLE.print(booking.getBookingDate()),
               FormatUtils.TIME_HUMAN_READABLE.print(booking.getBookingTime()),
               booking.getPlayer().toString()
             }));
     mail.setBody(msg.get("BookingSuccessfulMailBodyAdmin", getDetailBody(request, booking)));
     mail.setRecipients(contactsToNotifyOnBooking);
     mailUtils.send(mail, request);
   }
 }
Ejemplo n.º 5
0
  public void checkForBookedCourts(
      TimeSlot timeSlot, List<Booking> confirmedBookings, Boolean preventOverlapping) {
    LocalTime startTime = timeSlot.getStartTime();
    LocalTime endTime = timeSlot.getEndTime();

    for (Booking booking : confirmedBookings) {

      if (timeSlot.getDate().equals(booking.getBookingDate())) {
        LocalTime bookingStartTime = booking.getBookingTime();
        LocalTime bookingEndTime = bookingStartTime.plusMinutes(booking.getDuration().intValue());
        Boolean addBooking = false;
        if (preventOverlapping) {
          if (startTime.isBefore(bookingEndTime)) {
            if (endTime.isAfter(bookingStartTime)) {
              addBooking = true;
            }
          }
        } else {
          // for displaying allocations
          if (startTime.compareTo(bookingStartTime) >= 0) {
            if (endTime.compareTo(bookingEndTime) <= 0) {
              addBooking = true;
            }
          }
        }
        if (addBooking) {
          Offer offer = booking.getOffer();
          for (Offer timeSlotOffer : timeSlot.getConfig().getOffers()) {
            if (offer.equals(timeSlotOffer)) {
              timeSlot.addBooking(booking);
              break;
            }
          }
        }
      }
    }
  }