File indexing completed on 2024-12-29 04:51:06

0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 function parsePdfTicket(pdf, node, triggerNode) {
0005     const page = pdf.pages[triggerNode.location];
0006 
0007     const leftSidebarText = page.textInRect(0, 0.3, 0.3, 1).split('\n');
0008 
0009     const res = JsonLd.newEventReservation();
0010     res.reservationNumber = triggerNode.content;
0011     res.reservationFor.location.name = "Kino " + leftSidebarText[6];
0012     res.reservationFor.location.address.streetAddress = leftSidebarText[7];
0013     res.reservationFor.location.address.addressLocality = leftSidebarText[8];
0014 
0015     const mainText = page.textInRect(0.3, 0, 1, 1);
0016 
0017     const dt = mainText.match(/Datum (.*) \w* Zeit (.*) Uhr/);
0018     res.reservationFor.startDate = JsonLd.toDateTime(dt[1].trim() + ' ' + dt[2].trim(), 'dd.MM.yyyy hh:mm', 'de');
0019 
0020     res.underName = mainText.match(/Gebucht von (.*)/)[0];
0021     res.reservationFor.name = mainText.split('\n').join(' ').match(/Ticket\w*(.*)\w*Kino .* Datum .* Zeit/)[1]
0022 
0023     const seat = mainText.replace('\n', ' ').match(/Saal\w*(.*)\w*Reihe\w*(.*)\w*Platz\w*(.*)\w*/)
0024 
0025     res.reservedTicket.ticketedSeat.seatRow = seat[2];
0026     res.reservedTicket.ticketedSeat.seatNumber = seat[3];
0027     res.reservedTicket.ticketToken = 'qrCode:' + triggerNode.content;
0028 
0029     return res;
0030 }