Completed
Branch dev (1f3862)
by
unknown
14:13 queued 07:26
created
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3651 added lines, -3651 removed lines patch added patch discarded remove patch
@@ -20,2206 +20,2206 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
22 22
 {
23
-    /**
24
-     * @var EE_Registration
25
-     */
26
-    private $_registration;
27
-
28
-    /**
29
-     * @var EE_Event
30
-     */
31
-    private $_reg_event;
32
-
33
-    /**
34
-     * @var EE_Session
35
-     */
36
-    private $_session;
37
-
38
-    /**
39
-     * @var array
40
-     */
41
-    private static $_reg_status;
42
-
43
-    /**
44
-     * Form for displaying the custom questions for this registration.
45
-     * This gets used a few times throughout the request so its best to cache it
46
-     *
47
-     * @var EE_Registration_Custom_Questions_Form
48
-     */
49
-    protected $_reg_custom_questions_form;
50
-
51
-    /**
52
-     * @var EEM_Registration $registration_model
53
-     */
54
-    private $registration_model;
55
-
56
-    /**
57
-     * @var EEM_Attendee $attendee_model
58
-     */
59
-    private $attendee_model;
60
-
61
-    /**
62
-     * @var EEM_Event $event_model
63
-     */
64
-    private $event_model;
65
-
66
-    /**
67
-     * @var EEM_Status $status_model
68
-     */
69
-    private $status_model;
70
-
71
-
72
-    /**
73
-     * @param bool $routing
74
-     * @throws EE_Error
75
-     * @throws InvalidArgumentException
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws ReflectionException
79
-     */
80
-    public function __construct($routing = true)
81
-    {
82
-        parent::__construct($routing);
83
-        add_action('wp_loaded', [$this, 'wp_loaded']);
84
-    }
85
-
86
-
87
-    /**
88
-     * @return EEM_Registration
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     * @since 4.10.2.p
93
-     */
94
-    protected function getRegistrationModel()
95
-    {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
97
-            $this->registration_model = $this->loader->getShared('EEM_Registration');
98
-        }
99
-        return $this->registration_model;
100
-    }
101
-
102
-
103
-    /**
104
-     * @return EEM_Attendee
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @since 4.10.2.p
109
-     */
110
-    protected function getAttendeeModel()
111
-    {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
113
-            $this->attendee_model = $this->loader->getShared('EEM_Attendee');
114
-        }
115
-        return $this->attendee_model;
116
-    }
117
-
118
-
119
-    /**
120
-     * @return EEM_Event
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidInterfaceException
124
-     * @since 4.10.2.p
125
-     */
126
-    protected function getEventModel()
127
-    {
128
-        if (! $this->event_model instanceof EEM_Event) {
129
-            $this->event_model = $this->loader->getShared('EEM_Event');
130
-        }
131
-        return $this->event_model;
132
-    }
133
-
134
-
135
-    /**
136
-     * @return EEM_Status
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     * @since 4.10.2.p
141
-     */
142
-    protected function getStatusModel()
143
-    {
144
-        if (! $this->status_model instanceof EEM_Status) {
145
-            $this->status_model = $this->loader->getShared('EEM_Status');
146
-        }
147
-        return $this->status_model;
148
-    }
149
-
150
-
151
-    public function wp_loaded()
152
-    {
153
-        // when adding a new registration...
154
-        $action = $this->request->getRequestParam('action');
155
-        if ($action === 'new_registration') {
156
-            EE_System::do_not_cache();
157
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
-                // and it's NOT the attendee information reg step
159
-                // force cookie expiration by setting time to last week
160
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
-                // and update the global
162
-                $_COOKIE['ee_registration_added'] = 0;
163
-            }
164
-        }
165
-    }
166
-
167
-
168
-    protected function _init_page_props()
169
-    {
170
-        $this->page_slug        = REG_PG_SLUG;
171
-        $this->_admin_base_url  = REG_ADMIN_URL;
172
-        $this->_admin_base_path = REG_ADMIN;
173
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
174
-        $this->_cpt_routes      = [
175
-            'add_new_attendee' => 'espresso_attendees',
176
-            'edit_attendee'    => 'espresso_attendees',
177
-            'insert_attendee'  => 'espresso_attendees',
178
-            'update_attendee'  => 'espresso_attendees',
179
-        ];
180
-        $this->_cpt_model_names = [
181
-            'add_new_attendee' => 'EEM_Attendee',
182
-            'edit_attendee'    => 'EEM_Attendee',
183
-        ];
184
-        $this->_cpt_edit_routes = [
185
-            'espresso_attendees' => 'edit_attendee',
186
-        ];
187
-        $this->_pagenow_map     = [
188
-            'add_new_attendee' => 'post-new.php',
189
-            'edit_attendee'    => 'post.php',
190
-            'trash'            => 'post.php',
191
-        ];
192
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
-        // add filters so that the comment urls don't take users to a confusing 404 page
194
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
-    }
196
-
197
-
198
-    /**
199
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
200
-     * @param WP_Comment $comment The current comment object.
201
-     * @return string
202
-     */
203
-    public function clear_comment_link($link, WP_Comment $comment)
204
-    {
205
-        // gotta make sure this only happens on this route
206
-        $post_type = get_post_type($comment->comment_post_ID);
207
-        if ($post_type === 'espresso_attendees') {
208
-            return '#commentsdiv';
209
-        }
210
-        return $link;
211
-    }
212
-
213
-
214
-    protected function _ajax_hooks()
215
-    {
216
-        // todo: all hooks for registrations ajax goes in here
217
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
-    }
219
-
220
-
221
-    protected function _define_page_props()
222
-    {
223
-        $this->_admin_page_title = $this->page_label;
224
-        $this->_labels           = [
225
-            'buttons'                      => [
226
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
-                'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
230
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
231
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
232
-            ],
233
-            'publishbox'                   => [
234
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
235
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
236
-            ],
237
-            'hide_add_button_on_cpt_route' => [
238
-                'edit_attendee' => true,
239
-            ],
240
-        ];
241
-    }
242
-
243
-
244
-    /**
245
-     * grab url requests and route them
246
-     *
247
-     * @return void
248
-     * @throws EE_Error
249
-     */
250
-    public function _set_page_routes()
251
-    {
252
-        $this->_get_registration_status_array();
253
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
254
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
255
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
256
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
257
-        $this->_page_routes = [
258
-            'default'                             => [
259
-                'func'       => [$this, '_registrations_overview_list_table'],
260
-                'capability' => 'ee_read_registrations',
261
-            ],
262
-            'view_registration'                   => [
263
-                'func'       => '_registration_details',
264
-                'capability' => 'ee_read_registration',
265
-                'obj_id'     => $REG_ID,
266
-            ],
267
-            'edit_registration'                   => [
268
-                'func'               => '_update_attendee_registration_form',
269
-                'noheader'           => true,
270
-                'headers_sent_route' => 'view_registration',
271
-                'capability'         => 'ee_edit_registration',
272
-                'obj_id'             => $REG_ID,
273
-                '_REG_ID'            => $REG_ID,
274
-            ],
275
-            'trash_registrations'                 => [
276
-                'func'       => '_trash_or_restore_registrations',
277
-                'args'       => ['trash' => true],
278
-                'noheader'   => true,
279
-                'capability' => 'ee_delete_registrations',
280
-            ],
281
-            'restore_registrations'               => [
282
-                'func'       => '_trash_or_restore_registrations',
283
-                'args'       => ['trash' => false],
284
-                'noheader'   => true,
285
-                'capability' => 'ee_delete_registrations',
286
-            ],
287
-            'delete_registrations'                => [
288
-                'func'       => '_delete_registrations',
289
-                'noheader'   => true,
290
-                'capability' => 'ee_delete_registrations',
291
-            ],
292
-            'new_registration'                    => [
293
-                'func'       => 'new_registration',
294
-                'capability' => 'ee_edit_registrations',
295
-            ],
296
-            'process_reg_step'                    => [
297
-                'func'       => 'process_reg_step',
298
-                'noheader'   => true,
299
-                'capability' => 'ee_edit_registrations',
300
-            ],
301
-            'redirect_to_txn'                     => [
302
-                'func'       => 'redirect_to_txn',
303
-                'noheader'   => true,
304
-                'capability' => 'ee_edit_registrations',
305
-            ],
306
-            'change_reg_status'                   => [
307
-                'func'       => '_change_reg_status',
308
-                'noheader'   => true,
309
-                'capability' => 'ee_edit_registration',
310
-                'obj_id'     => $REG_ID,
311
-            ],
312
-            'approve_registration'                => [
313
-                'func'       => 'approve_registration',
314
-                'noheader'   => true,
315
-                'capability' => 'ee_edit_registration',
316
-                'obj_id'     => $REG_ID,
317
-            ],
318
-            'approve_and_notify_registration'     => [
319
-                'func'       => 'approve_registration',
320
-                'noheader'   => true,
321
-                'args'       => [true],
322
-                'capability' => 'ee_edit_registration',
323
-                'obj_id'     => $REG_ID,
324
-            ],
325
-            'approve_registrations'               => [
326
-                'func'       => 'bulk_action_on_registrations',
327
-                'noheader'   => true,
328
-                'capability' => 'ee_edit_registrations',
329
-                'args'       => ['approve'],
330
-            ],
331
-            'approve_and_notify_registrations'    => [
332
-                'func'       => 'bulk_action_on_registrations',
333
-                'noheader'   => true,
334
-                'capability' => 'ee_edit_registrations',
335
-                'args'       => ['approve', true],
336
-            ],
337
-            'decline_registration'                => [
338
-                'func'       => 'decline_registration',
339
-                'noheader'   => true,
340
-                'capability' => 'ee_edit_registration',
341
-                'obj_id'     => $REG_ID,
342
-            ],
343
-            'decline_and_notify_registration'     => [
344
-                'func'       => 'decline_registration',
345
-                'noheader'   => true,
346
-                'args'       => [true],
347
-                'capability' => 'ee_edit_registration',
348
-                'obj_id'     => $REG_ID,
349
-            ],
350
-            'decline_registrations'               => [
351
-                'func'       => 'bulk_action_on_registrations',
352
-                'noheader'   => true,
353
-                'capability' => 'ee_edit_registrations',
354
-                'args'       => ['decline'],
355
-            ],
356
-            'decline_and_notify_registrations'    => [
357
-                'func'       => 'bulk_action_on_registrations',
358
-                'noheader'   => true,
359
-                'capability' => 'ee_edit_registrations',
360
-                'args'       => ['decline', true],
361
-            ],
362
-            'pending_registration'                => [
363
-                'func'       => 'pending_registration',
364
-                'noheader'   => true,
365
-                'capability' => 'ee_edit_registration',
366
-                'obj_id'     => $REG_ID,
367
-            ],
368
-            'pending_and_notify_registration'     => [
369
-                'func'       => 'pending_registration',
370
-                'noheader'   => true,
371
-                'args'       => [true],
372
-                'capability' => 'ee_edit_registration',
373
-                'obj_id'     => $REG_ID,
374
-            ],
375
-            'pending_registrations'               => [
376
-                'func'       => 'bulk_action_on_registrations',
377
-                'noheader'   => true,
378
-                'capability' => 'ee_edit_registrations',
379
-                'args'       => ['pending'],
380
-            ],
381
-            'pending_and_notify_registrations'    => [
382
-                'func'       => 'bulk_action_on_registrations',
383
-                'noheader'   => true,
384
-                'capability' => 'ee_edit_registrations',
385
-                'args'       => ['pending', true],
386
-            ],
387
-            'no_approve_registration'             => [
388
-                'func'       => 'not_approve_registration',
389
-                'noheader'   => true,
390
-                'capability' => 'ee_edit_registration',
391
-                'obj_id'     => $REG_ID,
392
-            ],
393
-            'no_approve_and_notify_registration'  => [
394
-                'func'       => 'not_approve_registration',
395
-                'noheader'   => true,
396
-                'args'       => [true],
397
-                'capability' => 'ee_edit_registration',
398
-                'obj_id'     => $REG_ID,
399
-            ],
400
-            'no_approve_registrations'            => [
401
-                'func'       => 'bulk_action_on_registrations',
402
-                'noheader'   => true,
403
-                'capability' => 'ee_edit_registrations',
404
-                'args'       => ['not_approve'],
405
-            ],
406
-            'no_approve_and_notify_registrations' => [
407
-                'func'       => 'bulk_action_on_registrations',
408
-                'noheader'   => true,
409
-                'capability' => 'ee_edit_registrations',
410
-                'args'       => ['not_approve', true],
411
-            ],
412
-            'cancel_registration'                 => [
413
-                'func'       => 'cancel_registration',
414
-                'noheader'   => true,
415
-                'capability' => 'ee_edit_registration',
416
-                'obj_id'     => $REG_ID,
417
-            ],
418
-            'cancel_and_notify_registration'      => [
419
-                'func'       => 'cancel_registration',
420
-                'noheader'   => true,
421
-                'args'       => [true],
422
-                'capability' => 'ee_edit_registration',
423
-                'obj_id'     => $REG_ID,
424
-            ],
425
-            'cancel_registrations'                => [
426
-                'func'       => 'bulk_action_on_registrations',
427
-                'noheader'   => true,
428
-                'capability' => 'ee_edit_registrations',
429
-                'args'       => ['cancel'],
430
-            ],
431
-            'cancel_and_notify_registrations'     => [
432
-                'func'       => 'bulk_action_on_registrations',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_edit_registrations',
435
-                'args'       => ['cancel', true],
436
-            ],
437
-            'wait_list_registration'              => [
438
-                'func'       => 'wait_list_registration',
439
-                'noheader'   => true,
440
-                'capability' => 'ee_edit_registration',
441
-                'obj_id'     => $REG_ID,
442
-            ],
443
-            'wait_list_and_notify_registration'   => [
444
-                'func'       => 'wait_list_registration',
445
-                'noheader'   => true,
446
-                'args'       => [true],
447
-                'capability' => 'ee_edit_registration',
448
-                'obj_id'     => $REG_ID,
449
-            ],
450
-            'contact_list'                        => [
451
-                'func'       => '_attendee_contact_list_table',
452
-                'capability' => 'ee_read_contacts',
453
-            ],
454
-            'add_new_attendee'                    => [
455
-                'func' => '_create_new_cpt_item',
456
-                'args' => [
457
-                    'new_attendee' => true,
458
-                    'capability'   => 'ee_edit_contacts',
459
-                ],
460
-            ],
461
-            'edit_attendee'                       => [
462
-                'func'       => '_edit_cpt_item',
463
-                'capability' => 'ee_edit_contacts',
464
-                'obj_id'     => $ATT_ID,
465
-            ],
466
-            'duplicate_attendee'                  => [
467
-                'func'       => '_duplicate_attendee',
468
-                'noheader'   => true,
469
-                'capability' => 'ee_edit_contacts',
470
-                'obj_id'     => $ATT_ID,
471
-            ],
472
-            'insert_attendee'                     => [
473
-                'func'       => '_insert_or_update_attendee',
474
-                'args'       => [
475
-                    'new_attendee' => true,
476
-                ],
477
-                'noheader'   => true,
478
-                'capability' => 'ee_edit_contacts',
479
-            ],
480
-            'update_attendee'                     => [
481
-                'func'       => '_insert_or_update_attendee',
482
-                'args'       => [
483
-                    'new_attendee' => false,
484
-                ],
485
-                'noheader'   => true,
486
-                'capability' => 'ee_edit_contacts',
487
-                'obj_id'     => $ATT_ID,
488
-            ],
489
-            'trash_attendees'                     => [
490
-                'func'       => '_trash_or_restore_attendees',
491
-                'args'       => [
492
-                    'trash' => 'true',
493
-                ],
494
-                'noheader'   => true,
495
-                'capability' => 'ee_delete_contacts',
496
-            ],
497
-            'trash_attendee'                      => [
498
-                'func'       => '_trash_or_restore_attendees',
499
-                'args'       => [
500
-                    'trash' => true,
501
-                ],
502
-                'noheader'   => true,
503
-                'capability' => 'ee_delete_contacts',
504
-                'obj_id'     => $ATT_ID,
505
-            ],
506
-            'restore_attendees'                   => [
507
-                'func'       => '_trash_or_restore_attendees',
508
-                'args'       => [
509
-                    'trash' => false,
510
-                ],
511
-                'noheader'   => true,
512
-                'capability' => 'ee_delete_contacts',
513
-                'obj_id'     => $ATT_ID,
514
-            ],
515
-            'resend_registration'                 => [
516
-                'func'       => '_resend_registration',
517
-                'noheader'   => true,
518
-                'capability' => 'ee_send_message',
519
-            ],
520
-            'registrations_report'                => [
521
-                'func'       => [$this, '_registrations_report'],
522
-                'noheader'   => true,
523
-                'capability' => 'ee_read_registrations',
524
-            ],
525
-            'contact_list_export'                 => [
526
-                'func'       => '_contact_list_export',
527
-                'noheader'   => true,
528
-                'capability' => 'export',
529
-            ],
530
-            'contact_list_report'                 => [
531
-                'func'       => '_contact_list_report',
532
-                'noheader'   => true,
533
-                'capability' => 'ee_read_contacts',
534
-            ],
535
-        ];
536
-    }
537
-
538
-
539
-    protected function _set_page_config()
540
-    {
541
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
542
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
543
-        $this->_page_config = [
544
-            'default'           => [
545
-                'nav'           => [
546
-                    'label' => esc_html__('Overview', 'event_espresso'),
547
-                    'icon' => 'dashicons-list-view',
548
-                    'order' => 5,
549
-                ],
550
-                'help_tabs'     => [
551
-                    'registrations_overview_help_tab'                       => [
552
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
-                        'filename' => 'registrations_overview',
554
-                    ],
555
-                    'registrations_overview_table_column_headings_help_tab' => [
556
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
-                        'filename' => 'registrations_overview_table_column_headings',
558
-                    ],
559
-                    'registrations_overview_filters_help_tab'               => [
560
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
-                        'filename' => 'registrations_overview_filters',
562
-                    ],
563
-                    'registrations_overview_views_help_tab'                 => [
564
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
565
-                        'filename' => 'registrations_overview_views',
566
-                    ],
567
-                    'registrations_regoverview_other_help_tab'              => [
568
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
-                        'filename' => 'registrations_overview_other',
570
-                    ],
571
-                ],
572
-                'list_table'    => 'EE_Registrations_List_Table',
573
-                'require_nonce' => false,
574
-            ],
575
-            'view_registration' => [
576
-                'nav'           => [
577
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
578
-                    'icon' => 'dashicons-clipboard',
579
-                    'order'      => 15,
580
-                    'url'        => $REG_ID
581
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
-                        : $this->_admin_base_url,
583
-                    'persistent' => false,
584
-                ],
585
-                'help_tabs'     => [
586
-                    'registrations_details_help_tab'                    => [
587
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
588
-                        'filename' => 'registrations_details',
589
-                    ],
590
-                    'registrations_details_table_help_tab'              => [
591
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
-                        'filename' => 'registrations_details_table',
593
-                    ],
594
-                    'registrations_details_form_answers_help_tab'       => [
595
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
-                        'filename' => 'registrations_details_form_answers',
597
-                    ],
598
-                    'registrations_details_registrant_details_help_tab' => [
599
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
600
-                        'filename' => 'registrations_details_registrant_details',
601
-                    ],
602
-                ],
603
-                'metaboxes'     => array_merge(
604
-                    $this->_default_espresso_metaboxes,
605
-                    ['_registration_details_metaboxes']
606
-                ),
607
-                'require_nonce' => false,
608
-            ],
609
-            'new_registration'  => [
610
-                'nav'           => [
611
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
-                    'icon' => 'dashicons-plus-alt',
613
-                    'url'        => '#',
614
-                    'order'      => 15,
615
-                    'persistent' => false,
616
-                ],
617
-                'metaboxes'     => $this->_default_espresso_metaboxes,
618
-                'labels'        => [
619
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
620
-                ],
621
-                'require_nonce' => false,
622
-            ],
623
-            'add_new_attendee'  => [
624
-                'nav'           => [
625
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
626
-                    'icon' => 'dashicons-plus-alt',
627
-                    'order'      => 15,
628
-                    'persistent' => false,
629
-                ],
630
-                'metaboxes'     => array_merge(
631
-                    $this->_default_espresso_metaboxes,
632
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
633
-                ),
634
-                'require_nonce' => false,
635
-            ],
636
-            'edit_attendee'     => [
637
-                'nav'           => [
638
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
639
-                    'icon' => 'dashicons-edit-large',
640
-                    'order'      => 15,
641
-                    'persistent' => false,
642
-                    'url'        => $ATT_ID
643
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
644
-                        : $this->_admin_base_url,
645
-                ],
646
-                'metaboxes'     => array_merge(
647
-                    $this->_default_espresso_metaboxes,
648
-                    ['attendee_editor_metaboxes']
649
-                ),
650
-                'require_nonce' => false,
651
-            ],
652
-            'contact_list'      => [
653
-                'nav'           => [
654
-                    'label' => esc_html__('Contact List', 'event_espresso'),
655
-                    'icon' => 'dashicons-id-alt',
656
-                    'order' => 20,
657
-                ],
658
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
659
-                'help_tabs'     => [
660
-                    'registrations_contact_list_help_tab'                       => [
661
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
662
-                        'filename' => 'registrations_contact_list',
663
-                    ],
664
-                    'registrations_contact-list_table_column_headings_help_tab' => [
665
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
666
-                        'filename' => 'registrations_contact_list_table_column_headings',
667
-                    ],
668
-                    'registrations_contact_list_views_help_tab'                 => [
669
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
670
-                        'filename' => 'registrations_contact_list_views',
671
-                    ],
672
-                    'registrations_contact_list_other_help_tab'                 => [
673
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
674
-                        'filename' => 'registrations_contact_list_other',
675
-                    ],
676
-                ],
677
-                'metaboxes'     => [],
678
-                'require_nonce' => false,
679
-            ],
680
-            // override default cpt routes
681
-            'create_new'        => '',
682
-            'edit'              => '',
683
-        ];
684
-    }
685
-
686
-
687
-    /**
688
-     * The below methods aren't used by this class currently
689
-     */
690
-    protected function _add_screen_options()
691
-    {
692
-    }
693
-
694
-
695
-    protected function _add_feature_pointers()
696
-    {
697
-    }
698
-
699
-
700
-    public function admin_init()
701
-    {
702
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
703
-            'click "Update Registration Questions" to save your changes',
704
-            'event_espresso'
705
-        );
706
-    }
707
-
708
-
709
-    public function admin_notices()
710
-    {
711
-    }
712
-
713
-
714
-    public function admin_footer_scripts()
715
-    {
716
-    }
717
-
718
-
719
-    /**
720
-     * get list of registration statuses
721
-     *
722
-     * @return void
723
-     * @throws EE_Error
724
-     */
725
-    private function _get_registration_status_array()
726
-    {
727
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
728
-    }
729
-
730
-
731
-    /**
732
-     * @throws InvalidArgumentException
733
-     * @throws InvalidDataTypeException
734
-     * @throws InvalidInterfaceException
735
-     * @since 4.10.2.p
736
-     */
737
-    protected function _add_screen_options_default()
738
-    {
739
-        $this->_per_page_screen_option();
740
-    }
741
-
742
-
743
-    /**
744
-     * @throws InvalidArgumentException
745
-     * @throws InvalidDataTypeException
746
-     * @throws InvalidInterfaceException
747
-     * @since 4.10.2.p
748
-     */
749
-    protected function _add_screen_options_contact_list()
750
-    {
751
-        $page_title              = $this->_admin_page_title;
752
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
753
-        $this->_per_page_screen_option();
754
-        $this->_admin_page_title = $page_title;
755
-    }
756
-
757
-
758
-    public function load_scripts_styles()
759
-    {
760
-        // style
761
-        wp_register_style(
762
-            'espresso_reg',
763
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
764
-            ['ee-admin-css'],
765
-            EVENT_ESPRESSO_VERSION
766
-        );
767
-        wp_enqueue_style('espresso_reg');
768
-        // script
769
-        wp_register_script(
770
-            'espresso_reg',
771
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
772
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
773
-            EVENT_ESPRESSO_VERSION,
774
-            true
775
-        );
776
-        wp_enqueue_script('espresso_reg');
777
-    }
778
-
779
-
780
-    /**
781
-     * @throws EE_Error
782
-     * @throws InvalidArgumentException
783
-     * @throws InvalidDataTypeException
784
-     * @throws InvalidInterfaceException
785
-     * @throws ReflectionException
786
-     * @since 4.10.2.p
787
-     */
788
-    public function load_scripts_styles_edit_attendee()
789
-    {
790
-        // stuff to only show up on our attendee edit details page.
791
-        $attendee_details_translations = [
792
-            'att_publish_text' => sprintf(
793
-            /* translators: The date and time */
794
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
795
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
796
-            ),
797
-        ];
798
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
799
-        wp_enqueue_script('jquery-validate');
800
-    }
801
-
802
-
803
-    /**
804
-     * @throws EE_Error
805
-     * @throws InvalidArgumentException
806
-     * @throws InvalidDataTypeException
807
-     * @throws InvalidInterfaceException
808
-     * @throws ReflectionException
809
-     * @since 4.10.2.p
810
-     */
811
-    public function load_scripts_styles_view_registration()
812
-    {
813
-        // styles
814
-        wp_enqueue_style('espresso-ui-theme');
815
-        // scripts
816
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
817
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
818
-    }
819
-
820
-
821
-    public function load_scripts_styles_contact_list()
822
-    {
823
-        wp_dequeue_style('espresso_reg');
824
-        wp_register_style(
825
-            'espresso_att',
826
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
827
-            ['ee-admin-css'],
828
-            EVENT_ESPRESSO_VERSION
829
-        );
830
-        wp_enqueue_style('espresso_att');
831
-    }
832
-
833
-
834
-    public function load_scripts_styles_new_registration()
835
-    {
836
-        wp_register_script(
837
-            'ee-spco-for-admin',
838
-            REG_ASSETS_URL . 'spco_for_admin.js',
839
-            ['underscore', 'jquery'],
840
-            EVENT_ESPRESSO_VERSION,
841
-            true
842
-        );
843
-        wp_enqueue_script('ee-spco-for-admin');
844
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
845
-        EE_Form_Section_Proper::wp_enqueue_scripts();
846
-        EED_Ticket_Selector::load_tckt_slctr_assets();
847
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
848
-    }
849
-
850
-
851
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
852
-    {
853
-        add_filter('FHEE_load_EE_messages', '__return_true');
854
-    }
855
-
856
-
857
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
858
-    {
859
-        add_filter('FHEE_load_EE_messages', '__return_true');
860
-    }
861
-
862
-
863
-    /**
864
-     * @throws EE_Error
865
-     * @throws InvalidArgumentException
866
-     * @throws InvalidDataTypeException
867
-     * @throws InvalidInterfaceException
868
-     * @throws ReflectionException
869
-     * @since 4.10.2.p
870
-     */
871
-    protected function _set_list_table_views_default()
872
-    {
873
-        // for notification related bulk actions we need to make sure only active messengers have an option.
874
-        EED_Messages::set_autoloaders();
875
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
876
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
877
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
878
-        // key= bulk_action_slug, value= message type.
879
-        $match_array = [
880
-            'approve_registrations'    => 'registration',
881
-            'decline_registrations'    => 'declined_registration',
882
-            'pending_registrations'    => 'pending_approval',
883
-            'no_approve_registrations' => 'not_approved_registration',
884
-            'cancel_registrations'     => 'cancelled_registration',
885
-        ];
886
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
887
-            'ee_send_message',
888
-            'batch_send_messages'
889
-        );
890
-        /** setup reg status bulk actions **/
891
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
892
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
893
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
894
-                'Approve and Notify Registrations',
895
-                'event_espresso'
896
-            );
897
-        }
898
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
899
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
900
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
901
-                'Decline and Notify Registrations',
902
-                'event_espresso'
903
-            );
904
-        }
905
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
906
-            'Set Registrations to Pending Payment',
907
-            'event_espresso'
908
-        );
909
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
910
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
911
-                'Set Registrations to Pending Payment and Notify',
912
-                'event_espresso'
913
-            );
914
-        }
915
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
916
-            'Set Registrations to Not Approved',
917
-            'event_espresso'
918
-        );
919
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
920
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
921
-                'Set Registrations to Not Approved and Notify',
922
-                'event_espresso'
923
-            );
924
-        }
925
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
926
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
927
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
928
-                'Cancel Registrations and Notify',
929
-                'event_espresso'
930
-            );
931
-        }
932
-        $def_reg_status_actions = apply_filters(
933
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
934
-            $def_reg_status_actions,
935
-            $active_mts,
936
-            $can_send
937
-        );
938
-
939
-        $this->_views = [
940
-            'all'   => [
941
-                'slug'        => 'all',
942
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
943
-                'count'       => 0,
944
-                'bulk_action' => array_merge(
945
-                    $def_reg_status_actions,
946
-                    [
947
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
948
-                    ]
949
-                ),
950
-            ],
951
-            'month' => [
952
-                'slug'        => 'month',
953
-                'label'       => esc_html__('This Month', 'event_espresso'),
954
-                'count'       => 0,
955
-                'bulk_action' => array_merge(
956
-                    $def_reg_status_actions,
957
-                    [
958
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
959
-                    ]
960
-                ),
961
-            ],
962
-            'today' => [
963
-                'slug'        => 'today',
964
-                'label'       => sprintf(
965
-                    esc_html__('Today - %s', 'event_espresso'),
966
-                    date('M d, Y', current_time('timestamp'))
967
-                ),
968
-                'count'       => 0,
969
-                'bulk_action' => array_merge(
970
-                    $def_reg_status_actions,
971
-                    [
972
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
973
-                    ]
974
-                ),
975
-            ],
976
-        ];
977
-        if (
978
-            EE_Registry::instance()->CAP->current_user_can(
979
-                'ee_delete_registrations',
980
-                'espresso_registrations_delete_registration'
981
-            )
982
-        ) {
983
-            $this->_views['incomplete'] = [
984
-                'slug'        => 'incomplete',
985
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
986
-                'count'       => 0,
987
-                'bulk_action' => [
988
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
989
-                ],
990
-            ];
991
-            $this->_views['trash']      = [
992
-                'slug'        => 'trash',
993
-                'label'       => esc_html__('Trash', 'event_espresso'),
994
-                'count'       => 0,
995
-                'bulk_action' => [
996
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
997
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
998
-                ],
999
-            ];
1000
-        }
1001
-    }
1002
-
1003
-
1004
-    protected function _set_list_table_views_contact_list()
1005
-    {
1006
-        $this->_views = [
1007
-            'in_use' => [
1008
-                'slug'        => 'in_use',
1009
-                'label'       => esc_html__('In Use', 'event_espresso'),
1010
-                'count'       => 0,
1011
-                'bulk_action' => [
1012
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1013
-                ],
1014
-            ],
1015
-        ];
1016
-        if (
1017
-            EE_Registry::instance()->CAP->current_user_can(
1018
-                'ee_delete_contacts',
1019
-                'espresso_registrations_trash_attendees'
1020
-            )
1021
-        ) {
1022
-            $this->_views['trash'] = [
1023
-                'slug'        => 'trash',
1024
-                'label'       => esc_html__('Trash', 'event_espresso'),
1025
-                'count'       => 0,
1026
-                'bulk_action' => [
1027
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1028
-                ],
1029
-            ];
1030
-        }
1031
-    }
1032
-
1033
-
1034
-    /**
1035
-     * @return array
1036
-     * @throws EE_Error
1037
-     */
1038
-    protected function _registration_legend_items()
1039
-    {
1040
-        $fc_items = [
1041
-            'star-icon'        => [
1042
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1043
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1044
-            ],
1045
-            'view_details'     => [
1046
-                'class' => 'dashicons dashicons-clipboard',
1047
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1048
-            ],
1049
-            'edit_attendee'    => [
1050
-                'class' => 'dashicons dashicons-admin-users',
1051
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1052
-            ],
1053
-            'view_transaction' => [
1054
-                'class' => 'dashicons dashicons-cart',
1055
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1056
-            ],
1057
-            'view_invoice'     => [
1058
-                'class' => 'dashicons dashicons-media-spreadsheet',
1059
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1060
-            ],
1061
-        ];
1062
-        if (
1063
-            EE_Registry::instance()->CAP->current_user_can(
1064
-                'ee_send_message',
1065
-                'espresso_registrations_resend_registration'
1066
-            )
1067
-        ) {
1068
-            $fc_items['resend_registration'] = [
1069
-                'class' => 'dashicons dashicons-email-alt',
1070
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1071
-            ];
1072
-        } else {
1073
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1074
-        }
1075
-        if (
1076
-            EE_Registry::instance()->CAP->current_user_can(
1077
-                'ee_read_global_messages',
1078
-                'view_filtered_messages'
1079
-            )
1080
-        ) {
1081
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1082
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1083
-                $fc_items['view_related_messages'] = [
1084
-                    'class' => $related_for_icon['css_class'],
1085
-                    'desc'  => $related_for_icon['label'],
1086
-                ];
1087
-            }
1088
-        }
1089
-        $sc_items = [
1090
-            'approved_status'   => [
1091
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1092
-                'desc'  => EEH_Template::pretty_status(
1093
-                    EEM_Registration::status_id_approved,
1094
-                    false,
1095
-                    'sentence'
1096
-                ),
1097
-            ],
1098
-            'pending_status'    => [
1099
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1100
-                'desc'  => EEH_Template::pretty_status(
1101
-                    EEM_Registration::status_id_pending_payment,
1102
-                    false,
1103
-                    'sentence'
1104
-                ),
1105
-            ],
1106
-            'wait_list'         => [
1107
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1108
-                'desc'  => EEH_Template::pretty_status(
1109
-                    EEM_Registration::status_id_wait_list,
1110
-                    false,
1111
-                    'sentence'
1112
-                ),
1113
-            ],
1114
-            'incomplete_status' => [
1115
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1116
-                'desc'  => EEH_Template::pretty_status(
1117
-                    EEM_Registration::status_id_incomplete,
1118
-                    false,
1119
-                    'sentence'
1120
-                ),
1121
-            ],
1122
-            'not_approved'      => [
1123
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1124
-                'desc'  => EEH_Template::pretty_status(
1125
-                    EEM_Registration::status_id_not_approved,
1126
-                    false,
1127
-                    'sentence'
1128
-                ),
1129
-            ],
1130
-            'declined_status'   => [
1131
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1132
-                'desc'  => EEH_Template::pretty_status(
1133
-                    EEM_Registration::status_id_declined,
1134
-                    false,
1135
-                    'sentence'
1136
-                ),
1137
-            ],
1138
-            'cancelled_status'  => [
1139
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1140
-                'desc'  => EEH_Template::pretty_status(
1141
-                    EEM_Registration::status_id_cancelled,
1142
-                    false,
1143
-                    'sentence'
1144
-                ),
1145
-            ],
1146
-        ];
1147
-        return array_merge($fc_items, $sc_items);
1148
-    }
1149
-
1150
-
1151
-
1152
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1153
-
1154
-
1155
-    /**
1156
-     * @throws DomainException
1157
-     * @throws EE_Error
1158
-     * @throws InvalidArgumentException
1159
-     * @throws InvalidDataTypeException
1160
-     * @throws InvalidInterfaceException
1161
-     */
1162
-    protected function _registrations_overview_list_table()
1163
-    {
1164
-        $this->appendAddNewRegistrationButtonToPageTitle();
1165
-        $header_text                  = '';
1166
-        $admin_page_header_decorators = [
1167
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1168
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1169
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1170
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1171
-        ];
1172
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1173
-            $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1174
-            $header_text = $filter_header_decorator->getHeaderText($header_text);
1175
-        }
1176
-        $this->_template_args['before_list_table']  = $header_text;
1177
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1178
-        $this->display_admin_list_table_page_with_no_sidebar();
1179
-    }
1180
-
1181
-
1182
-    /**
1183
-     * @throws EE_Error
1184
-     * @throws InvalidArgumentException
1185
-     * @throws InvalidDataTypeException
1186
-     * @throws InvalidInterfaceException
1187
-     */
1188
-    private function appendAddNewRegistrationButtonToPageTitle()
1189
-    {
1190
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1191
-        if (
1192
-            $EVT_ID
1193
-            && EE_Registry::instance()->CAP->current_user_can(
1194
-                'ee_edit_registrations',
1195
-                'espresso_registrations_new_registration',
1196
-                $EVT_ID
1197
-            )
1198
-        ) {
1199
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1200
-                'new_registration',
1201
-                'add-registrant',
1202
-                ['event_id' => $EVT_ID],
1203
-                'add-new-h2'
1204
-            );
1205
-        }
1206
-    }
1207
-
1208
-
1209
-    /**
1210
-     * This sets the _registration property for the registration details screen
1211
-     *
1212
-     * @return void
1213
-     * @throws EE_Error
1214
-     * @throws InvalidArgumentException
1215
-     * @throws InvalidDataTypeException
1216
-     * @throws InvalidInterfaceException
1217
-     */
1218
-    private function _set_registration_object()
1219
-    {
1220
-        // get out if we've already set the object
1221
-        if ($this->_registration instanceof EE_Registration) {
1222
-            return;
1223
-        }
1224
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1225
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1226
-            return;
1227
-        }
1228
-        $error_msg = sprintf(
1229
-            esc_html__(
1230
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1231
-                'event_espresso'
1232
-            ),
1233
-            $REG_ID
1234
-        );
1235
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1236
-        $this->_registration = null;
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     * Used to retrieve registrations for the list table.
1242
-     *
1243
-     * @param int  $per_page
1244
-     * @param bool $count
1245
-     * @param bool $this_month
1246
-     * @param bool $today
1247
-     * @return EE_Registration[]|int
1248
-     * @throws EE_Error
1249
-     * @throws InvalidArgumentException
1250
-     * @throws InvalidDataTypeException
1251
-     * @throws InvalidInterfaceException
1252
-     */
1253
-    public function get_registrations(
1254
-        $per_page = 10,
1255
-        $count = false,
1256
-        $this_month = false,
1257
-        $today = false
1258
-    ) {
1259
-        if ($this_month) {
1260
-            $this->request->setRequestParam('status', 'month');
1261
-        }
1262
-        if ($today) {
1263
-            $this->request->setRequestParam('status', 'today');
1264
-        }
1265
-        $query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1266
-        /**
1267
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1268
-         *
1269
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1270
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1271
-         *                      or if you have the development copy of EE you can view this at the path:
1272
-         *                      /docs/G--Model-System/model-query-params.md
1273
-         */
1274
-        $query_params['group_by'] = '';
1275
-
1276
-        return $count
1277
-            ? $this->getRegistrationModel()->count($query_params)
1278
-            /** @type EE_Registration[] */
1279
-            : $this->getRegistrationModel()->get_all($query_params);
1280
-    }
1281
-
1282
-
1283
-    /**
1284
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1285
-     * Note: this listens to values on the request for some of the query parameters.
1286
-     *
1287
-     * @param array $request
1288
-     * @param int   $per_page
1289
-     * @param bool  $count
1290
-     * @return array
1291
-     * @throws EE_Error
1292
-     * @throws InvalidArgumentException
1293
-     * @throws InvalidDataTypeException
1294
-     * @throws InvalidInterfaceException
1295
-     */
1296
-    protected function _get_registration_query_parameters(
1297
-        $request = [],
1298
-        $per_page = 10,
1299
-        $count = false
1300
-    ) {
1301
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1302
-        $list_table_query_builder = $this->loader->getNew(
1303
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1304
-            [null, null, $request]
1305
-        );
1306
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1307
-    }
1308
-
1309
-
1310
-    public function get_registration_status_array()
1311
-    {
1312
-        return self::$_reg_status;
1313
-    }
1314
-
1315
-
1316
-
1317
-
1318
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1319
-    /**
1320
-     * generates HTML for the View Registration Details Admin page
1321
-     *
1322
-     * @return void
1323
-     * @throws DomainException
1324
-     * @throws EE_Error
1325
-     * @throws InvalidArgumentException
1326
-     * @throws InvalidDataTypeException
1327
-     * @throws InvalidInterfaceException
1328
-     * @throws EntityNotFoundException
1329
-     * @throws ReflectionException
1330
-     */
1331
-    protected function _registration_details()
1332
-    {
1333
-        $this->_template_args = [];
1334
-        $this->_set_registration_object();
1335
-        if (is_object($this->_registration)) {
1336
-            $transaction                                   = $this->_registration->transaction()
1337
-                ? $this->_registration->transaction()
1338
-                : EE_Transaction::new_instance();
1339
-            $this->_session                                = $transaction->session_data();
1340
-            $event_id                                      = $this->_registration->event_ID();
1341
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1342
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1343
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1344
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1345
-            $this->_template_args['grand_total']           = $transaction->total();
1346
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1347
-            // link back to overview
1348
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1349
-            $this->_template_args['registration']                = $this->_registration;
1350
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1351
-                [
1352
-                    'action'   => 'default',
1353
-                    'event_id' => $event_id,
1354
-                ],
1355
-                REG_ADMIN_URL
1356
-            );
1357
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1358
-                [
1359
-                    'action' => 'default',
1360
-                    'EVT_ID' => $event_id,
1361
-                    'page'   => 'espresso_transactions',
1362
-                ],
1363
-                admin_url('admin.php')
1364
-            );
1365
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1366
-                [
1367
-                    'page'   => 'espresso_events',
1368
-                    'action' => 'edit',
1369
-                    'post'   => $event_id,
1370
-                ],
1371
-                admin_url('admin.php')
1372
-            );
1373
-            // next and previous links
1374
-            $next_reg                                      = $this->_registration->next(
1375
-                null,
1376
-                [],
1377
-                'REG_ID'
1378
-            );
1379
-            $this->_template_args['next_registration']     = $next_reg
1380
-                ? $this->_next_link(
1381
-                    EE_Admin_Page::add_query_args_and_nonce(
1382
-                        [
1383
-                            'action'  => 'view_registration',
1384
-                            '_REG_ID' => $next_reg['REG_ID'],
1385
-                        ],
1386
-                        REG_ADMIN_URL
1387
-                    ),
1388
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1389
-                )
1390
-                : '';
1391
-            $previous_reg                                  = $this->_registration->previous(
1392
-                null,
1393
-                [],
1394
-                'REG_ID'
1395
-            );
1396
-            $this->_template_args['previous_registration'] = $previous_reg
1397
-                ? $this->_previous_link(
1398
-                    EE_Admin_Page::add_query_args_and_nonce(
1399
-                        [
1400
-                            'action'  => 'view_registration',
1401
-                            '_REG_ID' => $previous_reg['REG_ID'],
1402
-                        ],
1403
-                        REG_ADMIN_URL
1404
-                    ),
1405
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1406
-                )
1407
-                : '';
1408
-            // grab header
1409
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1410
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1411
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1412
-                $template_path,
1413
-                $this->_template_args,
1414
-                true
1415
-            );
1416
-        } else {
1417
-            $this->_template_args['admin_page_header'] = '';
1418
-            $this->_display_espresso_notices();
1419
-        }
1420
-        // the details template wrapper
1421
-        $this->display_admin_page_with_sidebar();
1422
-    }
1423
-
1424
-
1425
-    /**
1426
-     * @throws EE_Error
1427
-     * @throws InvalidArgumentException
1428
-     * @throws InvalidDataTypeException
1429
-     * @throws InvalidInterfaceException
1430
-     * @throws ReflectionException
1431
-     * @since 4.10.2.p
1432
-     */
1433
-    protected function _registration_details_metaboxes()
1434
-    {
1435
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1436
-        $this->_set_registration_object();
1437
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1438
-        $this->addMetaBox(
1439
-            'edit-reg-status-mbox',
1440
-            esc_html__('Registration Status', 'event_espresso'),
1441
-            [$this, 'set_reg_status_buttons_metabox'],
1442
-            $this->_wp_page_slug
1443
-        );
1444
-        $this->addMetaBox(
1445
-            'edit-reg-details-mbox',
1446
-            '<span>' . esc_html__('Registration Details', 'event_espresso')
1447
-            . '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1448
-            [$this, '_reg_details_meta_box'],
1449
-            $this->_wp_page_slug
1450
-        );
1451
-        if (
1452
-            $attendee instanceof EE_Attendee
1453
-            && EE_Registry::instance()->CAP->current_user_can(
1454
-                'ee_read_registration',
1455
-                'edit-reg-questions-mbox',
1456
-                $this->_registration->ID()
1457
-            )
1458
-        ) {
1459
-            $this->addMetaBox(
1460
-                'edit-reg-questions-mbox',
1461
-                esc_html__('Registration Form Answers', 'event_espresso'),
1462
-                [$this, '_reg_questions_meta_box'],
1463
-                $this->_wp_page_slug
1464
-            );
1465
-        }
1466
-        $this->addMetaBox(
1467
-            'edit-reg-registrant-mbox',
1468
-            esc_html__('Contact Details', 'event_espresso'),
1469
-            [$this, '_reg_registrant_side_meta_box'],
1470
-            $this->_wp_page_slug,
1471
-            'side'
1472
-        );
1473
-        if ($this->_registration->group_size() > 1) {
1474
-            $this->addMetaBox(
1475
-                'edit-reg-attendees-mbox',
1476
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1477
-                [$this, '_reg_attendees_meta_box'],
1478
-                $this->_wp_page_slug
1479
-            );
1480
-        }
1481
-    }
1482
-
1483
-
1484
-    /**
1485
-     * set_reg_status_buttons_metabox
1486
-     *
1487
-     * @return void
1488
-     * @throws EE_Error
1489
-     * @throws EntityNotFoundException
1490
-     * @throws InvalidArgumentException
1491
-     * @throws InvalidDataTypeException
1492
-     * @throws InvalidInterfaceException
1493
-     * @throws ReflectionException
1494
-     */
1495
-    public function set_reg_status_buttons_metabox()
1496
-    {
1497
-        $this->_set_registration_object();
1498
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1499
-        $output                 = $change_reg_status_form->form_open(
1500
-            self::add_query_args_and_nonce(
1501
-                [
1502
-                    'action' => 'change_reg_status',
1503
-                ],
1504
-                REG_ADMIN_URL
1505
-            )
1506
-        );
1507
-        $output                 .= $change_reg_status_form->get_html();
1508
-        $output                 .= $change_reg_status_form->form_close();
1509
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1510
-    }
1511
-
1512
-
1513
-    /**
1514
-     * @return EE_Form_Section_Proper
1515
-     * @throws EE_Error
1516
-     * @throws InvalidArgumentException
1517
-     * @throws InvalidDataTypeException
1518
-     * @throws InvalidInterfaceException
1519
-     * @throws EntityNotFoundException
1520
-     * @throws ReflectionException
1521
-     */
1522
-    protected function _generate_reg_status_change_form()
1523
-    {
1524
-        $reg_status_change_form_array = [
1525
-            'name'            => 'reg_status_change_form',
1526
-            'html_id'         => 'reg-status-change-form',
1527
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1528
-            'subsections'     => [
1529
-                'return'         => new EE_Hidden_Input(
1530
-                    [
1531
-                        'name'    => 'return',
1532
-                        'default' => 'view_registration',
1533
-                    ]
1534
-                ),
1535
-                'REG_ID'         => new EE_Hidden_Input(
1536
-                    [
1537
-                        'name'    => 'REG_ID',
1538
-                        'default' => $this->_registration->ID(),
1539
-                    ]
1540
-                ),
1541
-            ],
1542
-        ];
1543
-        if (
1544
-            EE_Registry::instance()->CAP->current_user_can(
1545
-                'ee_edit_registration',
1546
-                'toggle_registration_status',
1547
-                $this->_registration->ID()
1548
-            )
1549
-        ) {
1550
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1551
-                $this->_get_reg_statuses(),
1552
-                [
1553
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1554
-                    'default'         => $this->_registration->status_ID(),
1555
-                ]
1556
-            );
1557
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1558
-                [
1559
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1560
-                    'default'         => false,
1561
-                    'html_help_text'  => esc_html__(
1562
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1563
-                        'event_espresso'
1564
-                    ),
1565
-                ]
1566
-            );
1567
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1568
-                [
1569
-                    'html_class'      => 'button--primary',
1570
-                    'html_label_text' => '&nbsp;',
1571
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1572
-                ]
1573
-            );
1574
-        }
1575
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1576
-    }
1577
-
1578
-
1579
-    /**
1580
-     * Returns an array of all the buttons for the various statuses and switch status actions
1581
-     *
1582
-     * @return array
1583
-     * @throws EE_Error
1584
-     * @throws InvalidArgumentException
1585
-     * @throws InvalidDataTypeException
1586
-     * @throws InvalidInterfaceException
1587
-     * @throws EntityNotFoundException
1588
-     */
1589
-    protected function _get_reg_statuses()
1590
-    {
1591
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1592
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1593
-        // get current reg status
1594
-        $current_status = $this->_registration->status_ID();
1595
-        // is registration for free event? This will determine whether to display the pending payment option
1596
-        if (
1597
-            $current_status !== EEM_Registration::status_id_pending_payment
1598
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1599
-        ) {
1600
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1601
-        }
1602
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1603
-    }
1604
-
1605
-
1606
-    /**
1607
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1608
-     *
1609
-     * @param bool $status REG status given for changing registrations to.
1610
-     * @param bool $notify Whether to send messages notifications or not.
1611
-     * @return array (array with reg_id(s) updated and whether update was successful.
1612
-     * @throws DomainException
1613
-     * @throws EE_Error
1614
-     * @throws EntityNotFoundException
1615
-     * @throws InvalidArgumentException
1616
-     * @throws InvalidDataTypeException
1617
-     * @throws InvalidInterfaceException
1618
-     * @throws ReflectionException
1619
-     * @throws RuntimeException
1620
-     */
1621
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1622
-    {
1623
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1624
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1625
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1626
-
1627
-        // sanitize $REG_IDs
1628
-        $REG_IDs = array_map('absint', $REG_IDs);
1629
-        // and remove empty entries
1630
-        $REG_IDs = array_filter($REG_IDs);
1631
-
1632
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1633
-
1634
-        /**
1635
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1636
-         * Currently this value is used downstream by the _process_resend_registration method.
1637
-         *
1638
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1639
-         * @param bool                     $status           The status registrations were changed to.
1640
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1641
-         * @param Registrations_Admin_Page $admin_page_object
1642
-         */
1643
-        $REG_ID = apply_filters(
1644
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1645
-            $result['REG_ID'],
1646
-            $status,
1647
-            $result['success'],
1648
-            $this
1649
-        );
1650
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1651
-
1652
-        // notify?
1653
-        if (
1654
-            $notify
1655
-            && $result['success']
1656
-            && ! empty($REG_ID)
1657
-            && EE_Registry::instance()->CAP->current_user_can(
1658
-                'ee_send_message',
1659
-                'espresso_registrations_resend_registration'
1660
-            )
1661
-        ) {
1662
-            $this->_process_resend_registration();
1663
-        }
1664
-        return $result;
1665
-    }
1666
-
1667
-
1668
-    /**
1669
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1670
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1671
-     *
1672
-     * @param array  $REG_IDs
1673
-     * @param string $status
1674
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1675
-     *                       slug sent with setting the registration status.
1676
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1677
-     * @throws EE_Error
1678
-     * @throws InvalidArgumentException
1679
-     * @throws InvalidDataTypeException
1680
-     * @throws InvalidInterfaceException
1681
-     * @throws ReflectionException
1682
-     * @throws RuntimeException
1683
-     * @throws EntityNotFoundException
1684
-     * @throws DomainException
1685
-     */
1686
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1687
-    {
1688
-        $success = false;
1689
-        // typecast $REG_IDs
1690
-        $REG_IDs = (array) $REG_IDs;
1691
-        if (! empty($REG_IDs)) {
1692
-            $success = true;
1693
-            // set default status if none is passed
1694
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1695
-            $status_context = $notify
1696
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1697
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1698
-            // loop through REG_ID's and change status
1699
-            foreach ($REG_IDs as $REG_ID) {
1700
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1701
-                if ($registration instanceof EE_Registration) {
1702
-                    $registration->set_status(
1703
-                        $status,
1704
-                        false,
1705
-                        new Context(
1706
-                            $status_context,
1707
-                            esc_html__(
1708
-                                'Manually triggered status change on a Registration Admin Page route.',
1709
-                                'event_espresso'
1710
-                            )
1711
-                        )
1712
-                    );
1713
-                    $result = $registration->save();
1714
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1715
-                    $success = $result !== false ? $success : false;
1716
-                }
1717
-            }
1718
-        }
1719
-
1720
-        // return $success and processed registrations
1721
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1722
-    }
1723
-
1724
-
1725
-    /**
1726
-     * Common logic for setting up success message and redirecting to appropriate route
1727
-     *
1728
-     * @param string $STS_ID status id for the registration changed to
1729
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1730
-     * @return void
1731
-     * @throws DomainException
1732
-     * @throws EE_Error
1733
-     * @throws EntityNotFoundException
1734
-     * @throws InvalidArgumentException
1735
-     * @throws InvalidDataTypeException
1736
-     * @throws InvalidInterfaceException
1737
-     * @throws ReflectionException
1738
-     * @throws RuntimeException
1739
-     */
1740
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1741
-    {
1742
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1743
-            : ['success' => false];
1744
-        $success = isset($result['success']) && $result['success'];
1745
-        // setup success message
1746
-        if ($success) {
1747
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1748
-                $msg = sprintf(
1749
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1750
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1751
-                );
1752
-            } else {
1753
-                $msg = sprintf(
1754
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1755
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1756
-                );
1757
-            }
1758
-            EE_Error::add_success($msg);
1759
-        } else {
1760
-            EE_Error::add_error(
1761
-                esc_html__(
1762
-                    'Something went wrong, and the status was not changed',
1763
-                    'event_espresso'
1764
-                ),
1765
-                __FILE__,
1766
-                __LINE__,
1767
-                __FUNCTION__
1768
-            );
1769
-        }
1770
-        $return = $this->request->getRequestParam('return');
1771
-        $route  = $return === 'view_registration'
1772
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1773
-            : ['action' => 'default'];
1774
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1775
-        $this->_redirect_after_action($success, '', '', $route, true);
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     * incoming reg status change from reg details page.
1781
-     *
1782
-     * @return void
1783
-     * @throws EE_Error
1784
-     * @throws EntityNotFoundException
1785
-     * @throws InvalidArgumentException
1786
-     * @throws InvalidDataTypeException
1787
-     * @throws InvalidInterfaceException
1788
-     * @throws ReflectionException
1789
-     * @throws RuntimeException
1790
-     * @throws DomainException
1791
-     */
1792
-    protected function _change_reg_status()
1793
-    {
1794
-        $this->request->setRequestParam('return', 'view_registration');
1795
-        // set notify based on whether the send notifications toggle is set or not
1796
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1797
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1798
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1799
-        switch ($reg_status) {
1800
-            case EEM_Registration::status_id_approved:
1801
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1802
-                $this->approve_registration($notify);
1803
-                break;
1804
-            case EEM_Registration::status_id_pending_payment:
1805
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1806
-                $this->pending_registration($notify);
1807
-                break;
1808
-            case EEM_Registration::status_id_not_approved:
1809
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1810
-                $this->not_approve_registration($notify);
1811
-                break;
1812
-            case EEM_Registration::status_id_declined:
1813
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1814
-                $this->decline_registration($notify);
1815
-                break;
1816
-            case EEM_Registration::status_id_cancelled:
1817
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1818
-                $this->cancel_registration($notify);
1819
-                break;
1820
-            case EEM_Registration::status_id_wait_list:
1821
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1822
-                $this->wait_list_registration($notify);
1823
-                break;
1824
-            case EEM_Registration::status_id_incomplete:
1825
-            default:
1826
-                $this->request->unSetRequestParam('return');
1827
-                $this->_reg_status_change_return('');
1828
-                break;
1829
-        }
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * Callback for bulk action routes.
1835
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1836
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1837
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1838
-     * when an action is happening on just a single registration).
1839
-     *
1840
-     * @param      $action
1841
-     * @param bool $notify
1842
-     */
1843
-    protected function bulk_action_on_registrations($action, $notify = false)
1844
-    {
1845
-        do_action(
1846
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1847
-            $this,
1848
-            $action,
1849
-            $notify
1850
-        );
1851
-        $method = $action . '_registration';
1852
-        if (method_exists($this, $method)) {
1853
-            $this->$method($notify);
1854
-        }
1855
-    }
1856
-
1857
-
1858
-    /**
1859
-     * approve_registration
1860
-     *
1861
-     * @param bool $notify whether or not to notify the registrant about their approval.
1862
-     * @return void
1863
-     * @throws EE_Error
1864
-     * @throws EntityNotFoundException
1865
-     * @throws InvalidArgumentException
1866
-     * @throws InvalidDataTypeException
1867
-     * @throws InvalidInterfaceException
1868
-     * @throws ReflectionException
1869
-     * @throws RuntimeException
1870
-     * @throws DomainException
1871
-     */
1872
-    protected function approve_registration($notify = false)
1873
-    {
1874
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1875
-    }
1876
-
1877
-
1878
-    /**
1879
-     * decline_registration
1880
-     *
1881
-     * @param bool $notify whether or not to notify the registrant about their status change.
1882
-     * @return void
1883
-     * @throws EE_Error
1884
-     * @throws EntityNotFoundException
1885
-     * @throws InvalidArgumentException
1886
-     * @throws InvalidDataTypeException
1887
-     * @throws InvalidInterfaceException
1888
-     * @throws ReflectionException
1889
-     * @throws RuntimeException
1890
-     * @throws DomainException
1891
-     */
1892
-    protected function decline_registration($notify = false)
1893
-    {
1894
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1895
-    }
1896
-
1897
-
1898
-    /**
1899
-     * cancel_registration
1900
-     *
1901
-     * @param bool $notify whether or not to notify the registrant about their status change.
1902
-     * @return void
1903
-     * @throws EE_Error
1904
-     * @throws EntityNotFoundException
1905
-     * @throws InvalidArgumentException
1906
-     * @throws InvalidDataTypeException
1907
-     * @throws InvalidInterfaceException
1908
-     * @throws ReflectionException
1909
-     * @throws RuntimeException
1910
-     * @throws DomainException
1911
-     */
1912
-    protected function cancel_registration($notify = false)
1913
-    {
1914
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1915
-    }
1916
-
1917
-
1918
-    /**
1919
-     * not_approve_registration
1920
-     *
1921
-     * @param bool $notify whether or not to notify the registrant about their status change.
1922
-     * @return void
1923
-     * @throws EE_Error
1924
-     * @throws EntityNotFoundException
1925
-     * @throws InvalidArgumentException
1926
-     * @throws InvalidDataTypeException
1927
-     * @throws InvalidInterfaceException
1928
-     * @throws ReflectionException
1929
-     * @throws RuntimeException
1930
-     * @throws DomainException
1931
-     */
1932
-    protected function not_approve_registration($notify = false)
1933
-    {
1934
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1935
-    }
1936
-
1937
-
1938
-    /**
1939
-     * decline_registration
1940
-     *
1941
-     * @param bool $notify whether or not to notify the registrant about their status change.
1942
-     * @return void
1943
-     * @throws EE_Error
1944
-     * @throws EntityNotFoundException
1945
-     * @throws InvalidArgumentException
1946
-     * @throws InvalidDataTypeException
1947
-     * @throws InvalidInterfaceException
1948
-     * @throws ReflectionException
1949
-     * @throws RuntimeException
1950
-     * @throws DomainException
1951
-     */
1952
-    protected function pending_registration($notify = false)
1953
-    {
1954
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1955
-    }
1956
-
1957
-
1958
-    /**
1959
-     * waitlist_registration
1960
-     *
1961
-     * @param bool $notify whether or not to notify the registrant about their status change.
1962
-     * @return void
1963
-     * @throws EE_Error
1964
-     * @throws EntityNotFoundException
1965
-     * @throws InvalidArgumentException
1966
-     * @throws InvalidDataTypeException
1967
-     * @throws InvalidInterfaceException
1968
-     * @throws ReflectionException
1969
-     * @throws RuntimeException
1970
-     * @throws DomainException
1971
-     */
1972
-    protected function wait_list_registration($notify = false)
1973
-    {
1974
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1975
-    }
1976
-
1977
-
1978
-    /**
1979
-     * generates HTML for the Registration main meta box
1980
-     *
1981
-     * @return void
1982
-     * @throws DomainException
1983
-     * @throws EE_Error
1984
-     * @throws InvalidArgumentException
1985
-     * @throws InvalidDataTypeException
1986
-     * @throws InvalidInterfaceException
1987
-     * @throws ReflectionException
1988
-     * @throws EntityNotFoundException
1989
-     */
1990
-    public function _reg_details_meta_box()
1991
-    {
1992
-        EEH_Autoloader::register_line_item_display_autoloaders();
1993
-        EEH_Autoloader::register_line_item_filter_autoloaders();
1994
-        EE_Registry::instance()->load_helper('Line_Item');
1995
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1996
-            : EE_Transaction::new_instance();
1997
-        $this->_session = $transaction->session_data();
1998
-        $filters        = new EE_Line_Item_Filter_Collection();
1999
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2000
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2001
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2002
-            $filters,
2003
-            $transaction->total_line_item()
2004
-        );
2005
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2006
-        $line_item_display                       = new EE_Line_Item_Display(
2007
-            'reg_admin_table',
2008
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2009
-        );
2010
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2011
-            $filtered_line_item_tree,
2012
-            ['EE_Registration' => $this->_registration]
2013
-        );
2014
-        $attendee                                = $this->_registration->attendee();
2015
-        if (
2016
-            EE_Registry::instance()->CAP->current_user_can(
2017
-                'ee_read_transaction',
2018
-                'espresso_transactions_view_transaction'
2019
-            )
2020
-        ) {
2021
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2022
-                EE_Admin_Page::add_query_args_and_nonce(
2023
-                    [
2024
-                        'action' => 'view_transaction',
2025
-                        'TXN_ID' => $transaction->ID(),
2026
-                    ],
2027
-                    TXN_ADMIN_URL
2028
-                ),
2029
-                esc_html__(' View Transaction', 'event_espresso'),
2030
-                'button button--secondary right',
2031
-                'dashicons dashicons-cart'
2032
-            );
2033
-        } else {
2034
-            $this->_template_args['view_transaction_button'] = '';
2035
-        }
2036
-        if (
2037
-            $attendee instanceof EE_Attendee
2038
-            && EE_Registry::instance()->CAP->current_user_can(
2039
-                'ee_send_message',
2040
-                'espresso_registrations_resend_registration'
2041
-            )
2042
-        ) {
2043
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2044
-                EE_Admin_Page::add_query_args_and_nonce(
2045
-                    [
2046
-                        'action'      => 'resend_registration',
2047
-                        '_REG_ID'     => $this->_registration->ID(),
2048
-                        'redirect_to' => 'view_registration',
2049
-                    ],
2050
-                    REG_ADMIN_URL
2051
-                ),
2052
-                esc_html__(' Resend Registration', 'event_espresso'),
2053
-                'button button--secondary right',
2054
-                'dashicons dashicons-email-alt'
2055
-            );
2056
-        } else {
2057
-            $this->_template_args['resend_registration_button'] = '';
2058
-        }
2059
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2060
-        $payment                               = $transaction->get_first_related('Payment');
2061
-        $payment                               = ! $payment instanceof EE_Payment
2062
-            ? EE_Payment::new_instance()
2063
-            : $payment;
2064
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2065
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2066
-            ? EE_Payment_Method::new_instance()
2067
-            : $payment_method;
2068
-        $reg_details                           = [
2069
-            'payment_method'       => $payment_method->name(),
2070
-            'response_msg'         => $payment->gateway_response(),
2071
-            'registration_id'      => $this->_registration->get('REG_code'),
2072
-            'registration_session' => $this->_registration->session_ID(),
2073
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2074
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2075
-        ];
2076
-        if (isset($reg_details['registration_id'])) {
2077
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2078
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2079
-                'Registration ID',
2080
-                'event_espresso'
2081
-            );
2082
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2083
-        }
2084
-        if (isset($reg_details['payment_method'])) {
2085
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2086
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2087
-                'Most Recent Payment Method',
2088
-                'event_espresso'
2089
-            );
2090
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2091
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2092
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2093
-                'Payment method response',
2094
-                'event_espresso'
2095
-            );
2096
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2097
-        }
2098
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2099
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2100
-            'Registration Session',
2101
-            'event_espresso'
2102
-        );
2103
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2104
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2105
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2106
-            'Registration placed from IP',
2107
-            'event_espresso'
2108
-        );
2109
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2110
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2111
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2112
-            'Registrant User Agent',
2113
-            'event_espresso'
2114
-        );
2115
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2116
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2117
-            [
2118
-                'action'   => 'default',
2119
-                'event_id' => $this->_registration->event_ID(),
2120
-            ],
2121
-            REG_ADMIN_URL
2122
-        );
2123
-
2124
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2125
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2126
-
2127
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2128
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2129
-    }
2130
-
2131
-
2132
-    /**
2133
-     * generates HTML for the Registration Questions meta box.
2134
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2135
-     * otherwise uses new forms system
2136
-     *
2137
-     * @return void
2138
-     * @throws DomainException
2139
-     * @throws EE_Error
2140
-     * @throws InvalidArgumentException
2141
-     * @throws InvalidDataTypeException
2142
-     * @throws InvalidInterfaceException
2143
-     * @throws ReflectionException
2144
-     */
2145
-    public function _reg_questions_meta_box()
2146
-    {
2147
-        // allow someone to override this method entirely
2148
-        if (
2149
-            apply_filters(
2150
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2151
-                true,
2152
-                $this,
2153
-                $this->_registration
2154
-            )
2155
-        ) {
2156
-            $form = $this->_get_reg_custom_questions_form(
2157
-                $this->_registration->ID()
2158
-            );
2159
-
2160
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2161
-                ? $form->get_html_and_js()
2162
-                : '';
2163
-
2164
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2165
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2166
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2167
-            EEH_Template::display_template($template_path, $this->_template_args);
2168
-        }
2169
-    }
2170
-
2171
-
2172
-    /**
2173
-     * form_before_question_group
2174
-     *
2175
-     * @param string $output
2176
-     * @return        string
2177
-     * @deprecated    as of 4.8.32.rc.000
2178
-     */
2179
-    public function form_before_question_group($output)
2180
-    {
2181
-        EE_Error::doing_it_wrong(
2182
-            __CLASS__ . '::' . __FUNCTION__,
2183
-            esc_html__(
2184
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2185
-                'event_espresso'
2186
-            ),
2187
-            '4.8.32.rc.000'
2188
-        );
2189
-        return '
23
+	/**
24
+	 * @var EE_Registration
25
+	 */
26
+	private $_registration;
27
+
28
+	/**
29
+	 * @var EE_Event
30
+	 */
31
+	private $_reg_event;
32
+
33
+	/**
34
+	 * @var EE_Session
35
+	 */
36
+	private $_session;
37
+
38
+	/**
39
+	 * @var array
40
+	 */
41
+	private static $_reg_status;
42
+
43
+	/**
44
+	 * Form for displaying the custom questions for this registration.
45
+	 * This gets used a few times throughout the request so its best to cache it
46
+	 *
47
+	 * @var EE_Registration_Custom_Questions_Form
48
+	 */
49
+	protected $_reg_custom_questions_form;
50
+
51
+	/**
52
+	 * @var EEM_Registration $registration_model
53
+	 */
54
+	private $registration_model;
55
+
56
+	/**
57
+	 * @var EEM_Attendee $attendee_model
58
+	 */
59
+	private $attendee_model;
60
+
61
+	/**
62
+	 * @var EEM_Event $event_model
63
+	 */
64
+	private $event_model;
65
+
66
+	/**
67
+	 * @var EEM_Status $status_model
68
+	 */
69
+	private $status_model;
70
+
71
+
72
+	/**
73
+	 * @param bool $routing
74
+	 * @throws EE_Error
75
+	 * @throws InvalidArgumentException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws ReflectionException
79
+	 */
80
+	public function __construct($routing = true)
81
+	{
82
+		parent::__construct($routing);
83
+		add_action('wp_loaded', [$this, 'wp_loaded']);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return EEM_Registration
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 * @since 4.10.2.p
93
+	 */
94
+	protected function getRegistrationModel()
95
+	{
96
+		if (! $this->registration_model instanceof EEM_Registration) {
97
+			$this->registration_model = $this->loader->getShared('EEM_Registration');
98
+		}
99
+		return $this->registration_model;
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return EEM_Attendee
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @since 4.10.2.p
109
+	 */
110
+	protected function getAttendeeModel()
111
+	{
112
+		if (! $this->attendee_model instanceof EEM_Attendee) {
113
+			$this->attendee_model = $this->loader->getShared('EEM_Attendee');
114
+		}
115
+		return $this->attendee_model;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return EEM_Event
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidInterfaceException
124
+	 * @since 4.10.2.p
125
+	 */
126
+	protected function getEventModel()
127
+	{
128
+		if (! $this->event_model instanceof EEM_Event) {
129
+			$this->event_model = $this->loader->getShared('EEM_Event');
130
+		}
131
+		return $this->event_model;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return EEM_Status
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 * @since 4.10.2.p
141
+	 */
142
+	protected function getStatusModel()
143
+	{
144
+		if (! $this->status_model instanceof EEM_Status) {
145
+			$this->status_model = $this->loader->getShared('EEM_Status');
146
+		}
147
+		return $this->status_model;
148
+	}
149
+
150
+
151
+	public function wp_loaded()
152
+	{
153
+		// when adding a new registration...
154
+		$action = $this->request->getRequestParam('action');
155
+		if ($action === 'new_registration') {
156
+			EE_System::do_not_cache();
157
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
+				// and it's NOT the attendee information reg step
159
+				// force cookie expiration by setting time to last week
160
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
+				// and update the global
162
+				$_COOKIE['ee_registration_added'] = 0;
163
+			}
164
+		}
165
+	}
166
+
167
+
168
+	protected function _init_page_props()
169
+	{
170
+		$this->page_slug        = REG_PG_SLUG;
171
+		$this->_admin_base_url  = REG_ADMIN_URL;
172
+		$this->_admin_base_path = REG_ADMIN;
173
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
174
+		$this->_cpt_routes      = [
175
+			'add_new_attendee' => 'espresso_attendees',
176
+			'edit_attendee'    => 'espresso_attendees',
177
+			'insert_attendee'  => 'espresso_attendees',
178
+			'update_attendee'  => 'espresso_attendees',
179
+		];
180
+		$this->_cpt_model_names = [
181
+			'add_new_attendee' => 'EEM_Attendee',
182
+			'edit_attendee'    => 'EEM_Attendee',
183
+		];
184
+		$this->_cpt_edit_routes = [
185
+			'espresso_attendees' => 'edit_attendee',
186
+		];
187
+		$this->_pagenow_map     = [
188
+			'add_new_attendee' => 'post-new.php',
189
+			'edit_attendee'    => 'post.php',
190
+			'trash'            => 'post.php',
191
+		];
192
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
+		// add filters so that the comment urls don't take users to a confusing 404 page
194
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
+	}
196
+
197
+
198
+	/**
199
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
200
+	 * @param WP_Comment $comment The current comment object.
201
+	 * @return string
202
+	 */
203
+	public function clear_comment_link($link, WP_Comment $comment)
204
+	{
205
+		// gotta make sure this only happens on this route
206
+		$post_type = get_post_type($comment->comment_post_ID);
207
+		if ($post_type === 'espresso_attendees') {
208
+			return '#commentsdiv';
209
+		}
210
+		return $link;
211
+	}
212
+
213
+
214
+	protected function _ajax_hooks()
215
+	{
216
+		// todo: all hooks for registrations ajax goes in here
217
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
+	}
219
+
220
+
221
+	protected function _define_page_props()
222
+	{
223
+		$this->_admin_page_title = $this->page_label;
224
+		$this->_labels           = [
225
+			'buttons'                      => [
226
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
+				'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
230
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
231
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
232
+			],
233
+			'publishbox'                   => [
234
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
235
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
236
+			],
237
+			'hide_add_button_on_cpt_route' => [
238
+				'edit_attendee' => true,
239
+			],
240
+		];
241
+	}
242
+
243
+
244
+	/**
245
+	 * grab url requests and route them
246
+	 *
247
+	 * @return void
248
+	 * @throws EE_Error
249
+	 */
250
+	public function _set_page_routes()
251
+	{
252
+		$this->_get_registration_status_array();
253
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
254
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
255
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
256
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
257
+		$this->_page_routes = [
258
+			'default'                             => [
259
+				'func'       => [$this, '_registrations_overview_list_table'],
260
+				'capability' => 'ee_read_registrations',
261
+			],
262
+			'view_registration'                   => [
263
+				'func'       => '_registration_details',
264
+				'capability' => 'ee_read_registration',
265
+				'obj_id'     => $REG_ID,
266
+			],
267
+			'edit_registration'                   => [
268
+				'func'               => '_update_attendee_registration_form',
269
+				'noheader'           => true,
270
+				'headers_sent_route' => 'view_registration',
271
+				'capability'         => 'ee_edit_registration',
272
+				'obj_id'             => $REG_ID,
273
+				'_REG_ID'            => $REG_ID,
274
+			],
275
+			'trash_registrations'                 => [
276
+				'func'       => '_trash_or_restore_registrations',
277
+				'args'       => ['trash' => true],
278
+				'noheader'   => true,
279
+				'capability' => 'ee_delete_registrations',
280
+			],
281
+			'restore_registrations'               => [
282
+				'func'       => '_trash_or_restore_registrations',
283
+				'args'       => ['trash' => false],
284
+				'noheader'   => true,
285
+				'capability' => 'ee_delete_registrations',
286
+			],
287
+			'delete_registrations'                => [
288
+				'func'       => '_delete_registrations',
289
+				'noheader'   => true,
290
+				'capability' => 'ee_delete_registrations',
291
+			],
292
+			'new_registration'                    => [
293
+				'func'       => 'new_registration',
294
+				'capability' => 'ee_edit_registrations',
295
+			],
296
+			'process_reg_step'                    => [
297
+				'func'       => 'process_reg_step',
298
+				'noheader'   => true,
299
+				'capability' => 'ee_edit_registrations',
300
+			],
301
+			'redirect_to_txn'                     => [
302
+				'func'       => 'redirect_to_txn',
303
+				'noheader'   => true,
304
+				'capability' => 'ee_edit_registrations',
305
+			],
306
+			'change_reg_status'                   => [
307
+				'func'       => '_change_reg_status',
308
+				'noheader'   => true,
309
+				'capability' => 'ee_edit_registration',
310
+				'obj_id'     => $REG_ID,
311
+			],
312
+			'approve_registration'                => [
313
+				'func'       => 'approve_registration',
314
+				'noheader'   => true,
315
+				'capability' => 'ee_edit_registration',
316
+				'obj_id'     => $REG_ID,
317
+			],
318
+			'approve_and_notify_registration'     => [
319
+				'func'       => 'approve_registration',
320
+				'noheader'   => true,
321
+				'args'       => [true],
322
+				'capability' => 'ee_edit_registration',
323
+				'obj_id'     => $REG_ID,
324
+			],
325
+			'approve_registrations'               => [
326
+				'func'       => 'bulk_action_on_registrations',
327
+				'noheader'   => true,
328
+				'capability' => 'ee_edit_registrations',
329
+				'args'       => ['approve'],
330
+			],
331
+			'approve_and_notify_registrations'    => [
332
+				'func'       => 'bulk_action_on_registrations',
333
+				'noheader'   => true,
334
+				'capability' => 'ee_edit_registrations',
335
+				'args'       => ['approve', true],
336
+			],
337
+			'decline_registration'                => [
338
+				'func'       => 'decline_registration',
339
+				'noheader'   => true,
340
+				'capability' => 'ee_edit_registration',
341
+				'obj_id'     => $REG_ID,
342
+			],
343
+			'decline_and_notify_registration'     => [
344
+				'func'       => 'decline_registration',
345
+				'noheader'   => true,
346
+				'args'       => [true],
347
+				'capability' => 'ee_edit_registration',
348
+				'obj_id'     => $REG_ID,
349
+			],
350
+			'decline_registrations'               => [
351
+				'func'       => 'bulk_action_on_registrations',
352
+				'noheader'   => true,
353
+				'capability' => 'ee_edit_registrations',
354
+				'args'       => ['decline'],
355
+			],
356
+			'decline_and_notify_registrations'    => [
357
+				'func'       => 'bulk_action_on_registrations',
358
+				'noheader'   => true,
359
+				'capability' => 'ee_edit_registrations',
360
+				'args'       => ['decline', true],
361
+			],
362
+			'pending_registration'                => [
363
+				'func'       => 'pending_registration',
364
+				'noheader'   => true,
365
+				'capability' => 'ee_edit_registration',
366
+				'obj_id'     => $REG_ID,
367
+			],
368
+			'pending_and_notify_registration'     => [
369
+				'func'       => 'pending_registration',
370
+				'noheader'   => true,
371
+				'args'       => [true],
372
+				'capability' => 'ee_edit_registration',
373
+				'obj_id'     => $REG_ID,
374
+			],
375
+			'pending_registrations'               => [
376
+				'func'       => 'bulk_action_on_registrations',
377
+				'noheader'   => true,
378
+				'capability' => 'ee_edit_registrations',
379
+				'args'       => ['pending'],
380
+			],
381
+			'pending_and_notify_registrations'    => [
382
+				'func'       => 'bulk_action_on_registrations',
383
+				'noheader'   => true,
384
+				'capability' => 'ee_edit_registrations',
385
+				'args'       => ['pending', true],
386
+			],
387
+			'no_approve_registration'             => [
388
+				'func'       => 'not_approve_registration',
389
+				'noheader'   => true,
390
+				'capability' => 'ee_edit_registration',
391
+				'obj_id'     => $REG_ID,
392
+			],
393
+			'no_approve_and_notify_registration'  => [
394
+				'func'       => 'not_approve_registration',
395
+				'noheader'   => true,
396
+				'args'       => [true],
397
+				'capability' => 'ee_edit_registration',
398
+				'obj_id'     => $REG_ID,
399
+			],
400
+			'no_approve_registrations'            => [
401
+				'func'       => 'bulk_action_on_registrations',
402
+				'noheader'   => true,
403
+				'capability' => 'ee_edit_registrations',
404
+				'args'       => ['not_approve'],
405
+			],
406
+			'no_approve_and_notify_registrations' => [
407
+				'func'       => 'bulk_action_on_registrations',
408
+				'noheader'   => true,
409
+				'capability' => 'ee_edit_registrations',
410
+				'args'       => ['not_approve', true],
411
+			],
412
+			'cancel_registration'                 => [
413
+				'func'       => 'cancel_registration',
414
+				'noheader'   => true,
415
+				'capability' => 'ee_edit_registration',
416
+				'obj_id'     => $REG_ID,
417
+			],
418
+			'cancel_and_notify_registration'      => [
419
+				'func'       => 'cancel_registration',
420
+				'noheader'   => true,
421
+				'args'       => [true],
422
+				'capability' => 'ee_edit_registration',
423
+				'obj_id'     => $REG_ID,
424
+			],
425
+			'cancel_registrations'                => [
426
+				'func'       => 'bulk_action_on_registrations',
427
+				'noheader'   => true,
428
+				'capability' => 'ee_edit_registrations',
429
+				'args'       => ['cancel'],
430
+			],
431
+			'cancel_and_notify_registrations'     => [
432
+				'func'       => 'bulk_action_on_registrations',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_edit_registrations',
435
+				'args'       => ['cancel', true],
436
+			],
437
+			'wait_list_registration'              => [
438
+				'func'       => 'wait_list_registration',
439
+				'noheader'   => true,
440
+				'capability' => 'ee_edit_registration',
441
+				'obj_id'     => $REG_ID,
442
+			],
443
+			'wait_list_and_notify_registration'   => [
444
+				'func'       => 'wait_list_registration',
445
+				'noheader'   => true,
446
+				'args'       => [true],
447
+				'capability' => 'ee_edit_registration',
448
+				'obj_id'     => $REG_ID,
449
+			],
450
+			'contact_list'                        => [
451
+				'func'       => '_attendee_contact_list_table',
452
+				'capability' => 'ee_read_contacts',
453
+			],
454
+			'add_new_attendee'                    => [
455
+				'func' => '_create_new_cpt_item',
456
+				'args' => [
457
+					'new_attendee' => true,
458
+					'capability'   => 'ee_edit_contacts',
459
+				],
460
+			],
461
+			'edit_attendee'                       => [
462
+				'func'       => '_edit_cpt_item',
463
+				'capability' => 'ee_edit_contacts',
464
+				'obj_id'     => $ATT_ID,
465
+			],
466
+			'duplicate_attendee'                  => [
467
+				'func'       => '_duplicate_attendee',
468
+				'noheader'   => true,
469
+				'capability' => 'ee_edit_contacts',
470
+				'obj_id'     => $ATT_ID,
471
+			],
472
+			'insert_attendee'                     => [
473
+				'func'       => '_insert_or_update_attendee',
474
+				'args'       => [
475
+					'new_attendee' => true,
476
+				],
477
+				'noheader'   => true,
478
+				'capability' => 'ee_edit_contacts',
479
+			],
480
+			'update_attendee'                     => [
481
+				'func'       => '_insert_or_update_attendee',
482
+				'args'       => [
483
+					'new_attendee' => false,
484
+				],
485
+				'noheader'   => true,
486
+				'capability' => 'ee_edit_contacts',
487
+				'obj_id'     => $ATT_ID,
488
+			],
489
+			'trash_attendees'                     => [
490
+				'func'       => '_trash_or_restore_attendees',
491
+				'args'       => [
492
+					'trash' => 'true',
493
+				],
494
+				'noheader'   => true,
495
+				'capability' => 'ee_delete_contacts',
496
+			],
497
+			'trash_attendee'                      => [
498
+				'func'       => '_trash_or_restore_attendees',
499
+				'args'       => [
500
+					'trash' => true,
501
+				],
502
+				'noheader'   => true,
503
+				'capability' => 'ee_delete_contacts',
504
+				'obj_id'     => $ATT_ID,
505
+			],
506
+			'restore_attendees'                   => [
507
+				'func'       => '_trash_or_restore_attendees',
508
+				'args'       => [
509
+					'trash' => false,
510
+				],
511
+				'noheader'   => true,
512
+				'capability' => 'ee_delete_contacts',
513
+				'obj_id'     => $ATT_ID,
514
+			],
515
+			'resend_registration'                 => [
516
+				'func'       => '_resend_registration',
517
+				'noheader'   => true,
518
+				'capability' => 'ee_send_message',
519
+			],
520
+			'registrations_report'                => [
521
+				'func'       => [$this, '_registrations_report'],
522
+				'noheader'   => true,
523
+				'capability' => 'ee_read_registrations',
524
+			],
525
+			'contact_list_export'                 => [
526
+				'func'       => '_contact_list_export',
527
+				'noheader'   => true,
528
+				'capability' => 'export',
529
+			],
530
+			'contact_list_report'                 => [
531
+				'func'       => '_contact_list_report',
532
+				'noheader'   => true,
533
+				'capability' => 'ee_read_contacts',
534
+			],
535
+		];
536
+	}
537
+
538
+
539
+	protected function _set_page_config()
540
+	{
541
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
542
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
543
+		$this->_page_config = [
544
+			'default'           => [
545
+				'nav'           => [
546
+					'label' => esc_html__('Overview', 'event_espresso'),
547
+					'icon' => 'dashicons-list-view',
548
+					'order' => 5,
549
+				],
550
+				'help_tabs'     => [
551
+					'registrations_overview_help_tab'                       => [
552
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
+						'filename' => 'registrations_overview',
554
+					],
555
+					'registrations_overview_table_column_headings_help_tab' => [
556
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
+						'filename' => 'registrations_overview_table_column_headings',
558
+					],
559
+					'registrations_overview_filters_help_tab'               => [
560
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
+						'filename' => 'registrations_overview_filters',
562
+					],
563
+					'registrations_overview_views_help_tab'                 => [
564
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
565
+						'filename' => 'registrations_overview_views',
566
+					],
567
+					'registrations_regoverview_other_help_tab'              => [
568
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
+						'filename' => 'registrations_overview_other',
570
+					],
571
+				],
572
+				'list_table'    => 'EE_Registrations_List_Table',
573
+				'require_nonce' => false,
574
+			],
575
+			'view_registration' => [
576
+				'nav'           => [
577
+					'label'      => esc_html__('REG Details', 'event_espresso'),
578
+					'icon' => 'dashicons-clipboard',
579
+					'order'      => 15,
580
+					'url'        => $REG_ID
581
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
+						: $this->_admin_base_url,
583
+					'persistent' => false,
584
+				],
585
+				'help_tabs'     => [
586
+					'registrations_details_help_tab'                    => [
587
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
588
+						'filename' => 'registrations_details',
589
+					],
590
+					'registrations_details_table_help_tab'              => [
591
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
+						'filename' => 'registrations_details_table',
593
+					],
594
+					'registrations_details_form_answers_help_tab'       => [
595
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
+						'filename' => 'registrations_details_form_answers',
597
+					],
598
+					'registrations_details_registrant_details_help_tab' => [
599
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
600
+						'filename' => 'registrations_details_registrant_details',
601
+					],
602
+				],
603
+				'metaboxes'     => array_merge(
604
+					$this->_default_espresso_metaboxes,
605
+					['_registration_details_metaboxes']
606
+				),
607
+				'require_nonce' => false,
608
+			],
609
+			'new_registration'  => [
610
+				'nav'           => [
611
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
+					'icon' => 'dashicons-plus-alt',
613
+					'url'        => '#',
614
+					'order'      => 15,
615
+					'persistent' => false,
616
+				],
617
+				'metaboxes'     => $this->_default_espresso_metaboxes,
618
+				'labels'        => [
619
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
620
+				],
621
+				'require_nonce' => false,
622
+			],
623
+			'add_new_attendee'  => [
624
+				'nav'           => [
625
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
626
+					'icon' => 'dashicons-plus-alt',
627
+					'order'      => 15,
628
+					'persistent' => false,
629
+				],
630
+				'metaboxes'     => array_merge(
631
+					$this->_default_espresso_metaboxes,
632
+					['_publish_post_box', 'attendee_editor_metaboxes']
633
+				),
634
+				'require_nonce' => false,
635
+			],
636
+			'edit_attendee'     => [
637
+				'nav'           => [
638
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
639
+					'icon' => 'dashicons-edit-large',
640
+					'order'      => 15,
641
+					'persistent' => false,
642
+					'url'        => $ATT_ID
643
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
644
+						: $this->_admin_base_url,
645
+				],
646
+				'metaboxes'     => array_merge(
647
+					$this->_default_espresso_metaboxes,
648
+					['attendee_editor_metaboxes']
649
+				),
650
+				'require_nonce' => false,
651
+			],
652
+			'contact_list'      => [
653
+				'nav'           => [
654
+					'label' => esc_html__('Contact List', 'event_espresso'),
655
+					'icon' => 'dashicons-id-alt',
656
+					'order' => 20,
657
+				],
658
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
659
+				'help_tabs'     => [
660
+					'registrations_contact_list_help_tab'                       => [
661
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
662
+						'filename' => 'registrations_contact_list',
663
+					],
664
+					'registrations_contact-list_table_column_headings_help_tab' => [
665
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
666
+						'filename' => 'registrations_contact_list_table_column_headings',
667
+					],
668
+					'registrations_contact_list_views_help_tab'                 => [
669
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
670
+						'filename' => 'registrations_contact_list_views',
671
+					],
672
+					'registrations_contact_list_other_help_tab'                 => [
673
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
674
+						'filename' => 'registrations_contact_list_other',
675
+					],
676
+				],
677
+				'metaboxes'     => [],
678
+				'require_nonce' => false,
679
+			],
680
+			// override default cpt routes
681
+			'create_new'        => '',
682
+			'edit'              => '',
683
+		];
684
+	}
685
+
686
+
687
+	/**
688
+	 * The below methods aren't used by this class currently
689
+	 */
690
+	protected function _add_screen_options()
691
+	{
692
+	}
693
+
694
+
695
+	protected function _add_feature_pointers()
696
+	{
697
+	}
698
+
699
+
700
+	public function admin_init()
701
+	{
702
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
703
+			'click "Update Registration Questions" to save your changes',
704
+			'event_espresso'
705
+		);
706
+	}
707
+
708
+
709
+	public function admin_notices()
710
+	{
711
+	}
712
+
713
+
714
+	public function admin_footer_scripts()
715
+	{
716
+	}
717
+
718
+
719
+	/**
720
+	 * get list of registration statuses
721
+	 *
722
+	 * @return void
723
+	 * @throws EE_Error
724
+	 */
725
+	private function _get_registration_status_array()
726
+	{
727
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
728
+	}
729
+
730
+
731
+	/**
732
+	 * @throws InvalidArgumentException
733
+	 * @throws InvalidDataTypeException
734
+	 * @throws InvalidInterfaceException
735
+	 * @since 4.10.2.p
736
+	 */
737
+	protected function _add_screen_options_default()
738
+	{
739
+		$this->_per_page_screen_option();
740
+	}
741
+
742
+
743
+	/**
744
+	 * @throws InvalidArgumentException
745
+	 * @throws InvalidDataTypeException
746
+	 * @throws InvalidInterfaceException
747
+	 * @since 4.10.2.p
748
+	 */
749
+	protected function _add_screen_options_contact_list()
750
+	{
751
+		$page_title              = $this->_admin_page_title;
752
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
753
+		$this->_per_page_screen_option();
754
+		$this->_admin_page_title = $page_title;
755
+	}
756
+
757
+
758
+	public function load_scripts_styles()
759
+	{
760
+		// style
761
+		wp_register_style(
762
+			'espresso_reg',
763
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
764
+			['ee-admin-css'],
765
+			EVENT_ESPRESSO_VERSION
766
+		);
767
+		wp_enqueue_style('espresso_reg');
768
+		// script
769
+		wp_register_script(
770
+			'espresso_reg',
771
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
772
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
773
+			EVENT_ESPRESSO_VERSION,
774
+			true
775
+		);
776
+		wp_enqueue_script('espresso_reg');
777
+	}
778
+
779
+
780
+	/**
781
+	 * @throws EE_Error
782
+	 * @throws InvalidArgumentException
783
+	 * @throws InvalidDataTypeException
784
+	 * @throws InvalidInterfaceException
785
+	 * @throws ReflectionException
786
+	 * @since 4.10.2.p
787
+	 */
788
+	public function load_scripts_styles_edit_attendee()
789
+	{
790
+		// stuff to only show up on our attendee edit details page.
791
+		$attendee_details_translations = [
792
+			'att_publish_text' => sprintf(
793
+			/* translators: The date and time */
794
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
795
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
796
+			),
797
+		];
798
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
799
+		wp_enqueue_script('jquery-validate');
800
+	}
801
+
802
+
803
+	/**
804
+	 * @throws EE_Error
805
+	 * @throws InvalidArgumentException
806
+	 * @throws InvalidDataTypeException
807
+	 * @throws InvalidInterfaceException
808
+	 * @throws ReflectionException
809
+	 * @since 4.10.2.p
810
+	 */
811
+	public function load_scripts_styles_view_registration()
812
+	{
813
+		// styles
814
+		wp_enqueue_style('espresso-ui-theme');
815
+		// scripts
816
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
817
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
818
+	}
819
+
820
+
821
+	public function load_scripts_styles_contact_list()
822
+	{
823
+		wp_dequeue_style('espresso_reg');
824
+		wp_register_style(
825
+			'espresso_att',
826
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
827
+			['ee-admin-css'],
828
+			EVENT_ESPRESSO_VERSION
829
+		);
830
+		wp_enqueue_style('espresso_att');
831
+	}
832
+
833
+
834
+	public function load_scripts_styles_new_registration()
835
+	{
836
+		wp_register_script(
837
+			'ee-spco-for-admin',
838
+			REG_ASSETS_URL . 'spco_for_admin.js',
839
+			['underscore', 'jquery'],
840
+			EVENT_ESPRESSO_VERSION,
841
+			true
842
+		);
843
+		wp_enqueue_script('ee-spco-for-admin');
844
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
845
+		EE_Form_Section_Proper::wp_enqueue_scripts();
846
+		EED_Ticket_Selector::load_tckt_slctr_assets();
847
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
848
+	}
849
+
850
+
851
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
852
+	{
853
+		add_filter('FHEE_load_EE_messages', '__return_true');
854
+	}
855
+
856
+
857
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
858
+	{
859
+		add_filter('FHEE_load_EE_messages', '__return_true');
860
+	}
861
+
862
+
863
+	/**
864
+	 * @throws EE_Error
865
+	 * @throws InvalidArgumentException
866
+	 * @throws InvalidDataTypeException
867
+	 * @throws InvalidInterfaceException
868
+	 * @throws ReflectionException
869
+	 * @since 4.10.2.p
870
+	 */
871
+	protected function _set_list_table_views_default()
872
+	{
873
+		// for notification related bulk actions we need to make sure only active messengers have an option.
874
+		EED_Messages::set_autoloaders();
875
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
876
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
877
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
878
+		// key= bulk_action_slug, value= message type.
879
+		$match_array = [
880
+			'approve_registrations'    => 'registration',
881
+			'decline_registrations'    => 'declined_registration',
882
+			'pending_registrations'    => 'pending_approval',
883
+			'no_approve_registrations' => 'not_approved_registration',
884
+			'cancel_registrations'     => 'cancelled_registration',
885
+		];
886
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
887
+			'ee_send_message',
888
+			'batch_send_messages'
889
+		);
890
+		/** setup reg status bulk actions **/
891
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
892
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
893
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
894
+				'Approve and Notify Registrations',
895
+				'event_espresso'
896
+			);
897
+		}
898
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
899
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
900
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
901
+				'Decline and Notify Registrations',
902
+				'event_espresso'
903
+			);
904
+		}
905
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
906
+			'Set Registrations to Pending Payment',
907
+			'event_espresso'
908
+		);
909
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
910
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
911
+				'Set Registrations to Pending Payment and Notify',
912
+				'event_espresso'
913
+			);
914
+		}
915
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
916
+			'Set Registrations to Not Approved',
917
+			'event_espresso'
918
+		);
919
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
920
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
921
+				'Set Registrations to Not Approved and Notify',
922
+				'event_espresso'
923
+			);
924
+		}
925
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
926
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
927
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
928
+				'Cancel Registrations and Notify',
929
+				'event_espresso'
930
+			);
931
+		}
932
+		$def_reg_status_actions = apply_filters(
933
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
934
+			$def_reg_status_actions,
935
+			$active_mts,
936
+			$can_send
937
+		);
938
+
939
+		$this->_views = [
940
+			'all'   => [
941
+				'slug'        => 'all',
942
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
943
+				'count'       => 0,
944
+				'bulk_action' => array_merge(
945
+					$def_reg_status_actions,
946
+					[
947
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
948
+					]
949
+				),
950
+			],
951
+			'month' => [
952
+				'slug'        => 'month',
953
+				'label'       => esc_html__('This Month', 'event_espresso'),
954
+				'count'       => 0,
955
+				'bulk_action' => array_merge(
956
+					$def_reg_status_actions,
957
+					[
958
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
959
+					]
960
+				),
961
+			],
962
+			'today' => [
963
+				'slug'        => 'today',
964
+				'label'       => sprintf(
965
+					esc_html__('Today - %s', 'event_espresso'),
966
+					date('M d, Y', current_time('timestamp'))
967
+				),
968
+				'count'       => 0,
969
+				'bulk_action' => array_merge(
970
+					$def_reg_status_actions,
971
+					[
972
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
973
+					]
974
+				),
975
+			],
976
+		];
977
+		if (
978
+			EE_Registry::instance()->CAP->current_user_can(
979
+				'ee_delete_registrations',
980
+				'espresso_registrations_delete_registration'
981
+			)
982
+		) {
983
+			$this->_views['incomplete'] = [
984
+				'slug'        => 'incomplete',
985
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
986
+				'count'       => 0,
987
+				'bulk_action' => [
988
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
989
+				],
990
+			];
991
+			$this->_views['trash']      = [
992
+				'slug'        => 'trash',
993
+				'label'       => esc_html__('Trash', 'event_espresso'),
994
+				'count'       => 0,
995
+				'bulk_action' => [
996
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
997
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
998
+				],
999
+			];
1000
+		}
1001
+	}
1002
+
1003
+
1004
+	protected function _set_list_table_views_contact_list()
1005
+	{
1006
+		$this->_views = [
1007
+			'in_use' => [
1008
+				'slug'        => 'in_use',
1009
+				'label'       => esc_html__('In Use', 'event_espresso'),
1010
+				'count'       => 0,
1011
+				'bulk_action' => [
1012
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1013
+				],
1014
+			],
1015
+		];
1016
+		if (
1017
+			EE_Registry::instance()->CAP->current_user_can(
1018
+				'ee_delete_contacts',
1019
+				'espresso_registrations_trash_attendees'
1020
+			)
1021
+		) {
1022
+			$this->_views['trash'] = [
1023
+				'slug'        => 'trash',
1024
+				'label'       => esc_html__('Trash', 'event_espresso'),
1025
+				'count'       => 0,
1026
+				'bulk_action' => [
1027
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1028
+				],
1029
+			];
1030
+		}
1031
+	}
1032
+
1033
+
1034
+	/**
1035
+	 * @return array
1036
+	 * @throws EE_Error
1037
+	 */
1038
+	protected function _registration_legend_items()
1039
+	{
1040
+		$fc_items = [
1041
+			'star-icon'        => [
1042
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1043
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1044
+			],
1045
+			'view_details'     => [
1046
+				'class' => 'dashicons dashicons-clipboard',
1047
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1048
+			],
1049
+			'edit_attendee'    => [
1050
+				'class' => 'dashicons dashicons-admin-users',
1051
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1052
+			],
1053
+			'view_transaction' => [
1054
+				'class' => 'dashicons dashicons-cart',
1055
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1056
+			],
1057
+			'view_invoice'     => [
1058
+				'class' => 'dashicons dashicons-media-spreadsheet',
1059
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1060
+			],
1061
+		];
1062
+		if (
1063
+			EE_Registry::instance()->CAP->current_user_can(
1064
+				'ee_send_message',
1065
+				'espresso_registrations_resend_registration'
1066
+			)
1067
+		) {
1068
+			$fc_items['resend_registration'] = [
1069
+				'class' => 'dashicons dashicons-email-alt',
1070
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1071
+			];
1072
+		} else {
1073
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1074
+		}
1075
+		if (
1076
+			EE_Registry::instance()->CAP->current_user_can(
1077
+				'ee_read_global_messages',
1078
+				'view_filtered_messages'
1079
+			)
1080
+		) {
1081
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1082
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1083
+				$fc_items['view_related_messages'] = [
1084
+					'class' => $related_for_icon['css_class'],
1085
+					'desc'  => $related_for_icon['label'],
1086
+				];
1087
+			}
1088
+		}
1089
+		$sc_items = [
1090
+			'approved_status'   => [
1091
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1092
+				'desc'  => EEH_Template::pretty_status(
1093
+					EEM_Registration::status_id_approved,
1094
+					false,
1095
+					'sentence'
1096
+				),
1097
+			],
1098
+			'pending_status'    => [
1099
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1100
+				'desc'  => EEH_Template::pretty_status(
1101
+					EEM_Registration::status_id_pending_payment,
1102
+					false,
1103
+					'sentence'
1104
+				),
1105
+			],
1106
+			'wait_list'         => [
1107
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1108
+				'desc'  => EEH_Template::pretty_status(
1109
+					EEM_Registration::status_id_wait_list,
1110
+					false,
1111
+					'sentence'
1112
+				),
1113
+			],
1114
+			'incomplete_status' => [
1115
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1116
+				'desc'  => EEH_Template::pretty_status(
1117
+					EEM_Registration::status_id_incomplete,
1118
+					false,
1119
+					'sentence'
1120
+				),
1121
+			],
1122
+			'not_approved'      => [
1123
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1124
+				'desc'  => EEH_Template::pretty_status(
1125
+					EEM_Registration::status_id_not_approved,
1126
+					false,
1127
+					'sentence'
1128
+				),
1129
+			],
1130
+			'declined_status'   => [
1131
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1132
+				'desc'  => EEH_Template::pretty_status(
1133
+					EEM_Registration::status_id_declined,
1134
+					false,
1135
+					'sentence'
1136
+				),
1137
+			],
1138
+			'cancelled_status'  => [
1139
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1140
+				'desc'  => EEH_Template::pretty_status(
1141
+					EEM_Registration::status_id_cancelled,
1142
+					false,
1143
+					'sentence'
1144
+				),
1145
+			],
1146
+		];
1147
+		return array_merge($fc_items, $sc_items);
1148
+	}
1149
+
1150
+
1151
+
1152
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1153
+
1154
+
1155
+	/**
1156
+	 * @throws DomainException
1157
+	 * @throws EE_Error
1158
+	 * @throws InvalidArgumentException
1159
+	 * @throws InvalidDataTypeException
1160
+	 * @throws InvalidInterfaceException
1161
+	 */
1162
+	protected function _registrations_overview_list_table()
1163
+	{
1164
+		$this->appendAddNewRegistrationButtonToPageTitle();
1165
+		$header_text                  = '';
1166
+		$admin_page_header_decorators = [
1167
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1168
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1169
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1170
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1171
+		];
1172
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1173
+			$filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1174
+			$header_text = $filter_header_decorator->getHeaderText($header_text);
1175
+		}
1176
+		$this->_template_args['before_list_table']  = $header_text;
1177
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1178
+		$this->display_admin_list_table_page_with_no_sidebar();
1179
+	}
1180
+
1181
+
1182
+	/**
1183
+	 * @throws EE_Error
1184
+	 * @throws InvalidArgumentException
1185
+	 * @throws InvalidDataTypeException
1186
+	 * @throws InvalidInterfaceException
1187
+	 */
1188
+	private function appendAddNewRegistrationButtonToPageTitle()
1189
+	{
1190
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1191
+		if (
1192
+			$EVT_ID
1193
+			&& EE_Registry::instance()->CAP->current_user_can(
1194
+				'ee_edit_registrations',
1195
+				'espresso_registrations_new_registration',
1196
+				$EVT_ID
1197
+			)
1198
+		) {
1199
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1200
+				'new_registration',
1201
+				'add-registrant',
1202
+				['event_id' => $EVT_ID],
1203
+				'add-new-h2'
1204
+			);
1205
+		}
1206
+	}
1207
+
1208
+
1209
+	/**
1210
+	 * This sets the _registration property for the registration details screen
1211
+	 *
1212
+	 * @return void
1213
+	 * @throws EE_Error
1214
+	 * @throws InvalidArgumentException
1215
+	 * @throws InvalidDataTypeException
1216
+	 * @throws InvalidInterfaceException
1217
+	 */
1218
+	private function _set_registration_object()
1219
+	{
1220
+		// get out if we've already set the object
1221
+		if ($this->_registration instanceof EE_Registration) {
1222
+			return;
1223
+		}
1224
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1225
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1226
+			return;
1227
+		}
1228
+		$error_msg = sprintf(
1229
+			esc_html__(
1230
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1231
+				'event_espresso'
1232
+			),
1233
+			$REG_ID
1234
+		);
1235
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1236
+		$this->_registration = null;
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 * Used to retrieve registrations for the list table.
1242
+	 *
1243
+	 * @param int  $per_page
1244
+	 * @param bool $count
1245
+	 * @param bool $this_month
1246
+	 * @param bool $today
1247
+	 * @return EE_Registration[]|int
1248
+	 * @throws EE_Error
1249
+	 * @throws InvalidArgumentException
1250
+	 * @throws InvalidDataTypeException
1251
+	 * @throws InvalidInterfaceException
1252
+	 */
1253
+	public function get_registrations(
1254
+		$per_page = 10,
1255
+		$count = false,
1256
+		$this_month = false,
1257
+		$today = false
1258
+	) {
1259
+		if ($this_month) {
1260
+			$this->request->setRequestParam('status', 'month');
1261
+		}
1262
+		if ($today) {
1263
+			$this->request->setRequestParam('status', 'today');
1264
+		}
1265
+		$query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1266
+		/**
1267
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1268
+		 *
1269
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1270
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1271
+		 *                      or if you have the development copy of EE you can view this at the path:
1272
+		 *                      /docs/G--Model-System/model-query-params.md
1273
+		 */
1274
+		$query_params['group_by'] = '';
1275
+
1276
+		return $count
1277
+			? $this->getRegistrationModel()->count($query_params)
1278
+			/** @type EE_Registration[] */
1279
+			: $this->getRegistrationModel()->get_all($query_params);
1280
+	}
1281
+
1282
+
1283
+	/**
1284
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1285
+	 * Note: this listens to values on the request for some of the query parameters.
1286
+	 *
1287
+	 * @param array $request
1288
+	 * @param int   $per_page
1289
+	 * @param bool  $count
1290
+	 * @return array
1291
+	 * @throws EE_Error
1292
+	 * @throws InvalidArgumentException
1293
+	 * @throws InvalidDataTypeException
1294
+	 * @throws InvalidInterfaceException
1295
+	 */
1296
+	protected function _get_registration_query_parameters(
1297
+		$request = [],
1298
+		$per_page = 10,
1299
+		$count = false
1300
+	) {
1301
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1302
+		$list_table_query_builder = $this->loader->getNew(
1303
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1304
+			[null, null, $request]
1305
+		);
1306
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1307
+	}
1308
+
1309
+
1310
+	public function get_registration_status_array()
1311
+	{
1312
+		return self::$_reg_status;
1313
+	}
1314
+
1315
+
1316
+
1317
+
1318
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1319
+	/**
1320
+	 * generates HTML for the View Registration Details Admin page
1321
+	 *
1322
+	 * @return void
1323
+	 * @throws DomainException
1324
+	 * @throws EE_Error
1325
+	 * @throws InvalidArgumentException
1326
+	 * @throws InvalidDataTypeException
1327
+	 * @throws InvalidInterfaceException
1328
+	 * @throws EntityNotFoundException
1329
+	 * @throws ReflectionException
1330
+	 */
1331
+	protected function _registration_details()
1332
+	{
1333
+		$this->_template_args = [];
1334
+		$this->_set_registration_object();
1335
+		if (is_object($this->_registration)) {
1336
+			$transaction                                   = $this->_registration->transaction()
1337
+				? $this->_registration->transaction()
1338
+				: EE_Transaction::new_instance();
1339
+			$this->_session                                = $transaction->session_data();
1340
+			$event_id                                      = $this->_registration->event_ID();
1341
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1342
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1343
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1344
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1345
+			$this->_template_args['grand_total']           = $transaction->total();
1346
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1347
+			// link back to overview
1348
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1349
+			$this->_template_args['registration']                = $this->_registration;
1350
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1351
+				[
1352
+					'action'   => 'default',
1353
+					'event_id' => $event_id,
1354
+				],
1355
+				REG_ADMIN_URL
1356
+			);
1357
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1358
+				[
1359
+					'action' => 'default',
1360
+					'EVT_ID' => $event_id,
1361
+					'page'   => 'espresso_transactions',
1362
+				],
1363
+				admin_url('admin.php')
1364
+			);
1365
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1366
+				[
1367
+					'page'   => 'espresso_events',
1368
+					'action' => 'edit',
1369
+					'post'   => $event_id,
1370
+				],
1371
+				admin_url('admin.php')
1372
+			);
1373
+			// next and previous links
1374
+			$next_reg                                      = $this->_registration->next(
1375
+				null,
1376
+				[],
1377
+				'REG_ID'
1378
+			);
1379
+			$this->_template_args['next_registration']     = $next_reg
1380
+				? $this->_next_link(
1381
+					EE_Admin_Page::add_query_args_and_nonce(
1382
+						[
1383
+							'action'  => 'view_registration',
1384
+							'_REG_ID' => $next_reg['REG_ID'],
1385
+						],
1386
+						REG_ADMIN_URL
1387
+					),
1388
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1389
+				)
1390
+				: '';
1391
+			$previous_reg                                  = $this->_registration->previous(
1392
+				null,
1393
+				[],
1394
+				'REG_ID'
1395
+			);
1396
+			$this->_template_args['previous_registration'] = $previous_reg
1397
+				? $this->_previous_link(
1398
+					EE_Admin_Page::add_query_args_and_nonce(
1399
+						[
1400
+							'action'  => 'view_registration',
1401
+							'_REG_ID' => $previous_reg['REG_ID'],
1402
+						],
1403
+						REG_ADMIN_URL
1404
+					),
1405
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1406
+				)
1407
+				: '';
1408
+			// grab header
1409
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1410
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1411
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1412
+				$template_path,
1413
+				$this->_template_args,
1414
+				true
1415
+			);
1416
+		} else {
1417
+			$this->_template_args['admin_page_header'] = '';
1418
+			$this->_display_espresso_notices();
1419
+		}
1420
+		// the details template wrapper
1421
+		$this->display_admin_page_with_sidebar();
1422
+	}
1423
+
1424
+
1425
+	/**
1426
+	 * @throws EE_Error
1427
+	 * @throws InvalidArgumentException
1428
+	 * @throws InvalidDataTypeException
1429
+	 * @throws InvalidInterfaceException
1430
+	 * @throws ReflectionException
1431
+	 * @since 4.10.2.p
1432
+	 */
1433
+	protected function _registration_details_metaboxes()
1434
+	{
1435
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1436
+		$this->_set_registration_object();
1437
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1438
+		$this->addMetaBox(
1439
+			'edit-reg-status-mbox',
1440
+			esc_html__('Registration Status', 'event_espresso'),
1441
+			[$this, 'set_reg_status_buttons_metabox'],
1442
+			$this->_wp_page_slug
1443
+		);
1444
+		$this->addMetaBox(
1445
+			'edit-reg-details-mbox',
1446
+			'<span>' . esc_html__('Registration Details', 'event_espresso')
1447
+			. '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1448
+			[$this, '_reg_details_meta_box'],
1449
+			$this->_wp_page_slug
1450
+		);
1451
+		if (
1452
+			$attendee instanceof EE_Attendee
1453
+			&& EE_Registry::instance()->CAP->current_user_can(
1454
+				'ee_read_registration',
1455
+				'edit-reg-questions-mbox',
1456
+				$this->_registration->ID()
1457
+			)
1458
+		) {
1459
+			$this->addMetaBox(
1460
+				'edit-reg-questions-mbox',
1461
+				esc_html__('Registration Form Answers', 'event_espresso'),
1462
+				[$this, '_reg_questions_meta_box'],
1463
+				$this->_wp_page_slug
1464
+			);
1465
+		}
1466
+		$this->addMetaBox(
1467
+			'edit-reg-registrant-mbox',
1468
+			esc_html__('Contact Details', 'event_espresso'),
1469
+			[$this, '_reg_registrant_side_meta_box'],
1470
+			$this->_wp_page_slug,
1471
+			'side'
1472
+		);
1473
+		if ($this->_registration->group_size() > 1) {
1474
+			$this->addMetaBox(
1475
+				'edit-reg-attendees-mbox',
1476
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1477
+				[$this, '_reg_attendees_meta_box'],
1478
+				$this->_wp_page_slug
1479
+			);
1480
+		}
1481
+	}
1482
+
1483
+
1484
+	/**
1485
+	 * set_reg_status_buttons_metabox
1486
+	 *
1487
+	 * @return void
1488
+	 * @throws EE_Error
1489
+	 * @throws EntityNotFoundException
1490
+	 * @throws InvalidArgumentException
1491
+	 * @throws InvalidDataTypeException
1492
+	 * @throws InvalidInterfaceException
1493
+	 * @throws ReflectionException
1494
+	 */
1495
+	public function set_reg_status_buttons_metabox()
1496
+	{
1497
+		$this->_set_registration_object();
1498
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1499
+		$output                 = $change_reg_status_form->form_open(
1500
+			self::add_query_args_and_nonce(
1501
+				[
1502
+					'action' => 'change_reg_status',
1503
+				],
1504
+				REG_ADMIN_URL
1505
+			)
1506
+		);
1507
+		$output                 .= $change_reg_status_form->get_html();
1508
+		$output                 .= $change_reg_status_form->form_close();
1509
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1510
+	}
1511
+
1512
+
1513
+	/**
1514
+	 * @return EE_Form_Section_Proper
1515
+	 * @throws EE_Error
1516
+	 * @throws InvalidArgumentException
1517
+	 * @throws InvalidDataTypeException
1518
+	 * @throws InvalidInterfaceException
1519
+	 * @throws EntityNotFoundException
1520
+	 * @throws ReflectionException
1521
+	 */
1522
+	protected function _generate_reg_status_change_form()
1523
+	{
1524
+		$reg_status_change_form_array = [
1525
+			'name'            => 'reg_status_change_form',
1526
+			'html_id'         => 'reg-status-change-form',
1527
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1528
+			'subsections'     => [
1529
+				'return'         => new EE_Hidden_Input(
1530
+					[
1531
+						'name'    => 'return',
1532
+						'default' => 'view_registration',
1533
+					]
1534
+				),
1535
+				'REG_ID'         => new EE_Hidden_Input(
1536
+					[
1537
+						'name'    => 'REG_ID',
1538
+						'default' => $this->_registration->ID(),
1539
+					]
1540
+				),
1541
+			],
1542
+		];
1543
+		if (
1544
+			EE_Registry::instance()->CAP->current_user_can(
1545
+				'ee_edit_registration',
1546
+				'toggle_registration_status',
1547
+				$this->_registration->ID()
1548
+			)
1549
+		) {
1550
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1551
+				$this->_get_reg_statuses(),
1552
+				[
1553
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1554
+					'default'         => $this->_registration->status_ID(),
1555
+				]
1556
+			);
1557
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1558
+				[
1559
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1560
+					'default'         => false,
1561
+					'html_help_text'  => esc_html__(
1562
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1563
+						'event_espresso'
1564
+					),
1565
+				]
1566
+			);
1567
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1568
+				[
1569
+					'html_class'      => 'button--primary',
1570
+					'html_label_text' => '&nbsp;',
1571
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1572
+				]
1573
+			);
1574
+		}
1575
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1576
+	}
1577
+
1578
+
1579
+	/**
1580
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1581
+	 *
1582
+	 * @return array
1583
+	 * @throws EE_Error
1584
+	 * @throws InvalidArgumentException
1585
+	 * @throws InvalidDataTypeException
1586
+	 * @throws InvalidInterfaceException
1587
+	 * @throws EntityNotFoundException
1588
+	 */
1589
+	protected function _get_reg_statuses()
1590
+	{
1591
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1592
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1593
+		// get current reg status
1594
+		$current_status = $this->_registration->status_ID();
1595
+		// is registration for free event? This will determine whether to display the pending payment option
1596
+		if (
1597
+			$current_status !== EEM_Registration::status_id_pending_payment
1598
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1599
+		) {
1600
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1601
+		}
1602
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1603
+	}
1604
+
1605
+
1606
+	/**
1607
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1608
+	 *
1609
+	 * @param bool $status REG status given for changing registrations to.
1610
+	 * @param bool $notify Whether to send messages notifications or not.
1611
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1612
+	 * @throws DomainException
1613
+	 * @throws EE_Error
1614
+	 * @throws EntityNotFoundException
1615
+	 * @throws InvalidArgumentException
1616
+	 * @throws InvalidDataTypeException
1617
+	 * @throws InvalidInterfaceException
1618
+	 * @throws ReflectionException
1619
+	 * @throws RuntimeException
1620
+	 */
1621
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1622
+	{
1623
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1624
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1625
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1626
+
1627
+		// sanitize $REG_IDs
1628
+		$REG_IDs = array_map('absint', $REG_IDs);
1629
+		// and remove empty entries
1630
+		$REG_IDs = array_filter($REG_IDs);
1631
+
1632
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1633
+
1634
+		/**
1635
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1636
+		 * Currently this value is used downstream by the _process_resend_registration method.
1637
+		 *
1638
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1639
+		 * @param bool                     $status           The status registrations were changed to.
1640
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1641
+		 * @param Registrations_Admin_Page $admin_page_object
1642
+		 */
1643
+		$REG_ID = apply_filters(
1644
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1645
+			$result['REG_ID'],
1646
+			$status,
1647
+			$result['success'],
1648
+			$this
1649
+		);
1650
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1651
+
1652
+		// notify?
1653
+		if (
1654
+			$notify
1655
+			&& $result['success']
1656
+			&& ! empty($REG_ID)
1657
+			&& EE_Registry::instance()->CAP->current_user_can(
1658
+				'ee_send_message',
1659
+				'espresso_registrations_resend_registration'
1660
+			)
1661
+		) {
1662
+			$this->_process_resend_registration();
1663
+		}
1664
+		return $result;
1665
+	}
1666
+
1667
+
1668
+	/**
1669
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1670
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1671
+	 *
1672
+	 * @param array  $REG_IDs
1673
+	 * @param string $status
1674
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1675
+	 *                       slug sent with setting the registration status.
1676
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1677
+	 * @throws EE_Error
1678
+	 * @throws InvalidArgumentException
1679
+	 * @throws InvalidDataTypeException
1680
+	 * @throws InvalidInterfaceException
1681
+	 * @throws ReflectionException
1682
+	 * @throws RuntimeException
1683
+	 * @throws EntityNotFoundException
1684
+	 * @throws DomainException
1685
+	 */
1686
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1687
+	{
1688
+		$success = false;
1689
+		// typecast $REG_IDs
1690
+		$REG_IDs = (array) $REG_IDs;
1691
+		if (! empty($REG_IDs)) {
1692
+			$success = true;
1693
+			// set default status if none is passed
1694
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1695
+			$status_context = $notify
1696
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1697
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1698
+			// loop through REG_ID's and change status
1699
+			foreach ($REG_IDs as $REG_ID) {
1700
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1701
+				if ($registration instanceof EE_Registration) {
1702
+					$registration->set_status(
1703
+						$status,
1704
+						false,
1705
+						new Context(
1706
+							$status_context,
1707
+							esc_html__(
1708
+								'Manually triggered status change on a Registration Admin Page route.',
1709
+								'event_espresso'
1710
+							)
1711
+						)
1712
+					);
1713
+					$result = $registration->save();
1714
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1715
+					$success = $result !== false ? $success : false;
1716
+				}
1717
+			}
1718
+		}
1719
+
1720
+		// return $success and processed registrations
1721
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1722
+	}
1723
+
1724
+
1725
+	/**
1726
+	 * Common logic for setting up success message and redirecting to appropriate route
1727
+	 *
1728
+	 * @param string $STS_ID status id for the registration changed to
1729
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1730
+	 * @return void
1731
+	 * @throws DomainException
1732
+	 * @throws EE_Error
1733
+	 * @throws EntityNotFoundException
1734
+	 * @throws InvalidArgumentException
1735
+	 * @throws InvalidDataTypeException
1736
+	 * @throws InvalidInterfaceException
1737
+	 * @throws ReflectionException
1738
+	 * @throws RuntimeException
1739
+	 */
1740
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1741
+	{
1742
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1743
+			: ['success' => false];
1744
+		$success = isset($result['success']) && $result['success'];
1745
+		// setup success message
1746
+		if ($success) {
1747
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1748
+				$msg = sprintf(
1749
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1750
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1751
+				);
1752
+			} else {
1753
+				$msg = sprintf(
1754
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1755
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1756
+				);
1757
+			}
1758
+			EE_Error::add_success($msg);
1759
+		} else {
1760
+			EE_Error::add_error(
1761
+				esc_html__(
1762
+					'Something went wrong, and the status was not changed',
1763
+					'event_espresso'
1764
+				),
1765
+				__FILE__,
1766
+				__LINE__,
1767
+				__FUNCTION__
1768
+			);
1769
+		}
1770
+		$return = $this->request->getRequestParam('return');
1771
+		$route  = $return === 'view_registration'
1772
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1773
+			: ['action' => 'default'];
1774
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1775
+		$this->_redirect_after_action($success, '', '', $route, true);
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 * incoming reg status change from reg details page.
1781
+	 *
1782
+	 * @return void
1783
+	 * @throws EE_Error
1784
+	 * @throws EntityNotFoundException
1785
+	 * @throws InvalidArgumentException
1786
+	 * @throws InvalidDataTypeException
1787
+	 * @throws InvalidInterfaceException
1788
+	 * @throws ReflectionException
1789
+	 * @throws RuntimeException
1790
+	 * @throws DomainException
1791
+	 */
1792
+	protected function _change_reg_status()
1793
+	{
1794
+		$this->request->setRequestParam('return', 'view_registration');
1795
+		// set notify based on whether the send notifications toggle is set or not
1796
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1797
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1798
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1799
+		switch ($reg_status) {
1800
+			case EEM_Registration::status_id_approved:
1801
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1802
+				$this->approve_registration($notify);
1803
+				break;
1804
+			case EEM_Registration::status_id_pending_payment:
1805
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1806
+				$this->pending_registration($notify);
1807
+				break;
1808
+			case EEM_Registration::status_id_not_approved:
1809
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1810
+				$this->not_approve_registration($notify);
1811
+				break;
1812
+			case EEM_Registration::status_id_declined:
1813
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1814
+				$this->decline_registration($notify);
1815
+				break;
1816
+			case EEM_Registration::status_id_cancelled:
1817
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1818
+				$this->cancel_registration($notify);
1819
+				break;
1820
+			case EEM_Registration::status_id_wait_list:
1821
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1822
+				$this->wait_list_registration($notify);
1823
+				break;
1824
+			case EEM_Registration::status_id_incomplete:
1825
+			default:
1826
+				$this->request->unSetRequestParam('return');
1827
+				$this->_reg_status_change_return('');
1828
+				break;
1829
+		}
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * Callback for bulk action routes.
1835
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1836
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1837
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1838
+	 * when an action is happening on just a single registration).
1839
+	 *
1840
+	 * @param      $action
1841
+	 * @param bool $notify
1842
+	 */
1843
+	protected function bulk_action_on_registrations($action, $notify = false)
1844
+	{
1845
+		do_action(
1846
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1847
+			$this,
1848
+			$action,
1849
+			$notify
1850
+		);
1851
+		$method = $action . '_registration';
1852
+		if (method_exists($this, $method)) {
1853
+			$this->$method($notify);
1854
+		}
1855
+	}
1856
+
1857
+
1858
+	/**
1859
+	 * approve_registration
1860
+	 *
1861
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1862
+	 * @return void
1863
+	 * @throws EE_Error
1864
+	 * @throws EntityNotFoundException
1865
+	 * @throws InvalidArgumentException
1866
+	 * @throws InvalidDataTypeException
1867
+	 * @throws InvalidInterfaceException
1868
+	 * @throws ReflectionException
1869
+	 * @throws RuntimeException
1870
+	 * @throws DomainException
1871
+	 */
1872
+	protected function approve_registration($notify = false)
1873
+	{
1874
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1875
+	}
1876
+
1877
+
1878
+	/**
1879
+	 * decline_registration
1880
+	 *
1881
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1882
+	 * @return void
1883
+	 * @throws EE_Error
1884
+	 * @throws EntityNotFoundException
1885
+	 * @throws InvalidArgumentException
1886
+	 * @throws InvalidDataTypeException
1887
+	 * @throws InvalidInterfaceException
1888
+	 * @throws ReflectionException
1889
+	 * @throws RuntimeException
1890
+	 * @throws DomainException
1891
+	 */
1892
+	protected function decline_registration($notify = false)
1893
+	{
1894
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1895
+	}
1896
+
1897
+
1898
+	/**
1899
+	 * cancel_registration
1900
+	 *
1901
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1902
+	 * @return void
1903
+	 * @throws EE_Error
1904
+	 * @throws EntityNotFoundException
1905
+	 * @throws InvalidArgumentException
1906
+	 * @throws InvalidDataTypeException
1907
+	 * @throws InvalidInterfaceException
1908
+	 * @throws ReflectionException
1909
+	 * @throws RuntimeException
1910
+	 * @throws DomainException
1911
+	 */
1912
+	protected function cancel_registration($notify = false)
1913
+	{
1914
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1915
+	}
1916
+
1917
+
1918
+	/**
1919
+	 * not_approve_registration
1920
+	 *
1921
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1922
+	 * @return void
1923
+	 * @throws EE_Error
1924
+	 * @throws EntityNotFoundException
1925
+	 * @throws InvalidArgumentException
1926
+	 * @throws InvalidDataTypeException
1927
+	 * @throws InvalidInterfaceException
1928
+	 * @throws ReflectionException
1929
+	 * @throws RuntimeException
1930
+	 * @throws DomainException
1931
+	 */
1932
+	protected function not_approve_registration($notify = false)
1933
+	{
1934
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1935
+	}
1936
+
1937
+
1938
+	/**
1939
+	 * decline_registration
1940
+	 *
1941
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1942
+	 * @return void
1943
+	 * @throws EE_Error
1944
+	 * @throws EntityNotFoundException
1945
+	 * @throws InvalidArgumentException
1946
+	 * @throws InvalidDataTypeException
1947
+	 * @throws InvalidInterfaceException
1948
+	 * @throws ReflectionException
1949
+	 * @throws RuntimeException
1950
+	 * @throws DomainException
1951
+	 */
1952
+	protected function pending_registration($notify = false)
1953
+	{
1954
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1955
+	}
1956
+
1957
+
1958
+	/**
1959
+	 * waitlist_registration
1960
+	 *
1961
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1962
+	 * @return void
1963
+	 * @throws EE_Error
1964
+	 * @throws EntityNotFoundException
1965
+	 * @throws InvalidArgumentException
1966
+	 * @throws InvalidDataTypeException
1967
+	 * @throws InvalidInterfaceException
1968
+	 * @throws ReflectionException
1969
+	 * @throws RuntimeException
1970
+	 * @throws DomainException
1971
+	 */
1972
+	protected function wait_list_registration($notify = false)
1973
+	{
1974
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1975
+	}
1976
+
1977
+
1978
+	/**
1979
+	 * generates HTML for the Registration main meta box
1980
+	 *
1981
+	 * @return void
1982
+	 * @throws DomainException
1983
+	 * @throws EE_Error
1984
+	 * @throws InvalidArgumentException
1985
+	 * @throws InvalidDataTypeException
1986
+	 * @throws InvalidInterfaceException
1987
+	 * @throws ReflectionException
1988
+	 * @throws EntityNotFoundException
1989
+	 */
1990
+	public function _reg_details_meta_box()
1991
+	{
1992
+		EEH_Autoloader::register_line_item_display_autoloaders();
1993
+		EEH_Autoloader::register_line_item_filter_autoloaders();
1994
+		EE_Registry::instance()->load_helper('Line_Item');
1995
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1996
+			: EE_Transaction::new_instance();
1997
+		$this->_session = $transaction->session_data();
1998
+		$filters        = new EE_Line_Item_Filter_Collection();
1999
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2000
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2001
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2002
+			$filters,
2003
+			$transaction->total_line_item()
2004
+		);
2005
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2006
+		$line_item_display                       = new EE_Line_Item_Display(
2007
+			'reg_admin_table',
2008
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2009
+		);
2010
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2011
+			$filtered_line_item_tree,
2012
+			['EE_Registration' => $this->_registration]
2013
+		);
2014
+		$attendee                                = $this->_registration->attendee();
2015
+		if (
2016
+			EE_Registry::instance()->CAP->current_user_can(
2017
+				'ee_read_transaction',
2018
+				'espresso_transactions_view_transaction'
2019
+			)
2020
+		) {
2021
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2022
+				EE_Admin_Page::add_query_args_and_nonce(
2023
+					[
2024
+						'action' => 'view_transaction',
2025
+						'TXN_ID' => $transaction->ID(),
2026
+					],
2027
+					TXN_ADMIN_URL
2028
+				),
2029
+				esc_html__(' View Transaction', 'event_espresso'),
2030
+				'button button--secondary right',
2031
+				'dashicons dashicons-cart'
2032
+			);
2033
+		} else {
2034
+			$this->_template_args['view_transaction_button'] = '';
2035
+		}
2036
+		if (
2037
+			$attendee instanceof EE_Attendee
2038
+			&& EE_Registry::instance()->CAP->current_user_can(
2039
+				'ee_send_message',
2040
+				'espresso_registrations_resend_registration'
2041
+			)
2042
+		) {
2043
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2044
+				EE_Admin_Page::add_query_args_and_nonce(
2045
+					[
2046
+						'action'      => 'resend_registration',
2047
+						'_REG_ID'     => $this->_registration->ID(),
2048
+						'redirect_to' => 'view_registration',
2049
+					],
2050
+					REG_ADMIN_URL
2051
+				),
2052
+				esc_html__(' Resend Registration', 'event_espresso'),
2053
+				'button button--secondary right',
2054
+				'dashicons dashicons-email-alt'
2055
+			);
2056
+		} else {
2057
+			$this->_template_args['resend_registration_button'] = '';
2058
+		}
2059
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2060
+		$payment                               = $transaction->get_first_related('Payment');
2061
+		$payment                               = ! $payment instanceof EE_Payment
2062
+			? EE_Payment::new_instance()
2063
+			: $payment;
2064
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2065
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2066
+			? EE_Payment_Method::new_instance()
2067
+			: $payment_method;
2068
+		$reg_details                           = [
2069
+			'payment_method'       => $payment_method->name(),
2070
+			'response_msg'         => $payment->gateway_response(),
2071
+			'registration_id'      => $this->_registration->get('REG_code'),
2072
+			'registration_session' => $this->_registration->session_ID(),
2073
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2074
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2075
+		];
2076
+		if (isset($reg_details['registration_id'])) {
2077
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2078
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2079
+				'Registration ID',
2080
+				'event_espresso'
2081
+			);
2082
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2083
+		}
2084
+		if (isset($reg_details['payment_method'])) {
2085
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2086
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2087
+				'Most Recent Payment Method',
2088
+				'event_espresso'
2089
+			);
2090
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2091
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2092
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2093
+				'Payment method response',
2094
+				'event_espresso'
2095
+			);
2096
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2097
+		}
2098
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2099
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2100
+			'Registration Session',
2101
+			'event_espresso'
2102
+		);
2103
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2104
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2105
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2106
+			'Registration placed from IP',
2107
+			'event_espresso'
2108
+		);
2109
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2110
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2111
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2112
+			'Registrant User Agent',
2113
+			'event_espresso'
2114
+		);
2115
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2116
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2117
+			[
2118
+				'action'   => 'default',
2119
+				'event_id' => $this->_registration->event_ID(),
2120
+			],
2121
+			REG_ADMIN_URL
2122
+		);
2123
+
2124
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2125
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2126
+
2127
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2128
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2129
+	}
2130
+
2131
+
2132
+	/**
2133
+	 * generates HTML for the Registration Questions meta box.
2134
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2135
+	 * otherwise uses new forms system
2136
+	 *
2137
+	 * @return void
2138
+	 * @throws DomainException
2139
+	 * @throws EE_Error
2140
+	 * @throws InvalidArgumentException
2141
+	 * @throws InvalidDataTypeException
2142
+	 * @throws InvalidInterfaceException
2143
+	 * @throws ReflectionException
2144
+	 */
2145
+	public function _reg_questions_meta_box()
2146
+	{
2147
+		// allow someone to override this method entirely
2148
+		if (
2149
+			apply_filters(
2150
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2151
+				true,
2152
+				$this,
2153
+				$this->_registration
2154
+			)
2155
+		) {
2156
+			$form = $this->_get_reg_custom_questions_form(
2157
+				$this->_registration->ID()
2158
+			);
2159
+
2160
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2161
+				? $form->get_html_and_js()
2162
+				: '';
2163
+
2164
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2165
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2166
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2167
+			EEH_Template::display_template($template_path, $this->_template_args);
2168
+		}
2169
+	}
2170
+
2171
+
2172
+	/**
2173
+	 * form_before_question_group
2174
+	 *
2175
+	 * @param string $output
2176
+	 * @return        string
2177
+	 * @deprecated    as of 4.8.32.rc.000
2178
+	 */
2179
+	public function form_before_question_group($output)
2180
+	{
2181
+		EE_Error::doing_it_wrong(
2182
+			__CLASS__ . '::' . __FUNCTION__,
2183
+			esc_html__(
2184
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2185
+				'event_espresso'
2186
+			),
2187
+			'4.8.32.rc.000'
2188
+		);
2189
+		return '
2190 2190
 	<table class="form-table ee-width-100">
2191 2191
 		<tbody>
2192 2192
 			';
2193
-    }
2194
-
2195
-
2196
-    /**
2197
-     * form_after_question_group
2198
-     *
2199
-     * @param string $output
2200
-     * @return        string
2201
-     * @deprecated    as of 4.8.32.rc.000
2202
-     */
2203
-    public function form_after_question_group($output)
2204
-    {
2205
-        EE_Error::doing_it_wrong(
2206
-            __CLASS__ . '::' . __FUNCTION__,
2207
-            esc_html__(
2208
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2209
-                'event_espresso'
2210
-            ),
2211
-            '4.8.32.rc.000'
2212
-        );
2213
-        return '
2193
+	}
2194
+
2195
+
2196
+	/**
2197
+	 * form_after_question_group
2198
+	 *
2199
+	 * @param string $output
2200
+	 * @return        string
2201
+	 * @deprecated    as of 4.8.32.rc.000
2202
+	 */
2203
+	public function form_after_question_group($output)
2204
+	{
2205
+		EE_Error::doing_it_wrong(
2206
+			__CLASS__ . '::' . __FUNCTION__,
2207
+			esc_html__(
2208
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2209
+				'event_espresso'
2210
+			),
2211
+			'4.8.32.rc.000'
2212
+		);
2213
+		return '
2214 2214
 			<tr class="hide-if-no-js">
2215 2215
 				<th> </th>
2216 2216
 				<td class="reg-admin-edit-attendee-question-td">
2217 2217
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2218
-               . esc_attr__('click to edit question', 'event_espresso')
2219
-               . '">
2218
+			   . esc_attr__('click to edit question', 'event_espresso')
2219
+			   . '">
2220 2220
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2221
-               . esc_html__('edit the above question group', 'event_espresso')
2222
-               . '</span>
2221
+			   . esc_html__('edit the above question group', 'event_espresso')
2222
+			   . '</span>
2223 2223
 						<div class="dashicons dashicons-edit"></div>
2224 2224
 					</a>
2225 2225
 				</td>
@@ -2227,636 +2227,636 @@  discard block
 block discarded – undo
2227 2227
 		</tbody>
2228 2228
 	</table>
2229 2229
 ';
2230
-    }
2231
-
2232
-
2233
-    /**
2234
-     * form_form_field_label_wrap
2235
-     *
2236
-     * @param string $label
2237
-     * @return        string
2238
-     * @deprecated    as of 4.8.32.rc.000
2239
-     */
2240
-    public function form_form_field_label_wrap($label)
2241
-    {
2242
-        EE_Error::doing_it_wrong(
2243
-            __CLASS__ . '::' . __FUNCTION__,
2244
-            esc_html__(
2245
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2246
-                'event_espresso'
2247
-            ),
2248
-            '4.8.32.rc.000'
2249
-        );
2250
-        return '
2230
+	}
2231
+
2232
+
2233
+	/**
2234
+	 * form_form_field_label_wrap
2235
+	 *
2236
+	 * @param string $label
2237
+	 * @return        string
2238
+	 * @deprecated    as of 4.8.32.rc.000
2239
+	 */
2240
+	public function form_form_field_label_wrap($label)
2241
+	{
2242
+		EE_Error::doing_it_wrong(
2243
+			__CLASS__ . '::' . __FUNCTION__,
2244
+			esc_html__(
2245
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2246
+				'event_espresso'
2247
+			),
2248
+			'4.8.32.rc.000'
2249
+		);
2250
+		return '
2251 2251
 			<tr>
2252 2252
 				<th>
2253 2253
 					' . $label . '
2254 2254
 				</th>';
2255
-    }
2256
-
2257
-
2258
-    /**
2259
-     * form_form_field_input__wrap
2260
-     *
2261
-     * @param string $input
2262
-     * @return        string
2263
-     * @deprecated    as of 4.8.32.rc.000
2264
-     */
2265
-    public function form_form_field_input__wrap($input)
2266
-    {
2267
-        EE_Error::doing_it_wrong(
2268
-            __CLASS__ . '::' . __FUNCTION__,
2269
-            esc_html__(
2270
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2271
-                'event_espresso'
2272
-            ),
2273
-            '4.8.32.rc.000'
2274
-        );
2275
-        return '
2255
+	}
2256
+
2257
+
2258
+	/**
2259
+	 * form_form_field_input__wrap
2260
+	 *
2261
+	 * @param string $input
2262
+	 * @return        string
2263
+	 * @deprecated    as of 4.8.32.rc.000
2264
+	 */
2265
+	public function form_form_field_input__wrap($input)
2266
+	{
2267
+		EE_Error::doing_it_wrong(
2268
+			__CLASS__ . '::' . __FUNCTION__,
2269
+			esc_html__(
2270
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2271
+				'event_espresso'
2272
+			),
2273
+			'4.8.32.rc.000'
2274
+		);
2275
+		return '
2276 2276
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2277 2277
 					' . $input . '
2278 2278
 				</td>
2279 2279
 			</tr>';
2280
-    }
2281
-
2282
-
2283
-    /**
2284
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2285
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2286
-     * to display the page
2287
-     *
2288
-     * @return void
2289
-     * @throws EE_Error
2290
-     * @throws InvalidArgumentException
2291
-     * @throws InvalidDataTypeException
2292
-     * @throws InvalidInterfaceException
2293
-     * @throws ReflectionException
2294
-     */
2295
-    protected function _update_attendee_registration_form()
2296
-    {
2297
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2298
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2299
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2300
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2301
-            if ($success) {
2302
-                $what  = esc_html__('Registration Form', 'event_espresso');
2303
-                $route = $REG_ID
2304
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2305
-                    : ['action' => 'default'];
2306
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2307
-            }
2308
-        }
2309
-    }
2310
-
2311
-
2312
-    /**
2313
-     * Gets the form for saving registrations custom questions (if done
2314
-     * previously retrieves the cached form object, which may have validation errors in it)
2315
-     *
2316
-     * @param int $REG_ID
2317
-     * @return EE_Registration_Custom_Questions_Form
2318
-     * @throws EE_Error
2319
-     * @throws InvalidArgumentException
2320
-     * @throws InvalidDataTypeException
2321
-     * @throws InvalidInterfaceException
2322
-     * @throws ReflectionException
2323
-     */
2324
-    protected function _get_reg_custom_questions_form($REG_ID)
2325
-    {
2326
-        if (! $this->_reg_custom_questions_form) {
2327
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2328
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2329
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2330
-            );
2331
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2332
-        }
2333
-        return $this->_reg_custom_questions_form;
2334
-    }
2335
-
2336
-
2337
-    /**
2338
-     * Saves
2339
-     *
2340
-     * @param bool $REG_ID
2341
-     * @return bool
2342
-     * @throws EE_Error
2343
-     * @throws InvalidArgumentException
2344
-     * @throws InvalidDataTypeException
2345
-     * @throws InvalidInterfaceException
2346
-     * @throws ReflectionException
2347
-     */
2348
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2349
-    {
2350
-        if (! $REG_ID) {
2351
-            EE_Error::add_error(
2352
-                esc_html__(
2353
-                    'An error occurred. No registration ID was received.',
2354
-                    'event_espresso'
2355
-                ),
2356
-                __FILE__,
2357
-                __FUNCTION__,
2358
-                __LINE__
2359
-            );
2360
-        }
2361
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2362
-        $form->receive_form_submission($this->request->requestParams());
2363
-        $success = false;
2364
-        if ($form->is_valid()) {
2365
-            foreach ($form->subforms() as $question_group_form) {
2366
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2367
-                    $where_conditions    = [
2368
-                        'QST_ID' => $question_id,
2369
-                        'REG_ID' => $REG_ID,
2370
-                    ];
2371
-                    $possibly_new_values = [
2372
-                        'ANS_value' => $input->normalized_value(),
2373
-                    ];
2374
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2375
-                    if ($answer instanceof EE_Answer) {
2376
-                        $success = $answer->save($possibly_new_values);
2377
-                    } else {
2378
-                        // insert it then
2379
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2380
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2381
-                        $success     = $answer->save();
2382
-                    }
2383
-                }
2384
-            }
2385
-        } else {
2386
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2387
-        }
2388
-        return $success;
2389
-    }
2390
-
2391
-
2392
-    /**
2393
-     * generates HTML for the Registration main meta box
2394
-     *
2395
-     * @return void
2396
-     * @throws DomainException
2397
-     * @throws EE_Error
2398
-     * @throws InvalidArgumentException
2399
-     * @throws InvalidDataTypeException
2400
-     * @throws InvalidInterfaceException
2401
-     * @throws ReflectionException
2402
-     */
2403
-    public function _reg_attendees_meta_box()
2404
-    {
2405
-        $REG = $this->getRegistrationModel();
2406
-        // get all other registrations on this transaction, and cache
2407
-        // the attendees for them so we don't have to run another query using force_join
2408
-        $registrations                           = $REG->get_all(
2409
-            [
2410
-                [
2411
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2412
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2413
-                ],
2414
-                'force_join'               => ['Attendee'],
2415
-                'default_where_conditions' => 'other_models_only',
2416
-            ]
2417
-        );
2418
-        $this->_template_args['attendees']       = [];
2419
-        $this->_template_args['attendee_notice'] = '';
2420
-        if (
2421
-            empty($registrations)
2422
-            || (is_array($registrations)
2423
-                && ! EEH_Array::get_one_item_from_array($registrations))
2424
-        ) {
2425
-            EE_Error::add_error(
2426
-                esc_html__(
2427
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2428
-                    'event_espresso'
2429
-                ),
2430
-                __FILE__,
2431
-                __FUNCTION__,
2432
-                __LINE__
2433
-            );
2434
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2435
-        } else {
2436
-            $att_nmbr = 1;
2437
-            foreach ($registrations as $registration) {
2438
-                /* @var $registration EE_Registration */
2439
-                $attendee                                                      = $registration->attendee()
2440
-                    ? $registration->attendee()
2441
-                    : $this->getAttendeeModel()->create_default_object();
2442
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2443
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2444
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2445
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2446
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2447
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2448
-                    ', ',
2449
-                    $attendee->full_address_as_array()
2450
-                );
2451
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2452
-                    [
2453
-                        'action' => 'edit_attendee',
2454
-                        'post'   => $attendee->ID(),
2455
-                    ],
2456
-                    REG_ADMIN_URL
2457
-                );
2458
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2459
-                    $registration->event_obj() instanceof EE_Event
2460
-                        ? $registration->event_obj()->name()
2461
-                        : '';
2462
-                $att_nmbr++;
2463
-            }
2464
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2465
-        }
2466
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2467
-        EEH_Template::display_template($template_path, $this->_template_args);
2468
-    }
2469
-
2470
-
2471
-    /**
2472
-     * generates HTML for the Edit Registration side meta box
2473
-     *
2474
-     * @return void
2475
-     * @throws DomainException
2476
-     * @throws EE_Error
2477
-     * @throws InvalidArgumentException
2478
-     * @throws InvalidDataTypeException
2479
-     * @throws InvalidInterfaceException
2480
-     * @throws ReflectionException
2481
-     */
2482
-    public function _reg_registrant_side_meta_box()
2483
-    {
2484
-        /*@var $attendee EE_Attendee */
2485
-        $att_check = $this->_registration->attendee();
2486
-        $attendee  = $att_check instanceof EE_Attendee
2487
-            ? $att_check
2488
-            : $this->getAttendeeModel()->create_default_object();
2489
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2490
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2491
-        // primary registration object (that way we know if we need to show create button or not)
2492
-        if (! $this->_registration->is_primary_registrant()) {
2493
-            $primary_registration = $this->_registration->get_primary_registration();
2494
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2495
-                : null;
2496
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2497
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2498
-                // custom attendee object so let's not worry about the primary reg.
2499
-                $primary_registration = null;
2500
-            }
2501
-        } else {
2502
-            $primary_registration = null;
2503
-        }
2504
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2505
-        $this->_template_args['fname']             = $attendee->fname();
2506
-        $this->_template_args['lname']             = $attendee->lname();
2507
-        $this->_template_args['email']             = $attendee->email();
2508
-        $this->_template_args['phone']             = $attendee->phone();
2509
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2510
-        // edit link
2511
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2512
-            [
2513
-                'action' => 'edit_attendee',
2514
-                'post'   => $attendee->ID(),
2515
-            ],
2516
-            REG_ADMIN_URL
2517
-        );
2518
-        $this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2519
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2520
-        // create link
2521
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2522
-            ? EE_Admin_Page::add_query_args_and_nonce(
2523
-                [
2524
-                    'action'  => 'duplicate_attendee',
2525
-                    '_REG_ID' => $this->_registration->ID(),
2526
-                ],
2527
-                REG_ADMIN_URL
2528
-            ) : '';
2529
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2530
-        $this->_template_args['att_check'] = $att_check;
2531
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2532
-        EEH_Template::display_template($template_path, $this->_template_args);
2533
-    }
2534
-
2535
-
2536
-    /**
2537
-     * trash or restore registrations
2538
-     *
2539
-     * @param boolean $trash whether to archive or restore
2540
-     * @return void
2541
-     * @throws EE_Error
2542
-     * @throws InvalidArgumentException
2543
-     * @throws InvalidDataTypeException
2544
-     * @throws InvalidInterfaceException
2545
-     * @throws RuntimeException
2546
-     */
2547
-    protected function _trash_or_restore_registrations($trash = true)
2548
-    {
2549
-        // if empty _REG_ID then get out because there's nothing to do
2550
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2551
-        if (empty($REG_IDs)) {
2552
-            EE_Error::add_error(
2553
-                sprintf(
2554
-                    esc_html__(
2555
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2556
-                        'event_espresso'
2557
-                    ),
2558
-                    $trash ? 'trash' : 'restore'
2559
-                ),
2560
-                __FILE__,
2561
-                __LINE__,
2562
-                __FUNCTION__
2563
-            );
2564
-            $this->_redirect_after_action(false, '', '', [], true);
2565
-        }
2566
-        $success        = 0;
2567
-        $overwrite_msgs = false;
2568
-        // Checkboxes
2569
-        $reg_count = count($REG_IDs);
2570
-        // cycle thru checkboxes
2571
-        foreach ($REG_IDs as $REG_ID) {
2572
-            /** @var EE_Registration $REG */
2573
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2574
-            $payments = $REG->registration_payments();
2575
-            if (! empty($payments)) {
2576
-                $name           = $REG->attendee() instanceof EE_Attendee
2577
-                    ? $REG->attendee()->full_name()
2578
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2579
-                $overwrite_msgs = true;
2580
-                EE_Error::add_error(
2581
-                    sprintf(
2582
-                        esc_html__(
2583
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2584
-                            'event_espresso'
2585
-                        ),
2586
-                        $name
2587
-                    ),
2588
-                    __FILE__,
2589
-                    __FUNCTION__,
2590
-                    __LINE__
2591
-                );
2592
-                // can't trash this registration because it has payments.
2593
-                continue;
2594
-            }
2595
-            $updated = $trash ? $REG->delete() : $REG->restore();
2596
-            if ($updated) {
2597
-                $success++;
2598
-            }
2599
-        }
2600
-        $this->_redirect_after_action(
2601
-            $success === $reg_count, // were ALL registrations affected?
2602
-            $success > 1
2603
-                ? esc_html__('Registrations', 'event_espresso')
2604
-                : esc_html__('Registration', 'event_espresso'),
2605
-            $trash
2606
-                ? esc_html__('moved to the trash', 'event_espresso')
2607
-                : esc_html__('restored', 'event_espresso'),
2608
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2609
-            $overwrite_msgs
2610
-        );
2611
-    }
2612
-
2613
-
2614
-    /**
2615
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2616
-     * registration but also.
2617
-     * 1. Removing relations to EE_Attendee
2618
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2619
-     * ALSO trashed.
2620
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2621
-     * 4. Removing relationships between all tickets and the related registrations
2622
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2623
-     * 6. Deleting permanently any related Checkins.
2624
-     *
2625
-     * @return void
2626
-     * @throws EE_Error
2627
-     * @throws InvalidArgumentException
2628
-     * @throws InvalidDataTypeException
2629
-     * @throws InvalidInterfaceException
2630
-     * @throws ReflectionException
2631
-     */
2632
-    protected function _delete_registrations()
2633
-    {
2634
-        $REG_MDL = $this->getRegistrationModel();
2635
-        $success = 0;
2636
-        // Checkboxes
2637
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2638
-
2639
-        if (! empty($REG_IDs)) {
2640
-            // if array has more than one element than success message should be plural
2641
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2642
-            // cycle thru checkboxes
2643
-            foreach ($REG_IDs as $REG_ID) {
2644
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2645
-                if (! $REG instanceof EE_Registration) {
2646
-                    continue;
2647
-                }
2648
-                $deleted = $this->_delete_registration($REG);
2649
-                if (! $deleted) {
2650
-                    $success = 0;
2651
-                }
2652
-            }
2653
-        }
2654
-
2655
-        $what        = $success > 1
2656
-            ? esc_html__('Registrations', 'event_espresso')
2657
-            : esc_html__('Registration', 'event_espresso');
2658
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2659
-        $this->_redirect_after_action(
2660
-            $success,
2661
-            $what,
2662
-            $action_desc,
2663
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2664
-            true
2665
-        );
2666
-    }
2667
-
2668
-
2669
-    /**
2670
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2671
-     * models get affected.
2672
-     *
2673
-     * @param EE_Registration $REG registration to be deleted permanently
2674
-     * @return bool true = successful deletion, false = fail.
2675
-     * @throws EE_Error
2676
-     * @throws InvalidArgumentException
2677
-     * @throws InvalidDataTypeException
2678
-     * @throws InvalidInterfaceException
2679
-     * @throws ReflectionException
2680
-     */
2681
-    protected function _delete_registration(EE_Registration $REG)
2682
-    {
2683
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2684
-        // registrations on the transaction that are NOT trashed.
2685
-        $TXN = $REG->get_first_related('Transaction');
2686
-        if (! $TXN instanceof EE_Transaction) {
2687
-            EE_Error::add_error(
2688
-                sprintf(
2689
-                    esc_html__(
2690
-                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2691
-                        'event_espresso'
2692
-                    ),
2693
-                    $REG->id()
2694
-                ),
2695
-                __FILE__,
2696
-                __FUNCTION__,
2697
-                __LINE__
2698
-            );
2699
-            return false;
2700
-        }
2701
-        $REGS        = $TXN->get_many_related('Registration');
2702
-        $all_trashed = true;
2703
-        foreach ($REGS as $registration) {
2704
-            if (! $registration->get('REG_deleted')) {
2705
-                $all_trashed = false;
2706
-            }
2707
-        }
2708
-        if (! $all_trashed) {
2709
-            EE_Error::add_error(
2710
-                esc_html__(
2711
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2712
-                    'event_espresso'
2713
-                ),
2714
-                __FILE__,
2715
-                __FUNCTION__,
2716
-                __LINE__
2717
-            );
2718
-            return false;
2719
-        }
2720
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2721
-        // separately from THIS one).
2722
-        foreach ($REGS as $registration) {
2723
-            // delete related answers
2724
-            $registration->delete_related_permanently('Answer');
2725
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2726
-            $attendee = $registration->get_first_related('Attendee');
2727
-            if ($attendee instanceof EE_Attendee) {
2728
-                $registration->_remove_relation_to($attendee, 'Attendee');
2729
-            }
2730
-            // now remove relationships to tickets on this registration.
2731
-            $registration->_remove_relations('Ticket');
2732
-            // now delete permanently the checkins related to this registration.
2733
-            $registration->delete_related_permanently('Checkin');
2734
-            if ($registration->ID() === $REG->ID()) {
2735
-                continue;
2736
-            } //we don't want to delete permanently the existing registration just yet.
2737
-            // remove relation to transaction for these registrations if NOT the existing registrations
2738
-            $registration->_remove_relations('Transaction');
2739
-            // delete permanently any related messages.
2740
-            $registration->delete_related_permanently('Message');
2741
-            // now delete this registration permanently
2742
-            $registration->delete_permanently();
2743
-        }
2744
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2745
-        // (the transaction and line items should be all that's left).
2746
-        // delete the line items related to the transaction for this registration.
2747
-        $TXN->delete_related_permanently('Line_Item');
2748
-        // we need to remove all the relationships on the transaction
2749
-        $TXN->delete_related_permanently('Payment');
2750
-        $TXN->delete_related_permanently('Extra_Meta');
2751
-        $TXN->delete_related_permanently('Message');
2752
-        // now we can delete this REG permanently (and the transaction of course)
2753
-        $REG->delete_related_permanently('Transaction');
2754
-        return $REG->delete_permanently();
2755
-    }
2756
-
2757
-
2758
-    /**
2759
-     *    generates HTML for the Register New Attendee Admin page
2760
-     *
2761
-     * @throws DomainException
2762
-     * @throws EE_Error
2763
-     * @throws InvalidArgumentException
2764
-     * @throws InvalidDataTypeException
2765
-     * @throws InvalidInterfaceException
2766
-     * @throws ReflectionException
2767
-     */
2768
-    public function new_registration()
2769
-    {
2770
-        if (! $this->_set_reg_event()) {
2771
-            throw new EE_Error(
2772
-                esc_html__(
2773
-                    'Unable to continue with registering because there is no Event ID in the request',
2774
-                    'event_espresso'
2775
-                )
2776
-            );
2777
-        }
2778
-        /** @var CurrentPage $current_page */
2779
-        $current_page = $this->loader->getShared(CurrentPage::class);
2780
-        $current_page->setEspressoPage(true);
2781
-        // gotta start with a clean slate if we're not coming here via ajax
2782
-        if (
2783
-            ! $this->request->isAjax()
2784
-            && (
2785
-                ! $this->request->requestParamIsSet('processing_registration')
2786
-                || $this->request->requestParamIsSet('step_error')
2787
-            )
2788
-        ) {
2789
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2790
-        }
2791
-        $this->_template_args['event_name'] = '';
2792
-        // event name
2793
-        if ($this->_reg_event) {
2794
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2795
-            $edit_event_url                     = self::add_query_args_and_nonce(
2796
-                [
2797
-                    'action' => 'edit',
2798
-                    'post'   => $this->_reg_event->ID(),
2799
-                ],
2800
-                EVENTS_ADMIN_URL
2801
-            );
2802
-            $edit_event_lnk                     = '<a href="'
2803
-                                                  . $edit_event_url
2804
-                                                  . '" title="'
2805
-                                                  . esc_attr__('Edit ', 'event_espresso')
2806
-                                                  . $this->_reg_event->name()
2807
-                                                  . '">'
2808
-                                                  . esc_html__('Edit Event', 'event_espresso')
2809
-                                                  . '</a>';
2810
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2811
-                                                   . $edit_event_lnk
2812
-                                                   . '</span>';
2813
-        }
2814
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2815
-        if ($this->request->isAjax()) {
2816
-            $this->_return_json();
2817
-        }
2818
-        // grab header
2819
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2820
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2821
-            $template_path,
2822
-            $this->_template_args,
2823
-            true
2824
-        );
2825
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2826
-        // the details template wrapper
2827
-        $this->display_admin_page_with_sidebar();
2828
-    }
2829
-
2830
-
2831
-    /**
2832
-     * This returns the content for a registration step
2833
-     *
2834
-     * @return string html
2835
-     * @throws DomainException
2836
-     * @throws EE_Error
2837
-     * @throws InvalidArgumentException
2838
-     * @throws InvalidDataTypeException
2839
-     * @throws InvalidInterfaceException
2840
-     * @throws ReflectionException
2841
-     */
2842
-    protected function _get_registration_step_content()
2843
-    {
2844
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2845
-            $warning_msg = sprintf(
2846
-                esc_html__(
2847
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2848
-                    'event_espresso'
2849
-                ),
2850
-                '<br />',
2851
-                '<h3 class="important-notice">',
2852
-                '</h3>',
2853
-                '<div class="float-right">',
2854
-                '<span id="redirect_timer" class="important-notice">30</span>',
2855
-                '</div>',
2856
-                '<b>',
2857
-                '</b>'
2858
-            );
2859
-            return '
2280
+	}
2281
+
2282
+
2283
+	/**
2284
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2285
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2286
+	 * to display the page
2287
+	 *
2288
+	 * @return void
2289
+	 * @throws EE_Error
2290
+	 * @throws InvalidArgumentException
2291
+	 * @throws InvalidDataTypeException
2292
+	 * @throws InvalidInterfaceException
2293
+	 * @throws ReflectionException
2294
+	 */
2295
+	protected function _update_attendee_registration_form()
2296
+	{
2297
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2298
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2299
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2300
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2301
+			if ($success) {
2302
+				$what  = esc_html__('Registration Form', 'event_espresso');
2303
+				$route = $REG_ID
2304
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2305
+					: ['action' => 'default'];
2306
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2307
+			}
2308
+		}
2309
+	}
2310
+
2311
+
2312
+	/**
2313
+	 * Gets the form for saving registrations custom questions (if done
2314
+	 * previously retrieves the cached form object, which may have validation errors in it)
2315
+	 *
2316
+	 * @param int $REG_ID
2317
+	 * @return EE_Registration_Custom_Questions_Form
2318
+	 * @throws EE_Error
2319
+	 * @throws InvalidArgumentException
2320
+	 * @throws InvalidDataTypeException
2321
+	 * @throws InvalidInterfaceException
2322
+	 * @throws ReflectionException
2323
+	 */
2324
+	protected function _get_reg_custom_questions_form($REG_ID)
2325
+	{
2326
+		if (! $this->_reg_custom_questions_form) {
2327
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2328
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2329
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2330
+			);
2331
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2332
+		}
2333
+		return $this->_reg_custom_questions_form;
2334
+	}
2335
+
2336
+
2337
+	/**
2338
+	 * Saves
2339
+	 *
2340
+	 * @param bool $REG_ID
2341
+	 * @return bool
2342
+	 * @throws EE_Error
2343
+	 * @throws InvalidArgumentException
2344
+	 * @throws InvalidDataTypeException
2345
+	 * @throws InvalidInterfaceException
2346
+	 * @throws ReflectionException
2347
+	 */
2348
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2349
+	{
2350
+		if (! $REG_ID) {
2351
+			EE_Error::add_error(
2352
+				esc_html__(
2353
+					'An error occurred. No registration ID was received.',
2354
+					'event_espresso'
2355
+				),
2356
+				__FILE__,
2357
+				__FUNCTION__,
2358
+				__LINE__
2359
+			);
2360
+		}
2361
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2362
+		$form->receive_form_submission($this->request->requestParams());
2363
+		$success = false;
2364
+		if ($form->is_valid()) {
2365
+			foreach ($form->subforms() as $question_group_form) {
2366
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2367
+					$where_conditions    = [
2368
+						'QST_ID' => $question_id,
2369
+						'REG_ID' => $REG_ID,
2370
+					];
2371
+					$possibly_new_values = [
2372
+						'ANS_value' => $input->normalized_value(),
2373
+					];
2374
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2375
+					if ($answer instanceof EE_Answer) {
2376
+						$success = $answer->save($possibly_new_values);
2377
+					} else {
2378
+						// insert it then
2379
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2380
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2381
+						$success     = $answer->save();
2382
+					}
2383
+				}
2384
+			}
2385
+		} else {
2386
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2387
+		}
2388
+		return $success;
2389
+	}
2390
+
2391
+
2392
+	/**
2393
+	 * generates HTML for the Registration main meta box
2394
+	 *
2395
+	 * @return void
2396
+	 * @throws DomainException
2397
+	 * @throws EE_Error
2398
+	 * @throws InvalidArgumentException
2399
+	 * @throws InvalidDataTypeException
2400
+	 * @throws InvalidInterfaceException
2401
+	 * @throws ReflectionException
2402
+	 */
2403
+	public function _reg_attendees_meta_box()
2404
+	{
2405
+		$REG = $this->getRegistrationModel();
2406
+		// get all other registrations on this transaction, and cache
2407
+		// the attendees for them so we don't have to run another query using force_join
2408
+		$registrations                           = $REG->get_all(
2409
+			[
2410
+				[
2411
+					'TXN_ID' => $this->_registration->transaction_ID(),
2412
+					'REG_ID' => ['!=', $this->_registration->ID()],
2413
+				],
2414
+				'force_join'               => ['Attendee'],
2415
+				'default_where_conditions' => 'other_models_only',
2416
+			]
2417
+		);
2418
+		$this->_template_args['attendees']       = [];
2419
+		$this->_template_args['attendee_notice'] = '';
2420
+		if (
2421
+			empty($registrations)
2422
+			|| (is_array($registrations)
2423
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2424
+		) {
2425
+			EE_Error::add_error(
2426
+				esc_html__(
2427
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2428
+					'event_espresso'
2429
+				),
2430
+				__FILE__,
2431
+				__FUNCTION__,
2432
+				__LINE__
2433
+			);
2434
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2435
+		} else {
2436
+			$att_nmbr = 1;
2437
+			foreach ($registrations as $registration) {
2438
+				/* @var $registration EE_Registration */
2439
+				$attendee                                                      = $registration->attendee()
2440
+					? $registration->attendee()
2441
+					: $this->getAttendeeModel()->create_default_object();
2442
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2443
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2444
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2445
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2446
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2447
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2448
+					', ',
2449
+					$attendee->full_address_as_array()
2450
+				);
2451
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2452
+					[
2453
+						'action' => 'edit_attendee',
2454
+						'post'   => $attendee->ID(),
2455
+					],
2456
+					REG_ADMIN_URL
2457
+				);
2458
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2459
+					$registration->event_obj() instanceof EE_Event
2460
+						? $registration->event_obj()->name()
2461
+						: '';
2462
+				$att_nmbr++;
2463
+			}
2464
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2465
+		}
2466
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2467
+		EEH_Template::display_template($template_path, $this->_template_args);
2468
+	}
2469
+
2470
+
2471
+	/**
2472
+	 * generates HTML for the Edit Registration side meta box
2473
+	 *
2474
+	 * @return void
2475
+	 * @throws DomainException
2476
+	 * @throws EE_Error
2477
+	 * @throws InvalidArgumentException
2478
+	 * @throws InvalidDataTypeException
2479
+	 * @throws InvalidInterfaceException
2480
+	 * @throws ReflectionException
2481
+	 */
2482
+	public function _reg_registrant_side_meta_box()
2483
+	{
2484
+		/*@var $attendee EE_Attendee */
2485
+		$att_check = $this->_registration->attendee();
2486
+		$attendee  = $att_check instanceof EE_Attendee
2487
+			? $att_check
2488
+			: $this->getAttendeeModel()->create_default_object();
2489
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2490
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2491
+		// primary registration object (that way we know if we need to show create button or not)
2492
+		if (! $this->_registration->is_primary_registrant()) {
2493
+			$primary_registration = $this->_registration->get_primary_registration();
2494
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2495
+				: null;
2496
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2497
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2498
+				// custom attendee object so let's not worry about the primary reg.
2499
+				$primary_registration = null;
2500
+			}
2501
+		} else {
2502
+			$primary_registration = null;
2503
+		}
2504
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2505
+		$this->_template_args['fname']             = $attendee->fname();
2506
+		$this->_template_args['lname']             = $attendee->lname();
2507
+		$this->_template_args['email']             = $attendee->email();
2508
+		$this->_template_args['phone']             = $attendee->phone();
2509
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2510
+		// edit link
2511
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2512
+			[
2513
+				'action' => 'edit_attendee',
2514
+				'post'   => $attendee->ID(),
2515
+			],
2516
+			REG_ADMIN_URL
2517
+		);
2518
+		$this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2519
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2520
+		// create link
2521
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2522
+			? EE_Admin_Page::add_query_args_and_nonce(
2523
+				[
2524
+					'action'  => 'duplicate_attendee',
2525
+					'_REG_ID' => $this->_registration->ID(),
2526
+				],
2527
+				REG_ADMIN_URL
2528
+			) : '';
2529
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2530
+		$this->_template_args['att_check'] = $att_check;
2531
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2532
+		EEH_Template::display_template($template_path, $this->_template_args);
2533
+	}
2534
+
2535
+
2536
+	/**
2537
+	 * trash or restore registrations
2538
+	 *
2539
+	 * @param boolean $trash whether to archive or restore
2540
+	 * @return void
2541
+	 * @throws EE_Error
2542
+	 * @throws InvalidArgumentException
2543
+	 * @throws InvalidDataTypeException
2544
+	 * @throws InvalidInterfaceException
2545
+	 * @throws RuntimeException
2546
+	 */
2547
+	protected function _trash_or_restore_registrations($trash = true)
2548
+	{
2549
+		// if empty _REG_ID then get out because there's nothing to do
2550
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2551
+		if (empty($REG_IDs)) {
2552
+			EE_Error::add_error(
2553
+				sprintf(
2554
+					esc_html__(
2555
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2556
+						'event_espresso'
2557
+					),
2558
+					$trash ? 'trash' : 'restore'
2559
+				),
2560
+				__FILE__,
2561
+				__LINE__,
2562
+				__FUNCTION__
2563
+			);
2564
+			$this->_redirect_after_action(false, '', '', [], true);
2565
+		}
2566
+		$success        = 0;
2567
+		$overwrite_msgs = false;
2568
+		// Checkboxes
2569
+		$reg_count = count($REG_IDs);
2570
+		// cycle thru checkboxes
2571
+		foreach ($REG_IDs as $REG_ID) {
2572
+			/** @var EE_Registration $REG */
2573
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2574
+			$payments = $REG->registration_payments();
2575
+			if (! empty($payments)) {
2576
+				$name           = $REG->attendee() instanceof EE_Attendee
2577
+					? $REG->attendee()->full_name()
2578
+					: esc_html__('Unknown Attendee', 'event_espresso');
2579
+				$overwrite_msgs = true;
2580
+				EE_Error::add_error(
2581
+					sprintf(
2582
+						esc_html__(
2583
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2584
+							'event_espresso'
2585
+						),
2586
+						$name
2587
+					),
2588
+					__FILE__,
2589
+					__FUNCTION__,
2590
+					__LINE__
2591
+				);
2592
+				// can't trash this registration because it has payments.
2593
+				continue;
2594
+			}
2595
+			$updated = $trash ? $REG->delete() : $REG->restore();
2596
+			if ($updated) {
2597
+				$success++;
2598
+			}
2599
+		}
2600
+		$this->_redirect_after_action(
2601
+			$success === $reg_count, // were ALL registrations affected?
2602
+			$success > 1
2603
+				? esc_html__('Registrations', 'event_espresso')
2604
+				: esc_html__('Registration', 'event_espresso'),
2605
+			$trash
2606
+				? esc_html__('moved to the trash', 'event_espresso')
2607
+				: esc_html__('restored', 'event_espresso'),
2608
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2609
+			$overwrite_msgs
2610
+		);
2611
+	}
2612
+
2613
+
2614
+	/**
2615
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2616
+	 * registration but also.
2617
+	 * 1. Removing relations to EE_Attendee
2618
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2619
+	 * ALSO trashed.
2620
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2621
+	 * 4. Removing relationships between all tickets and the related registrations
2622
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2623
+	 * 6. Deleting permanently any related Checkins.
2624
+	 *
2625
+	 * @return void
2626
+	 * @throws EE_Error
2627
+	 * @throws InvalidArgumentException
2628
+	 * @throws InvalidDataTypeException
2629
+	 * @throws InvalidInterfaceException
2630
+	 * @throws ReflectionException
2631
+	 */
2632
+	protected function _delete_registrations()
2633
+	{
2634
+		$REG_MDL = $this->getRegistrationModel();
2635
+		$success = 0;
2636
+		// Checkboxes
2637
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2638
+
2639
+		if (! empty($REG_IDs)) {
2640
+			// if array has more than one element than success message should be plural
2641
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2642
+			// cycle thru checkboxes
2643
+			foreach ($REG_IDs as $REG_ID) {
2644
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2645
+				if (! $REG instanceof EE_Registration) {
2646
+					continue;
2647
+				}
2648
+				$deleted = $this->_delete_registration($REG);
2649
+				if (! $deleted) {
2650
+					$success = 0;
2651
+				}
2652
+			}
2653
+		}
2654
+
2655
+		$what        = $success > 1
2656
+			? esc_html__('Registrations', 'event_espresso')
2657
+			: esc_html__('Registration', 'event_espresso');
2658
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2659
+		$this->_redirect_after_action(
2660
+			$success,
2661
+			$what,
2662
+			$action_desc,
2663
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2664
+			true
2665
+		);
2666
+	}
2667
+
2668
+
2669
+	/**
2670
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2671
+	 * models get affected.
2672
+	 *
2673
+	 * @param EE_Registration $REG registration to be deleted permanently
2674
+	 * @return bool true = successful deletion, false = fail.
2675
+	 * @throws EE_Error
2676
+	 * @throws InvalidArgumentException
2677
+	 * @throws InvalidDataTypeException
2678
+	 * @throws InvalidInterfaceException
2679
+	 * @throws ReflectionException
2680
+	 */
2681
+	protected function _delete_registration(EE_Registration $REG)
2682
+	{
2683
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2684
+		// registrations on the transaction that are NOT trashed.
2685
+		$TXN = $REG->get_first_related('Transaction');
2686
+		if (! $TXN instanceof EE_Transaction) {
2687
+			EE_Error::add_error(
2688
+				sprintf(
2689
+					esc_html__(
2690
+						'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2691
+						'event_espresso'
2692
+					),
2693
+					$REG->id()
2694
+				),
2695
+				__FILE__,
2696
+				__FUNCTION__,
2697
+				__LINE__
2698
+			);
2699
+			return false;
2700
+		}
2701
+		$REGS        = $TXN->get_many_related('Registration');
2702
+		$all_trashed = true;
2703
+		foreach ($REGS as $registration) {
2704
+			if (! $registration->get('REG_deleted')) {
2705
+				$all_trashed = false;
2706
+			}
2707
+		}
2708
+		if (! $all_trashed) {
2709
+			EE_Error::add_error(
2710
+				esc_html__(
2711
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2712
+					'event_espresso'
2713
+				),
2714
+				__FILE__,
2715
+				__FUNCTION__,
2716
+				__LINE__
2717
+			);
2718
+			return false;
2719
+		}
2720
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2721
+		// separately from THIS one).
2722
+		foreach ($REGS as $registration) {
2723
+			// delete related answers
2724
+			$registration->delete_related_permanently('Answer');
2725
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2726
+			$attendee = $registration->get_first_related('Attendee');
2727
+			if ($attendee instanceof EE_Attendee) {
2728
+				$registration->_remove_relation_to($attendee, 'Attendee');
2729
+			}
2730
+			// now remove relationships to tickets on this registration.
2731
+			$registration->_remove_relations('Ticket');
2732
+			// now delete permanently the checkins related to this registration.
2733
+			$registration->delete_related_permanently('Checkin');
2734
+			if ($registration->ID() === $REG->ID()) {
2735
+				continue;
2736
+			} //we don't want to delete permanently the existing registration just yet.
2737
+			// remove relation to transaction for these registrations if NOT the existing registrations
2738
+			$registration->_remove_relations('Transaction');
2739
+			// delete permanently any related messages.
2740
+			$registration->delete_related_permanently('Message');
2741
+			// now delete this registration permanently
2742
+			$registration->delete_permanently();
2743
+		}
2744
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2745
+		// (the transaction and line items should be all that's left).
2746
+		// delete the line items related to the transaction for this registration.
2747
+		$TXN->delete_related_permanently('Line_Item');
2748
+		// we need to remove all the relationships on the transaction
2749
+		$TXN->delete_related_permanently('Payment');
2750
+		$TXN->delete_related_permanently('Extra_Meta');
2751
+		$TXN->delete_related_permanently('Message');
2752
+		// now we can delete this REG permanently (and the transaction of course)
2753
+		$REG->delete_related_permanently('Transaction');
2754
+		return $REG->delete_permanently();
2755
+	}
2756
+
2757
+
2758
+	/**
2759
+	 *    generates HTML for the Register New Attendee Admin page
2760
+	 *
2761
+	 * @throws DomainException
2762
+	 * @throws EE_Error
2763
+	 * @throws InvalidArgumentException
2764
+	 * @throws InvalidDataTypeException
2765
+	 * @throws InvalidInterfaceException
2766
+	 * @throws ReflectionException
2767
+	 */
2768
+	public function new_registration()
2769
+	{
2770
+		if (! $this->_set_reg_event()) {
2771
+			throw new EE_Error(
2772
+				esc_html__(
2773
+					'Unable to continue with registering because there is no Event ID in the request',
2774
+					'event_espresso'
2775
+				)
2776
+			);
2777
+		}
2778
+		/** @var CurrentPage $current_page */
2779
+		$current_page = $this->loader->getShared(CurrentPage::class);
2780
+		$current_page->setEspressoPage(true);
2781
+		// gotta start with a clean slate if we're not coming here via ajax
2782
+		if (
2783
+			! $this->request->isAjax()
2784
+			&& (
2785
+				! $this->request->requestParamIsSet('processing_registration')
2786
+				|| $this->request->requestParamIsSet('step_error')
2787
+			)
2788
+		) {
2789
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2790
+		}
2791
+		$this->_template_args['event_name'] = '';
2792
+		// event name
2793
+		if ($this->_reg_event) {
2794
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2795
+			$edit_event_url                     = self::add_query_args_and_nonce(
2796
+				[
2797
+					'action' => 'edit',
2798
+					'post'   => $this->_reg_event->ID(),
2799
+				],
2800
+				EVENTS_ADMIN_URL
2801
+			);
2802
+			$edit_event_lnk                     = '<a href="'
2803
+												  . $edit_event_url
2804
+												  . '" title="'
2805
+												  . esc_attr__('Edit ', 'event_espresso')
2806
+												  . $this->_reg_event->name()
2807
+												  . '">'
2808
+												  . esc_html__('Edit Event', 'event_espresso')
2809
+												  . '</a>';
2810
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2811
+												   . $edit_event_lnk
2812
+												   . '</span>';
2813
+		}
2814
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2815
+		if ($this->request->isAjax()) {
2816
+			$this->_return_json();
2817
+		}
2818
+		// grab header
2819
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2820
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2821
+			$template_path,
2822
+			$this->_template_args,
2823
+			true
2824
+		);
2825
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2826
+		// the details template wrapper
2827
+		$this->display_admin_page_with_sidebar();
2828
+	}
2829
+
2830
+
2831
+	/**
2832
+	 * This returns the content for a registration step
2833
+	 *
2834
+	 * @return string html
2835
+	 * @throws DomainException
2836
+	 * @throws EE_Error
2837
+	 * @throws InvalidArgumentException
2838
+	 * @throws InvalidDataTypeException
2839
+	 * @throws InvalidInterfaceException
2840
+	 * @throws ReflectionException
2841
+	 */
2842
+	protected function _get_registration_step_content()
2843
+	{
2844
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2845
+			$warning_msg = sprintf(
2846
+				esc_html__(
2847
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2848
+					'event_espresso'
2849
+				),
2850
+				'<br />',
2851
+				'<h3 class="important-notice">',
2852
+				'</h3>',
2853
+				'<div class="float-right">',
2854
+				'<span id="redirect_timer" class="important-notice">30</span>',
2855
+				'</div>',
2856
+				'<b>',
2857
+				'</b>'
2858
+			);
2859
+			return '
2860 2860
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2861 2861
 	<script >
2862 2862
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2869,841 +2869,841 @@  discard block
 block discarded – undo
2869 2869
 	        }
2870 2870
 	    }, 800 );
2871 2871
 	</script >';
2872
-        }
2873
-        $template_args = [
2874
-            'title'                    => '',
2875
-            'content'                  => '',
2876
-            'step_button_text'         => '',
2877
-            'show_notification_toggle' => false,
2878
-        ];
2879
-        // to indicate we're processing a new registration
2880
-        $hidden_fields = [
2881
-            'processing_registration' => [
2882
-                'type'  => 'hidden',
2883
-                'value' => 0,
2884
-            ],
2885
-            'event_id'                => [
2886
-                'type'  => 'hidden',
2887
-                'value' => $this->_reg_event->ID(),
2888
-            ],
2889
-        ];
2890
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2891
-        $cart = EE_Registry::instance()->SSN->cart();
2892
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2893
-        switch ($step) {
2894
-            case 'ticket':
2895
-                $hidden_fields['processing_registration']['value'] = 1;
2896
-                $template_args['title']                            = esc_html__(
2897
-                    'Step One: Select the Ticket for this registration',
2898
-                    'event_espresso'
2899
-                );
2900
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2901
-                $template_args['content'] .= '</div>';
2902
-                $template_args['step_button_text'] = esc_html__(
2903
-                    'Add Tickets and Continue to Registrant Details',
2904
-                    'event_espresso'
2905
-                );
2906
-                $template_args['show_notification_toggle']         = false;
2907
-                break;
2908
-            case 'questions':
2909
-                $hidden_fields['processing_registration']['value'] = 2;
2910
-                $template_args['title']                            = esc_html__(
2911
-                    'Step Two: Add Registrant Details for this Registration',
2912
-                    'event_espresso'
2913
-                );
2914
-                // in theory, we should be able to run EED_SPCO at this point
2915
-                // because the cart should have been set up properly by the first process_reg_step run.
2916
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2917
-                $template_args['step_button_text'] = esc_html__(
2918
-                    'Save Registration and Continue to Details',
2919
-                    'event_espresso'
2920
-                );
2921
-                $template_args['show_notification_toggle'] = true;
2922
-                break;
2923
-        }
2924
-        // we come back to the process_registration_step route.
2925
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2926
-        return EEH_Template::display_template(
2927
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2928
-            $template_args,
2929
-            true
2930
-        );
2931
-    }
2932
-
2933
-
2934
-    /**
2935
-     * set_reg_event
2936
-     *
2937
-     * @return bool
2938
-     * @throws EE_Error
2939
-     * @throws InvalidArgumentException
2940
-     * @throws InvalidDataTypeException
2941
-     * @throws InvalidInterfaceException
2942
-     */
2943
-    private function _set_reg_event()
2944
-    {
2945
-        if (is_object($this->_reg_event)) {
2946
-            return true;
2947
-        }
2948
-
2949
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2950
-        if (! $EVT_ID) {
2951
-            return false;
2952
-        }
2953
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2954
-        return true;
2955
-    }
2956
-
2957
-
2958
-    /**
2959
-     * process_reg_step
2960
-     *
2961
-     * @return void
2962
-     * @throws DomainException
2963
-     * @throws EE_Error
2964
-     * @throws InvalidArgumentException
2965
-     * @throws InvalidDataTypeException
2966
-     * @throws InvalidInterfaceException
2967
-     * @throws ReflectionException
2968
-     * @throws RuntimeException
2969
-     */
2970
-    public function process_reg_step()
2971
-    {
2972
-        EE_System::do_not_cache();
2973
-        $this->_set_reg_event();
2974
-        /** @var CurrentPage $current_page */
2975
-        $current_page = $this->loader->getShared(CurrentPage::class);
2976
-        $current_page->setEspressoPage(true);
2977
-        $this->request->setRequestParam('uts', time());
2978
-        // what step are we on?
2979
-        $cart = EE_Registry::instance()->SSN->cart();
2980
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2981
-        // if doing ajax then we need to verify the nonce
2982
-        if ($this->request->isAjax()) {
2983
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
2984
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2985
-        }
2986
-        switch ($step) {
2987
-            case 'ticket':
2988
-                // process ticket selection
2989
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
2990
-                if ($success) {
2991
-                    EE_Error::add_success(
2992
-                        esc_html__(
2993
-                            'Tickets Selected. Now complete the registration.',
2994
-                            'event_espresso'
2995
-                        )
2996
-                    );
2997
-                } else {
2998
-                    $this->request->setRequestParam('step_error', true);
2999
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3000
-                }
3001
-                if ($this->request->isAjax()) {
3002
-                    $this->new_registration(); // display next step
3003
-                } else {
3004
-                    $query_args = [
3005
-                        'action'                  => 'new_registration',
3006
-                        'processing_registration' => 1,
3007
-                        'event_id'                => $this->_reg_event->ID(),
3008
-                        'uts'                     => time(),
3009
-                    ];
3010
-                    $this->_redirect_after_action(
3011
-                        false,
3012
-                        '',
3013
-                        '',
3014
-                        $query_args,
3015
-                        true
3016
-                    );
3017
-                }
3018
-                break;
3019
-            case 'questions':
3020
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3021
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3022
-                }
3023
-                // process registration
3024
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3025
-                if ($cart instanceof EE_Cart) {
3026
-                    $grand_total = $cart->get_grand_total();
3027
-                    if ($grand_total instanceof EE_Line_Item) {
3028
-                        $grand_total->save_this_and_descendants_to_txn();
3029
-                    }
3030
-                }
3031
-                if (! $transaction instanceof EE_Transaction) {
3032
-                    $query_args = [
3033
-                        'action'                  => 'new_registration',
3034
-                        'processing_registration' => 2,
3035
-                        'event_id'                => $this->_reg_event->ID(),
3036
-                        'uts'                     => time(),
3037
-                    ];
3038
-                    if ($this->request->isAjax()) {
3039
-                        // display registration form again because there are errors (maybe validation?)
3040
-                        $this->new_registration();
3041
-                        return;
3042
-                    }
3043
-                    $this->_redirect_after_action(
3044
-                        false,
3045
-                        '',
3046
-                        '',
3047
-                        $query_args,
3048
-                        true
3049
-                    );
3050
-                    return;
3051
-                }
3052
-                // maybe update status, and make sure to save transaction if not done already
3053
-                if (! $transaction->update_status_based_on_total_paid()) {
3054
-                    $transaction->save();
3055
-                }
3056
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3057
-                $query_args = [
3058
-                    'action'        => 'redirect_to_txn',
3059
-                    'TXN_ID'        => $transaction->ID(),
3060
-                    'EVT_ID'        => $this->_reg_event->ID(),
3061
-                    'event_name'    => urlencode($this->_reg_event->name()),
3062
-                    'redirect_from' => 'new_registration',
3063
-                ];
3064
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3065
-                break;
3066
-        }
3067
-        // what are you looking here for?  Should be nothing to do at this point.
3068
-    }
3069
-
3070
-
3071
-    /**
3072
-     * redirect_to_txn
3073
-     *
3074
-     * @return void
3075
-     * @throws EE_Error
3076
-     * @throws InvalidArgumentException
3077
-     * @throws InvalidDataTypeException
3078
-     * @throws InvalidInterfaceException
3079
-     * @throws ReflectionException
3080
-     */
3081
-    public function redirect_to_txn()
3082
-    {
3083
-        EE_System::do_not_cache();
3084
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3085
-        $query_args = [
3086
-            'action' => 'view_transaction',
3087
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3088
-            'page'   => 'espresso_transactions',
3089
-        ];
3090
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3091
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3092
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3093
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3094
-        }
3095
-        EE_Error::add_success(
3096
-            esc_html__(
3097
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3098
-                'event_espresso'
3099
-            )
3100
-        );
3101
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3102
-    }
3103
-
3104
-
3105
-    /**
3106
-     * generates HTML for the Attendee Contact List
3107
-     *
3108
-     * @return void
3109
-     * @throws DomainException
3110
-     * @throws EE_Error
3111
-     */
3112
-    protected function _attendee_contact_list_table()
3113
-    {
3114
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3115
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3116
-        $this->display_admin_list_table_page_with_no_sidebar();
3117
-    }
3118
-
3119
-
3120
-    /**
3121
-     * get_attendees
3122
-     *
3123
-     * @param      $per_page
3124
-     * @param bool $count whether to return count or data.
3125
-     * @param bool $trash
3126
-     * @return array|int
3127
-     * @throws EE_Error
3128
-     * @throws InvalidArgumentException
3129
-     * @throws InvalidDataTypeException
3130
-     * @throws InvalidInterfaceException
3131
-     */
3132
-    public function get_attendees($per_page, $count = false, $trash = false)
3133
-    {
3134
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3135
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3136
-        $orderby = $this->request->getRequestParam('orderby');
3137
-        switch ($orderby) {
3138
-            case 'ATT_ID':
3139
-            case 'ATT_fname':
3140
-            case 'ATT_email':
3141
-            case 'ATT_city':
3142
-            case 'STA_ID':
3143
-            case 'CNT_ID':
3144
-                break;
3145
-            case 'Registration_Count':
3146
-                $orderby = 'Registration_Count';
3147
-                break;
3148
-            default:
3149
-                $orderby = 'ATT_lname';
3150
-        }
3151
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3152
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3153
-        $per_page     = absint($per_page) ? $per_page : 10;
3154
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3155
-        $_where       = [];
3156
-        $search_term  = $this->request->getRequestParam('s');
3157
-        if ($search_term) {
3158
-            $search_term  = '%' . $search_term . '%';
3159
-            $_where['OR'] = [
3160
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3161
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3162
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3163
-                'ATT_fname'                         => ['LIKE', $search_term],
3164
-                'ATT_lname'                         => ['LIKE', $search_term],
3165
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3166
-                'ATT_email'                         => ['LIKE', $search_term],
3167
-                'ATT_address'                       => ['LIKE', $search_term],
3168
-                'ATT_address2'                      => ['LIKE', $search_term],
3169
-                'ATT_city'                          => ['LIKE', $search_term],
3170
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3171
-                'State.STA_name'                    => ['LIKE', $search_term],
3172
-                'ATT_phone'                         => ['LIKE', $search_term],
3173
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3174
-                'Registration.REG_code'             => ['LIKE', $search_term],
3175
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3176
-            ];
3177
-        }
3178
-        $offset     = ($current_page - 1) * $per_page;
3179
-        $limit      = $count ? null : [$offset, $per_page];
3180
-        $query_args = [
3181
-            $_where,
3182
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3183
-            'limit'         => $limit,
3184
-        ];
3185
-        if (! $count) {
3186
-            $query_args['order_by'] = [$orderby => $sort];
3187
-        }
3188
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3189
-        return $count
3190
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3191
-            : $this->getAttendeeModel()->get_all($query_args);
3192
-    }
3193
-
3194
-
3195
-    /**
3196
-     * This is just taking care of resending the registration confirmation
3197
-     *
3198
-     * @return void
3199
-     * @throws EE_Error
3200
-     * @throws InvalidArgumentException
3201
-     * @throws InvalidDataTypeException
3202
-     * @throws InvalidInterfaceException
3203
-     * @throws ReflectionException
3204
-     */
3205
-    protected function _resend_registration()
3206
-    {
3207
-        $this->_process_resend_registration();
3208
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3209
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3210
-        $query_args  = $redirect_to
3211
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3212
-            : ['action' => 'default'];
3213
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3214
-    }
3215
-
3216
-
3217
-    /**
3218
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3219
-     * to use when selecting registrations
3220
-     *
3221
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3222
-     *                                                     the query parameters from the request
3223
-     * @return void ends the request with a redirect or download
3224
-     */
3225
-    public function _registrations_report_base($method_name_for_getting_query_params)
3226
-    {
3227
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3228
-            ? $this->request->getRequestParam('EVT_ID', 0, DataType::INT)
3229
-            : null;
3230
-
3231
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3232
-            $return_url = $this->request->getRequestParam('return_url', '', DataType::URL);
3233
-            $filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3234
-            $use_filters = $this->request->getRequestParam('use_filters', false, DataType::BOOL);
3235
-            wp_redirect(
3236
-                EE_Admin_Page::add_query_args_and_nonce(
3237
-                    [
3238
-                        'page'        => EED_Batch::PAGE_SLUG,
3239
-                        'batch'       => EED_Batch::batch_file_job,
3240
-                        'EVT_ID'      => $EVT_ID,
3241
-                        'filters'     => urlencode(serialize($this->$method_name_for_getting_query_params($filters))),
3242
-                        'use_filters' => urlencode($use_filters),
3243
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3244
-                        'return_url'  => urlencode($return_url),
3245
-                    ]
3246
-                )
3247
-            );
3248
-        } else {
3249
-            // Pull the current request params
3250
-            $request_args = $this->request->requestParams();
3251
-            // Set the required request_args to be passed to the export
3252
-            $required_request_args = [
3253
-                'export' => 'report',
3254
-                'action' => 'registrations_report_for_event',
3255
-                'EVT_ID' => $EVT_ID,
3256
-            ];
3257
-            // Merge required request args, overriding any currently set
3258
-            $request_args = array_merge($request_args, $required_request_args);
3259
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3260
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3261
-                $EE_Export = EE_Export::instance($request_args);
3262
-                $EE_Export->export();
3263
-            }
3264
-        }
3265
-    }
3266
-
3267
-
3268
-    /**
3269
-     * Creates a registration report using only query parameters in the request
3270
-     *
3271
-     * @return void
3272
-     */
3273
-    public function _registrations_report()
3274
-    {
3275
-        $this->_registrations_report_base('_get_registration_query_parameters');
3276
-    }
3277
-
3278
-
3279
-    public function _contact_list_export()
3280
-    {
3281
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3282
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3283
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3284
-            $EE_Export->export_attendees();
3285
-        }
3286
-    }
3287
-
3288
-
3289
-    public function _contact_list_report()
3290
-    {
3291
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3292
-            wp_redirect(
3293
-                EE_Admin_Page::add_query_args_and_nonce(
3294
-                    [
3295
-                        'page'        => EED_Batch::PAGE_SLUG,
3296
-                        'batch'       => EED_Batch::batch_file_job,
3297
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3298
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3299
-                    ]
3300
-                )
3301
-            );
3302
-        } else {
3303
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3304
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3305
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3306
-                $EE_Export->report_attendees();
3307
-            }
3308
-        }
3309
-    }
3310
-
3311
-
3312
-
3313
-
3314
-
3315
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3316
-    /**
3317
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3318
-     *
3319
-     * @return void
3320
-     * @throws EE_Error
3321
-     * @throws InvalidArgumentException
3322
-     * @throws InvalidDataTypeException
3323
-     * @throws InvalidInterfaceException
3324
-     * @throws ReflectionException
3325
-     */
3326
-    protected function _duplicate_attendee()
3327
-    {
3328
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3329
-        $action = $this->request->getRequestParam('return', 'default');
3330
-        // verify we have necessary info
3331
-        if (! $REG_ID) {
3332
-            EE_Error::add_error(
3333
-                esc_html__(
3334
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3335
-                    'event_espresso'
3336
-                ),
3337
-                __FILE__,
3338
-                __LINE__,
3339
-                __FUNCTION__
3340
-            );
3341
-            $query_args = ['action' => $action];
3342
-            $this->_redirect_after_action('', '', '', $query_args, true);
3343
-        }
3344
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3345
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3346
-        if (! $registration instanceof EE_Registration) {
3347
-            throw new RuntimeException(
3348
-                sprintf(
3349
-                    esc_html__(
3350
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3351
-                        'event_espresso'
3352
-                    ),
3353
-                    $REG_ID
3354
-                )
3355
-            );
3356
-        }
3357
-        $attendee = $registration->attendee();
3358
-        // remove relation of existing attendee on registration
3359
-        $registration->_remove_relation_to($attendee, 'Attendee');
3360
-        // new attendee
3361
-        $new_attendee = clone $attendee;
3362
-        $new_attendee->set('ATT_ID', 0);
3363
-        $new_attendee->save();
3364
-        // add new attendee to reg
3365
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3366
-        EE_Error::add_success(
3367
-            esc_html__(
3368
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3369
-                'event_espresso'
3370
-            )
3371
-        );
3372
-        // redirect to edit page for attendee
3373
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3374
-        $this->_redirect_after_action('', '', '', $query_args, true);
3375
-    }
3376
-
3377
-
3378
-    /**
3379
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3380
-     *
3381
-     * @param int     $post_id
3382
-     * @param WP_Post $post
3383
-     * @throws DomainException
3384
-     * @throws EE_Error
3385
-     * @throws InvalidArgumentException
3386
-     * @throws InvalidDataTypeException
3387
-     * @throws InvalidInterfaceException
3388
-     * @throws LogicException
3389
-     * @throws InvalidFormSubmissionException
3390
-     * @throws ReflectionException
3391
-     */
3392
-    protected function _insert_update_cpt_item($post_id, $post)
3393
-    {
3394
-        $success  = true;
3395
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3396
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3397
-            : null;
3398
-        // for attendee updates
3399
-        if ($attendee instanceof EE_Attendee) {
3400
-            // note we should only be UPDATING attendees at this point.
3401
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3402
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3403
-            $updated_fields = [
3404
-                'ATT_fname'     => $fname,
3405
-                'ATT_lname'     => $lname,
3406
-                'ATT_full_name' => "{$fname} {$lname}",
3407
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3408
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3409
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3410
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3411
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3412
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3413
-            ];
3414
-            foreach ($updated_fields as $field => $value) {
3415
-                $attendee->set($field, $value);
3416
-            }
3417
-
3418
-            // process contact details metabox form handler (which will also save the attendee)
3419
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3420
-            $success              = $contact_details_form->process($this->request->requestParams());
3421
-
3422
-            $attendee_update_callbacks = apply_filters(
3423
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3424
-                []
3425
-            );
3426
-            foreach ($attendee_update_callbacks as $a_callback) {
3427
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3428
-                    throw new EE_Error(
3429
-                        sprintf(
3430
-                            esc_html__(
3431
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3432
-                                'event_espresso'
3433
-                            ),
3434
-                            $a_callback
3435
-                        )
3436
-                    );
3437
-                }
3438
-            }
3439
-        }
3440
-
3441
-        if ($success === false) {
3442
-            EE_Error::add_error(
3443
-                esc_html__(
3444
-                    'Something went wrong with updating the meta table data for the registration.',
3445
-                    'event_espresso'
3446
-                ),
3447
-                __FILE__,
3448
-                __FUNCTION__,
3449
-                __LINE__
3450
-            );
3451
-        }
3452
-    }
3453
-
3454
-
3455
-    public function trash_cpt_item($post_id)
3456
-    {
3457
-    }
3458
-
3459
-
3460
-    public function delete_cpt_item($post_id)
3461
-    {
3462
-    }
3463
-
3464
-
3465
-    public function restore_cpt_item($post_id)
3466
-    {
3467
-    }
3468
-
3469
-
3470
-    protected function _restore_cpt_item($post_id, $revision_id)
3471
-    {
3472
-    }
3473
-
3474
-
3475
-    /**
3476
-     * @throws EE_Error
3477
-     * @throws ReflectionException
3478
-     * @since 4.10.2.p
3479
-     */
3480
-    public function attendee_editor_metaboxes()
3481
-    {
3482
-        $this->verify_cpt_object();
3483
-        remove_meta_box(
3484
-            'postexcerpt',
3485
-            $this->_cpt_routes[ $this->_req_action ],
3486
-            'normal'
3487
-        );
3488
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3489
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3490
-            $this->addMetaBox(
3491
-                'postexcerpt',
3492
-                esc_html__('Short Biography', 'event_espresso'),
3493
-                'post_excerpt_meta_box',
3494
-                $this->_cpt_routes[ $this->_req_action ]
3495
-            );
3496
-        }
3497
-        if (post_type_supports('espresso_attendees', 'comments')) {
3498
-            $this->addMetaBox(
3499
-                'commentsdiv',
3500
-                esc_html__('Notes on the Contact', 'event_espresso'),
3501
-                'post_comment_meta_box',
3502
-                $this->_cpt_routes[ $this->_req_action ],
3503
-                'normal',
3504
-                'core'
3505
-            );
3506
-        }
3507
-        $this->addMetaBox(
3508
-            'attendee_contact_info',
3509
-            esc_html__('Contact Info', 'event_espresso'),
3510
-            [$this, 'attendee_contact_info'],
3511
-            $this->_cpt_routes[ $this->_req_action ],
3512
-            'side',
3513
-            'core'
3514
-        );
3515
-        $this->addMetaBox(
3516
-            'attendee_details_address',
3517
-            esc_html__('Address Details', 'event_espresso'),
3518
-            [$this, 'attendee_address_details'],
3519
-            $this->_cpt_routes[ $this->_req_action ],
3520
-            'normal',
3521
-            'core'
3522
-        );
3523
-        $this->addMetaBox(
3524
-            'attendee_registrations',
3525
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3526
-            [$this, 'attendee_registrations_meta_box'],
3527
-            $this->_cpt_routes[ $this->_req_action ]
3528
-        );
3529
-    }
3530
-
3531
-
3532
-    /**
3533
-     * Metabox for attendee contact info
3534
-     *
3535
-     * @param WP_Post $post wp post object
3536
-     * @return void attendee contact info ( and form )
3537
-     * @throws EE_Error
3538
-     * @throws InvalidArgumentException
3539
-     * @throws InvalidDataTypeException
3540
-     * @throws InvalidInterfaceException
3541
-     * @throws LogicException
3542
-     * @throws DomainException
3543
-     */
3544
-    public function attendee_contact_info($post)
3545
-    {
3546
-        // get attendee object ( should already have it )
3547
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3548
-        $form->enqueueStylesAndScripts();
3549
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3550
-    }
3551
-
3552
-
3553
-    /**
3554
-     * Return form handler for the contact details metabox
3555
-     *
3556
-     * @param EE_Attendee $attendee
3557
-     * @return AttendeeContactDetailsMetaboxFormHandler
3558
-     * @throws DomainException
3559
-     * @throws InvalidArgumentException
3560
-     * @throws InvalidDataTypeException
3561
-     * @throws InvalidInterfaceException
3562
-     */
3563
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3564
-    {
3565
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3566
-    }
3567
-
3568
-
3569
-    /**
3570
-     * Metabox for attendee details
3571
-     *
3572
-     * @param WP_Post $post wp post object
3573
-     * @throws EE_Error
3574
-     * @throws ReflectionException
3575
-     */
3576
-    public function attendee_address_details($post)
3577
-    {
3578
-        // get attendee object (should already have it)
3579
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3580
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3581
-            new EE_Question_Form_Input(
3582
-                EE_Question::new_instance(
3583
-                    [
3584
-                        'QST_ID'           => 0,
3585
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3586
-                        'QST_system'       => 'admin-state',
3587
-                    ]
3588
-                ),
3589
-                EE_Answer::new_instance(
3590
-                    [
3591
-                        'ANS_ID'    => 0,
3592
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3593
-                    ]
3594
-                ),
3595
-                [
3596
-                    'input_id'       => 'STA_ID',
3597
-                    'input_name'     => 'STA_ID',
3598
-                    'input_prefix'   => '',
3599
-                    'append_qstn_id' => false,
3600
-                ]
3601
-            )
3602
-        );
3603
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3604
-            new EE_Question_Form_Input(
3605
-                EE_Question::new_instance(
3606
-                    [
3607
-                        'QST_ID'           => 0,
3608
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3609
-                        'QST_system'       => 'admin-country',
3610
-                    ]
3611
-                ),
3612
-                EE_Answer::new_instance(
3613
-                    [
3614
-                        'ANS_ID'    => 0,
3615
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3616
-                    ]
3617
-                ),
3618
-                [
3619
-                    'input_id'       => 'CNT_ISO',
3620
-                    'input_name'     => 'CNT_ISO',
3621
-                    'input_prefix'   => '',
3622
-                    'append_qstn_id' => false,
3623
-                ]
3624
-            )
3625
-        );
3626
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3627
-        EEH_Template::display_template($template, $this->_template_args);
3628
-    }
3629
-
3630
-
3631
-    /**
3632
-     * _attendee_details
3633
-     *
3634
-     * @param $post
3635
-     * @return void
3636
-     * @throws DomainException
3637
-     * @throws EE_Error
3638
-     * @throws InvalidArgumentException
3639
-     * @throws InvalidDataTypeException
3640
-     * @throws InvalidInterfaceException
3641
-     * @throws ReflectionException
3642
-     */
3643
-    public function attendee_registrations_meta_box($post)
3644
-    {
3645
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3646
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3647
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3648
-        EEH_Template::display_template($template, $this->_template_args);
3649
-    }
3650
-
3651
-
3652
-    /**
3653
-     * add in the form fields for the attendee edit
3654
-     *
3655
-     * @param WP_Post $post wp post object
3656
-     * @return void echos html for new form.
3657
-     * @throws DomainException
3658
-     */
3659
-    public function after_title_form_fields($post)
3660
-    {
3661
-        if ($post->post_type === 'espresso_attendees') {
3662
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3663
-            $template_args['attendee'] = $this->_cpt_model_obj;
3664
-            EEH_Template::display_template($template, $template_args);
3665
-        }
3666
-    }
3667
-
3668
-
3669
-    /**
3670
-     * _trash_or_restore_attendee
3671
-     *
3672
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3673
-     * @return void
3674
-     * @throws EE_Error
3675
-     * @throws InvalidArgumentException
3676
-     * @throws InvalidDataTypeException
3677
-     * @throws InvalidInterfaceException
3678
-     */
3679
-    protected function _trash_or_restore_attendees($trash = true)
3680
-    {
3681
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3682
-        $status = $trash ? 'trash' : 'publish';
3683
-        // Checkboxes
3684
-        if ($this->request->requestParamIsSet('checkbox')) {
3685
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3686
-            // if array has more than one element than success message should be plural
3687
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3688
-            // cycle thru checkboxes
3689
-            foreach ($ATT_IDs as $ATT_ID) {
3690
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3691
-                if (! $updated) {
3692
-                    $success = 0;
3693
-                }
3694
-            }
3695
-        } else {
3696
-            // grab single id and delete
3697
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3698
-            // update attendee
3699
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3700
-        }
3701
-        $what        = $success > 1
3702
-            ? esc_html__('Contacts', 'event_espresso')
3703
-            : esc_html__('Contact', 'event_espresso');
3704
-        $action_desc = $trash
3705
-            ? esc_html__('moved to the trash', 'event_espresso')
3706
-            : esc_html__('restored', 'event_espresso');
3707
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3708
-    }
2872
+		}
2873
+		$template_args = [
2874
+			'title'                    => '',
2875
+			'content'                  => '',
2876
+			'step_button_text'         => '',
2877
+			'show_notification_toggle' => false,
2878
+		];
2879
+		// to indicate we're processing a new registration
2880
+		$hidden_fields = [
2881
+			'processing_registration' => [
2882
+				'type'  => 'hidden',
2883
+				'value' => 0,
2884
+			],
2885
+			'event_id'                => [
2886
+				'type'  => 'hidden',
2887
+				'value' => $this->_reg_event->ID(),
2888
+			],
2889
+		];
2890
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2891
+		$cart = EE_Registry::instance()->SSN->cart();
2892
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2893
+		switch ($step) {
2894
+			case 'ticket':
2895
+				$hidden_fields['processing_registration']['value'] = 1;
2896
+				$template_args['title']                            = esc_html__(
2897
+					'Step One: Select the Ticket for this registration',
2898
+					'event_espresso'
2899
+				);
2900
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2901
+				$template_args['content'] .= '</div>';
2902
+				$template_args['step_button_text'] = esc_html__(
2903
+					'Add Tickets and Continue to Registrant Details',
2904
+					'event_espresso'
2905
+				);
2906
+				$template_args['show_notification_toggle']         = false;
2907
+				break;
2908
+			case 'questions':
2909
+				$hidden_fields['processing_registration']['value'] = 2;
2910
+				$template_args['title']                            = esc_html__(
2911
+					'Step Two: Add Registrant Details for this Registration',
2912
+					'event_espresso'
2913
+				);
2914
+				// in theory, we should be able to run EED_SPCO at this point
2915
+				// because the cart should have been set up properly by the first process_reg_step run.
2916
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2917
+				$template_args['step_button_text'] = esc_html__(
2918
+					'Save Registration and Continue to Details',
2919
+					'event_espresso'
2920
+				);
2921
+				$template_args['show_notification_toggle'] = true;
2922
+				break;
2923
+		}
2924
+		// we come back to the process_registration_step route.
2925
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2926
+		return EEH_Template::display_template(
2927
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2928
+			$template_args,
2929
+			true
2930
+		);
2931
+	}
2932
+
2933
+
2934
+	/**
2935
+	 * set_reg_event
2936
+	 *
2937
+	 * @return bool
2938
+	 * @throws EE_Error
2939
+	 * @throws InvalidArgumentException
2940
+	 * @throws InvalidDataTypeException
2941
+	 * @throws InvalidInterfaceException
2942
+	 */
2943
+	private function _set_reg_event()
2944
+	{
2945
+		if (is_object($this->_reg_event)) {
2946
+			return true;
2947
+		}
2948
+
2949
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2950
+		if (! $EVT_ID) {
2951
+			return false;
2952
+		}
2953
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2954
+		return true;
2955
+	}
2956
+
2957
+
2958
+	/**
2959
+	 * process_reg_step
2960
+	 *
2961
+	 * @return void
2962
+	 * @throws DomainException
2963
+	 * @throws EE_Error
2964
+	 * @throws InvalidArgumentException
2965
+	 * @throws InvalidDataTypeException
2966
+	 * @throws InvalidInterfaceException
2967
+	 * @throws ReflectionException
2968
+	 * @throws RuntimeException
2969
+	 */
2970
+	public function process_reg_step()
2971
+	{
2972
+		EE_System::do_not_cache();
2973
+		$this->_set_reg_event();
2974
+		/** @var CurrentPage $current_page */
2975
+		$current_page = $this->loader->getShared(CurrentPage::class);
2976
+		$current_page->setEspressoPage(true);
2977
+		$this->request->setRequestParam('uts', time());
2978
+		// what step are we on?
2979
+		$cart = EE_Registry::instance()->SSN->cart();
2980
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2981
+		// if doing ajax then we need to verify the nonce
2982
+		if ($this->request->isAjax()) {
2983
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
2984
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2985
+		}
2986
+		switch ($step) {
2987
+			case 'ticket':
2988
+				// process ticket selection
2989
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2990
+				if ($success) {
2991
+					EE_Error::add_success(
2992
+						esc_html__(
2993
+							'Tickets Selected. Now complete the registration.',
2994
+							'event_espresso'
2995
+						)
2996
+					);
2997
+				} else {
2998
+					$this->request->setRequestParam('step_error', true);
2999
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3000
+				}
3001
+				if ($this->request->isAjax()) {
3002
+					$this->new_registration(); // display next step
3003
+				} else {
3004
+					$query_args = [
3005
+						'action'                  => 'new_registration',
3006
+						'processing_registration' => 1,
3007
+						'event_id'                => $this->_reg_event->ID(),
3008
+						'uts'                     => time(),
3009
+					];
3010
+					$this->_redirect_after_action(
3011
+						false,
3012
+						'',
3013
+						'',
3014
+						$query_args,
3015
+						true
3016
+					);
3017
+				}
3018
+				break;
3019
+			case 'questions':
3020
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3021
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3022
+				}
3023
+				// process registration
3024
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3025
+				if ($cart instanceof EE_Cart) {
3026
+					$grand_total = $cart->get_grand_total();
3027
+					if ($grand_total instanceof EE_Line_Item) {
3028
+						$grand_total->save_this_and_descendants_to_txn();
3029
+					}
3030
+				}
3031
+				if (! $transaction instanceof EE_Transaction) {
3032
+					$query_args = [
3033
+						'action'                  => 'new_registration',
3034
+						'processing_registration' => 2,
3035
+						'event_id'                => $this->_reg_event->ID(),
3036
+						'uts'                     => time(),
3037
+					];
3038
+					if ($this->request->isAjax()) {
3039
+						// display registration form again because there are errors (maybe validation?)
3040
+						$this->new_registration();
3041
+						return;
3042
+					}
3043
+					$this->_redirect_after_action(
3044
+						false,
3045
+						'',
3046
+						'',
3047
+						$query_args,
3048
+						true
3049
+					);
3050
+					return;
3051
+				}
3052
+				// maybe update status, and make sure to save transaction if not done already
3053
+				if (! $transaction->update_status_based_on_total_paid()) {
3054
+					$transaction->save();
3055
+				}
3056
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3057
+				$query_args = [
3058
+					'action'        => 'redirect_to_txn',
3059
+					'TXN_ID'        => $transaction->ID(),
3060
+					'EVT_ID'        => $this->_reg_event->ID(),
3061
+					'event_name'    => urlencode($this->_reg_event->name()),
3062
+					'redirect_from' => 'new_registration',
3063
+				];
3064
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3065
+				break;
3066
+		}
3067
+		// what are you looking here for?  Should be nothing to do at this point.
3068
+	}
3069
+
3070
+
3071
+	/**
3072
+	 * redirect_to_txn
3073
+	 *
3074
+	 * @return void
3075
+	 * @throws EE_Error
3076
+	 * @throws InvalidArgumentException
3077
+	 * @throws InvalidDataTypeException
3078
+	 * @throws InvalidInterfaceException
3079
+	 * @throws ReflectionException
3080
+	 */
3081
+	public function redirect_to_txn()
3082
+	{
3083
+		EE_System::do_not_cache();
3084
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3085
+		$query_args = [
3086
+			'action' => 'view_transaction',
3087
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3088
+			'page'   => 'espresso_transactions',
3089
+		];
3090
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3091
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3092
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3093
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3094
+		}
3095
+		EE_Error::add_success(
3096
+			esc_html__(
3097
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3098
+				'event_espresso'
3099
+			)
3100
+		);
3101
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3102
+	}
3103
+
3104
+
3105
+	/**
3106
+	 * generates HTML for the Attendee Contact List
3107
+	 *
3108
+	 * @return void
3109
+	 * @throws DomainException
3110
+	 * @throws EE_Error
3111
+	 */
3112
+	protected function _attendee_contact_list_table()
3113
+	{
3114
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3115
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3116
+		$this->display_admin_list_table_page_with_no_sidebar();
3117
+	}
3118
+
3119
+
3120
+	/**
3121
+	 * get_attendees
3122
+	 *
3123
+	 * @param      $per_page
3124
+	 * @param bool $count whether to return count or data.
3125
+	 * @param bool $trash
3126
+	 * @return array|int
3127
+	 * @throws EE_Error
3128
+	 * @throws InvalidArgumentException
3129
+	 * @throws InvalidDataTypeException
3130
+	 * @throws InvalidInterfaceException
3131
+	 */
3132
+	public function get_attendees($per_page, $count = false, $trash = false)
3133
+	{
3134
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3135
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3136
+		$orderby = $this->request->getRequestParam('orderby');
3137
+		switch ($orderby) {
3138
+			case 'ATT_ID':
3139
+			case 'ATT_fname':
3140
+			case 'ATT_email':
3141
+			case 'ATT_city':
3142
+			case 'STA_ID':
3143
+			case 'CNT_ID':
3144
+				break;
3145
+			case 'Registration_Count':
3146
+				$orderby = 'Registration_Count';
3147
+				break;
3148
+			default:
3149
+				$orderby = 'ATT_lname';
3150
+		}
3151
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3152
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3153
+		$per_page     = absint($per_page) ? $per_page : 10;
3154
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3155
+		$_where       = [];
3156
+		$search_term  = $this->request->getRequestParam('s');
3157
+		if ($search_term) {
3158
+			$search_term  = '%' . $search_term . '%';
3159
+			$_where['OR'] = [
3160
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3161
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3162
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3163
+				'ATT_fname'                         => ['LIKE', $search_term],
3164
+				'ATT_lname'                         => ['LIKE', $search_term],
3165
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3166
+				'ATT_email'                         => ['LIKE', $search_term],
3167
+				'ATT_address'                       => ['LIKE', $search_term],
3168
+				'ATT_address2'                      => ['LIKE', $search_term],
3169
+				'ATT_city'                          => ['LIKE', $search_term],
3170
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3171
+				'State.STA_name'                    => ['LIKE', $search_term],
3172
+				'ATT_phone'                         => ['LIKE', $search_term],
3173
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3174
+				'Registration.REG_code'             => ['LIKE', $search_term],
3175
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3176
+			];
3177
+		}
3178
+		$offset     = ($current_page - 1) * $per_page;
3179
+		$limit      = $count ? null : [$offset, $per_page];
3180
+		$query_args = [
3181
+			$_where,
3182
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3183
+			'limit'         => $limit,
3184
+		];
3185
+		if (! $count) {
3186
+			$query_args['order_by'] = [$orderby => $sort];
3187
+		}
3188
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3189
+		return $count
3190
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3191
+			: $this->getAttendeeModel()->get_all($query_args);
3192
+	}
3193
+
3194
+
3195
+	/**
3196
+	 * This is just taking care of resending the registration confirmation
3197
+	 *
3198
+	 * @return void
3199
+	 * @throws EE_Error
3200
+	 * @throws InvalidArgumentException
3201
+	 * @throws InvalidDataTypeException
3202
+	 * @throws InvalidInterfaceException
3203
+	 * @throws ReflectionException
3204
+	 */
3205
+	protected function _resend_registration()
3206
+	{
3207
+		$this->_process_resend_registration();
3208
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3209
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3210
+		$query_args  = $redirect_to
3211
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3212
+			: ['action' => 'default'];
3213
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3214
+	}
3215
+
3216
+
3217
+	/**
3218
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3219
+	 * to use when selecting registrations
3220
+	 *
3221
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3222
+	 *                                                     the query parameters from the request
3223
+	 * @return void ends the request with a redirect or download
3224
+	 */
3225
+	public function _registrations_report_base($method_name_for_getting_query_params)
3226
+	{
3227
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3228
+			? $this->request->getRequestParam('EVT_ID', 0, DataType::INT)
3229
+			: null;
3230
+
3231
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3232
+			$return_url = $this->request->getRequestParam('return_url', '', DataType::URL);
3233
+			$filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3234
+			$use_filters = $this->request->getRequestParam('use_filters', false, DataType::BOOL);
3235
+			wp_redirect(
3236
+				EE_Admin_Page::add_query_args_and_nonce(
3237
+					[
3238
+						'page'        => EED_Batch::PAGE_SLUG,
3239
+						'batch'       => EED_Batch::batch_file_job,
3240
+						'EVT_ID'      => $EVT_ID,
3241
+						'filters'     => urlencode(serialize($this->$method_name_for_getting_query_params($filters))),
3242
+						'use_filters' => urlencode($use_filters),
3243
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3244
+						'return_url'  => urlencode($return_url),
3245
+					]
3246
+				)
3247
+			);
3248
+		} else {
3249
+			// Pull the current request params
3250
+			$request_args = $this->request->requestParams();
3251
+			// Set the required request_args to be passed to the export
3252
+			$required_request_args = [
3253
+				'export' => 'report',
3254
+				'action' => 'registrations_report_for_event',
3255
+				'EVT_ID' => $EVT_ID,
3256
+			];
3257
+			// Merge required request args, overriding any currently set
3258
+			$request_args = array_merge($request_args, $required_request_args);
3259
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3260
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3261
+				$EE_Export = EE_Export::instance($request_args);
3262
+				$EE_Export->export();
3263
+			}
3264
+		}
3265
+	}
3266
+
3267
+
3268
+	/**
3269
+	 * Creates a registration report using only query parameters in the request
3270
+	 *
3271
+	 * @return void
3272
+	 */
3273
+	public function _registrations_report()
3274
+	{
3275
+		$this->_registrations_report_base('_get_registration_query_parameters');
3276
+	}
3277
+
3278
+
3279
+	public function _contact_list_export()
3280
+	{
3281
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3282
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3283
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3284
+			$EE_Export->export_attendees();
3285
+		}
3286
+	}
3287
+
3288
+
3289
+	public function _contact_list_report()
3290
+	{
3291
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3292
+			wp_redirect(
3293
+				EE_Admin_Page::add_query_args_and_nonce(
3294
+					[
3295
+						'page'        => EED_Batch::PAGE_SLUG,
3296
+						'batch'       => EED_Batch::batch_file_job,
3297
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3298
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3299
+					]
3300
+				)
3301
+			);
3302
+		} else {
3303
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3304
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3305
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3306
+				$EE_Export->report_attendees();
3307
+			}
3308
+		}
3309
+	}
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3316
+	/**
3317
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3318
+	 *
3319
+	 * @return void
3320
+	 * @throws EE_Error
3321
+	 * @throws InvalidArgumentException
3322
+	 * @throws InvalidDataTypeException
3323
+	 * @throws InvalidInterfaceException
3324
+	 * @throws ReflectionException
3325
+	 */
3326
+	protected function _duplicate_attendee()
3327
+	{
3328
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3329
+		$action = $this->request->getRequestParam('return', 'default');
3330
+		// verify we have necessary info
3331
+		if (! $REG_ID) {
3332
+			EE_Error::add_error(
3333
+				esc_html__(
3334
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3335
+					'event_espresso'
3336
+				),
3337
+				__FILE__,
3338
+				__LINE__,
3339
+				__FUNCTION__
3340
+			);
3341
+			$query_args = ['action' => $action];
3342
+			$this->_redirect_after_action('', '', '', $query_args, true);
3343
+		}
3344
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3345
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3346
+		if (! $registration instanceof EE_Registration) {
3347
+			throw new RuntimeException(
3348
+				sprintf(
3349
+					esc_html__(
3350
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3351
+						'event_espresso'
3352
+					),
3353
+					$REG_ID
3354
+				)
3355
+			);
3356
+		}
3357
+		$attendee = $registration->attendee();
3358
+		// remove relation of existing attendee on registration
3359
+		$registration->_remove_relation_to($attendee, 'Attendee');
3360
+		// new attendee
3361
+		$new_attendee = clone $attendee;
3362
+		$new_attendee->set('ATT_ID', 0);
3363
+		$new_attendee->save();
3364
+		// add new attendee to reg
3365
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3366
+		EE_Error::add_success(
3367
+			esc_html__(
3368
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3369
+				'event_espresso'
3370
+			)
3371
+		);
3372
+		// redirect to edit page for attendee
3373
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3374
+		$this->_redirect_after_action('', '', '', $query_args, true);
3375
+	}
3376
+
3377
+
3378
+	/**
3379
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3380
+	 *
3381
+	 * @param int     $post_id
3382
+	 * @param WP_Post $post
3383
+	 * @throws DomainException
3384
+	 * @throws EE_Error
3385
+	 * @throws InvalidArgumentException
3386
+	 * @throws InvalidDataTypeException
3387
+	 * @throws InvalidInterfaceException
3388
+	 * @throws LogicException
3389
+	 * @throws InvalidFormSubmissionException
3390
+	 * @throws ReflectionException
3391
+	 */
3392
+	protected function _insert_update_cpt_item($post_id, $post)
3393
+	{
3394
+		$success  = true;
3395
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3396
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3397
+			: null;
3398
+		// for attendee updates
3399
+		if ($attendee instanceof EE_Attendee) {
3400
+			// note we should only be UPDATING attendees at this point.
3401
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3402
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3403
+			$updated_fields = [
3404
+				'ATT_fname'     => $fname,
3405
+				'ATT_lname'     => $lname,
3406
+				'ATT_full_name' => "{$fname} {$lname}",
3407
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3408
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3409
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3410
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3411
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3412
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3413
+			];
3414
+			foreach ($updated_fields as $field => $value) {
3415
+				$attendee->set($field, $value);
3416
+			}
3417
+
3418
+			// process contact details metabox form handler (which will also save the attendee)
3419
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3420
+			$success              = $contact_details_form->process($this->request->requestParams());
3421
+
3422
+			$attendee_update_callbacks = apply_filters(
3423
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3424
+				[]
3425
+			);
3426
+			foreach ($attendee_update_callbacks as $a_callback) {
3427
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3428
+					throw new EE_Error(
3429
+						sprintf(
3430
+							esc_html__(
3431
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3432
+								'event_espresso'
3433
+							),
3434
+							$a_callback
3435
+						)
3436
+					);
3437
+				}
3438
+			}
3439
+		}
3440
+
3441
+		if ($success === false) {
3442
+			EE_Error::add_error(
3443
+				esc_html__(
3444
+					'Something went wrong with updating the meta table data for the registration.',
3445
+					'event_espresso'
3446
+				),
3447
+				__FILE__,
3448
+				__FUNCTION__,
3449
+				__LINE__
3450
+			);
3451
+		}
3452
+	}
3453
+
3454
+
3455
+	public function trash_cpt_item($post_id)
3456
+	{
3457
+	}
3458
+
3459
+
3460
+	public function delete_cpt_item($post_id)
3461
+	{
3462
+	}
3463
+
3464
+
3465
+	public function restore_cpt_item($post_id)
3466
+	{
3467
+	}
3468
+
3469
+
3470
+	protected function _restore_cpt_item($post_id, $revision_id)
3471
+	{
3472
+	}
3473
+
3474
+
3475
+	/**
3476
+	 * @throws EE_Error
3477
+	 * @throws ReflectionException
3478
+	 * @since 4.10.2.p
3479
+	 */
3480
+	public function attendee_editor_metaboxes()
3481
+	{
3482
+		$this->verify_cpt_object();
3483
+		remove_meta_box(
3484
+			'postexcerpt',
3485
+			$this->_cpt_routes[ $this->_req_action ],
3486
+			'normal'
3487
+		);
3488
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3489
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3490
+			$this->addMetaBox(
3491
+				'postexcerpt',
3492
+				esc_html__('Short Biography', 'event_espresso'),
3493
+				'post_excerpt_meta_box',
3494
+				$this->_cpt_routes[ $this->_req_action ]
3495
+			);
3496
+		}
3497
+		if (post_type_supports('espresso_attendees', 'comments')) {
3498
+			$this->addMetaBox(
3499
+				'commentsdiv',
3500
+				esc_html__('Notes on the Contact', 'event_espresso'),
3501
+				'post_comment_meta_box',
3502
+				$this->_cpt_routes[ $this->_req_action ],
3503
+				'normal',
3504
+				'core'
3505
+			);
3506
+		}
3507
+		$this->addMetaBox(
3508
+			'attendee_contact_info',
3509
+			esc_html__('Contact Info', 'event_espresso'),
3510
+			[$this, 'attendee_contact_info'],
3511
+			$this->_cpt_routes[ $this->_req_action ],
3512
+			'side',
3513
+			'core'
3514
+		);
3515
+		$this->addMetaBox(
3516
+			'attendee_details_address',
3517
+			esc_html__('Address Details', 'event_espresso'),
3518
+			[$this, 'attendee_address_details'],
3519
+			$this->_cpt_routes[ $this->_req_action ],
3520
+			'normal',
3521
+			'core'
3522
+		);
3523
+		$this->addMetaBox(
3524
+			'attendee_registrations',
3525
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3526
+			[$this, 'attendee_registrations_meta_box'],
3527
+			$this->_cpt_routes[ $this->_req_action ]
3528
+		);
3529
+	}
3530
+
3531
+
3532
+	/**
3533
+	 * Metabox for attendee contact info
3534
+	 *
3535
+	 * @param WP_Post $post wp post object
3536
+	 * @return void attendee contact info ( and form )
3537
+	 * @throws EE_Error
3538
+	 * @throws InvalidArgumentException
3539
+	 * @throws InvalidDataTypeException
3540
+	 * @throws InvalidInterfaceException
3541
+	 * @throws LogicException
3542
+	 * @throws DomainException
3543
+	 */
3544
+	public function attendee_contact_info($post)
3545
+	{
3546
+		// get attendee object ( should already have it )
3547
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3548
+		$form->enqueueStylesAndScripts();
3549
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3550
+	}
3551
+
3552
+
3553
+	/**
3554
+	 * Return form handler for the contact details metabox
3555
+	 *
3556
+	 * @param EE_Attendee $attendee
3557
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3558
+	 * @throws DomainException
3559
+	 * @throws InvalidArgumentException
3560
+	 * @throws InvalidDataTypeException
3561
+	 * @throws InvalidInterfaceException
3562
+	 */
3563
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3564
+	{
3565
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3566
+	}
3567
+
3568
+
3569
+	/**
3570
+	 * Metabox for attendee details
3571
+	 *
3572
+	 * @param WP_Post $post wp post object
3573
+	 * @throws EE_Error
3574
+	 * @throws ReflectionException
3575
+	 */
3576
+	public function attendee_address_details($post)
3577
+	{
3578
+		// get attendee object (should already have it)
3579
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3580
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3581
+			new EE_Question_Form_Input(
3582
+				EE_Question::new_instance(
3583
+					[
3584
+						'QST_ID'           => 0,
3585
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3586
+						'QST_system'       => 'admin-state',
3587
+					]
3588
+				),
3589
+				EE_Answer::new_instance(
3590
+					[
3591
+						'ANS_ID'    => 0,
3592
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3593
+					]
3594
+				),
3595
+				[
3596
+					'input_id'       => 'STA_ID',
3597
+					'input_name'     => 'STA_ID',
3598
+					'input_prefix'   => '',
3599
+					'append_qstn_id' => false,
3600
+				]
3601
+			)
3602
+		);
3603
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3604
+			new EE_Question_Form_Input(
3605
+				EE_Question::new_instance(
3606
+					[
3607
+						'QST_ID'           => 0,
3608
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3609
+						'QST_system'       => 'admin-country',
3610
+					]
3611
+				),
3612
+				EE_Answer::new_instance(
3613
+					[
3614
+						'ANS_ID'    => 0,
3615
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3616
+					]
3617
+				),
3618
+				[
3619
+					'input_id'       => 'CNT_ISO',
3620
+					'input_name'     => 'CNT_ISO',
3621
+					'input_prefix'   => '',
3622
+					'append_qstn_id' => false,
3623
+				]
3624
+			)
3625
+		);
3626
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3627
+		EEH_Template::display_template($template, $this->_template_args);
3628
+	}
3629
+
3630
+
3631
+	/**
3632
+	 * _attendee_details
3633
+	 *
3634
+	 * @param $post
3635
+	 * @return void
3636
+	 * @throws DomainException
3637
+	 * @throws EE_Error
3638
+	 * @throws InvalidArgumentException
3639
+	 * @throws InvalidDataTypeException
3640
+	 * @throws InvalidInterfaceException
3641
+	 * @throws ReflectionException
3642
+	 */
3643
+	public function attendee_registrations_meta_box($post)
3644
+	{
3645
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3646
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3647
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3648
+		EEH_Template::display_template($template, $this->_template_args);
3649
+	}
3650
+
3651
+
3652
+	/**
3653
+	 * add in the form fields for the attendee edit
3654
+	 *
3655
+	 * @param WP_Post $post wp post object
3656
+	 * @return void echos html for new form.
3657
+	 * @throws DomainException
3658
+	 */
3659
+	public function after_title_form_fields($post)
3660
+	{
3661
+		if ($post->post_type === 'espresso_attendees') {
3662
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3663
+			$template_args['attendee'] = $this->_cpt_model_obj;
3664
+			EEH_Template::display_template($template, $template_args);
3665
+		}
3666
+	}
3667
+
3668
+
3669
+	/**
3670
+	 * _trash_or_restore_attendee
3671
+	 *
3672
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3673
+	 * @return void
3674
+	 * @throws EE_Error
3675
+	 * @throws InvalidArgumentException
3676
+	 * @throws InvalidDataTypeException
3677
+	 * @throws InvalidInterfaceException
3678
+	 */
3679
+	protected function _trash_or_restore_attendees($trash = true)
3680
+	{
3681
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3682
+		$status = $trash ? 'trash' : 'publish';
3683
+		// Checkboxes
3684
+		if ($this->request->requestParamIsSet('checkbox')) {
3685
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3686
+			// if array has more than one element than success message should be plural
3687
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3688
+			// cycle thru checkboxes
3689
+			foreach ($ATT_IDs as $ATT_ID) {
3690
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3691
+				if (! $updated) {
3692
+					$success = 0;
3693
+				}
3694
+			}
3695
+		} else {
3696
+			// grab single id and delete
3697
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3698
+			// update attendee
3699
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3700
+		}
3701
+		$what        = $success > 1
3702
+			? esc_html__('Contacts', 'event_espresso')
3703
+			: esc_html__('Contact', 'event_espresso');
3704
+		$action_desc = $trash
3705
+			? esc_html__('moved to the trash', 'event_espresso')
3706
+			: esc_html__('restored', 'event_espresso');
3707
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3708
+	}
3709 3709
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function getRegistrationModel()
95 95
     {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
96
+        if ( ! $this->registration_model instanceof EEM_Registration) {
97 97
             $this->registration_model = $this->loader->getShared('EEM_Registration');
98 98
         }
99 99
         return $this->registration_model;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function getAttendeeModel()
111 111
     {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
112
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
113 113
             $this->attendee_model = $this->loader->getShared('EEM_Attendee');
114 114
         }
115 115
         return $this->attendee_model;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getEventModel()
127 127
     {
128
-        if (! $this->event_model instanceof EEM_Event) {
128
+        if ( ! $this->event_model instanceof EEM_Event) {
129 129
             $this->event_model = $this->loader->getShared('EEM_Event');
130 130
         }
131 131
         return $this->event_model;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function getStatusModel()
143 143
     {
144
-        if (! $this->status_model instanceof EEM_Status) {
144
+        if ( ! $this->status_model instanceof EEM_Status) {
145 145
             $this->status_model = $this->loader->getShared('EEM_Status');
146 146
         }
147 147
         return $this->status_model;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         // style
761 761
         wp_register_style(
762 762
             'espresso_reg',
763
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
763
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
764 764
             ['ee-admin-css'],
765 765
             EVENT_ESPRESSO_VERSION
766 766
         );
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         // script
769 769
         wp_register_script(
770 770
             'espresso_reg',
771
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
771
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
772 772
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
773 773
             EVENT_ESPRESSO_VERSION,
774 774
             true
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
             'att_publish_text' => sprintf(
793 793
             /* translators: The date and time */
794 794
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
795
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
795
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
796 796
             ),
797 797
         ];
798 798
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
         wp_dequeue_style('espresso_reg');
824 824
         wp_register_style(
825 825
             'espresso_att',
826
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
826
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
827 827
             ['ee-admin-css'],
828 828
             EVENT_ESPRESSO_VERSION
829 829
         );
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
     {
836 836
         wp_register_script(
837 837
             'ee-spco-for-admin',
838
-            REG_ASSETS_URL . 'spco_for_admin.js',
838
+            REG_ASSETS_URL.'spco_for_admin.js',
839 839
             ['underscore', 'jquery'],
840 840
             EVENT_ESPRESSO_VERSION,
841 841
             true
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
             'no_approve_registrations' => 'not_approved_registration',
884 884
             'cancel_registrations'     => 'cancelled_registration',
885 885
         ];
886
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
886
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
887 887
             'ee_send_message',
888 888
             'batch_send_messages'
889 889
         );
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
989 989
                 ],
990 990
             ];
991
-            $this->_views['trash']      = [
991
+            $this->_views['trash'] = [
992 992
                 'slug'        => 'trash',
993 993
                 'label'       => esc_html__('Trash', 'event_espresso'),
994 994
                 'count'       => 0,
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
         }
1089 1089
         $sc_items = [
1090 1090
             'approved_status'   => [
1091
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1091
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_approved,
1092 1092
                 'desc'  => EEH_Template::pretty_status(
1093 1093
                     EEM_Registration::status_id_approved,
1094 1094
                     false,
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
                 ),
1097 1097
             ],
1098 1098
             'pending_status'    => [
1099
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1099
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_pending_payment,
1100 1100
                 'desc'  => EEH_Template::pretty_status(
1101 1101
                     EEM_Registration::status_id_pending_payment,
1102 1102
                     false,
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                 ),
1105 1105
             ],
1106 1106
             'wait_list'         => [
1107
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1107
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_wait_list,
1108 1108
                 'desc'  => EEH_Template::pretty_status(
1109 1109
                     EEM_Registration::status_id_wait_list,
1110 1110
                     false,
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
                 ),
1113 1113
             ],
1114 1114
             'incomplete_status' => [
1115
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1115
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_incomplete,
1116 1116
                 'desc'  => EEH_Template::pretty_status(
1117 1117
                     EEM_Registration::status_id_incomplete,
1118 1118
                     false,
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                 ),
1121 1121
             ],
1122 1122
             'not_approved'      => [
1123
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1123
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_not_approved,
1124 1124
                 'desc'  => EEH_Template::pretty_status(
1125 1125
                     EEM_Registration::status_id_not_approved,
1126 1126
                     false,
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                 ),
1129 1129
             ],
1130 1130
             'declined_status'   => [
1131
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1131
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_declined,
1132 1132
                 'desc'  => EEH_Template::pretty_status(
1133 1133
                     EEM_Registration::status_id_declined,
1134 1134
                     false,
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
                 ),
1137 1137
             ],
1138 1138
             'cancelled_status'  => [
1139
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1139
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_cancelled,
1140 1140
                 'desc'  => EEH_Template::pretty_status(
1141 1141
                     EEM_Registration::status_id_cancelled,
1142 1142
                     false,
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
             $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1174 1174
             $header_text = $filter_header_decorator->getHeaderText($header_text);
1175 1175
         }
1176
-        $this->_template_args['before_list_table']  = $header_text;
1177
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1176
+        $this->_template_args['before_list_table'] = $header_text;
1177
+        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1178 1178
         $this->display_admin_list_table_page_with_no_sidebar();
1179 1179
     }
1180 1180
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
                 $EVT_ID
1197 1197
             )
1198 1198
         ) {
1199
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1199
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1200 1200
                 'new_registration',
1201 1201
                 'add-registrant',
1202 1202
                 ['event_id' => $EVT_ID],
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                 ],
1355 1355
                 REG_ADMIN_URL
1356 1356
             );
1357
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1357
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1358 1358
                 [
1359 1359
                     'action' => 'default',
1360 1360
                     'EVT_ID' => $event_id,
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
                 ],
1363 1363
                 admin_url('admin.php')
1364 1364
             );
1365
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1365
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1366 1366
                 [
1367 1367
                     'page'   => 'espresso_events',
1368 1368
                     'action' => 'edit',
@@ -1371,12 +1371,12 @@  discard block
 block discarded – undo
1371 1371
                 admin_url('admin.php')
1372 1372
             );
1373 1373
             // next and previous links
1374
-            $next_reg                                      = $this->_registration->next(
1374
+            $next_reg = $this->_registration->next(
1375 1375
                 null,
1376 1376
                 [],
1377 1377
                 'REG_ID'
1378 1378
             );
1379
-            $this->_template_args['next_registration']     = $next_reg
1379
+            $this->_template_args['next_registration'] = $next_reg
1380 1380
                 ? $this->_next_link(
1381 1381
                     EE_Admin_Page::add_query_args_and_nonce(
1382 1382
                         [
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1389 1389
                 )
1390 1390
                 : '';
1391
-            $previous_reg                                  = $this->_registration->previous(
1391
+            $previous_reg = $this->_registration->previous(
1392 1392
                 null,
1393 1393
                 [],
1394 1394
                 'REG_ID'
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
                 )
1407 1407
                 : '';
1408 1408
             // grab header
1409
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1409
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1410 1410
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1411 1411
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1412 1412
                 $template_path,
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
         );
1444 1444
         $this->addMetaBox(
1445 1445
             'edit-reg-details-mbox',
1446
-            '<span>' . esc_html__('Registration Details', 'event_espresso')
1446
+            '<span>'.esc_html__('Registration Details', 'event_espresso')
1447 1447
             . '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1448 1448
             [$this, '_reg_details_meta_box'],
1449 1449
             $this->_wp_page_slug
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
                 $this->_registration->ID()
1548 1548
             )
1549 1549
         ) {
1550
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1550
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1551 1551
                 $this->_get_reg_statuses(),
1552 1552
                 [
1553 1553
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
                     ),
1565 1565
                 ]
1566 1566
             );
1567
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1567
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1568 1568
                 [
1569 1569
                     'html_class'      => 'button--primary',
1570 1570
                     'html_label_text' => '&nbsp;',
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
     protected function _get_reg_statuses()
1590 1590
     {
1591 1591
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1592
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1592
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1593 1593
         // get current reg status
1594 1594
         $current_status = $this->_registration->status_ID();
1595 1595
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
             $current_status !== EEM_Registration::status_id_pending_payment
1598 1598
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1599 1599
         ) {
1600
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1600
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1601 1601
         }
1602 1602
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1603 1603
     }
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
         $success = false;
1689 1689
         // typecast $REG_IDs
1690 1690
         $REG_IDs = (array) $REG_IDs;
1691
-        if (! empty($REG_IDs)) {
1691
+        if ( ! empty($REG_IDs)) {
1692 1692
             $success = true;
1693 1693
             // set default status if none is passed
1694 1694
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
             $action,
1849 1849
             $notify
1850 1850
         );
1851
-        $method = $action . '_registration';
1851
+        $method = $action.'_registration';
1852 1852
         if (method_exists($this, $method)) {
1853 1853
             $this->$method($notify);
1854 1854
         }
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
         $filters        = new EE_Line_Item_Filter_Collection();
1999 1999
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2000 2000
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2001
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2001
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2002 2002
             $filters,
2003 2003
             $transaction->total_line_item()
2004 2004
         );
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
             $filtered_line_item_tree,
2012 2012
             ['EE_Registration' => $this->_registration]
2013 2013
         );
2014
-        $attendee                                = $this->_registration->attendee();
2014
+        $attendee = $this->_registration->attendee();
2015 2015
         if (
2016 2016
             EE_Registry::instance()->CAP->current_user_can(
2017 2017
                 'ee_read_transaction',
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
                 'Payment method response',
2094 2094
                 'event_espresso'
2095 2095
             );
2096
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2096
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2097 2097
         }
2098 2098
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2099 2099
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
         $this->_template_args['REG_ID'] = $this->_registration->ID();
2125 2125
         $this->_template_args['event_id'] = $this->_registration->event_ID();
2126 2126
 
2127
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2127
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2128 2128
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2129 2129
     }
2130 2130
 
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 
2164 2164
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2165 2165
             $this->_template_args['REG_ID'] = $this->_registration->ID();
2166
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2166
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2167 2167
             EEH_Template::display_template($template_path, $this->_template_args);
2168 2168
         }
2169 2169
     }
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
     public function form_before_question_group($output)
2180 2180
     {
2181 2181
         EE_Error::doing_it_wrong(
2182
-            __CLASS__ . '::' . __FUNCTION__,
2182
+            __CLASS__.'::'.__FUNCTION__,
2183 2183
             esc_html__(
2184 2184
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2185 2185
                 'event_espresso'
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
     public function form_after_question_group($output)
2204 2204
     {
2205 2205
         EE_Error::doing_it_wrong(
2206
-            __CLASS__ . '::' . __FUNCTION__,
2206
+            __CLASS__.'::'.__FUNCTION__,
2207 2207
             esc_html__(
2208 2208
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2209 2209
                 'event_espresso'
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
     public function form_form_field_label_wrap($label)
2241 2241
     {
2242 2242
         EE_Error::doing_it_wrong(
2243
-            __CLASS__ . '::' . __FUNCTION__,
2243
+            __CLASS__.'::'.__FUNCTION__,
2244 2244
             esc_html__(
2245 2245
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2246 2246
                 'event_espresso'
@@ -2250,7 +2250,7 @@  discard block
 block discarded – undo
2250 2250
         return '
2251 2251
 			<tr>
2252 2252
 				<th>
2253
-					' . $label . '
2253
+					' . $label.'
2254 2254
 				</th>';
2255 2255
     }
2256 2256
 
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
     public function form_form_field_input__wrap($input)
2266 2266
     {
2267 2267
         EE_Error::doing_it_wrong(
2268
-            __CLASS__ . '::' . __FUNCTION__,
2268
+            __CLASS__.'::'.__FUNCTION__,
2269 2269
             esc_html__(
2270 2270
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2271 2271
                 'event_espresso'
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
         );
2275 2275
         return '
2276 2276
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2277
-					' . $input . '
2277
+					' . $input.'
2278 2278
 				</td>
2279 2279
 			</tr>';
2280 2280
     }
@@ -2323,8 +2323,8 @@  discard block
 block discarded – undo
2323 2323
      */
2324 2324
     protected function _get_reg_custom_questions_form($REG_ID)
2325 2325
     {
2326
-        if (! $this->_reg_custom_questions_form) {
2327
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2326
+        if ( ! $this->_reg_custom_questions_form) {
2327
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2328 2328
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2329 2329
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2330 2330
             );
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
      */
2348 2348
     private function _save_reg_custom_questions_form($REG_ID = 0)
2349 2349
     {
2350
-        if (! $REG_ID) {
2350
+        if ( ! $REG_ID) {
2351 2351
             EE_Error::add_error(
2352 2352
                 esc_html__(
2353 2353
                     'An error occurred. No registration ID was received.',
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
         if ($form->is_valid()) {
2365 2365
             foreach ($form->subforms() as $question_group_form) {
2366 2366
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2367
-                    $where_conditions    = [
2367
+                    $where_conditions = [
2368 2368
                         'QST_ID' => $question_id,
2369 2369
                         'REG_ID' => $REG_ID,
2370 2370
                     ];
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
         $REG = $this->getRegistrationModel();
2406 2406
         // get all other registrations on this transaction, and cache
2407 2407
         // the attendees for them so we don't have to run another query using force_join
2408
-        $registrations                           = $REG->get_all(
2408
+        $registrations = $REG->get_all(
2409 2409
             [
2410 2410
                 [
2411 2411
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2439,23 +2439,23 @@  discard block
 block discarded – undo
2439 2439
                 $attendee                                                      = $registration->attendee()
2440 2440
                     ? $registration->attendee()
2441 2441
                     : $this->getAttendeeModel()->create_default_object();
2442
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2443
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2444
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2445
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2446
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2447
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2442
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2443
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2444
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2445
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2446
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2447
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2448 2448
                     ', ',
2449 2449
                     $attendee->full_address_as_array()
2450 2450
                 );
2451
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2451
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2452 2452
                     [
2453 2453
                         'action' => 'edit_attendee',
2454 2454
                         'post'   => $attendee->ID(),
2455 2455
                     ],
2456 2456
                     REG_ADMIN_URL
2457 2457
                 );
2458
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2458
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2459 2459
                     $registration->event_obj() instanceof EE_Event
2460 2460
                         ? $registration->event_obj()->name()
2461 2461
                         : '';
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
             }
2464 2464
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2465 2465
         }
2466
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2466
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2467 2467
         EEH_Template::display_template($template_path, $this->_template_args);
2468 2468
     }
2469 2469
 
@@ -2489,11 +2489,11 @@  discard block
 block discarded – undo
2489 2489
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2490 2490
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2491 2491
         // primary registration object (that way we know if we need to show create button or not)
2492
-        if (! $this->_registration->is_primary_registrant()) {
2492
+        if ( ! $this->_registration->is_primary_registrant()) {
2493 2493
             $primary_registration = $this->_registration->get_primary_registration();
2494 2494
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2495 2495
                 : null;
2496
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2496
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2497 2497
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2498 2498
                 // custom attendee object so let's not worry about the primary reg.
2499 2499
                 $primary_registration = null;
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
         $this->_template_args['phone']             = $attendee->phone();
2509 2509
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2510 2510
         // edit link
2511
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2511
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2512 2512
             [
2513 2513
                 'action' => 'edit_attendee',
2514 2514
                 'post'   => $attendee->ID(),
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
         $this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2519 2519
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2520 2520
         // create link
2521
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2521
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2522 2522
             ? EE_Admin_Page::add_query_args_and_nonce(
2523 2523
                 [
2524 2524
                     'action'  => 'duplicate_attendee',
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
             ) : '';
2529 2529
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2530 2530
         $this->_template_args['att_check'] = $att_check;
2531
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2531
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2532 2532
         EEH_Template::display_template($template_path, $this->_template_args);
2533 2533
     }
2534 2534
 
@@ -2572,7 +2572,7 @@  discard block
 block discarded – undo
2572 2572
             /** @var EE_Registration $REG */
2573 2573
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2574 2574
             $payments = $REG->registration_payments();
2575
-            if (! empty($payments)) {
2575
+            if ( ! empty($payments)) {
2576 2576
                 $name           = $REG->attendee() instanceof EE_Attendee
2577 2577
                     ? $REG->attendee()->full_name()
2578 2578
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2636,17 +2636,17 @@  discard block
 block discarded – undo
2636 2636
         // Checkboxes
2637 2637
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2638 2638
 
2639
-        if (! empty($REG_IDs)) {
2639
+        if ( ! empty($REG_IDs)) {
2640 2640
             // if array has more than one element than success message should be plural
2641 2641
             $success = count($REG_IDs) > 1 ? 2 : 1;
2642 2642
             // cycle thru checkboxes
2643 2643
             foreach ($REG_IDs as $REG_ID) {
2644 2644
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2645
-                if (! $REG instanceof EE_Registration) {
2645
+                if ( ! $REG instanceof EE_Registration) {
2646 2646
                     continue;
2647 2647
                 }
2648 2648
                 $deleted = $this->_delete_registration($REG);
2649
-                if (! $deleted) {
2649
+                if ( ! $deleted) {
2650 2650
                     $success = 0;
2651 2651
                 }
2652 2652
             }
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2684 2684
         // registrations on the transaction that are NOT trashed.
2685 2685
         $TXN = $REG->get_first_related('Transaction');
2686
-        if (! $TXN instanceof EE_Transaction) {
2686
+        if ( ! $TXN instanceof EE_Transaction) {
2687 2687
             EE_Error::add_error(
2688 2688
                 sprintf(
2689 2689
                     esc_html__(
@@ -2701,11 +2701,11 @@  discard block
 block discarded – undo
2701 2701
         $REGS        = $TXN->get_many_related('Registration');
2702 2702
         $all_trashed = true;
2703 2703
         foreach ($REGS as $registration) {
2704
-            if (! $registration->get('REG_deleted')) {
2704
+            if ( ! $registration->get('REG_deleted')) {
2705 2705
                 $all_trashed = false;
2706 2706
             }
2707 2707
         }
2708
-        if (! $all_trashed) {
2708
+        if ( ! $all_trashed) {
2709 2709
             EE_Error::add_error(
2710 2710
                 esc_html__(
2711 2711
                     'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
@@ -2767,7 +2767,7 @@  discard block
 block discarded – undo
2767 2767
      */
2768 2768
     public function new_registration()
2769 2769
     {
2770
-        if (! $this->_set_reg_event()) {
2770
+        if ( ! $this->_set_reg_event()) {
2771 2771
             throw new EE_Error(
2772 2772
                 esc_html__(
2773 2773
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2799,7 +2799,7 @@  discard block
 block discarded – undo
2799 2799
                 ],
2800 2800
                 EVENTS_ADMIN_URL
2801 2801
             );
2802
-            $edit_event_lnk                     = '<a href="'
2802
+            $edit_event_lnk = '<a href="'
2803 2803
                                                   . $edit_event_url
2804 2804
                                                   . '" title="'
2805 2805
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2816,7 +2816,7 @@  discard block
 block discarded – undo
2816 2816
             $this->_return_json();
2817 2817
         }
2818 2818
         // grab header
2819
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2819
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2820 2820
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2821 2821
             $template_path,
2822 2822
             $this->_template_args,
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
                 '</b>'
2858 2858
             );
2859 2859
             return '
2860
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2860
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2861 2861
 	<script >
2862 2862
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2863 2863
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
         // we come back to the process_registration_step route.
2925 2925
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2926 2926
         return EEH_Template::display_template(
2927
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2927
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2928 2928
             $template_args,
2929 2929
             true
2930 2930
         );
@@ -2947,7 +2947,7 @@  discard block
 block discarded – undo
2947 2947
         }
2948 2948
 
2949 2949
         $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2950
-        if (! $EVT_ID) {
2950
+        if ( ! $EVT_ID) {
2951 2951
             return false;
2952 2952
         }
2953 2953
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3017,7 +3017,7 @@  discard block
 block discarded – undo
3017 3017
                 }
3018 3018
                 break;
3019 3019
             case 'questions':
3020
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3020
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3021 3021
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3022 3022
                 }
3023 3023
                 // process registration
@@ -3028,7 +3028,7 @@  discard block
 block discarded – undo
3028 3028
                         $grand_total->save_this_and_descendants_to_txn();
3029 3029
                     }
3030 3030
                 }
3031
-                if (! $transaction instanceof EE_Transaction) {
3031
+                if ( ! $transaction instanceof EE_Transaction) {
3032 3032
                     $query_args = [
3033 3033
                         'action'                  => 'new_registration',
3034 3034
                         'processing_registration' => 2,
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
                     return;
3051 3051
                 }
3052 3052
                 // maybe update status, and make sure to save transaction if not done already
3053
-                if (! $transaction->update_status_based_on_total_paid()) {
3053
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3054 3054
                     $transaction->save();
3055 3055
                 }
3056 3056
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
     public function get_attendees($per_page, $count = false, $trash = false)
3133 3133
     {
3134 3134
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3135
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3135
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3136 3136
         $orderby = $this->request->getRequestParam('orderby');
3137 3137
         switch ($orderby) {
3138 3138
             case 'ATT_ID':
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
         $_where       = [];
3156 3156
         $search_term  = $this->request->getRequestParam('s');
3157 3157
         if ($search_term) {
3158
-            $search_term  = '%' . $search_term . '%';
3158
+            $search_term  = '%'.$search_term.'%';
3159 3159
             $_where['OR'] = [
3160 3160
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3161 3161
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3182,7 +3182,7 @@  discard block
 block discarded – undo
3182 3182
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3183 3183
             'limit'         => $limit,
3184 3184
         ];
3185
-        if (! $count) {
3185
+        if ( ! $count) {
3186 3186
             $query_args['order_by'] = [$orderby => $sort];
3187 3187
         }
3188 3188
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3228,7 +3228,7 @@  discard block
 block discarded – undo
3228 3228
             ? $this->request->getRequestParam('EVT_ID', 0, DataType::INT)
3229 3229
             : null;
3230 3230
 
3231
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3231
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3232 3232
             $return_url = $this->request->getRequestParam('return_url', '', DataType::URL);
3233 3233
             $filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3234 3234
             $use_filters = $this->request->getRequestParam('use_filters', false, DataType::BOOL);
@@ -3256,8 +3256,8 @@  discard block
 block discarded – undo
3256 3256
             ];
3257 3257
             // Merge required request args, overriding any currently set
3258 3258
             $request_args = array_merge($request_args, $required_request_args);
3259
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3260
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3259
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3260
+                require_once(EE_CLASSES.'EE_Export.class.php');
3261 3261
                 $EE_Export = EE_Export::instance($request_args);
3262 3262
                 $EE_Export->export();
3263 3263
             }
@@ -3278,8 +3278,8 @@  discard block
 block discarded – undo
3278 3278
 
3279 3279
     public function _contact_list_export()
3280 3280
     {
3281
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3282
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3281
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3282
+            require_once(EE_CLASSES.'EE_Export.class.php');
3283 3283
             $EE_Export = EE_Export::instance($this->request->requestParams());
3284 3284
             $EE_Export->export_attendees();
3285 3285
         }
@@ -3288,7 +3288,7 @@  discard block
 block discarded – undo
3288 3288
 
3289 3289
     public function _contact_list_report()
3290 3290
     {
3291
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3291
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3292 3292
             wp_redirect(
3293 3293
                 EE_Admin_Page::add_query_args_and_nonce(
3294 3294
                     [
@@ -3300,8 +3300,8 @@  discard block
 block discarded – undo
3300 3300
                 )
3301 3301
             );
3302 3302
         } else {
3303
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3304
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3303
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3304
+                require_once(EE_CLASSES.'EE_Export.class.php');
3305 3305
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3306 3306
                 $EE_Export->report_attendees();
3307 3307
             }
@@ -3328,7 +3328,7 @@  discard block
 block discarded – undo
3328 3328
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3329 3329
         $action = $this->request->getRequestParam('return', 'default');
3330 3330
         // verify we have necessary info
3331
-        if (! $REG_ID) {
3331
+        if ( ! $REG_ID) {
3332 3332
             EE_Error::add_error(
3333 3333
                 esc_html__(
3334 3334
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3343,7 +3343,7 @@  discard block
 block discarded – undo
3343 3343
         }
3344 3344
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3345 3345
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3346
-        if (! $registration instanceof EE_Registration) {
3346
+        if ( ! $registration instanceof EE_Registration) {
3347 3347
             throw new RuntimeException(
3348 3348
                 sprintf(
3349 3349
                     esc_html__(
@@ -3482,16 +3482,16 @@  discard block
 block discarded – undo
3482 3482
         $this->verify_cpt_object();
3483 3483
         remove_meta_box(
3484 3484
             'postexcerpt',
3485
-            $this->_cpt_routes[ $this->_req_action ],
3485
+            $this->_cpt_routes[$this->_req_action],
3486 3486
             'normal'
3487 3487
         );
3488
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3488
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3489 3489
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3490 3490
             $this->addMetaBox(
3491 3491
                 'postexcerpt',
3492 3492
                 esc_html__('Short Biography', 'event_espresso'),
3493 3493
                 'post_excerpt_meta_box',
3494
-                $this->_cpt_routes[ $this->_req_action ]
3494
+                $this->_cpt_routes[$this->_req_action]
3495 3495
             );
3496 3496
         }
3497 3497
         if (post_type_supports('espresso_attendees', 'comments')) {
@@ -3499,7 +3499,7 @@  discard block
 block discarded – undo
3499 3499
                 'commentsdiv',
3500 3500
                 esc_html__('Notes on the Contact', 'event_espresso'),
3501 3501
                 'post_comment_meta_box',
3502
-                $this->_cpt_routes[ $this->_req_action ],
3502
+                $this->_cpt_routes[$this->_req_action],
3503 3503
                 'normal',
3504 3504
                 'core'
3505 3505
             );
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
             'attendee_contact_info',
3509 3509
             esc_html__('Contact Info', 'event_espresso'),
3510 3510
             [$this, 'attendee_contact_info'],
3511
-            $this->_cpt_routes[ $this->_req_action ],
3511
+            $this->_cpt_routes[$this->_req_action],
3512 3512
             'side',
3513 3513
             'core'
3514 3514
         );
@@ -3516,7 +3516,7 @@  discard block
 block discarded – undo
3516 3516
             'attendee_details_address',
3517 3517
             esc_html__('Address Details', 'event_espresso'),
3518 3518
             [$this, 'attendee_address_details'],
3519
-            $this->_cpt_routes[ $this->_req_action ],
3519
+            $this->_cpt_routes[$this->_req_action],
3520 3520
             'normal',
3521 3521
             'core'
3522 3522
         );
@@ -3524,7 +3524,7 @@  discard block
 block discarded – undo
3524 3524
             'attendee_registrations',
3525 3525
             esc_html__('Registrations for this Contact', 'event_espresso'),
3526 3526
             [$this, 'attendee_registrations_meta_box'],
3527
-            $this->_cpt_routes[ $this->_req_action ]
3527
+            $this->_cpt_routes[$this->_req_action]
3528 3528
         );
3529 3529
     }
3530 3530
 
@@ -3623,7 +3623,7 @@  discard block
 block discarded – undo
3623 3623
                 ]
3624 3624
             )
3625 3625
         );
3626
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3626
+        $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3627 3627
         EEH_Template::display_template($template, $this->_template_args);
3628 3628
     }
3629 3629
 
@@ -3644,7 +3644,7 @@  discard block
 block discarded – undo
3644 3644
     {
3645 3645
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3646 3646
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3647
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3647
+        $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3648 3648
         EEH_Template::display_template($template, $this->_template_args);
3649 3649
     }
3650 3650
 
@@ -3659,7 +3659,7 @@  discard block
 block discarded – undo
3659 3659
     public function after_title_form_fields($post)
3660 3660
     {
3661 3661
         if ($post->post_type === 'espresso_attendees') {
3662
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3662
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3663 3663
             $template_args['attendee'] = $this->_cpt_model_obj;
3664 3664
             EEH_Template::display_template($template, $template_args);
3665 3665
         }
@@ -3688,7 +3688,7 @@  discard block
 block discarded – undo
3688 3688
             // cycle thru checkboxes
3689 3689
             foreach ($ATT_IDs as $ATT_ID) {
3690 3690
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3691
-                if (! $updated) {
3691
+                if ( ! $updated) {
3692 3692
                     $success = 0;
3693 3693
                 }
3694 3694
             }
Please login to merge, or discard this patch.