1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* TicketControllerExtension.php |
4
|
|
|
* |
5
|
|
|
* @author Bram de Leeuw |
6
|
|
|
* Date: 09/03/17 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Broarm\EventTickets; |
10
|
|
|
|
11
|
|
|
use CalendarEvent_Controller; |
12
|
|
|
use Extension; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class TicketControllerExtension |
16
|
|
|
* |
17
|
|
|
* @package Broarm\EventTickets |
18
|
|
|
* |
19
|
|
|
* @property TicketControllerExtension|TicketExtension|CalendarEvent_Controller $owner |
20
|
|
|
*/ |
21
|
|
|
class TicketControllerExtension extends Extension |
22
|
|
|
{ |
23
|
|
|
private static $allowed_actions = array( |
|
|
|
|
24
|
|
|
'TicketForm', |
25
|
|
|
'WaitingListRegistrationForm', |
26
|
|
|
'checkin' |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Get the ticket form with available tickets |
31
|
|
|
* |
32
|
|
|
* @return TicketForm |
|
|
|
|
33
|
|
|
*/ |
34
|
|
|
public function TicketForm() |
35
|
|
|
{ |
36
|
|
|
if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) { |
37
|
|
|
$ticketForm = new TicketForm($this->owner, 'TicketForm', $this->owner->Tickets(), $this->owner->dataRecord); |
38
|
|
|
$ticketForm->setNextStep(CheckoutSteps::start()); |
39
|
|
|
return $ticketForm; |
40
|
|
|
} else { |
41
|
|
|
return null; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* show the waiting list form when the event is sold out |
47
|
|
|
* |
48
|
|
|
* @return WaitingListRegistrationForm |
|
|
|
|
49
|
|
|
*/ |
50
|
|
|
public function WaitingListRegistrationForm() |
51
|
|
|
{ |
52
|
|
|
if ( |
53
|
|
|
$this->owner->Tickets()->count() |
54
|
|
|
&& $this->owner->getTicketsSoldOut() |
55
|
|
|
&& !$this->owner->getEventExpired() |
56
|
|
|
) { |
57
|
|
|
return new WaitingListRegistrationForm($this->owner, 'WaitingListRegistrationForm'); |
58
|
|
|
} else { |
59
|
|
|
return null; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Go to the check in controller |
65
|
|
|
* |
66
|
|
|
* @return CheckInController |
67
|
|
|
*/ |
68
|
|
|
public function checkIn() |
69
|
|
|
{ |
70
|
|
|
return new CheckInController($this->owner->dataRecord); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Checks the waiting list var |
75
|
|
|
* |
76
|
|
|
* @return mixed |
77
|
|
|
*/ |
78
|
|
|
public function getWaitingListSuccess() |
79
|
|
|
{ |
80
|
|
|
return $this->owner->getRequest()->getVar('waitinglist'); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|