@@ -239,7 +239,7 @@ |
||
239 | 239 | * setTicketMinAndMax |
240 | 240 | * |
241 | 241 | * @param int $remaining |
242 | - * @return array |
|
242 | + * @return integer[] |
|
243 | 243 | */ |
244 | 244 | protected function setTicketMinAndMax($remaining) |
245 | 245 | { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | $ticket_selector_row_html = \EEH_HTML::tr( |
184 | 184 | '', '', |
185 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
185 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket) |
|
186 | 186 | ); |
187 | 187 | /** |
188 | 188 | * Allow plugins to hook in and abort the generation and display of the contents of this |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $status_class |
207 | 207 | ); |
208 | 208 | if ($new_row_cells_content !== false) { |
209 | - return $ticket_selector_row_html . $new_row_cells_content . \EEH_HTML::trx(); |
|
209 | + return $ticket_selector_row_html.$new_row_cells_content.\EEH_HTML::trx(); |
|
210 | 210 | } |
211 | 211 | $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
212 | 212 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
375 | 375 | $html .= \EEH_Template::format_currency($ticket_price); |
376 | 376 | $html .= $this->ticket->taxable() |
377 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
377 | + ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
378 | 378 | : ''; |
379 | 379 | $html .= ' '; |
380 | 380 | $html .= \EEH_HTML::span( |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | // display submit button since we have tickets available |
409 | 409 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
410 | 410 | $this->hidden_input_qty = false; |
411 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
412 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
413 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
411 | + $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"'; |
|
412 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
413 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"'; |
|
414 | 414 | $html .= $this->row === 1 ? ' checked="checked"' : ''; |
415 | 415 | $html .= ' title=""/>'; |
416 | 416 | return $html; |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | // display submit button since we have tickets available |
431 | 431 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
432 | 432 | $this->hidden_input_qty = false; |
433 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
434 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
433 | + $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"'; |
|
434 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
435 | 435 | $html .= ' class="ticket-selector-tbl-qty-slct">'; |
436 | 436 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
437 | 437 | if ($min !== 0 && ! $this->ticket->required()) { |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | } |
440 | 440 | // offer ticket quantities from the min to the max |
441 | 441 | for ($i = $min; $i <= $max; $i++) { |
442 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
442 | + $html .= '<option value="'.$i.'"> '.$i.' </option>'; |
|
443 | 443 | } |
444 | 444 | $html .= '</select>'; |
445 | 445 | return $html; |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | $html = ''; |
458 | 458 | // depending on group reg we need to change the format for qty |
459 | 459 | if ($this->hidden_input_qty) { |
460 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
460 | + $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>'; |
|
461 | 461 | } |
462 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
463 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
462 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"'; |
|
463 | + $html .= ' value="'.$this->ticket->ID().'"/>'; |
|
464 | 464 | return $html; |
465 | 465 | } |
466 | 466 |
@@ -16,458 +16,458 @@ |
||
16 | 16 | class TicketSelectorRowStandard extends TicketSelectorRow |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var TicketDetails $ticket_details |
|
21 | - */ |
|
22 | - protected $ticket_details; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
26 | - */ |
|
27 | - protected $template_settings; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Tax_Config $tax_settings |
|
31 | - */ |
|
32 | - protected $tax_settings; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $required_ticket_sold_out |
|
36 | - */ |
|
37 | - protected $required_ticket_sold_out; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var boolean $prices_displayed_including_taxes |
|
41 | - */ |
|
42 | - protected $prices_displayed_including_taxes; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string $event_status |
|
46 | - */ |
|
47 | - protected $event_status; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var int $row |
|
51 | - */ |
|
52 | - protected $row; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var int $cols |
|
56 | - */ |
|
57 | - protected $cols; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var boolean $hidden_input_qty |
|
61 | - */ |
|
62 | - protected $hidden_input_qty; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var string $ticket_datetime_classes |
|
66 | - */ |
|
67 | - protected $ticket_datetime_classes; |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * TicketDetails constructor. |
|
73 | - * |
|
74 | - * @param \EE_Ticket $ticket |
|
75 | - * @param TicketDetails $ticket_details |
|
76 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
77 | - * @param \EE_Tax_Config $tax_settings |
|
78 | - * @param int $max_atndz |
|
79 | - * @param int $row |
|
80 | - * @param int $cols |
|
81 | - * @param boolean $required_ticket_sold_out |
|
82 | - * @param string $event_status |
|
83 | - * @param string $date_format |
|
84 | - * @param string $ticket_datetime_classes |
|
85 | - */ |
|
86 | - public function __construct( |
|
87 | - \EE_Ticket $ticket, |
|
88 | - TicketDetails $ticket_details, |
|
89 | - \EE_Ticket_Selector_Config $template_settings, |
|
90 | - \EE_Tax_Config $tax_settings, |
|
91 | - $max_atndz, |
|
92 | - $row, |
|
93 | - $cols, |
|
94 | - $required_ticket_sold_out, |
|
95 | - $event_status, |
|
96 | - $date_format, |
|
97 | - $ticket_datetime_classes |
|
98 | - ) { |
|
99 | - $this->ticket = $ticket; |
|
100 | - $this->ticket_details = $ticket_details; |
|
101 | - $this->template_settings = $template_settings; |
|
102 | - $this->tax_settings = $tax_settings; |
|
103 | - $this->max_atndz = $max_atndz; |
|
104 | - $this->row = $row; |
|
105 | - $this->cols = $cols; |
|
106 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
107 | - $this->event_status = $event_status; |
|
108 | - $this->date_format = $date_format; |
|
109 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
110 | - parent::__construct($ticket, $max_atndz, $date_format); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * other ticket rows will need to know if a required ticket is sold out, |
|
117 | - * so that they are not offered for sale |
|
118 | - * |
|
119 | - * @return boolean |
|
120 | - */ |
|
121 | - public function getRequiredTicketSoldOut() |
|
122 | - { |
|
123 | - return $this->required_ticket_sold_out; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return int |
|
130 | - */ |
|
131 | - public function getCols() |
|
132 | - { |
|
133 | - return $this->cols; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * getHtml |
|
140 | - * |
|
141 | - * @return string |
|
142 | - * @throws \EE_Error |
|
143 | - */ |
|
144 | - public function getHtml() |
|
145 | - { |
|
146 | - $min = 0; |
|
147 | - $max = $this->ticket->max(); |
|
148 | - $remaining = $this->ticket->remaining(); |
|
149 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
150 | - list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
151 | - } else { |
|
152 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
153 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
154 | - ? $this->ticket->start_date() |
|
155 | - : $this->required_ticket_sold_out; |
|
156 | - } |
|
157 | - list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
158 | - list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
159 | - /** |
|
160 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
161 | - * something else if they want. |
|
162 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
163 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
164 | - * current row. |
|
165 | - * |
|
166 | - * @var string|bool |
|
167 | - */ |
|
168 | - $ticket_selector_row_html = apply_filters( |
|
169 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
170 | - false, |
|
171 | - $this->ticket, |
|
172 | - $max, |
|
173 | - $min, |
|
174 | - $this->required_ticket_sold_out, |
|
175 | - $ticket_price, |
|
176 | - $ticket_bundle, |
|
177 | - $ticket_status, |
|
178 | - $status_class |
|
179 | - ); |
|
180 | - if ($ticket_selector_row_html !== false) { |
|
181 | - return $ticket_selector_row_html; |
|
182 | - } |
|
183 | - $ticket_selector_row_html = \EEH_HTML::tr( |
|
184 | - '', '', |
|
185 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
186 | - ); |
|
187 | - /** |
|
188 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
189 | - * row to do something else if they want. |
|
190 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
191 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
192 | - * current row. |
|
193 | - * |
|
194 | - * @var string|bool |
|
195 | - */ |
|
196 | - $new_row_cells_content = apply_filters( |
|
197 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
198 | - false, |
|
199 | - $this->ticket, |
|
200 | - $max, |
|
201 | - $min, |
|
202 | - $this->required_ticket_sold_out, |
|
203 | - $ticket_price, |
|
204 | - $ticket_bundle, |
|
205 | - $ticket_status, |
|
206 | - $status_class |
|
207 | - ); |
|
208 | - if ($new_row_cells_content !== false) { |
|
209 | - return $ticket_selector_row_html . $new_row_cells_content . \EEH_HTML::trx(); |
|
210 | - } |
|
211 | - $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
212 | - |
|
213 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
214 | - $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
215 | - $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
216 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
217 | - if (empty($this->ticket_status_display)) { |
|
218 | - if ($this->max_atndz === 1) { |
|
219 | - // only ONE attendee is allowed to register at a time |
|
220 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
221 | - } else if ($max > 0) { |
|
222 | - $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
223 | - } |
|
224 | - } |
|
225 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
226 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
227 | - $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
228 | - $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
229 | - $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
230 | - |
|
231 | - |
|
232 | - $this->row++; |
|
233 | - return $ticket_selector_row_html; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * setTicketMinAndMax |
|
240 | - * |
|
241 | - * @param int $remaining |
|
242 | - * @return array |
|
243 | - */ |
|
244 | - protected function setTicketMinAndMax($remaining) |
|
245 | - { |
|
246 | - // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
247 | - $max = min($remaining, $this->max_atndz); |
|
248 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
249 | - // however, the max still can't be higher than what was just set above |
|
250 | - $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
251 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
252 | - $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
253 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
254 | - $min = $this->ticket->required() ? max($min, 1) : $min; |
|
255 | - return array($min, $max); |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * getTicketPriceDetails |
|
261 | - * |
|
262 | - * @return array |
|
263 | - */ |
|
264 | - protected function getTicketPriceDetails() |
|
265 | - { |
|
266 | - $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
267 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
268 | - : $this->ticket->get_ticket_subtotal(); |
|
269 | - $ticket_bundle = false; |
|
270 | - $ticket_min = $this->ticket->min(); |
|
271 | - // for ticket bundles, set min and max qty the same |
|
272 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
273 | - $ticket_price *= $ticket_min; |
|
274 | - $ticket_bundle = true; |
|
275 | - } |
|
276 | - $ticket_price = apply_filters( |
|
277 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
278 | - $ticket_price, |
|
279 | - $this->ticket |
|
280 | - ); |
|
281 | - return array($ticket_price, $ticket_bundle); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * getTicketStatusClasses |
|
288 | - * |
|
289 | - * @param int $remaining |
|
290 | - * @return array |
|
291 | - * @throws \EE_Error |
|
292 | - */ |
|
293 | - protected function getTicketStatusClasses($remaining = 0) |
|
294 | - { |
|
295 | - // if a previous required ticket with the same sale start date is sold out, |
|
296 | - // then mark this ticket as sold out as well. |
|
297 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
298 | - $tkt_status = $this->required_ticket_sold_out !== false |
|
299 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
300 | - ? \EE_Ticket::sold_out |
|
301 | - : $this->ticket->ticket_status(); |
|
302 | - $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
303 | - ? \EE_Ticket::sold_out |
|
304 | - : $tkt_status; |
|
305 | - // check ticket status |
|
306 | - switch ($tkt_status) { |
|
307 | - // sold_out |
|
308 | - case \EE_Ticket::sold_out : |
|
309 | - $ticket_status = 'ticket-sales-sold-out'; |
|
310 | - $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
311 | - break; |
|
312 | - // expired |
|
313 | - case \EE_Ticket::expired : |
|
314 | - $ticket_status = 'ticket-sales-expired'; |
|
315 | - $status_class = 'ticket-sales-expired lt-grey-text'; |
|
316 | - break; |
|
317 | - // archived |
|
318 | - case \EE_Ticket::archived : |
|
319 | - $ticket_status = 'archived-ticket'; |
|
320 | - $status_class = 'archived-ticket hidden'; |
|
321 | - break; |
|
322 | - // pending |
|
323 | - case \EE_Ticket::pending : |
|
324 | - $ticket_status = 'ticket-pending'; |
|
325 | - $status_class = 'ticket-pending'; |
|
326 | - break; |
|
327 | - // onsale |
|
328 | - case \EE_Ticket::onsale : |
|
329 | - default : |
|
330 | - $ticket_status = 'ticket-on-sale'; |
|
331 | - $status_class = 'ticket-on-sale'; |
|
332 | - break; |
|
333 | - } |
|
334 | - $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
335 | - return array($tkt_status, $ticket_status, $status_class); |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * ticketNameTableCell |
|
342 | - * |
|
343 | - * @return string |
|
344 | - * @throws \EE_Error |
|
345 | - */ |
|
346 | - protected function ticketNameTableCell() |
|
347 | - { |
|
348 | - $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
349 | - $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
350 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
351 | - if ($this->ticket->required()) { |
|
352 | - $html .= \EEH_HTML::p( |
|
353 | - apply_filters( |
|
354 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
355 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
356 | - ), |
|
357 | - '', 'ticket-required-pg' |
|
358 | - ); |
|
359 | - } |
|
360 | - $html .= \EEH_HTML::tdx(); |
|
361 | - return $html; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * ticketPriceTableCell |
|
368 | - * |
|
369 | - * @param float $ticket_price |
|
370 | - * @param bool $ticket_bundle |
|
371 | - * @return string |
|
372 | - * @throws \EE_Error |
|
373 | - */ |
|
374 | - protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
375 | - { |
|
376 | - $html = ''; |
|
377 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
378 | - $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
379 | - $html .= \EEH_Template::format_currency($ticket_price); |
|
380 | - $html .= $this->ticket->taxable() |
|
381 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
382 | - : ''; |
|
383 | - $html .= ' '; |
|
384 | - $html .= \EEH_HTML::span( |
|
385 | - $ticket_bundle |
|
386 | - ? apply_filters( |
|
387 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
388 | - __(' / bundle', 'event_espresso') |
|
389 | - ) |
|
390 | - : apply_filters( |
|
391 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
392 | - __('', 'event_espresso') |
|
393 | - ), |
|
394 | - '', 'smaller-text no-bold' |
|
395 | - ); |
|
396 | - $html .= ' '; |
|
397 | - $html .= \EEH_HTML::tdx(); |
|
398 | - $this->cols++; |
|
399 | - } |
|
400 | - return $html; |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * onlyOneAttendeeCanRegister |
|
407 | - * |
|
408 | - * @return string |
|
409 | - */ |
|
410 | - protected function onlyOneAttendeeCanRegister() |
|
411 | - { |
|
412 | - // display submit button since we have tickets available |
|
413 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
414 | - $this->hidden_input_qty = false; |
|
415 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
416 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
417 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
418 | - $html .= $this->row === 1 ? ' checked="checked"' : ''; |
|
419 | - $html .= ' title=""/>'; |
|
420 | - return $html; |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * ticketQuantitySelector |
|
427 | - * |
|
428 | - * @param int $min |
|
429 | - * @param int $max |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - protected function ticketQuantitySelector($min = 0, $max = 0) |
|
433 | - { |
|
434 | - // display submit button since we have tickets available |
|
435 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
436 | - $this->hidden_input_qty = false; |
|
437 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
438 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
439 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
440 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
441 | - if ($min !== 0 && ! $this->ticket->required()) { |
|
442 | - $html .= '<option value="0"> 0 </option>'; |
|
443 | - } |
|
444 | - // offer ticket quantities from the min to the max |
|
445 | - for ($i = $min; $i <= $max; $i++) { |
|
446 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
447 | - } |
|
448 | - $html .= '</select>'; |
|
449 | - return $html; |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - |
|
454 | - /** |
|
455 | - * getHiddenInputs |
|
456 | - * |
|
457 | - * @return string |
|
458 | - * @throws \EE_Error |
|
459 | - */ |
|
460 | - protected function ticketQtyAndIdHiddenInputs() |
|
461 | - { |
|
462 | - $html = ''; |
|
463 | - // depending on group reg we need to change the format for qty |
|
464 | - if ($this->hidden_input_qty) { |
|
465 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
466 | - } |
|
467 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
468 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
469 | - return $html; |
|
470 | - } |
|
19 | + /** |
|
20 | + * @var TicketDetails $ticket_details |
|
21 | + */ |
|
22 | + protected $ticket_details; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
26 | + */ |
|
27 | + protected $template_settings; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Tax_Config $tax_settings |
|
31 | + */ |
|
32 | + protected $tax_settings; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $required_ticket_sold_out |
|
36 | + */ |
|
37 | + protected $required_ticket_sold_out; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var boolean $prices_displayed_including_taxes |
|
41 | + */ |
|
42 | + protected $prices_displayed_including_taxes; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string $event_status |
|
46 | + */ |
|
47 | + protected $event_status; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var int $row |
|
51 | + */ |
|
52 | + protected $row; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var int $cols |
|
56 | + */ |
|
57 | + protected $cols; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var boolean $hidden_input_qty |
|
61 | + */ |
|
62 | + protected $hidden_input_qty; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var string $ticket_datetime_classes |
|
66 | + */ |
|
67 | + protected $ticket_datetime_classes; |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * TicketDetails constructor. |
|
73 | + * |
|
74 | + * @param \EE_Ticket $ticket |
|
75 | + * @param TicketDetails $ticket_details |
|
76 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
77 | + * @param \EE_Tax_Config $tax_settings |
|
78 | + * @param int $max_atndz |
|
79 | + * @param int $row |
|
80 | + * @param int $cols |
|
81 | + * @param boolean $required_ticket_sold_out |
|
82 | + * @param string $event_status |
|
83 | + * @param string $date_format |
|
84 | + * @param string $ticket_datetime_classes |
|
85 | + */ |
|
86 | + public function __construct( |
|
87 | + \EE_Ticket $ticket, |
|
88 | + TicketDetails $ticket_details, |
|
89 | + \EE_Ticket_Selector_Config $template_settings, |
|
90 | + \EE_Tax_Config $tax_settings, |
|
91 | + $max_atndz, |
|
92 | + $row, |
|
93 | + $cols, |
|
94 | + $required_ticket_sold_out, |
|
95 | + $event_status, |
|
96 | + $date_format, |
|
97 | + $ticket_datetime_classes |
|
98 | + ) { |
|
99 | + $this->ticket = $ticket; |
|
100 | + $this->ticket_details = $ticket_details; |
|
101 | + $this->template_settings = $template_settings; |
|
102 | + $this->tax_settings = $tax_settings; |
|
103 | + $this->max_atndz = $max_atndz; |
|
104 | + $this->row = $row; |
|
105 | + $this->cols = $cols; |
|
106 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
107 | + $this->event_status = $event_status; |
|
108 | + $this->date_format = $date_format; |
|
109 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
110 | + parent::__construct($ticket, $max_atndz, $date_format); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * other ticket rows will need to know if a required ticket is sold out, |
|
117 | + * so that they are not offered for sale |
|
118 | + * |
|
119 | + * @return boolean |
|
120 | + */ |
|
121 | + public function getRequiredTicketSoldOut() |
|
122 | + { |
|
123 | + return $this->required_ticket_sold_out; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return int |
|
130 | + */ |
|
131 | + public function getCols() |
|
132 | + { |
|
133 | + return $this->cols; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * getHtml |
|
140 | + * |
|
141 | + * @return string |
|
142 | + * @throws \EE_Error |
|
143 | + */ |
|
144 | + public function getHtml() |
|
145 | + { |
|
146 | + $min = 0; |
|
147 | + $max = $this->ticket->max(); |
|
148 | + $remaining = $this->ticket->remaining(); |
|
149 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
150 | + list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
151 | + } else { |
|
152 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
153 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
154 | + ? $this->ticket->start_date() |
|
155 | + : $this->required_ticket_sold_out; |
|
156 | + } |
|
157 | + list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
158 | + list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
159 | + /** |
|
160 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
161 | + * something else if they want. |
|
162 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
163 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
164 | + * current row. |
|
165 | + * |
|
166 | + * @var string|bool |
|
167 | + */ |
|
168 | + $ticket_selector_row_html = apply_filters( |
|
169 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
170 | + false, |
|
171 | + $this->ticket, |
|
172 | + $max, |
|
173 | + $min, |
|
174 | + $this->required_ticket_sold_out, |
|
175 | + $ticket_price, |
|
176 | + $ticket_bundle, |
|
177 | + $ticket_status, |
|
178 | + $status_class |
|
179 | + ); |
|
180 | + if ($ticket_selector_row_html !== false) { |
|
181 | + return $ticket_selector_row_html; |
|
182 | + } |
|
183 | + $ticket_selector_row_html = \EEH_HTML::tr( |
|
184 | + '', '', |
|
185 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
186 | + ); |
|
187 | + /** |
|
188 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
189 | + * row to do something else if they want. |
|
190 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
191 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
192 | + * current row. |
|
193 | + * |
|
194 | + * @var string|bool |
|
195 | + */ |
|
196 | + $new_row_cells_content = apply_filters( |
|
197 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
198 | + false, |
|
199 | + $this->ticket, |
|
200 | + $max, |
|
201 | + $min, |
|
202 | + $this->required_ticket_sold_out, |
|
203 | + $ticket_price, |
|
204 | + $ticket_bundle, |
|
205 | + $ticket_status, |
|
206 | + $status_class |
|
207 | + ); |
|
208 | + if ($new_row_cells_content !== false) { |
|
209 | + return $ticket_selector_row_html . $new_row_cells_content . \EEH_HTML::trx(); |
|
210 | + } |
|
211 | + $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
212 | + |
|
213 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
214 | + $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
215 | + $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
216 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
217 | + if (empty($this->ticket_status_display)) { |
|
218 | + if ($this->max_atndz === 1) { |
|
219 | + // only ONE attendee is allowed to register at a time |
|
220 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
221 | + } else if ($max > 0) { |
|
222 | + $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
223 | + } |
|
224 | + } |
|
225 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
226 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
227 | + $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
228 | + $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
229 | + $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
230 | + |
|
231 | + |
|
232 | + $this->row++; |
|
233 | + return $ticket_selector_row_html; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * setTicketMinAndMax |
|
240 | + * |
|
241 | + * @param int $remaining |
|
242 | + * @return array |
|
243 | + */ |
|
244 | + protected function setTicketMinAndMax($remaining) |
|
245 | + { |
|
246 | + // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
247 | + $max = min($remaining, $this->max_atndz); |
|
248 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
249 | + // however, the max still can't be higher than what was just set above |
|
250 | + $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
251 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
252 | + $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
253 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
254 | + $min = $this->ticket->required() ? max($min, 1) : $min; |
|
255 | + return array($min, $max); |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * getTicketPriceDetails |
|
261 | + * |
|
262 | + * @return array |
|
263 | + */ |
|
264 | + protected function getTicketPriceDetails() |
|
265 | + { |
|
266 | + $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
267 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
268 | + : $this->ticket->get_ticket_subtotal(); |
|
269 | + $ticket_bundle = false; |
|
270 | + $ticket_min = $this->ticket->min(); |
|
271 | + // for ticket bundles, set min and max qty the same |
|
272 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
273 | + $ticket_price *= $ticket_min; |
|
274 | + $ticket_bundle = true; |
|
275 | + } |
|
276 | + $ticket_price = apply_filters( |
|
277 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
278 | + $ticket_price, |
|
279 | + $this->ticket |
|
280 | + ); |
|
281 | + return array($ticket_price, $ticket_bundle); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * getTicketStatusClasses |
|
288 | + * |
|
289 | + * @param int $remaining |
|
290 | + * @return array |
|
291 | + * @throws \EE_Error |
|
292 | + */ |
|
293 | + protected function getTicketStatusClasses($remaining = 0) |
|
294 | + { |
|
295 | + // if a previous required ticket with the same sale start date is sold out, |
|
296 | + // then mark this ticket as sold out as well. |
|
297 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
298 | + $tkt_status = $this->required_ticket_sold_out !== false |
|
299 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
300 | + ? \EE_Ticket::sold_out |
|
301 | + : $this->ticket->ticket_status(); |
|
302 | + $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
303 | + ? \EE_Ticket::sold_out |
|
304 | + : $tkt_status; |
|
305 | + // check ticket status |
|
306 | + switch ($tkt_status) { |
|
307 | + // sold_out |
|
308 | + case \EE_Ticket::sold_out : |
|
309 | + $ticket_status = 'ticket-sales-sold-out'; |
|
310 | + $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
311 | + break; |
|
312 | + // expired |
|
313 | + case \EE_Ticket::expired : |
|
314 | + $ticket_status = 'ticket-sales-expired'; |
|
315 | + $status_class = 'ticket-sales-expired lt-grey-text'; |
|
316 | + break; |
|
317 | + // archived |
|
318 | + case \EE_Ticket::archived : |
|
319 | + $ticket_status = 'archived-ticket'; |
|
320 | + $status_class = 'archived-ticket hidden'; |
|
321 | + break; |
|
322 | + // pending |
|
323 | + case \EE_Ticket::pending : |
|
324 | + $ticket_status = 'ticket-pending'; |
|
325 | + $status_class = 'ticket-pending'; |
|
326 | + break; |
|
327 | + // onsale |
|
328 | + case \EE_Ticket::onsale : |
|
329 | + default : |
|
330 | + $ticket_status = 'ticket-on-sale'; |
|
331 | + $status_class = 'ticket-on-sale'; |
|
332 | + break; |
|
333 | + } |
|
334 | + $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
335 | + return array($tkt_status, $ticket_status, $status_class); |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * ticketNameTableCell |
|
342 | + * |
|
343 | + * @return string |
|
344 | + * @throws \EE_Error |
|
345 | + */ |
|
346 | + protected function ticketNameTableCell() |
|
347 | + { |
|
348 | + $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
349 | + $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
350 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
351 | + if ($this->ticket->required()) { |
|
352 | + $html .= \EEH_HTML::p( |
|
353 | + apply_filters( |
|
354 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
355 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
356 | + ), |
|
357 | + '', 'ticket-required-pg' |
|
358 | + ); |
|
359 | + } |
|
360 | + $html .= \EEH_HTML::tdx(); |
|
361 | + return $html; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * ticketPriceTableCell |
|
368 | + * |
|
369 | + * @param float $ticket_price |
|
370 | + * @param bool $ticket_bundle |
|
371 | + * @return string |
|
372 | + * @throws \EE_Error |
|
373 | + */ |
|
374 | + protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
375 | + { |
|
376 | + $html = ''; |
|
377 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
378 | + $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
379 | + $html .= \EEH_Template::format_currency($ticket_price); |
|
380 | + $html .= $this->ticket->taxable() |
|
381 | + ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
382 | + : ''; |
|
383 | + $html .= ' '; |
|
384 | + $html .= \EEH_HTML::span( |
|
385 | + $ticket_bundle |
|
386 | + ? apply_filters( |
|
387 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
388 | + __(' / bundle', 'event_espresso') |
|
389 | + ) |
|
390 | + : apply_filters( |
|
391 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
392 | + __('', 'event_espresso') |
|
393 | + ), |
|
394 | + '', 'smaller-text no-bold' |
|
395 | + ); |
|
396 | + $html .= ' '; |
|
397 | + $html .= \EEH_HTML::tdx(); |
|
398 | + $this->cols++; |
|
399 | + } |
|
400 | + return $html; |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * onlyOneAttendeeCanRegister |
|
407 | + * |
|
408 | + * @return string |
|
409 | + */ |
|
410 | + protected function onlyOneAttendeeCanRegister() |
|
411 | + { |
|
412 | + // display submit button since we have tickets available |
|
413 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
414 | + $this->hidden_input_qty = false; |
|
415 | + $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
416 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
417 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
418 | + $html .= $this->row === 1 ? ' checked="checked"' : ''; |
|
419 | + $html .= ' title=""/>'; |
|
420 | + return $html; |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * ticketQuantitySelector |
|
427 | + * |
|
428 | + * @param int $min |
|
429 | + * @param int $max |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + protected function ticketQuantitySelector($min = 0, $max = 0) |
|
433 | + { |
|
434 | + // display submit button since we have tickets available |
|
435 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
436 | + $this->hidden_input_qty = false; |
|
437 | + $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
438 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
439 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
440 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
441 | + if ($min !== 0 && ! $this->ticket->required()) { |
|
442 | + $html .= '<option value="0"> 0 </option>'; |
|
443 | + } |
|
444 | + // offer ticket quantities from the min to the max |
|
445 | + for ($i = $min; $i <= $max; $i++) { |
|
446 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
447 | + } |
|
448 | + $html .= '</select>'; |
|
449 | + return $html; |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + |
|
454 | + /** |
|
455 | + * getHiddenInputs |
|
456 | + * |
|
457 | + * @return string |
|
458 | + * @throws \EE_Error |
|
459 | + */ |
|
460 | + protected function ticketQtyAndIdHiddenInputs() |
|
461 | + { |
|
462 | + $html = ''; |
|
463 | + // depending on group reg we need to change the format for qty |
|
464 | + if ($this->hidden_input_qty) { |
|
465 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
466 | + } |
|
467 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
468 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
469 | + return $html; |
|
470 | + } |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | // End of file TicketSelectorRowStandard.php |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_HTML ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
45 | 45 | self::$_instance = new EEH_HTML(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $other_attributes = '', |
103 | 103 | $force_close = false |
104 | 104 | ) { |
105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
113 | 113 | return $html; |
114 | 114 | } |
115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param bool $indent |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
130 | 130 | $comment = ''; |
131 | - if ( $id ) { |
|
132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
133 | - } else if ( $class ) { |
|
134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
131 | + if ($id) { |
|
132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
133 | + } else if ($class) { |
|
134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
135 | 135 | } |
136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
137 | - $html .= '</' . $tag . '>' . $comment; |
|
137 | + $html .= '</'.$tag.'>'.$comment; |
|
138 | 138 | return $html; |
139 | 139 | } |
140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $class - html class attribute |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public static function divx( $id = '', $class = '' ) { |
|
171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
170 | + public static function divx($id = '', $class = '') { |
|
171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $class - html class attribute |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function ulx( $id = '', $class = '' ) { |
|
320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
319 | + public static function ulx($id = '', $class = '') { |
|
320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param string $class - html class attribute |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public static function lix( $id = '', $class = '' ) { |
|
352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
351 | + public static function lix($id = '', $class = '') { |
|
352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $class - html class attribute |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public static function tablex( $id = '', $class = '' ) { |
|
382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
381 | + public static function tablex($id = '', $class = '') { |
|
382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $class - html class attribute |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public static function theadx( $id = '', $class = '' ) { |
|
412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
411 | + public static function theadx($id = '', $class = '') { |
|
412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $class - html class attribute |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
441 | + public static function tbodyx($id = '', $class = '') { |
|
442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | * @param string $class - html class attribute |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function trx( $id = '', $class = '' ) { |
|
472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
471 | + public static function trx($id = '', $class = '') { |
|
472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $class - html class attribute |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function thx( $id = '', $class = '' ) { |
|
502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
501 | + public static function thx($id = '', $class = '') { |
|
502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $class - html class attribute |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public static function tdx( $id = '', $class = '' ) { |
|
532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
531 | + public static function tdx($id = '', $class = '') { |
|
532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * @param int $colspan |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
546 | + public static function no_row($content = '', $colspan = 2) { |
|
547 | 547 | return EEH_HTML::tr( |
548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
549 | - '', '', 'padding:0; border:none;' |
|
548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
549 | + '', '', 'padding:0; border:none;' |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
571 | - $attributes = ! empty($href ) ? ' href="' . $href . '"' : ''; |
|
572 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
573 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
574 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
575 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
576 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
571 | + $attributes = ! empty($href) ? ' href="'.$href.'"' : ''; |
|
572 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
573 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
574 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
575 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
576 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
577 | 577 | return "<a{$attributes}>{$link_text}</a>"; |
578 | 578 | } |
579 | 579 | |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
592 | 592 | * @return string |
593 | 593 | */ |
594 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
595 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
596 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
597 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
598 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
599 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
600 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
601 | - return '<img' . $attributes . '/>'; |
|
594 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
595 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
596 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
597 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
598 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
599 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
600 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
601 | + return '<img'.$attributes.'/>'; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -616,12 +616,12 @@ discard block |
||
616 | 616 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
617 | 617 | * @return string |
618 | 618 | */ |
619 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
620 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
621 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
622 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
623 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
624 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
619 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
620 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
621 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
622 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
623 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
624 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
638 | 638 | * @return string |
639 | 639 | */ |
640 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
641 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
640 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
641 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
658 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
657 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
658 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
672 | 672 | * @return string |
673 | 673 | */ |
674 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
675 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
674 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
675 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @param string $comment |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - public static function comment( $comment = '' ) { |
|
688 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
687 | + public static function comment($comment = '') { |
|
688 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * @param int $nmbr - the number of line breaks to return |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public static function br( $nmbr = 1 ) { |
|
700 | - return str_repeat( '<br />', $nmbr ); |
|
699 | + public static function br($nmbr = 1) { |
|
700 | + return str_repeat('<br />', $nmbr); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | * @param int $nmbr - the number of non-breaking spaces to return |
709 | 709 | * @return string |
710 | 710 | */ |
711 | - public static function nbsp( $nmbr = 1 ) { |
|
712 | - return str_repeat( ' ', $nmbr ); |
|
711 | + public static function nbsp($nmbr = 1) { |
|
712 | + return str_repeat(' ', $nmbr); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -723,9 +723,9 @@ discard block |
||
723 | 723 | * @param string $id |
724 | 724 | * @return string |
725 | 725 | */ |
726 | - public static function sanitize_id( $id = '' ) { |
|
727 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
728 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
726 | + public static function sanitize_id($id = '') { |
|
727 | + $key = str_replace(' ', '-', trim($id)); |
|
728 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | * @param string $tag |
738 | 738 | * @return string - newline character plus # of indents passed (can be + or -) |
739 | 739 | */ |
740 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
740 | + public static function nl($indent = 0, $tag = 'none') { |
|
741 | 741 | $html = "\n"; |
742 | - EEH_HTML::indent( $indent, $tag ); |
|
743 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
742 | + EEH_HTML::indent($indent, $tag); |
|
743 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
744 | 744 | $html .= "\t"; |
745 | 745 | } |
746 | 746 | return $html; |
@@ -755,17 +755,17 @@ discard block |
||
755 | 755 | * @param int $indent can be negative to decrease the indentation level |
756 | 756 | * @param string $tag |
757 | 757 | */ |
758 | - public static function indent( $indent, $tag = 'none' ){ |
|
758 | + public static function indent($indent, $tag = 'none') { |
|
759 | 759 | static $default_indentation = FALSE; |
760 | - if ( ! $default_indentation ) { |
|
760 | + if ( ! $default_indentation) { |
|
761 | 761 | EEH_HTML::_set_default_indentation(); |
762 | 762 | $default_indentation = TRUE; |
763 | 763 | } |
764 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
765 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
764 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
765 | + EEH_HTML::$_indent[$tag] = 0; |
|
766 | 766 | } |
767 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
768 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
767 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
768 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | * @global array $allowedtags |
812 | 812 | * @return array |
813 | 813 | */ |
814 | - public static function get_simple_tags(){ |
|
814 | + public static function get_simple_tags() { |
|
815 | 815 | global $allowedtags; |
816 | 816 | $tags_we_allow = $allowedtags; |
817 | - $tags_we_allow['ol']=array(); |
|
818 | - $tags_we_allow['ul']=array(); |
|
819 | - $tags_we_allow['li']=array(); |
|
820 | - $tags_we_allow['br']=array(); |
|
821 | - $tags_we_allow['p']=array(); |
|
822 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
817 | + $tags_we_allow['ol'] = array(); |
|
818 | + $tags_we_allow['ul'] = array(); |
|
819 | + $tags_we_allow['li'] = array(); |
|
820 | + $tags_we_allow['br'] = array(); |
|
821 | + $tags_we_allow['p'] = array(); |
|
822 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 |
@@ -17,158 +17,158 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @var \EE_Ticket $ticket |
|
22 | - */ |
|
23 | - protected $ticket; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | - */ |
|
28 | - protected $template_settings; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $date_format |
|
32 | - */ |
|
33 | - protected $date_format; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $time_format |
|
37 | - */ |
|
38 | - protected $time_format; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var boolean $event_is_expired |
|
42 | - */ |
|
43 | - protected $event_is_expired; |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * TicketDetails constructor. |
|
49 | - * |
|
50 | - * @param \EE_Ticket $ticket |
|
51 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | - * @param array $template_args |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Ticket $ticket, |
|
56 | - \EE_Ticket_Selector_Config $template_settings, |
|
57 | - array $template_args |
|
58 | - ) |
|
59 | - { |
|
60 | - $this->ticket = $ticket; |
|
61 | - $this->template_settings = $template_settings; |
|
62 | - $this->date_format = $template_args['date_format']; |
|
63 | - $this->time_format = $template_args['time_format']; |
|
64 | - $this->event_is_expired = $template_args['event_is_expired']; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function showTicketDetails() |
|
73 | - { |
|
74 | - return $this->template_settings->show_ticket_details; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function getShowHideLinks() |
|
83 | - { |
|
84 | - if ( ! $this->showTicketDetails()) { |
|
85 | - return ''; |
|
86 | - } |
|
87 | - return \EEH_HTML::link( |
|
88 | - '', |
|
89 | - sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
90 | - esc_attr( |
|
91 | - apply_filters( |
|
92 | - 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
93 | - __('click to show additional ticket details', 'event_espresso') |
|
94 | - ) |
|
95 | - ), |
|
96 | - "display-{$this->cssId()}", |
|
97 | - 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
98 | - '', |
|
99 | - 'rel="' . $this->cssId() . '"' |
|
100 | - ) . \EEH_HTML::link( |
|
101 | - '', |
|
102 | - sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
103 | - esc_attr( |
|
104 | - apply_filters( |
|
105 | - 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
106 | - __('click to hide additional ticket details', 'event_espresso') |
|
107 | - ) |
|
108 | - ), |
|
109 | - "hide-{$this->cssId()}", |
|
110 | - 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
111 | - 'display:none;', |
|
112 | - 'rel="' . $this->cssId() . '"' |
|
113 | - ); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function cssId() |
|
122 | - { |
|
123 | - return apply_filters( |
|
124 | - 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
125 | - "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @param float $ticket_price |
|
133 | - * @param int $remaining |
|
134 | - * @param int $cols |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - public function display( |
|
138 | - $ticket_price = 0.00, |
|
139 | - $remaining, |
|
140 | - $cols = 2 |
|
141 | - ) { |
|
142 | - $template_args = array(); |
|
143 | - $template_args['ticket'] = $this->ticket; |
|
144 | - $template_args['ticket_price'] = $ticket_price; |
|
145 | - $template_args['remaining'] = $remaining; |
|
146 | - $template_args['cols'] = $cols; |
|
147 | - $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
148 | - $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
149 | - $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
150 | - $template_args['ticket_details_css_id'] = $this->cssId(); |
|
151 | - $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
152 | - 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
153 | - true |
|
154 | - ); |
|
155 | - $template_args['price_breakdown_heading'] = apply_filters( |
|
156 | - 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
157 | - esc_html__('Price', 'event_espresso') |
|
158 | - ); |
|
159 | - $template_args['date_format'] = $this->date_format; |
|
160 | - $template_args['time_format'] = $this->time_format; |
|
161 | - $template_args['event_is_expired'] = $this->event_is_expired; |
|
162 | - |
|
163 | - return \EEH_Template::locate_template( |
|
164 | - apply_filters( |
|
165 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
166 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
167 | - $this->ticket |
|
168 | - ), |
|
169 | - $template_args |
|
170 | - ); |
|
171 | - } |
|
20 | + /** |
|
21 | + * @var \EE_Ticket $ticket |
|
22 | + */ |
|
23 | + protected $ticket; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | + */ |
|
28 | + protected $template_settings; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $date_format |
|
32 | + */ |
|
33 | + protected $date_format; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $time_format |
|
37 | + */ |
|
38 | + protected $time_format; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var boolean $event_is_expired |
|
42 | + */ |
|
43 | + protected $event_is_expired; |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * TicketDetails constructor. |
|
49 | + * |
|
50 | + * @param \EE_Ticket $ticket |
|
51 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | + * @param array $template_args |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Ticket $ticket, |
|
56 | + \EE_Ticket_Selector_Config $template_settings, |
|
57 | + array $template_args |
|
58 | + ) |
|
59 | + { |
|
60 | + $this->ticket = $ticket; |
|
61 | + $this->template_settings = $template_settings; |
|
62 | + $this->date_format = $template_args['date_format']; |
|
63 | + $this->time_format = $template_args['time_format']; |
|
64 | + $this->event_is_expired = $template_args['event_is_expired']; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function showTicketDetails() |
|
73 | + { |
|
74 | + return $this->template_settings->show_ticket_details; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function getShowHideLinks() |
|
83 | + { |
|
84 | + if ( ! $this->showTicketDetails()) { |
|
85 | + return ''; |
|
86 | + } |
|
87 | + return \EEH_HTML::link( |
|
88 | + '', |
|
89 | + sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
90 | + esc_attr( |
|
91 | + apply_filters( |
|
92 | + 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
93 | + __('click to show additional ticket details', 'event_espresso') |
|
94 | + ) |
|
95 | + ), |
|
96 | + "display-{$this->cssId()}", |
|
97 | + 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
98 | + '', |
|
99 | + 'rel="' . $this->cssId() . '"' |
|
100 | + ) . \EEH_HTML::link( |
|
101 | + '', |
|
102 | + sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
103 | + esc_attr( |
|
104 | + apply_filters( |
|
105 | + 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
106 | + __('click to hide additional ticket details', 'event_espresso') |
|
107 | + ) |
|
108 | + ), |
|
109 | + "hide-{$this->cssId()}", |
|
110 | + 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
111 | + 'display:none;', |
|
112 | + 'rel="' . $this->cssId() . '"' |
|
113 | + ); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function cssId() |
|
122 | + { |
|
123 | + return apply_filters( |
|
124 | + 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
125 | + "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @param float $ticket_price |
|
133 | + * @param int $remaining |
|
134 | + * @param int $cols |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + public function display( |
|
138 | + $ticket_price = 0.00, |
|
139 | + $remaining, |
|
140 | + $cols = 2 |
|
141 | + ) { |
|
142 | + $template_args = array(); |
|
143 | + $template_args['ticket'] = $this->ticket; |
|
144 | + $template_args['ticket_price'] = $ticket_price; |
|
145 | + $template_args['remaining'] = $remaining; |
|
146 | + $template_args['cols'] = $cols; |
|
147 | + $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
148 | + $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
149 | + $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
150 | + $template_args['ticket_details_css_id'] = $this->cssId(); |
|
151 | + $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
152 | + 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
153 | + true |
|
154 | + ); |
|
155 | + $template_args['price_breakdown_heading'] = apply_filters( |
|
156 | + 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
157 | + esc_html__('Price', 'event_espresso') |
|
158 | + ); |
|
159 | + $template_args['date_format'] = $this->date_format; |
|
160 | + $template_args['time_format'] = $this->time_format; |
|
161 | + $template_args['event_is_expired'] = $this->event_is_expired; |
|
162 | + |
|
163 | + return \EEH_Template::locate_template( |
|
164 | + apply_filters( |
|
165 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
166 | + TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
167 | + $this->ticket |
|
168 | + ), |
|
169 | + $template_args |
|
170 | + ); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | // End of file TicketDetails.php |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | "display-{$this->cssId()}", |
97 | 97 | 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
98 | 98 | '', |
99 | - 'rel="' . $this->cssId() . '"' |
|
100 | - ) . \EEH_HTML::link( |
|
99 | + 'rel="'.$this->cssId().'"' |
|
100 | + ).\EEH_HTML::link( |
|
101 | 101 | '', |
102 | 102 | sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
103 | 103 | esc_attr( |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | "hide-{$this->cssId()}", |
110 | 110 | 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
111 | 111 | 'display:none;', |
112 | - 'rel="' . $this->cssId() . '"' |
|
112 | + 'rel="'.$this->cssId().'"' |
|
113 | 113 | ); |
114 | 114 | } |
115 | 115 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return \EEH_Template::locate_template( |
164 | 164 | apply_filters( |
165 | 165 | 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
166 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
166 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_details.template.php', |
|
167 | 167 | $this->ticket |
168 | 168 | ), |
169 | 169 | $template_args |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
7 | 7 | <?php |
8 | 8 | if ( $ticket instanceof EE_Ticket ) { |
9 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
10 | - $ticket_description = $ticket->description(); |
|
11 | - $ticket_description .= ! empty( $ticket_description ) |
|
12 | - ? '<br />' . $ticket_status_display |
|
13 | - : $ticket_status_display; |
|
14 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
15 | - $ticket_description = "<p>{$ticket_description}</p>"; |
|
16 | - } |
|
9 | + do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
10 | + $ticket_description = $ticket->description(); |
|
11 | + $ticket_description .= ! empty( $ticket_description ) |
|
12 | + ? '<br />' . $ticket_status_display |
|
13 | + : $ticket_status_display; |
|
14 | + if ( ! strpos( $ticket_description, '<div' ) ) { |
|
15 | + $ticket_description = "<p>{$ticket_description}</p>"; |
|
16 | + } |
|
17 | 17 | ?> |
18 | 18 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
19 | 19 | <div class="no-tkt-slctr-ticket-content-dv"> |
@@ -23,6 +23,6 @@ discard block |
||
23 | 23 | <?php } ?> |
24 | 24 | </div> |
25 | 25 | <?php |
26 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
26 | + do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
27 | 27 | } |
28 | 28 | ?> |
@@ -5,24 +5,24 @@ |
||
5 | 5 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/> |
6 | 6 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
7 | 7 | <?php |
8 | -if ( $ticket instanceof EE_Ticket ) { |
|
9 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
8 | +if ($ticket instanceof EE_Ticket) { |
|
9 | + do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
10 | 10 | $ticket_description = $ticket->description(); |
11 | - $ticket_description .= ! empty( $ticket_description ) |
|
12 | - ? '<br />' . $ticket_status_display |
|
11 | + $ticket_description .= ! empty($ticket_description) |
|
12 | + ? '<br />'.$ticket_status_display |
|
13 | 13 | : $ticket_status_display; |
14 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
14 | + if ( ! strpos($ticket_description, '<div')) { |
|
15 | 15 | $ticket_description = "<p>{$ticket_description}</p>"; |
16 | 16 | } |
17 | 17 | ?> |
18 | 18 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
19 | 19 | <div class="no-tkt-slctr-ticket-content-dv"> |
20 | 20 | <h5><?php echo $ticket->name(); ?></h5> |
21 | - <?php if ( ! empty( $ticket_description ) ) { ?> |
|
21 | + <?php if ( ! empty($ticket_description)) { ?> |
|
22 | 22 | <?php echo $ticket_description; ?> |
23 | 23 | <?php } ?> |
24 | 24 | </div> |
25 | 25 | <?php |
26 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
26 | + do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
27 | 27 | } |
28 | 28 | ?> |
@@ -18,46 +18,46 @@ |
||
18 | 18 | class TicketSelectorSimple extends TicketSelector |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var \EE_Ticket $ticket |
|
23 | - */ |
|
24 | - protected $ticket; |
|
21 | + /** |
|
22 | + * @var \EE_Ticket $ticket |
|
23 | + */ |
|
24 | + protected $ticket; |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * TicketSelectorSimple constructor. |
|
30 | - * |
|
31 | - * @param \EE_Event $event |
|
32 | - * @param \EE_Ticket $ticket |
|
33 | - * @param int $max_attendees |
|
34 | - * @param array $template_args |
|
35 | - */ |
|
36 | - public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
37 | - { |
|
38 | - $this->ticket = $ticket; |
|
39 | - parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
40 | - } |
|
28 | + /** |
|
29 | + * TicketSelectorSimple constructor. |
|
30 | + * |
|
31 | + * @param \EE_Event $event |
|
32 | + * @param \EE_Ticket $ticket |
|
33 | + * @param int $max_attendees |
|
34 | + * @param array $template_args |
|
35 | + */ |
|
36 | + public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
37 | + { |
|
38 | + $this->ticket = $ticket; |
|
39 | + parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * sets any and all template args that are required for this Ticket Selector |
|
46 | - * |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - protected function addTemplateArgs() |
|
50 | - { |
|
51 | - unset($this->template_args['tickets']); |
|
52 | - $this->template_args['ticket'] = $this->ticket; |
|
53 | - $ticket_selector_row = new TicketSelectorRowSimple( |
|
54 | - $this->ticket, |
|
55 | - $this->max_attendees, |
|
56 | - $this->template_args['date_format'] |
|
57 | - ); |
|
58 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
59 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
60 | - } |
|
44 | + /** |
|
45 | + * sets any and all template args that are required for this Ticket Selector |
|
46 | + * |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + protected function addTemplateArgs() |
|
50 | + { |
|
51 | + unset($this->template_args['tickets']); |
|
52 | + $this->template_args['ticket'] = $this->ticket; |
|
53 | + $ticket_selector_row = new TicketSelectorRowSimple( |
|
54 | + $this->ticket, |
|
55 | + $this->max_attendees, |
|
56 | + $this->template_args['date_format'] |
|
57 | + ); |
|
58 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
59 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | 63 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $this->template_args['date_format'] |
57 | 57 | ); |
58 | 58 | $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
59 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
59 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php'; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 |
@@ -16,90 +16,90 @@ |
||
16 | 16 | abstract class TicketSelector |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Event $event |
|
21 | - */ |
|
22 | - protected $event; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket[] $tickets |
|
26 | - */ |
|
27 | - protected $tickets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var int max_attendees |
|
31 | - */ |
|
32 | - protected $max_attendees; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var array $template_args |
|
36 | - */ |
|
37 | - protected $template_args; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * TicketSelectorSimple constructor. |
|
43 | - * |
|
44 | - * @param \EE_Event $event |
|
45 | - * @param \EE_Ticket[] $tickets |
|
46 | - * @param int $max_attendees |
|
47 | - * @param array $template_args |
|
48 | - */ |
|
49 | - public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
50 | - { |
|
51 | - $this->event = $event; |
|
52 | - $this->tickets = $tickets; |
|
53 | - $this->max_attendees = $max_attendees; |
|
54 | - $this->template_args = $template_args; |
|
55 | - $this->addTemplateArgs(); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * sets any and all template args that are required for this Ticket Selector |
|
62 | - * |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - abstract protected function addTemplateArgs(); |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * loadTicketSelectorTemplate |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - protected function loadTicketSelectorTemplate() |
|
75 | - { |
|
76 | - try { |
|
77 | - return \EEH_Template::locate_template( |
|
78 | - apply_filters( |
|
79 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
80 | - $this->template_args['template_path'], |
|
81 | - $this->event |
|
82 | - ), |
|
83 | - $this->template_args |
|
84 | - ); |
|
85 | - } catch (\Exception $e) { |
|
86 | - \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
87 | - } |
|
88 | - return ''; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
95 | - * |
|
96 | - * @return string |
|
97 | - * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
98 | - */ |
|
99 | - public function __toString() |
|
100 | - { |
|
101 | - return $this->loadTicketSelectorTemplate(); |
|
102 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Event $event |
|
21 | + */ |
|
22 | + protected $event; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket[] $tickets |
|
26 | + */ |
|
27 | + protected $tickets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var int max_attendees |
|
31 | + */ |
|
32 | + protected $max_attendees; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var array $template_args |
|
36 | + */ |
|
37 | + protected $template_args; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * TicketSelectorSimple constructor. |
|
43 | + * |
|
44 | + * @param \EE_Event $event |
|
45 | + * @param \EE_Ticket[] $tickets |
|
46 | + * @param int $max_attendees |
|
47 | + * @param array $template_args |
|
48 | + */ |
|
49 | + public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
50 | + { |
|
51 | + $this->event = $event; |
|
52 | + $this->tickets = $tickets; |
|
53 | + $this->max_attendees = $max_attendees; |
|
54 | + $this->template_args = $template_args; |
|
55 | + $this->addTemplateArgs(); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * sets any and all template args that are required for this Ticket Selector |
|
62 | + * |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + abstract protected function addTemplateArgs(); |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * loadTicketSelectorTemplate |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + protected function loadTicketSelectorTemplate() |
|
75 | + { |
|
76 | + try { |
|
77 | + return \EEH_Template::locate_template( |
|
78 | + apply_filters( |
|
79 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
80 | + $this->template_args['template_path'], |
|
81 | + $this->event |
|
82 | + ), |
|
83 | + $this->template_args |
|
84 | + ); |
|
85 | + } catch (\Exception $e) { |
|
86 | + \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
87 | + } |
|
88 | + return ''; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
95 | + * |
|
96 | + * @return string |
|
97 | + * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
98 | + */ |
|
99 | + public function __toString() |
|
100 | + { |
|
101 | + return $this->loadTicketSelectorTemplate(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 |
@@ -111,7 +111,7 @@ |
||
111 | 111 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
112 | 112 | $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector($this->date_format); |
113 | 113 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
114 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
114 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
115 | 115 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
116 | 116 | } |
117 | 117 |
@@ -17,118 +17,118 @@ |
||
17 | 17 | class TicketSelectorStandard extends TicketSelector |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $date_format |
|
22 | - */ |
|
23 | - protected $date_format; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $time_format |
|
27 | - */ |
|
28 | - protected $time_format; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | - */ |
|
33 | - protected $ticket_selector_config; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \EE_Tax_Config $tax_config |
|
37 | - */ |
|
38 | - protected $tax_config; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * TicketSelectorSimple constructor. |
|
44 | - * |
|
45 | - * @param \EE_Event $event |
|
46 | - * @param \EE_Ticket[] $tickets |
|
47 | - * @param int $max_attendees |
|
48 | - * @param array $template_args |
|
49 | - * @param string $date_format |
|
50 | - * @param string $time_format |
|
51 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | - * @param \EE_Tax_Config $tax_config |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Event $event, |
|
56 | - array $tickets, |
|
57 | - $max_attendees, |
|
58 | - array $template_args, |
|
59 | - $date_format = 'Y-m-d', |
|
60 | - $time_format = 'g:i a', |
|
61 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | - \EE_Tax_Config $tax_config = null |
|
63 | - ) { |
|
64 | - $this->date_format = $date_format; |
|
65 | - $this->time_format = $time_format; |
|
66 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | - $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | - : new \EE_Ticket_Selector_Config(); |
|
70 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | - $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | - : new \EE_Tax_Config(); |
|
76 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * sets any and all template args that are required for this Ticket Selector |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function addTemplateArgs() |
|
88 | - { |
|
89 | - $row = 1; |
|
90 | - $ticket_row_html = ''; |
|
91 | - $required_ticket_sold_out = false; |
|
92 | - // flag to indicate that at least one taxable ticket has been encountered |
|
93 | - $taxable_tickets = false; |
|
94 | - $datetime_selector = new DatetimeSelector( |
|
95 | - $this->event, |
|
96 | - $this->tickets, |
|
97 | - $this->ticket_selector_config, |
|
98 | - $this->date_format, |
|
99 | - $this->time_format |
|
100 | - ); |
|
101 | - // loop through tickets |
|
102 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
103 | - if ($ticket instanceof \EE_Ticket) { |
|
104 | - $cols = 2; |
|
105 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
106 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
107 | - $ticket, |
|
108 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
109 | - $this->ticket_selector_config, |
|
110 | - $this->tax_config, |
|
111 | - $this->max_attendees, |
|
112 | - $row, |
|
113 | - $cols, |
|
114 | - $required_ticket_sold_out, |
|
115 | - $this->template_args['event_status'], |
|
116 | - $this->template_args['date_format'], |
|
117 | - $datetime_selector->getTicketDatetimeClasses($ticket) |
|
118 | - ); |
|
119 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
120 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
121 | - $row++; |
|
122 | - } |
|
123 | - } |
|
124 | - $this->template_args['row'] = $row; |
|
125 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
126 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
127 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
128 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
129 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
130 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
131 | - } |
|
20 | + /** |
|
21 | + * @var string $date_format |
|
22 | + */ |
|
23 | + protected $date_format; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $time_format |
|
27 | + */ |
|
28 | + protected $time_format; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | + */ |
|
33 | + protected $ticket_selector_config; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \EE_Tax_Config $tax_config |
|
37 | + */ |
|
38 | + protected $tax_config; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * TicketSelectorSimple constructor. |
|
44 | + * |
|
45 | + * @param \EE_Event $event |
|
46 | + * @param \EE_Ticket[] $tickets |
|
47 | + * @param int $max_attendees |
|
48 | + * @param array $template_args |
|
49 | + * @param string $date_format |
|
50 | + * @param string $time_format |
|
51 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | + * @param \EE_Tax_Config $tax_config |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Event $event, |
|
56 | + array $tickets, |
|
57 | + $max_attendees, |
|
58 | + array $template_args, |
|
59 | + $date_format = 'Y-m-d', |
|
60 | + $time_format = 'g:i a', |
|
61 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | + \EE_Tax_Config $tax_config = null |
|
63 | + ) { |
|
64 | + $this->date_format = $date_format; |
|
65 | + $this->time_format = $time_format; |
|
66 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | + $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | + : new \EE_Ticket_Selector_Config(); |
|
70 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | + $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | + : new \EE_Tax_Config(); |
|
76 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * sets any and all template args that are required for this Ticket Selector |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function addTemplateArgs() |
|
88 | + { |
|
89 | + $row = 1; |
|
90 | + $ticket_row_html = ''; |
|
91 | + $required_ticket_sold_out = false; |
|
92 | + // flag to indicate that at least one taxable ticket has been encountered |
|
93 | + $taxable_tickets = false; |
|
94 | + $datetime_selector = new DatetimeSelector( |
|
95 | + $this->event, |
|
96 | + $this->tickets, |
|
97 | + $this->ticket_selector_config, |
|
98 | + $this->date_format, |
|
99 | + $this->time_format |
|
100 | + ); |
|
101 | + // loop through tickets |
|
102 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
103 | + if ($ticket instanceof \EE_Ticket) { |
|
104 | + $cols = 2; |
|
105 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
106 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
107 | + $ticket, |
|
108 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
109 | + $this->ticket_selector_config, |
|
110 | + $this->tax_config, |
|
111 | + $this->max_attendees, |
|
112 | + $row, |
|
113 | + $cols, |
|
114 | + $required_ticket_sold_out, |
|
115 | + $this->template_args['event_status'], |
|
116 | + $this->template_args['date_format'], |
|
117 | + $datetime_selector->getTicketDatetimeClasses($ticket) |
|
118 | + ); |
|
119 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
120 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
121 | + $row++; |
|
122 | + } |
|
123 | + } |
|
124 | + $this->template_args['row'] = $row; |
|
125 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
126 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
127 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
128 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
129 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
130 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | 134 |
@@ -119,19 +119,19 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * Form constructor. |
|
124 | - * |
|
125 | - * @param string $form_name |
|
126 | - * @param string $admin_name |
|
127 | - * @param string $slug |
|
128 | - * @param string $form_action |
|
129 | - * @param string $form_config |
|
130 | - * @param \EE_Registry $registry |
|
131 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
132 | - * @throws \DomainException |
|
133 | - * @throws \InvalidArgumentException |
|
134 | - */ |
|
122 | + /** |
|
123 | + * Form constructor. |
|
124 | + * |
|
125 | + * @param string $form_name |
|
126 | + * @param string $admin_name |
|
127 | + * @param string $slug |
|
128 | + * @param string $form_action |
|
129 | + * @param string $form_config |
|
130 | + * @param \EE_Registry $registry |
|
131 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
132 | + * @throws \DomainException |
|
133 | + * @throws \InvalidArgumentException |
|
134 | + */ |
|
135 | 135 | public function __construct( |
136 | 136 | $form_name, |
137 | 137 | $admin_name, |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @throws \LogicException |
173 | 173 | */ |
174 | 174 | public function form( $for_display = false ) { |
175 | - if ( ! $this->formIsValid() ) { |
|
175 | + if ( ! $this->formIsValid() ) { |
|
176 | 176 | return null; |
177 | 177 | } |
178 | 178 | if ( $for_display ) { |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * @throws LogicException |
196 | 196 | */ |
197 | 197 | public function formIsValid() { |
198 | - if ( ! $this->form instanceof \EE_Form_Section_Proper ) { |
|
198 | + if ( ! $this->form instanceof \EE_Form_Section_Proper ) { |
|
199 | 199 | static $generated = false; |
200 | 200 | if ( ! $generated ) { |
201 | 201 | $generated = true; |
202 | 202 | $form = $this->generate(); |
203 | - if ( $form instanceof \EE_Form_Section_Proper) { |
|
204 | - $this->setForm($form); |
|
205 | - } |
|
203 | + if ( $form instanceof \EE_Form_Section_Proper) { |
|
204 | + $this->setForm($form); |
|
205 | + } |
|
206 | 206 | } |
207 | 207 | return $this->verifyForm(); |
208 | 208 | } |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | |
338 | 338 | |
339 | 339 | |
340 | - /** |
|
341 | - * @param string $submit_btn_text |
|
342 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
343 | - * @throws \InvalidArgumentException |
|
344 | - */ |
|
340 | + /** |
|
341 | + * @param string $submit_btn_text |
|
342 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
343 | + * @throws \InvalidArgumentException |
|
344 | + */ |
|
345 | 345 | public function setSubmitBtnText( $submit_btn_text ) { |
346 | 346 | if ( ! is_string( $submit_btn_text ) ) { |
347 | 347 | throw new InvalidDataTypeException( '$submit_btn_text', $submit_btn_text, 'string' ); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @throws \EE_Error |
575 | 575 | */ |
576 | 576 | public function display() { |
577 | - $form_html = apply_filters( |
|
577 | + $form_html = apply_filters( |
|
578 | 578 | 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form', |
579 | 579 | '' |
580 | 580 | ); |
@@ -613,11 +613,11 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function process( $submitted_form_data = array() ) { |
615 | 615 | if ( ! $this->form()->was_submitted( $submitted_form_data ) ) { |
616 | - throw new InvalidFormSubmissionException( $this->form_name ); |
|
616 | + throw new InvalidFormSubmissionException( $this->form_name ); |
|
617 | 617 | } |
618 | - $this->form( true )->receive_form_submission( $submitted_form_data ); |
|
618 | + $this->form( true )->receive_form_submission( $submitted_form_data ); |
|
619 | 619 | if ( ! $this->form()->is_valid() ) { |
620 | - throw new InvalidFormSubmissionException( |
|
620 | + throw new InvalidFormSubmissionException( |
|
621 | 621 | $this->form_name, |
622 | 622 | sprintf( |
623 | 623 | __( |
@@ -1207,7 +1207,7 @@ |
||
1207 | 1207 | * |
1208 | 1208 | * @access public |
1209 | 1209 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1210 | - * @return mixed void|string |
|
1210 | + * @return string void|string |
|
1211 | 1211 | * @throws \EE_Error |
1212 | 1212 | */ |
1213 | 1213 | public function pretty_active_status($echo = true) |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,1368 +14,1368 @@ discard block |
||
14 | 14 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * cached value for the the logical active status for the event |
|
19 | - * |
|
20 | - * @see get_active_status() |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $_active_status = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
27 | - * |
|
28 | - * @var EE_Datetime |
|
29 | - */ |
|
30 | - protected $_Primary_Datetime; |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param array $props_n_values incoming values |
|
36 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
37 | - * used.) |
|
38 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
39 | - * date_format and the second value is the time format |
|
40 | - * @return EE_Event |
|
41 | - */ |
|
42 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
43 | - { |
|
44 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
45 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @param array $props_n_values incoming values from the database |
|
52 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
53 | - * the website will be used. |
|
54 | - * @return EE_Event |
|
55 | - */ |
|
56 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
57 | - { |
|
58 | - return new self($props_n_values, true, $timezone); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
65 | - * |
|
66 | - * @param string $field_name |
|
67 | - * @param mixed $field_value |
|
68 | - * @param bool $use_default |
|
69 | - */ |
|
70 | - public function set($field_name, $field_value, $use_default = false) |
|
71 | - { |
|
72 | - switch ($field_name) { |
|
73 | - case 'status' : |
|
74 | - $this->set_status($field_value, $use_default); |
|
75 | - break; |
|
76 | - default : |
|
77 | - parent::set($field_name, $field_value, $use_default); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * set_status |
|
85 | - * Checks if event status is being changed to SOLD OUT |
|
86 | - * and updates event meta data with previous event status |
|
87 | - * so that we can revert things if/when the event is no longer sold out |
|
88 | - * |
|
89 | - * @access public |
|
90 | - * @param string $new_status |
|
91 | - * @param bool $use_default |
|
92 | - * @return bool|void |
|
93 | - * @throws \EE_Error |
|
94 | - */ |
|
95 | - public function set_status($new_status = null, $use_default = false) |
|
96 | - { |
|
97 | - // get current Event status |
|
98 | - $old_status = $this->status(); |
|
99 | - // if status has changed |
|
100 | - if ($old_status != $new_status) { |
|
101 | - // TO sold_out |
|
102 | - if ($new_status == EEM_Event::sold_out) { |
|
103 | - // save the previous event status so that we can revert if the event is no longer sold out |
|
104 | - $this->add_post_meta('_previous_event_status', $old_status); |
|
105 | - do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
106 | - // OR FROM sold_out |
|
107 | - } else if ($old_status == EEM_Event::sold_out) { |
|
108 | - $this->delete_post_meta('_previous_event_status'); |
|
109 | - do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
110 | - } |
|
111 | - // update status |
|
112 | - parent::set('status', $new_status, $use_default); |
|
113 | - do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
114 | - return true; |
|
115 | - } else { |
|
116 | - // even though the old value matches the new value, it's still good to |
|
117 | - // allow the parent set method to have a say |
|
118 | - parent::set('status', $new_status, $use_default); |
|
119 | - return true; |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * Gets all the datetimes for this event |
|
127 | - * |
|
128 | - * @param array $query_params like EEM_Base::get_all |
|
129 | - * @return EE_Datetime[] |
|
130 | - */ |
|
131 | - public function datetimes($query_params = array()) |
|
132 | - { |
|
133 | - return $this->get_many_related('Datetime', $query_params); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
140 | - * |
|
141 | - * @return EE_Datetime[] |
|
142 | - */ |
|
143 | - public function datetimes_in_chronological_order() |
|
144 | - { |
|
145 | - return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
152 | - * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
153 | - * after running our query, so that this timezone isn't set for EVERY query |
|
154 | - * on EEM_Datetime for the rest of the request, no? |
|
155 | - * |
|
156 | - * @param boolean $show_expired whether or not to include expired events |
|
157 | - * @param boolean $show_deleted whether or not to include deleted events |
|
158 | - * @param null $limit |
|
159 | - * @return \EE_Datetime[] |
|
160 | - * @throws \EE_Error |
|
161 | - */ |
|
162 | - public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
163 | - { |
|
164 | - return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
165 | - $this->ID(), |
|
166 | - $show_expired, |
|
167 | - $show_deleted, |
|
168 | - $limit |
|
169 | - ); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Returns one related datetime. Mostly only used by some legacy code. |
|
176 | - * |
|
177 | - * @return EE_Datetime |
|
178 | - */ |
|
179 | - public function first_datetime() |
|
180 | - { |
|
181 | - return $this->get_first_related('Datetime'); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Returns the 'primary' datetime for the event |
|
188 | - * |
|
189 | - * @param bool $try_to_exclude_expired |
|
190 | - * @param bool $try_to_exclude_deleted |
|
191 | - * @return EE_Datetime |
|
192 | - */ |
|
193 | - public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
194 | - { |
|
195 | - if ( ! empty ($this->_Primary_Datetime)) { |
|
196 | - return $this->_Primary_Datetime; |
|
197 | - } |
|
198 | - $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone) |
|
199 | - ->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, |
|
200 | - $try_to_exclude_deleted); |
|
201 | - return $this->_Primary_Datetime; |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * Gets all the tickets available for purchase of this event |
|
208 | - * |
|
209 | - * @param array $query_params like EEM_Base::get_all |
|
210 | - * @return EE_Ticket[] |
|
211 | - */ |
|
212 | - public function tickets($query_params = array()) |
|
213 | - { |
|
214 | - //first get all datetimes |
|
215 | - $datetimes = $this->datetimes_ordered(); |
|
216 | - if ( ! $datetimes) { |
|
217 | - return array(); |
|
218 | - } |
|
219 | - $datetime_ids = array(); |
|
220 | - foreach ($datetimes as $datetime) { |
|
221 | - $datetime_ids[] = $datetime->ID(); |
|
222 | - } |
|
223 | - $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
224 | - //if incoming $query_params has where conditions let's merge but not override existing. |
|
225 | - if (is_array($query_params) && isset($query_params[0])) { |
|
226 | - $where_params = array_merge($query_params[0], $where_params); |
|
227 | - unset($query_params[0]); |
|
228 | - } |
|
229 | - //now add $where_params to $query_params |
|
230 | - $query_params[0] = $where_params; |
|
231 | - return EEM_Ticket::instance()->get_all($query_params); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * @return bool |
|
238 | - */ |
|
239 | - public function additional_limit() |
|
240 | - { |
|
241 | - return $this->get('EVT_additional_limit'); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @return bool |
|
248 | - */ |
|
249 | - public function allow_overflow() |
|
250 | - { |
|
251 | - return $this->get('EVT_allow_overflow'); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * @return bool |
|
258 | - */ |
|
259 | - public function created() |
|
260 | - { |
|
261 | - return $this->get('EVT_created'); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @return bool |
|
268 | - */ |
|
269 | - public function description() |
|
270 | - { |
|
271 | - return $this->get('EVT_desc'); |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * Runs do_shortcode and wpautop on the description |
|
278 | - * |
|
279 | - * @return string of html |
|
280 | - */ |
|
281 | - public function description_filtered() |
|
282 | - { |
|
283 | - return $this->get_pretty('EVT_desc'); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * @return bool |
|
290 | - */ |
|
291 | - public function display_description() |
|
292 | - { |
|
293 | - return $this->get('EVT_display_desc'); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * @return bool |
|
300 | - */ |
|
301 | - public function display_ticket_selector() |
|
302 | - { |
|
303 | - return (bool)$this->get('EVT_display_ticket_selector'); |
|
304 | - } |
|
305 | - |
|
17 | + /** |
|
18 | + * cached value for the the logical active status for the event |
|
19 | + * |
|
20 | + * @see get_active_status() |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $_active_status = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
27 | + * |
|
28 | + * @var EE_Datetime |
|
29 | + */ |
|
30 | + protected $_Primary_Datetime; |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param array $props_n_values incoming values |
|
36 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
37 | + * used.) |
|
38 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
39 | + * date_format and the second value is the time format |
|
40 | + * @return EE_Event |
|
41 | + */ |
|
42 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
43 | + { |
|
44 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
45 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @param array $props_n_values incoming values from the database |
|
52 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
53 | + * the website will be used. |
|
54 | + * @return EE_Event |
|
55 | + */ |
|
56 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
57 | + { |
|
58 | + return new self($props_n_values, true, $timezone); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
65 | + * |
|
66 | + * @param string $field_name |
|
67 | + * @param mixed $field_value |
|
68 | + * @param bool $use_default |
|
69 | + */ |
|
70 | + public function set($field_name, $field_value, $use_default = false) |
|
71 | + { |
|
72 | + switch ($field_name) { |
|
73 | + case 'status' : |
|
74 | + $this->set_status($field_value, $use_default); |
|
75 | + break; |
|
76 | + default : |
|
77 | + parent::set($field_name, $field_value, $use_default); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * set_status |
|
85 | + * Checks if event status is being changed to SOLD OUT |
|
86 | + * and updates event meta data with previous event status |
|
87 | + * so that we can revert things if/when the event is no longer sold out |
|
88 | + * |
|
89 | + * @access public |
|
90 | + * @param string $new_status |
|
91 | + * @param bool $use_default |
|
92 | + * @return bool|void |
|
93 | + * @throws \EE_Error |
|
94 | + */ |
|
95 | + public function set_status($new_status = null, $use_default = false) |
|
96 | + { |
|
97 | + // get current Event status |
|
98 | + $old_status = $this->status(); |
|
99 | + // if status has changed |
|
100 | + if ($old_status != $new_status) { |
|
101 | + // TO sold_out |
|
102 | + if ($new_status == EEM_Event::sold_out) { |
|
103 | + // save the previous event status so that we can revert if the event is no longer sold out |
|
104 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
105 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
106 | + // OR FROM sold_out |
|
107 | + } else if ($old_status == EEM_Event::sold_out) { |
|
108 | + $this->delete_post_meta('_previous_event_status'); |
|
109 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
110 | + } |
|
111 | + // update status |
|
112 | + parent::set('status', $new_status, $use_default); |
|
113 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
114 | + return true; |
|
115 | + } else { |
|
116 | + // even though the old value matches the new value, it's still good to |
|
117 | + // allow the parent set method to have a say |
|
118 | + parent::set('status', $new_status, $use_default); |
|
119 | + return true; |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * Gets all the datetimes for this event |
|
127 | + * |
|
128 | + * @param array $query_params like EEM_Base::get_all |
|
129 | + * @return EE_Datetime[] |
|
130 | + */ |
|
131 | + public function datetimes($query_params = array()) |
|
132 | + { |
|
133 | + return $this->get_many_related('Datetime', $query_params); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
140 | + * |
|
141 | + * @return EE_Datetime[] |
|
142 | + */ |
|
143 | + public function datetimes_in_chronological_order() |
|
144 | + { |
|
145 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
152 | + * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
153 | + * after running our query, so that this timezone isn't set for EVERY query |
|
154 | + * on EEM_Datetime for the rest of the request, no? |
|
155 | + * |
|
156 | + * @param boolean $show_expired whether or not to include expired events |
|
157 | + * @param boolean $show_deleted whether or not to include deleted events |
|
158 | + * @param null $limit |
|
159 | + * @return \EE_Datetime[] |
|
160 | + * @throws \EE_Error |
|
161 | + */ |
|
162 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
163 | + { |
|
164 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
165 | + $this->ID(), |
|
166 | + $show_expired, |
|
167 | + $show_deleted, |
|
168 | + $limit |
|
169 | + ); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Returns one related datetime. Mostly only used by some legacy code. |
|
176 | + * |
|
177 | + * @return EE_Datetime |
|
178 | + */ |
|
179 | + public function first_datetime() |
|
180 | + { |
|
181 | + return $this->get_first_related('Datetime'); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Returns the 'primary' datetime for the event |
|
188 | + * |
|
189 | + * @param bool $try_to_exclude_expired |
|
190 | + * @param bool $try_to_exclude_deleted |
|
191 | + * @return EE_Datetime |
|
192 | + */ |
|
193 | + public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
194 | + { |
|
195 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
196 | + return $this->_Primary_Datetime; |
|
197 | + } |
|
198 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone) |
|
199 | + ->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, |
|
200 | + $try_to_exclude_deleted); |
|
201 | + return $this->_Primary_Datetime; |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * Gets all the tickets available for purchase of this event |
|
208 | + * |
|
209 | + * @param array $query_params like EEM_Base::get_all |
|
210 | + * @return EE_Ticket[] |
|
211 | + */ |
|
212 | + public function tickets($query_params = array()) |
|
213 | + { |
|
214 | + //first get all datetimes |
|
215 | + $datetimes = $this->datetimes_ordered(); |
|
216 | + if ( ! $datetimes) { |
|
217 | + return array(); |
|
218 | + } |
|
219 | + $datetime_ids = array(); |
|
220 | + foreach ($datetimes as $datetime) { |
|
221 | + $datetime_ids[] = $datetime->ID(); |
|
222 | + } |
|
223 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
224 | + //if incoming $query_params has where conditions let's merge but not override existing. |
|
225 | + if (is_array($query_params) && isset($query_params[0])) { |
|
226 | + $where_params = array_merge($query_params[0], $where_params); |
|
227 | + unset($query_params[0]); |
|
228 | + } |
|
229 | + //now add $where_params to $query_params |
|
230 | + $query_params[0] = $where_params; |
|
231 | + return EEM_Ticket::instance()->get_all($query_params); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * @return bool |
|
238 | + */ |
|
239 | + public function additional_limit() |
|
240 | + { |
|
241 | + return $this->get('EVT_additional_limit'); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @return bool |
|
248 | + */ |
|
249 | + public function allow_overflow() |
|
250 | + { |
|
251 | + return $this->get('EVT_allow_overflow'); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * @return bool |
|
258 | + */ |
|
259 | + public function created() |
|
260 | + { |
|
261 | + return $this->get('EVT_created'); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @return bool |
|
268 | + */ |
|
269 | + public function description() |
|
270 | + { |
|
271 | + return $this->get('EVT_desc'); |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * Runs do_shortcode and wpautop on the description |
|
278 | + * |
|
279 | + * @return string of html |
|
280 | + */ |
|
281 | + public function description_filtered() |
|
282 | + { |
|
283 | + return $this->get_pretty('EVT_desc'); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * @return bool |
|
290 | + */ |
|
291 | + public function display_description() |
|
292 | + { |
|
293 | + return $this->get('EVT_display_desc'); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * @return bool |
|
300 | + */ |
|
301 | + public function display_ticket_selector() |
|
302 | + { |
|
303 | + return (bool)$this->get('EVT_display_ticket_selector'); |
|
304 | + } |
|
305 | + |
|
306 | 306 | |
307 | 307 | |
308 | - /** |
|
309 | - * @return bool |
|
310 | - */ |
|
311 | - public function external_url() |
|
312 | - { |
|
313 | - return $this->get('EVT_external_URL'); |
|
314 | - } |
|
308 | + /** |
|
309 | + * @return bool |
|
310 | + */ |
|
311 | + public function external_url() |
|
312 | + { |
|
313 | + return $this->get('EVT_external_URL'); |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | 317 | |
318 | - /** |
|
319 | - * @return bool |
|
320 | - */ |
|
321 | - public function member_only() |
|
322 | - { |
|
323 | - return $this->get('EVT_member_only'); |
|
324 | - } |
|
318 | + /** |
|
319 | + * @return bool |
|
320 | + */ |
|
321 | + public function member_only() |
|
322 | + { |
|
323 | + return $this->get('EVT_member_only'); |
|
324 | + } |
|
325 | 325 | |
326 | 326 | |
327 | 327 | |
328 | - /** |
|
329 | - * @return bool |
|
330 | - */ |
|
331 | - public function phone() |
|
332 | - { |
|
333 | - return $this->get('EVT_phone'); |
|
334 | - } |
|
328 | + /** |
|
329 | + * @return bool |
|
330 | + */ |
|
331 | + public function phone() |
|
332 | + { |
|
333 | + return $this->get('EVT_phone'); |
|
334 | + } |
|
335 | 335 | |
336 | 336 | |
337 | 337 | |
338 | - /** |
|
339 | - * @return bool |
|
340 | - */ |
|
341 | - public function modified() |
|
342 | - { |
|
343 | - return $this->get('EVT_modified'); |
|
344 | - } |
|
338 | + /** |
|
339 | + * @return bool |
|
340 | + */ |
|
341 | + public function modified() |
|
342 | + { |
|
343 | + return $this->get('EVT_modified'); |
|
344 | + } |
|
345 | 345 | |
346 | 346 | |
347 | 347 | |
348 | - /** |
|
349 | - * @return bool |
|
350 | - */ |
|
351 | - public function name() |
|
352 | - { |
|
353 | - return $this->get('EVT_name'); |
|
354 | - } |
|
348 | + /** |
|
349 | + * @return bool |
|
350 | + */ |
|
351 | + public function name() |
|
352 | + { |
|
353 | + return $this->get('EVT_name'); |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | 357 | |
358 | - /** |
|
359 | - * @return bool |
|
360 | - */ |
|
361 | - public function order() |
|
362 | - { |
|
363 | - return $this->get('EVT_order'); |
|
364 | - } |
|
358 | + /** |
|
359 | + * @return bool |
|
360 | + */ |
|
361 | + public function order() |
|
362 | + { |
|
363 | + return $this->get('EVT_order'); |
|
364 | + } |
|
365 | 365 | |
366 | 366 | |
367 | 367 | |
368 | - /** |
|
369 | - * @return bool|string |
|
370 | - */ |
|
371 | - public function default_registration_status() |
|
372 | - { |
|
373 | - $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
374 | - return ! empty($event_default_registration_status) ? $event_default_registration_status |
|
375 | - : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
376 | - } |
|
368 | + /** |
|
369 | + * @return bool|string |
|
370 | + */ |
|
371 | + public function default_registration_status() |
|
372 | + { |
|
373 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
374 | + return ! empty($event_default_registration_status) ? $event_default_registration_status |
|
375 | + : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
376 | + } |
|
377 | 377 | |
378 | 378 | |
379 | 379 | |
380 | - /** |
|
381 | - * @param int $num_words |
|
382 | - * @param null $more |
|
383 | - * @param bool $not_full_desc |
|
384 | - * @return bool|string |
|
385 | - */ |
|
386 | - public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
387 | - { |
|
388 | - $short_desc = $this->get('EVT_short_desc'); |
|
389 | - if ( ! empty($short_desc) || $not_full_desc) { |
|
390 | - return $short_desc; |
|
391 | - } else { |
|
392 | - $full_desc = $this->get('EVT_desc'); |
|
393 | - return wp_trim_words($full_desc, $num_words, $more); |
|
394 | - } |
|
395 | - } |
|
380 | + /** |
|
381 | + * @param int $num_words |
|
382 | + * @param null $more |
|
383 | + * @param bool $not_full_desc |
|
384 | + * @return bool|string |
|
385 | + */ |
|
386 | + public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
387 | + { |
|
388 | + $short_desc = $this->get('EVT_short_desc'); |
|
389 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
390 | + return $short_desc; |
|
391 | + } else { |
|
392 | + $full_desc = $this->get('EVT_desc'); |
|
393 | + return wp_trim_words($full_desc, $num_words, $more); |
|
394 | + } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | |
398 | 398 | |
399 | - /** |
|
400 | - * @return bool |
|
401 | - */ |
|
402 | - public function slug() |
|
403 | - { |
|
404 | - return $this->get('EVT_slug'); |
|
405 | - } |
|
399 | + /** |
|
400 | + * @return bool |
|
401 | + */ |
|
402 | + public function slug() |
|
403 | + { |
|
404 | + return $this->get('EVT_slug'); |
|
405 | + } |
|
406 | 406 | |
407 | 407 | |
408 | 408 | |
409 | - /** |
|
410 | - * @return bool |
|
411 | - */ |
|
412 | - public function timezone_string() |
|
413 | - { |
|
414 | - return $this->get('EVT_timezone_string'); |
|
415 | - } |
|
409 | + /** |
|
410 | + * @return bool |
|
411 | + */ |
|
412 | + public function timezone_string() |
|
413 | + { |
|
414 | + return $this->get('EVT_timezone_string'); |
|
415 | + } |
|
416 | 416 | |
417 | 417 | |
418 | 418 | |
419 | - /** |
|
420 | - * @return bool |
|
421 | - */ |
|
422 | - public function visible_on() |
|
423 | - { |
|
424 | - return $this->get('EVT_visible_on'); |
|
425 | - } |
|
419 | + /** |
|
420 | + * @return bool |
|
421 | + */ |
|
422 | + public function visible_on() |
|
423 | + { |
|
424 | + return $this->get('EVT_visible_on'); |
|
425 | + } |
|
426 | 426 | |
427 | 427 | |
428 | 428 | |
429 | - /** |
|
430 | - * @return int |
|
431 | - */ |
|
432 | - public function wp_user() |
|
433 | - { |
|
434 | - return $this->get('EVT_wp_user'); |
|
435 | - } |
|
429 | + /** |
|
430 | + * @return int |
|
431 | + */ |
|
432 | + public function wp_user() |
|
433 | + { |
|
434 | + return $this->get('EVT_wp_user'); |
|
435 | + } |
|
436 | 436 | |
437 | 437 | |
438 | 438 | |
439 | - /** |
|
440 | - * @return bool |
|
441 | - */ |
|
442 | - public function donations() |
|
443 | - { |
|
444 | - return $this->get('EVT_donations'); |
|
445 | - } |
|
439 | + /** |
|
440 | + * @return bool |
|
441 | + */ |
|
442 | + public function donations() |
|
443 | + { |
|
444 | + return $this->get('EVT_donations'); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | |
448 | 448 | |
449 | - /** |
|
450 | - * @param $limit |
|
451 | - */ |
|
452 | - public function set_additional_limit($limit) |
|
453 | - { |
|
454 | - $this->set('EVT_additional_limit', $limit); |
|
455 | - } |
|
449 | + /** |
|
450 | + * @param $limit |
|
451 | + */ |
|
452 | + public function set_additional_limit($limit) |
|
453 | + { |
|
454 | + $this->set('EVT_additional_limit', $limit); |
|
455 | + } |
|
456 | 456 | |
457 | 457 | |
458 | 458 | |
459 | - /** |
|
460 | - * @param $created |
|
461 | - */ |
|
462 | - public function set_created($created) |
|
463 | - { |
|
464 | - $this->set('EVT_created', $created); |
|
465 | - } |
|
459 | + /** |
|
460 | + * @param $created |
|
461 | + */ |
|
462 | + public function set_created($created) |
|
463 | + { |
|
464 | + $this->set('EVT_created', $created); |
|
465 | + } |
|
466 | 466 | |
467 | 467 | |
468 | 468 | |
469 | - /** |
|
470 | - * @param $desc |
|
471 | - */ |
|
472 | - public function set_description($desc) |
|
473 | - { |
|
474 | - $this->set('EVT_desc', $desc); |
|
475 | - } |
|
469 | + /** |
|
470 | + * @param $desc |
|
471 | + */ |
|
472 | + public function set_description($desc) |
|
473 | + { |
|
474 | + $this->set('EVT_desc', $desc); |
|
475 | + } |
|
476 | 476 | |
477 | 477 | |
478 | 478 | |
479 | - /** |
|
480 | - * @param $display_desc |
|
481 | - */ |
|
482 | - public function set_display_description($display_desc) |
|
483 | - { |
|
484 | - $this->set('EVT_display_desc', $display_desc); |
|
485 | - } |
|
479 | + /** |
|
480 | + * @param $display_desc |
|
481 | + */ |
|
482 | + public function set_display_description($display_desc) |
|
483 | + { |
|
484 | + $this->set('EVT_display_desc', $display_desc); |
|
485 | + } |
|
486 | 486 | |
487 | 487 | |
488 | 488 | |
489 | - /** |
|
490 | - * @param $display_ticket_selector |
|
491 | - */ |
|
492 | - public function set_display_ticket_selector($display_ticket_selector) |
|
493 | - { |
|
494 | - $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
495 | - } |
|
489 | + /** |
|
490 | + * @param $display_ticket_selector |
|
491 | + */ |
|
492 | + public function set_display_ticket_selector($display_ticket_selector) |
|
493 | + { |
|
494 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
495 | + } |
|
496 | 496 | |
497 | 497 | |
498 | 498 | |
499 | - /** |
|
500 | - * @param $external_url |
|
501 | - */ |
|
502 | - public function set_external_url($external_url) |
|
503 | - { |
|
504 | - $this->set('EVT_external_URL', $external_url); |
|
505 | - } |
|
499 | + /** |
|
500 | + * @param $external_url |
|
501 | + */ |
|
502 | + public function set_external_url($external_url) |
|
503 | + { |
|
504 | + $this->set('EVT_external_URL', $external_url); |
|
505 | + } |
|
506 | 506 | |
507 | 507 | |
508 | 508 | |
509 | - /** |
|
510 | - * @param $member_only |
|
511 | - */ |
|
512 | - public function set_member_only($member_only) |
|
513 | - { |
|
514 | - $this->set('EVT_member_only', $member_only); |
|
515 | - } |
|
509 | + /** |
|
510 | + * @param $member_only |
|
511 | + */ |
|
512 | + public function set_member_only($member_only) |
|
513 | + { |
|
514 | + $this->set('EVT_member_only', $member_only); |
|
515 | + } |
|
516 | 516 | |
517 | 517 | |
518 | 518 | |
519 | - /** |
|
520 | - * @param $event_phone |
|
521 | - */ |
|
522 | - public function set_event_phone($event_phone) |
|
523 | - { |
|
524 | - $this->set('EVT_phone', $event_phone); |
|
525 | - } |
|
519 | + /** |
|
520 | + * @param $event_phone |
|
521 | + */ |
|
522 | + public function set_event_phone($event_phone) |
|
523 | + { |
|
524 | + $this->set('EVT_phone', $event_phone); |
|
525 | + } |
|
526 | 526 | |
527 | 527 | |
528 | 528 | |
529 | - /** |
|
530 | - * @param $modified |
|
531 | - */ |
|
532 | - public function set_modified($modified) |
|
533 | - { |
|
534 | - $this->set('EVT_modified', $modified); |
|
535 | - } |
|
529 | + /** |
|
530 | + * @param $modified |
|
531 | + */ |
|
532 | + public function set_modified($modified) |
|
533 | + { |
|
534 | + $this->set('EVT_modified', $modified); |
|
535 | + } |
|
536 | 536 | |
537 | 537 | |
538 | 538 | |
539 | - /** |
|
540 | - * @param $name |
|
541 | - */ |
|
542 | - public function set_name($name) |
|
543 | - { |
|
544 | - $this->set('EVT_name', $name); |
|
545 | - } |
|
539 | + /** |
|
540 | + * @param $name |
|
541 | + */ |
|
542 | + public function set_name($name) |
|
543 | + { |
|
544 | + $this->set('EVT_name', $name); |
|
545 | + } |
|
546 | 546 | |
547 | 547 | |
548 | 548 | |
549 | - /** |
|
550 | - * @param $order |
|
551 | - */ |
|
552 | - public function set_order($order) |
|
553 | - { |
|
554 | - $this->set('EVT_order', $order); |
|
555 | - } |
|
549 | + /** |
|
550 | + * @param $order |
|
551 | + */ |
|
552 | + public function set_order($order) |
|
553 | + { |
|
554 | + $this->set('EVT_order', $order); |
|
555 | + } |
|
556 | 556 | |
557 | 557 | |
558 | 558 | |
559 | - /** |
|
560 | - * @param $short_desc |
|
561 | - */ |
|
562 | - public function set_short_description($short_desc) |
|
563 | - { |
|
564 | - $this->set('EVT_short_desc', $short_desc); |
|
565 | - } |
|
559 | + /** |
|
560 | + * @param $short_desc |
|
561 | + */ |
|
562 | + public function set_short_description($short_desc) |
|
563 | + { |
|
564 | + $this->set('EVT_short_desc', $short_desc); |
|
565 | + } |
|
566 | 566 | |
567 | 567 | |
568 | 568 | |
569 | - /** |
|
570 | - * @param $slug |
|
571 | - */ |
|
572 | - public function set_slug($slug) |
|
573 | - { |
|
574 | - $this->set('EVT_slug', $slug); |
|
575 | - } |
|
569 | + /** |
|
570 | + * @param $slug |
|
571 | + */ |
|
572 | + public function set_slug($slug) |
|
573 | + { |
|
574 | + $this->set('EVT_slug', $slug); |
|
575 | + } |
|
576 | 576 | |
577 | 577 | |
578 | 578 | |
579 | - /** |
|
580 | - * @param $timezone_string |
|
581 | - */ |
|
582 | - public function set_timezone_string($timezone_string) |
|
583 | - { |
|
584 | - $this->set('EVT_timezone_string', $timezone_string); |
|
585 | - } |
|
579 | + /** |
|
580 | + * @param $timezone_string |
|
581 | + */ |
|
582 | + public function set_timezone_string($timezone_string) |
|
583 | + { |
|
584 | + $this->set('EVT_timezone_string', $timezone_string); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | 588 | |
589 | - /** |
|
590 | - * @param $visible_on |
|
591 | - */ |
|
592 | - public function set_visible_on($visible_on) |
|
593 | - { |
|
594 | - $this->set('EVT_visible_on', $visible_on); |
|
595 | - } |
|
589 | + /** |
|
590 | + * @param $visible_on |
|
591 | + */ |
|
592 | + public function set_visible_on($visible_on) |
|
593 | + { |
|
594 | + $this->set('EVT_visible_on', $visible_on); |
|
595 | + } |
|
596 | 596 | |
597 | 597 | |
598 | 598 | |
599 | - /** |
|
600 | - * @param $wp_user |
|
601 | - */ |
|
602 | - public function set_wp_user($wp_user) |
|
603 | - { |
|
604 | - $this->set('EVT_wp_user', $wp_user); |
|
605 | - } |
|
599 | + /** |
|
600 | + * @param $wp_user |
|
601 | + */ |
|
602 | + public function set_wp_user($wp_user) |
|
603 | + { |
|
604 | + $this->set('EVT_wp_user', $wp_user); |
|
605 | + } |
|
606 | 606 | |
607 | 607 | |
608 | - |
|
609 | - /** |
|
610 | - * @param $default_registration_status |
|
611 | - */ |
|
612 | - public function set_default_registration_status($default_registration_status) |
|
613 | - { |
|
614 | - $this->set('EVT_default_registration_status', $default_registration_status); |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - |
|
619 | - /** |
|
620 | - * @param $donations |
|
621 | - */ |
|
622 | - public function set_donations($donations) |
|
623 | - { |
|
624 | - $this->set('EVT_donations', $donations); |
|
625 | - } |
|
626 | - |
|
627 | - |
|
628 | - |
|
629 | - /** |
|
630 | - * Adds a venue to this event |
|
631 | - * |
|
632 | - * @param EE_Venue /int $venue_id_or_obj |
|
633 | - * @return EE_Venue |
|
634 | - */ |
|
635 | - public function add_venue($venue_id_or_obj) |
|
636 | - { |
|
637 | - return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
638 | - } |
|
639 | - |
|
640 | - |
|
641 | - |
|
642 | - /** |
|
643 | - * Removes a venue from the event |
|
644 | - * |
|
645 | - * @param EE_Venue /int $venue_id_or_obj |
|
646 | - * @return EE_Venue |
|
647 | - */ |
|
648 | - public function remove_venue($venue_id_or_obj) |
|
649 | - { |
|
650 | - return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - |
|
655 | - /** |
|
656 | - * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
657 | - * |
|
658 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
659 | - * @return EE_Venue[] |
|
660 | - */ |
|
661 | - public function venues($query_params = array()) |
|
662 | - { |
|
663 | - return $this->get_many_related('Venue', $query_params); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * check if event id is present and if event is published |
|
670 | - * |
|
671 | - * @access public |
|
672 | - * @return boolean true yes, false no |
|
673 | - */ |
|
674 | - private function _has_ID_and_is_published() |
|
675 | - { |
|
676 | - // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
|
677 | - return ($this->ID() && $this->ID() !== null |
|
678 | - && ($this->status() == 'publish' |
|
679 | - || $this->status() |
|
680 | - == EEM_Event::sold_out |
|
681 | - || $this->status() == EEM_Event::postponed |
|
682 | - || $this->status() == EEM_Event::cancelled)) ? true : false; |
|
683 | - } |
|
684 | - |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
689 | - * |
|
690 | - * @access public |
|
691 | - * @return boolean true yes, false no |
|
692 | - */ |
|
693 | - public function is_upcoming() |
|
694 | - { |
|
695 | - // check if event id is present and if this event is published |
|
696 | - if ($this->is_inactive()) { |
|
697 | - return false; |
|
698 | - } |
|
699 | - // set initial value |
|
700 | - $upcoming = false; |
|
701 | - //next let's get all datetimes and loop through them |
|
702 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
703 | - foreach ($datetimes as $datetime) { |
|
704 | - if ($datetime instanceof EE_Datetime) { |
|
705 | - //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
706 | - if ($datetime->is_expired()) { |
|
707 | - continue; |
|
708 | - } |
|
709 | - //if this dtt is active then we return false. |
|
710 | - if ($datetime->is_active()) { |
|
711 | - return false; |
|
712 | - } |
|
713 | - //otherwise let's check upcoming status |
|
714 | - $upcoming = $datetime->is_upcoming(); |
|
715 | - } |
|
716 | - } |
|
717 | - return $upcoming; |
|
718 | - } |
|
719 | - |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * @return bool |
|
724 | - */ |
|
725 | - public function is_active() |
|
726 | - { |
|
727 | - // check if event id is present and if this event is published |
|
728 | - if ($this->is_inactive()) { |
|
729 | - return false; |
|
730 | - } |
|
731 | - // set initial value |
|
732 | - $active = false; |
|
733 | - //next let's get all datetimes and loop through them |
|
734 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
735 | - foreach ($datetimes as $datetime) { |
|
736 | - if ($datetime instanceof EE_Datetime) { |
|
737 | - //if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
738 | - if ($datetime->is_expired()) { |
|
739 | - continue; |
|
740 | - } |
|
741 | - //if this dtt is upcoming then we return false. |
|
742 | - if ($datetime->is_upcoming()) { |
|
743 | - return false; |
|
744 | - } |
|
745 | - //otherwise let's check active status |
|
746 | - $active = $datetime->is_active(); |
|
747 | - } |
|
748 | - } |
|
749 | - return $active; |
|
750 | - } |
|
751 | - |
|
752 | - |
|
753 | - |
|
754 | - /** |
|
755 | - * @return bool |
|
756 | - */ |
|
757 | - public function is_expired() |
|
758 | - { |
|
759 | - // check if event id is present and if this event is published |
|
760 | - if ($this->is_inactive()) { |
|
761 | - return false; |
|
762 | - } |
|
763 | - // set initial value |
|
764 | - $expired = false; |
|
765 | - //first let's get all datetimes and loop through them |
|
766 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
767 | - foreach ($datetimes as $datetime) { |
|
768 | - if ($datetime instanceof EE_Datetime) { |
|
769 | - //if this dtt is upcoming or active then we return false. |
|
770 | - if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
771 | - return false; |
|
772 | - } |
|
773 | - //otherwise let's check active status |
|
774 | - $expired = $datetime->is_expired(); |
|
775 | - } |
|
776 | - } |
|
777 | - return $expired; |
|
778 | - } |
|
779 | - |
|
780 | - |
|
781 | - |
|
782 | - /** |
|
783 | - * @return bool |
|
784 | - */ |
|
785 | - public function is_inactive() |
|
786 | - { |
|
787 | - // check if event id is present and if this event is published |
|
788 | - if ($this->_has_ID_and_is_published()) { |
|
789 | - return false; |
|
790 | - } |
|
791 | - return true; |
|
792 | - } |
|
793 | - |
|
794 | - |
|
795 | - |
|
796 | - /** |
|
797 | - * perform_sold_out_status_check |
|
798 | - * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
799 | - * available... if NOT, then the event status will get toggled to 'sold_out' |
|
800 | - * |
|
801 | - * @access public |
|
802 | - * @return bool return the ACTUAL sold out state. |
|
803 | - */ |
|
804 | - public function perform_sold_out_status_check() |
|
805 | - { |
|
806 | - // get all unexpired untrashed tickets |
|
807 | - $tickets = $this->tickets(array( |
|
808 | - array( |
|
809 | - 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
810 | - 'TKT_deleted' => false, |
|
811 | - ), |
|
812 | - )); |
|
813 | - // if all the tickets are just expired, then don't update the event status to sold out |
|
814 | - if (empty($tickets)) { |
|
815 | - return true; |
|
816 | - } |
|
817 | - // set initial value |
|
818 | - $spaces_remaining = 0; |
|
819 | - foreach ($tickets as $ticket) { |
|
820 | - if ($ticket instanceof EE_Ticket) { |
|
821 | - $spaces_remaining += $ticket->qty('saleable'); |
|
822 | - } |
|
823 | - } |
|
824 | - if ($spaces_remaining === 0) { |
|
825 | - $this->set_status(EEM_Event::sold_out); |
|
826 | - if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
827 | - $this->save(); |
|
828 | - } |
|
829 | - $sold_out = true; |
|
830 | - } else { |
|
831 | - $sold_out = false; |
|
832 | - // was event previously marked as sold out ? |
|
833 | - if ($this->status() == EEM_Event::sold_out) { |
|
834 | - // revert status to previous value, if it was set |
|
835 | - $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
836 | - if ($previous_event_status) { |
|
837 | - $this->set_status($previous_event_status); |
|
838 | - } |
|
839 | - } |
|
840 | - } |
|
841 | - //note: I considered changing the EEM_Event status away from sold_out if this status check reveals that it's no longer sold out (yet the status is still set as sold out) but the problem is... what do we change the status BACK to? We can't always assume that the previous event status was 'published' because this status check is always done in the admin and its entirely possible the event admin manually changes to sold_out status from some other status. We also don't want a draft event to become a "publish event" because the sold out check reveals its NOT sold out. |
|
842 | - // So I'll forgo the automatic switch away from sold out status for now and instead just return the $sold out status... so this check can be used to validate the TRUE sold out status regardless of what the Event status is set to. |
|
843 | - return $sold_out; |
|
844 | - } |
|
845 | - |
|
846 | - |
|
847 | - |
|
848 | - /** |
|
849 | - * This returns the total remaining spaces for sale on this event. |
|
850 | - * ############################ |
|
851 | - * VERY IMPORTANT FOR DEVELOPERS: |
|
852 | - * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
853 | - * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
854 | - * ############################ |
|
855 | - * |
|
856 | - * @uses EE_Event::total_available_spaces() |
|
857 | - * @return float|int (EE_INF is returned as float) |
|
858 | - */ |
|
859 | - public function spaces_remaining_for_sale() |
|
860 | - { |
|
861 | - //first get total available spaces including consideration for tickets that have already sold. |
|
862 | - $spaces_available = $this->total_available_spaces(true); |
|
863 | - //if total available = 0, then exit right away because that means everything is expired. |
|
864 | - if ($spaces_available === 0) { |
|
865 | - return 0; |
|
866 | - } |
|
867 | - //subtract total approved registrations from spaces available to get how many are remaining. |
|
868 | - $spots_taken = EEM_Registration::instance()->count(array( |
|
869 | - array( |
|
870 | - 'EVT_ID' => $this->ID(), |
|
871 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
872 | - ), |
|
873 | - ), 'REG_ID', true); |
|
874 | - $spaces_remaining = $spaces_available - $spots_taken; |
|
875 | - return $spaces_remaining > 0 ? $spaces_remaining : 0; |
|
876 | - } |
|
877 | - |
|
878 | - |
|
879 | - |
|
880 | - /** |
|
881 | - * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg |
|
882 | - * limits on the datetimes attached to this event. |
|
883 | - * ############################ |
|
884 | - * VERY IMPORTANT FOR DEVELOPERS: |
|
885 | - * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
886 | - * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
887 | - * ############################ |
|
888 | - * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using |
|
889 | - * the value from this method and subtracting the approved registrations for the event. |
|
890 | - * |
|
891 | - * @param bool $current_total_available Whether to consider any tickets that have already sold in our |
|
892 | - * calculation. If this is false, then we return the most tickets that |
|
893 | - * could ever be sold for this event with the datetime and tickets |
|
894 | - * setup on the event under optimal selling conditions. Otherwise we |
|
895 | - * return a live calculation of spaces available based on tickets |
|
896 | - * sold. Depending on setup and stage of sales, this may appear to |
|
897 | - * equal remaining tickets. However, the more tickets are sold out, |
|
898 | - * the more accurate the "live" total is. |
|
899 | - * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
|
900 | - */ |
|
901 | - public function total_available_spaces($current_total_available = false) |
|
902 | - { |
|
903 | - $spaces_available = 0; |
|
904 | - //first get all tickets on the event and include expired tickets |
|
905 | - $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
906 | - $ticket_sums = array(); |
|
907 | - $datetime_limits = array(); |
|
908 | - //loop through tickets and normalize them |
|
909 | - foreach ($tickets as $ticket) { |
|
910 | - $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
911 | - if (empty($datetimes)) { |
|
912 | - continue; |
|
913 | - } |
|
914 | - //first datetime should be the lowest datetime |
|
915 | - $least_datetime = reset($datetimes); |
|
916 | - //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
|
917 | - //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
|
918 | - if ($current_total_available) { |
|
919 | - if ($ticket->is_remaining()) { |
|
920 | - $remaining = $ticket->remaining(); |
|
921 | - } else { |
|
922 | - $spaces_available += $ticket->sold(); |
|
923 | - //and we don't cache this ticket to our list because its sold out. |
|
924 | - continue; |
|
925 | - } |
|
926 | - } else { |
|
927 | - $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
928 | - } |
|
929 | - //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
|
930 | - if ($remaining === EE_INF) { |
|
931 | - return EE_INF; |
|
932 | - } |
|
933 | - //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
|
934 | - //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
|
935 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
936 | - $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
|
937 | - foreach ($datetimes as $datetime) { |
|
938 | - if ($datetime->reg_limit() === EE_INF) { |
|
939 | - $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
|
940 | - } else { |
|
941 | - $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available |
|
942 | - ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
943 | - } |
|
944 | - $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() |
|
945 | - : $datetime->reg_limit(); |
|
946 | - } |
|
947 | - $ticket_sums[$ticket->ID()]['ticket'] = $ticket; |
|
948 | - } |
|
949 | - //The order is sorted by lowest available first (which is calculated for each ticket by multiplying the normalized |
|
950 | - //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
|
951 | - //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
|
952 | - //$current_total_available ) for the datetimes on the ticket. |
|
953 | - usort($ticket_sums, function ($a, $b) { |
|
954 | - if ($a['sum'] == $b['sum']) { |
|
955 | - if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
956 | - return 0; |
|
957 | - } |
|
958 | - return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
|
959 | - } |
|
960 | - return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
961 | - }); |
|
962 | - //now let's loop through the sorted tickets and simulate sellouts |
|
963 | - foreach ($ticket_sums as $ticket_info) { |
|
964 | - if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
965 | - $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
966 | - //need to sort these $datetimes by remaining (only if $current_total_available) |
|
967 | - //setup datetimes for simulation |
|
968 | - $ticket_datetimes_remaining = array(); |
|
969 | - foreach ($datetimes as $datetime) { |
|
970 | - $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
|
971 | - $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
|
972 | - } |
|
973 | - usort($ticket_datetimes_remaining, function ($a, $b) { |
|
974 | - if ($a['rem'] == $b['rem']) { |
|
975 | - return 0; |
|
976 | - } |
|
977 | - return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
978 | - }); |
|
979 | - //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
|
980 | - //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
|
981 | - $lowest_datetime = reset($ticket_datetimes_remaining); |
|
982 | - //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
|
983 | - // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
|
984 | - // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
|
985 | - // to the next ticket. |
|
986 | - if ($current_total_available) { |
|
987 | - $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
988 | - } else { |
|
989 | - $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
990 | - } |
|
991 | - //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
|
992 | - //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
|
993 | - //available. |
|
994 | - if ($remaining === EE_INF) { |
|
995 | - $spaces_available += $ticket_info['ticket']->qty(); |
|
996 | - continue; |
|
997 | - } |
|
998 | - //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
|
999 | - if ($current_total_available) { |
|
1000 | - $spaces_available += $ticket_info['ticket']->sold(); |
|
1001 | - } |
|
1002 | - if ($remaining <= 0) { |
|
1003 | - continue; |
|
1004 | - } else { |
|
1005 | - $spaces_available += $remaining; |
|
1006 | - } |
|
1007 | - //loop through the datetimes and sell them out! |
|
1008 | - foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
1009 | - if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
1010 | - $datetime_limits[$datetime_info['datetime']->ID()] += -$remaining; |
|
1011 | - } |
|
1012 | - } |
|
1013 | - } |
|
1014 | - } |
|
1015 | - return $spaces_available; |
|
1016 | - } |
|
1017 | - |
|
1018 | - |
|
1019 | - |
|
1020 | - /** |
|
1021 | - * Checks if the event is set to sold out |
|
1022 | - * |
|
1023 | - * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to |
|
1024 | - * flip the status if necessary to sold out If false, we just check the existing status of the |
|
1025 | - * event |
|
1026 | - * @return boolean |
|
1027 | - */ |
|
1028 | - public function is_sold_out($actual = false) |
|
1029 | - { |
|
1030 | - if ( ! $actual) { |
|
1031 | - return $this->status() == EEM_Event::sold_out; |
|
1032 | - } else { |
|
1033 | - return $this->perform_sold_out_status_check(); |
|
1034 | - } |
|
1035 | - } |
|
1036 | - |
|
1037 | - |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * Checks if the event is marked as postponed |
|
1041 | - * |
|
1042 | - * @return boolean |
|
1043 | - */ |
|
1044 | - public function is_postponed() |
|
1045 | - { |
|
1046 | - return $this->status() == EEM_Event::postponed; |
|
1047 | - } |
|
1048 | - |
|
1049 | - |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * Checks if the event is marked as cancelled |
|
1053 | - * |
|
1054 | - * @return boolean |
|
1055 | - */ |
|
1056 | - public function is_cancelled() |
|
1057 | - { |
|
1058 | - return $this->status() == EEM_Event::cancelled; |
|
1059 | - } |
|
1060 | - |
|
1061 | - |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
1065 | - * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
1066 | - * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
1067 | - * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
1068 | - * the event is considered expired. |
|
1069 | - * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
1070 | - * status set on the EVENT when it is not published and thus is done |
|
1071 | - * |
|
1072 | - * @param bool $reset |
|
1073 | - * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
1074 | - */ |
|
1075 | - public function get_active_status($reset = false) |
|
1076 | - { |
|
1077 | - // if the active status has already been set, then just use that value (unless we are resetting it) |
|
1078 | - if ( ! empty($this->_active_status) && ! $reset) { |
|
1079 | - return $this->_active_status; |
|
1080 | - } |
|
1081 | - //first check if event id is present on this object |
|
1082 | - if ( ! $this->ID()) { |
|
1083 | - return false; |
|
1084 | - } |
|
1085 | - $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
1086 | - //if event is published: |
|
1087 | - if ($this->status() === 'publish') { |
|
1088 | - //active? |
|
1089 | - if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) |
|
1090 | - > 0 |
|
1091 | - ) { |
|
1092 | - $this->_active_status = EE_Datetime::active; |
|
1093 | - } else { |
|
1094 | - //upcoming? |
|
1095 | - if (EEM_Datetime::instance() |
|
1096 | - ->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0 |
|
1097 | - ) { |
|
1098 | - $this->_active_status = EE_Datetime::upcoming; |
|
1099 | - } else { |
|
1100 | - //expired? |
|
1101 | - if (EEM_Datetime::instance() |
|
1102 | - ->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0 |
|
1103 | - ) { |
|
1104 | - $this->_active_status = EE_Datetime::expired; |
|
1105 | - } else { |
|
1106 | - //it would be odd if things make it this far because it basically means there are no datetime's |
|
1107 | - //attached to the event. So in this case it will just be considered inactive. |
|
1108 | - $this->_active_status = EE_Datetime::inactive; |
|
1109 | - } |
|
1110 | - } |
|
1111 | - } |
|
1112 | - } else { |
|
1113 | - //the event is not published, so let's just set it's active status according to its' post status |
|
1114 | - switch ($this->status()) { |
|
1115 | - case EEM_Event::sold_out : |
|
1116 | - $this->_active_status = EE_Datetime::sold_out; |
|
1117 | - break; |
|
1118 | - case EEM_Event::cancelled : |
|
1119 | - $this->_active_status = EE_Datetime::cancelled; |
|
1120 | - break; |
|
1121 | - case EEM_Event::postponed : |
|
1122 | - $this->_active_status = EE_Datetime::postponed; |
|
1123 | - break; |
|
1124 | - default : |
|
1125 | - $this->_active_status = EE_Datetime::inactive; |
|
1126 | - } |
|
1127 | - } |
|
1128 | - return $this->_active_status; |
|
1129 | - } |
|
1130 | - |
|
1131 | - |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * pretty_active_status |
|
1135 | - * |
|
1136 | - * @access public |
|
1137 | - * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
1138 | - * @return mixed void|string |
|
1139 | - */ |
|
1140 | - public function pretty_active_status($echo = true) |
|
1141 | - { |
|
1142 | - $active_status = $this->get_active_status(); |
|
1143 | - $status = '<span class="ee-status event-active-status-' |
|
1144 | - . $active_status |
|
1145 | - . '">' |
|
1146 | - . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1147 | - . '</span>'; |
|
1148 | - if ($echo) { |
|
1149 | - echo $status; |
|
1150 | - return ''; |
|
1151 | - } |
|
1152 | - return $status; |
|
1153 | - } |
|
1154 | - |
|
1155 | - |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * @return bool|int |
|
1159 | - */ |
|
1160 | - public function get_number_of_tickets_sold() |
|
1161 | - { |
|
1162 | - $tkt_sold = 0; |
|
1163 | - if ( ! $this->ID()) { |
|
1164 | - return 0; |
|
1165 | - } |
|
1166 | - $datetimes = $this->datetimes(); |
|
1167 | - foreach ($datetimes as $datetime) { |
|
1168 | - if ($datetime instanceof EE_Datetime) { |
|
1169 | - $tkt_sold += $datetime->sold(); |
|
1170 | - } |
|
1171 | - } |
|
1172 | - return $tkt_sold; |
|
1173 | - } |
|
1174 | - |
|
1175 | - |
|
1176 | - |
|
1177 | - /** |
|
1178 | - * This just returns a count of all the registrations for this event |
|
1179 | - * |
|
1180 | - * @access public |
|
1181 | - * @return int |
|
1182 | - */ |
|
1183 | - public function get_count_of_all_registrations() |
|
1184 | - { |
|
1185 | - return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1186 | - } |
|
1187 | - |
|
1188 | - |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * This returns the ticket with the earliest start time that is available for this event (across all datetimes |
|
1192 | - * attached to the event) |
|
1193 | - * |
|
1194 | - * @return EE_Ticket |
|
1195 | - */ |
|
1196 | - public function get_ticket_with_earliest_start_time() |
|
1197 | - { |
|
1198 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
1199 | - $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1200 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1201 | - } |
|
1202 | - |
|
1203 | - |
|
1204 | - |
|
1205 | - /** |
|
1206 | - * This returns the ticket with the latest end time that is available for this event (across all datetimes attached |
|
1207 | - * to the event) |
|
1208 | - * |
|
1209 | - * @return EE_Ticket |
|
1210 | - */ |
|
1211 | - public function get_ticket_with_latest_end_time() |
|
1212 | - { |
|
1213 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
1214 | - $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1215 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1216 | - } |
|
1217 | - |
|
1218 | - |
|
1219 | - |
|
1220 | - /** |
|
1221 | - * This returns whether there are any tickets on sale for this event. |
|
1222 | - * |
|
1223 | - * @return bool true = YES tickets on sale. |
|
1224 | - */ |
|
1225 | - public function tickets_on_sale() |
|
1226 | - { |
|
1227 | - $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
|
1228 | - $latest_ticket = $this->get_ticket_with_latest_end_time(); |
|
1229 | - if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1230 | - return false; |
|
1231 | - } |
|
1232 | - //check on sale for these two tickets. |
|
1233 | - if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1234 | - return true; |
|
1235 | - } |
|
1236 | - return false; |
|
1237 | - } |
|
1238 | - |
|
1239 | - |
|
1240 | - |
|
1241 | - /** |
|
1242 | - * Gets the URL for viewing this event on the front-end. Overrides parent |
|
1243 | - * to check for an external URL first |
|
1244 | - * |
|
1245 | - * @return string |
|
1246 | - */ |
|
1247 | - public function get_permalink() |
|
1248 | - { |
|
1249 | - if ($this->external_url()) { |
|
1250 | - return $this->external_url(); |
|
1251 | - } else { |
|
1252 | - return parent::get_permalink(); |
|
1253 | - } |
|
1254 | - } |
|
1255 | - |
|
1256 | - |
|
1257 | - |
|
1258 | - /** |
|
1259 | - * Gets the first term for 'espresso_event_categories' we can find |
|
1260 | - * |
|
1261 | - * @param array $query_params like EEM_Base::get_all |
|
1262 | - * @return EE_Term |
|
1263 | - */ |
|
1264 | - public function first_event_category($query_params = array()) |
|
1265 | - { |
|
1266 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1267 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1268 | - return EEM_Term::instance()->get_one($query_params); |
|
1269 | - } |
|
1270 | - |
|
1271 | - |
|
1272 | - |
|
1273 | - /** |
|
1274 | - * Gets all terms for 'espresso_event_categories' we can find |
|
1275 | - * |
|
1276 | - * @param array $query_params |
|
1277 | - * @return EE_Term[] |
|
1278 | - */ |
|
1279 | - public function get_all_event_categories($query_params = array()) |
|
1280 | - { |
|
1281 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1282 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1283 | - return EEM_Term::instance()->get_all($query_params); |
|
1284 | - } |
|
1285 | - |
|
1286 | - |
|
1287 | - |
|
1288 | - /** |
|
1289 | - * Gets all the question groups, ordering them by QSG_order ascending |
|
1290 | - * |
|
1291 | - * @param array $query_params @see EEM_Base::get_all |
|
1292 | - * @return EE_Question_Group[] |
|
1293 | - */ |
|
1294 | - public function question_groups($query_params = array()) |
|
1295 | - { |
|
1296 | - $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1297 | - return $this->get_many_related('Question_Group', $query_params); |
|
1298 | - } |
|
1299 | - |
|
1300 | - |
|
1301 | - |
|
1302 | - /** |
|
1303 | - * Implementation for EEI_Has_Icon interface method. |
|
1304 | - * |
|
1305 | - * @see EEI_Visual_Representation for comments |
|
1306 | - * @return string |
|
1307 | - */ |
|
1308 | - public function get_icon() |
|
1309 | - { |
|
1310 | - return '<span class="dashicons dashicons-flag"></span>'; |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - |
|
1315 | - /** |
|
1316 | - * Implementation for EEI_Admin_Links interface method. |
|
1317 | - * |
|
1318 | - * @see EEI_Admin_Links for comments |
|
1319 | - * @return string |
|
1320 | - */ |
|
1321 | - public function get_admin_details_link() |
|
1322 | - { |
|
1323 | - return $this->get_admin_edit_link(); |
|
1324 | - } |
|
1325 | - |
|
1326 | - |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * Implementation for EEI_Admin_Links interface method. |
|
1330 | - * |
|
1331 | - * @see EEI_Admin_Links for comments |
|
1332 | - * @return string |
|
1333 | - */ |
|
1334 | - public function get_admin_edit_link() |
|
1335 | - { |
|
1336 | - return EEH_URL::add_query_args_and_nonce(array( |
|
1337 | - 'page' => 'espresso_events', |
|
1338 | - 'action' => 'edit', |
|
1339 | - 'post' => $this->ID(), |
|
1340 | - ), |
|
1341 | - admin_url('admin.php') |
|
1342 | - ); |
|
1343 | - } |
|
1344 | - |
|
1345 | - |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * Implementation for EEI_Admin_Links interface method. |
|
1349 | - * |
|
1350 | - * @see EEI_Admin_Links for comments |
|
1351 | - * @return string |
|
1352 | - */ |
|
1353 | - public function get_admin_settings_link() |
|
1354 | - { |
|
1355 | - return EEH_URL::add_query_args_and_nonce(array( |
|
1356 | - 'page' => 'espresso_events', |
|
1357 | - 'action' => 'default_event_settings', |
|
1358 | - ), |
|
1359 | - admin_url('admin.php') |
|
1360 | - ); |
|
1361 | - } |
|
1362 | - |
|
1363 | - |
|
1364 | - |
|
1365 | - /** |
|
1366 | - * Implementation for EEI_Admin_Links interface method. |
|
1367 | - * |
|
1368 | - * @see EEI_Admin_Links for comments |
|
1369 | - * @return string |
|
1370 | - */ |
|
1371 | - public function get_admin_overview_link() |
|
1372 | - { |
|
1373 | - return EEH_URL::add_query_args_and_nonce(array( |
|
1374 | - 'page' => 'espresso_events', |
|
1375 | - 'action' => 'default' |
|
1376 | - ), |
|
1377 | - admin_url('admin.php') |
|
1378 | - ); |
|
1379 | - } |
|
608 | + |
|
609 | + /** |
|
610 | + * @param $default_registration_status |
|
611 | + */ |
|
612 | + public function set_default_registration_status($default_registration_status) |
|
613 | + { |
|
614 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + |
|
619 | + /** |
|
620 | + * @param $donations |
|
621 | + */ |
|
622 | + public function set_donations($donations) |
|
623 | + { |
|
624 | + $this->set('EVT_donations', $donations); |
|
625 | + } |
|
626 | + |
|
627 | + |
|
628 | + |
|
629 | + /** |
|
630 | + * Adds a venue to this event |
|
631 | + * |
|
632 | + * @param EE_Venue /int $venue_id_or_obj |
|
633 | + * @return EE_Venue |
|
634 | + */ |
|
635 | + public function add_venue($venue_id_or_obj) |
|
636 | + { |
|
637 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
638 | + } |
|
639 | + |
|
640 | + |
|
641 | + |
|
642 | + /** |
|
643 | + * Removes a venue from the event |
|
644 | + * |
|
645 | + * @param EE_Venue /int $venue_id_or_obj |
|
646 | + * @return EE_Venue |
|
647 | + */ |
|
648 | + public function remove_venue($venue_id_or_obj) |
|
649 | + { |
|
650 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + |
|
655 | + /** |
|
656 | + * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
657 | + * |
|
658 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
659 | + * @return EE_Venue[] |
|
660 | + */ |
|
661 | + public function venues($query_params = array()) |
|
662 | + { |
|
663 | + return $this->get_many_related('Venue', $query_params); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * check if event id is present and if event is published |
|
670 | + * |
|
671 | + * @access public |
|
672 | + * @return boolean true yes, false no |
|
673 | + */ |
|
674 | + private function _has_ID_and_is_published() |
|
675 | + { |
|
676 | + // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
|
677 | + return ($this->ID() && $this->ID() !== null |
|
678 | + && ($this->status() == 'publish' |
|
679 | + || $this->status() |
|
680 | + == EEM_Event::sold_out |
|
681 | + || $this->status() == EEM_Event::postponed |
|
682 | + || $this->status() == EEM_Event::cancelled)) ? true : false; |
|
683 | + } |
|
684 | + |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
689 | + * |
|
690 | + * @access public |
|
691 | + * @return boolean true yes, false no |
|
692 | + */ |
|
693 | + public function is_upcoming() |
|
694 | + { |
|
695 | + // check if event id is present and if this event is published |
|
696 | + if ($this->is_inactive()) { |
|
697 | + return false; |
|
698 | + } |
|
699 | + // set initial value |
|
700 | + $upcoming = false; |
|
701 | + //next let's get all datetimes and loop through them |
|
702 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
703 | + foreach ($datetimes as $datetime) { |
|
704 | + if ($datetime instanceof EE_Datetime) { |
|
705 | + //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
706 | + if ($datetime->is_expired()) { |
|
707 | + continue; |
|
708 | + } |
|
709 | + //if this dtt is active then we return false. |
|
710 | + if ($datetime->is_active()) { |
|
711 | + return false; |
|
712 | + } |
|
713 | + //otherwise let's check upcoming status |
|
714 | + $upcoming = $datetime->is_upcoming(); |
|
715 | + } |
|
716 | + } |
|
717 | + return $upcoming; |
|
718 | + } |
|
719 | + |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * @return bool |
|
724 | + */ |
|
725 | + public function is_active() |
|
726 | + { |
|
727 | + // check if event id is present and if this event is published |
|
728 | + if ($this->is_inactive()) { |
|
729 | + return false; |
|
730 | + } |
|
731 | + // set initial value |
|
732 | + $active = false; |
|
733 | + //next let's get all datetimes and loop through them |
|
734 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
735 | + foreach ($datetimes as $datetime) { |
|
736 | + if ($datetime instanceof EE_Datetime) { |
|
737 | + //if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
738 | + if ($datetime->is_expired()) { |
|
739 | + continue; |
|
740 | + } |
|
741 | + //if this dtt is upcoming then we return false. |
|
742 | + if ($datetime->is_upcoming()) { |
|
743 | + return false; |
|
744 | + } |
|
745 | + //otherwise let's check active status |
|
746 | + $active = $datetime->is_active(); |
|
747 | + } |
|
748 | + } |
|
749 | + return $active; |
|
750 | + } |
|
751 | + |
|
752 | + |
|
753 | + |
|
754 | + /** |
|
755 | + * @return bool |
|
756 | + */ |
|
757 | + public function is_expired() |
|
758 | + { |
|
759 | + // check if event id is present and if this event is published |
|
760 | + if ($this->is_inactive()) { |
|
761 | + return false; |
|
762 | + } |
|
763 | + // set initial value |
|
764 | + $expired = false; |
|
765 | + //first let's get all datetimes and loop through them |
|
766 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
767 | + foreach ($datetimes as $datetime) { |
|
768 | + if ($datetime instanceof EE_Datetime) { |
|
769 | + //if this dtt is upcoming or active then we return false. |
|
770 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
771 | + return false; |
|
772 | + } |
|
773 | + //otherwise let's check active status |
|
774 | + $expired = $datetime->is_expired(); |
|
775 | + } |
|
776 | + } |
|
777 | + return $expired; |
|
778 | + } |
|
779 | + |
|
780 | + |
|
781 | + |
|
782 | + /** |
|
783 | + * @return bool |
|
784 | + */ |
|
785 | + public function is_inactive() |
|
786 | + { |
|
787 | + // check if event id is present and if this event is published |
|
788 | + if ($this->_has_ID_and_is_published()) { |
|
789 | + return false; |
|
790 | + } |
|
791 | + return true; |
|
792 | + } |
|
793 | + |
|
794 | + |
|
795 | + |
|
796 | + /** |
|
797 | + * perform_sold_out_status_check |
|
798 | + * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
799 | + * available... if NOT, then the event status will get toggled to 'sold_out' |
|
800 | + * |
|
801 | + * @access public |
|
802 | + * @return bool return the ACTUAL sold out state. |
|
803 | + */ |
|
804 | + public function perform_sold_out_status_check() |
|
805 | + { |
|
806 | + // get all unexpired untrashed tickets |
|
807 | + $tickets = $this->tickets(array( |
|
808 | + array( |
|
809 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
810 | + 'TKT_deleted' => false, |
|
811 | + ), |
|
812 | + )); |
|
813 | + // if all the tickets are just expired, then don't update the event status to sold out |
|
814 | + if (empty($tickets)) { |
|
815 | + return true; |
|
816 | + } |
|
817 | + // set initial value |
|
818 | + $spaces_remaining = 0; |
|
819 | + foreach ($tickets as $ticket) { |
|
820 | + if ($ticket instanceof EE_Ticket) { |
|
821 | + $spaces_remaining += $ticket->qty('saleable'); |
|
822 | + } |
|
823 | + } |
|
824 | + if ($spaces_remaining === 0) { |
|
825 | + $this->set_status(EEM_Event::sold_out); |
|
826 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
827 | + $this->save(); |
|
828 | + } |
|
829 | + $sold_out = true; |
|
830 | + } else { |
|
831 | + $sold_out = false; |
|
832 | + // was event previously marked as sold out ? |
|
833 | + if ($this->status() == EEM_Event::sold_out) { |
|
834 | + // revert status to previous value, if it was set |
|
835 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
836 | + if ($previous_event_status) { |
|
837 | + $this->set_status($previous_event_status); |
|
838 | + } |
|
839 | + } |
|
840 | + } |
|
841 | + //note: I considered changing the EEM_Event status away from sold_out if this status check reveals that it's no longer sold out (yet the status is still set as sold out) but the problem is... what do we change the status BACK to? We can't always assume that the previous event status was 'published' because this status check is always done in the admin and its entirely possible the event admin manually changes to sold_out status from some other status. We also don't want a draft event to become a "publish event" because the sold out check reveals its NOT sold out. |
|
842 | + // So I'll forgo the automatic switch away from sold out status for now and instead just return the $sold out status... so this check can be used to validate the TRUE sold out status regardless of what the Event status is set to. |
|
843 | + return $sold_out; |
|
844 | + } |
|
845 | + |
|
846 | + |
|
847 | + |
|
848 | + /** |
|
849 | + * This returns the total remaining spaces for sale on this event. |
|
850 | + * ############################ |
|
851 | + * VERY IMPORTANT FOR DEVELOPERS: |
|
852 | + * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
853 | + * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
854 | + * ############################ |
|
855 | + * |
|
856 | + * @uses EE_Event::total_available_spaces() |
|
857 | + * @return float|int (EE_INF is returned as float) |
|
858 | + */ |
|
859 | + public function spaces_remaining_for_sale() |
|
860 | + { |
|
861 | + //first get total available spaces including consideration for tickets that have already sold. |
|
862 | + $spaces_available = $this->total_available_spaces(true); |
|
863 | + //if total available = 0, then exit right away because that means everything is expired. |
|
864 | + if ($spaces_available === 0) { |
|
865 | + return 0; |
|
866 | + } |
|
867 | + //subtract total approved registrations from spaces available to get how many are remaining. |
|
868 | + $spots_taken = EEM_Registration::instance()->count(array( |
|
869 | + array( |
|
870 | + 'EVT_ID' => $this->ID(), |
|
871 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
872 | + ), |
|
873 | + ), 'REG_ID', true); |
|
874 | + $spaces_remaining = $spaces_available - $spots_taken; |
|
875 | + return $spaces_remaining > 0 ? $spaces_remaining : 0; |
|
876 | + } |
|
877 | + |
|
878 | + |
|
879 | + |
|
880 | + /** |
|
881 | + * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg |
|
882 | + * limits on the datetimes attached to this event. |
|
883 | + * ############################ |
|
884 | + * VERY IMPORTANT FOR DEVELOPERS: |
|
885 | + * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
886 | + * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
887 | + * ############################ |
|
888 | + * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using |
|
889 | + * the value from this method and subtracting the approved registrations for the event. |
|
890 | + * |
|
891 | + * @param bool $current_total_available Whether to consider any tickets that have already sold in our |
|
892 | + * calculation. If this is false, then we return the most tickets that |
|
893 | + * could ever be sold for this event with the datetime and tickets |
|
894 | + * setup on the event under optimal selling conditions. Otherwise we |
|
895 | + * return a live calculation of spaces available based on tickets |
|
896 | + * sold. Depending on setup and stage of sales, this may appear to |
|
897 | + * equal remaining tickets. However, the more tickets are sold out, |
|
898 | + * the more accurate the "live" total is. |
|
899 | + * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
|
900 | + */ |
|
901 | + public function total_available_spaces($current_total_available = false) |
|
902 | + { |
|
903 | + $spaces_available = 0; |
|
904 | + //first get all tickets on the event and include expired tickets |
|
905 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
906 | + $ticket_sums = array(); |
|
907 | + $datetime_limits = array(); |
|
908 | + //loop through tickets and normalize them |
|
909 | + foreach ($tickets as $ticket) { |
|
910 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
911 | + if (empty($datetimes)) { |
|
912 | + continue; |
|
913 | + } |
|
914 | + //first datetime should be the lowest datetime |
|
915 | + $least_datetime = reset($datetimes); |
|
916 | + //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
|
917 | + //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
|
918 | + if ($current_total_available) { |
|
919 | + if ($ticket->is_remaining()) { |
|
920 | + $remaining = $ticket->remaining(); |
|
921 | + } else { |
|
922 | + $spaces_available += $ticket->sold(); |
|
923 | + //and we don't cache this ticket to our list because its sold out. |
|
924 | + continue; |
|
925 | + } |
|
926 | + } else { |
|
927 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
928 | + } |
|
929 | + //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
|
930 | + if ($remaining === EE_INF) { |
|
931 | + return EE_INF; |
|
932 | + } |
|
933 | + //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
|
934 | + //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
|
935 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
936 | + $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
|
937 | + foreach ($datetimes as $datetime) { |
|
938 | + if ($datetime->reg_limit() === EE_INF) { |
|
939 | + $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
|
940 | + } else { |
|
941 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available |
|
942 | + ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
943 | + } |
|
944 | + $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() |
|
945 | + : $datetime->reg_limit(); |
|
946 | + } |
|
947 | + $ticket_sums[$ticket->ID()]['ticket'] = $ticket; |
|
948 | + } |
|
949 | + //The order is sorted by lowest available first (which is calculated for each ticket by multiplying the normalized |
|
950 | + //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
|
951 | + //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
|
952 | + //$current_total_available ) for the datetimes on the ticket. |
|
953 | + usort($ticket_sums, function ($a, $b) { |
|
954 | + if ($a['sum'] == $b['sum']) { |
|
955 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
956 | + return 0; |
|
957 | + } |
|
958 | + return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
|
959 | + } |
|
960 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
961 | + }); |
|
962 | + //now let's loop through the sorted tickets and simulate sellouts |
|
963 | + foreach ($ticket_sums as $ticket_info) { |
|
964 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
965 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
966 | + //need to sort these $datetimes by remaining (only if $current_total_available) |
|
967 | + //setup datetimes for simulation |
|
968 | + $ticket_datetimes_remaining = array(); |
|
969 | + foreach ($datetimes as $datetime) { |
|
970 | + $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
|
971 | + $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
|
972 | + } |
|
973 | + usort($ticket_datetimes_remaining, function ($a, $b) { |
|
974 | + if ($a['rem'] == $b['rem']) { |
|
975 | + return 0; |
|
976 | + } |
|
977 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
978 | + }); |
|
979 | + //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
|
980 | + //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
|
981 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
982 | + //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
|
983 | + // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
|
984 | + // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
|
985 | + // to the next ticket. |
|
986 | + if ($current_total_available) { |
|
987 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
988 | + } else { |
|
989 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
990 | + } |
|
991 | + //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
|
992 | + //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
|
993 | + //available. |
|
994 | + if ($remaining === EE_INF) { |
|
995 | + $spaces_available += $ticket_info['ticket']->qty(); |
|
996 | + continue; |
|
997 | + } |
|
998 | + //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
|
999 | + if ($current_total_available) { |
|
1000 | + $spaces_available += $ticket_info['ticket']->sold(); |
|
1001 | + } |
|
1002 | + if ($remaining <= 0) { |
|
1003 | + continue; |
|
1004 | + } else { |
|
1005 | + $spaces_available += $remaining; |
|
1006 | + } |
|
1007 | + //loop through the datetimes and sell them out! |
|
1008 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
1009 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
1010 | + $datetime_limits[$datetime_info['datetime']->ID()] += -$remaining; |
|
1011 | + } |
|
1012 | + } |
|
1013 | + } |
|
1014 | + } |
|
1015 | + return $spaces_available; |
|
1016 | + } |
|
1017 | + |
|
1018 | + |
|
1019 | + |
|
1020 | + /** |
|
1021 | + * Checks if the event is set to sold out |
|
1022 | + * |
|
1023 | + * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to |
|
1024 | + * flip the status if necessary to sold out If false, we just check the existing status of the |
|
1025 | + * event |
|
1026 | + * @return boolean |
|
1027 | + */ |
|
1028 | + public function is_sold_out($actual = false) |
|
1029 | + { |
|
1030 | + if ( ! $actual) { |
|
1031 | + return $this->status() == EEM_Event::sold_out; |
|
1032 | + } else { |
|
1033 | + return $this->perform_sold_out_status_check(); |
|
1034 | + } |
|
1035 | + } |
|
1036 | + |
|
1037 | + |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * Checks if the event is marked as postponed |
|
1041 | + * |
|
1042 | + * @return boolean |
|
1043 | + */ |
|
1044 | + public function is_postponed() |
|
1045 | + { |
|
1046 | + return $this->status() == EEM_Event::postponed; |
|
1047 | + } |
|
1048 | + |
|
1049 | + |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * Checks if the event is marked as cancelled |
|
1053 | + * |
|
1054 | + * @return boolean |
|
1055 | + */ |
|
1056 | + public function is_cancelled() |
|
1057 | + { |
|
1058 | + return $this->status() == EEM_Event::cancelled; |
|
1059 | + } |
|
1060 | + |
|
1061 | + |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
1065 | + * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
1066 | + * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
1067 | + * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
1068 | + * the event is considered expired. |
|
1069 | + * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
1070 | + * status set on the EVENT when it is not published and thus is done |
|
1071 | + * |
|
1072 | + * @param bool $reset |
|
1073 | + * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
1074 | + */ |
|
1075 | + public function get_active_status($reset = false) |
|
1076 | + { |
|
1077 | + // if the active status has already been set, then just use that value (unless we are resetting it) |
|
1078 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
1079 | + return $this->_active_status; |
|
1080 | + } |
|
1081 | + //first check if event id is present on this object |
|
1082 | + if ( ! $this->ID()) { |
|
1083 | + return false; |
|
1084 | + } |
|
1085 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
1086 | + //if event is published: |
|
1087 | + if ($this->status() === 'publish') { |
|
1088 | + //active? |
|
1089 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) |
|
1090 | + > 0 |
|
1091 | + ) { |
|
1092 | + $this->_active_status = EE_Datetime::active; |
|
1093 | + } else { |
|
1094 | + //upcoming? |
|
1095 | + if (EEM_Datetime::instance() |
|
1096 | + ->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0 |
|
1097 | + ) { |
|
1098 | + $this->_active_status = EE_Datetime::upcoming; |
|
1099 | + } else { |
|
1100 | + //expired? |
|
1101 | + if (EEM_Datetime::instance() |
|
1102 | + ->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0 |
|
1103 | + ) { |
|
1104 | + $this->_active_status = EE_Datetime::expired; |
|
1105 | + } else { |
|
1106 | + //it would be odd if things make it this far because it basically means there are no datetime's |
|
1107 | + //attached to the event. So in this case it will just be considered inactive. |
|
1108 | + $this->_active_status = EE_Datetime::inactive; |
|
1109 | + } |
|
1110 | + } |
|
1111 | + } |
|
1112 | + } else { |
|
1113 | + //the event is not published, so let's just set it's active status according to its' post status |
|
1114 | + switch ($this->status()) { |
|
1115 | + case EEM_Event::sold_out : |
|
1116 | + $this->_active_status = EE_Datetime::sold_out; |
|
1117 | + break; |
|
1118 | + case EEM_Event::cancelled : |
|
1119 | + $this->_active_status = EE_Datetime::cancelled; |
|
1120 | + break; |
|
1121 | + case EEM_Event::postponed : |
|
1122 | + $this->_active_status = EE_Datetime::postponed; |
|
1123 | + break; |
|
1124 | + default : |
|
1125 | + $this->_active_status = EE_Datetime::inactive; |
|
1126 | + } |
|
1127 | + } |
|
1128 | + return $this->_active_status; |
|
1129 | + } |
|
1130 | + |
|
1131 | + |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * pretty_active_status |
|
1135 | + * |
|
1136 | + * @access public |
|
1137 | + * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
1138 | + * @return mixed void|string |
|
1139 | + */ |
|
1140 | + public function pretty_active_status($echo = true) |
|
1141 | + { |
|
1142 | + $active_status = $this->get_active_status(); |
|
1143 | + $status = '<span class="ee-status event-active-status-' |
|
1144 | + . $active_status |
|
1145 | + . '">' |
|
1146 | + . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1147 | + . '</span>'; |
|
1148 | + if ($echo) { |
|
1149 | + echo $status; |
|
1150 | + return ''; |
|
1151 | + } |
|
1152 | + return $status; |
|
1153 | + } |
|
1154 | + |
|
1155 | + |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * @return bool|int |
|
1159 | + */ |
|
1160 | + public function get_number_of_tickets_sold() |
|
1161 | + { |
|
1162 | + $tkt_sold = 0; |
|
1163 | + if ( ! $this->ID()) { |
|
1164 | + return 0; |
|
1165 | + } |
|
1166 | + $datetimes = $this->datetimes(); |
|
1167 | + foreach ($datetimes as $datetime) { |
|
1168 | + if ($datetime instanceof EE_Datetime) { |
|
1169 | + $tkt_sold += $datetime->sold(); |
|
1170 | + } |
|
1171 | + } |
|
1172 | + return $tkt_sold; |
|
1173 | + } |
|
1174 | + |
|
1175 | + |
|
1176 | + |
|
1177 | + /** |
|
1178 | + * This just returns a count of all the registrations for this event |
|
1179 | + * |
|
1180 | + * @access public |
|
1181 | + * @return int |
|
1182 | + */ |
|
1183 | + public function get_count_of_all_registrations() |
|
1184 | + { |
|
1185 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1186 | + } |
|
1187 | + |
|
1188 | + |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * This returns the ticket with the earliest start time that is available for this event (across all datetimes |
|
1192 | + * attached to the event) |
|
1193 | + * |
|
1194 | + * @return EE_Ticket |
|
1195 | + */ |
|
1196 | + public function get_ticket_with_earliest_start_time() |
|
1197 | + { |
|
1198 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1199 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1200 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1201 | + } |
|
1202 | + |
|
1203 | + |
|
1204 | + |
|
1205 | + /** |
|
1206 | + * This returns the ticket with the latest end time that is available for this event (across all datetimes attached |
|
1207 | + * to the event) |
|
1208 | + * |
|
1209 | + * @return EE_Ticket |
|
1210 | + */ |
|
1211 | + public function get_ticket_with_latest_end_time() |
|
1212 | + { |
|
1213 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1214 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1215 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1216 | + } |
|
1217 | + |
|
1218 | + |
|
1219 | + |
|
1220 | + /** |
|
1221 | + * This returns whether there are any tickets on sale for this event. |
|
1222 | + * |
|
1223 | + * @return bool true = YES tickets on sale. |
|
1224 | + */ |
|
1225 | + public function tickets_on_sale() |
|
1226 | + { |
|
1227 | + $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
|
1228 | + $latest_ticket = $this->get_ticket_with_latest_end_time(); |
|
1229 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1230 | + return false; |
|
1231 | + } |
|
1232 | + //check on sale for these two tickets. |
|
1233 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1234 | + return true; |
|
1235 | + } |
|
1236 | + return false; |
|
1237 | + } |
|
1238 | + |
|
1239 | + |
|
1240 | + |
|
1241 | + /** |
|
1242 | + * Gets the URL for viewing this event on the front-end. Overrides parent |
|
1243 | + * to check for an external URL first |
|
1244 | + * |
|
1245 | + * @return string |
|
1246 | + */ |
|
1247 | + public function get_permalink() |
|
1248 | + { |
|
1249 | + if ($this->external_url()) { |
|
1250 | + return $this->external_url(); |
|
1251 | + } else { |
|
1252 | + return parent::get_permalink(); |
|
1253 | + } |
|
1254 | + } |
|
1255 | + |
|
1256 | + |
|
1257 | + |
|
1258 | + /** |
|
1259 | + * Gets the first term for 'espresso_event_categories' we can find |
|
1260 | + * |
|
1261 | + * @param array $query_params like EEM_Base::get_all |
|
1262 | + * @return EE_Term |
|
1263 | + */ |
|
1264 | + public function first_event_category($query_params = array()) |
|
1265 | + { |
|
1266 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1267 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1268 | + return EEM_Term::instance()->get_one($query_params); |
|
1269 | + } |
|
1270 | + |
|
1271 | + |
|
1272 | + |
|
1273 | + /** |
|
1274 | + * Gets all terms for 'espresso_event_categories' we can find |
|
1275 | + * |
|
1276 | + * @param array $query_params |
|
1277 | + * @return EE_Term[] |
|
1278 | + */ |
|
1279 | + public function get_all_event_categories($query_params = array()) |
|
1280 | + { |
|
1281 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1282 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1283 | + return EEM_Term::instance()->get_all($query_params); |
|
1284 | + } |
|
1285 | + |
|
1286 | + |
|
1287 | + |
|
1288 | + /** |
|
1289 | + * Gets all the question groups, ordering them by QSG_order ascending |
|
1290 | + * |
|
1291 | + * @param array $query_params @see EEM_Base::get_all |
|
1292 | + * @return EE_Question_Group[] |
|
1293 | + */ |
|
1294 | + public function question_groups($query_params = array()) |
|
1295 | + { |
|
1296 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1297 | + return $this->get_many_related('Question_Group', $query_params); |
|
1298 | + } |
|
1299 | + |
|
1300 | + |
|
1301 | + |
|
1302 | + /** |
|
1303 | + * Implementation for EEI_Has_Icon interface method. |
|
1304 | + * |
|
1305 | + * @see EEI_Visual_Representation for comments |
|
1306 | + * @return string |
|
1307 | + */ |
|
1308 | + public function get_icon() |
|
1309 | + { |
|
1310 | + return '<span class="dashicons dashicons-flag"></span>'; |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + |
|
1315 | + /** |
|
1316 | + * Implementation for EEI_Admin_Links interface method. |
|
1317 | + * |
|
1318 | + * @see EEI_Admin_Links for comments |
|
1319 | + * @return string |
|
1320 | + */ |
|
1321 | + public function get_admin_details_link() |
|
1322 | + { |
|
1323 | + return $this->get_admin_edit_link(); |
|
1324 | + } |
|
1325 | + |
|
1326 | + |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * Implementation for EEI_Admin_Links interface method. |
|
1330 | + * |
|
1331 | + * @see EEI_Admin_Links for comments |
|
1332 | + * @return string |
|
1333 | + */ |
|
1334 | + public function get_admin_edit_link() |
|
1335 | + { |
|
1336 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1337 | + 'page' => 'espresso_events', |
|
1338 | + 'action' => 'edit', |
|
1339 | + 'post' => $this->ID(), |
|
1340 | + ), |
|
1341 | + admin_url('admin.php') |
|
1342 | + ); |
|
1343 | + } |
|
1344 | + |
|
1345 | + |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * Implementation for EEI_Admin_Links interface method. |
|
1349 | + * |
|
1350 | + * @see EEI_Admin_Links for comments |
|
1351 | + * @return string |
|
1352 | + */ |
|
1353 | + public function get_admin_settings_link() |
|
1354 | + { |
|
1355 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1356 | + 'page' => 'espresso_events', |
|
1357 | + 'action' => 'default_event_settings', |
|
1358 | + ), |
|
1359 | + admin_url('admin.php') |
|
1360 | + ); |
|
1361 | + } |
|
1362 | + |
|
1363 | + |
|
1364 | + |
|
1365 | + /** |
|
1366 | + * Implementation for EEI_Admin_Links interface method. |
|
1367 | + * |
|
1368 | + * @see EEI_Admin_Links for comments |
|
1369 | + * @return string |
|
1370 | + */ |
|
1371 | + public function get_admin_overview_link() |
|
1372 | + { |
|
1373 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1374 | + 'page' => 'espresso_events', |
|
1375 | + 'action' => 'default' |
|
1376 | + ), |
|
1377 | + admin_url('admin.php') |
|
1378 | + ); |
|
1379 | + } |
|
1380 | 1380 | |
1381 | 1381 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function display_ticket_selector() |
302 | 302 | { |
303 | - return (bool)$this->get('EVT_display_ticket_selector'); |
|
303 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
951 | 951 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
952 | 952 | //$current_total_available ) for the datetimes on the ticket. |
953 | - usort($ticket_sums, function ($a, $b) { |
|
953 | + usort($ticket_sums, function($a, $b) { |
|
954 | 954 | if ($a['sum'] == $b['sum']) { |
955 | 955 | if ($a['datetime_sums'] == $b['datetime_sums']) { |
956 | 956 | return 0; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
971 | 971 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
972 | 972 | } |
973 | - usort($ticket_datetimes_remaining, function ($a, $b) { |
|
973 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
974 | 974 | if ($a['rem'] == $b['rem']) { |
975 | 975 | return 0; |
976 | 976 | } |