Search in sources :

Example 1 with TicketReservation

use of alfio.model.TicketReservation in project alf.io by alfio-event.

the class TicketController method generateTicketCode.

@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/code.png", method = RequestMethod.GET)
public void generateTicketCode(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, HttpServletResponse response) throws IOException, WriterException {
    Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
    if (!oData.isPresent()) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        return;
    }
    Triple<Event, TicketReservation, Ticket> data = oData.get();
    Event event = data.getLeft();
    Ticket ticket = data.getRight();
    String qrCodeText = ticket.ticketCode(event.getPrivateKey());
    response.setContentType("image/png");
    response.getOutputStream().write(ImageUtil.createQRCode(qrCodeText));
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) Ticket(alfio.model.Ticket) Event(alfio.model.Event) TicketReservation(alfio.model.TicketReservation)

Example 2 with TicketReservation

use of alfio.model.TicketReservation in project alf.io by alfio-event.

the class TicketController method internalSendTicketByEmail.

private Ticket internalSendTicketByEmail(HttpServletRequest request, Triple<Event, TicketReservation, Ticket> data) throws IOException {
    Ticket ticket = data.getRight();
    Event event = data.getLeft();
    Locale locale = LocaleUtil.getTicketLanguage(ticket, request);
    TicketReservation reservation = data.getMiddle();
    Organization organization = organizationRepository.getById(event.getOrganizationId());
    TicketCategory category = ticketCategoryRepository.getById(ticket.getCategoryId());
    notificationManager.sendTicketByEmail(ticket, event, locale, TemplateProcessor.buildPartialEmail(event, organization, reservation, category, templateManager, ticketReservationManager.ticketUpdateUrl(event, ticket.getUuid()), request), reservation, ticketCategoryRepository.getByIdAndActive(ticket.getCategoryId(), event.getId()));
    return ticket;
}
Also used : Locale(java.util.Locale) Ticket(alfio.model.Ticket) Organization(alfio.model.user.Organization) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) TicketReservation(alfio.model.TicketReservation)

Example 3 with TicketReservation

use of alfio.model.TicketReservation in project alf.io by alfio-event.

the class TicketController method generateTicketPdf.

@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/download-ticket", method = RequestMethod.GET)
public void generateTicketPdf(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, HttpServletRequest request, HttpServletResponse response) throws IOException, WriterException {
    Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
    if (!oData.isPresent()) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        return;
    }
    Triple<Event, TicketReservation, Ticket> data = oData.get();
    Ticket ticket = data.getRight();
    response.setContentType("application/pdf");
    response.addHeader("Content-Disposition", "attachment; filename=ticket-" + ticketIdentifier + ".pdf");
    try (OutputStream os = response.getOutputStream()) {
        PdfBoxRenderer renderer = preparePdfTicket(request, data.getLeft(), data.getMiddle(), ticket).generate(ticket);
        if (renderer != null) {
            renderer.createPDF(os);
        }
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) Ticket(alfio.model.Ticket) OutputStream(java.io.OutputStream) Event(alfio.model.Event) TicketReservation(alfio.model.TicketReservation) PdfBoxRenderer(com.openhtmltopdf.pdfboxout.PdfBoxRenderer)

Example 4 with TicketReservation

use of alfio.model.TicketReservation in project alf.io by alfio-event.

the class TicketController method internalShowTicket.

private String internalShowTicket(String eventName, String ticketIdentifier, boolean ticketEmailSent, Model model, String backSuffix, Locale locale) {
    Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
    if (!oData.isPresent()) {
        return "redirect:/event/" + eventName;
    }
    Triple<Event, TicketReservation, Ticket> data = oData.get();
    TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(data.getRight().getCategoryId(), data.getLeft().getId());
    Organization organization = organizationRepository.getById(data.getLeft().getOrganizationId());
    Event event = data.getLeft();
    TicketReservation reservation = data.getMiddle();
    // 
    model.addAttribute("ticket", data.getRight()).addAttribute("reservation", // 
    reservation).addAttribute("event", // 
    event).addAttribute("ticketCategory", // 
    ticketCategory).addAttribute("organization", // 
    organization).addAttribute("ticketEmailSent", ticketEmailSent).addAttribute("reservationId", ticketReservationManager.getShortReservationID(event, reservation.getId())).addAttribute("deskPaymentRequired", Optional.ofNullable(reservation.getPaymentMethod()).orElse(PaymentProxy.STRIPE).isDeskPaymentRequired()).addAttribute("backSuffix", backSuffix).addAttribute("userLanguage", locale.getLanguage()).addAttribute("pageTitle", "show-ticket.header.title").addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()).addAttribute("validityStart", Optional.ofNullable(ticketCategory.getTicketValidityStart(event.getZoneId())).orElse(event.getBegin())).addAttribute("validityEnd", Optional.ofNullable(ticketCategory.getTicketValidityEnd(event.getZoneId())).orElse(event.getEnd())).addAttribute("ticketIdParam", "ticketId=" + ticketIdentifier);
    return "/event/show-ticket";
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) Ticket(alfio.model.Ticket) Organization(alfio.model.user.Organization) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) TicketReservation(alfio.model.TicketReservation)

Example 5 with TicketReservation

use of alfio.model.TicketReservation in project alf.io by alfio-event.

the class TicketController method showTicketForUpdate.

@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/update", method = RequestMethod.GET)
public String showTicketForUpdate(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, Model model, Locale locale) {
    Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
    if (!oData.isPresent()) {
        return "redirect:/event/" + eventName;
    }
    Triple<Event, TicketReservation, Ticket> data = oData.get();
    Event event = data.getLeft();
    TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(data.getRight().getCategoryId(), event.getId());
    Organization organization = organizationRepository.getById(event.getOrganizationId());
    boolean enableFreeCancellation = configurationManager.getBooleanConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ticketCategory.getId(), ALLOW_FREE_TICKETS_CANCELLATION), false);
    Ticket ticket = data.getRight();
    // 
    model.addAttribute("ticketAndCategory", Pair.of(eventManager.getTicketCategoryById(ticket.getCategoryId(), event.getId()), new TicketDecorator(ticket, enableFreeCancellation, eventManager.checkTicketCancellationPrerequisites().apply(ticket), "ticket/" + ticket.getUuid() + "/view", ticketHelper.findTicketFieldConfigurationAndValue(event.getId(), ticket, locale), true, ""))).addAttribute("reservation", // 
    data.getMiddle()).addAttribute("reservationId", ticketReservationManager.getShortReservationID(event, data.getMiddle().getId())).addAttribute("event", // 
    event).addAttribute("ticketCategory", // 
    ticketCategory).addAttribute("countries", TicketHelper.getLocalizedCountries(locale)).addAttribute("organization", // 
    organization).addAttribute("pageTitle", "show-ticket.header.title").addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName());
    return "/event/update-ticket";
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) TicketDecorator(alfio.controller.support.TicketDecorator) Ticket(alfio.model.Ticket) Organization(alfio.model.user.Organization) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) TicketReservation(alfio.model.TicketReservation)

Aggregations

Event (alfio.model.Event)5 Ticket (alfio.model.Ticket)5 TicketReservation (alfio.model.TicketReservation)5 Triple (org.apache.commons.lang3.tuple.Triple)4 TicketCategory (alfio.model.TicketCategory)3 Organization (alfio.model.user.Organization)3 TicketDecorator (alfio.controller.support.TicketDecorator)1 PdfBoxRenderer (com.openhtmltopdf.pdfboxout.PdfBoxRenderer)1 OutputStream (java.io.OutputStream)1 Locale (java.util.Locale)1