Completed
Branch BUG/remove-fatal-url-checkins (b957cf)
by
unknown
43:17 queued 34:59
created
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 1 patch
Indentation   +1202 added lines, -1202 removed lines patch added patch discarded remove patch
@@ -16,1259 +16,1259 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * This is used to hold the reports template data which is setup early in the request.
21
-     *
22
-     * @type array
23
-     */
24
-    protected $_reports_template_data = array();
19
+	/**
20
+	 * This is used to hold the reports template data which is setup early in the request.
21
+	 *
22
+	 * @type array
23
+	 */
24
+	protected $_reports_template_data = array();
25 25
 
26 26
 
27
-    /**
28
-     * Extend_Registrations_Admin_Page constructor.
29
-     *
30
-     * @param bool $routing
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
-        }
40
-    }
27
+	/**
28
+	 * Extend_Registrations_Admin_Page constructor.
29
+	 *
30
+	 * @param bool $routing
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
+		}
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Extending page configuration.
45
-     */
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        $new_page_routes = array(
53
-            'reports'                      => array(
54
-                'func'       => '_registration_reports',
55
-                'capability' => 'ee_read_registrations',
56
-            ),
57
-            'registration_checkins'        => array(
58
-                'func'       => '_registration_checkin_list_table',
59
-                'capability' => 'ee_read_checkins',
60
-            ),
61
-            'newsletter_selected_send'     => array(
62
-                'func'       => '_newsletter_selected_send',
63
-                'noheader'   => true,
64
-                'capability' => 'ee_send_message',
65
-            ),
66
-            'delete_checkin_rows'          => array(
67
-                'func'       => '_delete_checkin_rows',
68
-                'noheader'   => true,
69
-                'capability' => 'ee_delete_checkins',
70
-            ),
71
-            'delete_checkin_row'           => array(
72
-                'func'       => '_delete_checkin_row',
73
-                'noheader'   => true,
74
-                'capability' => 'ee_delete_checkin',
75
-                'obj_id'     => $reg_id,
76
-            ),
77
-            'toggle_checkin_status'        => array(
78
-                'func'       => '_toggle_checkin_status',
79
-                'noheader'   => true,
80
-                'capability' => 'ee_edit_checkin',
81
-                'obj_id'     => $reg_id,
82
-            ),
83
-            'toggle_checkin_status_bulk'   => array(
84
-                'func'       => '_toggle_checkin_status',
85
-                'noheader'   => true,
86
-                'capability' => 'ee_edit_checkins',
87
-            ),
88
-            'event_registrations'          => array(
89
-                'func'       => '_event_registrations_list_table',
90
-                'capability' => 'ee_read_checkins',
91
-            ),
92
-            'registrations_checkin_report' => array(
93
-                'func'       => '_registrations_checkin_report',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_read_registrations',
96
-            ),
97
-        );
98
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
-        $new_page_config = array(
100
-            'reports'               => array(
101
-                'nav'           => array(
102
-                    'label' => esc_html__('Reports', 'event_espresso'),
103
-                    'order' => 30,
104
-                ),
105
-                'help_tabs'     => array(
106
-                    'registrations_reports_help_tab' => array(
107
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
-                        'filename' => 'registrations_reports',
109
-                    ),
110
-                ),
111
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
-                'require_nonce' => false,
113
-            ),
114
-            'event_registrations'   => array(
115
-                'nav'           => array(
116
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
-                    'order'      => 10,
118
-                    'persistent' => true,
119
-                ),
120
-                'help_tabs'     => array(
121
-                    'registrations_event_checkin_help_tab'                       => array(
122
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
-                        'filename' => 'registrations_event_checkin',
124
-                    ),
125
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
126
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
-                        'filename' => 'registrations_event_checkin_table_column_headings',
128
-                    ),
129
-                    'registrations_event_checkin_filters_help_tab'               => array(
130
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
-                        'filename' => 'registrations_event_checkin_filters',
132
-                    ),
133
-                    'registrations_event_checkin_views_help_tab'                 => array(
134
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
-                        'filename' => 'registrations_event_checkin_views',
136
-                    ),
137
-                    'registrations_event_checkin_other_help_tab'                 => array(
138
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
-                        'filename' => 'registrations_event_checkin_other',
140
-                    ),
141
-                ),
142
-                'help_tour'     => array('Event_Checkin_Help_Tour'),
143
-                'qtips'         => array('Registration_List_Table_Tips'),
144
-                'list_table'    => 'EE_Event_Registrations_List_Table',
145
-                'metaboxes'     => array(),
146
-                'require_nonce' => false,
147
-            ),
148
-            'registration_checkins' => array(
149
-                'nav'           => array(
150
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
151
-                    'order'      => 15,
152
-                    'persistent' => false,
153
-                    'url'        => '',
154
-                ),
155
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
156
-                // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
157
-                'metaboxes'     => array(),
158
-                'require_nonce' => false,
159
-            ),
160
-        );
161
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
162
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
163
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
164
-    }
43
+	/**
44
+	 * Extending page configuration.
45
+	 */
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		$new_page_routes = array(
53
+			'reports'                      => array(
54
+				'func'       => '_registration_reports',
55
+				'capability' => 'ee_read_registrations',
56
+			),
57
+			'registration_checkins'        => array(
58
+				'func'       => '_registration_checkin_list_table',
59
+				'capability' => 'ee_read_checkins',
60
+			),
61
+			'newsletter_selected_send'     => array(
62
+				'func'       => '_newsletter_selected_send',
63
+				'noheader'   => true,
64
+				'capability' => 'ee_send_message',
65
+			),
66
+			'delete_checkin_rows'          => array(
67
+				'func'       => '_delete_checkin_rows',
68
+				'noheader'   => true,
69
+				'capability' => 'ee_delete_checkins',
70
+			),
71
+			'delete_checkin_row'           => array(
72
+				'func'       => '_delete_checkin_row',
73
+				'noheader'   => true,
74
+				'capability' => 'ee_delete_checkin',
75
+				'obj_id'     => $reg_id,
76
+			),
77
+			'toggle_checkin_status'        => array(
78
+				'func'       => '_toggle_checkin_status',
79
+				'noheader'   => true,
80
+				'capability' => 'ee_edit_checkin',
81
+				'obj_id'     => $reg_id,
82
+			),
83
+			'toggle_checkin_status_bulk'   => array(
84
+				'func'       => '_toggle_checkin_status',
85
+				'noheader'   => true,
86
+				'capability' => 'ee_edit_checkins',
87
+			),
88
+			'event_registrations'          => array(
89
+				'func'       => '_event_registrations_list_table',
90
+				'capability' => 'ee_read_checkins',
91
+			),
92
+			'registrations_checkin_report' => array(
93
+				'func'       => '_registrations_checkin_report',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_read_registrations',
96
+			),
97
+		);
98
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
+		$new_page_config = array(
100
+			'reports'               => array(
101
+				'nav'           => array(
102
+					'label' => esc_html__('Reports', 'event_espresso'),
103
+					'order' => 30,
104
+				),
105
+				'help_tabs'     => array(
106
+					'registrations_reports_help_tab' => array(
107
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
+						'filename' => 'registrations_reports',
109
+					),
110
+				),
111
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
+				'require_nonce' => false,
113
+			),
114
+			'event_registrations'   => array(
115
+				'nav'           => array(
116
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
+					'order'      => 10,
118
+					'persistent' => true,
119
+				),
120
+				'help_tabs'     => array(
121
+					'registrations_event_checkin_help_tab'                       => array(
122
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
+						'filename' => 'registrations_event_checkin',
124
+					),
125
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
126
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
+						'filename' => 'registrations_event_checkin_table_column_headings',
128
+					),
129
+					'registrations_event_checkin_filters_help_tab'               => array(
130
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
+						'filename' => 'registrations_event_checkin_filters',
132
+					),
133
+					'registrations_event_checkin_views_help_tab'                 => array(
134
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
+						'filename' => 'registrations_event_checkin_views',
136
+					),
137
+					'registrations_event_checkin_other_help_tab'                 => array(
138
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
+						'filename' => 'registrations_event_checkin_other',
140
+					),
141
+				),
142
+				'help_tour'     => array('Event_Checkin_Help_Tour'),
143
+				'qtips'         => array('Registration_List_Table_Tips'),
144
+				'list_table'    => 'EE_Event_Registrations_List_Table',
145
+				'metaboxes'     => array(),
146
+				'require_nonce' => false,
147
+			),
148
+			'registration_checkins' => array(
149
+				'nav'           => array(
150
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
151
+					'order'      => 15,
152
+					'persistent' => false,
153
+					'url'        => '',
154
+				),
155
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
156
+				// 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
157
+				'metaboxes'     => array(),
158
+				'require_nonce' => false,
159
+			),
160
+		);
161
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
162
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
163
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
164
+	}
165 165
 
166 166
 
167
-    /**
168
-     * Ajax hooks for all routes in this page.
169
-     */
170
-    protected function _ajax_hooks()
171
-    {
172
-        parent::_ajax_hooks();
173
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
174
-    }
167
+	/**
168
+	 * Ajax hooks for all routes in this page.
169
+	 */
170
+	protected function _ajax_hooks()
171
+	{
172
+		parent::_ajax_hooks();
173
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * Global scripts for all routes in this page.
179
-     */
180
-    public function load_scripts_styles()
181
-    {
182
-        parent::load_scripts_styles();
183
-        // if newsletter message type is active then let's add filter and load js for it.
184
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
185
-            // enqueue newsletter js
186
-            wp_enqueue_script(
187
-                'ee-newsletter-trigger',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
189
-                array('ee-dialog'),
190
-                EVENT_ESPRESSO_VERSION,
191
-                true
192
-            );
193
-            wp_enqueue_style(
194
-                'ee-newsletter-trigger-css',
195
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
196
-                array(),
197
-                EVENT_ESPRESSO_VERSION
198
-            );
199
-            // hook in buttons for newsletter message type trigger.
200
-            add_action(
201
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
202
-                array($this, 'add_newsletter_action_buttons'),
203
-                10
204
-            );
205
-        }
206
-    }
177
+	/**
178
+	 * Global scripts for all routes in this page.
179
+	 */
180
+	public function load_scripts_styles()
181
+	{
182
+		parent::load_scripts_styles();
183
+		// if newsletter message type is active then let's add filter and load js for it.
184
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
185
+			// enqueue newsletter js
186
+			wp_enqueue_script(
187
+				'ee-newsletter-trigger',
188
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
189
+				array('ee-dialog'),
190
+				EVENT_ESPRESSO_VERSION,
191
+				true
192
+			);
193
+			wp_enqueue_style(
194
+				'ee-newsletter-trigger-css',
195
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
196
+				array(),
197
+				EVENT_ESPRESSO_VERSION
198
+			);
199
+			// hook in buttons for newsletter message type trigger.
200
+			add_action(
201
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
202
+				array($this, 'add_newsletter_action_buttons'),
203
+				10
204
+			);
205
+		}
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * Scripts and styles for just the reports route.
211
-     */
212
-    public function load_scripts_styles_reports()
213
-    {
214
-        wp_register_script(
215
-            'ee-reg-reports-js',
216
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
217
-            array('google-charts'),
218
-            EVENT_ESPRESSO_VERSION,
219
-            true
220
-        );
221
-        wp_enqueue_script('ee-reg-reports-js');
222
-        $this->_registration_reports_js_setup();
223
-    }
209
+	/**
210
+	 * Scripts and styles for just the reports route.
211
+	 */
212
+	public function load_scripts_styles_reports()
213
+	{
214
+		wp_register_script(
215
+			'ee-reg-reports-js',
216
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
217
+			array('google-charts'),
218
+			EVENT_ESPRESSO_VERSION,
219
+			true
220
+		);
221
+		wp_enqueue_script('ee-reg-reports-js');
222
+		$this->_registration_reports_js_setup();
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * Register screen options for event_registrations route.
228
-     */
229
-    protected function _add_screen_options_event_registrations()
230
-    {
231
-        $this->_per_page_screen_option();
232
-    }
226
+	/**
227
+	 * Register screen options for event_registrations route.
228
+	 */
229
+	protected function _add_screen_options_event_registrations()
230
+	{
231
+		$this->_per_page_screen_option();
232
+	}
233 233
 
234 234
 
235
-    /**
236
-     * Register screen options for registration_checkins route
237
-     */
238
-    protected function _add_screen_options_registration_checkins()
239
-    {
240
-        $page_title = $this->_admin_page_title;
241
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
242
-        $this->_per_page_screen_option();
243
-        $this->_admin_page_title = $page_title;
244
-    }
235
+	/**
236
+	 * Register screen options for registration_checkins route
237
+	 */
238
+	protected function _add_screen_options_registration_checkins()
239
+	{
240
+		$page_title = $this->_admin_page_title;
241
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
242
+		$this->_per_page_screen_option();
243
+		$this->_admin_page_title = $page_title;
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * Set views property for event_registrations route.
249
-     */
250
-    protected function _set_list_table_views_event_registrations()
251
-    {
252
-        $this->_views = array(
253
-            'all' => array(
254
-                'slug'        => 'all',
255
-                'label'       => esc_html__('All', 'event_espresso'),
256
-                'count'       => 0,
257
-                'bulk_action' => ! isset($this->_req_data['event_id'])
258
-                    ? array()
259
-                    : array(
260
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
261
-                    ),
262
-            ),
263
-        );
264
-    }
247
+	/**
248
+	 * Set views property for event_registrations route.
249
+	 */
250
+	protected function _set_list_table_views_event_registrations()
251
+	{
252
+		$this->_views = array(
253
+			'all' => array(
254
+				'slug'        => 'all',
255
+				'label'       => esc_html__('All', 'event_espresso'),
256
+				'count'       => 0,
257
+				'bulk_action' => ! isset($this->_req_data['event_id'])
258
+					? array()
259
+					: array(
260
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
261
+					),
262
+			),
263
+		);
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * Set views property for registration_checkins route.
269
-     */
270
-    protected function _set_list_table_views_registration_checkins()
271
-    {
272
-        $this->_views = array(
273
-            'all' => array(
274
-                'slug'        => 'all',
275
-                'label'       => esc_html__('All', 'event_espresso'),
276
-                'count'       => 0,
277
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
278
-            ),
279
-        );
280
-    }
267
+	/**
268
+	 * Set views property for registration_checkins route.
269
+	 */
270
+	protected function _set_list_table_views_registration_checkins()
271
+	{
272
+		$this->_views = array(
273
+			'all' => array(
274
+				'slug'        => 'all',
275
+				'label'       => esc_html__('All', 'event_espresso'),
276
+				'count'       => 0,
277
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
278
+			),
279
+		);
280
+	}
281 281
 
282 282
 
283
-    /**
284
-     * callback for ajax action.
285
-     *
286
-     * @since 4.3.0
287
-     * @return void (JSON)
288
-     * @throws EE_Error
289
-     * @throws InvalidArgumentException
290
-     * @throws InvalidDataTypeException
291
-     * @throws InvalidInterfaceException
292
-     */
293
-    public function get_newsletter_form_content()
294
-    {
295
-        // do a nonce check cause we're not coming in from an normal route here.
296
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
297
-            $this->_req_data['get_newsletter_form_content_nonce']
298
-        ) : '';
299
-        $nonce_ref = 'get_newsletter_form_content_nonce';
300
-        $this->_verify_nonce($nonce, $nonce_ref);
301
-        // let's get the mtp for the incoming MTP_ ID
302
-        if (! isset($this->_req_data['GRP_ID'])) {
303
-            EE_Error::add_error(
304
-                esc_html__(
305
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
306
-                    'event_espresso'
307
-                ),
308
-                __FILE__,
309
-                __FUNCTION__,
310
-                __LINE__
311
-            );
312
-            $this->_template_args['success'] = false;
313
-            $this->_template_args['error'] = true;
314
-            $this->_return_json();
315
-        }
316
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
317
-        if (! $MTPG instanceof EE_Message_Template_Group) {
318
-            EE_Error::add_error(
319
-                sprintf(
320
-                    esc_html__(
321
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
322
-                        'event_espresso'
323
-                    ),
324
-                    $this->_req_data['GRP_ID']
325
-                ),
326
-                __FILE__,
327
-                __FUNCTION__,
328
-                __LINE__
329
-            );
330
-            $this->_template_args['success'] = false;
331
-            $this->_template_args['error'] = true;
332
-            $this->_return_json();
333
-        }
334
-        $MTPs = $MTPG->context_templates();
335
-        $MTPs = $MTPs['attendee'];
336
-        $template_fields = array();
337
-        /** @var EE_Message_Template $MTP */
338
-        foreach ($MTPs as $MTP) {
339
-            $field = $MTP->get('MTP_template_field');
340
-            if ($field === 'content') {
341
-                $content = $MTP->get('MTP_content');
342
-                if (! empty($content['newsletter_content'])) {
343
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
344
-                }
345
-                continue;
346
-            }
347
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
348
-        }
349
-        $this->_template_args['success'] = true;
350
-        $this->_template_args['error'] = false;
351
-        $this->_template_args['data'] = array(
352
-            'batch_message_from'    => isset($template_fields['from'])
353
-                ? $template_fields['from']
354
-                : '',
355
-            'batch_message_subject' => isset($template_fields['subject'])
356
-                ? $template_fields['subject']
357
-                : '',
358
-            'batch_message_content' => isset($template_fields['newsletter_content'])
359
-                ? $template_fields['newsletter_content']
360
-                : '',
361
-        );
362
-        $this->_return_json();
363
-    }
283
+	/**
284
+	 * callback for ajax action.
285
+	 *
286
+	 * @since 4.3.0
287
+	 * @return void (JSON)
288
+	 * @throws EE_Error
289
+	 * @throws InvalidArgumentException
290
+	 * @throws InvalidDataTypeException
291
+	 * @throws InvalidInterfaceException
292
+	 */
293
+	public function get_newsletter_form_content()
294
+	{
295
+		// do a nonce check cause we're not coming in from an normal route here.
296
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
297
+			$this->_req_data['get_newsletter_form_content_nonce']
298
+		) : '';
299
+		$nonce_ref = 'get_newsletter_form_content_nonce';
300
+		$this->_verify_nonce($nonce, $nonce_ref);
301
+		// let's get the mtp for the incoming MTP_ ID
302
+		if (! isset($this->_req_data['GRP_ID'])) {
303
+			EE_Error::add_error(
304
+				esc_html__(
305
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
306
+					'event_espresso'
307
+				),
308
+				__FILE__,
309
+				__FUNCTION__,
310
+				__LINE__
311
+			);
312
+			$this->_template_args['success'] = false;
313
+			$this->_template_args['error'] = true;
314
+			$this->_return_json();
315
+		}
316
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
317
+		if (! $MTPG instanceof EE_Message_Template_Group) {
318
+			EE_Error::add_error(
319
+				sprintf(
320
+					esc_html__(
321
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
322
+						'event_espresso'
323
+					),
324
+					$this->_req_data['GRP_ID']
325
+				),
326
+				__FILE__,
327
+				__FUNCTION__,
328
+				__LINE__
329
+			);
330
+			$this->_template_args['success'] = false;
331
+			$this->_template_args['error'] = true;
332
+			$this->_return_json();
333
+		}
334
+		$MTPs = $MTPG->context_templates();
335
+		$MTPs = $MTPs['attendee'];
336
+		$template_fields = array();
337
+		/** @var EE_Message_Template $MTP */
338
+		foreach ($MTPs as $MTP) {
339
+			$field = $MTP->get('MTP_template_field');
340
+			if ($field === 'content') {
341
+				$content = $MTP->get('MTP_content');
342
+				if (! empty($content['newsletter_content'])) {
343
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
344
+				}
345
+				continue;
346
+			}
347
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
348
+		}
349
+		$this->_template_args['success'] = true;
350
+		$this->_template_args['error'] = false;
351
+		$this->_template_args['data'] = array(
352
+			'batch_message_from'    => isset($template_fields['from'])
353
+				? $template_fields['from']
354
+				: '',
355
+			'batch_message_subject' => isset($template_fields['subject'])
356
+				? $template_fields['subject']
357
+				: '',
358
+			'batch_message_content' => isset($template_fields['newsletter_content'])
359
+				? $template_fields['newsletter_content']
360
+				: '',
361
+		);
362
+		$this->_return_json();
363
+	}
364 364
 
365 365
 
366
-    /**
367
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
368
-     *
369
-     * @since 4.3.0
370
-     * @param EE_Admin_List_Table $list_table
371
-     * @return void
372
-     * @throws InvalidArgumentException
373
-     * @throws InvalidDataTypeException
374
-     * @throws InvalidInterfaceException
375
-     */
376
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
377
-    {
378
-        if (! EE_Registry::instance()->CAP->current_user_can(
379
-            'ee_send_message',
380
-            'espresso_registrations_newsletter_selected_send'
381
-        )
382
-        ) {
383
-            return;
384
-        }
385
-        $routes_to_add_to = array(
386
-            'contact_list',
387
-            'event_registrations',
388
-            'default',
389
-        );
390
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
391
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
392
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
393
-            ) {
394
-                echo '';
395
-            } else {
396
-                $button_text = sprintf(
397
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
398
-                    '<span class="send-selected-newsletter-count">0</span>'
399
-                );
400
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
401
-                     . '<span class="dashicons dashicons-email "></span>'
402
-                     . $button_text
403
-                     . '</button>';
404
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
405
-            }
406
-        }
407
-    }
366
+	/**
367
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
368
+	 *
369
+	 * @since 4.3.0
370
+	 * @param EE_Admin_List_Table $list_table
371
+	 * @return void
372
+	 * @throws InvalidArgumentException
373
+	 * @throws InvalidDataTypeException
374
+	 * @throws InvalidInterfaceException
375
+	 */
376
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
377
+	{
378
+		if (! EE_Registry::instance()->CAP->current_user_can(
379
+			'ee_send_message',
380
+			'espresso_registrations_newsletter_selected_send'
381
+		)
382
+		) {
383
+			return;
384
+		}
385
+		$routes_to_add_to = array(
386
+			'contact_list',
387
+			'event_registrations',
388
+			'default',
389
+		);
390
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
391
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
392
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
393
+			) {
394
+				echo '';
395
+			} else {
396
+				$button_text = sprintf(
397
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
398
+					'<span class="send-selected-newsletter-count">0</span>'
399
+				);
400
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
401
+					 . '<span class="dashicons dashicons-email "></span>'
402
+					 . $button_text
403
+					 . '</button>';
404
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
405
+			}
406
+		}
407
+	}
408 408
 
409 409
 
410
-    /**
411
-     * @throws DomainException
412
-     * @throws EE_Error
413
-     * @throws InvalidArgumentException
414
-     * @throws InvalidDataTypeException
415
-     * @throws InvalidInterfaceException
416
-     */
417
-    public function newsletter_send_form_skeleton()
418
-    {
419
-        $list_table = $this->_list_table_object;
420
-        $codes = array();
421
-        // need to templates for the newsletter message type for the template selector.
422
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
423
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
424
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
425
-        );
426
-        foreach ($mtps as $mtp) {
427
-            $name = $mtp->name();
428
-            $values[] = array(
429
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
430
-                'id'   => $mtp->ID(),
431
-            );
432
-        }
433
-        // need to get a list of shortcodes that are available for the newsletter message type.
434
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
435
-            'newsletter',
436
-            'email',
437
-            array(),
438
-            'attendee',
439
-            false
440
-        );
441
-        foreach ($shortcodes as $field => $shortcode_array) {
442
-            $available_shortcodes = array();
443
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
444
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
445
-                    ? 'content'
446
-                    : $field;
447
-                $field_id = 'batch-message-' . strtolower($field_id);
448
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
449
-                                          . $shortcode
450
-                                          . '" data-linked-input-id="' . $field_id . '">'
451
-                                          . $shortcode
452
-                                          . '</span>';
453
-            }
454
-            $codes[ $field ] = implode(', ', $available_shortcodes);
455
-        }
456
-        $shortcodes = $codes;
457
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
458
-        $form_template_args = array(
459
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
460
-            'form_route'        => 'newsletter_selected_send',
461
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
462
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
463
-            'redirect_back_to'  => $this->_req_action,
464
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
465
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
466
-            'shortcodes'        => $shortcodes,
467
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
468
-        );
469
-        EEH_Template::display_template($form_template, $form_template_args);
470
-    }
410
+	/**
411
+	 * @throws DomainException
412
+	 * @throws EE_Error
413
+	 * @throws InvalidArgumentException
414
+	 * @throws InvalidDataTypeException
415
+	 * @throws InvalidInterfaceException
416
+	 */
417
+	public function newsletter_send_form_skeleton()
418
+	{
419
+		$list_table = $this->_list_table_object;
420
+		$codes = array();
421
+		// need to templates for the newsletter message type for the template selector.
422
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
423
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
424
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
425
+		);
426
+		foreach ($mtps as $mtp) {
427
+			$name = $mtp->name();
428
+			$values[] = array(
429
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
430
+				'id'   => $mtp->ID(),
431
+			);
432
+		}
433
+		// need to get a list of shortcodes that are available for the newsletter message type.
434
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
435
+			'newsletter',
436
+			'email',
437
+			array(),
438
+			'attendee',
439
+			false
440
+		);
441
+		foreach ($shortcodes as $field => $shortcode_array) {
442
+			$available_shortcodes = array();
443
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
444
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
445
+					? 'content'
446
+					: $field;
447
+				$field_id = 'batch-message-' . strtolower($field_id);
448
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
449
+										  . $shortcode
450
+										  . '" data-linked-input-id="' . $field_id . '">'
451
+										  . $shortcode
452
+										  . '</span>';
453
+			}
454
+			$codes[ $field ] = implode(', ', $available_shortcodes);
455
+		}
456
+		$shortcodes = $codes;
457
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
458
+		$form_template_args = array(
459
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
460
+			'form_route'        => 'newsletter_selected_send',
461
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
462
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
463
+			'redirect_back_to'  => $this->_req_action,
464
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
465
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
466
+			'shortcodes'        => $shortcodes,
467
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
468
+		);
469
+		EEH_Template::display_template($form_template, $form_template_args);
470
+	}
471 471
 
472 472
 
473
-    /**
474
-     * Handles sending selected registrations/contacts a newsletter.
475
-     *
476
-     * @since  4.3.0
477
-     * @return void
478
-     * @throws EE_Error
479
-     * @throws InvalidArgumentException
480
-     * @throws InvalidDataTypeException
481
-     * @throws InvalidInterfaceException
482
-     */
483
-    protected function _newsletter_selected_send()
484
-    {
485
-        $success = true;
486
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
487
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
488
-            EE_Error::add_error(
489
-                esc_html__(
490
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
491
-                    'event_espresso'
492
-                ),
493
-                __FILE__,
494
-                __FUNCTION__,
495
-                __LINE__
496
-            );
497
-            $success = false;
498
-        }
499
-        if ($success) {
500
-            // update Message template in case there are any changes
501
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
502
-                $this->_req_data['newsletter_mtp_selected']
503
-            );
504
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
505
-                ? $Message_Template_Group->context_templates()
506
-                : array();
507
-            if (empty($Message_Templates)) {
508
-                EE_Error::add_error(
509
-                    esc_html__(
510
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
511
-                        'event_espresso'
512
-                    ),
513
-                    __FILE__,
514
-                    __FUNCTION__,
515
-                    __LINE__
516
-                );
517
-            }
518
-            // let's just update the specific fields
519
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
520
-                if ($Message_Template instanceof EE_Message_Template) {
521
-                    $field = $Message_Template->get('MTP_template_field');
522
-                    $content = $Message_Template->get('MTP_content');
523
-                    $new_content = $content;
524
-                    switch ($field) {
525
-                        case 'from':
526
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
527
-                                ? $this->_req_data['batch_message']['from']
528
-                                : $content;
529
-                            break;
530
-                        case 'subject':
531
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
532
-                                ? $this->_req_data['batch_message']['subject']
533
-                                : $content;
534
-                            break;
535
-                        case 'content':
536
-                            $new_content = $content;
537
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
538
-                                ? $this->_req_data['batch_message']['content']
539
-                                : $content['newsletter_content'];
540
-                            break;
541
-                        default:
542
-                            // continue the foreach loop, we don't want to set $new_content nor save.
543
-                            continue 2;
544
-                    }
545
-                    $Message_Template->set('MTP_content', $new_content);
546
-                    $Message_Template->save();
547
-                }
548
-            }
549
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
550
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
551
-                ? $this->_req_data['batch_message']['id_type']
552
-                : 'registration';
553
-            // id_type will affect how we assemble the ids.
554
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
555
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
556
-                : array();
557
-            $registrations_used_for_contact_data = array();
558
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
559
-            switch ($id_type) {
560
-                case 'registration':
561
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
562
-                        array(
563
-                            array(
564
-                                'REG_ID' => array('IN', $ids),
565
-                            ),
566
-                        )
567
-                    );
568
-                    break;
569
-                case 'contact':
570
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
571
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
572
-                                                                               $ids
573
-                                                                           );
574
-                    break;
575
-            }
576
-            do_action_ref_array(
577
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
-                array(
579
-                    $registrations_used_for_contact_data,
580
-                    $Message_Template_Group->ID(),
581
-                )
582
-            );
583
-            // kept for backward compat, internally we no longer use this action.
584
-            // @deprecated 4.8.36.rc.002
585
-            $contacts = $id_type === 'registration'
586
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
-            do_action_ref_array(
589
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
-                array(
591
-                    $contacts,
592
-                    $Message_Template_Group->ID(),
593
-                )
594
-            );
595
-        }
596
-        $query_args = array(
597
-            'action' => ! empty($this->_req_data['redirect_back_to'])
598
-                ? $this->_req_data['redirect_back_to']
599
-                : 'default',
600
-        );
601
-        $this->_redirect_after_action(false, '', '', $query_args, true);
602
-    }
473
+	/**
474
+	 * Handles sending selected registrations/contacts a newsletter.
475
+	 *
476
+	 * @since  4.3.0
477
+	 * @return void
478
+	 * @throws EE_Error
479
+	 * @throws InvalidArgumentException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws InvalidInterfaceException
482
+	 */
483
+	protected function _newsletter_selected_send()
484
+	{
485
+		$success = true;
486
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
487
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
488
+			EE_Error::add_error(
489
+				esc_html__(
490
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
491
+					'event_espresso'
492
+				),
493
+				__FILE__,
494
+				__FUNCTION__,
495
+				__LINE__
496
+			);
497
+			$success = false;
498
+		}
499
+		if ($success) {
500
+			// update Message template in case there are any changes
501
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
502
+				$this->_req_data['newsletter_mtp_selected']
503
+			);
504
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
505
+				? $Message_Template_Group->context_templates()
506
+				: array();
507
+			if (empty($Message_Templates)) {
508
+				EE_Error::add_error(
509
+					esc_html__(
510
+						'Unable to retrieve message template fields from the db. Messages not sent.',
511
+						'event_espresso'
512
+					),
513
+					__FILE__,
514
+					__FUNCTION__,
515
+					__LINE__
516
+				);
517
+			}
518
+			// let's just update the specific fields
519
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
520
+				if ($Message_Template instanceof EE_Message_Template) {
521
+					$field = $Message_Template->get('MTP_template_field');
522
+					$content = $Message_Template->get('MTP_content');
523
+					$new_content = $content;
524
+					switch ($field) {
525
+						case 'from':
526
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
527
+								? $this->_req_data['batch_message']['from']
528
+								: $content;
529
+							break;
530
+						case 'subject':
531
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
532
+								? $this->_req_data['batch_message']['subject']
533
+								: $content;
534
+							break;
535
+						case 'content':
536
+							$new_content = $content;
537
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
538
+								? $this->_req_data['batch_message']['content']
539
+								: $content['newsletter_content'];
540
+							break;
541
+						default:
542
+							// continue the foreach loop, we don't want to set $new_content nor save.
543
+							continue 2;
544
+					}
545
+					$Message_Template->set('MTP_content', $new_content);
546
+					$Message_Template->save();
547
+				}
548
+			}
549
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
550
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
551
+				? $this->_req_data['batch_message']['id_type']
552
+				: 'registration';
553
+			// id_type will affect how we assemble the ids.
554
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
555
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
556
+				: array();
557
+			$registrations_used_for_contact_data = array();
558
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
559
+			switch ($id_type) {
560
+				case 'registration':
561
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
562
+						array(
563
+							array(
564
+								'REG_ID' => array('IN', $ids),
565
+							),
566
+						)
567
+					);
568
+					break;
569
+				case 'contact':
570
+					$registrations_used_for_contact_data = EEM_Registration::instance()
571
+																		   ->get_latest_registration_for_each_of_given_contacts(
572
+																			   $ids
573
+																		   );
574
+					break;
575
+			}
576
+			do_action_ref_array(
577
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
+				array(
579
+					$registrations_used_for_contact_data,
580
+					$Message_Template_Group->ID(),
581
+				)
582
+			);
583
+			// kept for backward compat, internally we no longer use this action.
584
+			// @deprecated 4.8.36.rc.002
585
+			$contacts = $id_type === 'registration'
586
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
+			do_action_ref_array(
589
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
+				array(
591
+					$contacts,
592
+					$Message_Template_Group->ID(),
593
+				)
594
+			);
595
+		}
596
+		$query_args = array(
597
+			'action' => ! empty($this->_req_data['redirect_back_to'])
598
+				? $this->_req_data['redirect_back_to']
599
+				: 'default',
600
+		);
601
+		$this->_redirect_after_action(false, '', '', $query_args, true);
602
+	}
603 603
 
604 604
 
605
-    /**
606
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
607
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
608
-     */
609
-    protected function _registration_reports_js_setup()
610
-    {
611
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
612
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
613
-    }
605
+	/**
606
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
607
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
608
+	 */
609
+	protected function _registration_reports_js_setup()
610
+	{
611
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
612
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
613
+	}
614 614
 
615 615
 
616
-    /**
617
-     *        generates Business Reports regarding Registrations
618
-     *
619
-     * @access protected
620
-     * @return void
621
-     * @throws DomainException
622
-     */
623
-    protected function _registration_reports()
624
-    {
625
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
626
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
627
-            $template_path,
628
-            $this->_reports_template_data,
629
-            true
630
-        );
631
-        // the final template wrapper
632
-        $this->display_admin_page_with_no_sidebar();
633
-    }
616
+	/**
617
+	 *        generates Business Reports regarding Registrations
618
+	 *
619
+	 * @access protected
620
+	 * @return void
621
+	 * @throws DomainException
622
+	 */
623
+	protected function _registration_reports()
624
+	{
625
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
626
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
627
+			$template_path,
628
+			$this->_reports_template_data,
629
+			true
630
+		);
631
+		// the final template wrapper
632
+		$this->display_admin_page_with_no_sidebar();
633
+	}
634 634
 
635 635
 
636
-    /**
637
-     * Generates Business Report showing total registrations per day.
638
-     *
639
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
640
-     * @return string
641
-     * @throws EE_Error
642
-     * @throws InvalidArgumentException
643
-     * @throws InvalidDataTypeException
644
-     * @throws InvalidInterfaceException
645
-     */
646
-    private function _registrations_per_day_report($period = '-1 month')
647
-    {
648
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
649
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
650
-        $results = (array) $results;
651
-        $regs = array();
652
-        $subtitle = '';
653
-        if ($results) {
654
-            $column_titles = array();
655
-            $tracker = 0;
656
-            foreach ($results as $result) {
657
-                $report_column_values = array();
658
-                foreach ($result as $property_name => $property_value) {
659
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
660
-                        : (int) $property_value;
661
-                    $report_column_values[] = $property_value;
662
-                    if ($tracker === 0) {
663
-                        if ($property_name === 'Registration_REG_date') {
664
-                            $column_titles[] = esc_html__(
665
-                                'Date (only days with registrations are shown)',
666
-                                'event_espresso'
667
-                            );
668
-                        } else {
669
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
670
-                        }
671
-                    }
672
-                }
673
-                $tracker++;
674
-                $regs[] = $report_column_values;
675
-            }
676
-            // make sure the column_titles is pushed to the beginning of the array
677
-            array_unshift($regs, $column_titles);
678
-            // setup the date range.
679
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
680
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
681
-            $ending_date = new DateTime("now", $DateTimeZone);
682
-            $subtitle = sprintf(
683
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
684
-                $beginning_date->format('Y-m-d'),
685
-                $ending_date->format('Y-m-d')
686
-            );
687
-        }
688
-        $report_title = esc_html__('Total Registrations per Day', 'event_espresso');
689
-        $report_params = array(
690
-            'title'     => $report_title,
691
-            'subtitle'  => $subtitle,
692
-            'id'        => $report_ID,
693
-            'regs'      => $regs,
694
-            'noResults' => empty($regs),
695
-            'noRegsMsg' => sprintf(
696
-                esc_html__(
697
-                    '%sThere are currently no registration records in the last month for this report.%s',
698
-                    'event_espresso'
699
-                ),
700
-                '<h2>' . $report_title . '</h2><p>',
701
-                '</p>'
702
-            ),
703
-        );
704
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
705
-        return $report_ID;
706
-    }
636
+	/**
637
+	 * Generates Business Report showing total registrations per day.
638
+	 *
639
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
640
+	 * @return string
641
+	 * @throws EE_Error
642
+	 * @throws InvalidArgumentException
643
+	 * @throws InvalidDataTypeException
644
+	 * @throws InvalidInterfaceException
645
+	 */
646
+	private function _registrations_per_day_report($period = '-1 month')
647
+	{
648
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
649
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
650
+		$results = (array) $results;
651
+		$regs = array();
652
+		$subtitle = '';
653
+		if ($results) {
654
+			$column_titles = array();
655
+			$tracker = 0;
656
+			foreach ($results as $result) {
657
+				$report_column_values = array();
658
+				foreach ($result as $property_name => $property_value) {
659
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
660
+						: (int) $property_value;
661
+					$report_column_values[] = $property_value;
662
+					if ($tracker === 0) {
663
+						if ($property_name === 'Registration_REG_date') {
664
+							$column_titles[] = esc_html__(
665
+								'Date (only days with registrations are shown)',
666
+								'event_espresso'
667
+							);
668
+						} else {
669
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
670
+						}
671
+					}
672
+				}
673
+				$tracker++;
674
+				$regs[] = $report_column_values;
675
+			}
676
+			// make sure the column_titles is pushed to the beginning of the array
677
+			array_unshift($regs, $column_titles);
678
+			// setup the date range.
679
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
680
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
681
+			$ending_date = new DateTime("now", $DateTimeZone);
682
+			$subtitle = sprintf(
683
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
684
+				$beginning_date->format('Y-m-d'),
685
+				$ending_date->format('Y-m-d')
686
+			);
687
+		}
688
+		$report_title = esc_html__('Total Registrations per Day', 'event_espresso');
689
+		$report_params = array(
690
+			'title'     => $report_title,
691
+			'subtitle'  => $subtitle,
692
+			'id'        => $report_ID,
693
+			'regs'      => $regs,
694
+			'noResults' => empty($regs),
695
+			'noRegsMsg' => sprintf(
696
+				esc_html__(
697
+					'%sThere are currently no registration records in the last month for this report.%s',
698
+					'event_espresso'
699
+				),
700
+				'<h2>' . $report_title . '</h2><p>',
701
+				'</p>'
702
+			),
703
+		);
704
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
705
+		return $report_ID;
706
+	}
707 707
 
708 708
 
709
-    /**
710
-     * Generates Business Report showing total registrations per event.
711
-     *
712
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
713
-     * @return string
714
-     * @throws EE_Error
715
-     * @throws InvalidArgumentException
716
-     * @throws InvalidDataTypeException
717
-     * @throws InvalidInterfaceException
718
-     */
719
-    private function _registrations_per_event_report($period = '-1 month')
720
-    {
721
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
722
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
723
-        $results = (array) $results;
724
-        $regs = array();
725
-        $subtitle = '';
726
-        if ($results) {
727
-            $column_titles = array();
728
-            $tracker = 0;
729
-            foreach ($results as $result) {
730
-                $report_column_values = array();
731
-                foreach ($result as $property_name => $property_value) {
732
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
733
-                        $property_value,
734
-                        4,
735
-                        '...'
736
-                    ) : (int) $property_value;
737
-                    $report_column_values[] = $property_value;
738
-                    if ($tracker === 0) {
739
-                        if ($property_name === 'Registration_Event') {
740
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
741
-                        } else {
742
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
743
-                        }
744
-                    }
745
-                }
746
-                $tracker++;
747
-                $regs[] = $report_column_values;
748
-            }
749
-            // make sure the column_titles is pushed to the beginning of the array
750
-            array_unshift($regs, $column_titles);
751
-            // setup the date range.
752
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
753
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
754
-            $ending_date = new DateTime("now", $DateTimeZone);
755
-            $subtitle = sprintf(
756
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
757
-                $beginning_date->format('Y-m-d'),
758
-                $ending_date->format('Y-m-d')
759
-            );
760
-        }
761
-        $report_title = esc_html__('Total Registrations per Event', 'event_espresso');
762
-        $report_params = array(
763
-            'title'     => $report_title,
764
-            'subtitle'  => $subtitle,
765
-            'id'        => $report_ID,
766
-            'regs'      => $regs,
767
-            'noResults' => empty($regs),
768
-            'noRegsMsg' => sprintf(
769
-                esc_html__(
770
-                    '%sThere are currently no registration records in the last month for this report.%s',
771
-                    'event_espresso'
772
-                ),
773
-                '<h2>' . $report_title . '</h2><p>',
774
-                '</p>'
775
-            ),
776
-        );
777
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
778
-        return $report_ID;
779
-    }
709
+	/**
710
+	 * Generates Business Report showing total registrations per event.
711
+	 *
712
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
713
+	 * @return string
714
+	 * @throws EE_Error
715
+	 * @throws InvalidArgumentException
716
+	 * @throws InvalidDataTypeException
717
+	 * @throws InvalidInterfaceException
718
+	 */
719
+	private function _registrations_per_event_report($period = '-1 month')
720
+	{
721
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
722
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
723
+		$results = (array) $results;
724
+		$regs = array();
725
+		$subtitle = '';
726
+		if ($results) {
727
+			$column_titles = array();
728
+			$tracker = 0;
729
+			foreach ($results as $result) {
730
+				$report_column_values = array();
731
+				foreach ($result as $property_name => $property_value) {
732
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
733
+						$property_value,
734
+						4,
735
+						'...'
736
+					) : (int) $property_value;
737
+					$report_column_values[] = $property_value;
738
+					if ($tracker === 0) {
739
+						if ($property_name === 'Registration_Event') {
740
+							$column_titles[] = esc_html__('Event', 'event_espresso');
741
+						} else {
742
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
743
+						}
744
+					}
745
+				}
746
+				$tracker++;
747
+				$regs[] = $report_column_values;
748
+			}
749
+			// make sure the column_titles is pushed to the beginning of the array
750
+			array_unshift($regs, $column_titles);
751
+			// setup the date range.
752
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
753
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
754
+			$ending_date = new DateTime("now", $DateTimeZone);
755
+			$subtitle = sprintf(
756
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
757
+				$beginning_date->format('Y-m-d'),
758
+				$ending_date->format('Y-m-d')
759
+			);
760
+		}
761
+		$report_title = esc_html__('Total Registrations per Event', 'event_espresso');
762
+		$report_params = array(
763
+			'title'     => $report_title,
764
+			'subtitle'  => $subtitle,
765
+			'id'        => $report_ID,
766
+			'regs'      => $regs,
767
+			'noResults' => empty($regs),
768
+			'noRegsMsg' => sprintf(
769
+				esc_html__(
770
+					'%sThere are currently no registration records in the last month for this report.%s',
771
+					'event_espresso'
772
+				),
773
+				'<h2>' . $report_title . '</h2><p>',
774
+				'</p>'
775
+			),
776
+		);
777
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
778
+		return $report_ID;
779
+	}
780 780
 
781 781
 
782
-    /**
783
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
784
-     *
785
-     * @access protected
786
-     * @return void
787
-     * @throws EE_Error
788
-     * @throws InvalidArgumentException
789
-     * @throws InvalidDataTypeException
790
-     * @throws InvalidInterfaceException
791
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
792
-     */
793
-    protected function _registration_checkin_list_table()
794
-    {
795
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
796
-        $reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null;
797
-        /** @var EE_Registration $registration */
798
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
799
-        $attendee = $registration->attendee();
800
-        $this->_admin_page_title .= $this->get_action_link_or_button(
801
-            'new_registration',
802
-            'add-registrant',
803
-            array('event_id' => $registration->event_ID()),
804
-            'add-new-h2'
805
-        );
806
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
807
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
808
-        $legend_items = array(
809
-            'checkin'  => array(
810
-                'class' => $checked_in->cssClasses(),
811
-                'desc'  => $checked_in->legendLabel(),
812
-            ),
813
-            'checkout' => array(
814
-                'class' => $checked_out->cssClasses(),
815
-                'desc'  => $checked_out->legendLabel(),
816
-            ),
817
-        );
818
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
819
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
820
-        /** @var EE_Datetime $datetime */
821
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
822
-        $datetime_label = '';
823
-        if ($datetime instanceof EE_Datetime) {
824
-            $datetime_label = $datetime->get_dtt_display_name(true);
825
-            $datetime_label .= ! empty($datetime_label)
826
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
827
-                : $datetime->get_dtt_display_name();
828
-        }
829
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
830
-            ? EE_Admin_Page::add_query_args_and_nonce(
831
-                array(
832
-                    'action'   => 'event_registrations',
833
-                    'event_id' => $registration->event_ID(),
834
-                    'DTT_ID'   => $dtt_id,
835
-                ),
836
-                $this->_admin_base_url
837
-            )
838
-            : '';
839
-        $datetime_link = ! empty($datetime_link)
840
-            ? '<a href="' . $datetime_link . '">'
841
-              . '<span id="checkin-dtt">'
842
-              . $datetime_label
843
-              . '</span></a>'
844
-            : $datetime_label;
845
-        $attendee_name = $attendee instanceof EE_Attendee
846
-            ? $attendee->full_name()
847
-            : '';
848
-        $attendee_link = $attendee instanceof EE_Attendee
849
-            ? $attendee->get_admin_details_link()
850
-            : '';
851
-        $attendee_link = ! empty($attendee_link)
852
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
853
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
854
-              . '<span id="checkin-attendee-name">'
855
-              . $attendee_name
856
-              . '</span></a>'
857
-            : '';
858
-        $event_link = $registration->event() instanceof EE_Event
859
-            ? $registration->event()->get_admin_details_link()
860
-            : '';
861
-        $event_link = ! empty($event_link)
862
-            ? '<a href="' . $event_link . '"'
863
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
864
-              . '<span id="checkin-event-name">'
865
-              . $registration->event_name()
866
-              . '</span>'
867
-              . '</a>'
868
-            : '';
869
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
870
-            ? '<h2>' . sprintf(
871
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
872
-                $attendee_link,
873
-                $datetime_link,
874
-                $event_link
875
-            ) . '</h2>'
876
-            : '';
877
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
878
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
879
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
880
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
881
-        $this->display_admin_list_table_page_with_no_sidebar();
882
-    }
782
+	/**
783
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
784
+	 *
785
+	 * @access protected
786
+	 * @return void
787
+	 * @throws EE_Error
788
+	 * @throws InvalidArgumentException
789
+	 * @throws InvalidDataTypeException
790
+	 * @throws InvalidInterfaceException
791
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
792
+	 */
793
+	protected function _registration_checkin_list_table()
794
+	{
795
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
796
+		$reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null;
797
+		/** @var EE_Registration $registration */
798
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
799
+		$attendee = $registration->attendee();
800
+		$this->_admin_page_title .= $this->get_action_link_or_button(
801
+			'new_registration',
802
+			'add-registrant',
803
+			array('event_id' => $registration->event_ID()),
804
+			'add-new-h2'
805
+		);
806
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
807
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
808
+		$legend_items = array(
809
+			'checkin'  => array(
810
+				'class' => $checked_in->cssClasses(),
811
+				'desc'  => $checked_in->legendLabel(),
812
+			),
813
+			'checkout' => array(
814
+				'class' => $checked_out->cssClasses(),
815
+				'desc'  => $checked_out->legendLabel(),
816
+			),
817
+		);
818
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
819
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
820
+		/** @var EE_Datetime $datetime */
821
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
822
+		$datetime_label = '';
823
+		if ($datetime instanceof EE_Datetime) {
824
+			$datetime_label = $datetime->get_dtt_display_name(true);
825
+			$datetime_label .= ! empty($datetime_label)
826
+				? ' (' . $datetime->get_dtt_display_name() . ')'
827
+				: $datetime->get_dtt_display_name();
828
+		}
829
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
830
+			? EE_Admin_Page::add_query_args_and_nonce(
831
+				array(
832
+					'action'   => 'event_registrations',
833
+					'event_id' => $registration->event_ID(),
834
+					'DTT_ID'   => $dtt_id,
835
+				),
836
+				$this->_admin_base_url
837
+			)
838
+			: '';
839
+		$datetime_link = ! empty($datetime_link)
840
+			? '<a href="' . $datetime_link . '">'
841
+			  . '<span id="checkin-dtt">'
842
+			  . $datetime_label
843
+			  . '</span></a>'
844
+			: $datetime_label;
845
+		$attendee_name = $attendee instanceof EE_Attendee
846
+			? $attendee->full_name()
847
+			: '';
848
+		$attendee_link = $attendee instanceof EE_Attendee
849
+			? $attendee->get_admin_details_link()
850
+			: '';
851
+		$attendee_link = ! empty($attendee_link)
852
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
853
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
854
+			  . '<span id="checkin-attendee-name">'
855
+			  . $attendee_name
856
+			  . '</span></a>'
857
+			: '';
858
+		$event_link = $registration->event() instanceof EE_Event
859
+			? $registration->event()->get_admin_details_link()
860
+			: '';
861
+		$event_link = ! empty($event_link)
862
+			? '<a href="' . $event_link . '"'
863
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
864
+			  . '<span id="checkin-event-name">'
865
+			  . $registration->event_name()
866
+			  . '</span>'
867
+			  . '</a>'
868
+			: '';
869
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
870
+			? '<h2>' . sprintf(
871
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
872
+				$attendee_link,
873
+				$datetime_link,
874
+				$event_link
875
+			) . '</h2>'
876
+			: '';
877
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
878
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
879
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
880
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
881
+		$this->display_admin_list_table_page_with_no_sidebar();
882
+	}
883 883
 
884 884
 
885
-    /**
886
-     * toggle the Check-in status for the given registration (coming from ajax)
887
-     *
888
-     * @return void (JSON)
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     */
894
-    public function toggle_checkin_status()
895
-    {
896
-        // first make sure we have the necessary data
897
-        if (! isset($this->_req_data['_regid'])) {
898
-            EE_Error::add_error(
899
-                esc_html__(
900
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
901
-                    'event_espresso'
902
-                ),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-            $this->_template_args['success'] = false;
908
-            $this->_template_args['error'] = true;
909
-            $this->_return_json();
910
-        };
911
-        // do a nonce check cause we're not coming in from an normal route here.
912
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
913
-            : '';
914
-        $nonce_ref = 'checkin_nonce';
915
-        $this->_verify_nonce($nonce, $nonce_ref);
916
-        // beautiful! Made it this far so let's get the status.
917
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
918
-        // setup new class to return via ajax
919
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
920
-        $this->_template_args['success'] = true;
921
-        $this->_return_json();
922
-    }
885
+	/**
886
+	 * toggle the Check-in status for the given registration (coming from ajax)
887
+	 *
888
+	 * @return void (JSON)
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 */
894
+	public function toggle_checkin_status()
895
+	{
896
+		// first make sure we have the necessary data
897
+		if (! isset($this->_req_data['_regid'])) {
898
+			EE_Error::add_error(
899
+				esc_html__(
900
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
901
+					'event_espresso'
902
+				),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+			$this->_template_args['success'] = false;
908
+			$this->_template_args['error'] = true;
909
+			$this->_return_json();
910
+		};
911
+		// do a nonce check cause we're not coming in from an normal route here.
912
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
913
+			: '';
914
+		$nonce_ref = 'checkin_nonce';
915
+		$this->_verify_nonce($nonce, $nonce_ref);
916
+		// beautiful! Made it this far so let's get the status.
917
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
918
+		// setup new class to return via ajax
919
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
920
+		$this->_template_args['success'] = true;
921
+		$this->_return_json();
922
+	}
923 923
 
924 924
 
925
-    /**
926
-     * handles toggling the checkin status for the registration,
927
-     *
928
-     * @access protected
929
-     * @return int|void
930
-     * @throws EE_Error
931
-     * @throws InvalidArgumentException
932
-     * @throws InvalidDataTypeException
933
-     * @throws InvalidInterfaceException
934
-     */
935
-    protected function _toggle_checkin_status()
936
-    {
937
-        // first let's get the query args out of the way for the redirect
938
-        $query_args = array(
939
-            'action'   => 'event_registrations',
940
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
941
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
942
-        );
943
-        $new_status = false;
944
-        // bulk action check in toggle
945
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
946
-            // cycle thru checkboxes
947
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
948
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
949
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
950
-            }
951
-        } elseif (isset($this->_req_data['_regid'])) {
952
-            // coming from ajax request
953
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
954
-            $query_args['DTT_ID'] = $DTT_ID;
955
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
956
-        } else {
957
-            EE_Error::add_error(
958
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
959
-                __FILE__,
960
-                __FUNCTION__,
961
-                __LINE__
962
-            );
963
-        }
964
-        if (defined('DOING_AJAX')) {
965
-            return $new_status;
966
-        }
967
-        $this->_redirect_after_action(false, '', '', $query_args, true);
968
-    }
925
+	/**
926
+	 * handles toggling the checkin status for the registration,
927
+	 *
928
+	 * @access protected
929
+	 * @return int|void
930
+	 * @throws EE_Error
931
+	 * @throws InvalidArgumentException
932
+	 * @throws InvalidDataTypeException
933
+	 * @throws InvalidInterfaceException
934
+	 */
935
+	protected function _toggle_checkin_status()
936
+	{
937
+		// first let's get the query args out of the way for the redirect
938
+		$query_args = array(
939
+			'action'   => 'event_registrations',
940
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
941
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
942
+		);
943
+		$new_status = false;
944
+		// bulk action check in toggle
945
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
946
+			// cycle thru checkboxes
947
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
948
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
949
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
950
+			}
951
+		} elseif (isset($this->_req_data['_regid'])) {
952
+			// coming from ajax request
953
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
954
+			$query_args['DTT_ID'] = $DTT_ID;
955
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
956
+		} else {
957
+			EE_Error::add_error(
958
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
959
+				__FILE__,
960
+				__FUNCTION__,
961
+				__LINE__
962
+			);
963
+		}
964
+		if (defined('DOING_AJAX')) {
965
+			return $new_status;
966
+		}
967
+		$this->_redirect_after_action(false, '', '', $query_args, true);
968
+	}
969 969
 
970 970
 
971
-    /**
972
-     * This is toggles a single Check-in for the given registration and datetime.
973
-     *
974
-     * @param  int $REG_ID The registration we're toggling
975
-     * @param  int $DTT_ID The datetime we're toggling
976
-     * @return int The new status toggled to.
977
-     * @throws EE_Error
978
-     * @throws InvalidArgumentException
979
-     * @throws InvalidDataTypeException
980
-     * @throws InvalidInterfaceException
981
-     */
982
-    private function _toggle_checkin($REG_ID, $DTT_ID)
983
-    {
984
-        /** @var EE_Registration $REG */
985
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
986
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
987
-        if ($new_status !== false) {
988
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
989
-        } else {
990
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
991
-            $new_status = false;
992
-        }
993
-        return $new_status;
994
-    }
971
+	/**
972
+	 * This is toggles a single Check-in for the given registration and datetime.
973
+	 *
974
+	 * @param  int $REG_ID The registration we're toggling
975
+	 * @param  int $DTT_ID The datetime we're toggling
976
+	 * @return int The new status toggled to.
977
+	 * @throws EE_Error
978
+	 * @throws InvalidArgumentException
979
+	 * @throws InvalidDataTypeException
980
+	 * @throws InvalidInterfaceException
981
+	 */
982
+	private function _toggle_checkin($REG_ID, $DTT_ID)
983
+	{
984
+		/** @var EE_Registration $REG */
985
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
986
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
987
+		if ($new_status !== false) {
988
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
989
+		} else {
990
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
991
+			$new_status = false;
992
+		}
993
+		return $new_status;
994
+	}
995 995
 
996 996
 
997
-    /**
998
-     * Takes care of deleting multiple EE_Checkin table rows
999
-     *
1000
-     * @access protected
1001
-     * @return void
1002
-     * @throws EE_Error
1003
-     * @throws InvalidArgumentException
1004
-     * @throws InvalidDataTypeException
1005
-     * @throws InvalidInterfaceException
1006
-     */
1007
-    protected function _delete_checkin_rows()
1008
-    {
1009
-        $query_args = array(
1010
-            'action'  => 'registration_checkins',
1011
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1012
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1013
-        );
1014
-        $errors = 0;
1015
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1016
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1017
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1018
-                    $errors++;
1019
-                }
1020
-            }
1021
-        } else {
1022
-            EE_Error::add_error(
1023
-                esc_html__(
1024
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1025
-                    'event_espresso'
1026
-                ),
1027
-                __FILE__,
1028
-                __FUNCTION__,
1029
-                __LINE__
1030
-            );
1031
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1032
-        }
1033
-        if ($errors > 0) {
1034
-            EE_Error::add_error(
1035
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1036
-                __FILE__,
1037
-                __FUNCTION__,
1038
-                __LINE__
1039
-            );
1040
-        } else {
1041
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1042
-        }
1043
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1044
-    }
997
+	/**
998
+	 * Takes care of deleting multiple EE_Checkin table rows
999
+	 *
1000
+	 * @access protected
1001
+	 * @return void
1002
+	 * @throws EE_Error
1003
+	 * @throws InvalidArgumentException
1004
+	 * @throws InvalidDataTypeException
1005
+	 * @throws InvalidInterfaceException
1006
+	 */
1007
+	protected function _delete_checkin_rows()
1008
+	{
1009
+		$query_args = array(
1010
+			'action'  => 'registration_checkins',
1011
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1012
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1013
+		);
1014
+		$errors = 0;
1015
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1016
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1017
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1018
+					$errors++;
1019
+				}
1020
+			}
1021
+		} else {
1022
+			EE_Error::add_error(
1023
+				esc_html__(
1024
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1025
+					'event_espresso'
1026
+				),
1027
+				__FILE__,
1028
+				__FUNCTION__,
1029
+				__LINE__
1030
+			);
1031
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1032
+		}
1033
+		if ($errors > 0) {
1034
+			EE_Error::add_error(
1035
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1036
+				__FILE__,
1037
+				__FUNCTION__,
1038
+				__LINE__
1039
+			);
1040
+		} else {
1041
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1042
+		}
1043
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1044
+	}
1045 1045
 
1046 1046
 
1047
-    /**
1048
-     * Deletes a single EE_Checkin row
1049
-     *
1050
-     * @return void
1051
-     * @throws EE_Error
1052
-     * @throws InvalidArgumentException
1053
-     * @throws InvalidDataTypeException
1054
-     * @throws InvalidInterfaceException
1055
-     */
1056
-    protected function _delete_checkin_row()
1057
-    {
1058
-        $query_args = array(
1059
-            'action'  => 'registration_checkins',
1060
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1061
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1062
-        );
1063
-        if (! empty($this->_req_data['CHK_ID'])) {
1064
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1065
-                EE_Error::add_error(
1066
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1067
-                    __FILE__,
1068
-                    __FUNCTION__,
1069
-                    __LINE__
1070
-                );
1071
-            } else {
1072
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1073
-            }
1074
-        } else {
1075
-            EE_Error::add_error(
1076
-                esc_html__(
1077
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1078
-                    'event_espresso'
1079
-                ),
1080
-                __FILE__,
1081
-                __FUNCTION__,
1082
-                __LINE__
1083
-            );
1084
-        }
1085
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1086
-    }
1047
+	/**
1048
+	 * Deletes a single EE_Checkin row
1049
+	 *
1050
+	 * @return void
1051
+	 * @throws EE_Error
1052
+	 * @throws InvalidArgumentException
1053
+	 * @throws InvalidDataTypeException
1054
+	 * @throws InvalidInterfaceException
1055
+	 */
1056
+	protected function _delete_checkin_row()
1057
+	{
1058
+		$query_args = array(
1059
+			'action'  => 'registration_checkins',
1060
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1061
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1062
+		);
1063
+		if (! empty($this->_req_data['CHK_ID'])) {
1064
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1065
+				EE_Error::add_error(
1066
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1067
+					__FILE__,
1068
+					__FUNCTION__,
1069
+					__LINE__
1070
+				);
1071
+			} else {
1072
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1073
+			}
1074
+		} else {
1075
+			EE_Error::add_error(
1076
+				esc_html__(
1077
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1078
+					'event_espresso'
1079
+				),
1080
+				__FILE__,
1081
+				__FUNCTION__,
1082
+				__LINE__
1083
+			);
1084
+		}
1085
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1086
+	}
1087 1087
 
1088 1088
 
1089
-    /**
1090
-     *        generates HTML for the Event Registrations List Table
1091
-     *
1092
-     * @access protected
1093
-     * @return void
1094
-     * @throws EE_Error
1095
-     * @throws InvalidArgumentException
1096
-     * @throws InvalidDataTypeException
1097
-     * @throws InvalidInterfaceException
1098
-     */
1099
-    protected function _event_registrations_list_table()
1100
-    {
1101
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1102
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1103
-            ? $this->get_action_link_or_button(
1104
-                'new_registration',
1105
-                'add-registrant',
1106
-                array('event_id' => $this->_req_data['event_id']),
1107
-                'add-new-h2',
1108
-                '',
1109
-                false
1110
-            )
1111
-            : '';
1112
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1113
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1114
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1115
-        $legend_items = array(
1116
-            'star-icon'        => array(
1117
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1118
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1119
-            ),
1120
-            'checkin'          => array(
1121
-                'class' => $checked_in->cssClasses(),
1122
-                'desc'  => $checked_in->legendLabel(),
1123
-            ),
1124
-            'checkout'         => array(
1125
-                'class' => $checked_out->cssClasses(),
1126
-                'desc'  => $checked_out->legendLabel(),
1127
-            ),
1128
-            'nocheckinrecord'  => array(
1129
-                'class' => $checked_never->cssClasses(),
1130
-                'desc'  => $checked_never->legendLabel(),
1131
-            ),
1132
-            'approved_status'  => array(
1133
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1134
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1135
-            ),
1136
-            'cancelled_status' => array(
1137
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1138
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1139
-            ),
1140
-            'declined_status'  => array(
1141
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1142
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1143
-            ),
1144
-            'not_approved'     => array(
1145
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1146
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1147
-            ),
1148
-            'pending_status'   => array(
1149
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1150
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1151
-            ),
1152
-            'wait_list'        => array(
1153
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1154
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1155
-            ),
1156
-        );
1157
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1158
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1159
-        $this->_template_args['before_list_table'] = ! empty($event_id)
1160
-            ? '<h2>' . sprintf(
1161
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1162
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1163
-            ) . '</h2>'
1164
-            : '';
1165
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1166
-        // the event.
1167
-        /** @var EE_Event $event */
1168
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1169
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1170
-        $datetime = null;
1171
-        if ($event instanceof EE_Event) {
1172
-            $datetimes_on_event = $event->datetimes();
1173
-            if (count($datetimes_on_event) === 1) {
1174
-                $datetime = reset($datetimes_on_event);
1175
-            }
1176
-        }
1177
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1178
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1179
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1180
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1181
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1182
-            $this->_template_args['before_list_table'] .= $datetime->name();
1183
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1184
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1185
-        }
1186
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1187
-        // column represents
1188
-        if (! $datetime instanceof EE_Datetime) {
1189
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1190
-                                                          . esc_html__(
1191
-                                                              'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1192
-                                                              'event_espresso'
1193
-                                                          )
1194
-                                                          . '</p>';
1195
-        }
1196
-        $this->display_admin_list_table_page_with_no_sidebar();
1197
-    }
1089
+	/**
1090
+	 *        generates HTML for the Event Registrations List Table
1091
+	 *
1092
+	 * @access protected
1093
+	 * @return void
1094
+	 * @throws EE_Error
1095
+	 * @throws InvalidArgumentException
1096
+	 * @throws InvalidDataTypeException
1097
+	 * @throws InvalidInterfaceException
1098
+	 */
1099
+	protected function _event_registrations_list_table()
1100
+	{
1101
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1102
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1103
+			? $this->get_action_link_or_button(
1104
+				'new_registration',
1105
+				'add-registrant',
1106
+				array('event_id' => $this->_req_data['event_id']),
1107
+				'add-new-h2',
1108
+				'',
1109
+				false
1110
+			)
1111
+			: '';
1112
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1113
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1114
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1115
+		$legend_items = array(
1116
+			'star-icon'        => array(
1117
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1118
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1119
+			),
1120
+			'checkin'          => array(
1121
+				'class' => $checked_in->cssClasses(),
1122
+				'desc'  => $checked_in->legendLabel(),
1123
+			),
1124
+			'checkout'         => array(
1125
+				'class' => $checked_out->cssClasses(),
1126
+				'desc'  => $checked_out->legendLabel(),
1127
+			),
1128
+			'nocheckinrecord'  => array(
1129
+				'class' => $checked_never->cssClasses(),
1130
+				'desc'  => $checked_never->legendLabel(),
1131
+			),
1132
+			'approved_status'  => array(
1133
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1134
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1135
+			),
1136
+			'cancelled_status' => array(
1137
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1138
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1139
+			),
1140
+			'declined_status'  => array(
1141
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1142
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1143
+			),
1144
+			'not_approved'     => array(
1145
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1146
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1147
+			),
1148
+			'pending_status'   => array(
1149
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1150
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1151
+			),
1152
+			'wait_list'        => array(
1153
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1154
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1155
+			),
1156
+		);
1157
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1158
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1159
+		$this->_template_args['before_list_table'] = ! empty($event_id)
1160
+			? '<h2>' . sprintf(
1161
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1162
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1163
+			) . '</h2>'
1164
+			: '';
1165
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1166
+		// the event.
1167
+		/** @var EE_Event $event */
1168
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1169
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1170
+		$datetime = null;
1171
+		if ($event instanceof EE_Event) {
1172
+			$datetimes_on_event = $event->datetimes();
1173
+			if (count($datetimes_on_event) === 1) {
1174
+				$datetime = reset($datetimes_on_event);
1175
+			}
1176
+		}
1177
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1178
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1179
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1180
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1181
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1182
+			$this->_template_args['before_list_table'] .= $datetime->name();
1183
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1184
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1185
+		}
1186
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1187
+		// column represents
1188
+		if (! $datetime instanceof EE_Datetime) {
1189
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1190
+														  . esc_html__(
1191
+															  'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1192
+															  'event_espresso'
1193
+														  )
1194
+														  . '</p>';
1195
+		}
1196
+		$this->display_admin_list_table_page_with_no_sidebar();
1197
+	}
1198 1198
 
1199
-    /**
1200
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1201
-     * conditions)
1202
-     *
1203
-     * @return void ends the request by a redirect or download
1204
-     */
1205
-    public function _registrations_checkin_report()
1206
-    {
1207
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1208
-    }
1199
+	/**
1200
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1201
+	 * conditions)
1202
+	 *
1203
+	 * @return void ends the request by a redirect or download
1204
+	 */
1205
+	public function _registrations_checkin_report()
1206
+	{
1207
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1208
+	}
1209 1209
 
1210
-    /**
1211
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1212
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1213
-     *
1214
-     * @param array $request
1215
-     * @param int   $per_page
1216
-     * @param bool  $count
1217
-     * @return array
1218
-     * @throws EE_Error
1219
-     */
1220
-    protected function _get_checkin_query_params_from_request(
1221
-        $request,
1222
-        $per_page = 10,
1223
-        $count = false
1224
-    ) {
1225
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1226
-        // unlike the regular registrations list table,
1227
-        $status_ids_array = apply_filters(
1228
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1229
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1230
-        );
1231
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1232
-        return $query_params;
1233
-    }
1210
+	/**
1211
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1212
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1213
+	 *
1214
+	 * @param array $request
1215
+	 * @param int   $per_page
1216
+	 * @param bool  $count
1217
+	 * @return array
1218
+	 * @throws EE_Error
1219
+	 */
1220
+	protected function _get_checkin_query_params_from_request(
1221
+		$request,
1222
+		$per_page = 10,
1223
+		$count = false
1224
+	) {
1225
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1226
+		// unlike the regular registrations list table,
1227
+		$status_ids_array = apply_filters(
1228
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1229
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1230
+		);
1231
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1232
+		return $query_params;
1233
+	}
1234 1234
 
1235 1235
 
1236
-    /**
1237
-     * Gets registrations for an event
1238
-     *
1239
-     * @param int    $per_page
1240
-     * @param bool   $count whether to return count or data.
1241
-     * @param bool   $trash
1242
-     * @param string $orderby
1243
-     * @return EE_Registration[]|int
1244
-     * @throws EE_Error
1245
-     * @throws InvalidArgumentException
1246
-     * @throws InvalidDataTypeException
1247
-     * @throws InvalidInterfaceException
1248
-     */
1249
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1250
-    {
1251
-        // normalize some request params that get setup by the parent `get_registrations` method.
1252
-        $request = $this->_req_data;
1253
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1254
-        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1255
-        if ($trash) {
1256
-            $request['status'] = 'trash';
1257
-        }
1258
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1259
-        /**
1260
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
-         *
1262
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
-         *                             or if you have the development copy of EE you can view this at the path:
1265
-         *                             /docs/G--Model-System/model-query-params.md
1266
-         */
1267
-        $query_params['group_by'] = '';
1236
+	/**
1237
+	 * Gets registrations for an event
1238
+	 *
1239
+	 * @param int    $per_page
1240
+	 * @param bool   $count whether to return count or data.
1241
+	 * @param bool   $trash
1242
+	 * @param string $orderby
1243
+	 * @return EE_Registration[]|int
1244
+	 * @throws EE_Error
1245
+	 * @throws InvalidArgumentException
1246
+	 * @throws InvalidDataTypeException
1247
+	 * @throws InvalidInterfaceException
1248
+	 */
1249
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1250
+	{
1251
+		// normalize some request params that get setup by the parent `get_registrations` method.
1252
+		$request = $this->_req_data;
1253
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1254
+		$request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1255
+		if ($trash) {
1256
+			$request['status'] = 'trash';
1257
+		}
1258
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1259
+		/**
1260
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
+		 *
1262
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
+		 *                             or if you have the development copy of EE you can view this at the path:
1265
+		 *                             /docs/G--Model-System/model-query-params.md
1266
+		 */
1267
+		$query_params['group_by'] = '';
1268 1268
 
1269
-        return $count
1270
-            ? EEM_Registration::instance()->count($query_params)
1271
-            /** @type EE_Registration[] */
1272
-            : EEM_Registration::instance()->get_all($query_params);
1273
-    }
1269
+		return $count
1270
+			? EEM_Registration::instance()->count($query_params)
1271
+			/** @type EE_Registration[] */
1272
+			: EEM_Registration::instance()->get_all($query_params);
1273
+	}
1274 1274
 }
Please login to merge, or discard this patch.