@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | * Sets deleted |
1073 | 1073 | * |
1074 | 1074 | * @param boolean $deleted |
1075 | - * @return boolean |
|
1075 | + * @return boolean|null |
|
1076 | 1076 | */ |
1077 | 1077 | public function set_deleted($deleted) |
1078 | 1078 | { |
@@ -1125,6 +1125,7 @@ discard block |
||
1125 | 1125 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
1126 | 1126 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
1127 | 1127 | * consider registration status as well as datetime access. |
1128 | + * @param integer $DTT_OR_ID |
|
1128 | 1129 | * @return bool |
1129 | 1130 | */ |
1130 | 1131 | public function can_checkin($DTT_OR_ID, $check_approved = true) |
@@ -1278,7 +1279,7 @@ discard block |
||
1278 | 1279 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
1279 | 1280 | * "Latest" is defined by the `DTT_EVT_start` column. |
1280 | 1281 | * |
1281 | - * @return EE_Datetime|null |
|
1282 | + * @return null|EE_Base_Class |
|
1282 | 1283 | * @throws \EE_Error |
1283 | 1284 | */ |
1284 | 1285 | public function get_latest_related_datetime() |
@@ -1557,7 +1558,7 @@ discard block |
||
1557 | 1558 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
1558 | 1559 | * Note: if there are no payments on the registration there will be no payment method returned. |
1559 | 1560 | * |
1560 | - * @return EE_Payment_Method|null |
|
1561 | + * @return null|EE_Base_Class |
|
1561 | 1562 | */ |
1562 | 1563 | public function payment_method() |
1563 | 1564 | { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('No direct script access allowed'); |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -15,1691 +15,1691 @@ discard block |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Used to reference when a registration has never been checked in. |
|
20 | - * |
|
21 | - * @type int |
|
22 | - */ |
|
23 | - const checkin_status_never = 2; |
|
24 | - |
|
25 | - /** |
|
26 | - * Used to reference when a registration has been checked in. |
|
27 | - * |
|
28 | - * @type int |
|
29 | - */ |
|
30 | - const checkin_status_in = 1; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Used to reference when a registration has been checked out. |
|
35 | - * |
|
36 | - * @type int |
|
37 | - */ |
|
38 | - const checkin_status_out = 0; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * extra meta key for tracking reg status os trashed registrations |
|
43 | - * |
|
44 | - * @type string |
|
45 | - */ |
|
46 | - const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * extra meta key for tracking if registration has reserved ticket |
|
51 | - * |
|
52 | - * @type string |
|
53 | - */ |
|
54 | - const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @param array $props_n_values incoming values |
|
59 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | - * used.) |
|
61 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | - * date_format and the second value is the time format |
|
63 | - * @return EE_Registration |
|
64 | - */ |
|
65 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | - { |
|
67 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
68 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param array $props_n_values incoming values from the database |
|
74 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
75 | - * the website will be used. |
|
76 | - * @return EE_Registration |
|
77 | - */ |
|
78 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
79 | - { |
|
80 | - return new self($props_n_values, true, $timezone); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Set Event ID |
|
86 | - * |
|
87 | - * @param int $EVT_ID Event ID |
|
88 | - */ |
|
89 | - public function set_event($EVT_ID = 0) |
|
90 | - { |
|
91 | - $this->set('EVT_ID', $EVT_ID); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
97 | - * be routed to internal methods |
|
98 | - * |
|
99 | - * @param string $field_name |
|
100 | - * @param mixed $field_value |
|
101 | - * @param bool $use_default |
|
102 | - * @throws \EE_Error |
|
103 | - * @throws \RuntimeException |
|
104 | - */ |
|
105 | - public function set($field_name, $field_value, $use_default = false) |
|
106 | - { |
|
107 | - switch ($field_name) { |
|
108 | - case 'REG_code' : |
|
109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
110 | - $this->set_reg_code($field_value, $use_default); |
|
111 | - } |
|
112 | - break; |
|
113 | - case 'STS_ID' : |
|
114 | - $this->set_status($field_value, $use_default); |
|
115 | - break; |
|
116 | - default : |
|
117 | - parent::set($field_name, $field_value, $use_default); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Set Status ID |
|
124 | - * updates the registration status and ALSO... |
|
125 | - * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
126 | - * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
127 | - * |
|
128 | - * @param string $new_STS_ID |
|
129 | - * @param boolean $use_default |
|
130 | - * @return bool |
|
131 | - * @throws \RuntimeException |
|
132 | - * @throws \EE_Error |
|
133 | - */ |
|
134 | - public function set_status($new_STS_ID = null, $use_default = false) |
|
135 | - { |
|
136 | - // get current REG_Status |
|
137 | - $old_STS_ID = $this->status_ID(); |
|
138 | - // if status has changed |
|
139 | - if ( |
|
140 | - $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
141 | - && ! empty($old_STS_ID) // and that old status is actually set |
|
142 | - && ! empty($new_STS_ID) // as well as the new status |
|
143 | - && $this->ID() // ensure registration is in the db |
|
144 | - ) { |
|
145 | - // TO approved |
|
146 | - if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
147 | - // reserve a space by incrementing ticket and datetime sold values |
|
148 | - $this->_reserve_registration_space(); |
|
149 | - do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
150 | - // OR FROM approved |
|
151 | - } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
152 | - // release a space by decrementing ticket and datetime sold values |
|
153 | - $this->_release_registration_space(); |
|
154 | - do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
155 | - } |
|
156 | - // update status |
|
157 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
158 | - $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
159 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
160 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
161 | - $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
162 | - $this->transaction()->update_status_based_on_total_paid(true); |
|
163 | - do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
164 | - return true; |
|
165 | - } else { |
|
166 | - //even though the old value matches the new value, it's still good to |
|
167 | - //allow the parent set method to have a say |
|
168 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
169 | - return true; |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * update REGs and TXN when cancelled or declined registrations involved |
|
176 | - * |
|
177 | - * @param string $new_STS_ID |
|
178 | - * @param string $old_STS_ID |
|
179 | - * @throws \EE_Error |
|
180 | - */ |
|
181 | - private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
182 | - { |
|
183 | - // these reg statuses should not be considered in any calculations involving monies owing |
|
184 | - $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
185 | - // true if registration has been cancelled or declined |
|
186 | - if ( |
|
187 | - in_array($new_STS_ID, $closed_reg_statuses, true) |
|
188 | - && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
189 | - ) { |
|
190 | - /** @type EE_Registration_Processor $registration_processor */ |
|
191 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
192 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
193 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
194 | - // cancelled or declined registration |
|
195 | - $registration_processor->update_registration_after_being_canceled_or_declined( |
|
196 | - $this, |
|
197 | - $closed_reg_statuses |
|
198 | - ); |
|
199 | - $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
200 | - $this, |
|
201 | - $closed_reg_statuses, |
|
202 | - false |
|
203 | - ); |
|
204 | - do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
205 | - return; |
|
206 | - } |
|
207 | - // true if reinstating cancelled or declined registration |
|
208 | - if ( |
|
209 | - in_array($old_STS_ID, $closed_reg_statuses, true) |
|
210 | - && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
211 | - ) { |
|
212 | - /** @type EE_Registration_Processor $registration_processor */ |
|
213 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
214 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
215 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
216 | - // reinstating cancelled or declined registration |
|
217 | - $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
218 | - $this, |
|
219 | - $closed_reg_statuses |
|
220 | - ); |
|
221 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
222 | - $this, |
|
223 | - $closed_reg_statuses, |
|
224 | - false |
|
225 | - ); |
|
226 | - do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * get Status ID |
|
233 | - */ |
|
234 | - public function status_ID() |
|
235 | - { |
|
236 | - return $this->get('STS_ID'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * increments this registration's related ticket sold and corresponding datetime sold values |
|
242 | - * |
|
243 | - * @return void |
|
244 | - * @throws \EE_Error |
|
245 | - */ |
|
246 | - private function _reserve_registration_space() |
|
247 | - { |
|
248 | - // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
249 | - // so stop tracking that this reg has a ticket reserved |
|
250 | - $this->release_reserved_ticket(); |
|
251 | - $ticket = $this->ticket(); |
|
252 | - $ticket->increase_sold(); |
|
253 | - $ticket->save(); |
|
254 | - // possibly set event status to sold out |
|
255 | - $this->event()->perform_sold_out_status_check(); |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * Gets the ticket this registration is for |
|
261 | - * |
|
262 | - * @param boolean $include_archived whether to include archived tickets or not. |
|
263 | - * @return EE_Ticket|EE_Base_Class |
|
264 | - * @throws \EE_Error |
|
265 | - */ |
|
266 | - public function ticket($include_archived = true) |
|
267 | - { |
|
268 | - $query_params = array(); |
|
269 | - if ($include_archived) { |
|
270 | - $query_params['default_where_conditions'] = 'none'; |
|
271 | - } |
|
272 | - return $this->get_first_related('Ticket', $query_params); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * Gets the event this registration is for |
|
278 | - * |
|
279 | - * @return EE_Event |
|
280 | - */ |
|
281 | - public function event() |
|
282 | - { |
|
283 | - $event = $this->get_first_related('Event'); |
|
284 | - if (! $event instanceof \EE_Event) { |
|
285 | - throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
286 | - } |
|
287 | - return $event; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
293 | - * with the author of the event this registration is for. |
|
294 | - * |
|
295 | - * @since 4.5.0 |
|
296 | - * @return int |
|
297 | - */ |
|
298 | - public function wp_user() |
|
299 | - { |
|
300 | - $event = $this->event(); |
|
301 | - if ($event instanceof EE_Event) { |
|
302 | - return $event->wp_user(); |
|
303 | - } |
|
304 | - return 0; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
310 | - * |
|
311 | - * @return void |
|
312 | - * @throws \EE_Error |
|
313 | - */ |
|
314 | - private function _release_registration_space() |
|
315 | - { |
|
316 | - $ticket = $this->ticket(); |
|
317 | - $ticket->decrease_sold(); |
|
318 | - $ticket->save(); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * tracks this registration's ticket reservation in extra meta |
|
324 | - * and can increment related ticket reserved and corresponding datetime reserved values |
|
325 | - * |
|
326 | - * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
327 | - * @return void |
|
328 | - * @throws \EE_Error |
|
329 | - */ |
|
330 | - public function reserve_ticket($update_ticket = false) |
|
331 | - { |
|
332 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
333 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
334 | - // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
335 | - if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
336 | - $ticket = $this->ticket(); |
|
337 | - $ticket->increase_reserved(); |
|
338 | - $ticket->save(); |
|
339 | - } |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * stops tracking this registration's ticket reservation in extra meta |
|
346 | - * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
347 | - * |
|
348 | - * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
349 | - * @return void |
|
350 | - * @throws \EE_Error |
|
351 | - */ |
|
352 | - public function release_reserved_ticket($update_ticket = false) |
|
353 | - { |
|
354 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
355 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
356 | - // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
357 | - if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
358 | - $ticket = $this->ticket(); |
|
359 | - $ticket->decrease_reserved(); |
|
360 | - $ticket->save(); |
|
361 | - } |
|
362 | - } |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Set Attendee ID |
|
368 | - * |
|
369 | - * @param int $ATT_ID Attendee ID |
|
370 | - */ |
|
371 | - public function set_attendee_id($ATT_ID = 0) |
|
372 | - { |
|
373 | - $this->set('ATT_ID', $ATT_ID); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * Set Transaction ID |
|
379 | - * |
|
380 | - * @param int $TXN_ID Transaction ID |
|
381 | - */ |
|
382 | - public function set_transaction_id($TXN_ID = 0) |
|
383 | - { |
|
384 | - $this->set('TXN_ID', $TXN_ID); |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * Set Session |
|
390 | - * |
|
391 | - * @param string $REG_session PHP Session ID |
|
392 | - */ |
|
393 | - public function set_session($REG_session = '') |
|
394 | - { |
|
395 | - $this->set('REG_session', $REG_session); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - /** |
|
400 | - * Set Registration URL Link |
|
401 | - * |
|
402 | - * @param string $REG_url_link Registration URL Link |
|
403 | - */ |
|
404 | - public function set_reg_url_link($REG_url_link = '') |
|
405 | - { |
|
406 | - $this->set('REG_url_link', $REG_url_link); |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Set Attendee Counter |
|
412 | - * |
|
413 | - * @param int $REG_count Primary Attendee |
|
414 | - */ |
|
415 | - public function set_count($REG_count = 1) |
|
416 | - { |
|
417 | - $this->set('REG_count', $REG_count); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * Set Group Size |
|
423 | - * |
|
424 | - * @param boolean $REG_group_size Group Registration |
|
425 | - */ |
|
426 | - public function set_group_size($REG_group_size = false) |
|
427 | - { |
|
428 | - $this->set('REG_group_size', $REG_group_size); |
|
429 | - } |
|
430 | - |
|
431 | - |
|
432 | - /** |
|
433 | - * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
434 | - * EEM_Registration::status_id_not_approved |
|
435 | - * |
|
436 | - * @return boolean |
|
437 | - */ |
|
438 | - public function is_not_approved() |
|
439 | - { |
|
440 | - return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
446 | - * EEM_Registration::status_id_pending_payment |
|
447 | - * |
|
448 | - * @return boolean |
|
449 | - */ |
|
450 | - public function is_pending_payment() |
|
451 | - { |
|
452 | - return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - /** |
|
457 | - * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
458 | - * |
|
459 | - * @return boolean |
|
460 | - */ |
|
461 | - public function is_approved() |
|
462 | - { |
|
463 | - return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
469 | - * |
|
470 | - * @return boolean |
|
471 | - */ |
|
472 | - public function is_cancelled() |
|
473 | - { |
|
474 | - return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
480 | - * |
|
481 | - * @return boolean |
|
482 | - */ |
|
483 | - public function is_declined() |
|
484 | - { |
|
485 | - return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
491 | - * EEM_Registration::status_id_incomplete |
|
492 | - * |
|
493 | - * @return boolean |
|
494 | - */ |
|
495 | - public function is_incomplete() |
|
496 | - { |
|
497 | - return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
498 | - } |
|
499 | - |
|
500 | - |
|
501 | - /** |
|
502 | - * Set Registration Date |
|
503 | - * |
|
504 | - * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
505 | - * Date |
|
506 | - */ |
|
507 | - public function set_reg_date($REG_date = false) |
|
508 | - { |
|
509 | - $this->set('REG_date', $REG_date); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - /** |
|
514 | - * Set final price owing for this registration after all ticket/price modifications |
|
515 | - * |
|
516 | - * @access public |
|
517 | - * @param float $REG_final_price |
|
518 | - */ |
|
519 | - public function set_final_price($REG_final_price = 0.00) |
|
520 | - { |
|
521 | - $this->set('REG_final_price', $REG_final_price); |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * Set amount paid towards this registration's final price |
|
527 | - * |
|
528 | - * @access public |
|
529 | - * @param float $REG_paid |
|
530 | - */ |
|
531 | - public function set_paid($REG_paid = 0.00) |
|
532 | - { |
|
533 | - $this->set('REG_paid', $REG_paid); |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * Attendee Is Going |
|
539 | - * |
|
540 | - * @param boolean $REG_att_is_going Attendee Is Going |
|
541 | - */ |
|
542 | - public function set_att_is_going($REG_att_is_going = false) |
|
543 | - { |
|
544 | - $this->set('REG_att_is_going', $REG_att_is_going); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * Gets the related attendee |
|
550 | - * |
|
551 | - * @return EE_Attendee |
|
552 | - */ |
|
553 | - public function attendee() |
|
554 | - { |
|
555 | - return $this->get_first_related('Attendee'); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * get Event ID |
|
561 | - */ |
|
562 | - public function event_ID() |
|
563 | - { |
|
564 | - return $this->get('EVT_ID'); |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * get Event ID |
|
570 | - */ |
|
571 | - public function event_name() |
|
572 | - { |
|
573 | - $event = $this->event_obj(); |
|
574 | - if ($event) { |
|
575 | - return $event->name(); |
|
576 | - } else { |
|
577 | - return null; |
|
578 | - } |
|
579 | - } |
|
580 | - |
|
581 | - |
|
582 | - /** |
|
583 | - * Fetches the event this registration is for |
|
584 | - * |
|
585 | - * @return EE_Event |
|
586 | - */ |
|
587 | - public function event_obj() |
|
588 | - { |
|
589 | - return $this->get_first_related('Event'); |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * get Attendee ID |
|
595 | - */ |
|
596 | - public function attendee_ID() |
|
597 | - { |
|
598 | - return $this->get('ATT_ID'); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * get PHP Session ID |
|
604 | - */ |
|
605 | - public function session_ID() |
|
606 | - { |
|
607 | - return $this->get('REG_session'); |
|
608 | - } |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
613 | - * |
|
614 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
615 | - * @return string |
|
616 | - */ |
|
617 | - public function receipt_url($messenger = 'html') |
|
618 | - { |
|
619 | - |
|
620 | - /** |
|
621 | - * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
622 | - * |
|
623 | - * @since 4.5.0 |
|
624 | - */ |
|
625 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
626 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
627 | - |
|
628 | - if ($has_custom) { |
|
629 | - return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
630 | - } |
|
631 | - return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
637 | - * |
|
638 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
639 | - * @return string |
|
640 | - */ |
|
641 | - public function invoice_url($messenger = 'html') |
|
642 | - { |
|
643 | - /** |
|
644 | - * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
645 | - * |
|
646 | - * @since 4.5.0 |
|
647 | - */ |
|
648 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
649 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
650 | - |
|
651 | - if ($has_custom) { |
|
652 | - if ($messenger == 'html') { |
|
653 | - return $this->invoice_url('launch'); |
|
654 | - } |
|
655 | - $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
656 | - |
|
657 | - $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
658 | - if ($messenger == 'html') { |
|
659 | - $query_args['html'] = true; |
|
660 | - } |
|
661 | - return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
662 | - } |
|
663 | - return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - /** |
|
668 | - * get Registration URL Link |
|
669 | - * |
|
670 | - * @access public |
|
671 | - * @return string |
|
672 | - * @throws \EE_Error |
|
673 | - */ |
|
674 | - public function reg_url_link() |
|
675 | - { |
|
676 | - return (string)$this->get('REG_url_link'); |
|
677 | - } |
|
678 | - |
|
679 | - |
|
680 | - /** |
|
681 | - * Echoes out invoice_url() |
|
682 | - * |
|
683 | - * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
684 | - * @return void |
|
685 | - */ |
|
686 | - public function e_invoice_url($type = 'launch') |
|
687 | - { |
|
688 | - echo $this->invoice_url($type); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * Echoes out payment_overview_url |
|
694 | - */ |
|
695 | - public function e_payment_overview_url() |
|
696 | - { |
|
697 | - echo $this->payment_overview_url(); |
|
698 | - } |
|
699 | - |
|
700 | - |
|
701 | - /** |
|
702 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
703 | - * a query parameter |
|
704 | - * |
|
705 | - * @return string |
|
706 | - */ |
|
707 | - public function payment_overview_url() |
|
708 | - { |
|
709 | - return add_query_arg(array( |
|
710 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
711 | - 'step' => 'payment_options', |
|
712 | - 'revisit' => true, |
|
713 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
714 | - } |
|
715 | - |
|
716 | - |
|
717 | - /** |
|
718 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
719 | - * a query parameter |
|
720 | - * |
|
721 | - * @return string |
|
722 | - */ |
|
723 | - public function edit_attendee_information_url() |
|
724 | - { |
|
725 | - return add_query_arg(array( |
|
726 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
727 | - 'step' => 'attendee_information', |
|
728 | - 'revisit' => true, |
|
729 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
730 | - } |
|
731 | - |
|
732 | - |
|
733 | - /** |
|
734 | - * Simply generates and returns the appropriate admin_url link to edit this registration |
|
735 | - * |
|
736 | - * @return string |
|
737 | - */ |
|
738 | - public function get_admin_edit_url() |
|
739 | - { |
|
740 | - return EEH_URL::add_query_args_and_nonce(array( |
|
741 | - 'page' => 'espresso_registrations', |
|
742 | - 'action' => 'view_registration', |
|
743 | - '_REG_ID' => $this->ID(), |
|
744 | - ), admin_url('admin.php')); |
|
745 | - } |
|
746 | - |
|
747 | - |
|
748 | - /** |
|
749 | - * is_primary_registrant? |
|
750 | - */ |
|
751 | - public function is_primary_registrant() |
|
752 | - { |
|
753 | - return $this->get('REG_count') == 1 ? true : false; |
|
754 | - } |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * This returns the primary registration object for this registration group (which may be this object). |
|
759 | - * |
|
760 | - * @return EE_Registration |
|
761 | - */ |
|
762 | - public function get_primary_registration() |
|
763 | - { |
|
764 | - if ($this->is_primary_registrant()) { |
|
765 | - return $this; |
|
766 | - } |
|
767 | - |
|
768 | - //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
769 | - $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
770 | - array( |
|
771 | - 'TXN_ID' => $this->transaction_ID(), |
|
772 | - 'REG_count' => 1, |
|
773 | - ), |
|
774 | - )); |
|
775 | - return $primary_registrant; |
|
776 | - } |
|
777 | - |
|
778 | - |
|
779 | - /** |
|
780 | - * get Attendee Number |
|
781 | - * |
|
782 | - * @access public |
|
783 | - */ |
|
784 | - public function count() |
|
785 | - { |
|
786 | - return $this->get('REG_count'); |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - /** |
|
791 | - * get Group Size |
|
792 | - */ |
|
793 | - public function group_size() |
|
794 | - { |
|
795 | - return $this->get('REG_group_size'); |
|
796 | - } |
|
797 | - |
|
798 | - |
|
799 | - /** |
|
800 | - * get Registration Date |
|
801 | - */ |
|
802 | - public function date() |
|
803 | - { |
|
804 | - return $this->get('REG_date'); |
|
805 | - } |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * gets a pretty date |
|
810 | - * |
|
811 | - * @param string $date_format |
|
812 | - * @param string $time_format |
|
813 | - * @return string |
|
814 | - */ |
|
815 | - public function pretty_date($date_format = null, $time_format = null) |
|
816 | - { |
|
817 | - return $this->get_datetime('REG_date', $date_format, $time_format); |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - /** |
|
822 | - * final_price |
|
823 | - * the registration's share of the transaction total, so that the |
|
824 | - * sum of all the transaction's REG_final_prices equal the transaction's total |
|
825 | - * |
|
826 | - * @return float |
|
827 | - */ |
|
828 | - public function final_price() |
|
829 | - { |
|
830 | - return $this->get('REG_final_price'); |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * pretty_final_price |
|
836 | - * final price as formatted string, with correct decimal places and currency symbol |
|
837 | - * |
|
838 | - * @return string |
|
839 | - */ |
|
840 | - public function pretty_final_price() |
|
841 | - { |
|
842 | - return $this->get_pretty('REG_final_price'); |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * get paid (yeah) |
|
848 | - * |
|
849 | - * @return float |
|
850 | - */ |
|
851 | - public function paid() |
|
852 | - { |
|
853 | - return $this->get('REG_paid'); |
|
854 | - } |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * pretty_paid |
|
859 | - * |
|
860 | - * @return float |
|
861 | - */ |
|
862 | - public function pretty_paid() |
|
863 | - { |
|
864 | - return $this->get_pretty('REG_paid'); |
|
865 | - } |
|
866 | - |
|
867 | - |
|
868 | - /** |
|
869 | - * owes_monies_and_can_pay |
|
870 | - * whether or not this registration has monies owing and it's' status allows payment |
|
871 | - * |
|
872 | - * @param array $requires_payment |
|
873 | - * @return bool |
|
874 | - */ |
|
875 | - public function owes_monies_and_can_pay($requires_payment = array()) |
|
876 | - { |
|
877 | - // these reg statuses require payment (if event is not free) |
|
878 | - $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
879 | - if ( |
|
880 | - in_array($this->status_ID(), $requires_payment) && |
|
881 | - $this->final_price() != 0 && |
|
882 | - $this->final_price() != $this->paid() |
|
883 | - ) { |
|
884 | - return true; |
|
885 | - } else { |
|
886 | - return false; |
|
887 | - } |
|
888 | - } |
|
889 | - |
|
890 | - |
|
891 | - /** |
|
892 | - * Prints out the return value of $this->pretty_status() |
|
893 | - * |
|
894 | - * @param bool $show_icons |
|
895 | - * @return void |
|
896 | - */ |
|
897 | - public function e_pretty_status($show_icons = false) |
|
898 | - { |
|
899 | - echo $this->pretty_status($show_icons); |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - /** |
|
904 | - * Returns a nice version of the status for displaying to customers |
|
905 | - * |
|
906 | - * @param bool $show_icons |
|
907 | - * @return string |
|
908 | - */ |
|
909 | - public function pretty_status($show_icons = false) |
|
910 | - { |
|
911 | - $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
912 | - false, 'sentence'); |
|
913 | - $icon = ''; |
|
914 | - switch ($this->status_ID()) { |
|
915 | - case EEM_Registration::status_id_approved: |
|
916 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
917 | - break; |
|
918 | - case EEM_Registration::status_id_pending_payment: |
|
919 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
920 | - break; |
|
921 | - case EEM_Registration::status_id_not_approved: |
|
922 | - $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
923 | - break; |
|
924 | - case EEM_Registration::status_id_cancelled: |
|
925 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
926 | - break; |
|
927 | - case EEM_Registration::status_id_incomplete: |
|
928 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
929 | - break; |
|
930 | - case EEM_Registration::status_id_declined: |
|
931 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
932 | - break; |
|
933 | - case EEM_Registration::status_id_wait_list: |
|
934 | - $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
935 | - break; |
|
936 | - } |
|
937 | - return $icon . $status[$this->status_ID()]; |
|
938 | - } |
|
939 | - |
|
940 | - |
|
941 | - /** |
|
942 | - * get Attendee Is Going |
|
943 | - */ |
|
944 | - public function att_is_going() |
|
945 | - { |
|
946 | - return $this->get('REG_att_is_going'); |
|
947 | - } |
|
948 | - |
|
949 | - |
|
950 | - /** |
|
951 | - * Gets related answers |
|
952 | - * |
|
953 | - * @param array $query_params like EEM_Base::get_all |
|
954 | - * @return EE_Answer[] |
|
955 | - */ |
|
956 | - public function answers($query_params = null) |
|
957 | - { |
|
958 | - return $this->get_many_related('Answer', $query_params); |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - /** |
|
963 | - * Gets the registration's answer value to the specified question |
|
964 | - * (either the question's ID or a question object) |
|
965 | - * |
|
966 | - * @param EE_Question|int $question |
|
967 | - * @param bool $pretty_value |
|
968 | - * @return array|string if pretty_value= true, the result will always be a string |
|
969 | - * (because the answer might be an array of answer values, so passing pretty_value=true |
|
970 | - * will convert it into some kind of string) |
|
971 | - */ |
|
972 | - public function answer_value_to_question($question, $pretty_value = true) |
|
973 | - { |
|
974 | - $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
975 | - return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
976 | - } |
|
977 | - |
|
978 | - |
|
979 | - /** |
|
980 | - * question_groups |
|
981 | - * returns an array of EE_Question_Group objects for this registration |
|
982 | - * |
|
983 | - * @return EE_Question_Group[] |
|
984 | - */ |
|
985 | - public function question_groups() |
|
986 | - { |
|
987 | - $question_groups = array(); |
|
988 | - if ($this->event() instanceof EE_Event) { |
|
989 | - $question_groups = $this->event()->question_groups( |
|
990 | - array( |
|
991 | - array( |
|
992 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
993 | - ), |
|
994 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
995 | - ) |
|
996 | - ); |
|
997 | - } |
|
998 | - return $question_groups; |
|
999 | - } |
|
1000 | - |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * count_question_groups |
|
1004 | - * returns a count of the number of EE_Question_Group objects for this registration |
|
1005 | - * |
|
1006 | - * @return int |
|
1007 | - */ |
|
1008 | - public function count_question_groups() |
|
1009 | - { |
|
1010 | - $qg_count = 0; |
|
1011 | - if ($this->event() instanceof EE_Event) { |
|
1012 | - $qg_count = $this->event()->count_related( |
|
1013 | - 'Question_Group', |
|
1014 | - array( |
|
1015 | - array( |
|
1016 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
1017 | - ), |
|
1018 | - ) |
|
1019 | - ); |
|
1020 | - } |
|
1021 | - return $qg_count; |
|
1022 | - } |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * Returns the registration date in the 'standard' string format |
|
1027 | - * (function may be improved in the future to allow for different formats and timezones) |
|
1028 | - * |
|
1029 | - * @return string |
|
1030 | - */ |
|
1031 | - public function reg_date() |
|
1032 | - { |
|
1033 | - return $this->get_datetime('REG_date'); |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - /** |
|
1038 | - * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
1039 | - * the ticket this registration purchased, or the datetime they have registered |
|
1040 | - * to attend) |
|
1041 | - * |
|
1042 | - * @return EE_Datetime_Ticket |
|
1043 | - */ |
|
1044 | - public function datetime_ticket() |
|
1045 | - { |
|
1046 | - return $this->get_first_related('Datetime_Ticket'); |
|
1047 | - } |
|
1048 | - |
|
1049 | - |
|
1050 | - /** |
|
1051 | - * Sets the registration's datetime_ticket. |
|
1052 | - * |
|
1053 | - * @param EE_Datetime_Ticket $datetime_ticket |
|
1054 | - * @return EE_Datetime_Ticket |
|
1055 | - */ |
|
1056 | - public function set_datetime_ticket($datetime_ticket) |
|
1057 | - { |
|
1058 | - return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
1059 | - } |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * Gets deleted |
|
1063 | - * |
|
1064 | - * @return boolean |
|
1065 | - */ |
|
1066 | - public function deleted() |
|
1067 | - { |
|
1068 | - return $this->get('REG_deleted'); |
|
1069 | - } |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * Sets deleted |
|
1073 | - * |
|
1074 | - * @param boolean $deleted |
|
1075 | - * @return boolean |
|
1076 | - */ |
|
1077 | - public function set_deleted($deleted) |
|
1078 | - { |
|
1079 | - if ($deleted) { |
|
1080 | - $this->delete(); |
|
1081 | - } else { |
|
1082 | - $this->restore(); |
|
1083 | - } |
|
1084 | - } |
|
1085 | - |
|
1086 | - |
|
1087 | - /** |
|
1088 | - * Get the status object of this object |
|
1089 | - * |
|
1090 | - * @return EE_Status |
|
1091 | - */ |
|
1092 | - public function status_obj() |
|
1093 | - { |
|
1094 | - return $this->get_first_related('Status'); |
|
1095 | - } |
|
1096 | - |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * Returns the number of times this registration has checked into any of the datetimes |
|
1100 | - * its available for |
|
1101 | - * |
|
1102 | - * @return int |
|
1103 | - */ |
|
1104 | - public function count_checkins() |
|
1105 | - { |
|
1106 | - return $this->get_model()->count_related($this, 'Checkin'); |
|
1107 | - } |
|
1108 | - |
|
1109 | - |
|
1110 | - /** |
|
1111 | - * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
1112 | - * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
1113 | - * |
|
1114 | - * @return int |
|
1115 | - */ |
|
1116 | - public function count_checkins_not_checkedout() |
|
1117 | - { |
|
1118 | - return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
1119 | - } |
|
1120 | - |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
1124 | - * |
|
1125 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1126 | - * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
1127 | - * consider registration status as well as datetime access. |
|
1128 | - * @return bool |
|
1129 | - */ |
|
1130 | - public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
1131 | - { |
|
1132 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1133 | - |
|
1134 | - //first check registration status |
|
1135 | - if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1136 | - return false; |
|
1137 | - } |
|
1138 | - //is there a datetime ticket that matches this dtt_ID? |
|
1139 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1140 | - array( |
|
1141 | - 'TKT_ID' => $this->get('TKT_ID'), |
|
1142 | - 'DTT_ID' => $DTT_ID, |
|
1143 | - ), |
|
1144 | - ))) |
|
1145 | - ) { |
|
1146 | - return false; |
|
1147 | - } |
|
1148 | - |
|
1149 | - //final check is against TKT_uses |
|
1150 | - return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1151 | - } |
|
1152 | - |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
1156 | - * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
1157 | - * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
1158 | - * then return false. Otherwise return true. |
|
1159 | - * |
|
1160 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1161 | - * @return bool true means can checkin. false means cannot checkin. |
|
1162 | - */ |
|
1163 | - public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
1164 | - { |
|
1165 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1166 | - |
|
1167 | - if (! $DTT_ID) { |
|
1168 | - return false; |
|
1169 | - } |
|
1170 | - |
|
1171 | - $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
1172 | - |
|
1173 | - // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
1174 | - // or not. |
|
1175 | - if (! $max_uses || $max_uses === EE_INF) { |
|
1176 | - return true; |
|
1177 | - } |
|
1178 | - |
|
1179 | - //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
1180 | - //go ahead and toggle. |
|
1181 | - if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1182 | - return true; |
|
1183 | - } |
|
1184 | - |
|
1185 | - //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
1186 | - //disallows further check-ins. |
|
1187 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
1188 | - array( |
|
1189 | - 'REG_ID' => $this->ID(), |
|
1190 | - 'CHK_in' => true, |
|
1191 | - ), |
|
1192 | - ), 'DTT_ID', true); |
|
1193 | - // checkins have already reached their max number of uses |
|
1194 | - // so registrant can NOT checkin |
|
1195 | - if ($count_unique_dtt_checkins >= $max_uses) { |
|
1196 | - EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
1197 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1198 | - return false; |
|
1199 | - } |
|
1200 | - return true; |
|
1201 | - } |
|
1202 | - |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * toggle Check-in status for this registration |
|
1206 | - * Check-ins are toggled in the following order: |
|
1207 | - * never checked in -> checked in |
|
1208 | - * checked in -> checked out |
|
1209 | - * checked out -> checked in |
|
1210 | - * |
|
1211 | - * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1212 | - * If not included or null, then it is assumed latest datetime is being toggled. |
|
1213 | - * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1214 | - * can be checked in or not. Otherwise this forces change in checkin status. |
|
1215 | - * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1216 | - * @throws EE_Error |
|
1217 | - */ |
|
1218 | - public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
1219 | - { |
|
1220 | - if (empty($DTT_ID)) { |
|
1221 | - $datetime = $this->get_latest_related_datetime(); |
|
1222 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
1223 | - // verify the registration can checkin for the given DTT_ID |
|
1224 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
1225 | - EE_Error::add_error( |
|
1226 | - sprintf( |
|
1227 | - __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
1228 | - 'event_espresso'), |
|
1229 | - $this->ID(), |
|
1230 | - $DTT_ID |
|
1231 | - ), |
|
1232 | - __FILE__, __FUNCTION__, __LINE__ |
|
1233 | - ); |
|
1234 | - return false; |
|
1235 | - } |
|
1236 | - $status_paths = array( |
|
1237 | - EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
1238 | - EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
1239 | - EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
1240 | - ); |
|
1241 | - //start by getting the current status so we know what status we'll be changing to. |
|
1242 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
1243 | - $status_to = $status_paths[$cur_status]; |
|
1244 | - // database only records true for checked IN or false for checked OUT |
|
1245 | - // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
1246 | - $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
1247 | - // add relation - note Check-ins are always creating new rows |
|
1248 | - // because we are keeping track of Check-ins over time. |
|
1249 | - // Eventually we'll probably want to show a list table |
|
1250 | - // for the individual Check-ins so that they can be managed. |
|
1251 | - $checkin = EE_Checkin::new_instance(array( |
|
1252 | - 'REG_ID' => $this->ID(), |
|
1253 | - 'DTT_ID' => $DTT_ID, |
|
1254 | - 'CHK_in' => $new_status, |
|
1255 | - )); |
|
1256 | - // if the record could not be saved then return false |
|
1257 | - if ($checkin->save() === 0) { |
|
1258 | - if (WP_DEBUG) { |
|
1259 | - global $wpdb; |
|
1260 | - $error = sprintf( |
|
1261 | - __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
1262 | - 'event_espresso'), |
|
1263 | - '<br />', |
|
1264 | - $wpdb->last_error |
|
1265 | - ); |
|
1266 | - } else { |
|
1267 | - $error = __('Registration check in update failed because of an unknown database error', |
|
1268 | - 'event_espresso'); |
|
1269 | - } |
|
1270 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1271 | - return false; |
|
1272 | - } |
|
1273 | - return $status_to; |
|
1274 | - } |
|
1275 | - |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1279 | - * "Latest" is defined by the `DTT_EVT_start` column. |
|
1280 | - * |
|
1281 | - * @return EE_Datetime|null |
|
1282 | - * @throws \EE_Error |
|
1283 | - */ |
|
1284 | - public function get_latest_related_datetime() |
|
1285 | - { |
|
1286 | - return EEM_Datetime::instance()->get_one( |
|
1287 | - array( |
|
1288 | - array( |
|
1289 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1290 | - ), |
|
1291 | - 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
1292 | - ) |
|
1293 | - ); |
|
1294 | - } |
|
1295 | - |
|
1296 | - |
|
1297 | - /** |
|
1298 | - * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1299 | - * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1300 | - * |
|
1301 | - * @throws \EE_Error |
|
1302 | - */ |
|
1303 | - public function get_earliest_related_datetime() |
|
1304 | - { |
|
1305 | - return EEM_Datetime::instance()->get_one( |
|
1306 | - array( |
|
1307 | - array( |
|
1308 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1309 | - ), |
|
1310 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
1311 | - ) |
|
1312 | - ); |
|
1313 | - } |
|
1314 | - |
|
1315 | - |
|
1316 | - /** |
|
1317 | - * This method simply returns the check-in status for this registration and the given datetime. |
|
1318 | - * If neither the datetime nor the checkin values are provided as arguments, |
|
1319 | - * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1320 | - * |
|
1321 | - * @param int $DTT_ID The ID of the datetime we're checking against |
|
1322 | - * (if empty we'll get the primary datetime for |
|
1323 | - * this registration (via event) and use it's ID); |
|
1324 | - * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1325 | - * @return int Integer representing Check-in status. |
|
1326 | - * @throws \EE_Error |
|
1327 | - */ |
|
1328 | - public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
1329 | - { |
|
1330 | - $checkin_query_params = array( |
|
1331 | - 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
1332 | - ); |
|
1333 | - |
|
1334 | - if ($DTT_ID > 0) { |
|
1335 | - $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1336 | - } |
|
1337 | - |
|
1338 | - //get checkin object (if exists) |
|
1339 | - $checkin = $checkin instanceof EE_Checkin |
|
1340 | - ? $checkin |
|
1341 | - : $this->get_first_related('Checkin', $checkin_query_params); |
|
1342 | - if ($checkin instanceof EE_Checkin) { |
|
1343 | - if ($checkin->get('CHK_in')) { |
|
1344 | - return EE_Registration::checkin_status_in; //checked in |
|
1345 | - } |
|
1346 | - return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
1347 | - } |
|
1348 | - return EE_Registration::checkin_status_never; //never been checked in |
|
1349 | - } |
|
1350 | - |
|
1351 | - |
|
1352 | - /** |
|
1353 | - * This method returns a localized message for the toggled Check-in message. |
|
1354 | - * |
|
1355 | - * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
1356 | - * then it is assumed Check-in for primary datetime was toggled. |
|
1357 | - * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
1358 | - * message can be customized with the attendee name. |
|
1359 | - * @return string internationalized message |
|
1360 | - */ |
|
1361 | - public function get_checkin_msg($DTT_ID, $error = false) |
|
1362 | - { |
|
1363 | - //let's get the attendee first so we can include the name of the attendee |
|
1364 | - $attendee = $this->get_first_related('Attendee'); |
|
1365 | - if ($attendee instanceof EE_Attendee) { |
|
1366 | - if ($error) { |
|
1367 | - return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1368 | - } |
|
1369 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1370 | - //what is the status message going to be? |
|
1371 | - switch ($cur_status) { |
|
1372 | - case EE_Registration::checkin_status_never : |
|
1373 | - return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
1374 | - $attendee->full_name()); |
|
1375 | - break; |
|
1376 | - case EE_Registration::checkin_status_in : |
|
1377 | - return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1378 | - break; |
|
1379 | - case EE_Registration::checkin_status_out : |
|
1380 | - return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1381 | - break; |
|
1382 | - } |
|
1383 | - } |
|
1384 | - return __("The check-in status could not be determined.", "event_espresso"); |
|
1385 | - } |
|
1386 | - |
|
1387 | - |
|
1388 | - /** |
|
1389 | - * Returns the related EE_Transaction to this registration |
|
1390 | - * |
|
1391 | - * @return EE_Transaction |
|
1392 | - */ |
|
1393 | - public function transaction() |
|
1394 | - { |
|
1395 | - $transaction = $this->get_first_related('Transaction'); |
|
1396 | - if (! $transaction instanceof \EE_Transaction) { |
|
1397 | - throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
1398 | - } |
|
1399 | - return $transaction; |
|
1400 | - } |
|
1401 | - |
|
1402 | - |
|
1403 | - /** |
|
1404 | - * get Registration Code |
|
1405 | - */ |
|
1406 | - public function reg_code() |
|
1407 | - { |
|
1408 | - return $this->get('REG_code'); |
|
1409 | - } |
|
1410 | - |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * get Transaction ID |
|
1414 | - */ |
|
1415 | - public function transaction_ID() |
|
1416 | - { |
|
1417 | - return $this->get('TXN_ID'); |
|
1418 | - } |
|
1419 | - |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * @return int |
|
1423 | - */ |
|
1424 | - public function ticket_ID() |
|
1425 | - { |
|
1426 | - return $this->get('TKT_ID'); |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * Set Registration Code |
|
1432 | - * |
|
1433 | - * @access public |
|
1434 | - * @param string $REG_code Registration Code |
|
1435 | - * @param boolean $use_default |
|
1436 | - */ |
|
1437 | - public function set_reg_code($REG_code, $use_default = false) |
|
1438 | - { |
|
1439 | - if (empty($REG_code)) { |
|
1440 | - EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1441 | - return; |
|
1442 | - } |
|
1443 | - if (! $this->reg_code()) { |
|
1444 | - parent::set('REG_code', $REG_code, $use_default); |
|
1445 | - } else { |
|
1446 | - EE_Error::doing_it_wrong( |
|
1447 | - __CLASS__ . '::' . __FUNCTION__, |
|
1448 | - __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1449 | - '4.6.0' |
|
1450 | - ); |
|
1451 | - } |
|
1452 | - } |
|
1453 | - |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
1457 | - * Note, if you want to just get all registrations in the same transaction (group), use: |
|
1458 | - * $registration->transaction()->registrations(); |
|
1459 | - * |
|
1460 | - * @since 4.5.0 |
|
1461 | - * @return EE_Registration[] or empty array if this isn't a group registration. |
|
1462 | - */ |
|
1463 | - public function get_all_other_registrations_in_group() |
|
1464 | - { |
|
1465 | - if ($this->group_size() < 2) { |
|
1466 | - return array(); |
|
1467 | - } |
|
1468 | - |
|
1469 | - $query[0] = array( |
|
1470 | - 'TXN_ID' => $this->transaction_ID(), |
|
1471 | - 'REG_ID' => array('!=', $this->ID()), |
|
1472 | - 'TKT_ID' => $this->ticket_ID(), |
|
1473 | - ); |
|
1474 | - |
|
1475 | - $registrations = $this->get_model()->get_all($query); |
|
1476 | - return $registrations; |
|
1477 | - } |
|
1478 | - |
|
1479 | - /** |
|
1480 | - * Return the link to the admin details for the object. |
|
1481 | - * |
|
1482 | - * @return string |
|
1483 | - */ |
|
1484 | - public function get_admin_details_link() |
|
1485 | - { |
|
1486 | - EE_Registry::instance()->load_helper('URL'); |
|
1487 | - return EEH_URL::add_query_args_and_nonce( |
|
1488 | - array( |
|
1489 | - 'page' => 'espresso_registrations', |
|
1490 | - 'action' => 'view_registration', |
|
1491 | - '_REG_ID' => $this->ID(), |
|
1492 | - ), |
|
1493 | - admin_url('admin.php') |
|
1494 | - ); |
|
1495 | - } |
|
1496 | - |
|
1497 | - /** |
|
1498 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
1499 | - * |
|
1500 | - * @return string |
|
1501 | - */ |
|
1502 | - public function get_admin_edit_link() |
|
1503 | - { |
|
1504 | - return $this->get_admin_details_link(); |
|
1505 | - } |
|
1506 | - |
|
1507 | - /** |
|
1508 | - * Returns the link to a settings page for the object. |
|
1509 | - * |
|
1510 | - * @return string |
|
1511 | - */ |
|
1512 | - public function get_admin_settings_link() |
|
1513 | - { |
|
1514 | - return $this->get_admin_details_link(); |
|
1515 | - } |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
1519 | - * |
|
1520 | - * @return string |
|
1521 | - */ |
|
1522 | - public function get_admin_overview_link() |
|
1523 | - { |
|
1524 | - EE_Registry::instance()->load_helper('URL'); |
|
1525 | - return EEH_URL::add_query_args_and_nonce( |
|
1526 | - array( |
|
1527 | - 'page' => 'espresso_registrations', |
|
1528 | - ), |
|
1529 | - admin_url('admin.php') |
|
1530 | - ); |
|
1531 | - } |
|
1532 | - |
|
1533 | - |
|
1534 | - /** |
|
1535 | - * @param array $query_params |
|
1536 | - * @return \EE_Registration[] |
|
1537 | - * @throws \EE_Error |
|
1538 | - */ |
|
1539 | - public function payments($query_params = array()) |
|
1540 | - { |
|
1541 | - return $this->get_many_related('Payment', $query_params); |
|
1542 | - } |
|
1543 | - |
|
1544 | - |
|
1545 | - /** |
|
1546 | - * @param array $query_params |
|
1547 | - * @return \EE_Registration_Payment[] |
|
1548 | - * @throws \EE_Error |
|
1549 | - */ |
|
1550 | - public function registration_payments($query_params = array()) |
|
1551 | - { |
|
1552 | - return $this->get_many_related('Registration_Payment', $query_params); |
|
1553 | - } |
|
1554 | - |
|
1555 | - |
|
1556 | - /** |
|
1557 | - * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
1558 | - * Note: if there are no payments on the registration there will be no payment method returned. |
|
1559 | - * |
|
1560 | - * @return EE_Payment_Method|null |
|
1561 | - */ |
|
1562 | - public function payment_method() |
|
1563 | - { |
|
1564 | - return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1565 | - } |
|
1566 | - |
|
1567 | - |
|
1568 | - /** |
|
1569 | - * @return \EE_Line_Item |
|
1570 | - * @throws EntityNotFoundException |
|
1571 | - * @throws \EE_Error |
|
1572 | - */ |
|
1573 | - public function ticket_line_item() |
|
1574 | - { |
|
1575 | - $ticket = $this->ticket(); |
|
1576 | - $transaction = $this->transaction(); |
|
1577 | - $line_item = null; |
|
1578 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
1579 | - $transaction->total_line_item(), |
|
1580 | - 'Ticket', |
|
1581 | - array($ticket->ID()) |
|
1582 | - ); |
|
1583 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
1584 | - if ( |
|
1585 | - $ticket_line_item instanceof \EE_Line_Item |
|
1586 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
1587 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
1588 | - ) { |
|
1589 | - $line_item = $ticket_line_item; |
|
1590 | - break; |
|
1591 | - } |
|
1592 | - } |
|
1593 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1594 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
1595 | - } |
|
1596 | - return $line_item; |
|
1597 | - } |
|
1598 | - |
|
1599 | - |
|
1600 | - /** |
|
1601 | - * Soft Deletes this model object. |
|
1602 | - * |
|
1603 | - * @return boolean | int |
|
1604 | - * @throws \RuntimeException |
|
1605 | - * @throws \EE_Error |
|
1606 | - */ |
|
1607 | - public function delete() |
|
1608 | - { |
|
1609 | - if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1610 | - $this->set_status(EEM_Registration::status_id_cancelled); |
|
1611 | - } |
|
1612 | - return parent::delete(); |
|
1613 | - } |
|
1614 | - |
|
1615 | - |
|
1616 | - /** |
|
1617 | - * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
1618 | - * |
|
1619 | - * @throws \EE_Error |
|
1620 | - * @throws \RuntimeException |
|
1621 | - */ |
|
1622 | - public function restore() |
|
1623 | - { |
|
1624 | - $previous_status = $this->get_extra_meta( |
|
1625 | - EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
1626 | - true, |
|
1627 | - EEM_Registration::status_id_cancelled |
|
1628 | - ); |
|
1629 | - if ($previous_status) { |
|
1630 | - $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
1631 | - $this->set_status($previous_status); |
|
1632 | - } |
|
1633 | - return parent::restore(); |
|
1634 | - } |
|
1635 | - |
|
1636 | - |
|
1637 | - |
|
1638 | - /*************************** DEPRECATED ***************************/ |
|
1639 | - |
|
1640 | - |
|
1641 | - /** |
|
1642 | - * @deprecated |
|
1643 | - * @since 4.7.0 |
|
1644 | - * @access public |
|
1645 | - */ |
|
1646 | - public function price_paid() |
|
1647 | - { |
|
1648 | - EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
1649 | - __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
1650 | - '4.7.0'); |
|
1651 | - return $this->final_price(); |
|
1652 | - } |
|
1653 | - |
|
1654 | - |
|
1655 | - /** |
|
1656 | - * @deprecated |
|
1657 | - * @since 4.7.0 |
|
1658 | - * @access public |
|
1659 | - * @param float $REG_final_price |
|
1660 | - */ |
|
1661 | - public function set_price_paid($REG_final_price = 0.00) |
|
1662 | - { |
|
1663 | - EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
1664 | - __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
1665 | - '4.7.0'); |
|
1666 | - $this->set_final_price($REG_final_price); |
|
1667 | - } |
|
1668 | - |
|
1669 | - |
|
1670 | - /** |
|
1671 | - * @deprecated |
|
1672 | - * @since 4.7.0 |
|
1673 | - * @return string |
|
1674 | - */ |
|
1675 | - public function pretty_price_paid() |
|
1676 | - { |
|
1677 | - EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
1678 | - __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
1679 | - 'event_espresso'), '4.7.0'); |
|
1680 | - return $this->pretty_final_price(); |
|
1681 | - } |
|
1682 | - |
|
1683 | - |
|
1684 | - /** |
|
1685 | - * Gets the primary datetime related to this registration via the related Event to this registration |
|
1686 | - * |
|
1687 | - * @deprecated 4.9.17 |
|
1688 | - * @return EE_Datetime |
|
1689 | - */ |
|
1690 | - public function get_related_primary_datetime() |
|
1691 | - { |
|
1692 | - EE_Error::doing_it_wrong( |
|
1693 | - __METHOD__, |
|
1694 | - esc_html__( |
|
1695 | - 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1696 | - 'event_espresso' |
|
1697 | - ), |
|
1698 | - '4.9.17', |
|
1699 | - '5.0.0' |
|
1700 | - ); |
|
1701 | - return $this->event()->primary_datetime(); |
|
1702 | - } |
|
18 | + /** |
|
19 | + * Used to reference when a registration has never been checked in. |
|
20 | + * |
|
21 | + * @type int |
|
22 | + */ |
|
23 | + const checkin_status_never = 2; |
|
24 | + |
|
25 | + /** |
|
26 | + * Used to reference when a registration has been checked in. |
|
27 | + * |
|
28 | + * @type int |
|
29 | + */ |
|
30 | + const checkin_status_in = 1; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Used to reference when a registration has been checked out. |
|
35 | + * |
|
36 | + * @type int |
|
37 | + */ |
|
38 | + const checkin_status_out = 0; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * extra meta key for tracking reg status os trashed registrations |
|
43 | + * |
|
44 | + * @type string |
|
45 | + */ |
|
46 | + const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * extra meta key for tracking if registration has reserved ticket |
|
51 | + * |
|
52 | + * @type string |
|
53 | + */ |
|
54 | + const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @param array $props_n_values incoming values |
|
59 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | + * used.) |
|
61 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | + * date_format and the second value is the time format |
|
63 | + * @return EE_Registration |
|
64 | + */ |
|
65 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | + { |
|
67 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
68 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param array $props_n_values incoming values from the database |
|
74 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
75 | + * the website will be used. |
|
76 | + * @return EE_Registration |
|
77 | + */ |
|
78 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
79 | + { |
|
80 | + return new self($props_n_values, true, $timezone); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Set Event ID |
|
86 | + * |
|
87 | + * @param int $EVT_ID Event ID |
|
88 | + */ |
|
89 | + public function set_event($EVT_ID = 0) |
|
90 | + { |
|
91 | + $this->set('EVT_ID', $EVT_ID); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
97 | + * be routed to internal methods |
|
98 | + * |
|
99 | + * @param string $field_name |
|
100 | + * @param mixed $field_value |
|
101 | + * @param bool $use_default |
|
102 | + * @throws \EE_Error |
|
103 | + * @throws \RuntimeException |
|
104 | + */ |
|
105 | + public function set($field_name, $field_value, $use_default = false) |
|
106 | + { |
|
107 | + switch ($field_name) { |
|
108 | + case 'REG_code' : |
|
109 | + if (! empty($field_value) && $this->reg_code() === null) { |
|
110 | + $this->set_reg_code($field_value, $use_default); |
|
111 | + } |
|
112 | + break; |
|
113 | + case 'STS_ID' : |
|
114 | + $this->set_status($field_value, $use_default); |
|
115 | + break; |
|
116 | + default : |
|
117 | + parent::set($field_name, $field_value, $use_default); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Set Status ID |
|
124 | + * updates the registration status and ALSO... |
|
125 | + * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
126 | + * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
127 | + * |
|
128 | + * @param string $new_STS_ID |
|
129 | + * @param boolean $use_default |
|
130 | + * @return bool |
|
131 | + * @throws \RuntimeException |
|
132 | + * @throws \EE_Error |
|
133 | + */ |
|
134 | + public function set_status($new_STS_ID = null, $use_default = false) |
|
135 | + { |
|
136 | + // get current REG_Status |
|
137 | + $old_STS_ID = $this->status_ID(); |
|
138 | + // if status has changed |
|
139 | + if ( |
|
140 | + $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
141 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
142 | + && ! empty($new_STS_ID) // as well as the new status |
|
143 | + && $this->ID() // ensure registration is in the db |
|
144 | + ) { |
|
145 | + // TO approved |
|
146 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
147 | + // reserve a space by incrementing ticket and datetime sold values |
|
148 | + $this->_reserve_registration_space(); |
|
149 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
150 | + // OR FROM approved |
|
151 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
152 | + // release a space by decrementing ticket and datetime sold values |
|
153 | + $this->_release_registration_space(); |
|
154 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
155 | + } |
|
156 | + // update status |
|
157 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
158 | + $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
159 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
160 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
161 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
162 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
163 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
164 | + return true; |
|
165 | + } else { |
|
166 | + //even though the old value matches the new value, it's still good to |
|
167 | + //allow the parent set method to have a say |
|
168 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
169 | + return true; |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * update REGs and TXN when cancelled or declined registrations involved |
|
176 | + * |
|
177 | + * @param string $new_STS_ID |
|
178 | + * @param string $old_STS_ID |
|
179 | + * @throws \EE_Error |
|
180 | + */ |
|
181 | + private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
182 | + { |
|
183 | + // these reg statuses should not be considered in any calculations involving monies owing |
|
184 | + $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
185 | + // true if registration has been cancelled or declined |
|
186 | + if ( |
|
187 | + in_array($new_STS_ID, $closed_reg_statuses, true) |
|
188 | + && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
189 | + ) { |
|
190 | + /** @type EE_Registration_Processor $registration_processor */ |
|
191 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
192 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
193 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
194 | + // cancelled or declined registration |
|
195 | + $registration_processor->update_registration_after_being_canceled_or_declined( |
|
196 | + $this, |
|
197 | + $closed_reg_statuses |
|
198 | + ); |
|
199 | + $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
200 | + $this, |
|
201 | + $closed_reg_statuses, |
|
202 | + false |
|
203 | + ); |
|
204 | + do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
205 | + return; |
|
206 | + } |
|
207 | + // true if reinstating cancelled or declined registration |
|
208 | + if ( |
|
209 | + in_array($old_STS_ID, $closed_reg_statuses, true) |
|
210 | + && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
211 | + ) { |
|
212 | + /** @type EE_Registration_Processor $registration_processor */ |
|
213 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
214 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
215 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
216 | + // reinstating cancelled or declined registration |
|
217 | + $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
218 | + $this, |
|
219 | + $closed_reg_statuses |
|
220 | + ); |
|
221 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
222 | + $this, |
|
223 | + $closed_reg_statuses, |
|
224 | + false |
|
225 | + ); |
|
226 | + do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * get Status ID |
|
233 | + */ |
|
234 | + public function status_ID() |
|
235 | + { |
|
236 | + return $this->get('STS_ID'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * increments this registration's related ticket sold and corresponding datetime sold values |
|
242 | + * |
|
243 | + * @return void |
|
244 | + * @throws \EE_Error |
|
245 | + */ |
|
246 | + private function _reserve_registration_space() |
|
247 | + { |
|
248 | + // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
249 | + // so stop tracking that this reg has a ticket reserved |
|
250 | + $this->release_reserved_ticket(); |
|
251 | + $ticket = $this->ticket(); |
|
252 | + $ticket->increase_sold(); |
|
253 | + $ticket->save(); |
|
254 | + // possibly set event status to sold out |
|
255 | + $this->event()->perform_sold_out_status_check(); |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * Gets the ticket this registration is for |
|
261 | + * |
|
262 | + * @param boolean $include_archived whether to include archived tickets or not. |
|
263 | + * @return EE_Ticket|EE_Base_Class |
|
264 | + * @throws \EE_Error |
|
265 | + */ |
|
266 | + public function ticket($include_archived = true) |
|
267 | + { |
|
268 | + $query_params = array(); |
|
269 | + if ($include_archived) { |
|
270 | + $query_params['default_where_conditions'] = 'none'; |
|
271 | + } |
|
272 | + return $this->get_first_related('Ticket', $query_params); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * Gets the event this registration is for |
|
278 | + * |
|
279 | + * @return EE_Event |
|
280 | + */ |
|
281 | + public function event() |
|
282 | + { |
|
283 | + $event = $this->get_first_related('Event'); |
|
284 | + if (! $event instanceof \EE_Event) { |
|
285 | + throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
286 | + } |
|
287 | + return $event; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
293 | + * with the author of the event this registration is for. |
|
294 | + * |
|
295 | + * @since 4.5.0 |
|
296 | + * @return int |
|
297 | + */ |
|
298 | + public function wp_user() |
|
299 | + { |
|
300 | + $event = $this->event(); |
|
301 | + if ($event instanceof EE_Event) { |
|
302 | + return $event->wp_user(); |
|
303 | + } |
|
304 | + return 0; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
310 | + * |
|
311 | + * @return void |
|
312 | + * @throws \EE_Error |
|
313 | + */ |
|
314 | + private function _release_registration_space() |
|
315 | + { |
|
316 | + $ticket = $this->ticket(); |
|
317 | + $ticket->decrease_sold(); |
|
318 | + $ticket->save(); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * tracks this registration's ticket reservation in extra meta |
|
324 | + * and can increment related ticket reserved and corresponding datetime reserved values |
|
325 | + * |
|
326 | + * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
327 | + * @return void |
|
328 | + * @throws \EE_Error |
|
329 | + */ |
|
330 | + public function reserve_ticket($update_ticket = false) |
|
331 | + { |
|
332 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
333 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
334 | + // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
335 | + if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
336 | + $ticket = $this->ticket(); |
|
337 | + $ticket->increase_reserved(); |
|
338 | + $ticket->save(); |
|
339 | + } |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * stops tracking this registration's ticket reservation in extra meta |
|
346 | + * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
347 | + * |
|
348 | + * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
349 | + * @return void |
|
350 | + * @throws \EE_Error |
|
351 | + */ |
|
352 | + public function release_reserved_ticket($update_ticket = false) |
|
353 | + { |
|
354 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
355 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
356 | + // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
357 | + if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
358 | + $ticket = $this->ticket(); |
|
359 | + $ticket->decrease_reserved(); |
|
360 | + $ticket->save(); |
|
361 | + } |
|
362 | + } |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Set Attendee ID |
|
368 | + * |
|
369 | + * @param int $ATT_ID Attendee ID |
|
370 | + */ |
|
371 | + public function set_attendee_id($ATT_ID = 0) |
|
372 | + { |
|
373 | + $this->set('ATT_ID', $ATT_ID); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * Set Transaction ID |
|
379 | + * |
|
380 | + * @param int $TXN_ID Transaction ID |
|
381 | + */ |
|
382 | + public function set_transaction_id($TXN_ID = 0) |
|
383 | + { |
|
384 | + $this->set('TXN_ID', $TXN_ID); |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * Set Session |
|
390 | + * |
|
391 | + * @param string $REG_session PHP Session ID |
|
392 | + */ |
|
393 | + public function set_session($REG_session = '') |
|
394 | + { |
|
395 | + $this->set('REG_session', $REG_session); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + /** |
|
400 | + * Set Registration URL Link |
|
401 | + * |
|
402 | + * @param string $REG_url_link Registration URL Link |
|
403 | + */ |
|
404 | + public function set_reg_url_link($REG_url_link = '') |
|
405 | + { |
|
406 | + $this->set('REG_url_link', $REG_url_link); |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Set Attendee Counter |
|
412 | + * |
|
413 | + * @param int $REG_count Primary Attendee |
|
414 | + */ |
|
415 | + public function set_count($REG_count = 1) |
|
416 | + { |
|
417 | + $this->set('REG_count', $REG_count); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * Set Group Size |
|
423 | + * |
|
424 | + * @param boolean $REG_group_size Group Registration |
|
425 | + */ |
|
426 | + public function set_group_size($REG_group_size = false) |
|
427 | + { |
|
428 | + $this->set('REG_group_size', $REG_group_size); |
|
429 | + } |
|
430 | + |
|
431 | + |
|
432 | + /** |
|
433 | + * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
434 | + * EEM_Registration::status_id_not_approved |
|
435 | + * |
|
436 | + * @return boolean |
|
437 | + */ |
|
438 | + public function is_not_approved() |
|
439 | + { |
|
440 | + return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
446 | + * EEM_Registration::status_id_pending_payment |
|
447 | + * |
|
448 | + * @return boolean |
|
449 | + */ |
|
450 | + public function is_pending_payment() |
|
451 | + { |
|
452 | + return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + /** |
|
457 | + * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
458 | + * |
|
459 | + * @return boolean |
|
460 | + */ |
|
461 | + public function is_approved() |
|
462 | + { |
|
463 | + return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
469 | + * |
|
470 | + * @return boolean |
|
471 | + */ |
|
472 | + public function is_cancelled() |
|
473 | + { |
|
474 | + return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
480 | + * |
|
481 | + * @return boolean |
|
482 | + */ |
|
483 | + public function is_declined() |
|
484 | + { |
|
485 | + return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
491 | + * EEM_Registration::status_id_incomplete |
|
492 | + * |
|
493 | + * @return boolean |
|
494 | + */ |
|
495 | + public function is_incomplete() |
|
496 | + { |
|
497 | + return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
498 | + } |
|
499 | + |
|
500 | + |
|
501 | + /** |
|
502 | + * Set Registration Date |
|
503 | + * |
|
504 | + * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
505 | + * Date |
|
506 | + */ |
|
507 | + public function set_reg_date($REG_date = false) |
|
508 | + { |
|
509 | + $this->set('REG_date', $REG_date); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + /** |
|
514 | + * Set final price owing for this registration after all ticket/price modifications |
|
515 | + * |
|
516 | + * @access public |
|
517 | + * @param float $REG_final_price |
|
518 | + */ |
|
519 | + public function set_final_price($REG_final_price = 0.00) |
|
520 | + { |
|
521 | + $this->set('REG_final_price', $REG_final_price); |
|
522 | + } |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * Set amount paid towards this registration's final price |
|
527 | + * |
|
528 | + * @access public |
|
529 | + * @param float $REG_paid |
|
530 | + */ |
|
531 | + public function set_paid($REG_paid = 0.00) |
|
532 | + { |
|
533 | + $this->set('REG_paid', $REG_paid); |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * Attendee Is Going |
|
539 | + * |
|
540 | + * @param boolean $REG_att_is_going Attendee Is Going |
|
541 | + */ |
|
542 | + public function set_att_is_going($REG_att_is_going = false) |
|
543 | + { |
|
544 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * Gets the related attendee |
|
550 | + * |
|
551 | + * @return EE_Attendee |
|
552 | + */ |
|
553 | + public function attendee() |
|
554 | + { |
|
555 | + return $this->get_first_related('Attendee'); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * get Event ID |
|
561 | + */ |
|
562 | + public function event_ID() |
|
563 | + { |
|
564 | + return $this->get('EVT_ID'); |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * get Event ID |
|
570 | + */ |
|
571 | + public function event_name() |
|
572 | + { |
|
573 | + $event = $this->event_obj(); |
|
574 | + if ($event) { |
|
575 | + return $event->name(); |
|
576 | + } else { |
|
577 | + return null; |
|
578 | + } |
|
579 | + } |
|
580 | + |
|
581 | + |
|
582 | + /** |
|
583 | + * Fetches the event this registration is for |
|
584 | + * |
|
585 | + * @return EE_Event |
|
586 | + */ |
|
587 | + public function event_obj() |
|
588 | + { |
|
589 | + return $this->get_first_related('Event'); |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * get Attendee ID |
|
595 | + */ |
|
596 | + public function attendee_ID() |
|
597 | + { |
|
598 | + return $this->get('ATT_ID'); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * get PHP Session ID |
|
604 | + */ |
|
605 | + public function session_ID() |
|
606 | + { |
|
607 | + return $this->get('REG_session'); |
|
608 | + } |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
613 | + * |
|
614 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
615 | + * @return string |
|
616 | + */ |
|
617 | + public function receipt_url($messenger = 'html') |
|
618 | + { |
|
619 | + |
|
620 | + /** |
|
621 | + * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
622 | + * |
|
623 | + * @since 4.5.0 |
|
624 | + */ |
|
625 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
626 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
627 | + |
|
628 | + if ($has_custom) { |
|
629 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
630 | + } |
|
631 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
637 | + * |
|
638 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
639 | + * @return string |
|
640 | + */ |
|
641 | + public function invoice_url($messenger = 'html') |
|
642 | + { |
|
643 | + /** |
|
644 | + * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
645 | + * |
|
646 | + * @since 4.5.0 |
|
647 | + */ |
|
648 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
649 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
650 | + |
|
651 | + if ($has_custom) { |
|
652 | + if ($messenger == 'html') { |
|
653 | + return $this->invoice_url('launch'); |
|
654 | + } |
|
655 | + $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
656 | + |
|
657 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
658 | + if ($messenger == 'html') { |
|
659 | + $query_args['html'] = true; |
|
660 | + } |
|
661 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
662 | + } |
|
663 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + /** |
|
668 | + * get Registration URL Link |
|
669 | + * |
|
670 | + * @access public |
|
671 | + * @return string |
|
672 | + * @throws \EE_Error |
|
673 | + */ |
|
674 | + public function reg_url_link() |
|
675 | + { |
|
676 | + return (string)$this->get('REG_url_link'); |
|
677 | + } |
|
678 | + |
|
679 | + |
|
680 | + /** |
|
681 | + * Echoes out invoice_url() |
|
682 | + * |
|
683 | + * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
684 | + * @return void |
|
685 | + */ |
|
686 | + public function e_invoice_url($type = 'launch') |
|
687 | + { |
|
688 | + echo $this->invoice_url($type); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * Echoes out payment_overview_url |
|
694 | + */ |
|
695 | + public function e_payment_overview_url() |
|
696 | + { |
|
697 | + echo $this->payment_overview_url(); |
|
698 | + } |
|
699 | + |
|
700 | + |
|
701 | + /** |
|
702 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
703 | + * a query parameter |
|
704 | + * |
|
705 | + * @return string |
|
706 | + */ |
|
707 | + public function payment_overview_url() |
|
708 | + { |
|
709 | + return add_query_arg(array( |
|
710 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
711 | + 'step' => 'payment_options', |
|
712 | + 'revisit' => true, |
|
713 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
714 | + } |
|
715 | + |
|
716 | + |
|
717 | + /** |
|
718 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
719 | + * a query parameter |
|
720 | + * |
|
721 | + * @return string |
|
722 | + */ |
|
723 | + public function edit_attendee_information_url() |
|
724 | + { |
|
725 | + return add_query_arg(array( |
|
726 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
727 | + 'step' => 'attendee_information', |
|
728 | + 'revisit' => true, |
|
729 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
730 | + } |
|
731 | + |
|
732 | + |
|
733 | + /** |
|
734 | + * Simply generates and returns the appropriate admin_url link to edit this registration |
|
735 | + * |
|
736 | + * @return string |
|
737 | + */ |
|
738 | + public function get_admin_edit_url() |
|
739 | + { |
|
740 | + return EEH_URL::add_query_args_and_nonce(array( |
|
741 | + 'page' => 'espresso_registrations', |
|
742 | + 'action' => 'view_registration', |
|
743 | + '_REG_ID' => $this->ID(), |
|
744 | + ), admin_url('admin.php')); |
|
745 | + } |
|
746 | + |
|
747 | + |
|
748 | + /** |
|
749 | + * is_primary_registrant? |
|
750 | + */ |
|
751 | + public function is_primary_registrant() |
|
752 | + { |
|
753 | + return $this->get('REG_count') == 1 ? true : false; |
|
754 | + } |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * This returns the primary registration object for this registration group (which may be this object). |
|
759 | + * |
|
760 | + * @return EE_Registration |
|
761 | + */ |
|
762 | + public function get_primary_registration() |
|
763 | + { |
|
764 | + if ($this->is_primary_registrant()) { |
|
765 | + return $this; |
|
766 | + } |
|
767 | + |
|
768 | + //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
769 | + $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
770 | + array( |
|
771 | + 'TXN_ID' => $this->transaction_ID(), |
|
772 | + 'REG_count' => 1, |
|
773 | + ), |
|
774 | + )); |
|
775 | + return $primary_registrant; |
|
776 | + } |
|
777 | + |
|
778 | + |
|
779 | + /** |
|
780 | + * get Attendee Number |
|
781 | + * |
|
782 | + * @access public |
|
783 | + */ |
|
784 | + public function count() |
|
785 | + { |
|
786 | + return $this->get('REG_count'); |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + /** |
|
791 | + * get Group Size |
|
792 | + */ |
|
793 | + public function group_size() |
|
794 | + { |
|
795 | + return $this->get('REG_group_size'); |
|
796 | + } |
|
797 | + |
|
798 | + |
|
799 | + /** |
|
800 | + * get Registration Date |
|
801 | + */ |
|
802 | + public function date() |
|
803 | + { |
|
804 | + return $this->get('REG_date'); |
|
805 | + } |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * gets a pretty date |
|
810 | + * |
|
811 | + * @param string $date_format |
|
812 | + * @param string $time_format |
|
813 | + * @return string |
|
814 | + */ |
|
815 | + public function pretty_date($date_format = null, $time_format = null) |
|
816 | + { |
|
817 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + /** |
|
822 | + * final_price |
|
823 | + * the registration's share of the transaction total, so that the |
|
824 | + * sum of all the transaction's REG_final_prices equal the transaction's total |
|
825 | + * |
|
826 | + * @return float |
|
827 | + */ |
|
828 | + public function final_price() |
|
829 | + { |
|
830 | + return $this->get('REG_final_price'); |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * pretty_final_price |
|
836 | + * final price as formatted string, with correct decimal places and currency symbol |
|
837 | + * |
|
838 | + * @return string |
|
839 | + */ |
|
840 | + public function pretty_final_price() |
|
841 | + { |
|
842 | + return $this->get_pretty('REG_final_price'); |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * get paid (yeah) |
|
848 | + * |
|
849 | + * @return float |
|
850 | + */ |
|
851 | + public function paid() |
|
852 | + { |
|
853 | + return $this->get('REG_paid'); |
|
854 | + } |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * pretty_paid |
|
859 | + * |
|
860 | + * @return float |
|
861 | + */ |
|
862 | + public function pretty_paid() |
|
863 | + { |
|
864 | + return $this->get_pretty('REG_paid'); |
|
865 | + } |
|
866 | + |
|
867 | + |
|
868 | + /** |
|
869 | + * owes_monies_and_can_pay |
|
870 | + * whether or not this registration has monies owing and it's' status allows payment |
|
871 | + * |
|
872 | + * @param array $requires_payment |
|
873 | + * @return bool |
|
874 | + */ |
|
875 | + public function owes_monies_and_can_pay($requires_payment = array()) |
|
876 | + { |
|
877 | + // these reg statuses require payment (if event is not free) |
|
878 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
879 | + if ( |
|
880 | + in_array($this->status_ID(), $requires_payment) && |
|
881 | + $this->final_price() != 0 && |
|
882 | + $this->final_price() != $this->paid() |
|
883 | + ) { |
|
884 | + return true; |
|
885 | + } else { |
|
886 | + return false; |
|
887 | + } |
|
888 | + } |
|
889 | + |
|
890 | + |
|
891 | + /** |
|
892 | + * Prints out the return value of $this->pretty_status() |
|
893 | + * |
|
894 | + * @param bool $show_icons |
|
895 | + * @return void |
|
896 | + */ |
|
897 | + public function e_pretty_status($show_icons = false) |
|
898 | + { |
|
899 | + echo $this->pretty_status($show_icons); |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + /** |
|
904 | + * Returns a nice version of the status for displaying to customers |
|
905 | + * |
|
906 | + * @param bool $show_icons |
|
907 | + * @return string |
|
908 | + */ |
|
909 | + public function pretty_status($show_icons = false) |
|
910 | + { |
|
911 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
912 | + false, 'sentence'); |
|
913 | + $icon = ''; |
|
914 | + switch ($this->status_ID()) { |
|
915 | + case EEM_Registration::status_id_approved: |
|
916 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
917 | + break; |
|
918 | + case EEM_Registration::status_id_pending_payment: |
|
919 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
920 | + break; |
|
921 | + case EEM_Registration::status_id_not_approved: |
|
922 | + $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
923 | + break; |
|
924 | + case EEM_Registration::status_id_cancelled: |
|
925 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
926 | + break; |
|
927 | + case EEM_Registration::status_id_incomplete: |
|
928 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
929 | + break; |
|
930 | + case EEM_Registration::status_id_declined: |
|
931 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
932 | + break; |
|
933 | + case EEM_Registration::status_id_wait_list: |
|
934 | + $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
935 | + break; |
|
936 | + } |
|
937 | + return $icon . $status[$this->status_ID()]; |
|
938 | + } |
|
939 | + |
|
940 | + |
|
941 | + /** |
|
942 | + * get Attendee Is Going |
|
943 | + */ |
|
944 | + public function att_is_going() |
|
945 | + { |
|
946 | + return $this->get('REG_att_is_going'); |
|
947 | + } |
|
948 | + |
|
949 | + |
|
950 | + /** |
|
951 | + * Gets related answers |
|
952 | + * |
|
953 | + * @param array $query_params like EEM_Base::get_all |
|
954 | + * @return EE_Answer[] |
|
955 | + */ |
|
956 | + public function answers($query_params = null) |
|
957 | + { |
|
958 | + return $this->get_many_related('Answer', $query_params); |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + /** |
|
963 | + * Gets the registration's answer value to the specified question |
|
964 | + * (either the question's ID or a question object) |
|
965 | + * |
|
966 | + * @param EE_Question|int $question |
|
967 | + * @param bool $pretty_value |
|
968 | + * @return array|string if pretty_value= true, the result will always be a string |
|
969 | + * (because the answer might be an array of answer values, so passing pretty_value=true |
|
970 | + * will convert it into some kind of string) |
|
971 | + */ |
|
972 | + public function answer_value_to_question($question, $pretty_value = true) |
|
973 | + { |
|
974 | + $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
975 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
976 | + } |
|
977 | + |
|
978 | + |
|
979 | + /** |
|
980 | + * question_groups |
|
981 | + * returns an array of EE_Question_Group objects for this registration |
|
982 | + * |
|
983 | + * @return EE_Question_Group[] |
|
984 | + */ |
|
985 | + public function question_groups() |
|
986 | + { |
|
987 | + $question_groups = array(); |
|
988 | + if ($this->event() instanceof EE_Event) { |
|
989 | + $question_groups = $this->event()->question_groups( |
|
990 | + array( |
|
991 | + array( |
|
992 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
993 | + ), |
|
994 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
995 | + ) |
|
996 | + ); |
|
997 | + } |
|
998 | + return $question_groups; |
|
999 | + } |
|
1000 | + |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * count_question_groups |
|
1004 | + * returns a count of the number of EE_Question_Group objects for this registration |
|
1005 | + * |
|
1006 | + * @return int |
|
1007 | + */ |
|
1008 | + public function count_question_groups() |
|
1009 | + { |
|
1010 | + $qg_count = 0; |
|
1011 | + if ($this->event() instanceof EE_Event) { |
|
1012 | + $qg_count = $this->event()->count_related( |
|
1013 | + 'Question_Group', |
|
1014 | + array( |
|
1015 | + array( |
|
1016 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
1017 | + ), |
|
1018 | + ) |
|
1019 | + ); |
|
1020 | + } |
|
1021 | + return $qg_count; |
|
1022 | + } |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * Returns the registration date in the 'standard' string format |
|
1027 | + * (function may be improved in the future to allow for different formats and timezones) |
|
1028 | + * |
|
1029 | + * @return string |
|
1030 | + */ |
|
1031 | + public function reg_date() |
|
1032 | + { |
|
1033 | + return $this->get_datetime('REG_date'); |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + /** |
|
1038 | + * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
1039 | + * the ticket this registration purchased, or the datetime they have registered |
|
1040 | + * to attend) |
|
1041 | + * |
|
1042 | + * @return EE_Datetime_Ticket |
|
1043 | + */ |
|
1044 | + public function datetime_ticket() |
|
1045 | + { |
|
1046 | + return $this->get_first_related('Datetime_Ticket'); |
|
1047 | + } |
|
1048 | + |
|
1049 | + |
|
1050 | + /** |
|
1051 | + * Sets the registration's datetime_ticket. |
|
1052 | + * |
|
1053 | + * @param EE_Datetime_Ticket $datetime_ticket |
|
1054 | + * @return EE_Datetime_Ticket |
|
1055 | + */ |
|
1056 | + public function set_datetime_ticket($datetime_ticket) |
|
1057 | + { |
|
1058 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
1059 | + } |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * Gets deleted |
|
1063 | + * |
|
1064 | + * @return boolean |
|
1065 | + */ |
|
1066 | + public function deleted() |
|
1067 | + { |
|
1068 | + return $this->get('REG_deleted'); |
|
1069 | + } |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * Sets deleted |
|
1073 | + * |
|
1074 | + * @param boolean $deleted |
|
1075 | + * @return boolean |
|
1076 | + */ |
|
1077 | + public function set_deleted($deleted) |
|
1078 | + { |
|
1079 | + if ($deleted) { |
|
1080 | + $this->delete(); |
|
1081 | + } else { |
|
1082 | + $this->restore(); |
|
1083 | + } |
|
1084 | + } |
|
1085 | + |
|
1086 | + |
|
1087 | + /** |
|
1088 | + * Get the status object of this object |
|
1089 | + * |
|
1090 | + * @return EE_Status |
|
1091 | + */ |
|
1092 | + public function status_obj() |
|
1093 | + { |
|
1094 | + return $this->get_first_related('Status'); |
|
1095 | + } |
|
1096 | + |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * Returns the number of times this registration has checked into any of the datetimes |
|
1100 | + * its available for |
|
1101 | + * |
|
1102 | + * @return int |
|
1103 | + */ |
|
1104 | + public function count_checkins() |
|
1105 | + { |
|
1106 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
1107 | + } |
|
1108 | + |
|
1109 | + |
|
1110 | + /** |
|
1111 | + * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
1112 | + * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
1113 | + * |
|
1114 | + * @return int |
|
1115 | + */ |
|
1116 | + public function count_checkins_not_checkedout() |
|
1117 | + { |
|
1118 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
1119 | + } |
|
1120 | + |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
1124 | + * |
|
1125 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1126 | + * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
1127 | + * consider registration status as well as datetime access. |
|
1128 | + * @return bool |
|
1129 | + */ |
|
1130 | + public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
1131 | + { |
|
1132 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1133 | + |
|
1134 | + //first check registration status |
|
1135 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1136 | + return false; |
|
1137 | + } |
|
1138 | + //is there a datetime ticket that matches this dtt_ID? |
|
1139 | + if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1140 | + array( |
|
1141 | + 'TKT_ID' => $this->get('TKT_ID'), |
|
1142 | + 'DTT_ID' => $DTT_ID, |
|
1143 | + ), |
|
1144 | + ))) |
|
1145 | + ) { |
|
1146 | + return false; |
|
1147 | + } |
|
1148 | + |
|
1149 | + //final check is against TKT_uses |
|
1150 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1151 | + } |
|
1152 | + |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
1156 | + * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
1157 | + * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
1158 | + * then return false. Otherwise return true. |
|
1159 | + * |
|
1160 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1161 | + * @return bool true means can checkin. false means cannot checkin. |
|
1162 | + */ |
|
1163 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
1164 | + { |
|
1165 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1166 | + |
|
1167 | + if (! $DTT_ID) { |
|
1168 | + return false; |
|
1169 | + } |
|
1170 | + |
|
1171 | + $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
1172 | + |
|
1173 | + // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
1174 | + // or not. |
|
1175 | + if (! $max_uses || $max_uses === EE_INF) { |
|
1176 | + return true; |
|
1177 | + } |
|
1178 | + |
|
1179 | + //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
1180 | + //go ahead and toggle. |
|
1181 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1182 | + return true; |
|
1183 | + } |
|
1184 | + |
|
1185 | + //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
1186 | + //disallows further check-ins. |
|
1187 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
1188 | + array( |
|
1189 | + 'REG_ID' => $this->ID(), |
|
1190 | + 'CHK_in' => true, |
|
1191 | + ), |
|
1192 | + ), 'DTT_ID', true); |
|
1193 | + // checkins have already reached their max number of uses |
|
1194 | + // so registrant can NOT checkin |
|
1195 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1196 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
1197 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1198 | + return false; |
|
1199 | + } |
|
1200 | + return true; |
|
1201 | + } |
|
1202 | + |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * toggle Check-in status for this registration |
|
1206 | + * Check-ins are toggled in the following order: |
|
1207 | + * never checked in -> checked in |
|
1208 | + * checked in -> checked out |
|
1209 | + * checked out -> checked in |
|
1210 | + * |
|
1211 | + * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1212 | + * If not included or null, then it is assumed latest datetime is being toggled. |
|
1213 | + * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1214 | + * can be checked in or not. Otherwise this forces change in checkin status. |
|
1215 | + * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1216 | + * @throws EE_Error |
|
1217 | + */ |
|
1218 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
1219 | + { |
|
1220 | + if (empty($DTT_ID)) { |
|
1221 | + $datetime = $this->get_latest_related_datetime(); |
|
1222 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
1223 | + // verify the registration can checkin for the given DTT_ID |
|
1224 | + } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
1225 | + EE_Error::add_error( |
|
1226 | + sprintf( |
|
1227 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
1228 | + 'event_espresso'), |
|
1229 | + $this->ID(), |
|
1230 | + $DTT_ID |
|
1231 | + ), |
|
1232 | + __FILE__, __FUNCTION__, __LINE__ |
|
1233 | + ); |
|
1234 | + return false; |
|
1235 | + } |
|
1236 | + $status_paths = array( |
|
1237 | + EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
1238 | + EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
1239 | + EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
1240 | + ); |
|
1241 | + //start by getting the current status so we know what status we'll be changing to. |
|
1242 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
1243 | + $status_to = $status_paths[$cur_status]; |
|
1244 | + // database only records true for checked IN or false for checked OUT |
|
1245 | + // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
1246 | + $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
1247 | + // add relation - note Check-ins are always creating new rows |
|
1248 | + // because we are keeping track of Check-ins over time. |
|
1249 | + // Eventually we'll probably want to show a list table |
|
1250 | + // for the individual Check-ins so that they can be managed. |
|
1251 | + $checkin = EE_Checkin::new_instance(array( |
|
1252 | + 'REG_ID' => $this->ID(), |
|
1253 | + 'DTT_ID' => $DTT_ID, |
|
1254 | + 'CHK_in' => $new_status, |
|
1255 | + )); |
|
1256 | + // if the record could not be saved then return false |
|
1257 | + if ($checkin->save() === 0) { |
|
1258 | + if (WP_DEBUG) { |
|
1259 | + global $wpdb; |
|
1260 | + $error = sprintf( |
|
1261 | + __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
1262 | + 'event_espresso'), |
|
1263 | + '<br />', |
|
1264 | + $wpdb->last_error |
|
1265 | + ); |
|
1266 | + } else { |
|
1267 | + $error = __('Registration check in update failed because of an unknown database error', |
|
1268 | + 'event_espresso'); |
|
1269 | + } |
|
1270 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1271 | + return false; |
|
1272 | + } |
|
1273 | + return $status_to; |
|
1274 | + } |
|
1275 | + |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1279 | + * "Latest" is defined by the `DTT_EVT_start` column. |
|
1280 | + * |
|
1281 | + * @return EE_Datetime|null |
|
1282 | + * @throws \EE_Error |
|
1283 | + */ |
|
1284 | + public function get_latest_related_datetime() |
|
1285 | + { |
|
1286 | + return EEM_Datetime::instance()->get_one( |
|
1287 | + array( |
|
1288 | + array( |
|
1289 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1290 | + ), |
|
1291 | + 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
1292 | + ) |
|
1293 | + ); |
|
1294 | + } |
|
1295 | + |
|
1296 | + |
|
1297 | + /** |
|
1298 | + * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1299 | + * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1300 | + * |
|
1301 | + * @throws \EE_Error |
|
1302 | + */ |
|
1303 | + public function get_earliest_related_datetime() |
|
1304 | + { |
|
1305 | + return EEM_Datetime::instance()->get_one( |
|
1306 | + array( |
|
1307 | + array( |
|
1308 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1309 | + ), |
|
1310 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
1311 | + ) |
|
1312 | + ); |
|
1313 | + } |
|
1314 | + |
|
1315 | + |
|
1316 | + /** |
|
1317 | + * This method simply returns the check-in status for this registration and the given datetime. |
|
1318 | + * If neither the datetime nor the checkin values are provided as arguments, |
|
1319 | + * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1320 | + * |
|
1321 | + * @param int $DTT_ID The ID of the datetime we're checking against |
|
1322 | + * (if empty we'll get the primary datetime for |
|
1323 | + * this registration (via event) and use it's ID); |
|
1324 | + * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1325 | + * @return int Integer representing Check-in status. |
|
1326 | + * @throws \EE_Error |
|
1327 | + */ |
|
1328 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
1329 | + { |
|
1330 | + $checkin_query_params = array( |
|
1331 | + 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
1332 | + ); |
|
1333 | + |
|
1334 | + if ($DTT_ID > 0) { |
|
1335 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1336 | + } |
|
1337 | + |
|
1338 | + //get checkin object (if exists) |
|
1339 | + $checkin = $checkin instanceof EE_Checkin |
|
1340 | + ? $checkin |
|
1341 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
1342 | + if ($checkin instanceof EE_Checkin) { |
|
1343 | + if ($checkin->get('CHK_in')) { |
|
1344 | + return EE_Registration::checkin_status_in; //checked in |
|
1345 | + } |
|
1346 | + return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
1347 | + } |
|
1348 | + return EE_Registration::checkin_status_never; //never been checked in |
|
1349 | + } |
|
1350 | + |
|
1351 | + |
|
1352 | + /** |
|
1353 | + * This method returns a localized message for the toggled Check-in message. |
|
1354 | + * |
|
1355 | + * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
1356 | + * then it is assumed Check-in for primary datetime was toggled. |
|
1357 | + * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
1358 | + * message can be customized with the attendee name. |
|
1359 | + * @return string internationalized message |
|
1360 | + */ |
|
1361 | + public function get_checkin_msg($DTT_ID, $error = false) |
|
1362 | + { |
|
1363 | + //let's get the attendee first so we can include the name of the attendee |
|
1364 | + $attendee = $this->get_first_related('Attendee'); |
|
1365 | + if ($attendee instanceof EE_Attendee) { |
|
1366 | + if ($error) { |
|
1367 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1368 | + } |
|
1369 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1370 | + //what is the status message going to be? |
|
1371 | + switch ($cur_status) { |
|
1372 | + case EE_Registration::checkin_status_never : |
|
1373 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
1374 | + $attendee->full_name()); |
|
1375 | + break; |
|
1376 | + case EE_Registration::checkin_status_in : |
|
1377 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1378 | + break; |
|
1379 | + case EE_Registration::checkin_status_out : |
|
1380 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1381 | + break; |
|
1382 | + } |
|
1383 | + } |
|
1384 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1385 | + } |
|
1386 | + |
|
1387 | + |
|
1388 | + /** |
|
1389 | + * Returns the related EE_Transaction to this registration |
|
1390 | + * |
|
1391 | + * @return EE_Transaction |
|
1392 | + */ |
|
1393 | + public function transaction() |
|
1394 | + { |
|
1395 | + $transaction = $this->get_first_related('Transaction'); |
|
1396 | + if (! $transaction instanceof \EE_Transaction) { |
|
1397 | + throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
1398 | + } |
|
1399 | + return $transaction; |
|
1400 | + } |
|
1401 | + |
|
1402 | + |
|
1403 | + /** |
|
1404 | + * get Registration Code |
|
1405 | + */ |
|
1406 | + public function reg_code() |
|
1407 | + { |
|
1408 | + return $this->get('REG_code'); |
|
1409 | + } |
|
1410 | + |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * get Transaction ID |
|
1414 | + */ |
|
1415 | + public function transaction_ID() |
|
1416 | + { |
|
1417 | + return $this->get('TXN_ID'); |
|
1418 | + } |
|
1419 | + |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * @return int |
|
1423 | + */ |
|
1424 | + public function ticket_ID() |
|
1425 | + { |
|
1426 | + return $this->get('TKT_ID'); |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * Set Registration Code |
|
1432 | + * |
|
1433 | + * @access public |
|
1434 | + * @param string $REG_code Registration Code |
|
1435 | + * @param boolean $use_default |
|
1436 | + */ |
|
1437 | + public function set_reg_code($REG_code, $use_default = false) |
|
1438 | + { |
|
1439 | + if (empty($REG_code)) { |
|
1440 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1441 | + return; |
|
1442 | + } |
|
1443 | + if (! $this->reg_code()) { |
|
1444 | + parent::set('REG_code', $REG_code, $use_default); |
|
1445 | + } else { |
|
1446 | + EE_Error::doing_it_wrong( |
|
1447 | + __CLASS__ . '::' . __FUNCTION__, |
|
1448 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1449 | + '4.6.0' |
|
1450 | + ); |
|
1451 | + } |
|
1452 | + } |
|
1453 | + |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
1457 | + * Note, if you want to just get all registrations in the same transaction (group), use: |
|
1458 | + * $registration->transaction()->registrations(); |
|
1459 | + * |
|
1460 | + * @since 4.5.0 |
|
1461 | + * @return EE_Registration[] or empty array if this isn't a group registration. |
|
1462 | + */ |
|
1463 | + public function get_all_other_registrations_in_group() |
|
1464 | + { |
|
1465 | + if ($this->group_size() < 2) { |
|
1466 | + return array(); |
|
1467 | + } |
|
1468 | + |
|
1469 | + $query[0] = array( |
|
1470 | + 'TXN_ID' => $this->transaction_ID(), |
|
1471 | + 'REG_ID' => array('!=', $this->ID()), |
|
1472 | + 'TKT_ID' => $this->ticket_ID(), |
|
1473 | + ); |
|
1474 | + |
|
1475 | + $registrations = $this->get_model()->get_all($query); |
|
1476 | + return $registrations; |
|
1477 | + } |
|
1478 | + |
|
1479 | + /** |
|
1480 | + * Return the link to the admin details for the object. |
|
1481 | + * |
|
1482 | + * @return string |
|
1483 | + */ |
|
1484 | + public function get_admin_details_link() |
|
1485 | + { |
|
1486 | + EE_Registry::instance()->load_helper('URL'); |
|
1487 | + return EEH_URL::add_query_args_and_nonce( |
|
1488 | + array( |
|
1489 | + 'page' => 'espresso_registrations', |
|
1490 | + 'action' => 'view_registration', |
|
1491 | + '_REG_ID' => $this->ID(), |
|
1492 | + ), |
|
1493 | + admin_url('admin.php') |
|
1494 | + ); |
|
1495 | + } |
|
1496 | + |
|
1497 | + /** |
|
1498 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
1499 | + * |
|
1500 | + * @return string |
|
1501 | + */ |
|
1502 | + public function get_admin_edit_link() |
|
1503 | + { |
|
1504 | + return $this->get_admin_details_link(); |
|
1505 | + } |
|
1506 | + |
|
1507 | + /** |
|
1508 | + * Returns the link to a settings page for the object. |
|
1509 | + * |
|
1510 | + * @return string |
|
1511 | + */ |
|
1512 | + public function get_admin_settings_link() |
|
1513 | + { |
|
1514 | + return $this->get_admin_details_link(); |
|
1515 | + } |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
1519 | + * |
|
1520 | + * @return string |
|
1521 | + */ |
|
1522 | + public function get_admin_overview_link() |
|
1523 | + { |
|
1524 | + EE_Registry::instance()->load_helper('URL'); |
|
1525 | + return EEH_URL::add_query_args_and_nonce( |
|
1526 | + array( |
|
1527 | + 'page' => 'espresso_registrations', |
|
1528 | + ), |
|
1529 | + admin_url('admin.php') |
|
1530 | + ); |
|
1531 | + } |
|
1532 | + |
|
1533 | + |
|
1534 | + /** |
|
1535 | + * @param array $query_params |
|
1536 | + * @return \EE_Registration[] |
|
1537 | + * @throws \EE_Error |
|
1538 | + */ |
|
1539 | + public function payments($query_params = array()) |
|
1540 | + { |
|
1541 | + return $this->get_many_related('Payment', $query_params); |
|
1542 | + } |
|
1543 | + |
|
1544 | + |
|
1545 | + /** |
|
1546 | + * @param array $query_params |
|
1547 | + * @return \EE_Registration_Payment[] |
|
1548 | + * @throws \EE_Error |
|
1549 | + */ |
|
1550 | + public function registration_payments($query_params = array()) |
|
1551 | + { |
|
1552 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1553 | + } |
|
1554 | + |
|
1555 | + |
|
1556 | + /** |
|
1557 | + * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
1558 | + * Note: if there are no payments on the registration there will be no payment method returned. |
|
1559 | + * |
|
1560 | + * @return EE_Payment_Method|null |
|
1561 | + */ |
|
1562 | + public function payment_method() |
|
1563 | + { |
|
1564 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1565 | + } |
|
1566 | + |
|
1567 | + |
|
1568 | + /** |
|
1569 | + * @return \EE_Line_Item |
|
1570 | + * @throws EntityNotFoundException |
|
1571 | + * @throws \EE_Error |
|
1572 | + */ |
|
1573 | + public function ticket_line_item() |
|
1574 | + { |
|
1575 | + $ticket = $this->ticket(); |
|
1576 | + $transaction = $this->transaction(); |
|
1577 | + $line_item = null; |
|
1578 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
1579 | + $transaction->total_line_item(), |
|
1580 | + 'Ticket', |
|
1581 | + array($ticket->ID()) |
|
1582 | + ); |
|
1583 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
1584 | + if ( |
|
1585 | + $ticket_line_item instanceof \EE_Line_Item |
|
1586 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
1587 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
1588 | + ) { |
|
1589 | + $line_item = $ticket_line_item; |
|
1590 | + break; |
|
1591 | + } |
|
1592 | + } |
|
1593 | + if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1594 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
1595 | + } |
|
1596 | + return $line_item; |
|
1597 | + } |
|
1598 | + |
|
1599 | + |
|
1600 | + /** |
|
1601 | + * Soft Deletes this model object. |
|
1602 | + * |
|
1603 | + * @return boolean | int |
|
1604 | + * @throws \RuntimeException |
|
1605 | + * @throws \EE_Error |
|
1606 | + */ |
|
1607 | + public function delete() |
|
1608 | + { |
|
1609 | + if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1610 | + $this->set_status(EEM_Registration::status_id_cancelled); |
|
1611 | + } |
|
1612 | + return parent::delete(); |
|
1613 | + } |
|
1614 | + |
|
1615 | + |
|
1616 | + /** |
|
1617 | + * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
1618 | + * |
|
1619 | + * @throws \EE_Error |
|
1620 | + * @throws \RuntimeException |
|
1621 | + */ |
|
1622 | + public function restore() |
|
1623 | + { |
|
1624 | + $previous_status = $this->get_extra_meta( |
|
1625 | + EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
1626 | + true, |
|
1627 | + EEM_Registration::status_id_cancelled |
|
1628 | + ); |
|
1629 | + if ($previous_status) { |
|
1630 | + $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
1631 | + $this->set_status($previous_status); |
|
1632 | + } |
|
1633 | + return parent::restore(); |
|
1634 | + } |
|
1635 | + |
|
1636 | + |
|
1637 | + |
|
1638 | + /*************************** DEPRECATED ***************************/ |
|
1639 | + |
|
1640 | + |
|
1641 | + /** |
|
1642 | + * @deprecated |
|
1643 | + * @since 4.7.0 |
|
1644 | + * @access public |
|
1645 | + */ |
|
1646 | + public function price_paid() |
|
1647 | + { |
|
1648 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
1649 | + __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
1650 | + '4.7.0'); |
|
1651 | + return $this->final_price(); |
|
1652 | + } |
|
1653 | + |
|
1654 | + |
|
1655 | + /** |
|
1656 | + * @deprecated |
|
1657 | + * @since 4.7.0 |
|
1658 | + * @access public |
|
1659 | + * @param float $REG_final_price |
|
1660 | + */ |
|
1661 | + public function set_price_paid($REG_final_price = 0.00) |
|
1662 | + { |
|
1663 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
1664 | + __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
1665 | + '4.7.0'); |
|
1666 | + $this->set_final_price($REG_final_price); |
|
1667 | + } |
|
1668 | + |
|
1669 | + |
|
1670 | + /** |
|
1671 | + * @deprecated |
|
1672 | + * @since 4.7.0 |
|
1673 | + * @return string |
|
1674 | + */ |
|
1675 | + public function pretty_price_paid() |
|
1676 | + { |
|
1677 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
1678 | + __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
1679 | + 'event_espresso'), '4.7.0'); |
|
1680 | + return $this->pretty_final_price(); |
|
1681 | + } |
|
1682 | + |
|
1683 | + |
|
1684 | + /** |
|
1685 | + * Gets the primary datetime related to this registration via the related Event to this registration |
|
1686 | + * |
|
1687 | + * @deprecated 4.9.17 |
|
1688 | + * @return EE_Datetime |
|
1689 | + */ |
|
1690 | + public function get_related_primary_datetime() |
|
1691 | + { |
|
1692 | + EE_Error::doing_it_wrong( |
|
1693 | + __METHOD__, |
|
1694 | + esc_html__( |
|
1695 | + 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1696 | + 'event_espresso' |
|
1697 | + ), |
|
1698 | + '4.9.17', |
|
1699 | + '5.0.0' |
|
1700 | + ); |
|
1701 | + return $this->event()->primary_datetime(); |
|
1702 | + } |
|
1703 | 1703 | |
1704 | 1704 | |
1705 | 1705 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | switch ($field_name) { |
108 | 108 | case 'REG_code' : |
109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
109 | + if ( ! empty($field_value) && $this->reg_code() === null) { |
|
110 | 110 | $this->set_reg_code($field_value, $use_default); |
111 | 111 | } |
112 | 112 | break; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function event() |
282 | 282 | { |
283 | 283 | $event = $this->get_first_related('Event'); |
284 | - if (! $event instanceof \EE_Event) { |
|
284 | + if ( ! $event instanceof \EE_Event) { |
|
285 | 285 | throw new EntityNotFoundException('Event ID', $this->event_ID()); |
286 | 286 | } |
287 | 287 | return $event; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | */ |
674 | 674 | public function reg_url_link() |
675 | 675 | { |
676 | - return (string)$this->get('REG_url_link'); |
|
676 | + return (string) $this->get('REG_url_link'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
935 | 935 | break; |
936 | 936 | } |
937 | - return $icon . $status[$this->status_ID()]; |
|
937 | + return $icon.$status[$this->status_ID()]; |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | return false; |
1137 | 1137 | } |
1138 | 1138 | //is there a datetime ticket that matches this dtt_ID? |
1139 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1139 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1140 | 1140 | array( |
1141 | 1141 | 'TKT_ID' => $this->get('TKT_ID'), |
1142 | 1142 | 'DTT_ID' => $DTT_ID, |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | { |
1165 | 1165 | $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
1166 | 1166 | |
1167 | - if (! $DTT_ID) { |
|
1167 | + if ( ! $DTT_ID) { |
|
1168 | 1168 | return false; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | |
1173 | 1173 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
1174 | 1174 | // or not. |
1175 | - if (! $max_uses || $max_uses === EE_INF) { |
|
1175 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
1176 | 1176 | return true; |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | $datetime = $this->get_latest_related_datetime(); |
1222 | 1222 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
1223 | 1223 | // verify the registration can checkin for the given DTT_ID |
1224 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
1224 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1225 | 1225 | EE_Error::add_error( |
1226 | 1226 | sprintf( |
1227 | 1227 | __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | public function transaction() |
1394 | 1394 | { |
1395 | 1395 | $transaction = $this->get_first_related('Transaction'); |
1396 | - if (! $transaction instanceof \EE_Transaction) { |
|
1396 | + if ( ! $transaction instanceof \EE_Transaction) { |
|
1397 | 1397 | throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
1398 | 1398 | } |
1399 | 1399 | return $transaction; |
@@ -1440,11 +1440,11 @@ discard block |
||
1440 | 1440 | EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
1441 | 1441 | return; |
1442 | 1442 | } |
1443 | - if (! $this->reg_code()) { |
|
1443 | + if ( ! $this->reg_code()) { |
|
1444 | 1444 | parent::set('REG_code', $REG_code, $use_default); |
1445 | 1445 | } else { |
1446 | 1446 | EE_Error::doing_it_wrong( |
1447 | - __CLASS__ . '::' . __FUNCTION__, |
|
1447 | + __CLASS__.'::'.__FUNCTION__, |
|
1448 | 1448 | __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
1449 | 1449 | '4.6.0' |
1450 | 1450 | ); |
@@ -1590,7 +1590,7 @@ discard block |
||
1590 | 1590 | break; |
1591 | 1591 | } |
1592 | 1592 | } |
1593 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1593 | + if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1594 | 1594 | throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
1595 | 1595 | } |
1596 | 1596 | return $line_item; |
@@ -14,248 +14,248 @@ |
||
14 | 14 | abstract class EE_Form_Section_Layout_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Form form section to lay out |
|
19 | - * |
|
20 | - * @var EE_Form_Section_Proper |
|
21 | - */ |
|
22 | - protected $_form_section; |
|
23 | - |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * __construct |
|
28 | - */ |
|
29 | - function __construct() |
|
30 | - { |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * The form section on which this strategy is to perform |
|
37 | - * |
|
38 | - * @param EE_Form_Section_Proper $form |
|
39 | - */ |
|
40 | - public function _construct_finalize(EE_Form_Section_Proper $form) |
|
41 | - { |
|
42 | - $this->_form_section = $form; |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return \EE_Form_Section_Proper |
|
49 | - */ |
|
50 | - public function form_section() |
|
51 | - { |
|
52 | - return $this->_form_section; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Also has teh side effect of enqueuing any needed JS and CSS for |
|
59 | - * this form. |
|
60 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
61 | - * proper subsections. |
|
62 | - * Returns the HTML |
|
63 | - * |
|
64 | - * @return string HTML for displaying |
|
65 | - */ |
|
66 | - public function layout_form() |
|
67 | - { |
|
68 | - $html = ''; |
|
69 | - // layout_form_begin |
|
70 | - $html .= apply_filters( |
|
71 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
72 | - $this->layout_form_begin(), |
|
73 | - $this->_form_section |
|
74 | - ); |
|
75 | - // layout_form_loop |
|
76 | - $html .= apply_filters( |
|
77 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
78 | - $this->layout_form_loop(), |
|
79 | - $this->_form_section |
|
80 | - ); |
|
81 | - // layout_form_end |
|
82 | - $html .= apply_filters( |
|
83 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
84 | - $this->layout_form_end(), |
|
85 | - $this->_form_section |
|
86 | - ); |
|
87 | - $html = $this->add_form_section_hooks_and_filters($html); |
|
88 | - return $html; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function layout_form_loop() |
|
97 | - { |
|
98 | - $html = ''; |
|
99 | - foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
100 | - if ($subsection instanceof EE_Form_Input_Base) { |
|
101 | - $html .= apply_filters( |
|
102 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
103 | - $this->layout_input($subsection), |
|
104 | - $this->_form_section, |
|
105 | - $subsection |
|
106 | - ); |
|
107 | - } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
108 | - $html .= apply_filters( |
|
109 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
110 | - $this->layout_subsection($subsection), |
|
111 | - $this->_form_section, |
|
112 | - $subsection |
|
113 | - ); |
|
114 | - } |
|
115 | - } |
|
116 | - return $html; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
123 | - * |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - abstract public function layout_form_begin(); |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
132 | - * |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - abstract public function layout_form_end(); |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
141 | - * is putting each input in a row of its own, this should probably be called by a |
|
142 | - * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
143 | - * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
144 | - * customize the form's layout, but would like to make use of it for laying out |
|
145 | - * 'easy-to-layout' inputs |
|
146 | - * |
|
147 | - * @param EE_Form_Input_Base $input |
|
148 | - * @return string html |
|
149 | - */ |
|
150 | - abstract public function layout_input($input); |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * Similar to layout_input(), should be used internally by layout_form() within a |
|
156 | - * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
157 | - * that the proper subsection will layout its container, label, etc on its own. |
|
158 | - * |
|
159 | - * @param EE_Form_Section_Base $subsection |
|
160 | - * @return string html |
|
161 | - */ |
|
162 | - abstract public function layout_subsection($subsection); |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Gets the HTML for the label tag and its contents for the input |
|
168 | - * |
|
169 | - * @param EE_Form_Input_Base $input |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function display_label($input) |
|
173 | - { |
|
174 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
175 | - $label_text = $input->required() |
|
176 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
177 | - : $input->html_label_text(); |
|
178 | - return '<label id="' |
|
179 | - . $input->html_label_id() |
|
180 | - . '" class="' |
|
181 | - . $class |
|
182 | - . '" style="' |
|
183 | - . $input->html_label_style() |
|
184 | - . '" for="' . $input->html_name() |
|
185 | - . '">' |
|
186 | - . $label_text |
|
187 | - . '</label>'; |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * returns the HTML for the server-side validation errors for the specified input |
|
194 | - * Note that if JS is enabled, it should remove these and instead |
|
195 | - * populate the form's errors in the jquery validate fashion |
|
196 | - * using the localized data provided to the JS |
|
197 | - * |
|
198 | - * @param EE_Form_Input_Base $input |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function display_errors($input) |
|
202 | - { |
|
203 | - if ($input->get_validation_errors()) { |
|
204 | - return "<label id='" |
|
205 | - . $input->html_id() |
|
206 | - . "-error' class='error' for='{$input->html_name()}'>" |
|
207 | - . $input->get_validation_error_string() |
|
208 | - . "</label>"; |
|
209 | - } else { |
|
210 | - return ''; |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * Displays the help span for the specified input |
|
218 | - * |
|
219 | - * @param EE_Form_Input_Base $input |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function display_help_text($input) |
|
223 | - { |
|
224 | - if ($input->html_help_text() != '') { |
|
225 | - $tag = is_admin() ? 'p' : 'span'; |
|
226 | - return '<' |
|
227 | - . $tag |
|
228 | - . ' id="' |
|
229 | - . $input->html_id() |
|
230 | - . '-help" class="' |
|
231 | - . $input->html_help_class() |
|
232 | - . '" style="' |
|
233 | - . $input->html_help_style() |
|
234 | - . '">' |
|
235 | - . $input->html_help_text() |
|
236 | - . '</' |
|
237 | - . $tag |
|
238 | - . '>'; |
|
239 | - } |
|
240 | - return ''; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Does an action and hook onto the end of teh form |
|
247 | - * |
|
248 | - * @param string $html |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function add_form_section_hooks_and_filters($html) |
|
252 | - { |
|
253 | - // replace dashes and spaces with underscores |
|
254 | - $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
255 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
256 | - $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
257 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
258 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
259 | - return $html; |
|
260 | - } |
|
17 | + /** |
|
18 | + * Form form section to lay out |
|
19 | + * |
|
20 | + * @var EE_Form_Section_Proper |
|
21 | + */ |
|
22 | + protected $_form_section; |
|
23 | + |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * __construct |
|
28 | + */ |
|
29 | + function __construct() |
|
30 | + { |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * The form section on which this strategy is to perform |
|
37 | + * |
|
38 | + * @param EE_Form_Section_Proper $form |
|
39 | + */ |
|
40 | + public function _construct_finalize(EE_Form_Section_Proper $form) |
|
41 | + { |
|
42 | + $this->_form_section = $form; |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return \EE_Form_Section_Proper |
|
49 | + */ |
|
50 | + public function form_section() |
|
51 | + { |
|
52 | + return $this->_form_section; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Also has teh side effect of enqueuing any needed JS and CSS for |
|
59 | + * this form. |
|
60 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
61 | + * proper subsections. |
|
62 | + * Returns the HTML |
|
63 | + * |
|
64 | + * @return string HTML for displaying |
|
65 | + */ |
|
66 | + public function layout_form() |
|
67 | + { |
|
68 | + $html = ''; |
|
69 | + // layout_form_begin |
|
70 | + $html .= apply_filters( |
|
71 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
72 | + $this->layout_form_begin(), |
|
73 | + $this->_form_section |
|
74 | + ); |
|
75 | + // layout_form_loop |
|
76 | + $html .= apply_filters( |
|
77 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
78 | + $this->layout_form_loop(), |
|
79 | + $this->_form_section |
|
80 | + ); |
|
81 | + // layout_form_end |
|
82 | + $html .= apply_filters( |
|
83 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
84 | + $this->layout_form_end(), |
|
85 | + $this->_form_section |
|
86 | + ); |
|
87 | + $html = $this->add_form_section_hooks_and_filters($html); |
|
88 | + return $html; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function layout_form_loop() |
|
97 | + { |
|
98 | + $html = ''; |
|
99 | + foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
100 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
101 | + $html .= apply_filters( |
|
102 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
103 | + $this->layout_input($subsection), |
|
104 | + $this->_form_section, |
|
105 | + $subsection |
|
106 | + ); |
|
107 | + } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
108 | + $html .= apply_filters( |
|
109 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
110 | + $this->layout_subsection($subsection), |
|
111 | + $this->_form_section, |
|
112 | + $subsection |
|
113 | + ); |
|
114 | + } |
|
115 | + } |
|
116 | + return $html; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
123 | + * |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + abstract public function layout_form_begin(); |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
132 | + * |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + abstract public function layout_form_end(); |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
141 | + * is putting each input in a row of its own, this should probably be called by a |
|
142 | + * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
143 | + * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
144 | + * customize the form's layout, but would like to make use of it for laying out |
|
145 | + * 'easy-to-layout' inputs |
|
146 | + * |
|
147 | + * @param EE_Form_Input_Base $input |
|
148 | + * @return string html |
|
149 | + */ |
|
150 | + abstract public function layout_input($input); |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * Similar to layout_input(), should be used internally by layout_form() within a |
|
156 | + * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
157 | + * that the proper subsection will layout its container, label, etc on its own. |
|
158 | + * |
|
159 | + * @param EE_Form_Section_Base $subsection |
|
160 | + * @return string html |
|
161 | + */ |
|
162 | + abstract public function layout_subsection($subsection); |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Gets the HTML for the label tag and its contents for the input |
|
168 | + * |
|
169 | + * @param EE_Form_Input_Base $input |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function display_label($input) |
|
173 | + { |
|
174 | + $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
175 | + $label_text = $input->required() |
|
176 | + ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
177 | + : $input->html_label_text(); |
|
178 | + return '<label id="' |
|
179 | + . $input->html_label_id() |
|
180 | + . '" class="' |
|
181 | + . $class |
|
182 | + . '" style="' |
|
183 | + . $input->html_label_style() |
|
184 | + . '" for="' . $input->html_name() |
|
185 | + . '">' |
|
186 | + . $label_text |
|
187 | + . '</label>'; |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * returns the HTML for the server-side validation errors for the specified input |
|
194 | + * Note that if JS is enabled, it should remove these and instead |
|
195 | + * populate the form's errors in the jquery validate fashion |
|
196 | + * using the localized data provided to the JS |
|
197 | + * |
|
198 | + * @param EE_Form_Input_Base $input |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function display_errors($input) |
|
202 | + { |
|
203 | + if ($input->get_validation_errors()) { |
|
204 | + return "<label id='" |
|
205 | + . $input->html_id() |
|
206 | + . "-error' class='error' for='{$input->html_name()}'>" |
|
207 | + . $input->get_validation_error_string() |
|
208 | + . "</label>"; |
|
209 | + } else { |
|
210 | + return ''; |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * Displays the help span for the specified input |
|
218 | + * |
|
219 | + * @param EE_Form_Input_Base $input |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function display_help_text($input) |
|
223 | + { |
|
224 | + if ($input->html_help_text() != '') { |
|
225 | + $tag = is_admin() ? 'p' : 'span'; |
|
226 | + return '<' |
|
227 | + . $tag |
|
228 | + . ' id="' |
|
229 | + . $input->html_id() |
|
230 | + . '-help" class="' |
|
231 | + . $input->html_help_class() |
|
232 | + . '" style="' |
|
233 | + . $input->html_help_style() |
|
234 | + . '">' |
|
235 | + . $input->html_help_text() |
|
236 | + . '</' |
|
237 | + . $tag |
|
238 | + . '>'; |
|
239 | + } |
|
240 | + return ''; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Does an action and hook onto the end of teh form |
|
247 | + * |
|
248 | + * @param string $html |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function add_form_section_hooks_and_filters($html) |
|
252 | + { |
|
253 | + // replace dashes and spaces with underscores |
|
254 | + $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
255 | + do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
256 | + $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
257 | + $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
258 | + $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
259 | + return $html; |
|
260 | + } |
|
261 | 261 | } |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | $html = ''; |
69 | 69 | // layout_form_begin |
70 | 70 | $html .= apply_filters( |
71 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
71 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(), |
|
72 | 72 | $this->layout_form_begin(), |
73 | 73 | $this->_form_section |
74 | 74 | ); |
75 | 75 | // layout_form_loop |
76 | 76 | $html .= apply_filters( |
77 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
77 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(), |
|
78 | 78 | $this->layout_form_loop(), |
79 | 79 | $this->_form_section |
80 | 80 | ); |
81 | 81 | // layout_form_end |
82 | 82 | $html .= apply_filters( |
83 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
83 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(), |
|
84 | 84 | $this->layout_form_end(), |
85 | 85 | $this->_form_section |
86 | 86 | ); |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | foreach ($this->_form_section->subsections() as $name => $subsection) { |
100 | 100 | if ($subsection instanceof EE_Form_Input_Base) { |
101 | 101 | $html .= apply_filters( |
102 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
102 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'.$name.'__in_'.$this->_form_section->name(), |
|
103 | 103 | $this->layout_input($subsection), |
104 | 104 | $this->_form_section, |
105 | 105 | $subsection |
106 | 106 | ); |
107 | 107 | } elseif ($subsection instanceof EE_Form_Section_Base) { |
108 | 108 | $html .= apply_filters( |
109 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
109 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'.$name.'__in_'.$this->_form_section->name(), |
|
110 | 110 | $this->layout_subsection($subsection), |
111 | 111 | $this->_form_section, |
112 | 112 | $subsection |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function display_label($input) |
173 | 173 | { |
174 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
174 | + $class = $input->required() ? 'ee-required-label '.$input->html_label_class() : $input->html_label_class(); |
|
175 | 175 | $label_text = $input->required() |
176 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
176 | + ? $input->html_label_text().'<span class="ee-asterisk">*</span>' |
|
177 | 177 | : $input->html_label_text(); |
178 | 178 | return '<label id="' |
179 | 179 | . $input->html_label_id() |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | . $class |
182 | 182 | . '" style="' |
183 | 183 | . $input->html_label_style() |
184 | - . '" for="' . $input->html_name() |
|
184 | + . '" for="'.$input->html_name() |
|
185 | 185 | . '">' |
186 | 186 | . $label_text |
187 | 187 | . '</label>'; |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | { |
253 | 253 | // replace dashes and spaces with underscores |
254 | 254 | $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
255 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
256 | - $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
257 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
258 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
255 | + do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section); |
|
256 | + $html = apply_filters('AFEE__Form_Section_Layout__'.$hook_name.'__html', $html, $this->_form_section); |
|
257 | + $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->'; |
|
258 | + $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->'; |
|
259 | 259 | return $html; |
260 | 260 | } |
261 | 261 | } |
@@ -9,69 +9,69 @@ |
||
9 | 9 | class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * Overriding the parent table layout to include <tbody> tags |
|
14 | - * |
|
15 | - * @param array $additional_args |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function layout_form_begin($additional_args = array()) |
|
19 | - { |
|
20 | - $this->_form_section->set_html_class('form-table'); |
|
21 | - return parent::layout_form_begin($additional_args); |
|
22 | - } |
|
12 | + /** |
|
13 | + * Overriding the parent table layout to include <tbody> tags |
|
14 | + * |
|
15 | + * @param array $additional_args |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function layout_form_begin($additional_args = array()) |
|
19 | + { |
|
20 | + $this->_form_section->set_html_class('form-table'); |
|
21 | + return parent::layout_form_begin($additional_args); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Lays out a row for the subsection |
|
28 | - * |
|
29 | - * @param EE_Form_Section_Proper $form_section |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function layout_subsection($form_section) |
|
33 | - { |
|
34 | - if ($form_section instanceof EE_Form_Section_Proper) { |
|
35 | - return EEH_HTML::no_row($form_section->get_html(), 2); |
|
36 | - } elseif ($form_section instanceof EE_Form_Section_HTML) { |
|
37 | - return EEH_HTML::no_row($form_section->get_html(), 2); |
|
38 | - } |
|
39 | - return ''; |
|
40 | - } |
|
26 | + /** |
|
27 | + * Lays out a row for the subsection |
|
28 | + * |
|
29 | + * @param EE_Form_Section_Proper $form_section |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function layout_subsection($form_section) |
|
33 | + { |
|
34 | + if ($form_section instanceof EE_Form_Section_Proper) { |
|
35 | + return EEH_HTML::no_row($form_section->get_html(), 2); |
|
36 | + } elseif ($form_section instanceof EE_Form_Section_HTML) { |
|
37 | + return EEH_HTML::no_row($form_section->get_html(), 2); |
|
38 | + } |
|
39 | + return ''; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Lays out the row for the input, including label and errors |
|
46 | - * |
|
47 | - * @param EE_Form_Input_Base $input |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function layout_input($input) |
|
51 | - { |
|
52 | - if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
53 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
54 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
55 | - ) { |
|
56 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
57 | - } |
|
58 | - if ($input instanceof EE_Text_Area_Input) { |
|
59 | - $input->set_rows(4); |
|
60 | - $input->set_cols(60); |
|
61 | - } |
|
62 | - $input_html = $input->get_html_for_input(); |
|
63 | - // maybe add errors and help text ? |
|
64 | - $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
65 | - $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
66 | - //overriding parent to add wp admin specific things. |
|
67 | - $html = ''; |
|
68 | - if ($input instanceof EE_Hidden_Input) { |
|
69 | - $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
|
70 | - } else { |
|
71 | - $html .= EEH_HTML::tr( |
|
72 | - EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
73 | - ); |
|
74 | - } |
|
75 | - return $html; |
|
76 | - } |
|
44 | + /** |
|
45 | + * Lays out the row for the input, including label and errors |
|
46 | + * |
|
47 | + * @param EE_Form_Input_Base $input |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function layout_input($input) |
|
51 | + { |
|
52 | + if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
53 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
54 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
55 | + ) { |
|
56 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
57 | + } |
|
58 | + if ($input instanceof EE_Text_Area_Input) { |
|
59 | + $input->set_rows(4); |
|
60 | + $input->set_cols(60); |
|
61 | + } |
|
62 | + $input_html = $input->get_html_for_input(); |
|
63 | + // maybe add errors and help text ? |
|
64 | + $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
65 | + $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
66 | + //overriding parent to add wp admin specific things. |
|
67 | + $html = ''; |
|
68 | + if ($input instanceof EE_Hidden_Input) { |
|
69 | + $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
|
70 | + } else { |
|
71 | + $html .= EEH_HTML::tr( |
|
72 | + EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
73 | + ); |
|
74 | + } |
|
75 | + return $html; |
|
76 | + } |
|
77 | 77 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
54 | 54 | || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
55 | 55 | ) { |
56 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
56 | + $input->set_html_class($input->html_class().' large-text'); |
|
57 | 57 | } |
58 | 58 | if ($input instanceof EE_Text_Area_Input) { |
59 | 59 | $input->set_rows(4); |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | } |
62 | 62 | $input_html = $input->get_html_for_input(); |
63 | 63 | // maybe add errors and help text ? |
64 | - $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
65 | - $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
64 | + $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl().$input->get_html_for_errors() : ''; |
|
65 | + $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
66 | 66 | //overriding parent to add wp admin specific things. |
67 | 67 | $html = ''; |
68 | 68 | if ($input instanceof EE_Hidden_Input) { |
69 | 69 | $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
70 | 70 | } else { |
71 | 71 | $html .= EEH_HTML::tr( |
72 | - EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
72 | + EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"').EEH_HTML::td($input_html) |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | return $html; |
@@ -14,123 +14,123 @@ |
||
14 | 14 | class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * opening div tag for a form |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function layout_form_begin() |
|
23 | - { |
|
24 | - return EEH_HTML::div( |
|
25 | - '', |
|
26 | - $this->_form_section->html_id(), |
|
27 | - $this->_form_section->html_class(), |
|
28 | - $this->_form_section->html_style() |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Lays out the row for the input, including label and errors |
|
36 | - * |
|
37 | - * @param EE_Form_Input_Base $input |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function layout_input($input) |
|
41 | - { |
|
42 | - $html = ''; |
|
43 | - if ($input instanceof EE_Hidden_Input) { |
|
44 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
45 | - } elseif ($input instanceof EE_Submit_Input) { |
|
46 | - $html .= EEH_HTML::div( |
|
47 | - $input->get_html_for_input(), |
|
48 | - $input->html_id() . '-submit-dv', |
|
49 | - $input->html_class() . '-submit-dv' |
|
50 | - ); |
|
51 | - } elseif ($input instanceof EE_Select_Input) { |
|
52 | - $html .= EEH_HTML::div( |
|
53 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
54 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
55 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
56 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
57 | - $input->html_id() . '-input-dv', |
|
58 | - $input->html_class() . '-input-dv' |
|
59 | - ); |
|
60 | - } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
61 | - $html .= EEH_HTML::div( |
|
62 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
64 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
65 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
66 | - $input->html_id() . '-input-dv', |
|
67 | - $input->html_class() . '-input-dv' |
|
68 | - ); |
|
69 | - } else { |
|
70 | - $html .= EEH_HTML::div( |
|
71 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
73 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
74 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
75 | - $input->html_id() . '-input-dv', |
|
76 | - $input->html_class() . '-input-dv' |
|
77 | - ); |
|
78 | - } |
|
79 | - return $html; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * _display_label_for_option_type_question |
|
86 | - * Gets the HTML for the 'label', which is just text for this (because labels |
|
87 | - * should be for each input) |
|
88 | - * |
|
89 | - * @param EE_Form_Input_With_Options_Base $input |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
93 | - { |
|
94 | - if ($input->display_html_label_text() != '') { |
|
95 | - $class = $input->required() |
|
96 | - ? 'ee-required-label ' . $input->html_label_class() |
|
97 | - : $input->html_label_class(); |
|
98 | - $label_text = $input->required() |
|
99 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
100 | - : $input->html_label_text(); |
|
101 | - $html = '<div id="' . $input->html_label_id() . '"'; |
|
102 | - $html .= ' class="' . $class . '"'; |
|
103 | - $html .= ' style="' . $input->html_label_style() . '">'; |
|
104 | - $html .= $label_text . '</div>'; |
|
105 | - return $html; |
|
106 | - } else { |
|
107 | - return ''; |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Lays out a row for the subsection |
|
115 | - * |
|
116 | - * @param EE_Form_Section_Proper $form_section |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function layout_subsection($form_section) |
|
120 | - { |
|
121 | - // d( $form_section ); |
|
122 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * closing div tag for a form |
|
129 | - * |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - public function layout_form_end() |
|
133 | - { |
|
134 | - return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
135 | - } |
|
17 | + /** |
|
18 | + * opening div tag for a form |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function layout_form_begin() |
|
23 | + { |
|
24 | + return EEH_HTML::div( |
|
25 | + '', |
|
26 | + $this->_form_section->html_id(), |
|
27 | + $this->_form_section->html_class(), |
|
28 | + $this->_form_section->html_style() |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Lays out the row for the input, including label and errors |
|
36 | + * |
|
37 | + * @param EE_Form_Input_Base $input |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function layout_input($input) |
|
41 | + { |
|
42 | + $html = ''; |
|
43 | + if ($input instanceof EE_Hidden_Input) { |
|
44 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
45 | + } elseif ($input instanceof EE_Submit_Input) { |
|
46 | + $html .= EEH_HTML::div( |
|
47 | + $input->get_html_for_input(), |
|
48 | + $input->html_id() . '-submit-dv', |
|
49 | + $input->html_class() . '-submit-dv' |
|
50 | + ); |
|
51 | + } elseif ($input instanceof EE_Select_Input) { |
|
52 | + $html .= EEH_HTML::div( |
|
53 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
54 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
55 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
56 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
57 | + $input->html_id() . '-input-dv', |
|
58 | + $input->html_class() . '-input-dv' |
|
59 | + ); |
|
60 | + } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
61 | + $html .= EEH_HTML::div( |
|
62 | + EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
63 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
64 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
65 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
66 | + $input->html_id() . '-input-dv', |
|
67 | + $input->html_class() . '-input-dv' |
|
68 | + ); |
|
69 | + } else { |
|
70 | + $html .= EEH_HTML::div( |
|
71 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
72 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
73 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
74 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
75 | + $input->html_id() . '-input-dv', |
|
76 | + $input->html_class() . '-input-dv' |
|
77 | + ); |
|
78 | + } |
|
79 | + return $html; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * _display_label_for_option_type_question |
|
86 | + * Gets the HTML for the 'label', which is just text for this (because labels |
|
87 | + * should be for each input) |
|
88 | + * |
|
89 | + * @param EE_Form_Input_With_Options_Base $input |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
93 | + { |
|
94 | + if ($input->display_html_label_text() != '') { |
|
95 | + $class = $input->required() |
|
96 | + ? 'ee-required-label ' . $input->html_label_class() |
|
97 | + : $input->html_label_class(); |
|
98 | + $label_text = $input->required() |
|
99 | + ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
100 | + : $input->html_label_text(); |
|
101 | + $html = '<div id="' . $input->html_label_id() . '"'; |
|
102 | + $html .= ' class="' . $class . '"'; |
|
103 | + $html .= ' style="' . $input->html_label_style() . '">'; |
|
104 | + $html .= $label_text . '</div>'; |
|
105 | + return $html; |
|
106 | + } else { |
|
107 | + return ''; |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Lays out a row for the subsection |
|
115 | + * |
|
116 | + * @param EE_Form_Section_Proper $form_section |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function layout_subsection($form_section) |
|
120 | + { |
|
121 | + // d( $form_section ); |
|
122 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * closing div tag for a form |
|
129 | + * |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + public function layout_form_end() |
|
133 | + { |
|
134 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
135 | + } |
|
136 | 136 | } |
137 | 137 | \ No newline at end of file |
@@ -41,39 +41,39 @@ discard block |
||
41 | 41 | { |
42 | 42 | $html = ''; |
43 | 43 | if ($input instanceof EE_Hidden_Input) { |
44 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
44 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
45 | 45 | } elseif ($input instanceof EE_Submit_Input) { |
46 | 46 | $html .= EEH_HTML::div( |
47 | 47 | $input->get_html_for_input(), |
48 | - $input->html_id() . '-submit-dv', |
|
49 | - $input->html_class() . '-submit-dv' |
|
48 | + $input->html_id().'-submit-dv', |
|
49 | + $input->html_class().'-submit-dv' |
|
50 | 50 | ); |
51 | 51 | } elseif ($input instanceof EE_Select_Input) { |
52 | 52 | $html .= EEH_HTML::div( |
53 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
54 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
55 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
56 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
57 | - $input->html_id() . '-input-dv', |
|
58 | - $input->html_class() . '-input-dv' |
|
53 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
54 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
55 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
56 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
57 | + $input->html_id().'-input-dv', |
|
58 | + $input->html_class().'-input-dv' |
|
59 | 59 | ); |
60 | 60 | } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
61 | 61 | $html .= EEH_HTML::div( |
62 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
64 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
65 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
66 | - $input->html_id() . '-input-dv', |
|
67 | - $input->html_class() . '-input-dv' |
|
62 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
63 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
64 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
65 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
66 | + $input->html_id().'-input-dv', |
|
67 | + $input->html_class().'-input-dv' |
|
68 | 68 | ); |
69 | 69 | } else { |
70 | 70 | $html .= EEH_HTML::div( |
71 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
73 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
74 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
75 | - $input->html_id() . '-input-dv', |
|
76 | - $input->html_class() . '-input-dv' |
|
71 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
72 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
73 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
74 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
75 | + $input->html_id().'-input-dv', |
|
76 | + $input->html_class().'-input-dv' |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | return $html; |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | { |
94 | 94 | if ($input->display_html_label_text() != '') { |
95 | 95 | $class = $input->required() |
96 | - ? 'ee-required-label ' . $input->html_label_class() |
|
96 | + ? 'ee-required-label '.$input->html_label_class() |
|
97 | 97 | : $input->html_label_class(); |
98 | 98 | $label_text = $input->required() |
99 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
99 | + ? $input->html_label_text().'<span class="ee-asterisk">*</span>' |
|
100 | 100 | : $input->html_label_text(); |
101 | - $html = '<div id="' . $input->html_label_id() . '"'; |
|
102 | - $html .= ' class="' . $class . '"'; |
|
103 | - $html .= ' style="' . $input->html_label_style() . '">'; |
|
104 | - $html .= $label_text . '</div>'; |
|
101 | + $html = '<div id="'.$input->html_label_id().'"'; |
|
102 | + $html .= ' class="'.$class.'"'; |
|
103 | + $html .= ' style="'.$input->html_label_style().'">'; |
|
104 | + $html .= $label_text.'</div>'; |
|
105 | 105 | return $html; |
106 | 106 | } else { |
107 | 107 | return ''; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function layout_subsection($form_section) |
120 | 120 | { |
121 | 121 | // d( $form_section ); |
122 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
122 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 |
@@ -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 | |
@@ -16,109 +16,109 @@ discard block |
||
16 | 16 | class EE_Fieldset_Section_Layout extends EE_Div_Per_Section_Layout |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * legend_class |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_legend_class; |
|
25 | - |
|
26 | - /** |
|
27 | - * legend_text |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $_legend_text; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * construct |
|
37 | - * |
|
38 | - * @param array $options |
|
39 | - */ |
|
40 | - public function __construct($options = array()) |
|
41 | - { |
|
42 | - foreach ($options as $key => $value) { |
|
43 | - $key = '_' . $key; |
|
44 | - if (property_exists($this, $key)) { |
|
45 | - $this->{$key} = $value; |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * opening div tag for a form |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function layout_form_begin() |
|
58 | - { |
|
59 | - $html = EEH_HTML::nl(1) |
|
60 | - . '<fieldset id="' |
|
61 | - . $this->_form_section->html_id() |
|
62 | - . '" class="' |
|
63 | - . $this->_form_section->html_class() |
|
64 | - . '" style="' |
|
65 | - . $this->_form_section->html_style() |
|
66 | - . '">'; |
|
67 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
68 | - return $html; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * closing div tag for a form |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function layout_form_end() |
|
79 | - { |
|
80 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $legend_class |
|
87 | - */ |
|
88 | - public function set_legend_class($legend_class) |
|
89 | - { |
|
90 | - $this->_legend_class = $legend_class; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function legend_class() |
|
99 | - { |
|
100 | - return $this->_legend_class; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @param string $legend_text |
|
107 | - */ |
|
108 | - public function set_legend_text($legend_text) |
|
109 | - { |
|
110 | - $this->_legend_text = $legend_text; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function legend_text() |
|
119 | - { |
|
120 | - return $this->_legend_text; |
|
121 | - } |
|
19 | + /** |
|
20 | + * legend_class |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_legend_class; |
|
25 | + |
|
26 | + /** |
|
27 | + * legend_text |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $_legend_text; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * construct |
|
37 | + * |
|
38 | + * @param array $options |
|
39 | + */ |
|
40 | + public function __construct($options = array()) |
|
41 | + { |
|
42 | + foreach ($options as $key => $value) { |
|
43 | + $key = '_' . $key; |
|
44 | + if (property_exists($this, $key)) { |
|
45 | + $this->{$key} = $value; |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * opening div tag for a form |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function layout_form_begin() |
|
58 | + { |
|
59 | + $html = EEH_HTML::nl(1) |
|
60 | + . '<fieldset id="' |
|
61 | + . $this->_form_section->html_id() |
|
62 | + . '" class="' |
|
63 | + . $this->_form_section->html_class() |
|
64 | + . '" style="' |
|
65 | + . $this->_form_section->html_style() |
|
66 | + . '">'; |
|
67 | + $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
68 | + return $html; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * closing div tag for a form |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function layout_form_end() |
|
79 | + { |
|
80 | + return EEH_HTML::nl(-1) . '</fieldset>'; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $legend_class |
|
87 | + */ |
|
88 | + public function set_legend_class($legend_class) |
|
89 | + { |
|
90 | + $this->_legend_class = $legend_class; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function legend_class() |
|
99 | + { |
|
100 | + return $this->_legend_class; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @param string $legend_text |
|
107 | + */ |
|
108 | + public function set_legend_text($legend_text) |
|
109 | + { |
|
110 | + $this->_legend_text = $legend_text; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function legend_text() |
|
119 | + { |
|
120 | + return $this->_legend_text; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | 124 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function __construct($options = array()) |
41 | 41 | { |
42 | 42 | foreach ($options as $key => $value) { |
43 | - $key = '_' . $key; |
|
43 | + $key = '_'.$key; |
|
44 | 44 | if (property_exists($this, $key)) { |
45 | 45 | $this->{$key} = $value; |
46 | 46 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | . '" style="' |
65 | 65 | . $this->_form_section->html_style() |
66 | 66 | . '">'; |
67 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
67 | + $html .= '<legend class="'.$this->legend_class().'">'.$this->legend_text().'</legend>'; |
|
68 | 68 | return $html; |
69 | 69 | } |
70 | 70 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function layout_form_end() |
79 | 79 | { |
80 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
80 | + return EEH_HTML::nl(-1).'</fieldset>'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 |
@@ -15,117 +15,117 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
20 | - * strategy. |
|
21 | - * |
|
22 | - * @var bool |
|
23 | - */ |
|
24 | - protected $_use_break_tags = true; |
|
25 | - |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * EE_No_Layout constructor. |
|
30 | - * |
|
31 | - * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
32 | - * property on the class. |
|
33 | - */ |
|
34 | - public function __construct($options = array()) |
|
35 | - { |
|
36 | - $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
37 | - ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
38 | - : $this->_use_break_tags; |
|
39 | - parent::__construct(); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Add line break at beginning of form |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function layout_form_begin() |
|
50 | - { |
|
51 | - return EEH_HTML::nl(1); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Lays out the row for the input, including label and errors |
|
58 | - * |
|
59 | - * @param EE_Form_Input_Base $input |
|
60 | - * @return string |
|
61 | - * @throws \EE_Error |
|
62 | - */ |
|
63 | - public function layout_input($input) |
|
64 | - { |
|
65 | - $html = ''; |
|
66 | - if ($input instanceof EE_Hidden_Input) { |
|
67 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
68 | - } elseif ($input instanceof EE_Submit_Input) { |
|
69 | - $html .= $this->br(); |
|
70 | - $html .= $input->get_html_for_input(); |
|
71 | - } elseif ($input instanceof EE_Select_Input) { |
|
72 | - $html .= $this->br(); |
|
73 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
74 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
77 | - $html .= $this->br(); |
|
78 | - } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
79 | - $html .= $this->br(); |
|
80 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
83 | - } else { |
|
84 | - $html .= $this->br(); |
|
85 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
86 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
87 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
88 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
89 | - } |
|
90 | - $html .= EEH_HTML::nl(-1); |
|
91 | - return $html; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Lays out a row for the subsection |
|
98 | - * |
|
99 | - * @param EE_Form_Section_Proper $form_section |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function layout_subsection($form_section) |
|
103 | - { |
|
104 | - // d( $form_section ); |
|
105 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Add line break at end of form. |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function layout_form_end() |
|
116 | - { |
|
117 | - return EEH_HTML::nl(-1); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - protected function br() |
|
128 | - { |
|
129 | - return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
130 | - } |
|
18 | + /** |
|
19 | + * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
20 | + * strategy. |
|
21 | + * |
|
22 | + * @var bool |
|
23 | + */ |
|
24 | + protected $_use_break_tags = true; |
|
25 | + |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * EE_No_Layout constructor. |
|
30 | + * |
|
31 | + * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
32 | + * property on the class. |
|
33 | + */ |
|
34 | + public function __construct($options = array()) |
|
35 | + { |
|
36 | + $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
37 | + ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
38 | + : $this->_use_break_tags; |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Add line break at beginning of form |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function layout_form_begin() |
|
50 | + { |
|
51 | + return EEH_HTML::nl(1); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Lays out the row for the input, including label and errors |
|
58 | + * |
|
59 | + * @param EE_Form_Input_Base $input |
|
60 | + * @return string |
|
61 | + * @throws \EE_Error |
|
62 | + */ |
|
63 | + public function layout_input($input) |
|
64 | + { |
|
65 | + $html = ''; |
|
66 | + if ($input instanceof EE_Hidden_Input) { |
|
67 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
68 | + } elseif ($input instanceof EE_Submit_Input) { |
|
69 | + $html .= $this->br(); |
|
70 | + $html .= $input->get_html_for_input(); |
|
71 | + } elseif ($input instanceof EE_Select_Input) { |
|
72 | + $html .= $this->br(); |
|
73 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
74 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
77 | + $html .= $this->br(); |
|
78 | + } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
79 | + $html .= $this->br(); |
|
80 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
83 | + } else { |
|
84 | + $html .= $this->br(); |
|
85 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
86 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
87 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
88 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
89 | + } |
|
90 | + $html .= EEH_HTML::nl(-1); |
|
91 | + return $html; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Lays out a row for the subsection |
|
98 | + * |
|
99 | + * @param EE_Form_Section_Proper $form_section |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function layout_subsection($form_section) |
|
103 | + { |
|
104 | + // d( $form_section ); |
|
105 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Add line break at end of form. |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function layout_form_end() |
|
116 | + { |
|
117 | + return EEH_HTML::nl(-1); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + protected function br() |
|
128 | + { |
|
129 | + return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
130 | + } |
|
131 | 131 | } |
@@ -64,28 +64,28 @@ discard block |
||
64 | 64 | { |
65 | 65 | $html = ''; |
66 | 66 | if ($input instanceof EE_Hidden_Input) { |
67 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
67 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
68 | 68 | } elseif ($input instanceof EE_Submit_Input) { |
69 | 69 | $html .= $this->br(); |
70 | 70 | $html .= $input->get_html_for_input(); |
71 | 71 | } elseif ($input instanceof EE_Select_Input) { |
72 | 72 | $html .= $this->br(); |
73 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
74 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
73 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
74 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
75 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
76 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
77 | 77 | $html .= $this->br(); |
78 | 78 | } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
79 | 79 | $html .= $this->br(); |
80 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
80 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
81 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
82 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
83 | 83 | } else { |
84 | 84 | $html .= $this->br(); |
85 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
86 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
87 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
88 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
85 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
86 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
87 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
88 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
89 | 89 | } |
90 | 90 | $html .= EEH_HTML::nl(-1); |
91 | 91 | return $html; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function layout_subsection($form_section) |
103 | 103 | { |
104 | 104 | // d( $form_section ); |
105 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
105 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 |
@@ -5,80 +5,80 @@ |
||
5 | 5 | class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | - * |
|
11 | - * @param array $additional_args |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - public function layout_form_begin($additional_args = array()) |
|
15 | - { |
|
16 | - return EEH_HTML::table( |
|
17 | - '', |
|
18 | - $this->_form_section->html_id(), |
|
19 | - $this->_form_section->html_class(), |
|
20 | - $this->_form_section->html_style() |
|
21 | - ) . EEH_HTML::tbody(); |
|
22 | - } |
|
8 | + /** |
|
9 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | + * |
|
11 | + * @param array $additional_args |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + public function layout_form_begin($additional_args = array()) |
|
15 | + { |
|
16 | + return EEH_HTML::table( |
|
17 | + '', |
|
18 | + $this->_form_section->html_id(), |
|
19 | + $this->_form_section->html_class(), |
|
20 | + $this->_form_section->html_style() |
|
21 | + ) . EEH_HTML::tbody(); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
28 | - * |
|
29 | - * @param array $additional_args |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function layout_form_end($additional_args = array()) |
|
33 | - { |
|
34 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
35 | - } |
|
26 | + /** |
|
27 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
28 | + * |
|
29 | + * @param array $additional_args |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function layout_form_end($additional_args = array()) |
|
33 | + { |
|
34 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Lays out the row for the input, including label and errors |
|
41 | - * |
|
42 | - * @param EE_Form_Input_Base $input |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function layout_input($input) |
|
46 | - { |
|
47 | - $html = ''; |
|
48 | - if ($input instanceof EE_Hidden_Input) { |
|
49 | - $html .= $input->get_html_for_input(); |
|
50 | - } else { |
|
51 | - $html_for_input = $input->get_html_for_input(); |
|
52 | - $html_for_input .= $input->get_html_for_errors() != '' |
|
53 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
54 | - : ''; |
|
55 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
56 | - $html .= EEH_HTML::tr( |
|
57 | - EEH_HTML::th($input->get_html_for_label()) . |
|
58 | - EEH_HTML::td($html_for_input) |
|
59 | - ); |
|
60 | - } |
|
61 | - return $html; |
|
62 | - } |
|
39 | + /** |
|
40 | + * Lays out the row for the input, including label and errors |
|
41 | + * |
|
42 | + * @param EE_Form_Input_Base $input |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function layout_input($input) |
|
46 | + { |
|
47 | + $html = ''; |
|
48 | + if ($input instanceof EE_Hidden_Input) { |
|
49 | + $html .= $input->get_html_for_input(); |
|
50 | + } else { |
|
51 | + $html_for_input = $input->get_html_for_input(); |
|
52 | + $html_for_input .= $input->get_html_for_errors() != '' |
|
53 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
54 | + : ''; |
|
55 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
56 | + $html .= EEH_HTML::tr( |
|
57 | + EEH_HTML::th($input->get_html_for_label()) . |
|
58 | + EEH_HTML::td($html_for_input) |
|
59 | + ); |
|
60 | + } |
|
61 | + return $html; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * Lays out a row for the subsection |
|
68 | - * |
|
69 | - * @param EE_Form_Section_Proper $form_section |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function layout_subsection($form_section) |
|
73 | - { |
|
74 | - $html = ''; |
|
75 | - if ($form_section instanceof EE_Form_Section_HTML) { |
|
76 | - $html .= $form_section->get_html(); |
|
77 | - } else { |
|
78 | - $html .= EEH_HTML::tr( |
|
79 | - EEH_HTML::td($form_section->get_html(), '', '', '', 'colspan="2"') |
|
80 | - ); |
|
81 | - } |
|
82 | - return $html; |
|
83 | - } |
|
66 | + /** |
|
67 | + * Lays out a row for the subsection |
|
68 | + * |
|
69 | + * @param EE_Form_Section_Proper $form_section |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function layout_subsection($form_section) |
|
73 | + { |
|
74 | + $html = ''; |
|
75 | + if ($form_section instanceof EE_Form_Section_HTML) { |
|
76 | + $html .= $form_section->get_html(); |
|
77 | + } else { |
|
78 | + $html .= EEH_HTML::tr( |
|
79 | + EEH_HTML::td($form_section->get_html(), '', '', '', 'colspan="2"') |
|
80 | + ); |
|
81 | + } |
|
82 | + return $html; |
|
83 | + } |
|
84 | 84 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $this->_form_section->html_id(), |
19 | 19 | $this->_form_section->html_class(), |
20 | 20 | $this->_form_section->html_style() |
21 | - ) . EEH_HTML::tbody(); |
|
21 | + ).EEH_HTML::tbody(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function layout_form_end($additional_args = array()) |
33 | 33 | { |
34 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
34 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $html_for_input = $input->get_html_for_input(); |
52 | 52 | $html_for_input .= $input->get_html_for_errors() != '' |
53 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
54 | 54 | : ''; |
55 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
55 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
56 | 56 | $html .= EEH_HTML::tr( |
57 | - EEH_HTML::th($input->get_html_for_label()) . |
|
57 | + EEH_HTML::th($input->get_html_for_label()). |
|
58 | 58 | EEH_HTML::td($html_for_input) |
59 | 59 | ); |
60 | 60 | } |
@@ -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 | |
@@ -27,201 +27,201 @@ discard block |
||
27 | 27 | class EE_Template_Layout extends EE_Div_Per_Section_Layout |
28 | 28 | { |
29 | 29 | |
30 | - protected $_layout_template_file = null; |
|
31 | - |
|
32 | - protected $_layout_begin_template_file = null; |
|
33 | - |
|
34 | - protected $_input_template_file = null; |
|
35 | - |
|
36 | - protected $_subsection_template_file = null; |
|
37 | - |
|
38 | - protected $_layout_end_template_file = null; |
|
39 | - |
|
40 | - protected $_template_args = array(); |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @param array $template_options { |
|
46 | - * @type string $_layout_template_file |
|
47 | - * @type string $_begin_template_file |
|
48 | - * @type string $_input_template_file |
|
49 | - * @type string $_subsection_template_file |
|
50 | - * @type string $_end_template_file |
|
51 | - * @type array $_template_args |
|
52 | - * } |
|
53 | - */ |
|
54 | - public function __construct($template_options = array()) |
|
55 | - { |
|
56 | - // loop through incoming options |
|
57 | - foreach ($template_options as $key => $value) { |
|
58 | - // add underscore to $key to match property names |
|
59 | - $_key = '_' . $key; |
|
60 | - if (property_exists($this, $_key)) { |
|
61 | - $this->{$_key} = $value; |
|
62 | - } |
|
63 | - } |
|
64 | - parent::__construct(); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Also has the side effect of enqueuing any needed JS and CSS for |
|
71 | - * this form. |
|
72 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
73 | - * proper subsections. |
|
74 | - * Returns the HTML |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function layout_form() |
|
79 | - { |
|
80 | - if ($this->_layout_template_file) { |
|
81 | - return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
82 | - } else { |
|
83 | - return parent::layout_form(); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * opening div tag for a form |
|
91 | - * |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function layout_form_begin() |
|
95 | - { |
|
96 | - if ($this->_layout_begin_template_file) { |
|
97 | - return EEH_Template::locate_template( |
|
98 | - $this->_layout_begin_template_file, |
|
99 | - $this->template_args(), |
|
100 | - true, |
|
101 | - true |
|
102 | - ); |
|
103 | - } else { |
|
104 | - return parent::layout_form_begin(); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
112 | - * |
|
113 | - * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
114 | - * @param EE_Form_Input_Base $input |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function layout_input($input) |
|
118 | - { |
|
119 | - if ($this->_input_template_file) { |
|
120 | - return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
121 | - } |
|
122 | - return parent::layout_input($input); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
129 | - * |
|
130 | - * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
131 | - * @param EE_Form_Section_Proper $form_section |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function layout_subsection($form_section) |
|
135 | - { |
|
136 | - if ($this->_subsection_template_file) { |
|
137 | - return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
138 | - } |
|
139 | - return parent::layout_subsection($form_section); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * closing div tag for a form |
|
146 | - * |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function layout_form_end() |
|
150 | - { |
|
151 | - if ($this->_layout_end_template_file) { |
|
152 | - return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
153 | - } else { |
|
154 | - return parent::layout_form_end(); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param array $template_args |
|
162 | - */ |
|
163 | - public function set_template_args($template_args = array()) |
|
164 | - { |
|
165 | - $this->_template_args = $template_args; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param array $template_args |
|
172 | - */ |
|
173 | - public function add_template_args($template_args = array()) |
|
174 | - { |
|
175 | - $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * @return array |
|
182 | - */ |
|
183 | - public function template_args() |
|
184 | - { |
|
185 | - foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
186 | - $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
187 | - if (strpos($subsection_name, '[') !== false) { |
|
188 | - $sub_name = explode('[', $subsection_name); |
|
189 | - $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
190 | - } else { |
|
191 | - $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
192 | - } |
|
193 | - } |
|
194 | - // d( $this->_template_args ); |
|
195 | - return $this->_template_args; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * prep_form_section_key_name |
|
202 | - * |
|
203 | - * @access public |
|
204 | - * @param string $subsection_name |
|
205 | - * @return string |
|
206 | - */ |
|
207 | - public static function prep_form_subsection_key_name($subsection_name = '') |
|
208 | - { |
|
209 | - $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
210 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * get_subform - just a wrapper for the above method |
|
217 | - * |
|
218 | - * @access public |
|
219 | - * @param string $subsection_name |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public static function get_subform_name($subsection_name = '') |
|
223 | - { |
|
224 | - return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
225 | - } |
|
30 | + protected $_layout_template_file = null; |
|
31 | + |
|
32 | + protected $_layout_begin_template_file = null; |
|
33 | + |
|
34 | + protected $_input_template_file = null; |
|
35 | + |
|
36 | + protected $_subsection_template_file = null; |
|
37 | + |
|
38 | + protected $_layout_end_template_file = null; |
|
39 | + |
|
40 | + protected $_template_args = array(); |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @param array $template_options { |
|
46 | + * @type string $_layout_template_file |
|
47 | + * @type string $_begin_template_file |
|
48 | + * @type string $_input_template_file |
|
49 | + * @type string $_subsection_template_file |
|
50 | + * @type string $_end_template_file |
|
51 | + * @type array $_template_args |
|
52 | + * } |
|
53 | + */ |
|
54 | + public function __construct($template_options = array()) |
|
55 | + { |
|
56 | + // loop through incoming options |
|
57 | + foreach ($template_options as $key => $value) { |
|
58 | + // add underscore to $key to match property names |
|
59 | + $_key = '_' . $key; |
|
60 | + if (property_exists($this, $_key)) { |
|
61 | + $this->{$_key} = $value; |
|
62 | + } |
|
63 | + } |
|
64 | + parent::__construct(); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Also has the side effect of enqueuing any needed JS and CSS for |
|
71 | + * this form. |
|
72 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
73 | + * proper subsections. |
|
74 | + * Returns the HTML |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function layout_form() |
|
79 | + { |
|
80 | + if ($this->_layout_template_file) { |
|
81 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
82 | + } else { |
|
83 | + return parent::layout_form(); |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * opening div tag for a form |
|
91 | + * |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function layout_form_begin() |
|
95 | + { |
|
96 | + if ($this->_layout_begin_template_file) { |
|
97 | + return EEH_Template::locate_template( |
|
98 | + $this->_layout_begin_template_file, |
|
99 | + $this->template_args(), |
|
100 | + true, |
|
101 | + true |
|
102 | + ); |
|
103 | + } else { |
|
104 | + return parent::layout_form_begin(); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
112 | + * |
|
113 | + * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
114 | + * @param EE_Form_Input_Base $input |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function layout_input($input) |
|
118 | + { |
|
119 | + if ($this->_input_template_file) { |
|
120 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
121 | + } |
|
122 | + return parent::layout_input($input); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
129 | + * |
|
130 | + * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
131 | + * @param EE_Form_Section_Proper $form_section |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function layout_subsection($form_section) |
|
135 | + { |
|
136 | + if ($this->_subsection_template_file) { |
|
137 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
138 | + } |
|
139 | + return parent::layout_subsection($form_section); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * closing div tag for a form |
|
146 | + * |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function layout_form_end() |
|
150 | + { |
|
151 | + if ($this->_layout_end_template_file) { |
|
152 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
153 | + } else { |
|
154 | + return parent::layout_form_end(); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param array $template_args |
|
162 | + */ |
|
163 | + public function set_template_args($template_args = array()) |
|
164 | + { |
|
165 | + $this->_template_args = $template_args; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param array $template_args |
|
172 | + */ |
|
173 | + public function add_template_args($template_args = array()) |
|
174 | + { |
|
175 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * @return array |
|
182 | + */ |
|
183 | + public function template_args() |
|
184 | + { |
|
185 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
186 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
187 | + if (strpos($subsection_name, '[') !== false) { |
|
188 | + $sub_name = explode('[', $subsection_name); |
|
189 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
190 | + } else { |
|
191 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
192 | + } |
|
193 | + } |
|
194 | + // d( $this->_template_args ); |
|
195 | + return $this->_template_args; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * prep_form_section_key_name |
|
202 | + * |
|
203 | + * @access public |
|
204 | + * @param string $subsection_name |
|
205 | + * @return string |
|
206 | + */ |
|
207 | + public static function prep_form_subsection_key_name($subsection_name = '') |
|
208 | + { |
|
209 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
210 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * get_subform - just a wrapper for the above method |
|
217 | + * |
|
218 | + * @access public |
|
219 | + * @param string $subsection_name |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public static function get_subform_name($subsection_name = '') |
|
223 | + { |
|
224 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | // End of file EE_Template_Layout.strategy.php |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | // loop through incoming options |
57 | 57 | foreach ($template_options as $key => $value) { |
58 | 58 | // add underscore to $key to match property names |
59 | - $_key = '_' . $key; |
|
59 | + $_key = '_'.$key; |
|
60 | 60 | if (property_exists($this, $_key)) { |
61 | 61 | $this->{$_key} = $value; |
62 | 62 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | public static function prep_form_subsection_key_name($subsection_name = '') |
208 | 208 | { |
209 | 209 | $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
210 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
210 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 |
@@ -111,7 +111,7 @@ |
||
111 | 111 | * |
112 | 112 | * @abstract |
113 | 113 | * @access protected |
114 | - * @return array |
|
114 | + * @return string[] |
|
115 | 115 | */ |
116 | 116 | protected function _get_table_filters() |
117 | 117 | { |
@@ -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 | /** |
@@ -22,106 +22,106 @@ discard block |
||
22 | 22 | class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table |
23 | 23 | { |
24 | 24 | |
25 | - private $_status; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @param \Transactions_Admin_Page $admin_page |
|
30 | - */ |
|
31 | - public function __construct(\Transactions_Admin_Page $admin_page) |
|
32 | - { |
|
33 | - parent::__construct($admin_page); |
|
34 | - $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - *_setup_data |
|
40 | - */ |
|
41 | - protected function _setup_data() |
|
42 | - { |
|
43 | - $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
44 | - $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
45 | - $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - *_set_properties |
|
51 | - */ |
|
52 | - protected function _set_properties() |
|
53 | - { |
|
54 | - $this->_wp_list_args = array( |
|
55 | - 'singular' => __('transaction', 'event_espresso'), |
|
56 | - 'plural' => __('transactions', 'event_espresso'), |
|
57 | - 'ajax' => true, |
|
58 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
59 | - ); |
|
60 | - $ID_column_name = __('ID', 'event_espresso'); |
|
61 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
62 | - $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
63 | - $ID_column_name .= '</span> '; |
|
64 | - $this->_columns = array( |
|
65 | - 'TXN_ID' => $ID_column_name, |
|
66 | - 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
67 | - 'TXN_total' => __('Total', 'event_espresso'), |
|
68 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
69 | - 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
70 | - 'event_name' => __('Event', 'event_espresso'), |
|
71 | - 'actions' => __('Actions', 'event_espresso'), |
|
72 | - ); |
|
73 | - |
|
74 | - $this->_sortable_columns = array( |
|
75 | - 'TXN_ID' => array('TXN_ID' => false), |
|
76 | - 'event_name' => array('event_name' => false), |
|
77 | - 'ATT_fname' => array('ATT_fname' => false), |
|
78 | - 'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted |
|
79 | - ); |
|
80 | - |
|
81 | - $this->_primary_column = 'TXN_ID'; |
|
82 | - |
|
83 | - $this->_hidden_columns = array(); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * This simply sets up the row class for the table rows. |
|
89 | - * Allows for easier overriding of child methods for setting up sorting. |
|
90 | - * |
|
91 | - * @param EE_Transaction $item the current item |
|
92 | - * @return string |
|
93 | - * @throws \EE_Error |
|
94 | - */ |
|
95 | - protected function _get_row_class($item) |
|
96 | - { |
|
97 | - $class = parent::_get_row_class($item); |
|
98 | - //add status class |
|
99 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
100 | - if ($this->_has_checkbox_column) { |
|
101 | - $class .= ' has-checkbox-column'; |
|
102 | - } |
|
103 | - return $class; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * _get_table_filters |
|
109 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
110 | - * get's shown in the table. |
|
111 | - * |
|
112 | - * @abstract |
|
113 | - * @access protected |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - protected function _get_table_filters() |
|
117 | - { |
|
118 | - $filters = array(); |
|
119 | - $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
120 | - strtotime('-10 year')); |
|
121 | - $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', |
|
122 | - current_time('timestamp')); |
|
123 | - ob_start(); |
|
124 | - ?> |
|
25 | + private $_status; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @param \Transactions_Admin_Page $admin_page |
|
30 | + */ |
|
31 | + public function __construct(\Transactions_Admin_Page $admin_page) |
|
32 | + { |
|
33 | + parent::__construct($admin_page); |
|
34 | + $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + *_setup_data |
|
40 | + */ |
|
41 | + protected function _setup_data() |
|
42 | + { |
|
43 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
44 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
45 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + *_set_properties |
|
51 | + */ |
|
52 | + protected function _set_properties() |
|
53 | + { |
|
54 | + $this->_wp_list_args = array( |
|
55 | + 'singular' => __('transaction', 'event_espresso'), |
|
56 | + 'plural' => __('transactions', 'event_espresso'), |
|
57 | + 'ajax' => true, |
|
58 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
59 | + ); |
|
60 | + $ID_column_name = __('ID', 'event_espresso'); |
|
61 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
62 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
63 | + $ID_column_name .= '</span> '; |
|
64 | + $this->_columns = array( |
|
65 | + 'TXN_ID' => $ID_column_name, |
|
66 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
67 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
68 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
69 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
70 | + 'event_name' => __('Event', 'event_espresso'), |
|
71 | + 'actions' => __('Actions', 'event_espresso'), |
|
72 | + ); |
|
73 | + |
|
74 | + $this->_sortable_columns = array( |
|
75 | + 'TXN_ID' => array('TXN_ID' => false), |
|
76 | + 'event_name' => array('event_name' => false), |
|
77 | + 'ATT_fname' => array('ATT_fname' => false), |
|
78 | + 'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted |
|
79 | + ); |
|
80 | + |
|
81 | + $this->_primary_column = 'TXN_ID'; |
|
82 | + |
|
83 | + $this->_hidden_columns = array(); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * This simply sets up the row class for the table rows. |
|
89 | + * Allows for easier overriding of child methods for setting up sorting. |
|
90 | + * |
|
91 | + * @param EE_Transaction $item the current item |
|
92 | + * @return string |
|
93 | + * @throws \EE_Error |
|
94 | + */ |
|
95 | + protected function _get_row_class($item) |
|
96 | + { |
|
97 | + $class = parent::_get_row_class($item); |
|
98 | + //add status class |
|
99 | + $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
100 | + if ($this->_has_checkbox_column) { |
|
101 | + $class .= ' has-checkbox-column'; |
|
102 | + } |
|
103 | + return $class; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * _get_table_filters |
|
109 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
110 | + * get's shown in the table. |
|
111 | + * |
|
112 | + * @abstract |
|
113 | + * @access protected |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + protected function _get_table_filters() |
|
117 | + { |
|
118 | + $filters = array(); |
|
119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
120 | + strtotime('-10 year')); |
|
121 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', |
|
122 | + current_time('timestamp')); |
|
123 | + ob_start(); |
|
124 | + ?> |
|
125 | 125 | <label for="txn-filter-start-date">Display Transactions from </label> |
126 | 126 | <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>" |
127 | 127 | name="txn-filter-start-date" size="15"/> |
@@ -129,361 +129,361 @@ discard block |
||
129 | 129 | <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>" |
130 | 130 | name="txn-filter-end-date" size="15"/> |
131 | 131 | <?php |
132 | - $filters[] = ob_get_contents(); |
|
133 | - ob_end_clean(); |
|
134 | - return $filters; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - *_add_view_counts |
|
140 | - */ |
|
141 | - protected function _add_view_counts() |
|
142 | - { |
|
143 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all'); |
|
144 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned'); |
|
145 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed'); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * column TXN_ID |
|
151 | - * |
|
152 | - * @param \EE_Transaction $item |
|
153 | - * @return string |
|
154 | - * @throws \EE_Error |
|
155 | - */ |
|
156 | - public function column_TXN_ID(EE_Transaction $item) |
|
157 | - { |
|
158 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
159 | - 'action' => 'view_transaction', |
|
160 | - 'TXN_ID' => $item->ID(), |
|
161 | - ), TXN_ADMIN_URL); |
|
162 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
163 | - 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
164 | - |
|
165 | - //txn timestamp |
|
166 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
167 | - return $content; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param \EE_Transaction $item |
|
173 | - * @return mixed|string|void |
|
174 | - * @throws \EE_Error |
|
175 | - */ |
|
176 | - protected function _get_txn_timestamp(EE_Transaction $item) |
|
177 | - { |
|
178 | - //txn timestamp |
|
179 | - // is TXN less than 2 hours old ? |
|
180 | - if ( |
|
181 | - ($item->failed() || $item->is_abandoned()) |
|
182 | - && ( |
|
183 | - (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
184 | - ) |
|
185 | - ) { |
|
186 | - $timestamp = __('TXN in progress...', 'event_espresso'); |
|
187 | - } else { |
|
188 | - $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
189 | - } |
|
190 | - return $timestamp; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * column_cb |
|
196 | - * |
|
197 | - * @param \EE_Transaction $item |
|
198 | - * @return string |
|
199 | - * @throws \EE_Error |
|
200 | - */ |
|
201 | - public function column_cb($item) |
|
202 | - { |
|
203 | - return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], |
|
204 | - $item->ID()); |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * column_TXN_timestamp |
|
210 | - * |
|
211 | - * @param \EE_Transaction $item |
|
212 | - * @return string |
|
213 | - * @throws \EE_Error |
|
214 | - */ |
|
215 | - public function column_TXN_timestamp(EE_Transaction $item) |
|
216 | - { |
|
217 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
218 | - 'action' => 'view_transaction', |
|
219 | - 'TXN_ID' => $item->ID(), |
|
220 | - ), TXN_ADMIN_URL); |
|
221 | - $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
222 | - 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
223 | - //status |
|
224 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
225 | - 'sentence') . '</span>'; |
|
226 | - return $txn_date; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * column_TXN_total |
|
232 | - * |
|
233 | - * @param \EE_Transaction $item |
|
234 | - * @return string |
|
235 | - * @throws \EE_Error |
|
236 | - */ |
|
237 | - public function column_TXN_total(EE_Transaction $item) |
|
238 | - { |
|
239 | - if ($item->get('TXN_total') > 0) { |
|
240 | - return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
241 | - $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
242 | - } else { |
|
243 | - return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
244 | - } |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * column_TXN_paid |
|
250 | - * |
|
251 | - * @param \EE_Transaction $item |
|
252 | - * @return mixed|string |
|
253 | - * @throws \EE_Error |
|
254 | - */ |
|
255 | - public function column_TXN_paid(EE_Transaction $item) |
|
256 | - { |
|
257 | - $transaction_total = $item->get('TXN_total'); |
|
258 | - $transaction_paid = $item->get('TXN_paid'); |
|
259 | - |
|
260 | - if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
261 | - // monies owing |
|
262 | - $span_class = 'txn-overview-part-payment-spn'; |
|
263 | - if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
264 | - // paid in full |
|
265 | - $span_class = 'txn-overview-full-payment-spn'; |
|
266 | - } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
267 | - // no payments made |
|
268 | - $span_class = 'txn-overview-no-payment-spn'; |
|
269 | - } |
|
270 | - } else { |
|
271 | - $span_class = 'txn-overview-free-event-spn'; |
|
272 | - $transaction_paid = 0; |
|
273 | - } |
|
274 | - |
|
275 | - $payment_method = $item->payment_method(); |
|
276 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
|
277 | - 'event_espresso'); |
|
278 | - |
|
279 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
280 | - if ($transaction_paid > 0) { |
|
281 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
282 | - $payment_method_name) . '</span>'; |
|
283 | - } |
|
284 | - return $content; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * column_ATT_fname |
|
290 | - * |
|
291 | - * @param \EE_Transaction $item |
|
292 | - * @return string|void |
|
293 | - * @throws \EE_Error |
|
294 | - */ |
|
295 | - public function column_ATT_fname(EE_Transaction $item) |
|
296 | - { |
|
297 | - $primary_reg = $item->primary_registration(); |
|
298 | - $attendee = $primary_reg->get_first_related('Attendee'); |
|
299 | - if ($attendee instanceof EE_Attendee) { |
|
300 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
301 | - 'action' => 'view_registration', |
|
302 | - '_REG_ID' => $primary_reg->ID(), |
|
303 | - ), REG_ADMIN_URL); |
|
304 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
305 | - 'espresso_registrations_view_registration', |
|
306 | - $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
307 | - 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
308 | - $content .= '<br>' . $attendee->email(); |
|
309 | - return $content; |
|
310 | - } |
|
311 | - return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
|
312 | - 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', |
|
313 | - 'event_espresso'); |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * column_ATT_email |
|
319 | - * |
|
320 | - * @param \EE_Transaction $item |
|
321 | - * @return string|void |
|
322 | - * @throws \EE_Error |
|
323 | - */ |
|
324 | - public function column_ATT_email(EE_Transaction $item) |
|
325 | - { |
|
326 | - $attendee = $item->primary_registration()->get_first_related('Attendee'); |
|
327 | - if (! empty($attendee)) { |
|
328 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
329 | - } else { |
|
330 | - return $item->failed() || $item->is_abandoned() |
|
331 | - ? __('no contact record.', 'event_espresso') |
|
332 | - : __( |
|
333 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
334 | - 'event_espresso' |
|
335 | - ); |
|
336 | - } |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * column_event_name |
|
342 | - * |
|
343 | - * @param \EE_Transaction $item |
|
344 | - * @return string|void |
|
345 | - * @throws \EE_Error |
|
346 | - */ |
|
347 | - public function column_event_name(EE_Transaction $item) |
|
348 | - { |
|
349 | - $actions = array(); |
|
350 | - $event = $item->primary_registration()->get_first_related('Event'); |
|
351 | - if (! empty($event)) { |
|
352 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
353 | - EVENTS_ADMIN_URL); |
|
354 | - $event_name = $event->get('EVT_name'); |
|
355 | - |
|
356 | - //filter this view by transactions for this event |
|
357 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array( |
|
358 | - 'action' => 'default', |
|
359 | - 'EVT_ID' => $event->ID(), |
|
360 | - )); |
|
361 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
362 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
363 | - 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
364 | - } |
|
365 | - |
|
366 | - return sprintf('%1$s %2$s', |
|
367 | - EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
|
368 | - $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
369 | - 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
370 | - '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
371 | - } else { |
|
372 | - return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
|
373 | - 'event_espresso'); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * column_actions |
|
380 | - * |
|
381 | - * @param \EE_Transaction $item |
|
382 | - * @return string |
|
383 | - * @throws \EE_Error |
|
384 | - */ |
|
385 | - public function column_actions(EE_Transaction $item) |
|
386 | - { |
|
387 | - |
|
388 | - $registration = $item->primary_registration(); |
|
389 | - $attendee = $registration->attendee(); |
|
390 | - |
|
391 | - //Build row actions |
|
392 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
393 | - 'action' => 'view_transaction', |
|
394 | - 'TXN_ID' => $item->ID(), |
|
395 | - ), TXN_ADMIN_URL); |
|
396 | - $dl_invoice_lnk_url = $registration->invoice_url(); |
|
397 | - $dl_receipt_lnk_url = $registration->receipt_url(); |
|
398 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
399 | - 'action' => 'view_registration', |
|
400 | - '_REG_ID' => $registration->ID(), |
|
401 | - ), REG_ADMIN_URL); |
|
402 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
403 | - 'action' => 'send_payment_reminder', |
|
404 | - 'TXN_ID' => $item->ID(), |
|
405 | - ), TXN_ADMIN_URL); |
|
406 | - $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
407 | - 'TXN_ID' => $item->ID(), |
|
408 | - )); |
|
409 | - |
|
410 | - //Build row actions |
|
411 | - $view_lnk = ' |
|
132 | + $filters[] = ob_get_contents(); |
|
133 | + ob_end_clean(); |
|
134 | + return $filters; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + *_add_view_counts |
|
140 | + */ |
|
141 | + protected function _add_view_counts() |
|
142 | + { |
|
143 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all'); |
|
144 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned'); |
|
145 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed'); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * column TXN_ID |
|
151 | + * |
|
152 | + * @param \EE_Transaction $item |
|
153 | + * @return string |
|
154 | + * @throws \EE_Error |
|
155 | + */ |
|
156 | + public function column_TXN_ID(EE_Transaction $item) |
|
157 | + { |
|
158 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
159 | + 'action' => 'view_transaction', |
|
160 | + 'TXN_ID' => $item->ID(), |
|
161 | + ), TXN_ADMIN_URL); |
|
162 | + $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
163 | + 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
164 | + |
|
165 | + //txn timestamp |
|
166 | + $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
167 | + return $content; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param \EE_Transaction $item |
|
173 | + * @return mixed|string|void |
|
174 | + * @throws \EE_Error |
|
175 | + */ |
|
176 | + protected function _get_txn_timestamp(EE_Transaction $item) |
|
177 | + { |
|
178 | + //txn timestamp |
|
179 | + // is TXN less than 2 hours old ? |
|
180 | + if ( |
|
181 | + ($item->failed() || $item->is_abandoned()) |
|
182 | + && ( |
|
183 | + (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
184 | + ) |
|
185 | + ) { |
|
186 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
187 | + } else { |
|
188 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
189 | + } |
|
190 | + return $timestamp; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * column_cb |
|
196 | + * |
|
197 | + * @param \EE_Transaction $item |
|
198 | + * @return string |
|
199 | + * @throws \EE_Error |
|
200 | + */ |
|
201 | + public function column_cb($item) |
|
202 | + { |
|
203 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], |
|
204 | + $item->ID()); |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * column_TXN_timestamp |
|
210 | + * |
|
211 | + * @param \EE_Transaction $item |
|
212 | + * @return string |
|
213 | + * @throws \EE_Error |
|
214 | + */ |
|
215 | + public function column_TXN_timestamp(EE_Transaction $item) |
|
216 | + { |
|
217 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
218 | + 'action' => 'view_transaction', |
|
219 | + 'TXN_ID' => $item->ID(), |
|
220 | + ), TXN_ADMIN_URL); |
|
221 | + $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
222 | + 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
223 | + //status |
|
224 | + $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
225 | + 'sentence') . '</span>'; |
|
226 | + return $txn_date; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * column_TXN_total |
|
232 | + * |
|
233 | + * @param \EE_Transaction $item |
|
234 | + * @return string |
|
235 | + * @throws \EE_Error |
|
236 | + */ |
|
237 | + public function column_TXN_total(EE_Transaction $item) |
|
238 | + { |
|
239 | + if ($item->get('TXN_total') > 0) { |
|
240 | + return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
241 | + $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
242 | + } else { |
|
243 | + return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
244 | + } |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * column_TXN_paid |
|
250 | + * |
|
251 | + * @param \EE_Transaction $item |
|
252 | + * @return mixed|string |
|
253 | + * @throws \EE_Error |
|
254 | + */ |
|
255 | + public function column_TXN_paid(EE_Transaction $item) |
|
256 | + { |
|
257 | + $transaction_total = $item->get('TXN_total'); |
|
258 | + $transaction_paid = $item->get('TXN_paid'); |
|
259 | + |
|
260 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
261 | + // monies owing |
|
262 | + $span_class = 'txn-overview-part-payment-spn'; |
|
263 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
264 | + // paid in full |
|
265 | + $span_class = 'txn-overview-full-payment-spn'; |
|
266 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
267 | + // no payments made |
|
268 | + $span_class = 'txn-overview-no-payment-spn'; |
|
269 | + } |
|
270 | + } else { |
|
271 | + $span_class = 'txn-overview-free-event-spn'; |
|
272 | + $transaction_paid = 0; |
|
273 | + } |
|
274 | + |
|
275 | + $payment_method = $item->payment_method(); |
|
276 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
|
277 | + 'event_espresso'); |
|
278 | + |
|
279 | + $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
280 | + if ($transaction_paid > 0) { |
|
281 | + $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
282 | + $payment_method_name) . '</span>'; |
|
283 | + } |
|
284 | + return $content; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * column_ATT_fname |
|
290 | + * |
|
291 | + * @param \EE_Transaction $item |
|
292 | + * @return string|void |
|
293 | + * @throws \EE_Error |
|
294 | + */ |
|
295 | + public function column_ATT_fname(EE_Transaction $item) |
|
296 | + { |
|
297 | + $primary_reg = $item->primary_registration(); |
|
298 | + $attendee = $primary_reg->get_first_related('Attendee'); |
|
299 | + if ($attendee instanceof EE_Attendee) { |
|
300 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
301 | + 'action' => 'view_registration', |
|
302 | + '_REG_ID' => $primary_reg->ID(), |
|
303 | + ), REG_ADMIN_URL); |
|
304 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
305 | + 'espresso_registrations_view_registration', |
|
306 | + $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
307 | + 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
308 | + $content .= '<br>' . $attendee->email(); |
|
309 | + return $content; |
|
310 | + } |
|
311 | + return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
|
312 | + 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', |
|
313 | + 'event_espresso'); |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * column_ATT_email |
|
319 | + * |
|
320 | + * @param \EE_Transaction $item |
|
321 | + * @return string|void |
|
322 | + * @throws \EE_Error |
|
323 | + */ |
|
324 | + public function column_ATT_email(EE_Transaction $item) |
|
325 | + { |
|
326 | + $attendee = $item->primary_registration()->get_first_related('Attendee'); |
|
327 | + if (! empty($attendee)) { |
|
328 | + return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
329 | + } else { |
|
330 | + return $item->failed() || $item->is_abandoned() |
|
331 | + ? __('no contact record.', 'event_espresso') |
|
332 | + : __( |
|
333 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
334 | + 'event_espresso' |
|
335 | + ); |
|
336 | + } |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * column_event_name |
|
342 | + * |
|
343 | + * @param \EE_Transaction $item |
|
344 | + * @return string|void |
|
345 | + * @throws \EE_Error |
|
346 | + */ |
|
347 | + public function column_event_name(EE_Transaction $item) |
|
348 | + { |
|
349 | + $actions = array(); |
|
350 | + $event = $item->primary_registration()->get_first_related('Event'); |
|
351 | + if (! empty($event)) { |
|
352 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
353 | + EVENTS_ADMIN_URL); |
|
354 | + $event_name = $event->get('EVT_name'); |
|
355 | + |
|
356 | + //filter this view by transactions for this event |
|
357 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array( |
|
358 | + 'action' => 'default', |
|
359 | + 'EVT_ID' => $event->ID(), |
|
360 | + )); |
|
361 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
362 | + $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
363 | + 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
364 | + } |
|
365 | + |
|
366 | + return sprintf('%1$s %2$s', |
|
367 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
|
368 | + $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
369 | + 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
370 | + '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
371 | + } else { |
|
372 | + return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
|
373 | + 'event_espresso'); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * column_actions |
|
380 | + * |
|
381 | + * @param \EE_Transaction $item |
|
382 | + * @return string |
|
383 | + * @throws \EE_Error |
|
384 | + */ |
|
385 | + public function column_actions(EE_Transaction $item) |
|
386 | + { |
|
387 | + |
|
388 | + $registration = $item->primary_registration(); |
|
389 | + $attendee = $registration->attendee(); |
|
390 | + |
|
391 | + //Build row actions |
|
392 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
393 | + 'action' => 'view_transaction', |
|
394 | + 'TXN_ID' => $item->ID(), |
|
395 | + ), TXN_ADMIN_URL); |
|
396 | + $dl_invoice_lnk_url = $registration->invoice_url(); |
|
397 | + $dl_receipt_lnk_url = $registration->receipt_url(); |
|
398 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
399 | + 'action' => 'view_registration', |
|
400 | + '_REG_ID' => $registration->ID(), |
|
401 | + ), REG_ADMIN_URL); |
|
402 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
403 | + 'action' => 'send_payment_reminder', |
|
404 | + 'TXN_ID' => $item->ID(), |
|
405 | + ), TXN_ADMIN_URL); |
|
406 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
407 | + 'TXN_ID' => $item->ID(), |
|
408 | + )); |
|
409 | + |
|
410 | + //Build row actions |
|
411 | + $view_lnk = ' |
|
412 | 412 | <li> |
413 | 413 | <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
414 | 414 | <span class="dashicons dashicons-cart"></span> |
415 | 415 | </a> |
416 | 416 | </li>'; |
417 | 417 | |
418 | - $dl_invoice_lnk = ''; |
|
419 | - //only show invoice link if message type is active. |
|
420 | - if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
421 | - $dl_invoice_lnk = ' |
|
418 | + $dl_invoice_lnk = ''; |
|
419 | + //only show invoice link if message type is active. |
|
420 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
421 | + $dl_invoice_lnk = ' |
|
422 | 422 | <li> |
423 | 423 | <a title="' . esc_attr__('View Transaction Invoice', |
424 | - 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
424 | + 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
425 | 425 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
426 | 426 | </a> |
427 | 427 | </li>'; |
428 | - } |
|
428 | + } |
|
429 | 429 | |
430 | - $dl_receipt_lnk = ''; |
|
431 | - //only show receipt link if message type is active. |
|
432 | - if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
433 | - $dl_receipt_lnk = ' |
|
430 | + $dl_receipt_lnk = ''; |
|
431 | + //only show receipt link if message type is active. |
|
432 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
433 | + $dl_receipt_lnk = ' |
|
434 | 434 | <li> |
435 | 435 | <a title="' . esc_attr__('View Transaction Receipt', |
436 | - 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
436 | + 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
437 | 437 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
438 | 438 | </a> |
439 | 439 | </li>'; |
440 | - } |
|
441 | - |
|
442 | - //only show payment reminder link if the message type is active. |
|
443 | - if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
444 | - $send_pay_lnk = $attendee instanceof EE_Attendee |
|
445 | - && EE_Registry::instance()->CAP->current_user_can( |
|
446 | - 'ee_send_message', |
|
447 | - 'espresso_transactions_send_payment_reminder' |
|
448 | - ) |
|
449 | - ? ' |
|
440 | + } |
|
441 | + |
|
442 | + //only show payment reminder link if the message type is active. |
|
443 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
444 | + $send_pay_lnk = $attendee instanceof EE_Attendee |
|
445 | + && EE_Registry::instance()->CAP->current_user_can( |
|
446 | + 'ee_send_message', |
|
447 | + 'espresso_transactions_send_payment_reminder' |
|
448 | + ) |
|
449 | + ? ' |
|
450 | 450 | <li> |
451 | 451 | <a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', |
452 | - 'event_espresso') . '" class="tiny-text"> |
|
452 | + 'event_espresso') . '" class="tiny-text"> |
|
453 | 453 | <span class="dashicons dashicons-email-alt"></span> |
454 | 454 | </a> |
455 | 455 | </li>' |
456 | - : ''; |
|
457 | - $send_pay_lnk = $item->get('STS_ID') !== EEM_Transaction::complete_status_code |
|
458 | - && $item->get('STS_ID') !== EEM_Transaction::overpaid_status_code |
|
459 | - ? $send_pay_lnk |
|
460 | - : ''; |
|
461 | - } else { |
|
462 | - $send_pay_lnk = ''; |
|
463 | - } |
|
464 | - |
|
465 | - $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can( |
|
466 | - 'ee_read_registration', |
|
467 | - 'espresso_registrations_view_registration', |
|
468 | - $registration->ID() |
|
469 | - ) |
|
470 | - ? ' |
|
456 | + : ''; |
|
457 | + $send_pay_lnk = $item->get('STS_ID') !== EEM_Transaction::complete_status_code |
|
458 | + && $item->get('STS_ID') !== EEM_Transaction::overpaid_status_code |
|
459 | + ? $send_pay_lnk |
|
460 | + : ''; |
|
461 | + } else { |
|
462 | + $send_pay_lnk = ''; |
|
463 | + } |
|
464 | + |
|
465 | + $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can( |
|
466 | + 'ee_read_registration', |
|
467 | + 'espresso_registrations_view_registration', |
|
468 | + $registration->ID() |
|
469 | + ) |
|
470 | + ? ' |
|
471 | 471 | <li> |
472 | 472 | <a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', |
473 | - 'event_espresso') . '" class="tiny-text"> |
|
473 | + 'event_espresso') . '" class="tiny-text"> |
|
474 | 474 | <span class="dashicons dashicons-clipboard"></span> |
475 | 475 | </a> |
476 | 476 | </li>' |
477 | - : ''; |
|
477 | + : ''; |
|
478 | 478 | |
479 | - $view_related_messages_lnk = ''; |
|
480 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
481 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
482 | - } |
|
479 | + $view_related_messages_lnk = ''; |
|
480 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
481 | + $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
482 | + } |
|
483 | 483 | |
484 | - return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
485 | - $item, 'ul', 'txn-overview-actions-ul'); |
|
486 | - } |
|
484 | + return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
485 | + $item, 'ul', 'txn-overview-actions-ul'); |
|
486 | + } |
|
487 | 487 | |
488 | 488 | |
489 | 489 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | 'ajax' => true, |
58 | 58 | 'screen' => $this->_admin_page->get_current_screen()->id, |
59 | 59 | ); |
60 | - $ID_column_name = __('ID', 'event_espresso'); |
|
60 | + $ID_column_name = __('ID', 'event_espresso'); |
|
61 | 61 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
62 | 62 | $ID_column_name .= __('Transaction Date', 'event_espresso'); |
63 | 63 | $ID_column_name .= '</span> '; |
64 | - $this->_columns = array( |
|
64 | + $this->_columns = array( |
|
65 | 65 | 'TXN_ID' => $ID_column_name, |
66 | 66 | 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
67 | 67 | 'TXN_total' => __('Total', 'event_espresso'), |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | $class = parent::_get_row_class($item); |
98 | 98 | //add status class |
99 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
99 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
100 | 100 | if ($this->_has_checkbox_column) { |
101 | 101 | $class .= ' has-checkbox-column'; |
102 | 102 | } |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | 'action' => 'view_transaction', |
160 | 160 | 'TXN_ID' => $item->ID(), |
161 | 161 | ), TXN_ADMIN_URL); |
162 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
163 | - 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
162 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', |
|
163 | + 'event_espresso').'">'.$item->ID().'</a>'; |
|
164 | 164 | |
165 | 165 | //txn timestamp |
166 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
166 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
167 | 167 | return $content; |
168 | 168 | } |
169 | 169 | |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | 'action' => 'view_transaction', |
219 | 219 | 'TXN_ID' => $item->ID(), |
220 | 220 | ), TXN_ADMIN_URL); |
221 | - $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
222 | - 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
221 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', |
|
222 | + 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
223 | 223 | //status |
224 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
225 | - 'sentence') . '</span>'; |
|
224 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, |
|
225 | + 'sentence').'</span>'; |
|
226 | 226 | return $txn_date; |
227 | 227 | } |
228 | 228 | |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | public function column_TXN_total(EE_Transaction $item) |
238 | 238 | { |
239 | 239 | if ($item->get('TXN_total') > 0) { |
240 | - return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
241 | - $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
240 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
241 | + $item->get_pretty('TXN_total'), $item).'</span>'; |
|
242 | 242 | } else { |
243 | - return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
243 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
277 | 277 | 'event_espresso'); |
278 | 278 | |
279 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
279 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
280 | 280 | if ($transaction_paid > 0) { |
281 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
282 | - $payment_method_name) . '</span>'; |
|
281 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), |
|
282 | + $payment_method_name).'</span>'; |
|
283 | 283 | } |
284 | 284 | return $content; |
285 | 285 | } |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | 'action' => 'view_registration', |
302 | 302 | '_REG_ID' => $primary_reg->ID(), |
303 | 303 | ), REG_ADMIN_URL); |
304 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
304 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
305 | 305 | 'espresso_registrations_view_registration', |
306 | - $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
307 | - 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
308 | - $content .= '<br>' . $attendee->email(); |
|
306 | + $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', |
|
307 | + 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
308 | + $content .= '<br>'.$attendee->email(); |
|
309 | 309 | return $content; |
310 | 310 | } |
311 | 311 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | public function column_ATT_email(EE_Transaction $item) |
325 | 325 | { |
326 | 326 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
327 | - if (! empty($attendee)) { |
|
328 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
327 | + if ( ! empty($attendee)) { |
|
328 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
329 | 329 | } else { |
330 | 330 | return $item->failed() || $item->is_abandoned() |
331 | 331 | ? __('no contact record.', 'event_espresso') |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | { |
349 | 349 | $actions = array(); |
350 | 350 | $event = $item->primary_registration()->get_first_related('Event'); |
351 | - if (! empty($event)) { |
|
351 | + if ( ! empty($event)) { |
|
352 | 352 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
353 | 353 | EVENTS_ADMIN_URL); |
354 | 354 | $event_name = $event->get('EVT_name'); |
@@ -359,15 +359,15 @@ discard block |
||
359 | 359 | 'EVT_ID' => $event->ID(), |
360 | 360 | )); |
361 | 361 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
362 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
363 | - 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
362 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', |
|
363 | + 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return sprintf('%1$s %2$s', |
367 | 367 | EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
368 | - $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
369 | - 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
370 | - '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
368 | + $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', |
|
369 | + 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, |
|
370 | + '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
371 | 371 | } else { |
372 | 372 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
373 | 373 | 'event_espresso'); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $attendee = $registration->attendee(); |
390 | 390 | |
391 | 391 | //Build row actions |
392 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
392 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
393 | 393 | 'action' => 'view_transaction', |
394 | 394 | 'TXN_ID' => $item->ID(), |
395 | 395 | ), TXN_ADMIN_URL); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | 'action' => 'view_registration', |
400 | 400 | '_REG_ID' => $registration->ID(), |
401 | 401 | ), REG_ADMIN_URL); |
402 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
402 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
403 | 403 | 'action' => 'send_payment_reminder', |
404 | 404 | 'TXN_ID' => $item->ID(), |
405 | 405 | ), TXN_ADMIN_URL); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | //Build row actions |
411 | 411 | $view_lnk = ' |
412 | 412 | <li> |
413 | - <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
|
413 | + <a href="' . $view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
414 | 414 | <span class="dashicons dashicons-cart"></span> |
415 | 415 | </a> |
416 | 416 | </li>'; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $dl_invoice_lnk = ' |
422 | 422 | <li> |
423 | 423 | <a title="' . esc_attr__('View Transaction Invoice', |
424 | - 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
424 | + 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
425 | 425 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
426 | 426 | </a> |
427 | 427 | </li>'; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $dl_receipt_lnk = ' |
434 | 434 | <li> |
435 | 435 | <a title="' . esc_attr__('View Transaction Receipt', |
436 | - 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
436 | + 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
437 | 437 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
438 | 438 | </a> |
439 | 439 | </li>'; |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | ) |
449 | 449 | ? ' |
450 | 450 | <li> |
451 | - <a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', |
|
452 | - 'event_espresso') . '" class="tiny-text"> |
|
451 | + <a href="' . $send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', |
|
452 | + 'event_espresso').'" class="tiny-text"> |
|
453 | 453 | <span class="dashicons dashicons-email-alt"></span> |
454 | 454 | </a> |
455 | 455 | </li>' |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | ) |
470 | 470 | ? ' |
471 | 471 | <li> |
472 | - <a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
473 | - 'event_espresso') . '" class="tiny-text"> |
|
472 | + <a href="' . $view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', |
|
473 | + 'event_espresso').'" class="tiny-text"> |
|
474 | 474 | <span class="dashicons dashicons-clipboard"></span> |
475 | 475 | </a> |
476 | 476 | </li>' |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | |
479 | 479 | $view_related_messages_lnk = ''; |
480 | 480 | if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
481 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
481 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
482 | 482 | } |
483 | 483 | |
484 | - return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
484 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, |
|
485 | 485 | $item, 'ul', 'txn-overview-actions-ul'); |
486 | 486 | } |
487 | 487 |