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));
}
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;
}
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);
}
}
}
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";
}
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";
}
Aggregations