<?php /** * Arrival module, this is a rewrite of the old module. */ $ticketManager = TicketManager::getInstance(); $usertable = $sql_prefix . "_users"; $ticketstable = $sql_prefix . "_tickets"; $tickettypestable = $sql_prefix . "_ticketTypes"; $thisModule = "arrival"; $action = isset($_GET['action']) ? $_GET['action'] : null; $acl_ticket = acl_access("ticketadmin", "", $sessioninfo->eventID); $acl_seating = acl_access("seating", "", $sessioninfo->eventID); // Check if user has permission to tickets if ($acl_ticket == 'No') { printNoAccessError(); } $content .= "\n <h1 class=\"page-title\">" . _("Arrival") . "</h1>\n <div class=\"arrival\">"; switch ($action) { //================================================================================== // Ticket detail display case "changeuser": $ticketID = isset($_GET['ticket']) && is_numeric($_GET['ticket']) ? intval($_GET['ticket']) : -1; if ($ticketID < 1) { $content .= "<p>Ugyldig parametere</p>"; } else { $ticket = $ticketManager->getTicket($ticketID); $changeType = isset($_GET['type']) ? $_GET['type'] : 'user'; /* HANDLERS */ if (isset($_GET['set']) && is_numeric($_GET['set']) == true && intval($_GET['set']) > 0) { $ret = "index.php?module={$thisModule}&action=ticketdetail&ticket=" . $ticketID . "&changed=" . $changeType;
// Set ticket as paid. $ticket->setPaid(); $orderInfo["setAsPaid"] = "true"; } else { // TODO: Handle no tickets to set as paid! } } catch (\Stripe\Error\Card $e) { $orderInfo["error"] = strval($e); // no-op } catch (\Stripe\Error\InvalidRequest $e) { $orderInfo["error"] = strval($e); // no-op } $_SESSION["order-" . $userID] = $orderInfo; // Log this TicketManager::getInstance()->logTicketPurchase($userID, $eventID, $ticket->getTicketID(), time(), isset($orderInfo["stripeTime"]) ? $orderInfo["stripeTime"] : 0, isset($orderInfo["stripeRef"]) ? $orderInfo["stripeRef"] : "", $orderInfo["status"], $ticketType, $price, 1); header("Location: index.php?module=usertickets&action=receipt"); die; } break; //================================================================================== // List user tickets //================================================================================== // List user tickets default: $tickets = $user->getTickets(); // Message to user if (isset($_GET['msg']) && is_numeric($_GET['msg'])) { $message = ""; $messageType = "success"; switch ($_GET['msg']) {
/** * Provides the tickets of this user in an array of Ticket objects. * * @return Ticket[] */ public function getTickets() { global $sql_prefix; if ($this->_tickets == null) { $this->_tickets = TicketManager::getInstance()->getTicketsOfUser($this->getUserID()); } return $this->_tickets; }
} } else { // Just go! $orderInfo["status"] = "ordered"; $tickets = $ticketManager->getTicketsByMD5($orderInfo["ticketMD5"]); if (is_array($tickets) && count($tickets) > 0) { foreach ($tickets as $ticket) { $ticketIDs[] = $ticket->getTicketID(); } } unset($tickets); } break; } // Log this TicketManager::getInstance()->logTicketPurchase($userID, $eventID, count($ticketIDs) > 0 ? implode(", ", $ticketIDs) : "", time(), isset($orderInfo["stripeTime"]) ? $orderInfo["stripeTime"] : 0, isset($orderInfo["stripeRef"]) ? $orderInfo["stripeRef"] : "", $orderInfo["status"], $ticketType, $price, $amount); $_SESSION["orderInfo" . $sessioninfo->userID] = array_merge($_SESSION["orderInfo" . $sessioninfo->userID], $orderInfo); header("Location: index.php?module=ticketorder&action=receipt"); die; //================================================================================== // Order a ticket //================================================================================== // Order a ticket case "orderTicket": if ($userID < 1) { header("Location: ?module=ticketorder"); die; } $ttID = $requestGet->has("ttID") ? $requestGet->getInt("ttID", -1) : -1; if ($ttID > 0) { $ticketType = $ticketManager->getTicketTypeByID($ttID);
/** * Indicates if this ticket can be seated. * * @see getSeat() * @return bool */ public function canSeat() { /* if ticket.isPaid: return true else: canSeat = true loop user.tickets if ticket.isPaid is False AND ticket.hasSeat is True: canSeat = false return canSeat */ if ($this->isPaid()) { // This ticket is paid, user can seat it. return true; } $canSeat = true; // Fetch all tickets on user. $tickets = TicketManager::getInstance()->getTicketsOfUser($this->getUserID()); if (is_array($tickets) && count($tickets) > 0) { foreach ($tickets as $ticket) { if (!$ticket->isPaid() && $ticket->hasSeat()) { $canSeat = false; } } } return $canSeat; }
public function getTicket() { return TicketManager::getInstance()->getTicket($this->getTicketID()); }