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