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