1 | <?php |
||
41 | class Ticket extends DataObject |
||
42 | { |
||
43 | /** |
||
44 | * The default sale start date |
||
45 | * This defaults to the event start date '-1 week' |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private static $sale_start_threshold = '-1 week'; |
||
50 | |||
51 | /** |
||
52 | * The default sale end date |
||
53 | * This defaults to the event start date time '-12 hours' |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private static $sale_end_threshold = '-12 hours'; |
||
58 | |||
59 | private static $db = array( |
||
|
|||
60 | 'Title' => 'Varchar(255)', |
||
61 | 'Price' => 'Currency', |
||
62 | 'AvailableFromDate' => 'SS_DateTime', |
||
63 | 'AvailableTillDate' => 'SS_DateTime', |
||
64 | 'OrderMin' => 'Int', |
||
65 | 'OrderMax' => 'Int', |
||
66 | 'Sort' => 'Int' |
||
67 | ); |
||
68 | |||
69 | private static $default_sort = 'Sort ASC, AvailableFromDate DESC'; |
||
70 | |||
71 | private static $has_one = array( |
||
72 | 'Event' => 'CalendarEvent' |
||
73 | ); |
||
74 | |||
75 | private static $defaults = array( |
||
76 | 'OrderMin' => 1, |
||
77 | 'OrderMax' => 5 |
||
78 | ); |
||
79 | |||
80 | private static $summary_fields = array( |
||
81 | 'Title' => 'Title', |
||
82 | 'Price.NiceDecimalPoint' => 'Price', |
||
83 | 'AvailableFrom' => 'Available from', |
||
84 | 'AvailableTill' => 'Available till', |
||
85 | 'AvailableSummary' => 'Available' |
||
86 | ); |
||
87 | |||
88 | private static $translate = array( |
||
89 | 'Title' |
||
90 | ); |
||
91 | |||
92 | public function getCMSFields() |
||
123 | |||
124 | /** |
||
125 | * Returns the singular name without the namespaces |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | public function singular_name() |
||
134 | |||
135 | /** |
||
136 | * Get the available form date if it is set, |
||
137 | * otherwise get it from the parent |
||
138 | * |
||
139 | * @return \SS_DateTime|Date|\DBField|null |
||
140 | */ |
||
141 | public function getAvailableFrom() |
||
153 | |||
154 | /** |
||
155 | * Get the available till date if it is set, |
||
156 | * otherwise get it from the parent |
||
157 | * Use the event start date as last sale possibility |
||
158 | * |
||
159 | * @return \SS_DateTime|Date|\DBField|null |
||
160 | */ |
||
161 | public function getAvailableTill() |
||
174 | |||
175 | /** |
||
176 | * Validate if the start and end date are in the past and the future |
||
177 | * todo check start time and treshhold |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | public function validateDate() |
||
194 | |||
195 | /** |
||
196 | * Validate the available capacity |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | private function validateAvailability() |
||
204 | |||
205 | /** |
||
206 | * Return if the ticket is available or not |
||
207 | * |
||
208 | * @return bool |
||
209 | */ |
||
210 | public function getAvailable() |
||
220 | |||
221 | /** |
||
222 | * Return availability for use in grid fields |
||
223 | * |
||
224 | * @return LiteralField |
||
225 | */ |
||
226 | public function getAvailableSummary() |
||
234 | |||
235 | /** |
||
236 | * Get the event start date |
||
237 | * |
||
238 | * @return Date |
||
239 | */ |
||
240 | private function getEventStartDate() |
||
253 | |||
254 | public function canView($member = null) |
||
258 | |||
259 | public function canEdit($member = null) |
||
263 | |||
264 | public function canDelete($member = null) |
||
268 | |||
269 | public function canCreate($member = null) |
||
273 | } |
||
274 |