1 | <?php |
||
19 | abstract class TicketSelectorRow |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var \EE_Ticket $ticket |
||
24 | */ |
||
25 | protected $ticket; |
||
26 | |||
27 | /** |
||
28 | * @var int $total_tickets |
||
29 | */ |
||
30 | protected $total_tickets; |
||
31 | |||
32 | /** |
||
33 | * @var int $max_atndz |
||
34 | */ |
||
35 | protected $max_atndz; |
||
36 | |||
37 | /** |
||
38 | * @var string $date_format |
||
39 | */ |
||
40 | protected $date_format; |
||
41 | |||
42 | /** |
||
43 | * @var int $EVT_ID |
||
44 | */ |
||
45 | protected $EVT_ID; |
||
46 | |||
47 | /** |
||
48 | * @var string $event_status |
||
49 | */ |
||
50 | protected $event_status; |
||
51 | |||
52 | /** |
||
53 | * @var boolean $required_ticket_sold_out |
||
54 | */ |
||
55 | protected $required_ticket_sold_out; |
||
56 | |||
57 | /** |
||
58 | * @var string $ticket_status_display |
||
59 | */ |
||
60 | protected $ticket_status_display; |
||
61 | |||
62 | |||
63 | |||
64 | /** |
||
65 | * @param \EE_Ticket $ticket |
||
66 | * @param int $max_atndz |
||
67 | * @param string $date_format |
||
68 | * @param string $event_status |
||
69 | * @param bool $required_ticket_sold_out |
||
70 | * @throws EE_Error |
||
71 | * @throws UnexpectedEntityException |
||
72 | */ |
||
73 | public function __construct( |
||
74 | \EE_Ticket $ticket, |
||
75 | $max_atndz, |
||
76 | $date_format, |
||
77 | $event_status, |
||
78 | $required_ticket_sold_out = false |
||
79 | ) { |
||
80 | $this->ticket = $ticket; |
||
81 | $this->max_atndz = $max_atndz; |
||
82 | $this->date_format = $date_format; |
||
83 | $this->EVT_ID = $this->ticket->get_event_ID(); |
||
84 | $this->event_status = $event_status; |
||
85 | $this->required_ticket_sold_out = $required_ticket_sold_out; |
||
86 | } |
||
87 | |||
88 | |||
89 | |||
90 | /** |
||
91 | * getTicketStatusClasses |
||
92 | * |
||
93 | * @param int $remaining |
||
94 | * @return array |
||
95 | * @throws EE_Error |
||
96 | */ |
||
97 | protected function getTicketStatusClasses($remaining = 0) |
||
98 | { |
||
99 | // if a previous required ticket with the same sale start date is sold out, |
||
100 | // then mark this ticket as sold out as well. |
||
101 | // tickets that go on sale at a later date than the required ticket will NOT be affected |
||
102 | $tkt_status = $this->required_ticket_sold_out !== false |
||
103 | && $this->required_ticket_sold_out === $this->ticket->start_date() |
||
104 | ? \EE_Ticket::sold_out |
||
105 | : $this->ticket->ticket_status(); |
||
106 | $tkt_status = $this->event_status === \EE_Datetime::sold_out |
||
107 | ? \EE_Ticket::sold_out |
||
108 | : $tkt_status; |
||
109 | // check ticket status |
||
110 | switch ($tkt_status) { |
||
111 | // sold_out |
||
112 | case \EE_Ticket::sold_out : |
||
113 | $ticket_status = 'ticket-sales-sold-out'; |
||
114 | $status_class = 'ticket-sales-sold-out lt-grey-text'; |
||
115 | break; |
||
116 | // expired |
||
117 | case \EE_Ticket::expired : |
||
118 | $ticket_status = 'ticket-sales-expired'; |
||
119 | $status_class = 'ticket-sales-expired lt-grey-text'; |
||
120 | break; |
||
121 | // archived |
||
122 | case \EE_Ticket::archived : |
||
123 | $ticket_status = 'archived-ticket'; |
||
124 | $status_class = 'archived-ticket hidden'; |
||
125 | break; |
||
126 | // pending |
||
127 | case \EE_Ticket::pending : |
||
128 | $ticket_status = 'ticket-pending'; |
||
129 | $status_class = 'ticket-pending'; |
||
130 | break; |
||
131 | // onsale |
||
132 | case \EE_Ticket::onsale : |
||
133 | default : |
||
134 | $ticket_status = 'ticket-on-sale'; |
||
135 | $status_class = 'ticket-on-sale'; |
||
136 | break; |
||
137 | } |
||
138 | $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
||
139 | return array($tkt_status, $ticket_status, $status_class); |
||
140 | } |
||
141 | |||
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getTicketStatusDisplay() |
||
147 | { |
||
148 | return $this->ticket_status_display; |
||
149 | } |
||
150 | |||
151 | |||
152 | |||
153 | /** |
||
154 | * setTicketStatusDisplay |
||
155 | * |
||
156 | * @param string $tkt_status |
||
157 | * @param string $ticket_status |
||
158 | * @param int $remaining |
||
159 | * @throws EE_Error |
||
160 | */ |
||
161 | protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
||
181 | |||
182 | |||
183 | |||
184 | /** |
||
185 | * registrationClosed |
||
186 | */ |
||
187 | protected function registrationClosed() |
||
197 | |||
198 | |||
199 | |||
200 | /** |
||
201 | * ticketsSoldOut |
||
202 | */ |
||
203 | protected function ticketsSoldOut() |
||
213 | |||
214 | |||
215 | |||
216 | /** |
||
217 | * ticketsSalesPending |
||
218 | * |
||
219 | * @throws EE_Error |
||
220 | */ |
||
221 | protected function ticketsSalesPending() |
||
245 | |||
246 | |||
247 | |||
248 | /** |
||
249 | * notEnoughTicketsAvailable |
||
250 | */ |
||
251 | protected function notEnoughTicketsAvailable() |
||
265 | |||
266 | |||
267 | |||
268 | } |
||
269 | // End of file TicketSelectorRow.php |
||
270 | // Location: EventEspresso\modules\ticket_selector/TicketSelectorRow.php |